Commit 4faa54e5 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'regulator/topic/max1586',...

Merge remote-tracking branches 'regulator/topic/max1586', 'regulator/topic/max77686', 'regulator/topic/max77693', 'regulator/topic/max8649', 'regulator/topic/max8660', 'regulator/topic/max8907', 'regulator/topic/max8925' and 'regulator/topic/max8952' into regulator-next
...@@ -46,8 +46,6 @@ struct max1586_data { ...@@ -46,8 +46,6 @@ struct max1586_data {
unsigned int v3_curr_sel; unsigned int v3_curr_sel;
unsigned int v6_curr_sel; unsigned int v6_curr_sel;
struct regulator_dev *rdev[0];
}; };
/* /*
...@@ -162,14 +160,12 @@ static struct regulator_desc max1586_reg[] = { ...@@ -162,14 +160,12 @@ static struct regulator_desc max1586_reg[] = {
static int max1586_pmic_probe(struct i2c_client *client, static int max1586_pmic_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id) const struct i2c_device_id *i2c_id)
{ {
struct regulator_dev **rdev;
struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); struct max1586_platform_data *pdata = dev_get_platdata(&client->dev);
struct regulator_config config = { }; struct regulator_config config = { };
struct max1586_data *max1586; struct max1586_data *max1586;
int i, id; int i, id;
max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data),
sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
GFP_KERNEL); GFP_KERNEL);
if (!max1586) if (!max1586)
return -ENOMEM; return -ENOMEM;
...@@ -186,8 +182,9 @@ static int max1586_pmic_probe(struct i2c_client *client, ...@@ -186,8 +182,9 @@ static int max1586_pmic_probe(struct i2c_client *client,
max1586->v3_curr_sel = 24; /* 1.3V */ max1586->v3_curr_sel = 24; /* 1.3V */
max1586->v6_curr_sel = 0; max1586->v6_curr_sel = 0;
rdev = max1586->rdev;
for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) { for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) {
struct regulator_dev *rdev;
id = pdata->subdevs[i].id; id = pdata->subdevs[i].id;
if (!pdata->subdevs[i].platform_data) if (!pdata->subdevs[i].platform_data)
continue; continue;
...@@ -207,12 +204,12 @@ static int max1586_pmic_probe(struct i2c_client *client, ...@@ -207,12 +204,12 @@ static int max1586_pmic_probe(struct i2c_client *client,
config.init_data = pdata->subdevs[i].platform_data; config.init_data = pdata->subdevs[i].platform_data;
config.driver_data = max1586; config.driver_data = max1586;
rdev[i] = devm_regulator_register(&client->dev, rdev = devm_regulator_register(&client->dev,
&max1586_reg[id], &config); &max1586_reg[id], &config);
if (IS_ERR(rdev[i])) { if (IS_ERR(rdev)) {
dev_err(&client->dev, "failed to register %s\n", dev_err(&client->dev, "failed to register %s\n",
max1586_reg[id].name); max1586_reg[id].name);
return PTR_ERR(rdev[i]); return PTR_ERR(rdev);
} }
} }
......
...@@ -65,7 +65,6 @@ enum max77686_ramp_rate { ...@@ -65,7 +65,6 @@ enum max77686_ramp_rate {
}; };
struct max77686_data { struct max77686_data {
struct regulator_dev *rdev[MAX77686_REGULATORS];
unsigned int opmode[MAX77686_REGULATORS]; unsigned int opmode[MAX77686_REGULATORS];
}; };
...@@ -400,7 +399,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, ...@@ -400,7 +399,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
unsigned int i; unsigned int i;
pmic_np = iodev->dev->of_node; pmic_np = iodev->dev->of_node;
regulators_np = of_find_node_by_name(pmic_np, "voltage-regulators"); regulators_np = of_get_child_by_name(pmic_np, "voltage-regulators");
if (!regulators_np) { if (!regulators_np) {
dev_err(&pdev->dev, "could not find regulators sub-node\n"); dev_err(&pdev->dev, "could not find regulators sub-node\n");
return -EINVAL; return -EINVAL;
...@@ -410,8 +409,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, ...@@ -410,8 +409,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
pdata->num_regulators, GFP_KERNEL); pdata->num_regulators, GFP_KERNEL);
if (!rdata) { if (!rdata) {
dev_err(&pdev->dev, of_node_put(regulators_np);
"could not allocate memory for regulator data\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -425,6 +423,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev, ...@@ -425,6 +423,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
} }
pdata->regulators = rdata; pdata->regulators = rdata;
of_node_put(regulators_np);
return 0; return 0;
} }
...@@ -474,16 +473,18 @@ static int max77686_pmic_probe(struct platform_device *pdev) ...@@ -474,16 +473,18 @@ static int max77686_pmic_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, max77686); platform_set_drvdata(pdev, max77686);
for (i = 0; i < MAX77686_REGULATORS; i++) { for (i = 0; i < MAX77686_REGULATORS; i++) {
struct regulator_dev *rdev;
config.init_data = pdata->regulators[i].initdata; config.init_data = pdata->regulators[i].initdata;
config.of_node = pdata->regulators[i].of_node; config.of_node = pdata->regulators[i].of_node;
max77686->opmode[i] = regulators[i].enable_mask; max77686->opmode[i] = regulators[i].enable_mask;
max77686->rdev[i] = devm_regulator_register(&pdev->dev, rdev = devm_regulator_register(&pdev->dev,
&regulators[i], &config); &regulators[i], &config);
if (IS_ERR(max77686->rdev[i])) { if (IS_ERR(rdev)) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"regulator init failed for %d\n", i); "regulator init failed for %d\n", i);
return PTR_ERR(max77686->rdev[i]); return PTR_ERR(rdev);
} }
} }
......
...@@ -34,13 +34,6 @@ ...@@ -34,13 +34,6 @@
#define CHGIN_ILIM_STEP_20mA 20000 #define CHGIN_ILIM_STEP_20mA 20000
struct max77693_pmic_dev {
struct device *dev;
struct max77693_dev *iodev;
int num_regulators;
struct regulator_dev **rdev;
};
/* CHARGER regulator ops */ /* CHARGER regulator ops */
/* CHARGER regulator uses two bits for enabling */ /* CHARGER regulator uses two bits for enabling */
static int max77693_chg_is_enabled(struct regulator_dev *rdev) static int max77693_chg_is_enabled(struct regulator_dev *rdev)
...@@ -170,19 +163,22 @@ static int max77693_pmic_dt_parse_rdata(struct device *dev, ...@@ -170,19 +163,22 @@ static int max77693_pmic_dt_parse_rdata(struct device *dev,
struct max77693_regulator_data *tmp; struct max77693_regulator_data *tmp;
int i, matched = 0; int i, matched = 0;
np = of_find_node_by_name(dev->parent->of_node, "regulators"); np = of_get_child_by_name(dev->parent->of_node, "regulators");
if (!np) if (!np)
return -EINVAL; return -EINVAL;
rmatch = devm_kzalloc(dev, rmatch = devm_kzalloc(dev,
sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL); sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL);
if (!rmatch) if (!rmatch) {
of_node_put(np);
return -ENOMEM; return -ENOMEM;
}
for (i = 0; i < ARRAY_SIZE(regulators); i++) for (i = 0; i < ARRAY_SIZE(regulators); i++)
rmatch[i].name = regulators[i].name; rmatch[i].name = regulators[i].name;
matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators)); matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators));
of_node_put(np);
if (matched <= 0) if (matched <= 0)
return matched; return matched;
*rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL); *rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL);
...@@ -229,7 +225,6 @@ static int max77693_pmic_init_rdata(struct device *dev, ...@@ -229,7 +225,6 @@ static int max77693_pmic_init_rdata(struct device *dev,
static int max77693_pmic_probe(struct platform_device *pdev) static int max77693_pmic_probe(struct platform_device *pdev)
{ {
struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct max77693_pmic_dev *max77693_pmic;
struct max77693_regulator_data *rdata = NULL; struct max77693_regulator_data *rdata = NULL;
int num_rdata, i; int num_rdata, i;
struct regulator_config config; struct regulator_config config;
...@@ -240,39 +235,22 @@ static int max77693_pmic_probe(struct platform_device *pdev) ...@@ -240,39 +235,22 @@ static int max77693_pmic_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
max77693_pmic = devm_kzalloc(&pdev->dev,
sizeof(struct max77693_pmic_dev),
GFP_KERNEL);
if (!max77693_pmic)
return -ENOMEM;
max77693_pmic->rdev = devm_kzalloc(&pdev->dev,
sizeof(struct regulator_dev *) * num_rdata,
GFP_KERNEL);
if (!max77693_pmic->rdev)
return -ENOMEM;
max77693_pmic->dev = &pdev->dev;
max77693_pmic->iodev = iodev;
max77693_pmic->num_regulators = num_rdata;
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.regmap = iodev->regmap; config.regmap = iodev->regmap;
config.driver_data = max77693_pmic;
platform_set_drvdata(pdev, max77693_pmic);
for (i = 0; i < max77693_pmic->num_regulators; i++) { for (i = 0; i < num_rdata; i++) {
int id = rdata[i].id; int id = rdata[i].id;
struct regulator_dev *rdev;
config.init_data = rdata[i].initdata; config.init_data = rdata[i].initdata;
config.of_node = rdata[i].of_node; config.of_node = rdata[i].of_node;
max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev, rdev = devm_regulator_register(&pdev->dev,
&regulators[id], &config); &regulators[id], &config);
if (IS_ERR(max77693_pmic->rdev[i])) { if (IS_ERR(rdev)) {
dev_err(max77693_pmic->dev, dev_err(&pdev->dev,
"Failed to initialize regulator-%d\n", id); "Failed to initialize regulator-%d\n", id);
return PTR_ERR(max77693_pmic->rdev[i]); return PTR_ERR(rdev);
} }
} }
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#define MAX8649_RAMP_DOWN (1 << 1) #define MAX8649_RAMP_DOWN (1 << 1)
struct max8649_regulator_info { struct max8649_regulator_info {
struct regulator_dev *regulator;
struct device *dev; struct device *dev;
struct regmap *regmap; struct regmap *regmap;
...@@ -154,6 +153,7 @@ static int max8649_regulator_probe(struct i2c_client *client, ...@@ -154,6 +153,7 @@ static int max8649_regulator_probe(struct i2c_client *client,
{ {
struct max8649_platform_data *pdata = dev_get_platdata(&client->dev); struct max8649_platform_data *pdata = dev_get_platdata(&client->dev);
struct max8649_regulator_info *info = NULL; struct max8649_regulator_info *info = NULL;
struct regulator_dev *regulator;
struct regulator_config config = { }; struct regulator_config config = { };
unsigned int val; unsigned int val;
unsigned char data; unsigned char data;
...@@ -234,12 +234,12 @@ static int max8649_regulator_probe(struct i2c_client *client, ...@@ -234,12 +234,12 @@ static int max8649_regulator_probe(struct i2c_client *client,
config.driver_data = info; config.driver_data = info;
config.regmap = info->regmap; config.regmap = info->regmap;
info->regulator = devm_regulator_register(&client->dev, &dcdc_desc, regulator = devm_regulator_register(&client->dev, &dcdc_desc,
&config); &config);
if (IS_ERR(info->regulator)) { if (IS_ERR(regulator)) {
dev_err(info->dev, "failed to register regulator %s\n", dev_err(info->dev, "failed to register regulator %s\n",
dcdc_desc.name); dcdc_desc.name);
return PTR_ERR(info->regulator); return PTR_ERR(regulator);
} }
return 0; return 0;
......
...@@ -81,16 +81,17 @@ enum { ...@@ -81,16 +81,17 @@ enum {
struct max8660 { struct max8660 {
struct i2c_client *client; struct i2c_client *client;
u8 shadow_regs[MAX8660_N_REGS]; /* as chip is write only */ u8 shadow_regs[MAX8660_N_REGS]; /* as chip is write only */
struct regulator_dev *rdev[];
}; };
static int max8660_write(struct max8660 *max8660, u8 reg, u8 mask, u8 val) static int max8660_write(struct max8660 *max8660, u8 reg, u8 mask, u8 val)
{ {
static const u8 max8660_addresses[MAX8660_N_REGS] = static const u8 max8660_addresses[MAX8660_N_REGS] = {
{ 0x10, 0x12, 0x20, 0x23, 0x24, 0x29, 0x2a, 0x32, 0x33, 0x39, 0x80 }; 0x10, 0x12, 0x20, 0x23, 0x24, 0x29, 0x2a, 0x32, 0x33, 0x39, 0x80
};
int ret; int ret;
u8 reg_val = (max8660->shadow_regs[reg] & mask) | val; u8 reg_val = (max8660->shadow_regs[reg] & mask) | val;
dev_vdbg(&max8660->client->dev, "Writing reg %02x with %02x\n", dev_vdbg(&max8660->client->dev, "Writing reg %02x with %02x\n",
max8660_addresses[reg], reg_val); max8660_addresses[reg], reg_val);
...@@ -112,6 +113,7 @@ static int max8660_dcdc_is_enabled(struct regulator_dev *rdev) ...@@ -112,6 +113,7 @@ static int max8660_dcdc_is_enabled(struct regulator_dev *rdev)
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 val = max8660->shadow_regs[MAX8660_OVER1]; u8 val = max8660->shadow_regs[MAX8660_OVER1];
u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4; u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;
return !!(val & mask); return !!(val & mask);
} }
...@@ -119,6 +121,7 @@ static int max8660_dcdc_enable(struct regulator_dev *rdev) ...@@ -119,6 +121,7 @@ static int max8660_dcdc_enable(struct regulator_dev *rdev)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 bit = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4; u8 bit = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;
return max8660_write(max8660, MAX8660_OVER1, 0xff, bit); return max8660_write(max8660, MAX8660_OVER1, 0xff, bit);
} }
...@@ -126,15 +129,16 @@ static int max8660_dcdc_disable(struct regulator_dev *rdev) ...@@ -126,15 +129,16 @@ static int max8660_dcdc_disable(struct regulator_dev *rdev)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? ~1 : ~4; u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? ~1 : ~4;
return max8660_write(max8660, MAX8660_OVER1, mask, 0); return max8660_write(max8660, MAX8660_OVER1, mask, 0);
} }
static int max8660_dcdc_get_voltage_sel(struct regulator_dev *rdev) static int max8660_dcdc_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2; u8 reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2;
u8 selector = max8660->shadow_regs[reg]; u8 selector = max8660->shadow_regs[reg];
return selector; return selector;
} }
...@@ -207,6 +211,7 @@ static int max8660_ldo67_is_enabled(struct regulator_dev *rdev) ...@@ -207,6 +211,7 @@ static int max8660_ldo67_is_enabled(struct regulator_dev *rdev)
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 val = max8660->shadow_regs[MAX8660_OVER2]; u8 val = max8660->shadow_regs[MAX8660_OVER2];
u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4; u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;
return !!(val & mask); return !!(val & mask);
} }
...@@ -214,6 +219,7 @@ static int max8660_ldo67_enable(struct regulator_dev *rdev) ...@@ -214,6 +219,7 @@ static int max8660_ldo67_enable(struct regulator_dev *rdev)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 bit = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4; u8 bit = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;
return max8660_write(max8660, MAX8660_OVER2, 0xff, bit); return max8660_write(max8660, MAX8660_OVER2, 0xff, bit);
} }
...@@ -221,15 +227,16 @@ static int max8660_ldo67_disable(struct regulator_dev *rdev) ...@@ -221,15 +227,16 @@ static int max8660_ldo67_disable(struct regulator_dev *rdev)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? ~2 : ~4; u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? ~2 : ~4;
return max8660_write(max8660, MAX8660_OVER2, mask, 0); return max8660_write(max8660, MAX8660_OVER2, mask, 0);
} }
static int max8660_ldo67_get_voltage_sel(struct regulator_dev *rdev) static int max8660_ldo67_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct max8660 *max8660 = rdev_get_drvdata(rdev); struct max8660 *max8660 = rdev_get_drvdata(rdev);
u8 shift = (rdev_get_id(rdev) == MAX8660_V6) ? 0 : 4; u8 shift = (rdev_get_id(rdev) == MAX8660_V6) ? 0 : 4;
u8 selector = (max8660->shadow_regs[MAX8660_L12VCR] >> shift) & 0xf; u8 selector = (max8660->shadow_regs[MAX8660_L12VCR] >> shift) & 0xf;
return selector; return selector;
} }
...@@ -330,7 +337,7 @@ static int max8660_pdata_from_dt(struct device *dev, ...@@ -330,7 +337,7 @@ static int max8660_pdata_from_dt(struct device *dev,
struct max8660_subdev_data *sub; struct max8660_subdev_data *sub;
struct of_regulator_match rmatch[ARRAY_SIZE(max8660_reg)]; struct of_regulator_match rmatch[ARRAY_SIZE(max8660_reg)];
np = of_find_node_by_name(dev->of_node, "regulators"); np = of_get_child_by_name(dev->of_node, "regulators");
if (!np) { if (!np) {
dev_err(dev, "missing 'regulators' subnode in DT\n"); dev_err(dev, "missing 'regulators' subnode in DT\n");
return -EINVAL; return -EINVAL;
...@@ -340,6 +347,7 @@ static int max8660_pdata_from_dt(struct device *dev, ...@@ -340,6 +347,7 @@ static int max8660_pdata_from_dt(struct device *dev,
rmatch[i].name = max8660_reg[i].name; rmatch[i].name = max8660_reg[i].name;
matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(rmatch)); matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(rmatch));
of_node_put(np);
if (matched <= 0) if (matched <= 0)
return matched; return matched;
...@@ -373,7 +381,6 @@ static inline int max8660_pdata_from_dt(struct device *dev, ...@@ -373,7 +381,6 @@ static inline int max8660_pdata_from_dt(struct device *dev,
static int max8660_probe(struct i2c_client *client, static int max8660_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id) const struct i2c_device_id *i2c_id)
{ {
struct regulator_dev **rdev;
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct max8660_platform_data *pdata = dev_get_platdata(dev); struct max8660_platform_data *pdata = dev_get_platdata(dev);
struct regulator_config config = { }; struct regulator_config config = { };
...@@ -406,14 +413,11 @@ static int max8660_probe(struct i2c_client *client, ...@@ -406,14 +413,11 @@ static int max8660_probe(struct i2c_client *client,
return -EINVAL; return -EINVAL;
} }
max8660 = devm_kzalloc(dev, sizeof(struct max8660) + max8660 = devm_kzalloc(dev, sizeof(struct max8660), GFP_KERNEL);
sizeof(struct regulator_dev *) * MAX8660_V_END,
GFP_KERNEL);
if (!max8660) if (!max8660)
return -ENOMEM; return -ENOMEM;
max8660->client = client; max8660->client = client;
rdev = max8660->rdev;
if (pdata->en34_is_high) { if (pdata->en34_is_high) {
/* Simulate always on */ /* Simulate always on */
...@@ -481,6 +485,7 @@ static int max8660_probe(struct i2c_client *client, ...@@ -481,6 +485,7 @@ static int max8660_probe(struct i2c_client *client,
/* Finally register devices */ /* Finally register devices */
for (i = 0; i < pdata->num_subdevs; i++) { for (i = 0; i < pdata->num_subdevs; i++) {
struct regulator_dev *rdev;
id = pdata->subdevs[i].id; id = pdata->subdevs[i].id;
...@@ -489,13 +494,13 @@ static int max8660_probe(struct i2c_client *client, ...@@ -489,13 +494,13 @@ static int max8660_probe(struct i2c_client *client,
config.of_node = of_node[i]; config.of_node = of_node[i];
config.driver_data = max8660; config.driver_data = max8660;
rdev[i] = devm_regulator_register(&client->dev, rdev = devm_regulator_register(&client->dev,
&max8660_reg[id], &config); &max8660_reg[id], &config);
if (IS_ERR(rdev[i])) { if (IS_ERR(rdev)) {
ret = PTR_ERR(rdev[i]); ret = PTR_ERR(rdev);
dev_err(&client->dev, "failed to register %s\n", dev_err(&client->dev, "failed to register %s\n",
max8660_reg[id].name); max8660_reg[id].name);
return PTR_ERR(rdev[i]); return PTR_ERR(rdev);
} }
} }
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
struct max8907_regulator { struct max8907_regulator {
struct regulator_desc desc[MAX8907_NUM_REGULATORS]; struct regulator_desc desc[MAX8907_NUM_REGULATORS];
struct regulator_dev *rdev[MAX8907_NUM_REGULATORS];
}; };
#define REG_MBATT() \ #define REG_MBATT() \
...@@ -231,7 +230,7 @@ static int max8907_regulator_parse_dt(struct platform_device *pdev) ...@@ -231,7 +230,7 @@ static int max8907_regulator_parse_dt(struct platform_device *pdev)
if (!np) if (!np)
return 0; return 0;
regulators = of_find_node_by_name(np, "regulators"); regulators = of_get_child_by_name(np, "regulators");
if (!regulators) { if (!regulators) {
dev_err(&pdev->dev, "regulators node not found\n"); dev_err(&pdev->dev, "regulators node not found\n");
return -EINVAL; return -EINVAL;
...@@ -292,10 +291,9 @@ static int max8907_regulator_probe(struct platform_device *pdev) ...@@ -292,10 +291,9 @@ static int max8907_regulator_probe(struct platform_device *pdev)
return ret; return ret;
pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
if (!pmic) { if (!pmic)
dev_err(&pdev->dev, "Failed to alloc pmic\n");
return -ENOMEM; return -ENOMEM;
}
platform_set_drvdata(pdev, pmic); platform_set_drvdata(pdev, pmic);
memcpy(pmic->desc, max8907_regulators, sizeof(pmic->desc)); memcpy(pmic->desc, max8907_regulators, sizeof(pmic->desc));
...@@ -311,6 +309,8 @@ static int max8907_regulator_probe(struct platform_device *pdev) ...@@ -311,6 +309,8 @@ static int max8907_regulator_probe(struct platform_device *pdev)
} }
for (i = 0; i < MAX8907_NUM_REGULATORS; i++) { for (i = 0; i < MAX8907_NUM_REGULATORS; i++) {
struct regulator_dev *rdev;
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
if (pdata) if (pdata)
idata = pdata->init_data[i]; idata = pdata->init_data[i];
...@@ -350,13 +350,13 @@ static int max8907_regulator_probe(struct platform_device *pdev) ...@@ -350,13 +350,13 @@ static int max8907_regulator_probe(struct platform_device *pdev)
pmic->desc[i].ops = &max8907_out5v_hwctl_ops; pmic->desc[i].ops = &max8907_out5v_hwctl_ops;
} }
pmic->rdev[i] = devm_regulator_register(&pdev->dev, rdev = devm_regulator_register(&pdev->dev,
&pmic->desc[i], &config); &pmic->desc[i], &config);
if (IS_ERR(pmic->rdev[i])) { if (IS_ERR(rdev)) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"failed to register %s regulator\n", "failed to register %s regulator\n",
pmic->desc[i].name); pmic->desc[i].name);
return PTR_ERR(pmic->rdev[i]); return PTR_ERR(rdev);
} }
} }
......
...@@ -36,9 +36,7 @@ ...@@ -36,9 +36,7 @@
struct max8925_regulator_info { struct max8925_regulator_info {
struct regulator_desc desc; struct regulator_desc desc;
struct regulator_dev *regulator;
struct i2c_client *i2c; struct i2c_client *i2c;
struct max8925_chip *chip;
int vol_reg; int vol_reg;
int enable_reg; int enable_reg;
...@@ -251,10 +249,11 @@ static int max8925_regulator_dt_init(struct platform_device *pdev, ...@@ -251,10 +249,11 @@ static int max8925_regulator_dt_init(struct platform_device *pdev,
{ {
struct device_node *nproot, *np; struct device_node *nproot, *np;
int rcount; int rcount;
nproot = of_node_get(pdev->dev.parent->of_node); nproot = of_node_get(pdev->dev.parent->of_node);
if (!nproot) if (!nproot)
return -ENODEV; return -ENODEV;
np = of_find_node_by_name(nproot, "regulators"); np = of_get_child_by_name(nproot, "regulators");
if (!np) { if (!np) {
dev_err(&pdev->dev, "failed to find regulators node\n"); dev_err(&pdev->dev, "failed to find regulators node\n");
return -ENODEV; return -ENODEV;
...@@ -264,7 +263,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev, ...@@ -264,7 +263,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev,
&max8925_regulator_matches[ridx], 1); &max8925_regulator_matches[ridx], 1);
of_node_put(np); of_node_put(np);
if (rcount < 0) if (rcount < 0)
return -ENODEV; return rcount;
config->init_data = max8925_regulator_matches[ridx].init_data; config->init_data = max8925_regulator_matches[ridx].init_data;
config->of_node = max8925_regulator_matches[ridx].of_node; config->of_node = max8925_regulator_matches[ridx].of_node;
...@@ -303,7 +302,6 @@ static int max8925_regulator_probe(struct platform_device *pdev) ...@@ -303,7 +302,6 @@ static int max8925_regulator_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
ri->i2c = chip->i2c; ri->i2c = chip->i2c;
ri->chip = chip;
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.driver_data = ri; config.driver_data = ri;
......
...@@ -48,9 +48,7 @@ enum { ...@@ -48,9 +48,7 @@ enum {
struct max8952_data { struct max8952_data {
struct i2c_client *client; struct i2c_client *client;
struct device *dev;
struct max8952_platform_data *pdata; struct max8952_platform_data *pdata;
struct regulator_dev *rdev;
bool vid0; bool vid0;
bool vid1; bool vid1;
...@@ -59,6 +57,7 @@ struct max8952_data { ...@@ -59,6 +57,7 @@ struct max8952_data {
static int max8952_read_reg(struct max8952_data *max8952, u8 reg) static int max8952_read_reg(struct max8952_data *max8952, u8 reg)
{ {
int ret = i2c_smbus_read_byte_data(max8952->client, reg); int ret = i2c_smbus_read_byte_data(max8952->client, reg);
if (ret > 0) if (ret > 0)
ret &= 0xff; ret &= 0xff;
...@@ -144,10 +143,8 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev) ...@@ -144,10 +143,8 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
int i; int i;
pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
if (!pd) { if (!pd)
dev_err(dev, "Failed to allocate platform data\n");
return NULL; return NULL;
}
pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0); pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0);
pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1); pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1);
...@@ -199,6 +196,7 @@ static int max8952_pmic_probe(struct i2c_client *client, ...@@ -199,6 +196,7 @@ static int max8952_pmic_probe(struct i2c_client *client,
struct max8952_platform_data *pdata = dev_get_platdata(&client->dev); struct max8952_platform_data *pdata = dev_get_platdata(&client->dev);
struct regulator_config config = { }; struct regulator_config config = { };
struct max8952_data *max8952; struct max8952_data *max8952;
struct regulator_dev *rdev;
int ret = 0, err = 0; int ret = 0, err = 0;
...@@ -219,10 +217,9 @@ static int max8952_pmic_probe(struct i2c_client *client, ...@@ -219,10 +217,9 @@ static int max8952_pmic_probe(struct i2c_client *client,
return -ENOMEM; return -ENOMEM;
max8952->client = client; max8952->client = client;
max8952->dev = &client->dev;
max8952->pdata = pdata; max8952->pdata = pdata;
config.dev = max8952->dev; config.dev = &client->dev;
config.init_data = pdata->reg_data; config.init_data = pdata->reg_data;
config.driver_data = max8952; config.driver_data = max8952;
config.of_node = client->dev.of_node; config.of_node = client->dev.of_node;
...@@ -231,11 +228,11 @@ static int max8952_pmic_probe(struct i2c_client *client, ...@@ -231,11 +228,11 @@ static int max8952_pmic_probe(struct i2c_client *client,
if (pdata->reg_data->constraints.boot_on) if (pdata->reg_data->constraints.boot_on)
config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
max8952->rdev = regulator_register(&regulator, &config); rdev = devm_regulator_register(&client->dev, &regulator, &config);
if (IS_ERR(max8952->rdev)) { if (IS_ERR(rdev)) {
ret = PTR_ERR(max8952->rdev); ret = PTR_ERR(rdev);
dev_err(max8952->dev, "regulator init failed (%d)\n", ret); dev_err(&client->dev, "regulator init failed (%d)\n", ret);
return ret; return ret;
} }
...@@ -263,7 +260,7 @@ static int max8952_pmic_probe(struct i2c_client *client, ...@@ -263,7 +260,7 @@ static int max8952_pmic_probe(struct i2c_client *client,
err = 3; err = 3;
if (err) { if (err) {
dev_warn(max8952->dev, "VID0/1 gpio invalid: " dev_warn(&client->dev, "VID0/1 gpio invalid: "
"DVS not available.\n"); "DVS not available.\n");
max8952->vid0 = 0; max8952->vid0 = 0;
max8952->vid1 = 0; max8952->vid1 = 0;
...@@ -274,7 +271,7 @@ static int max8952_pmic_probe(struct i2c_client *client, ...@@ -274,7 +271,7 @@ static int max8952_pmic_probe(struct i2c_client *client,
/* Disable Pulldown of EN only */ /* Disable Pulldown of EN only */
max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x60); max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x60);
dev_err(max8952->dev, "DVS modes disabled because VID0 and VID1" dev_err(&client->dev, "DVS modes disabled because VID0 and VID1"
" do not have proper controls.\n"); " do not have proper controls.\n");
} else { } else {
/* /*
...@@ -321,9 +318,6 @@ static int max8952_pmic_remove(struct i2c_client *client) ...@@ -321,9 +318,6 @@ static int max8952_pmic_remove(struct i2c_client *client)
{ {
struct max8952_data *max8952 = i2c_get_clientdata(client); struct max8952_data *max8952 = i2c_get_clientdata(client);
struct max8952_platform_data *pdata = max8952->pdata; struct max8952_platform_data *pdata = max8952->pdata;
struct regulator_dev *rdev = max8952->rdev;
regulator_unregister(rdev);
gpio_free(pdata->gpio_vid0); gpio_free(pdata->gpio_vid0);
gpio_free(pdata->gpio_vid1); gpio_free(pdata->gpio_vid1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment