From 3c870e3f9d9d98f1ab98614b3b1fd5c79287d361 Mon Sep 17 00:00:00 2001 From: J Keerthy Date: Mon, 18 Feb 2013 10:44:20 +0530 Subject: regulator: palmas: Change the DT node property names to follow the convention DT node properties should not have "_". Replacing them by "-". Signed-off-by: J Keerthy Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index cde13bb5a8fb..4f86f6cab620 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -553,17 +553,17 @@ static void palmas_dt_to_pdata(struct device *dev, sizeof(struct palmas_reg_init), GFP_KERNEL); ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,warm_reset", &prop); + "ti,warm-reset", &prop); if (!ret) pdata->reg_init[idx]->warm_reset = prop; ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,roof_floor", &prop); + "ti,roof-floor", &prop); if (!ret) pdata->reg_init[idx]->roof_floor = prop; ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,mode_sleep", &prop); + "ti,mode-sleep", &prop); if (!ret) pdata->reg_init[idx]->mode_sleep = prop; @@ -578,7 +578,7 @@ static void palmas_dt_to_pdata(struct device *dev, pdata->reg_init[idx]->vsel = prop; } - ret = of_property_read_u32(node, "ti,ldo6_vibrator", &prop); + ret = of_property_read_u32(node, "ti,ldo6-vibrator", &prop); if (!ret) pdata->ldo6_vibrator = prop; } -- cgit v1.2.3 From 7be859f74ce232361c39d92d29da207ce6ee72bb Mon Sep 17 00:00:00 2001 From: Graeme Gregory Date: Thu, 7 Mar 2013 13:17:48 +0000 Subject: regulator: palmas correct dt parsing Fix the DT parsing to agree with the bindings document. Some small changes to the value names and also fix the handling of boolean values. They were previously using prop = 1/0, now just use of_property_read_bool calls. Signed-off-by: Graeme Gregory Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 4f86f6cab620..c25c2ff48305 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -1,7 +1,7 @@ /* * Driver for Regulator part of Palmas PMIC Chips * - * Copyright 2011-2012 Texas Instruments Inc. + * Copyright 2011-2013 Texas Instruments Inc. * * Author: Graeme Gregory * @@ -552,15 +552,13 @@ static void palmas_dt_to_pdata(struct device *dev, pdata->reg_init[idx] = devm_kzalloc(dev, sizeof(struct palmas_reg_init), GFP_KERNEL); - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,warm-reset", &prop); - if (!ret) - pdata->reg_init[idx]->warm_reset = prop; + pdata->reg_init[idx]->warm_reset = + of_property_read_u32(palmas_matches[idx].of_node, + "ti,warm-reset", &prop); - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,roof-floor", &prop); - if (!ret) - pdata->reg_init[idx]->roof_floor = prop; + pdata->reg_init[idx]->roof_floor = + of_property_read_bool(palmas_matches[idx].of_node, + "ti,roof-floor"); ret = of_property_read_u32(palmas_matches[idx].of_node, "ti,mode-sleep", &prop); @@ -572,15 +570,14 @@ static void palmas_dt_to_pdata(struct device *dev, if (!ret) pdata->reg_init[idx]->tstep = prop; - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,vsel", &prop); - if (!ret) - pdata->reg_init[idx]->vsel = prop; + ret = of_property_read_bool(palmas_matches[idx].of_node, + "ti,smps-range"); + if (ret) + pdata->reg_init[idx]->vsel = + PALMAS_SMPS12_VOLTAGE_RANGE; } - ret = of_property_read_u32(node, "ti,ldo6-vibrator", &prop); - if (!ret) - pdata->ldo6_vibrator = prop; + pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator"); } @@ -805,6 +802,13 @@ static int palmas_remove(struct platform_device *pdev) static struct of_device_id of_palmas_match_tbl[] = { { .compatible = "ti,palmas-pmic", }, + { .compatible = "ti,palmas-charger-pmic", }, + { .compatible = "ti,twl6035-pmic", }, + { .compatible = "ti,twl6036-pmic", }, + { .compatible = "ti,twl6037-pmic", }, + { .compatible = "ti,tps65913-pmic", }, + { .compatible = "ti,tps65914-pmic", }, + { .compatible = "ti,tps80036-pmic", }, { /* end */ } }; -- cgit v1.2.3 From 71f2146f6c22716838ffafd054391826341874f9 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 12 Mar 2013 23:40:19 +0800 Subject: regulator: palmas: Use of_property_read_bool to read "ti,warm-reset" DT property It does not make sense to assign return value of of_property_read_u32() to pdata->reg_init[idx]->warm_reset. Use of_property_read_bool() to read "ti,warm-reset" DT property instead which will return correct setting for pdata->reg_init[idx]->warm_reset. Signed-off-by: Axel Lin Acked-by: Graeme Gregory Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index c25c2ff48305..122fea432d38 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -553,8 +553,8 @@ static void palmas_dt_to_pdata(struct device *dev, sizeof(struct palmas_reg_init), GFP_KERNEL); pdata->reg_init[idx]->warm_reset = - of_property_read_u32(palmas_matches[idx].of_node, - "ti,warm-reset", &prop); + of_property_read_bool(palmas_matches[idx].of_node, + "ti,warm-reset"); pdata->reg_init[idx]->roof_floor = of_property_read_bool(palmas_matches[idx].of_node, -- cgit v1.2.3 From bbcf50b1d6b38e34958a1572f4077fa12d3dc24d Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Mon, 18 Mar 2013 14:59:49 +0530 Subject: regulator: palmas: rename probe/remove callback functions When palmas regulator probe creates stack dump during initialization due to some crash, it prints the call trace as follows: [3.166321] [] (_regmap_read+0x5c/0xa8) from [] (regmap_read+0x44/0x5c) [3.174669] [] (regmap_read+0x44/0x5c) from [] (palmas_probe+0x240/0x7d0) [3.183193] [] (palmas_probe+0x240/0x7d0) from [] (platform_drv_probe+0x14/0x18) [3.192322] [] (platform_drv_probe+0x14/0x18) from [] (driver_probe_device+0x104/0x214) [3.202055] [] (driver_probe_device+0x104/0x214) from [] (bus_for_each_drv+0x5c/0x88) The palmas_probe is current name but it helps on debugging if the function name is more appropriate to the sub-module name. Renaming the palmas_probe() to palmas_regulator_probe() and palmas_remove() to palams_regulator_remove(). Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 122fea432d38..aec2d76096dd 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -581,7 +581,7 @@ static void palmas_dt_to_pdata(struct device *dev, } -static int palmas_probe(struct platform_device *pdev) +static int palmas_regulators_probe(struct platform_device *pdev) { struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data; @@ -790,7 +790,7 @@ err_unregister_regulator: return ret; } -static int palmas_remove(struct platform_device *pdev) +static int palmas_regulators_remove(struct platform_device *pdev) { struct palmas_pmic *pmic = platform_get_drvdata(pdev); int id; @@ -818,8 +818,8 @@ static struct platform_driver palmas_driver = { .of_match_table = of_palmas_match_tbl, .owner = THIS_MODULE, }, - .probe = palmas_probe, - .remove = palmas_remove, + .probe = palmas_regulators_probe, + .remove = palmas_regulators_remove, }; static int __init palmas_init(void) -- cgit v1.2.3 From 574651f0f8eac83ef4cded056272dcb97333aa68 Mon Sep 17 00:00:00 2001 From: Ian Lartey Date: Fri, 22 Mar 2013 14:55:22 +0000 Subject: regulator: palmas remove palmas-charger option from DT bindings Signed-off-by: Ian Lartey Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index aec2d76096dd..3bd61bd02a46 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -802,7 +802,6 @@ static int palmas_regulators_remove(struct platform_device *pdev) static struct of_device_id of_palmas_match_tbl[] = { { .compatible = "ti,palmas-pmic", }, - { .compatible = "ti,palmas-charger-pmic", }, { .compatible = "ti,twl6035-pmic", }, { .compatible = "ti,twl6036-pmic", }, { .compatible = "ti,twl6037-pmic", }, -- cgit v1.2.3 From 504382c99d346c7443664dbc21b61101ccce078d Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 20 Mar 2013 19:26:37 +0530 Subject: regulator: palmas: add input supply names Palmas regulator support the different input supply pins for each of the rails. Fill the regulator info data with their input supply pin names. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 3bd61bd02a46..24bbd620d933 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -28,6 +28,7 @@ struct regs_info { char *name; + char *sname; u8 vsel_addr; u8 ctrl_addr; u8 tstep_addr; @@ -36,110 +37,131 @@ struct regs_info { static const struct regs_info palmas_regs_info[] = { { .name = "SMPS12", + .sname = "smps1-in", .vsel_addr = PALMAS_SMPS12_VOLTAGE, .ctrl_addr = PALMAS_SMPS12_CTRL, .tstep_addr = PALMAS_SMPS12_TSTEP, }, { .name = "SMPS123", + .sname = "smps1-in", .vsel_addr = PALMAS_SMPS12_VOLTAGE, .ctrl_addr = PALMAS_SMPS12_CTRL, .tstep_addr = PALMAS_SMPS12_TSTEP, }, { .name = "SMPS3", + .sname = "smps3-in", .vsel_addr = PALMAS_SMPS3_VOLTAGE, .ctrl_addr = PALMAS_SMPS3_CTRL, }, { .name = "SMPS45", + .sname = "smps4-in", .vsel_addr = PALMAS_SMPS45_VOLTAGE, .ctrl_addr = PALMAS_SMPS45_CTRL, .tstep_addr = PALMAS_SMPS45_TSTEP, }, { .name = "SMPS457", + .sname = "smps4-in", .vsel_addr = PALMAS_SMPS45_VOLTAGE, .ctrl_addr = PALMAS_SMPS45_CTRL, .tstep_addr = PALMAS_SMPS45_TSTEP, }, { .name = "SMPS6", + .sname = "smps6-in", .vsel_addr = PALMAS_SMPS6_VOLTAGE, .ctrl_addr = PALMAS_SMPS6_CTRL, .tstep_addr = PALMAS_SMPS6_TSTEP, }, { .name = "SMPS7", + .sname = "smps7-in", .vsel_addr = PALMAS_SMPS7_VOLTAGE, .ctrl_addr = PALMAS_SMPS7_CTRL, }, { .name = "SMPS8", + .sname = "smps8-in", .vsel_addr = PALMAS_SMPS8_VOLTAGE, .ctrl_addr = PALMAS_SMPS8_CTRL, .tstep_addr = PALMAS_SMPS8_TSTEP, }, { .name = "SMPS9", + .sname = "smps9-in", .vsel_addr = PALMAS_SMPS9_VOLTAGE, .ctrl_addr = PALMAS_SMPS9_CTRL, }, { .name = "SMPS10", + .sname = "smps10-in", }, { .name = "LDO1", + .sname = "ldo1-in", .vsel_addr = PALMAS_LDO1_VOLTAGE, .ctrl_addr = PALMAS_LDO1_CTRL, }, { .name = "LDO2", + .sname = "ldo2-in", .vsel_addr = PALMAS_LDO2_VOLTAGE, .ctrl_addr = PALMAS_LDO2_CTRL, }, { .name = "LDO3", + .sname = "ldo3-in", .vsel_addr = PALMAS_LDO3_VOLTAGE, .ctrl_addr = PALMAS_LDO3_CTRL, }, { .name = "LDO4", + .sname = "ldo4-in", .vsel_addr = PALMAS_LDO4_VOLTAGE, .ctrl_addr = PALMAS_LDO4_CTRL, }, { .name = "LDO5", + .sname = "ldo5-in", .vsel_addr = PALMAS_LDO5_VOLTAGE, .ctrl_addr = PALMAS_LDO5_CTRL, }, { .name = "LDO6", + .sname = "ldo6-in", .vsel_addr = PALMAS_LDO6_VOLTAGE, .ctrl_addr = PALMAS_LDO6_CTRL, }, { .name = "LDO7", + .sname = "ldo7-in", .vsel_addr = PALMAS_LDO7_VOLTAGE, .ctrl_addr = PALMAS_LDO7_CTRL, }, { .name = "LDO8", + .sname = "ldo8-in", .vsel_addr = PALMAS_LDO8_VOLTAGE, .ctrl_addr = PALMAS_LDO8_CTRL, }, { .name = "LDO9", + .sname = "ldo9-in", .vsel_addr = PALMAS_LDO9_VOLTAGE, .ctrl_addr = PALMAS_LDO9_CTRL, }, { .name = "LDOLN", + .sname = "ldoln-in", .vsel_addr = PALMAS_LDOLN_VOLTAGE, .ctrl_addr = PALMAS_LDOLN_CTRL, }, { .name = "LDOUSB", + .sname = "ldousb-in", .vsel_addr = PALMAS_LDOUSB_VOLTAGE, .ctrl_addr = PALMAS_LDOUSB_CTRL, }, @@ -709,6 +731,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) else config.init_data = NULL; + pmic->desc[id].supply_name = palmas_regs_info[id].sname; config.of_node = palmas_matches[id].of_node; rdev = regulator_register(&pmic->desc[id], &config); @@ -755,6 +778,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) else config.init_data = NULL; + pmic->desc[id].supply_name = palmas_regs_info[id].sname; config.of_node = palmas_matches[id].of_node; rdev = regulator_register(&pmic->desc[id], &config); -- cgit v1.2.3 From 30590d04808c03fb29341e1c6f721644b2f07650 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 17 Apr 2013 15:13:11 +0530 Subject: regulator: palmas: clear sleep bits if not selected Clear the sleep/warm reset bits when it is not selected through regulator platform data. This will make sure that configuration is inline with the platform data regardless of boot/POR configuration. Signed-off-by: Laxman Dewangan Acked-by: Graeme Gregory Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 24bbd620d933..af2109a73a80 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -443,24 +443,26 @@ static int palmas_smps_init(struct palmas *palmas, int id, switch (id) { case PALMAS_REG_SMPS10: - if (reg_init->mode_sleep) { - reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK; + reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK; + if (reg_init->mode_sleep) reg |= reg_init->mode_sleep << PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT; - } break; default: if (reg_init->warm_reset) reg |= PALMAS_SMPS12_CTRL_WR_S; + else + reg &= ~PALMAS_SMPS12_CTRL_WR_S; if (reg_init->roof_floor) reg |= PALMAS_SMPS12_CTRL_ROOF_FLOOR_EN; + else + reg &= ~PALMAS_SMPS12_CTRL_ROOF_FLOOR_EN; - if (reg_init->mode_sleep) { - reg &= ~PALMAS_SMPS12_CTRL_MODE_SLEEP_MASK; + reg &= ~PALMAS_SMPS12_CTRL_MODE_SLEEP_MASK; + if (reg_init->mode_sleep) reg |= reg_init->mode_sleep << PALMAS_SMPS12_CTRL_MODE_SLEEP_SHIFT; - } } ret = palmas_smps_write(palmas, addr, reg); @@ -506,9 +508,13 @@ static int palmas_ldo_init(struct palmas *palmas, int id, if (reg_init->warm_reset) reg |= PALMAS_LDO1_CTRL_WR_S; + else + reg &= ~PALMAS_LDO1_CTRL_WR_S; if (reg_init->mode_sleep) reg |= PALMAS_LDO1_CTRL_MODE_SLEEP; + else + reg &= ~PALMAS_LDO1_CTRL_MODE_SLEEP; ret = palmas_ldo_write(palmas, addr, reg); if (ret) -- cgit v1.2.3 From aa07f02793ec149d560142f25af0243fff84208b Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 17 Apr 2013 15:13:12 +0530 Subject: regulator: palmas: support for external regulator through control outputs Palmas device have control outputs like REGEN1, REGEN2, REGEN3, SYSEN1 and SYSEN2. These control outputs can be used for controlling external voltage switches to enabled/disable voltage outputs. Add support of these control outputs through regulator framework. Signed-off-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 95 +++++++++++++++++++++++++++++++----- include/linux/mfd/palmas.h | 6 +++ 2 files changed, 89 insertions(+), 12 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index af2109a73a80..c61c0fa83e22 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -165,6 +165,26 @@ static const struct regs_info palmas_regs_info[] = { .vsel_addr = PALMAS_LDOUSB_VOLTAGE, .ctrl_addr = PALMAS_LDOUSB_CTRL, }, + { + .name = "REGEN1", + .ctrl_addr = PALMAS_REGEN1_CTRL, + }, + { + .name = "REGEN2", + .ctrl_addr = PALMAS_REGEN2_CTRL, + }, + { + .name = "REGEN3", + .ctrl_addr = PALMAS_REGEN3_CTRL, + }, + { + .name = "SYSEN1", + .ctrl_addr = PALMAS_SYSEN1_CTRL, + }, + { + .name = "SYSEN2", + .ctrl_addr = PALMAS_SYSEN2_CTRL, + }, }; #define SMPS_CTRL_MODE_OFF 0x00 @@ -422,6 +442,12 @@ static struct regulator_ops palmas_ops_ldo = { .map_voltage = regulator_map_voltage_linear, }; +static struct regulator_ops palmas_ops_extreg = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, +}; + /* * setup the hardware based sleep configuration of the SMPS/LDO regulators * from the platform data. This is different to the software based control @@ -523,6 +549,28 @@ static int palmas_ldo_init(struct palmas *palmas, int id, return 0; } +static int palmas_extreg_init(struct palmas *palmas, int id, + struct palmas_reg_init *reg_init) +{ + unsigned int addr; + int ret; + unsigned int val = 0; + + addr = palmas_regs_info[id].ctrl_addr; + + if (reg_init->mode_sleep) + val = PALMAS_REGEN1_CTRL_MODE_SLEEP; + + ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, + addr, PALMAS_REGEN1_CTRL_MODE_SLEEP, val); + if (ret < 0) { + dev_err(palmas->dev, "Resource reg 0x%02x update failed %d\n", + addr, ret); + return ret; + } + return 0; +} + static struct of_regulator_match palmas_matches[] = { { .name = "smps12", }, { .name = "smps123", }, @@ -545,6 +593,11 @@ static struct of_regulator_match palmas_matches[] = { { .name = "ldo9", }, { .name = "ldoln", }, { .name = "ldousb", }, + { .name = "regen1", }, + { .name = "regen2", }, + { .name = "regen3", }, + { .name = "sysen1", }, + { .name = "sysen2", }, }; static void palmas_dt_to_pdata(struct device *dev, @@ -763,21 +816,34 @@ static int palmas_regulators_probe(struct platform_device *pdev) /* Register the regulators */ pmic->desc[id].name = palmas_regs_info[id].name; pmic->desc[id].id = id; - pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; - - pmic->desc[id].ops = &palmas_ops_ldo; - pmic->desc[id].type = REGULATOR_VOLTAGE; pmic->desc[id].owner = THIS_MODULE; - pmic->desc[id].min_uV = 900000; - pmic->desc[id].uV_step = 50000; - pmic->desc[id].linear_min_sel = 1; - pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, + + if (id < PALMAS_REG_REGEN1) { + pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; + pmic->desc[id].ops = &palmas_ops_ldo; + pmic->desc[id].min_uV = 900000; + pmic->desc[id].uV_step = 50000; + pmic->desc[id].linear_min_sel = 1; + pmic->desc[id].vsel_reg = + PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, palmas_regs_info[id].vsel_addr); - pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK; - pmic->desc[id].enable_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, + pmic->desc[id].vsel_mask = + PALMAS_LDO1_VOLTAGE_VSEL_MASK; + pmic->desc[id].enable_reg = + PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, + palmas_regs_info[id].ctrl_addr); + pmic->desc[id].enable_mask = + PALMAS_LDO1_CTRL_MODE_ACTIVE; + } else { + pmic->desc[id].n_voltages = 1; + pmic->desc[id].ops = &palmas_ops_extreg; + pmic->desc[id].enable_reg = + PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, palmas_regs_info[id].ctrl_addr); - pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE; + pmic->desc[id].enable_mask = + PALMAS_REGEN1_CTRL_MODE_ACTIVE; + } if (pdata) config.init_data = pdata->reg_data[id]; @@ -803,7 +869,12 @@ static int palmas_regulators_probe(struct platform_device *pdev) if (pdata) { reg_init = pdata->reg_init[id]; if (reg_init) { - ret = palmas_ldo_init(palmas, id, reg_init); + if (id < PALMAS_REG_REGEN1) + ret = palmas_ldo_init(palmas, + id, reg_init); + else + ret = palmas_extreg_init(palmas, + id, reg_init); if (ret) { regulator_unregister(pmic->rdev[id]); goto err_unregister_regulator; diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index a4d13d7cd001..44256aa7b46a 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -154,6 +154,12 @@ enum palmas_regulators { PALMAS_REG_LDO9, PALMAS_REG_LDOLN, PALMAS_REG_LDOUSB, + /* External regulators */ + PALMAS_REG_REGEN1, + PALMAS_REG_REGEN2, + PALMAS_REG_REGEN3, + PALMAS_REG_SYSEN1, + PALMAS_REG_SYSEN2, /* Total number of regulators */ PALMAS_NUM_REGS, }; -- cgit v1.2.3 From 17c11a7603496949989ed286ed218a9e645b6259 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 17 Apr 2013 15:13:13 +0530 Subject: regulator: palmas: add support for LDO8 tracking mode LDO8 of Palma device like tps65913 support the tracking mode on which LDO8 track the SMPS45 voltage when SMPS45 is ON and use the LDO8.VOLTAGE_SEL register when SMPS45 is OFF. On track mode, the steps of voltage change for LDO8 is 25mV where in non-tracking mode it is 50mV. Set the steps accordingly. Number of voltage count is still same for both the cases. Signed-off-by: Laxman Dewangan Acked-by: Graeme Gregory Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 53 ++++++++++++++++++++++++++++++++++++ include/linux/mfd/palmas.h | 3 ++ 2 files changed, 56 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index c61c0fa83e22..6538b339e441 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -571,6 +571,46 @@ static int palmas_extreg_init(struct palmas *palmas, int id, return 0; } +static void palmas_enable_ldo8_track(struct palmas *palmas) +{ + unsigned int reg; + unsigned int addr; + int ret; + + addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr; + + ret = palmas_ldo_read(palmas, addr, ®); + if (ret) { + dev_err(palmas->dev, "Error in reading ldo8 control reg\n"); + return; + } + + reg |= PALMAS_LDO8_CTRL_LDO_TRACKING_EN; + ret = palmas_ldo_write(palmas, addr, reg); + if (ret < 0) { + dev_err(palmas->dev, "Error in enabling tracking mode\n"); + return; + } + /* + * When SMPS45 is set to off and LDO8 tracking is enabled, the LDO8 + * output is defined by the LDO8_VOLTAGE.VSEL register divided by two, + * and can be set from 0.45 to 1.65 V. + */ + addr = palmas_regs_info[PALMAS_REG_LDO8].vsel_addr; + ret = palmas_ldo_read(palmas, addr, ®); + if (ret) { + dev_err(palmas->dev, "Error in reading ldo8 voltage reg\n"); + return; + } + + reg = (reg << 1) & PALMAS_LDO8_VOLTAGE_VSEL_MASK; + ret = palmas_ldo_write(palmas, addr, reg); + if (ret < 0) + dev_err(palmas->dev, "Error in setting ldo8 voltage reg\n"); + + return; +} + static struct of_regulator_match palmas_matches[] = { { .name = "smps12", }, { .name = "smps123", }, @@ -656,6 +696,11 @@ static void palmas_dt_to_pdata(struct device *dev, if (ret) pdata->reg_init[idx]->vsel = PALMAS_SMPS12_VOLTAGE_RANGE; + + if (idx == PALMAS_REG_LDO8) + pdata->enable_ldo8_tracking = of_property_read_bool( + palmas_matches[idx].of_node, + "ti,enable-ldo8-tracking"); } pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator"); @@ -835,6 +880,13 @@ static int palmas_regulators_probe(struct platform_device *pdev) palmas_regs_info[id].ctrl_addr); pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE; + + /* Check if LDO8 is in tracking mode or not */ + if (pdata && (id == PALMAS_REG_LDO8) && + pdata->enable_ldo8_tracking) { + palmas_enable_ldo8_track(palmas); + pmic->desc[id].uV_step = 25000; + } } else { pmic->desc[id].n_voltages = 1; pmic->desc[id].ops = &palmas_ops_extreg; @@ -883,6 +935,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) } } + return 0; err_unregister_regulator: diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 44256aa7b46a..10daa8c1e73c 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -177,6 +177,9 @@ struct palmas_pmic_platform_data { /* use LDO6 for vibrator control */ int ldo6_vibrator; + + /* Enable tracking mode of LDO8 */ + bool enable_ldo8_tracking; }; struct palmas_usb_platform_data { -- cgit v1.2.3 From 28d1e8cd671a53d6b4f967abbbc2a55f7bd333f6 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Thu, 18 Apr 2013 18:32:47 +0530 Subject: regulator: palma: add ramp delay support through regulator constraints Currently Palma regulator driver support the ramp delay through rail specific platform data. As regulator framework support the configuration of ramp delay through regulator constraint, using the framework method and removing the platform specific data approach. Signed-off-by: Laxman Dewangan Acked-by: Graeme Gregory Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 93 ++++++++++++++++++++++++++++++------ include/linux/mfd/palmas.h | 14 +----- 2 files changed, 79 insertions(+), 28 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 6538b339e441..33369160b770 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -187,6 +187,8 @@ static const struct regs_info palmas_regs_info[] = { }, }; +static unsigned int palmas_smps_ramp_delay[4] = {0, 10000, 5000, 2500}; + #define SMPS_CTRL_MODE_OFF 0x00 #define SMPS_CTRL_MODE_ON 0x01 #define SMPS_CTRL_MODE_ECO 0x02 @@ -397,6 +399,56 @@ static int palmas_map_voltage_smps(struct regulator_dev *rdev, return ret; } +static int palma_smps_set_voltage_smps_time_sel(struct regulator_dev *rdev, + unsigned int old_selector, unsigned int new_selector) +{ + struct palmas_pmic *pmic = rdev_get_drvdata(rdev); + int id = rdev_get_id(rdev); + int old_uv, new_uv; + unsigned int ramp_delay = pmic->ramp_delay[id]; + + if (!ramp_delay) + return 0; + + old_uv = palmas_list_voltage_smps(rdev, old_selector); + if (old_uv < 0) + return old_uv; + + new_uv = palmas_list_voltage_smps(rdev, new_selector); + if (new_uv < 0) + return new_uv; + + return DIV_ROUND_UP(abs(old_uv - new_uv), ramp_delay); +} + +static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev, + int ramp_delay) +{ + struct palmas_pmic *pmic = rdev_get_drvdata(rdev); + int id = rdev_get_id(rdev); + unsigned int reg = 0; + unsigned int addr = palmas_regs_info[id].tstep_addr; + int ret; + + if (ramp_delay <= 0) + reg = 0; + else if (ramp_delay < 2500) + reg = 3; + else if (ramp_delay < 5000) + reg = 2; + else + reg = 1; + + ret = palmas_smps_write(pmic->palmas, addr, reg); + if (ret < 0) { + dev_err(pmic->palmas->dev, "TSTEP write failed: %d\n", ret); + return ret; + } + + pmic->ramp_delay[id] = palmas_smps_ramp_delay[reg]; + return ret; +} + static struct regulator_ops palmas_ops_smps = { .is_enabled = palmas_is_enabled_smps, .enable = palmas_enable_smps, @@ -407,6 +459,8 @@ static struct regulator_ops palmas_ops_smps = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .list_voltage = palmas_list_voltage_smps, .map_voltage = palmas_map_voltage_smps, + .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel, + .set_ramp_delay = palmas_smps_set_ramp_delay, }; static struct regulator_ops palmas_ops_smps10 = { @@ -495,16 +549,6 @@ static int palmas_smps_init(struct palmas *palmas, int id, if (ret) return ret; - if (palmas_regs_info[id].tstep_addr && reg_init->tstep) { - addr = palmas_regs_info[id].tstep_addr; - - reg = reg_init->tstep & PALMAS_SMPS12_TSTEP_TSTEP_MASK; - - ret = palmas_smps_write(palmas, addr, reg); - if (ret) - return ret; - } - if (palmas_regs_info[id].vsel_addr && reg_init->vsel) { addr = palmas_regs_info[id].vsel_addr; @@ -686,11 +730,6 @@ static void palmas_dt_to_pdata(struct device *dev, if (!ret) pdata->reg_init[idx]->mode_sleep = prop; - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,tstep", &prop); - if (!ret) - pdata->reg_init[idx]->tstep = prop; - ret = of_property_read_bool(palmas_matches[idx].of_node, "ti,smps-range"); if (ret) @@ -752,6 +791,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) config.driver_data = pmic; for (id = 0; id < PALMAS_REG_LDO1; id++) { + bool ramp_delay_support = false; /* * Miss out regulators which are not available due @@ -762,19 +802,42 @@ static int palmas_regulators_probe(struct platform_device *pdev) case PALMAS_REG_SMPS3: if (pmic->smps123) continue; + if (id == PALMAS_REG_SMPS12) + ramp_delay_support = true; break; case PALMAS_REG_SMPS123: if (!pmic->smps123) continue; + ramp_delay_support = true; break; case PALMAS_REG_SMPS45: case PALMAS_REG_SMPS7: if (pmic->smps457) continue; + if (id == PALMAS_REG_SMPS45) + ramp_delay_support = true; break; case PALMAS_REG_SMPS457: if (!pmic->smps457) continue; + ramp_delay_support = true; + break; + } + + if ((id == PALMAS_REG_SMPS6) && (id == PALMAS_REG_SMPS8)) + ramp_delay_support = true; + + if (ramp_delay_support) { + addr = palmas_regs_info[id].tstep_addr; + ret = palmas_smps_read(pmic->palmas, addr, ®); + if (ret < 0) { + dev_err(&pdev->dev, + "reading TSTEP reg failed: %d\n", ret); + goto err_unregister_regulator; + } + pmic->desc[id].ramp_delay = + palmas_smps_ramp_delay[reg & 0x3]; + pmic->ramp_delay[id] = pmic->desc[id].ramp_delay; } /* Initialise sleep/init values from platform data */ diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 10daa8c1e73c..a58c579e8cf4 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -109,19 +109,6 @@ struct palmas_reg_init { */ int mode_sleep; - /* tstep is the timestep loaded to the TSTEP register - * - * For SMPS - * - * 0: Jump (no slope control) - * 1: 10mV/us - * 2: 5mV/us - * 3: 2.5mV/us - * - * For LDO unused - */ - int tstep; - /* voltage_sel is the bitfield loaded onto the SMPSX_VOLTAGE * register. Set this is the default voltage set in OTP needs * to be overridden. @@ -339,6 +326,7 @@ struct palmas_pmic { int smps457; int range[PALMAS_REG_SMPS10]; + unsigned int ramp_delay[PALMAS_REG_SMPS10]; }; struct palmas_resource { -- cgit v1.2.3 From 51d3a0c999e18a802a654171b5e05952b4630148 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Thu, 18 Apr 2013 18:32:48 +0530 Subject: regulator: palmas: preserve modes of rails during enable/disable The Palma device like TPS65913 have the mode mask which is also used for enable/disable the rails. The mode bits are defined as 00: OFF 01: AUTO 10: ECO 11: Forced PWM and modes are set accordingly as REGULATOR_MODE_NORMAL: AUTO REGULATOR_MODE_IDLE: ECO REGULATOR_MODE_FAST: PWM Two issue observed: 1. If client calls following sequence: regulator_enable(), regulator_set_mode(FAST), regulator_disable() and again the regulator_enable() then the mode is reset to NORMAL inplace of keeping the mode as FAST. Fixing this by storing the current mode configured by client and restoring modes when enable() is called after disable(). 2. In following sequence, the regulator get enabled: regulator_disable() regulator_set_mode(FAST), Fixing this by updating new mode in register only if it is enabled. Signed-off-by: Laxman Dewangan Acked-by: Graeme Gregory Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 30 +++++++++++++++++++++++------- include/linux/mfd/palmas.h | 1 + 2 files changed, 24 insertions(+), 7 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 33369160b770..38447ac53cb8 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -274,7 +274,10 @@ static int palmas_enable_smps(struct regulator_dev *dev) palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; - reg |= SMPS_CTRL_MODE_ON; + if (pmic->current_reg_mode[id]) + reg |= pmic->current_reg_mode[id]; + else + reg |= SMPS_CTRL_MODE_ON; palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); @@ -296,16 +299,19 @@ static int palmas_disable_smps(struct regulator_dev *dev) return 0; } - static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) { struct palmas_pmic *pmic = rdev_get_drvdata(dev); int id = rdev_get_id(dev); unsigned int reg; + bool rail_enable = true; palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; + if (reg == SMPS_CTRL_MODE_OFF) + rail_enable = false; + switch (mode) { case REGULATOR_MODE_NORMAL: reg |= SMPS_CTRL_MODE_ON; @@ -319,8 +325,11 @@ static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) default: return -EINVAL; } - palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); + pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; + if (rail_enable) + palmas_smps_write(pmic->palmas, + palmas_regs_info[id].ctrl_addr, reg); return 0; } @@ -330,9 +339,7 @@ static unsigned int palmas_get_mode_smps(struct regulator_dev *dev) int id = rdev_get_id(dev); unsigned int reg; - palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, ®); - reg &= PALMAS_SMPS12_CTRL_STATUS_MASK; - reg >>= PALMAS_SMPS12_CTRL_STATUS_SHIFT; + reg = pmic->current_reg_mode[id] & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; switch (reg) { case SMPS_CTRL_MODE_ON: @@ -871,7 +878,8 @@ static int palmas_regulators_probe(struct platform_device *pdev) /* * Read and store the RANGE bit for later use * This must be done before regulator is probed, - * otherwise we error in probe with unsupportable ranges. + * otherwise we error in probe with unsupportable + * ranges. Read the current smps mode for later use. */ addr = palmas_regs_info[id].vsel_addr; @@ -888,6 +896,14 @@ static int palmas_regulators_probe(struct platform_device *pdev) palmas_regs_info[id].vsel_addr); pmic->desc[id].vsel_mask = PALMAS_SMPS12_VOLTAGE_VSEL_MASK; + + /* Read the smps mode for later use. */ + addr = palmas_regs_info[id].ctrl_addr; + ret = palmas_smps_read(pmic->palmas, addr, ®); + if (ret) + goto err_unregister_regulator; + pmic->current_reg_mode[id] = reg & + PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; } pmic->desc[id].type = REGULATOR_VOLTAGE; diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index a58c579e8cf4..e971a7c81b79 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -327,6 +327,7 @@ struct palmas_pmic { int range[PALMAS_REG_SMPS10]; unsigned int ramp_delay[PALMAS_REG_SMPS10]; + unsigned int current_reg_mode[PALMAS_REG_SMPS10]; }; struct palmas_resource { -- cgit v1.2.3 From 3df4a81c467e1f05188b3d93ebebfd633df58c5e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 19 Apr 2013 00:53:52 +0800 Subject: regulator: palmas: Fix min_uV for LDO8 tracking mode When SMPS45 is set to off and LDO8 tracking is enabled, the output voltage can be set from 0.45 to 1.65 V. Thus set min_uV to be 450000. Signed-off-by: Axel Lin Acked-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 38447ac53cb8..8e5331c0b338 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -964,6 +964,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) if (pdata && (id == PALMAS_REG_LDO8) && pdata->enable_ldo8_tracking) { palmas_enable_ldo8_track(palmas); + pmic->desc[id].min_uV = 450000; pmic->desc[id].uV_step = 25000; } } else { -- cgit v1.2.3 From f22c2bae2e9ca75174614d7fdccc206b2b062138 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 19 Apr 2013 14:18:48 +0800 Subject: regulator: palmas: Don't update tstep register for SMPS3 and SMPS7 SMPS3 and SMPS7 do not have tstep_addr setting, so current code actually writes 0 to smps12_ctl (offset is 0) register when set_ramp_delay callback is called for SMPS3 and SMPS7. Signed-off-by: Axel Lin Acked-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 8e5331c0b338..a74106322604 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -437,6 +437,13 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev, unsigned int addr = palmas_regs_info[id].tstep_addr; int ret; + /* SMPS3 and SMPS7 do not have tstep_addr setting */ + switch (id) { + case PALMAS_REG_SMPS3: + case PALMAS_REG_SMPS7: + return 0; + } + if (ramp_delay <= 0) reg = 0; else if (ramp_delay < 2500) -- cgit v1.2.3 From e31089c608ae8fa323c5f9c3a2fa208d25e052a6 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 19 Apr 2013 20:33:45 +0800 Subject: regulator: palmas: Add missing ctrl_addr setting for SMPS10 The ctrl_addr setting for SMPS10 is missed, thus palmas_smps_init() read/write wrong register for SMPS10 in current code. Fix it. Signed-off-by: Axel Lin Acked-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index a74106322604..552ed514ba25 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -98,6 +98,7 @@ static const struct regs_info palmas_regs_info[] = { { .name = "SMPS10", .sname = "smps10-in", + .ctrl_addr = PALMAS_SMPS10_CTRL, }, { .name = "LDO1", -- cgit v1.2.3 From 0ea34b578647e60ad4e06c9ba29829dc07c5264a Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 22 Apr 2013 18:22:49 +0800 Subject: regulator: palmas: Fix off-by-one for ramp_delay and register value mapping Datasheet says: Time Step (TSTEP) selection, when changing the output voltage, the new value is reached through successive voltage steps (if not bypassed). The equivalent programmable slew rate of the output voltage is: TSTEP[1:0]: 00 Jump (no slope control) TSTEP[1:0]: 01 10mV/us TSTEP[1:0]: 10 5mV/us (default) TSTEP[1:0]: 11 2.5mV/us Signed-off-by: Axel Lin Acked-by: Laxman Dewangan Signed-off-by: Mark Brown --- drivers/regulator/palmas-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 552ed514ba25..1be9c3216974 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -447,9 +447,9 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev, if (ramp_delay <= 0) reg = 0; - else if (ramp_delay < 2500) + else if (ramp_delay <= 2500) reg = 3; - else if (ramp_delay < 5000) + else if (ramp_delay <= 5000) reg = 2; else reg = 1; -- cgit v1.2.3