20 #include <linux/module.h>
22 #include <linux/i2c.h>
25 #include <linux/slab.h>
28 #define MAX1586_V3_MAX_VSEL 31
29 #define MAX1586_V6_MAX_VSEL 3
31 #define MAX1586_V3_MIN_UV 700000
32 #define MAX1586_V3_MAX_UV 1475000
34 #define MAX1586_V6_MIN_UV 0
35 #define MAX1586_V6_MAX_UV 3000000
37 #define I2C_V3_SELECT (0 << 5)
38 #define I2C_V6_SELECT (1 << 5)
56 static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
73 dev_dbg(&client->
dev,
"changing voltage v3 to %dmv\n",
80 static int max1586_v6_set_voltage_sel(
struct regulator_dev *rdev,
81 unsigned int selector)
86 dev_dbg(&client->
dev,
"changing voltage v6 to %dmv\n",
87 rdev->
desc->volt_table[selector] / 1000);
98 .set_voltage_sel = max1586_v3_set_voltage_sel,
104 .set_voltage_sel = max1586_v6_set_voltage_sel,
112 .ops = &max1586_v3_ops,
120 .ops = &max1586_v6_ops,
123 .volt_table = v6_voltages_uv,
151 rdev = max1586->
rdev;
154 if (!pdata->
subdevs[i].platform_data)
157 dev_err(&client->
dev,
"invalid regulator id %d\n",
id);
168 config.
dev = &client->
dev;
173 if (IS_ERR(rdev[i])) {
174 ret = PTR_ERR(rdev[i]);
175 dev_err(&client->
dev,
"failed to register %s\n",
176 max1586_reg[
id].
name);
181 i2c_set_clientdata(client, max1586);
182 dev_info(&client->
dev,
"Maxim 1586 regulator driver loaded\n");
193 struct max1586_data *max1586 = i2c_get_clientdata(client);
197 if (max1586->
rdev[i])
208 static struct i2c_driver max1586_pmic_driver = {
209 .probe = max1586_pmic_probe,
215 .id_table = max1586_id,
218 static int __init max1586_pmic_init(
void)
220 return i2c_add_driver(&max1586_pmic_driver);
224 static void __exit max1586_pmic_exit(
void)