Source
/*
* max8660.c -- Voltage regulation for the Maxim 8660/8661
*
* based on max1586.c and wm8400-regulator.c
*
* Copyright (C) 2009 Wolfram Sang, Pengutronix e.K.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*
* Some info:
*
* Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX8660-MAX8661.pdf
*
* This chip is a bit nasty because it is a write-only device. Thus, the driver
* uses shadow registers to keep track of its values. The main problem appears
* to be the initialization: When Linux boots up, we cannot know if the chip is
* in the default state or not, so we would have to pass such information in
* platform_data. As this adds a bit of complexity to the driver, this is left
* out for now until it is really needed.
*
* [A|S|M]DTV1 registers are currently not used, but [A|S|M]DTV2.
*
* If the driver is feature complete, it might be worth to check if one set of
* functions for V3-V7 is sufficient. For maximum flexibility during
* development, they are separated for now.
*
*/
enum {
MAX8660_OVER1,
MAX8660_OVER2,
MAX8660_VCC1,
MAX8660_ADTV1,
MAX8660_ADTV2,
MAX8660_SDTV1,
MAX8660_SDTV2,
MAX8660_MDTV1,
MAX8660_MDTV2,
MAX8660_L12VCR,
MAX8660_FPWM,
MAX8660_N_REGS, /* not a real register */
};
struct max8660 {
struct i2c_client *client;
u8 shadow_regs[MAX8660_N_REGS]; /* as chip is write only */
};
static int max8660_write(struct max8660 *max8660, u8 reg, u8 mask, u8 val)
{
static const u8 max8660_addresses[MAX8660_N_REGS] = {
0x10, 0x12, 0x20, 0x23, 0x24, 0x29, 0x2a, 0x32, 0x33, 0x39, 0x80
};
int ret;