From 9075cceaac1c8d8a4cf43bebfd342bd61442967e Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 8 Oct 2014 23:19:08 +0200 Subject: regulator: rn5t618: Convert to new style DT parsing Use the simplified DT parsing method to remove some duplicated code. Since this is a MFD subdevice and its device object doesn't have an associated DT node, the configuration instance used to register the regulators has been changed to point to the parent device. Signed-off-by: Beniamino Galvani Signed-off-by: Mark Brown --- drivers/regulator/rn5t618-regulator.c | 51 +++-------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) (limited to 'drivers') diff --git a/drivers/regulator/rn5t618-regulator.c b/drivers/regulator/rn5t618-regulator.c index e58d79aeb393..b85ceb8ff911 100644 --- a/drivers/regulator/rn5t618-regulator.c +++ b/drivers/regulator/rn5t618-regulator.c @@ -31,6 +31,8 @@ static struct regulator_ops rn5t618_reg_ops = { #define REG(rid, ereg, emask, vreg, vmask, min, max, step) \ [RN5T618_##rid] = { \ .name = #rid, \ + .of_match = of_match_ptr(#rid), \ + .regulators_node = of_match_ptr("regulators"), \ .id = RN5T618_##rid, \ .type = REGULATOR_VOLTAGE, \ .owner = THIS_MODULE, \ @@ -60,60 +62,15 @@ static struct regulator_desc rn5t618_regulators[] = { REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), }; -static struct of_regulator_match rn5t618_matches[] = { - [RN5T618_DCDC1] = { .name = "DCDC1" }, - [RN5T618_DCDC2] = { .name = "DCDC2" }, - [RN5T618_DCDC3] = { .name = "DCDC3" }, - [RN5T618_LDO1] = { .name = "LDO1" }, - [RN5T618_LDO2] = { .name = "LDO2" }, - [RN5T618_LDO3] = { .name = "LDO3" }, - [RN5T618_LDO4] = { .name = "LDO4" }, - [RN5T618_LDO5] = { .name = "LDO5" }, - [RN5T618_LDORTC1] = { .name = "LDORTC1" }, - [RN5T618_LDORTC2] = { .name = "LDORTC2" }, -}; - -static int rn5t618_regulator_parse_dt(struct platform_device *pdev) -{ - struct device_node *np, *regulators; - int ret; - - np = of_node_get(pdev->dev.parent->of_node); - if (!np) - return 0; - - regulators = of_get_child_by_name(np, "regulators"); - if (!regulators) { - dev_err(&pdev->dev, "regulators node not found\n"); - return -EINVAL; - } - - ret = of_regulator_match(&pdev->dev, regulators, rn5t618_matches, - ARRAY_SIZE(rn5t618_matches)); - of_node_put(regulators); - if (ret < 0) { - dev_err(&pdev->dev, "error parsing regulator init data: %d\n", - ret); - } - - return 0; -} - static int rn5t618_regulator_probe(struct platform_device *pdev) { struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); struct regulator_config config = { }; struct regulator_dev *rdev; - int ret, i; - - ret = rn5t618_regulator_parse_dt(pdev); - if (ret) - return ret; + int i; for (i = 0; i < RN5T618_REG_NUM; i++) { - config.dev = &pdev->dev; - config.init_data = rn5t618_matches[i].init_data; - config.of_node = rn5t618_matches[i].of_node; + config.dev = pdev->dev.parent; config.regmap = rn5t618->regmap; rdev = devm_regulator_register(&pdev->dev, -- cgit v1.2.3 From 80e82ac2ddf0e3de6f38de863b6d90de38961ed8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 16 Oct 2014 10:23:28 +0200 Subject: regulator: s2mps11: Don't zero allocated memory for external control The driver was allocating memory for storing GPIOs for external control with unnecessary GFP_ZERO flag. Then right after allocation it initialized memory to -EINVAL in loop. Skip the GFP_ZERO flag. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index adab82d5279f..7f59e67252e7 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -845,7 +845,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; }; - s2mps11->ext_control_gpio = devm_kzalloc(&pdev->dev, + s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num, GFP_KERNEL); if (!s2mps11->ext_control_gpio) -- cgit v1.2.3 From 4b8e43f255b0ae093bb776f7415619bcd9eb7858 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 27 Oct 2014 16:44:14 +0100 Subject: regulator: s2mpa01: Make regulator_desc array const The regulator_register() expects array of 'regulator_desc' to be const. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s2mpa01.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 4acefa6b462e..2263071414e2 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -298,7 +298,7 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask = S2MPA01_ENABLE_MASK \ } -static struct regulator_desc regulators[] = { +static const struct regulator_desc regulators[] = { regulator_desc_ldo(1, STEP_25_MV), regulator_desc_ldo(2, STEP_50_MV), regulator_desc_ldo(3, STEP_50_MV), -- cgit v1.2.3 From b1917578fd5d8efa67afa05a0d6d7e323f2802da Mon Sep 17 00:00:00 2001 From: Beomho Seo Date: Wed, 12 Nov 2014 21:07:59 +0900 Subject: regulator: rt5033: Add RT5033 Regulator device driver This patch add device driver of Richtek RT5033 PMIC. The driver support multiple regulator like LDO and synchronous Buck. The integrated synchronous buck converter is designed to provide 0.6 A application with high efficiency. Two LDOs are integrated. One safe LDO is for 60mA and the other one LDO is for 150 mA. Cc: Liam Girdwood Cc: Mark Brown Signed-off-by: Beomho Seo Acked-by: Chanwoo Choi Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 8 +++ drivers/regulator/Makefile | 1 + drivers/regulator/rt5033-regulator.c | 123 +++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 drivers/regulator/rt5033-regulator.c (limited to 'drivers') diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 55d7b7b0f2e0..8558e1b21f05 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -521,6 +521,14 @@ config REGULATOR_RN5T618 help Say y here to support the regulators found on Ricoh RN5T618 PMIC. +config REGULATOR_RT5033 + tristate "Richtek RT5033 Regulators" + depends on MFD_RT5033 + help + This adds support for voltage and current regulators in Richtek + RT5033 PMIC. The device supports multiple regulators like + current source, LDO and Buck. + config REGULATOR_S2MPA01 tristate "Samsung S2MPA01 voltage regulator" depends on MFD_SEC_CORE diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 1029ed39c512..1f28ebfc6f3a 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -69,6 +69,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o +obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o diff --git a/drivers/regulator/rt5033-regulator.c b/drivers/regulator/rt5033-regulator.c new file mode 100644 index 000000000000..870cc49438db --- /dev/null +++ b/drivers/regulator/rt5033-regulator.c @@ -0,0 +1,123 @@ +/* + * Regulator driver for the Richtek RT5033 + * + * Copyright (C) 2014 Samsung Electronics, Co., Ltd. + * Author: Beomho Seo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published bythe Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +static struct regulator_ops rt5033_safe_ldo_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear, +}; + +static struct regulator_ops rt5033_buck_ops = { + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, +}; + +static const struct regulator_desc rt5033_supported_regulators[] = { + [RT5033_BUCK] = { + .name = "BUCK", + .id = RT5033_BUCK, + .ops = &rt5033_buck_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .n_voltages = RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM, + .min_uV = RT5033_REGULATOR_BUCK_VOLTAGE_MIN, + .uV_step = RT5033_REGULATOR_BUCK_VOLTAGE_STEP, + .enable_reg = RT5033_REG_CTRL, + .enable_mask = RT5033_CTRL_EN_BUCK_MASK, + .vsel_reg = RT5033_REG_BUCK_CTRL, + .vsel_mask = RT5033_BUCK_CTRL_MASK, + }, + [RT5033_LDO] = { + .name = "LDO", + .id = RT5033_LDO, + .ops = &rt5033_buck_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .n_voltages = RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM, + .min_uV = RT5033_REGULATOR_LDO_VOLTAGE_MIN, + .uV_step = RT5033_REGULATOR_LDO_VOLTAGE_STEP, + .enable_reg = RT5033_REG_CTRL, + .enable_mask = RT5033_CTRL_EN_LDO_MASK, + .vsel_reg = RT5033_REG_LDO_CTRL, + .vsel_mask = RT5033_LDO_CTRL_MASK, + }, + [RT5033_SAFE_LDO] = { + .name = "SAFE_LDO", + .id = RT5033_SAFE_LDO, + .ops = &rt5033_safe_ldo_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .n_voltages = 1, + .min_uV = RT5033_REGULATOR_SAFE_LDO_VOLTAGE, + .enable_reg = RT5033_REG_CTRL, + .enable_mask = RT5033_CTRL_EN_SAFE_LDO_MASK, + }, +}; + +static int rt5033_regulator_probe(struct platform_device *pdev) +{ + struct rt5033_dev *rt5033 = dev_get_drvdata(pdev->dev.parent); + int ret, i; + struct regulator_config config = {}; + + config.dev = &pdev->dev; + config.driver_data = rt5033; + + for (i = 0; i < ARRAY_SIZE(rt5033_supported_regulators); i++) { + struct regulator_dev *regulator; + + config.regmap = rt5033->regmap; + + regulator = devm_regulator_register(&pdev->dev, + &rt5033_supported_regulators[i], &config); + if (IS_ERR(regulator)) { + ret = PTR_ERR(regulator); + dev_err(&pdev->dev, + "Regulator init failed %d: with error: %d\n", + i, ret); + return ret; + } + } + + return 0; +} + +static const struct platform_device_id rt5033_regulator_id[] = { + { "rt5033-regulator", }, + { } +}; +MODULE_DEVICE_TABLE(platform, rt5033_regulator_id); + +static struct platform_driver rt5033_regulator_driver = { + .driver = { + .name = "rt5033-regulator", + }, + .probe = rt5033_regulator_probe, + .id_table = rt5033_regulator_id, +}; +module_platform_driver(rt5033_regulator_driver); + +MODULE_DESCRIPTION("Richtek RT5033 Regulator driver"); +MODULE_AUTHOR("Beomho Seo "); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 0f5bb5b5de3b18877373f746bdb85d8ea0efeedf Mon Sep 17 00:00:00 2001 From: Josh Cartwright Date: Thu, 20 Nov 2014 13:41:25 -0600 Subject: regulator: rpm: add support for RPM-controller SMB208 The IPQ8064 reference boards make use of SMB208 regulators which are controlled by RPM. Implement support for these regulators in the RPM regulator driver. Signed-off-by: Josh Cartwright Acked-by: Bjorn Andersson Signed-off-by: Mark Brown --- drivers/regulator/qcom_rpm-regulator.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'drivers') diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c index b55cd5b50ebe..fbcbd3fe501e 100644 --- a/drivers/regulator/qcom_rpm-regulator.c +++ b/drivers/regulator/qcom_rpm-regulator.c @@ -183,6 +183,13 @@ static const struct regulator_linear_range ftsmps_ranges[] = { REGULATOR_LINEAR_RANGE(1500000, 64, 100, 50000), }; +static const struct regulator_linear_range smb208_ranges[] = { + REGULATOR_LINEAR_RANGE( 375000, 0, 29, 12500), + REGULATOR_LINEAR_RANGE( 750000, 30, 89, 12500), + REGULATOR_LINEAR_RANGE(1500000, 90, 153, 25000), + REGULATOR_LINEAR_RANGE(3100000, 154, 234, 25000), +}; + static const struct regulator_linear_range ncp_ranges[] = { REGULATOR_LINEAR_RANGE(1500000, 0, 31, 50000), }; @@ -559,6 +566,16 @@ static const struct qcom_rpm_reg pm8921_switch = { .parts = &rpm8960_switch_parts, }; +static const struct qcom_rpm_reg smb208_smps = { + .desc.linear_ranges = smb208_ranges, + .desc.n_linear_ranges = ARRAY_SIZE(smb208_ranges), + .desc.n_voltages = 235, + .desc.ops = &uV_ops, + .parts = &rpm8960_smps_parts, + .supports_force_mode_auto = false, + .supports_force_mode_bypass = false, +}; + static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-pm8058-pldo", .data = &pm8058_pldo }, { .compatible = "qcom,rpm-pm8058-nldo", .data = &pm8058_nldo }, @@ -578,6 +595,8 @@ static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-pm8921-ftsmps", .data = &pm8921_ftsmps }, { .compatible = "qcom,rpm-pm8921-ncp", .data = &pm8921_ncp }, { .compatible = "qcom,rpm-pm8921-switch", .data = &pm8921_switch }, + + { .compatible = "qcom,rpm-smb208", .data = &smb208_smps }, { } }; MODULE_DEVICE_TABLE(of, rpm_of_match); -- cgit v1.2.3