40 #include <linux/module.h>
42 #include <linux/i2c.h>
45 #include <linux/slab.h>
48 #define MAX8660_DCDC_MIN_UV 725000
49 #define MAX8660_DCDC_MAX_UV 1800000
50 #define MAX8660_DCDC_STEP 25000
51 #define MAX8660_DCDC_MAX_SEL 0x2b
53 #define MAX8660_LDO5_MIN_UV 1700000
54 #define MAX8660_LDO5_MAX_UV 2000000
55 #define MAX8660_LDO5_STEP 25000
56 #define MAX8660_LDO5_MAX_SEL 0x0c
58 #define MAX8660_LDO67_MIN_UV 1800000
59 #define MAX8660_LDO67_MAX_UV 3300000
60 #define MAX8660_LDO67_STEP 100000
61 #define MAX8660_LDO67_MAX_SEL 0x0f
87 { 0x10, 0x12, 0x20, 0x23, 0x24, 0x29, 0x2a, 0x32, 0x33, 0x39, 0x80 };
92 max8660_addresses[reg], reg_val);
95 max8660_addresses[reg], reg_val);
112 return !!(val &
mask);
146 ret = max8660_write(max8660, reg, 0, selector);
152 return max8660_write(max8660,
MAX8660_VCC1, 0xff, bits);
156 .is_enabled = max8660_dcdc_is_enabled,
159 .set_voltage_sel = max8660_dcdc_set_voltage_sel,
160 .get_voltage_sel = max8660_dcdc_get_voltage_sel,
168 static int max8660_ldo5_get_voltage_sel(
struct regulator_dev *rdev)
176 static int max8660_ldo5_set_voltage_sel(
struct regulator_dev *rdev,
177 unsigned int selector)
187 return max8660_write(max8660,
MAX8660_VCC1, 0xff, 0xc0);
193 .set_voltage_sel = max8660_ldo5_set_voltage_sel,
194 .get_voltage_sel = max8660_ldo5_get_voltage_sel,
202 static int max8660_ldo67_is_enabled(
struct regulator_dev *rdev)
207 return !!(val &
mask);
224 static int max8660_ldo67_get_voltage_sel(
struct regulator_dev *rdev)
233 static int max8660_ldo67_set_voltage_sel(
struct regulator_dev *rdev,
234 unsigned int selector)
246 .is_enabled = max8660_ldo67_is_enabled,
247 .enable = max8660_ldo67_enable,
248 .disable = max8660_ldo67_disable,
251 .get_voltage_sel = max8660_ldo67_get_voltage_sel,
252 .set_voltage_sel = max8660_ldo67_set_voltage_sel,
259 .ops = &max8660_dcdc_ops,
269 .ops = &max8660_dcdc_ops,
279 .ops = &max8660_ldo5_ops,
289 .ops = &max8660_ldo67_ops,
299 .ops = &max8660_ldo67_ops,
314 struct max8660 *max8660;
318 dev_err(&client->
dev,
"Too many regulators found!\n");
329 rdev = max8660->
rdev;
336 max8660_dcdc_ops.
enable = max8660_dcdc_enable;
337 max8660_dcdc_ops.
disable = max8660_dcdc_disable;
354 if (!pdata->
subdevs[i].platform_data)
357 boot_on = pdata->
subdevs[
i].platform_data->constraints.boot_on;
359 switch (pdata->
subdevs[i].id) {
380 dev_err(&client->
dev,
"Regulator not on this chip!\n");
389 dev_err(&client->
dev,
"invalid regulator %s\n",
400 config.
dev = &client->
dev;
405 if (IS_ERR(rdev[i])) {
406 ret = PTR_ERR(rdev[i]);
407 dev_err(&client->
dev,
"failed to register %s\n",
408 max8660_reg[
id].
name);
413 i2c_set_clientdata(client, max8660);
425 struct max8660 *max8660 = i2c_get_clientdata(client);
429 if (max8660->
rdev[i])
442 .probe = max8660_probe,
448 .id_table = max8660_id,
451 static int __init max8660_init(
void)
453 return i2c_add_driver(&max8660_driver);
457 static void __exit max8660_exit(
void)