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