From fcf371ee5624cc87abac205cd0dad2432d7f0346 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 18 Apr 2013 10:34:49 +0800 Subject: regulator: core: Add regulator_map_voltage_ascend() API A lot of regulator hardware has ascendant voltage list. This patch adds regulator_map_voltage_ascend() and export it. Drivers that have ascendant voltage list can use this as their map_voltage() operation, this is more efficient than default regulator_map_voltage_iterate() function. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e3661c20cf38..56f4ca0854c9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2137,6 +2137,37 @@ int regulator_map_voltage_iterate(struct regulator_dev *rdev, } EXPORT_SYMBOL_GPL(regulator_map_voltage_iterate); +/** + * regulator_map_voltage_ascend - map_voltage() for ascendant voltage list + * + * @rdev: Regulator to operate on + * @min_uV: Lower bound for voltage + * @max_uV: Upper bound for voltage + * + * Drivers that have ascendant voltage list can use this as their + * map_voltage() operation. + */ +int regulator_map_voltage_ascend(struct regulator_dev *rdev, + int min_uV, int max_uV) +{ + int i, ret; + + for (i = 0; i < rdev->desc->n_voltages; i++) { + ret = rdev->desc->ops->list_voltage(rdev, i); + if (ret < 0) + continue; + + if (ret > max_uV) + break; + + if (ret >= min_uV && ret <= max_uV) + return i; + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(regulator_map_voltage_ascend); + /** * regulator_map_voltage_linear - map_voltage() for simple linear mappings * -- cgit v1.2.3 From 3e655618e1316719d826eab5af3510128d45f0e6 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 21 Apr 2013 00:35:31 +0800 Subject: regulator: lp3971: Convert to use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Thus use regulator_map_voltage_ascend is more efficient than the default regulator_map_voltage_iterate. Signed-off-by: Axel Lin Acked-by: Marek Szyprowski Signed-off-by: Mark Brown --- drivers/regulator/lp3971.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 9cb2c0f34515..d8af9e773310 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c @@ -163,6 +163,7 @@ static int lp3971_ldo_set_voltage_sel(struct regulator_dev *dev, static struct regulator_ops lp3971_ldo_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .is_enabled = lp3971_ldo_is_enabled, .enable = lp3971_ldo_enable, .disable = lp3971_ldo_disable, @@ -236,6 +237,7 @@ static int lp3971_dcdc_set_voltage_sel(struct regulator_dev *dev, static struct regulator_ops lp3971_dcdc_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .is_enabled = lp3971_dcdc_is_enabled, .enable = lp3971_dcdc_enable, .disable = lp3971_dcdc_disable, -- cgit v1.2.3 From b50003b69dbb60097cf55c44f8e2b4dc25bd0b12 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 21 Apr 2013 00:36:56 +0800 Subject: regulator: lp3972: Convert to use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Thus use regulator_map_voltage_ascend is more efficient than the default regulator_map_voltage_iterate. Signed-off-by: Axel Lin Acked-by: Marek Szyprowski Signed-off-by: Mark Brown --- drivers/regulator/lp3972.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index 0baabcfb578a..61e4cf9edf6e 100644 --- a/drivers/regulator/lp3972.c +++ b/drivers/regulator/lp3972.c @@ -309,6 +309,7 @@ static int lp3972_ldo_set_voltage_sel(struct regulator_dev *dev, static struct regulator_ops lp3972_ldo_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .is_enabled = lp3972_ldo_is_enabled, .enable = lp3972_ldo_enable, .disable = lp3972_ldo_disable, @@ -389,6 +390,7 @@ static int lp3972_dcdc_set_voltage_sel(struct regulator_dev *dev, static struct regulator_ops lp3972_dcdc_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .is_enabled = lp3972_dcdc_is_enabled, .enable = lp3972_dcdc_enable, .disable = lp3972_dcdc_disable, -- cgit v1.2.3 From 9fa8175f0f6ebe1ac1495a3d4fa61cc31e0843c0 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 20 Apr 2013 10:30:17 +0800 Subject: regulator: tps65910: Convert to use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Some regulators have more than 200 supported voltages. e.g. For TPS65910_REG_VDD1 and TPS65910_REG_VDD2: n_voltages = VDD1_2_NUM_VOLT_FINE * VDD1_2_NUM_VOLT_COARSE = 73 * 3 = 219 Thus it worth converting to regulator_map_voltage_ascend rather than use default regulator_map_voltage_iterate. For consistent, convert all regulators to regulator_map_voltage_ascend. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps65910-regulator.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 6ba6931ac855..45c16447744b 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -748,6 +748,7 @@ static struct regulator_ops tps65910_ops_dcdc = { .set_voltage_sel = tps65910_set_voltage_dcdc_sel, .set_voltage_time_sel = regulator_set_voltage_time_sel, .list_voltage = tps65910_list_voltage_dcdc, + .map_voltage = regulator_map_voltage_ascend, }; static struct regulator_ops tps65910_ops_vdd3 = { @@ -758,6 +759,7 @@ static struct regulator_ops tps65910_ops_vdd3 = { .get_mode = tps65910_get_mode, .get_voltage = tps65910_get_voltage_vdd3, .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, }; static struct regulator_ops tps65910_ops = { @@ -769,6 +771,7 @@ static struct regulator_ops tps65910_ops = { .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_ascend, }; static struct regulator_ops tps65911_ops = { @@ -780,6 +783,7 @@ static struct regulator_ops tps65911_ops = { .get_voltage_sel = tps65911_get_voltage_sel, .set_voltage_sel = tps65911_set_voltage_sel, .list_voltage = tps65911_list_voltage, + .map_voltage = regulator_map_voltage_ascend, }; static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, -- cgit v1.2.3 From 4d673bbc582331e47af92f6008b0e54752e1a6ea Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 20 Apr 2013 11:35:13 +0800 Subject: regulator: tps6586x: Convert to use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Thus use regulator_map_voltage_ascend is more efficient than the default regulator_map_voltage_iterate. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps6586x-regulator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index e68382d0e1ea..ac8a6cb62090 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c @@ -70,6 +70,7 @@ static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev) static struct regulator_ops tps6586x_regulator_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, -- cgit v1.2.3 From a1bb63a80ccbbe8ea6582734f8cda008abfa48df Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 25 Apr 2013 11:33:42 +0800 Subject: regulator: tps6507x: Use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Use regulator_map_voltage_ascend for them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps6507x-regulator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 54aa2da7283b..4117ff52dba1 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c @@ -356,6 +356,7 @@ static struct regulator_ops tps6507x_pmic_ops = { .get_voltage_sel = tps6507x_pmic_get_voltage_sel, .set_voltage_sel = tps6507x_pmic_set_voltage_sel, .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, }; #ifdef CONFIG_OF -- cgit v1.2.3 From 2040541afb4c623d628e714a412160c53694b7f1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 25 Apr 2013 11:31:42 +0800 Subject: regulator: tps65023: Merge tps65020 ldo1 and ldo2 vsel table tps65020 ldo1 and ldo2 vsel tables are identical, merge them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps65023-regulator.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index 9b9af6d889c8..ec1c94109418 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c @@ -107,12 +107,7 @@ static const unsigned int DCDC_FIXED_1800000_VSEL_table[] = { }; /* Supported voltage values for LDO regulators for tps65020 */ -static const unsigned int TPS65020_LDO1_VSEL_table[] = { - 1000000, 1050000, 1100000, 1300000, - 1800000, 2500000, 3000000, 3300000, -}; - -static const unsigned int TPS65020_LDO2_VSEL_table[] = { +static const unsigned int TPS65020_LDO_VSEL_table[] = { 1000000, 1050000, 1100000, 1300000, 1800000, 2500000, 3000000, 3300000, }; @@ -347,13 +342,13 @@ static const struct tps_info tps65020_regs[] = { }, { .name = "LDO1", - .table_len = ARRAY_SIZE(TPS65020_LDO1_VSEL_table), - .table = TPS65020_LDO1_VSEL_table, + .table_len = ARRAY_SIZE(TPS65020_LDO_VSEL_table), + .table = TPS65020_LDO_VSEL_table, }, { .name = "LDO2", - .table_len = ARRAY_SIZE(TPS65020_LDO2_VSEL_table), - .table = TPS65020_LDO2_VSEL_table, + .table_len = ARRAY_SIZE(TPS65020_LDO_VSEL_table), + .table = TPS65020_LDO_VSEL_table, }, }; -- cgit v1.2.3 From c4bbfbd548671e1aaf92c6dd974790f29b887e0d Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 25 Apr 2013 11:32:40 +0800 Subject: regulator: tps65023: Use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Use regulator_map_voltage_ascend for them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps65023-regulator.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index ec1c94109418..8d21cf3385e4 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c @@ -197,6 +197,7 @@ static struct regulator_ops tps65023_dcdc_ops = { .get_voltage_sel = tps65023_dcdc_get_voltage_sel, .set_voltage_sel = tps65023_dcdc_set_voltage_sel, .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, }; /* Operations permitted on LDOx */ @@ -207,6 +208,7 @@ static struct regulator_ops tps65023_ldo_ops = { .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, }; static struct regmap_config tps65023_regmap_config = { -- cgit v1.2.3 From 3bdf599289fcdfef88c87d26e29fc840a18ae6bd Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 24 Apr 2013 20:42:29 +0800 Subject: regulator: mc13892: Use regulator_map_voltage_ascend for mc13892_sw_regulator_ops Both mc13892_sw1 and mc13892_sw voltage table have ascendant voltage list. Use regulator_map_voltage_ascend for them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/mc13892-regulator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 9891aec47b57..89d004bc2fdd 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c @@ -485,6 +485,7 @@ static int mc13892_sw_regulator_set_voltage_sel(struct regulator_dev *rdev, static struct regulator_ops mc13892_sw_regulator_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .set_voltage_sel = mc13892_sw_regulator_set_voltage_sel, .get_voltage_sel = mc13892_sw_regulator_get_voltage_sel, }; -- cgit v1.2.3 From a32f9e0202ff5194734a5ca2d437e5062afb9d87 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 24 Apr 2013 20:44:47 +0800 Subject: regulator: lp872x: Use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Use regulator_map_voltage_ascend for them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/lp872x.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 8e3c7ae0047f..f5fc4a142cdf 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -478,6 +478,7 @@ static unsigned int lp872x_buck_get_mode(struct regulator_dev *rdev) static struct regulator_ops lp872x_ldo_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .set_voltage_sel = regulator_set_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap, .enable = regulator_enable_regmap, @@ -488,6 +489,7 @@ static struct regulator_ops lp872x_ldo_ops = { static struct regulator_ops lp8720_buck_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .set_voltage_sel = lp872x_buck_set_voltage_sel, .get_voltage_sel = lp872x_buck_get_voltage_sel, .enable = regulator_enable_regmap, @@ -500,6 +502,7 @@ static struct regulator_ops lp8720_buck_ops = { static struct regulator_ops lp8725_buck_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .set_voltage_sel = lp872x_buck_set_voltage_sel, .get_voltage_sel = lp872x_buck_get_voltage_sel, .enable = regulator_enable_regmap, -- cgit v1.2.3 From 6dcbc200fe4e26fe9c53a47c5945646762c118be Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 24 Apr 2013 20:45:37 +0800 Subject: regulator: lp8788-buck: Use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Use regulator_map_voltage_ascend for them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/lp8788-buck.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c index 97891a7ea7b2..eb1e1e88ae51 100644 --- a/drivers/regulator/lp8788-buck.c +++ b/drivers/regulator/lp8788-buck.c @@ -346,6 +346,7 @@ static unsigned int lp8788_buck_get_mode(struct regulator_dev *rdev) static struct regulator_ops lp8788_buck12_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .set_voltage_sel = lp8788_buck12_set_voltage_sel, .get_voltage_sel = lp8788_buck12_get_voltage_sel, .enable = regulator_enable_regmap, @@ -358,6 +359,7 @@ static struct regulator_ops lp8788_buck12_ops = { static struct regulator_ops lp8788_buck34_ops = { .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .set_voltage_sel = regulator_set_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap, .enable = regulator_enable_regmap, -- cgit v1.2.3 From b92f567deb51d2ee312e02e59f60021778e657ae Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 26 Apr 2013 14:25:52 +0800 Subject: regulator: tps6524x: Use regulator_map_voltage_ascend All regulators have ascendant voltage list in this driver. Use regulator_map_voltage_ascend for them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps6524x-regulator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/regulator') diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 843ee0a9bb92..18b67d28d60b 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c @@ -572,6 +572,7 @@ static struct regulator_ops regulator_ops = { .get_voltage_sel = get_voltage_sel, .set_voltage_sel = set_voltage_sel, .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, .set_current_limit = set_current_limit, .get_current_limit = get_current_limit, }; -- cgit v1.2.3