diff options
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/s2mps11.c | 2 | ||||
-rw-r--r-- | drivers/regulator/s5m8767.c | 99 | ||||
-rw-r--r-- | drivers/regulator/stw481x-vmmc.c | 12 | ||||
-rw-r--r-- | drivers/regulator/tps51632-regulator.c | 30 | ||||
-rw-r--r-- | drivers/regulator/tps62360-regulator.c | 2 | ||||
-rw-r--r-- | drivers/regulator/tps65910-regulator.c | 40 | ||||
-rw-r--r-- | drivers/regulator/twl-regulator.c | 4 | ||||
-rw-r--r-- | drivers/regulator/wm831x-dcdc.c | 10 |
8 files changed, 119 insertions, 80 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 9e61922d8230..d9e557990577 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -70,8 +70,6 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev, ramp_delay = s2mps11->ramp_delay2; break; case S2MPS11_BUCK3: - ramp_delay = s2mps11->ramp_delay34; - break; case S2MPS11_BUCK4: ramp_delay = s2mps11->ramp_delay34; break; diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index aeb40aad0ae7..d7164bb75d3e 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -23,6 +23,7 @@ #include <linux/mfd/samsung/core.h> #include <linux/mfd/samsung/s5m8767.h> #include <linux/regulator/of_regulator.h> +#include <linux/regmap.h> #define S5M8767_OPMODE_NORMAL_MODE 0x1 @@ -120,8 +121,8 @@ static const struct sec_voltage_desc *reg_voltage_map[] = { [S5M8767_BUCK4] = &buck_voltage_val2, [S5M8767_BUCK5] = &buck_voltage_val1, [S5M8767_BUCK6] = &buck_voltage_val1, - [S5M8767_BUCK7] = NULL, - [S5M8767_BUCK8] = NULL, + [S5M8767_BUCK7] = &buck_voltage_val3, + [S5M8767_BUCK8] = &buck_voltage_val3, [S5M8767_BUCK9] = &buck_voltage_val3, }; @@ -217,7 +218,7 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev) { struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); int ret, reg; - int mask = 0xc0, enable_ctrl; + int enable_ctrl; unsigned int val; ret = s5m8767_get_register(rdev, ®, &enable_ctrl); @@ -226,37 +227,38 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev) else if (ret) return ret; - ret = sec_reg_read(s5m8767->iodev, reg, &val); + ret = regmap_read(s5m8767->iodev->regmap_pmic, reg, &val); if (ret) return ret; - return (val & mask) == enable_ctrl; + return (val & S5M8767_ENCTRL_MASK) == enable_ctrl; } static int s5m8767_reg_enable(struct regulator_dev *rdev) { struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); int ret, reg; - int mask = 0xc0, enable_ctrl; + int enable_ctrl; ret = s5m8767_get_register(rdev, ®, &enable_ctrl); if (ret) return ret; - return sec_reg_update(s5m8767->iodev, reg, enable_ctrl, mask); + return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg, + S5M8767_ENCTRL_MASK, enable_ctrl); } static int s5m8767_reg_disable(struct regulator_dev *rdev) { struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); - int ret, reg; - int mask = 0xc0, enable_ctrl; + int ret, reg, enable_ctrl; ret = s5m8767_get_register(rdev, ®, &enable_ctrl); if (ret) return ret; - return sec_reg_update(s5m8767->iodev, reg, ~mask, mask); + return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg, + S5M8767_ENCTRL_MASK, ~S5M8767_ENCTRL_MASK); } static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) @@ -417,9 +419,12 @@ static struct regulator_ops s5m8767_ops = { }; static struct regulator_ops s5m8767_buck78_ops = { + .list_voltage = regulator_list_voltage_linear, .is_enabled = s5m8767_reg_is_enabled, .enable = s5m8767_reg_enable, .disable = s5m8767_reg_disable, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, }; #define s5m8767_regulator_desc(_name) { \ @@ -745,17 +750,20 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, pdata->buck2_init); - sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init); + regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK2DVS2, + buck_init); buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, pdata->buck3_init); - sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init); + regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK3DVS2, + buck_init); buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, pdata->buck4_init); - sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init); + regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK4DVS2, + buck_init); for (i = 0; i < 8; i++) { if (s5m8767->buck2_gpiodvs) { @@ -837,71 +845,76 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || pdata->buck4_gpiodvs) { - sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK2CTRL, - (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1), - 1 << 1); - sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK3CTRL, - (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1), - 1 << 1); - sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK4CTRL, - (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1), - 1 << 1); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK2CTRL, 1 << 1, + (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1)); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK3CTRL, 1 << 1, + (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1)); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK4CTRL, 1 << 1, + (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1)); } /* Initialize GPIO DVS registers */ for (i = 0; i < 8; i++) { if (s5m8767->buck2_gpiodvs) { - sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS1 + i, - s5m8767->buck2_vol[i]); + regmap_write(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK2DVS1 + i, + s5m8767->buck2_vol[i]); } if (s5m8767->buck3_gpiodvs) { - sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS1 + i, - s5m8767->buck3_vol[i]); + regmap_write(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK3DVS1 + i, + s5m8767->buck3_vol[i]); } if (s5m8767->buck4_gpiodvs) { - sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS1 + i, - s5m8767->buck4_vol[i]); + regmap_write(s5m8767->iodev->regmap_pmic, + S5M8767_REG_BUCK4DVS1 + i, + s5m8767->buck4_vol[i]); } } if (s5m8767->buck2_ramp) - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x08, 0x08); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_DVSRAMP, 0x08, 0x08); if (s5m8767->buck3_ramp) - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x04, 0x04); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_DVSRAMP, 0x04, 0x04); if (s5m8767->buck4_ramp) - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x02, 0x02); + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_DVSRAMP, 0x02, 0x02); if (s5m8767->buck2_ramp || s5m8767->buck3_ramp || s5m8767->buck4_ramp) { + unsigned int val; switch (s5m8767->ramp_delay) { case 5: - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, - 0x40, 0xf0); + val = S5M8767_DVS_BUCK_RAMP_5; break; case 10: - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, - 0x90, 0xf0); + val = S5M8767_DVS_BUCK_RAMP_10; break; case 25: - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, - 0xd0, 0xf0); + val = S5M8767_DVS_BUCK_RAMP_25; break; case 50: - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, - 0xe0, 0xf0); + val = S5M8767_DVS_BUCK_RAMP_50; break; case 100: - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, - 0xf0, 0xf0); + val = S5M8767_DVS_BUCK_RAMP_100; break; default: - sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, - 0x90, 0xf0); + val = S5M8767_DVS_BUCK_RAMP_10; } + regmap_update_bits(s5m8767->iodev->regmap_pmic, + S5M8767_REG_DVSRAMP, + S5M8767_DVS_BUCK_RAMP_MASK, + val << S5M8767_DVS_BUCK_RAMP_SHIFT); } for (i = 0; i < pdata->num_regulators; i++) { diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c index f78857bd6a15..a7e152696a02 100644 --- a/drivers/regulator/stw481x-vmmc.c +++ b/drivers/regulator/stw481x-vmmc.c @@ -74,7 +74,8 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) config.init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); - stw481x->vmmc_regulator = regulator_register(&vmmc_regulator, &config); + stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, + &vmmc_regulator, &config); if (IS_ERR(stw481x->vmmc_regulator)) { dev_err(&pdev->dev, "error initializing STw481x VMMC regulator\n"); @@ -85,14 +86,6 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) return 0; } -static int stw481x_vmmc_regulator_remove(struct platform_device *pdev) -{ - struct stw481x *stw481x = dev_get_platdata(&pdev->dev); - - regulator_unregister(stw481x->vmmc_regulator); - return 0; -} - static const struct of_device_id stw481x_vmmc_match[] = { { .compatible = "st,stw481x-vmmc", }, {}, @@ -105,7 +98,6 @@ static struct platform_driver stw481x_vmmc_regulator_driver = { .of_match_table = stw481x_vmmc_match, }, .probe = stw481x_vmmc_regulator_probe, - .remove = stw481x_vmmc_regulator_remove, }; module_platform_driver(stw481x_vmmc_regulator_driver); diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index b0a3f0917a27..b3764f594ee9 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c @@ -70,16 +70,16 @@ #define TPS51632_POWER_STATE_SINGLE_PHASE_CCM 0x1 #define TPS51632_POWER_STATE_SINGLE_PHASE_DCM 0x2 -#define TPS51632_MIN_VOLATGE 500000 -#define TPS51632_MAX_VOLATGE 1520000 -#define TPS51632_VOLATGE_STEP_10mV 10000 -#define TPS51632_VOLATGE_STEP_20mV 20000 +#define TPS51632_MIN_VOLTAGE 500000 +#define TPS51632_MAX_VOLTAGE 1520000 +#define TPS51632_VOLTAGE_STEP_10mV 10000 +#define TPS51632_VOLTAGE_STEP_20mV 20000 #define TPS51632_MAX_VSEL 0x7F #define TPS51632_MIN_VSEL 0x19 #define TPS51632_DEFAULT_RAMP_DELAY 6000 #define TPS51632_VOLT_VSEL(uV) \ - (DIV_ROUND_UP(uV - TPS51632_MIN_VOLATGE, \ - TPS51632_VOLATGE_STEP_10mV) + \ + (DIV_ROUND_UP(uV - TPS51632_MIN_VOLTAGE, \ + TPS51632_VOLTAGE_STEP_10mV) + \ TPS51632_MIN_VSEL) /* TPS51632 chip information */ @@ -243,9 +243,9 @@ static struct tps51632_regulator_platform_data * pdata->dvfs_step_20mV = of_property_read_bool(np, "ti,dvfs-step-20mV"); pdata->base_voltage_uV = pdata->reg_init_data->constraints.min_uV ? : - TPS51632_MIN_VOLATGE; + TPS51632_MIN_VOLTAGE; pdata->max_voltage_uV = pdata->reg_init_data->constraints.max_uV ? : - TPS51632_MAX_VOLATGE; + TPS51632_MAX_VOLTAGE; return pdata; } #else @@ -284,15 +284,15 @@ static int tps51632_probe(struct i2c_client *client, } if (pdata->enable_pwm_dvfs) { - if ((pdata->base_voltage_uV < TPS51632_MIN_VOLATGE) || - (pdata->base_voltage_uV > TPS51632_MAX_VOLATGE)) { + if ((pdata->base_voltage_uV < TPS51632_MIN_VOLTAGE) || + (pdata->base_voltage_uV > TPS51632_MAX_VOLTAGE)) { dev_err(&client->dev, "Invalid base_voltage_uV setting\n"); return -EINVAL; } if ((pdata->max_voltage_uV) && - ((pdata->max_voltage_uV < TPS51632_MIN_VOLATGE) || - (pdata->max_voltage_uV > TPS51632_MAX_VOLATGE))) { + ((pdata->max_voltage_uV < TPS51632_MIN_VOLTAGE) || + (pdata->max_voltage_uV > TPS51632_MAX_VOLTAGE))) { dev_err(&client->dev, "Invalid max_voltage_uV setting\n"); return -EINVAL; } @@ -305,11 +305,11 @@ static int tps51632_probe(struct i2c_client *client, } tps->dev = &client->dev; - tps->desc.name = id->name; + tps->desc.name = client->name; tps->desc.id = 0; tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; - tps->desc.min_uV = TPS51632_MIN_VOLATGE; - tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV; + tps->desc.min_uV = TPS51632_MIN_VOLTAGE; + tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; tps->desc.linear_min_sel = TPS51632_MIN_VSEL; tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; tps->desc.ops = &tps51632_dcdc_ops; diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index c2c0185a2dcd..c3fa15a299b1 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -360,7 +360,7 @@ static int tps62360_probe(struct i2c_client *client, dev_err(&client->dev, "Error: No device match found\n"); return -ENODEV; } - chip_id = (int)match->data; + chip_id = (int)(long)match->data; if (!pdata) pdata = of_get_tps62360_platform_data(&client->dev); } else if (id) { diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index a00132e31ec7..f50dd847eebc 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -88,6 +88,11 @@ static const unsigned int VMMC_VSEL_table[] = { 1800000, 2800000, 3000000, 3300000, }; +/* supported BBCH voltages in microvolts */ +static const unsigned int VBB_VSEL_table[] = { + 3000000, 2520000, 3150000, 5000000, +}; + struct tps_info { const char *name; const char *vin_name; @@ -183,6 +188,12 @@ static struct tps_info tps65910_regs[] = { .voltage_table = VMMC_VSEL_table, .enable_time_us = 100, }, + { + .name = "vbb", + .vin_name = "vcc7", + .n_voltages = ARRAY_SIZE(VBB_VSEL_table), + .voltage_table = VBB_VSEL_table, + }, }; static struct tps_info tps65911_regs[] = { @@ -339,6 +350,8 @@ static int tps65910_get_ctrl_register(int id) return TPS65910_VAUX33; case TPS65910_REG_VMMC: return TPS65910_VMMC; + case TPS65910_REG_VBB: + return TPS65910_BBCH; default: return -EINVAL; } @@ -528,6 +541,10 @@ static int tps65910_get_voltage_sel(struct regulator_dev *dev) value &= LDO_SEL_MASK; value >>= LDO_SEL_SHIFT; break; + case TPS65910_REG_VBB: + value &= BBCH_BBSEL_MASK; + value >>= BBCH_BBSEL_SHIFT; + break; default: return -EINVAL; } @@ -638,6 +655,9 @@ static int tps65910_set_voltage_sel(struct regulator_dev *dev, case TPS65910_REG_VMMC: return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, selector << LDO_SEL_SHIFT); + case TPS65910_REG_VBB: + return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK, + selector << BBCH_BBSEL_SHIFT); } return -EINVAL; @@ -669,6 +689,9 @@ static int tps65911_set_voltage_sel(struct regulator_dev *dev, case TPS65910_REG_VIO: return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, selector << LDO_SEL_SHIFT); + case TPS65910_REG_VBB: + return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK, + selector << BBCH_BBSEL_SHIFT); } return -EINVAL; @@ -762,6 +785,18 @@ static struct regulator_ops tps65910_ops_vdd3 = { .map_voltage = regulator_map_voltage_ascend, }; +static struct regulator_ops tps65910_ops_vbb = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .set_mode = tps65910_set_mode, + .get_mode = tps65910_get_mode, + .get_voltage_sel = tps65910_get_voltage_sel, + .set_voltage_sel = tps65910_set_voltage_sel, + .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_iterate, +}; + static struct regulator_ops tps65910_ops = { .is_enabled = regulator_is_enabled_regmap, .enable = regulator_enable_regmap, @@ -944,6 +979,7 @@ static struct of_regulator_match tps65910_matches[] = { { .name = "vaux2", .driver_data = (void *) &tps65910_regs[10] }, { .name = "vaux33", .driver_data = (void *) &tps65910_regs[11] }, { .name = "vmmc", .driver_data = (void *) &tps65910_regs[12] }, + { .name = "vbb", .driver_data = (void *) &tps65910_regs[13] }, }; static struct of_regulator_match tps65911_matches[] = { @@ -1145,6 +1181,10 @@ static int tps65910_probe(struct platform_device *pdev) pmic->desc[i].ops = &tps65910_ops_dcdc; pmic->desc[i].ramp_delay = 5000; } + } else if (i == TPS65910_REG_VBB && + tps65910_chip_id(tps65910) == TPS65910) { + pmic->desc[i].ops = &tps65910_ops_vbb; + pmic->desc[i].volt_table = info->voltage_table; } else { if (tps65910_chip_id(tps65910) == TPS65910) { pmic->desc[i].ops = &tps65910_ops; diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 8ebd785485c7..fed28abef419 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -58,7 +58,7 @@ struct twlreg_info { struct regulator_desc desc; /* chip specific features */ - unsigned long features; + unsigned long features; /* * optional override functions for voltage set/get @@ -1128,7 +1128,7 @@ static int twlreg_probe(struct platform_device *pdev) if (!initdata) return -EINVAL; - info = kmemdup(template, sizeof (*info), GFP_KERNEL); + info = kmemdup(template, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 6823e6f2b88a..04cf9c16ef23 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c @@ -762,8 +762,7 @@ static int wm831x_boostp_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_REG, 0); if (res == NULL) { dev_err(&pdev->dev, "No REG resource\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } dcdc->base = res->start; @@ -788,7 +787,7 @@ static int wm831x_boostp_probe(struct platform_device *pdev) ret = PTR_ERR(dcdc->regulator); dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", id + 1, ret); - goto err; + return ret; } irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); @@ -799,15 +798,12 @@ static int wm831x_boostp_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); - goto err; + return ret; } platform_set_drvdata(pdev, dcdc); return 0; - -err: - return ret; } static struct platform_driver wm831x_boostp_driver = { |