From b36c6b1887ffc6b58b556120bfbd511880515247 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Wed, 8 Sep 2021 18:57:44 +0800 Subject: [PATCH 01/34] regulator: ti-abb: Make use of the helper function devm_ioremap related Use the devm_platform_ioremap_resource_byname() helper instead of calling platform_get_resource_byname() and devm_ioremap/devm_ioremap_resource() separately Signed-off-by: Cai Huoqing Link: https://lore.kernel.org/r/20210908105745.1984-1-caihuoqing@baidu.com Signed-off-by: Mark Brown --- drivers/regulator/ti-abb-regulator.c | 31 ++++++---------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index 9f0a4d50cead..2931a0b89bff 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c @@ -725,9 +725,7 @@ static int ti_abb_probe(struct platform_device *pdev) /* Map ABB resources */ if (abb->regs->setup_off || abb->regs->control_off) { - pname = "base-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - abb->base = devm_ioremap_resource(dev, res); + abb->base = devm_platform_ioremap_resource_byname(pdev, "base-address"); if (IS_ERR(abb->base)) return PTR_ERR(abb->base); @@ -735,35 +733,18 @@ static int ti_abb_probe(struct platform_device *pdev) abb->control_reg = abb->base + abb->regs->control_off; } else { - pname = "control-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - abb->control_reg = devm_ioremap_resource(dev, res); + abb->control_reg = devm_platform_ioremap_resource_byname(pdev, "control-address"); if (IS_ERR(abb->control_reg)) return PTR_ERR(abb->control_reg); - pname = "setup-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - abb->setup_reg = devm_ioremap_resource(dev, res); + abb->setup_reg = devm_platform_ioremap_resource_byname(pdev, "setup-address"); if (IS_ERR(abb->setup_reg)) return PTR_ERR(abb->setup_reg); } - pname = "int-address"; - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); - if (!res) { - dev_err(dev, "Missing '%s' IO resource\n", pname); - return -ENODEV; - } - /* - * We may have shared interrupt register offsets which are - * write-1-to-clear between domains ensuring exclusivity. - */ - abb->int_base = devm_ioremap(dev, res->start, - resource_size(res)); - if (!abb->int_base) { - dev_err(dev, "Unable to map '%s'\n", pname); - return -ENOMEM; - } + abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address"); + if (IS_ERR(abb->int_base)) + return PTR_ERR(abb->int_base); /* Map Optional resources */ pname = "efuse-address"; From b36061c2ea5bdacf51305f8bc79f29595b343eb6 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Wed, 8 Sep 2021 18:57:37 +0800 Subject: [PATCH 02/34] regulator: ti-abb: Kconfig: Add helper dependency on COMPILE_TEST COMPILE_TEST is helpful to find compilation errors in other platform(e.g.X86). In this case, the support of COMPILE_TEST is added, so this module could be compiled in other platform(e.g.X86), without ARCH_SYNQUACER configuration. Signed-off-by: Cai Huoqing Link: https://lore.kernel.org/r/20210908105738.1933-1-caihuoqing@baidu.com Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 4fd13b06231f..e35cca5871c3 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1181,7 +1181,7 @@ config REGULATOR_STPMIC1 config REGULATOR_TI_ABB tristate "TI Adaptive Body Bias on-chip LDO" - depends on ARCH_OMAP + depends on ARCH_OMAP || COMPILE_TEST help Select this option to support Texas Instruments' on-chip Adaptive Body Bias (ABB) LDO regulators. It is recommended that this option be From 6998c575b6dc26275b61987a3d70a8a4c976048b Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Wed, 8 Sep 2021 18:57:51 +0800 Subject: [PATCH 03/34] regulator: vqmmc-ipq4019: Make use of the helper function devm_platform_ioremap_resource() Use the devm_platform_ioremap_resource() helper instead of calling platform_get_resource() and devm_ioremap_resource() separately Signed-off-by: Cai Huoqing Link: https://lore.kernel.org/r/20210908105752.2035-1-caihuoqing@baidu.com Signed-off-by: Mark Brown --- drivers/regulator/vqmmc-ipq4019-regulator.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/regulator/vqmmc-ipq4019-regulator.c b/drivers/regulator/vqmmc-ipq4019-regulator.c index 6d5ae25d08d1..c4213f096fe5 100644 --- a/drivers/regulator/vqmmc-ipq4019-regulator.c +++ b/drivers/regulator/vqmmc-ipq4019-regulator.c @@ -48,7 +48,6 @@ static int ipq4019_regulator_probe(struct platform_device *pdev) struct regulator_init_data *init_data; struct regulator_config cfg = {}; struct regulator_dev *rdev; - struct resource *res; struct regmap *rmap; void __iomem *base; @@ -57,8 +56,7 @@ static int ipq4019_regulator_probe(struct platform_device *pdev) if (!init_data) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(dev, res); + base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); From adea283117225281ecf537171a06dd6e430bd8db Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 26 Aug 2021 12:40:17 -0700 Subject: [PATCH 04/34] regulator: core: resolve supply voltage deferral silently Voltage-controlled regulators depend on their supply regulator for retrieving their voltage, and so they might return -EPROBE_DEFER at this stage. Our caller already attempts to resolve supplies and retry, so we shouldn't be printing this error to logs. Quiets log messages like this, on Rockchip RK3399 Gru/Kevin boards: [ 1.033057] ppvar_bigcpu: failed to get the current voltage: -EPROBE_DEFER ... [ 1.036735] ppvar_litcpu: failed to get the current voltage: -EPROBE_DEFER ... [ 1.040366] ppvar_gpu: failed to get the current voltage: -EPROBE_DEFER ... [ 1.044086] ppvar_centerlogic: failed to get the current voltage: -EPROBE_DEFER Cc: Chen-Yu Tsai Signed-off-by: Brian Norris Link: https://lore.kernel.org/r/20210826124015.1.Iab79c6dd374ec48beac44be2fcddd165dd26476b@changeid Signed-off-by: Mark Brown --- drivers/regulator/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ca6caba8a191..85783fb3aadf 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1151,9 +1151,10 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, } if (current_uV < 0) { - rdev_err(rdev, - "failed to get the current voltage: %pe\n", - ERR_PTR(current_uV)); + if (current_uV != -EPROBE_DEFER) + rdev_err(rdev, + "failed to get the current voltage: %pe\n", + ERR_PTR(current_uV)); return current_uV; } From b1c36aae51c951af1c011de0b4f15bab06e82a52 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Wed, 1 Sep 2021 11:18:33 +0200 Subject: [PATCH 05/34] regulator: Convert SY8106A binding to a schema The Silergy SY8106A is a regulator controlled through i2c supported by Linux with a matching device tree binding. Now that we have the DT validation in place, let's convert the device tree bindings for that driver over to a YAML schema. Cc: Icenowy Zheng Cc: Liam Girdwood Cc: Mark Brown Cc: Ondrej Jirman Reviewed-by: Rob Herring Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/20210901091852.479202-34-maxime@cerno.tech Signed-off-by: Mark Brown --- .../bindings/regulator/silergy,sy8106a.yaml | 52 +++++++++++++++++++ .../bindings/regulator/sy8106a-regulator.txt | 23 -------- 2 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/silergy,sy8106a.yaml delete mode 100644 Documentation/devicetree/bindings/regulator/sy8106a-regulator.txt diff --git a/Documentation/devicetree/bindings/regulator/silergy,sy8106a.yaml b/Documentation/devicetree/bindings/regulator/silergy,sy8106a.yaml new file mode 100644 index 000000000000..a52a67c869b5 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/silergy,sy8106a.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/silergy,sy8106a.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Silergy SY8106A Voltage Regulator Device Tree Bindings + +maintainers: + - Ondrej Jirman + +allOf: + - $ref: regulator.yaml# + +properties: + compatible: + const: silergy,sy8106a + + reg: + maxItems: 1 + + silergy,fixed-microvolt: + description: > + The voltage when I2C regulating is disabled (set by external resistor + like a fixed voltage) + +required: + - compatible + - reg + - silergy,fixed-microvolt + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + regulator@65 { + compatible = "silergy,sy8106a"; + reg = <0x65>; + regulator-name = "sy8106a-vdd"; + silergy,fixed-microvolt = <1200000>; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1400000>; + regulator-boot-on; + regulator-always-on; + }; + }; + +... diff --git a/Documentation/devicetree/bindings/regulator/sy8106a-regulator.txt b/Documentation/devicetree/bindings/regulator/sy8106a-regulator.txt deleted file mode 100644 index 39a8ca73f572..000000000000 --- a/Documentation/devicetree/bindings/regulator/sy8106a-regulator.txt +++ /dev/null @@ -1,23 +0,0 @@ -SY8106A Voltage regulator - -Required properties: -- compatible: Must be "silergy,sy8106a" -- reg: I2C slave address - must be <0x65> -- silergy,fixed-microvolt - the voltage when I2C regulating is disabled (set - by external resistor like a fixed voltage) - -Any property defined as part of the core regulator binding, defined in -./regulator.txt, can also be used. - -Example: - - sy8106a { - compatible = "silergy,sy8106a"; - reg = <0x65>; - regulator-name = "sy8106a-vdd"; - silergy,fixed-microvolt = <1200000>; - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <1400000>; - regulator-boot-on; - regulator-always-on; - }; From 6f3a9b100379320d27f4a64fa90f58101c95c5a8 Mon Sep 17 00:00:00 2001 From: ChiYuan Huang Date: Tue, 14 Sep 2021 22:20:49 +0800 Subject: [PATCH 06/34] regulator: rtq6752: Enclose 'enable' gpio control by enable flag Fix 'enable' gpio control logic from the below cases if it's specified. 1. All off and both are sequentially controlled to be on. The 'enable' gpio control block to be called twice including the delay time. 2. Both are on and one is preparing to be off. The 'enable' gpio control low before register cache is configured to be true. Signed-off-by: ChiYuan Huang Link: https://lore.kernel.org/r/1631629249-9998-1-git-send-email-u0084500@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/rtq6752-regulator.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/rtq6752-regulator.c b/drivers/regulator/rtq6752-regulator.c index 609d3fcf4923..dfe45fb67353 100644 --- a/drivers/regulator/rtq6752-regulator.c +++ b/drivers/regulator/rtq6752-regulator.c @@ -54,14 +54,14 @@ static int rtq6752_set_vdd_enable(struct regulator_dev *rdev) int rid = rdev_get_id(rdev), ret; mutex_lock(&priv->lock); - if (priv->enable_gpio) { - gpiod_set_value(priv->enable_gpio, 1); - - usleep_range(RTQ6752_I2CRDY_TIMEUS, - RTQ6752_I2CRDY_TIMEUS + 100); - } - if (!priv->enable_flag) { + if (priv->enable_gpio) { + gpiod_set_value(priv->enable_gpio, 1); + + usleep_range(RTQ6752_I2CRDY_TIMEUS, + RTQ6752_I2CRDY_TIMEUS + 100); + } + regcache_cache_only(priv->regmap, false); ret = regcache_sync(priv->regmap); if (ret) { @@ -91,11 +91,11 @@ static int rtq6752_set_vdd_disable(struct regulator_dev *rdev) if (!priv->enable_flag) { regcache_cache_only(priv->regmap, true); regcache_mark_dirty(priv->regmap); + + if (priv->enable_gpio) + gpiod_set_value(priv->enable_gpio, 0); + } - - if (priv->enable_gpio) - gpiod_set_value(priv->enable_gpio, 0); - mutex_unlock(&priv->lock); return 0; From f1e5ecc5b7cc9d91ce975680a2f1f84b235f7e07 Mon Sep 17 00:00:00 2001 From: Ramona Alexandra Nechita Date: Mon, 20 Sep 2021 09:11:37 +0300 Subject: [PATCH 07/34] regulator: fix typo in Kconfig and max8973-regulator MAX8973 is supposed to be MAX8973A. Kconfig and the initial comment of max8973-regulator.c were modified accordingly. Signed-off-by: Ramona Alexandra Nechita Link: https://lore.kernel.org/r/20210920061137.10884-1-ramona.nechita@analog.com Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 4 ++-- drivers/regulator/max8973-regulator.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index e35cca5871c3..27578e9504d2 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -609,12 +609,12 @@ config REGULATOR_MAX8952 modes ranging from 0.77V to 1.40V by 0.01V steps. config REGULATOR_MAX8973 - tristate "Maxim MAX8973 voltage regulator " + tristate "Maxim MAX8973A voltage regulator" depends on I2C depends on THERMAL && THERMAL_OF select REGMAP_I2C help - The MAXIM MAX8973 high-efficiency. three phase, DC-DC step-down + The MAXIM MAX8973A high-efficiency. three phase, DC-DC step-down switching regulator delivers up to 9A of output current. Each phase operates at a 2MHz fixed frequency with a 120 deg shift from the adjacent phase, allowing the use of small magnetic component. diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index 8da8f9b6c4fd..80b65cb87cef 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -1,7 +1,7 @@ /* - * max8973-regulator.c -- Maxim max8973 + * max8973-regulator.c -- Maxim max8973A * - * Regulator driver for MAXIM 8973 DC-DC step-down switching regulator. + * Regulator driver for MAXIM 8973A DC-DC step-down switching regulator. * * Copyright (c) 2012, NVIDIA Corporation. * From 5fa6863ba69265cb7e45567d12614790ff26bd56 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 21 Sep 2021 20:21:49 +0100 Subject: [PATCH 08/34] spi: Check we have a spi_device_id for each DT compatible Currently for SPI devices we use the spi_device_id for module autoloading even on systems using device tree, meaning that listing a compatible string in the of_match_table isn't enough to have the module for a SPI driver autoloaded. We attempted to fix this by generating OF based modaliases for devices instantiated from DT in 3ce6c9e2617e ("spi: add of_device_uevent_modalias support") but this meant we no longer reported spi_device_id based aliases which broke drivers such as spi-nor which don't list all the compatible strings they support directly for DT, and in at least that case it's not super practical to do so given the very large number of compatibles needed, much larger than the number spi_device_ids due to vendor strings. As a result fell back to using spi_device_id based modalises. Try to close the gap by printing a warning when a SPI driver has a DT compatible that won't be matched as a SPI device ID with the goal of having drivers provide both. Given fallback compatibles this check is going to be excessive but it should be robust which is probably more important here. Signed-off-by: Mark Brown Link: https://lore.kernel.org/r/20210921192149.50740-1-broonie@kernel.org Signed-off-by: Mark Brown --- drivers/spi/spi.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 57e2499ec1ed..2c7f420b9f73 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -459,6 +459,47 @@ int __spi_register_driver(struct module *owner, struct spi_driver *sdrv) { sdrv->driver.owner = owner; sdrv->driver.bus = &spi_bus_type; + + /* + * For Really Good Reasons we use spi: modaliases not of: + * modaliases for DT so module autoloading won't work if we + * don't have a spi_device_id as well as a compatible string. + */ + if (sdrv->driver.of_match_table) { + const struct of_device_id *of_id; + + for (of_id = sdrv->driver.of_match_table; of_id->compatible[0]; + of_id++) { + const char *of_name; + + /* Strip off any vendor prefix */ + of_name = strnchr(of_id->compatible, + sizeof(of_id->compatible), ','); + if (of_name) + of_name++; + else + of_name = of_id->compatible; + + if (sdrv->id_table) { + const struct spi_device_id *spi_id; + + for (spi_id = sdrv->id_table; spi_id->name[0]; + spi_id++) + if (strcmp(spi_id->name, of_name) == 0) + break; + + if (spi_id->name[0]) + continue; + } else { + if (strcmp(sdrv->driver.name, of_name) == 0) + continue; + } + + pr_warn("SPI driver %s has no spi_device_id for %s\n", + sdrv->driver.name, of_id->compatible); + } + } + return driver_register(&sdrv->driver); } EXPORT_SYMBOL_GPL(__spi_register_driver); From e458d3f39d917770cef2ed78891349362ecd3e15 Mon Sep 17 00:00:00 2001 From: Anand Moon Date: Sat, 25 Sep 2021 17:34:12 +0000 Subject: [PATCH 09/34] regulator: pwm-regulator: Make use of the helper function dev_err_probe() devm_pwm_get() can return -EPROBE_DEFER if the pwm regulator is not ready yet. Use dev_err_probe() for pwm regulator resources to indicate the deferral reason when waiting for the resource to come up. Cc: Martin Blumenstingl Acked-by: Martin Blumenstingl Signed-off-by: Anand Moon Link: https://lore.kernel.org/r/20210925173413.1019-1-linux.amoon@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/pwm-regulator.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 7629476d94ae..b9eeaff1c661 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -352,15 +352,9 @@ static int pwm_regulator_probe(struct platform_device *pdev) config.init_data = init_data; drvdata->pwm = devm_pwm_get(&pdev->dev, NULL); - if (IS_ERR(drvdata->pwm)) { - ret = PTR_ERR(drvdata->pwm); - if (ret == -EPROBE_DEFER) - dev_dbg(&pdev->dev, - "Failed to get PWM, deferring probe\n"); - else - dev_err(&pdev->dev, "Failed to get PWM: %d\n", ret); - return ret; - } + if (IS_ERR(drvdata->pwm)) + return dev_err_probe(&pdev->dev, PTR_ERR(drvdata->pwm), + "Failed to get PWM\n"); if (init_data->constraints.boot_on || init_data->constraints.always_on) gpio_flags = GPIOD_OUT_HIGH; From c6e5e92cb29eab3e49dab444730b4ac200caaacb Mon Sep 17 00:00:00 2001 From: Zenghui Yu Date: Sat, 25 Sep 2021 11:55:07 +0800 Subject: [PATCH 10/34] regulator: dummy: Use devm_regulator_register() debugfs code complained at boot time that debugfs: Directory 'reg-dummy-regulator-dummy' with parent 'regulator' already present! if we compile kernel with DEBUG_TEST_DRIVER_REMOVE. The problem is that we don't provide .remove() method for dummy_regulator_driver, which should invoke regulator_unregister() on device teardown to properly free things. Though it's harmless as dummy_pdev never gets unbound in practice, let's use devm_regulator_register() to get rid of the inconsistency. Signed-off-by: Zenghui Yu Link: https://lore.kernel.org/r/20210925035507.1904-1-yuzenghui@huawei.com Signed-off-by: Mark Brown --- drivers/regulator/dummy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/dummy.c b/drivers/regulator/dummy.c index d8059f596391..24e586f93855 100644 --- a/drivers/regulator/dummy.c +++ b/drivers/regulator/dummy.c @@ -45,7 +45,8 @@ static int dummy_regulator_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.init_data = &dummy_initdata; - dummy_regulator_rdev = regulator_register(&dummy_desc, &config); + dummy_regulator_rdev = devm_regulator_register(&pdev->dev, &dummy_desc, + &config); if (IS_ERR(dummy_regulator_rdev)) { ret = PTR_ERR(dummy_regulator_rdev); pr_err("Failed to register regulator: %d\n", ret); From 35d114699b90c8b2c568c48f78adeb913d81bcc1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 29 Sep 2021 15:07:17 +0100 Subject: [PATCH 11/34] regulator: Lower priority of logging when setting supply We lowered all the other constraint related log messages to debug level so lower the logging of what supplies we're configuring to debug level too. Signed-off-by: Mark Brown Link: https://lore.kernel.org/r/20210929140717.3769-1-broonie@kernel.org Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 85783fb3aadf..21a2b28ab0ca 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1571,7 +1571,7 @@ static int set_supply(struct regulator_dev *rdev, { int err; - rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev)); + rdev_dbg(rdev, "supplied by %s\n", rdev_get_name(supply_rdev)); if (!try_module_get(supply_rdev->owner)) return -ENODEV; From 482f8032f496d8fa1441da742fd57fadbb17fb3d Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Sun, 26 Sep 2021 16:45:48 +0800 Subject: [PATCH 12/34] regulator: Document PM2250 smd-rpm regulators Document compatible for PM2250 smd-rpm regulators and list all of them. Signed-off-by: Shawn Guo Link: https://lore.kernel.org/r/20210926084549.29880-2-shawn.guo@linaro.org Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/qcom,smd-rpm-regulator.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.yaml b/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.yaml index 83b53579f463..f052e03be402 100644 --- a/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.yaml @@ -65,6 +65,9 @@ description: For pms405, s1, s2, s3, s4, s5, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13 + For pm2250, s1, s2, s3, s4, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, + l12, l13, l14, l15, l16, l17, l18, l19, l20, l21, l22 + maintainers: - Kathiravan T @@ -86,6 +89,7 @@ properties: - qcom,rpm-pmi8994-regulators - qcom,rpm-pmi8998-regulators - qcom,rpm-pms405-regulators + - qcom,rpm-pm2250-regulators patternProperties: ".*-supply$": From 400c93151f4160cf75e065d40e3774a18c8555a0 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Sun, 26 Sep 2021 16:45:49 +0800 Subject: [PATCH 13/34] regulator: qcom_smd: Add PM2250 regulators PM2250 is commonly used with QCM2290/QCS2290 SoCs, and provides 4 SMPS and 22 LDO regulators. The LDO regulators are the same types found on PM660. Signed-off-by: Shawn Guo Link: https://lore.kernel.org/r/20210926084549.29880-3-shawn.guo@linaro.org Signed-off-by: Mark Brown --- drivers/regulator/qcom_smd-regulator.c | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index 198fcc6551f6..8bac024dde8b 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -738,6 +738,24 @@ static const struct regulator_desc mp5496_ldoa2 = { .ops = &rpm_mp5496_ops, }; +static const struct regulator_desc pm2250_lvftsmps = { + .linear_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(320000, 0, 269, 4000), + }, + .n_linear_ranges = 1, + .n_voltages = 270, + .ops = &rpm_smps_ldo_ops, +}; + +static const struct regulator_desc pm2250_ftsmps = { + .linear_ranges = (struct linear_range[]) { + REGULATOR_LINEAR_RANGE(640000, 0, 269, 8000), + }, + .n_linear_ranges = 1, + .n_voltages = 270, + .ops = &rpm_smps_ldo_ops, +}; + struct rpm_regulator_data { const char *name; u32 type; @@ -1170,6 +1188,36 @@ static const struct rpm_regulator_data rpm_pms405_regulators[] = { {} }; +static const struct rpm_regulator_data rpm_pm2250_regulators[] = { + { "s1", QCOM_SMD_RPM_SMPA, 1, &pm2250_lvftsmps, "vdd_s1" }, + { "s2", QCOM_SMD_RPM_SMPA, 2, &pm2250_lvftsmps, "vdd_s2" }, + { "s3", QCOM_SMD_RPM_SMPA, 3, &pm2250_lvftsmps, "vdd_s3" }, + { "s4", QCOM_SMD_RPM_SMPA, 4, &pm2250_ftsmps, "vdd_s4" }, + { "l1", QCOM_SMD_RPM_LDOA, 1, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l2", QCOM_SMD_RPM_LDOA, 2, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l3", QCOM_SMD_RPM_LDOA, 3, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l4", QCOM_SMD_RPM_LDOA, 4, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l5", QCOM_SMD_RPM_LDOA, 5, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l6", QCOM_SMD_RPM_LDOA, 6, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l7", QCOM_SMD_RPM_LDOA, 7, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l8", QCOM_SMD_RPM_LDOA, 8, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l9", QCOM_SMD_RPM_LDOA, 9, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l10", QCOM_SMD_RPM_LDOA, 10, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l11", QCOM_SMD_RPM_LDOA, 11, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l12", QCOM_SMD_RPM_LDOA, 12, &pm660_nldo660, "vdd_l1_l2_l3_l5_l6_l7_l8_l9_l10_l11_l12" }, + { "l13", QCOM_SMD_RPM_LDOA, 13, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l14", QCOM_SMD_RPM_LDOA, 14, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l15", QCOM_SMD_RPM_LDOA, 15, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l16", QCOM_SMD_RPM_LDOA, 16, &pm660_ht_lvpldo, "vdd_l13_l14_l15_l16" }, + { "l17", QCOM_SMD_RPM_LDOA, 17, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l18", QCOM_SMD_RPM_LDOA, 18, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l19", QCOM_SMD_RPM_LDOA, 19, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l20", QCOM_SMD_RPM_LDOA, 20, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l21", QCOM_SMD_RPM_LDOA, 21, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + { "l22", QCOM_SMD_RPM_LDOA, 22, &pm660_pldo660, "vdd_l4_l17_l18_l19_l20_l21_l22" }, + {} +}; + static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-mp5496-regulators", .data = &rpm_mp5496_regulators }, { .compatible = "qcom,rpm-pm8841-regulators", .data = &rpm_pm8841_regulators }, @@ -1186,6 +1234,7 @@ static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-pmi8994-regulators", .data = &rpm_pmi8994_regulators }, { .compatible = "qcom,rpm-pmi8998-regulators", .data = &rpm_pmi8998_regulators }, { .compatible = "qcom,rpm-pms405-regulators", .data = &rpm_pms405_regulators }, + { .compatible = "qcom,rpm-pm2250-regulators", .data = &rpm_pm2250_regulators }, {} }; MODULE_DEVICE_TABLE(of, rpm_of_match); From 555767fd9136a5d3e911179fde1795c08a502ab3 Mon Sep 17 00:00:00 2001 From: Matti Vaittinen Date: Mon, 4 Oct 2021 10:14:02 +0300 Subject: [PATCH 14/34] regulator: bd71815: Use defined mask values Consistently use the defines for buck control mask values. Signed-off-by: Matti Vaittinen Link: https://lore.kernel.org/r/YVqpujZLZmaiqwe8@fedora Signed-off-by: Mark Brown --- drivers/regulator/bd71815-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/bd71815-regulator.c b/drivers/regulator/bd71815-regulator.c index 16edd9062ca9..acaa6607898e 100644 --- a/drivers/regulator/bd71815-regulator.c +++ b/drivers/regulator/bd71815-regulator.c @@ -461,9 +461,9 @@ static const struct regulator_ops bd7181x_led_regulator_ops = { .min_uV = (min), \ .uV_step = (step), \ .vsel_reg = (vsel), \ - .vsel_mask = 0x3f, \ + .vsel_mask = BD71815_VOLT_MASK, \ .enable_reg = (ereg), \ - .enable_mask = 0x04, \ + .enable_mask = BD71815_BUCK_RUN_ON, \ .ramp_reg = (ereg), \ .ramp_mask = BD71815_BUCK_RAMPRATE_MASK, \ .ramp_delay_table = bd7181x_ramp_table, \ From 5f4b59f7e640108512aa2afbabec5b02420eaebb Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 30 Sep 2021 16:03:27 +0200 Subject: [PATCH 15/34] regulator: dt-bindings: maxim,max8952: convert to dtschema Convert the Maxim MAX8952 regulator to DT schema format. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20210930140327.196232-1-krzysztof.kozlowski@canonical.com Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/max8952.txt | 52 --------- .../bindings/regulator/maxim,max8952.yaml | 109 ++++++++++++++++++ 2 files changed, 109 insertions(+), 52 deletions(-) delete mode 100644 Documentation/devicetree/bindings/regulator/max8952.txt create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max8952.yaml diff --git a/Documentation/devicetree/bindings/regulator/max8952.txt b/Documentation/devicetree/bindings/regulator/max8952.txt deleted file mode 100644 index 866fcdd0f4eb..000000000000 --- a/Documentation/devicetree/bindings/regulator/max8952.txt +++ /dev/null @@ -1,52 +0,0 @@ -Maxim MAX8952 voltage regulator - -Required properties: -- compatible: must be equal to "maxim,max8952" -- reg: I2C slave address, usually 0x60 -- max8952,dvs-mode-microvolt: array of 4 integer values defining DVS voltages - in microvolts. All values must be from range <770000, 1400000> -- any required generic properties defined in regulator.txt - -Optional properties: -- max8952,vid-gpios: array of two GPIO pins used for DVS voltage selection -- max8952,en-gpio: GPIO used to control enable status of regulator -- max8952,default-mode: index of default DVS voltage, from <0, 3> range -- max8952,sync-freq: sync frequency, must be one of following values: - - 0: 26 MHz - - 1: 13 MHz - - 2: 19.2 MHz - Defaults to 26 MHz if not specified. -- max8952,ramp-speed: voltage ramp speed, must be one of following values: - - 0: 32mV/us - - 1: 16mV/us - - 2: 8mV/us - - 3: 4mV/us - - 4: 2mV/us - - 5: 1mV/us - - 6: 0.5mV/us - - 7: 0.25mV/us - Defaults to 32mV/us if not specified. -- any available generic properties defined in regulator.txt - -Example: - - vdd_arm_reg: pmic@60 { - compatible = "maxim,max8952"; - reg = <0x60>; - - /* max8952-specific properties */ - max8952,vid-gpios = <&gpx0 3 0>, <&gpx0 4 0>; - max8952,en-gpio = <&gpx0 1 0>; - max8952,default-mode = <0>; - max8952,dvs-mode-microvolt = <1250000>, <1200000>, - <1050000>, <950000>; - max8952,sync-freq = <0>; - max8952,ramp-speed = <0>; - - /* generic regulator properties */ - regulator-name = "vdd_arm"; - regulator-min-microvolt = <770000>; - regulator-max-microvolt = <1400000>; - regulator-always-on; - regulator-boot-on; - }; diff --git a/Documentation/devicetree/bindings/regulator/maxim,max8952.yaml b/Documentation/devicetree/bindings/regulator/maxim,max8952.yaml new file mode 100644 index 000000000000..e4e8c58f6046 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/maxim,max8952.yaml @@ -0,0 +1,109 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/maxim,max8952.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX8952 voltage regulator + +maintainers: + - Krzysztof Kozlowski + +allOf: + - $ref: regulator.yaml# + +properties: + compatible: + const: maxim,max8952 + + max8952,default-mode: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + description: | + index of default DVS voltage + + max8952,dvs-mode-microvolt: + minItems: 4 + maxItems: 4 + items: + minimum: 770000 + maximum: 1400000 + description: | + Array of 4 integer values defining DVS voltages in microvolts. All values + must be from range <770000, 1400000>. + + max8952,en-gpio: + maxItems: 1 + description: | + GPIO used to control enable status of regulator + + max8952,ramp-speed: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3, 4, 5, 6, 7] + default: 0 + description: | + Voltage ramp speed, values map to: + - 0: 32mV/us + - 1: 16mV/us + - 2: 8mV/us + - 3: 4mV/us + - 4: 2mV/us + - 5: 1mV/us + - 6: 0.5mV/us + - 7: 0.25mV/us + Defaults to 32mV/us if not specified. + + max8952,sync-freq: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2] + default: 0 + description: | + Sync frequency, values map to: + - 0: 26 MHz + - 1: 13 MHz + - 2: 19.2 MHz + Defaults to 26 MHz if not specified. + + max8952,vid-gpios: + minItems: 2 + maxItems: 2 + description: | + Array of two GPIO pins used for DVS voltage selection + + reg: + maxItems: 1 + +required: + - compatible + - max8952,dvs-mode-microvolt + - reg + +unevaluatedProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@60 { + compatible = "maxim,max8952"; + reg = <0x60>; + + max8952,vid-gpios = <&gpx0 3 GPIO_ACTIVE_HIGH>, + <&gpx0 4 GPIO_ACTIVE_HIGH>; + max8952,default-mode = <0>; + max8952,dvs-mode-microvolt = <1250000>, <1200000>, + <1050000>, <950000>; + max8952,sync-freq = <0>; + max8952,ramp-speed = <0>; + + regulator-name = "VARM_1.2V_C210"; + regulator-min-microvolt = <770000>; + regulator-max-microvolt = <1400000>; + regulator-always-on; + regulator-boot-on; + }; + }; From 1d2104f21618a4cea8555dd4683529e9fbb829a9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 1 Oct 2021 15:02:49 +0200 Subject: [PATCH 16/34] regulator: dt-bindings: maxim,max8997: convert to dtschema Convert the Maxim MAX8997 PMIC bindings to DT schema format. Extend the examples with additional one copied from kernel's exynos4210-origen.dts. Also the binding descriptions are copied from old file, so license entire work under GPL-2.0. This also adds previously undocumented 32 kHz clock output modelled as regulators. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20211001130249.80405-1-krzysztof.kozlowski@canonical.com Signed-off-by: Mark Brown --- .../bindings/regulator/max8997-regulator.txt | 145 ------ .../bindings/regulator/maxim,max8997.yaml | 445 ++++++++++++++++++ 2 files changed, 445 insertions(+), 145 deletions(-) delete mode 100644 Documentation/devicetree/bindings/regulator/max8997-regulator.txt create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max8997.yaml diff --git a/Documentation/devicetree/bindings/regulator/max8997-regulator.txt b/Documentation/devicetree/bindings/regulator/max8997-regulator.txt deleted file mode 100644 index b53c5e2b335f..000000000000 --- a/Documentation/devicetree/bindings/regulator/max8997-regulator.txt +++ /dev/null @@ -1,145 +0,0 @@ -* Maxim MAX8997 Voltage and Current Regulator - -The Maxim MAX8997 is a multi-function device which includes voltage and -current regulators, rtc, charger controller and other sub-blocks. It is -interfaced to the host controller using a i2c interface. Each sub-block is -addressed by the host system using different i2c slave address. This document -describes the bindings for 'pmic' sub-block of max8997. - -Required properties: -- compatible: Should be "maxim,max8997-pmic". -- reg: Specifies the i2c slave address of the pmic block. It should be 0x66. - -- max8997,pmic-buck1-dvs-voltage: A set of 8 voltage values in micro-volt (uV) - units for buck1 when changing voltage using gpio dvs. Refer to [1] below - for additional information. - -- max8997,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) - units for buck2 when changing voltage using gpio dvs. Refer to [1] below - for additional information. - -- max8997,pmic-buck5-dvs-voltage: A set of 8 voltage values in micro-volt (uV) - units for buck5 when changing voltage using gpio dvs. Refer to [1] below - for additional information. - -[1] If none of the 'max8997,pmic-buck[1/2/5]-uses-gpio-dvs' optional - property is specified, the 'max8997,pmic-buck[1/2/5]-dvs-voltage' - property should specify atleast one voltage level (which would be a - safe operating voltage). - - If either of the 'max8997,pmic-buck[1/2/5]-uses-gpio-dvs' optional - property is specified, then all the eight voltage values for the - 'max8997,pmic-buck[1/2/5]-dvs-voltage' should be specified. - -Optional properties: -- interrupts: Interrupt specifiers for two interrupt sources. - - First interrupt specifier is for 'irq1' interrupt. - - Second interrupt specifier is for 'alert' interrupt. -- charger-supply: regulator node for charging current. -- max8997,pmic-buck1-uses-gpio-dvs: 'buck1' can be controlled by gpio dvs. -- max8997,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. -- max8997,pmic-buck5-uses-gpio-dvs: 'buck5' can be controlled by gpio dvs. - -Additional properties required if either of the optional properties are used: -- max8997,pmic-ignore-gpiodvs-side-effect: When GPIO-DVS mode is used for - multiple bucks, changing the voltage value of one of the bucks may affect - that of another buck, which is the side effect of the change (set_voltage). - Use this property to ignore such side effects and change the voltage. - -- max8997,pmic-buck125-default-dvs-idx: Default voltage setting selected from - the possible 8 options selectable by the dvs gpios. The value of this - property should be between 0 and 7. If not specified or if out of range, the - default value of this property is set to 0. - -- max8997,pmic-buck125-dvs-gpios: GPIO specifiers for three host gpio's used - for dvs. The format of the gpio specifier depends in the gpio controller. - -Regulators: The regulators of max8997 that have to be instantiated should be -included in a sub-node named 'regulators'. Regulator nodes included in this -sub-node should be of the format as listed below. - - regulator_name { - standard regulator bindings here - }; - -The following are the names of the regulators that the max8997 pmic block -supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number -as per the datasheet of max8997. - - - LDOn - - valid values for n are 1 to 18 and 21 - - Example: LDO0, LD01, LDO2, LDO21 - - BUCKn - - valid values for n are 1 to 7. - - Example: BUCK1, BUCK2, BUCK3, BUCK7 - - - ENVICHG: Battery Charging Current Monitor Output. This is a fixed - voltage type regulator - - - ESAFEOUT1: (ldo19) - - ESAFEOUT2: (ld020) - - - CHARGER_CV: main battery charger voltage control - - CHARGER: main battery charger current control - - CHARGER_TOPOFF: end of charge current threshold level - -The bindings inside the regulator nodes use the standard regulator bindings -which are documented elsewhere. - -Example: - - max8997_pmic@66 { - compatible = "maxim,max8997-pmic"; - interrupt-parent = <&wakeup_eint>; - reg = <0x66>; - interrupts = <4 0>, <3 0>; - - max8997,pmic-buck1-uses-gpio-dvs; - max8997,pmic-buck2-uses-gpio-dvs; - max8997,pmic-buck5-uses-gpio-dvs; - - max8997,pmic-ignore-gpiodvs-side-effect; - max8997,pmic-buck125-default-dvs-idx = <0>; - - max8997,pmic-buck125-dvs-gpios = <&gpx0 0 1 0 0>, /* SET1 */ - <&gpx0 1 1 0 0>, /* SET2 */ - <&gpx0 2 1 0 0>; /* SET3 */ - - max8997,pmic-buck1-dvs-voltage = <1350000>, <1300000>, - <1250000>, <1200000>, - <1150000>, <1100000>, - <1000000>, <950000>; - - max8997,pmic-buck2-dvs-voltage = <1100000>, <1100000>, - <1100000>, <1100000>, - <1000000>, <1000000>, - <1000000>, <1000000>; - - max8997,pmic-buck5-dvs-voltage = <1200000>, <1200000>, - <1200000>, <1200000>, - <1200000>, <1200000>, - <1200000>, <1200000>; - - regulators { - ldo1_reg: LDO1 { - regulator-name = "VDD_ABB_3.3V"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - }; - - ldo2_reg: LDO2 { - regulator-name = "VDD_ALIVE_1.1V"; - regulator-min-microvolt = <1100000>; - regulator-max-microvolt = <1100000>; - regulator-always-on; - }; - - buck1_reg: BUCK1 { - regulator-name = "VDD_ARM_1.2V"; - regulator-min-microvolt = <950000>; - regulator-max-microvolt = <1350000>; - regulator-always-on; - regulator-boot-on; - }; - }; - }; diff --git a/Documentation/devicetree/bindings/regulator/maxim,max8997.yaml b/Documentation/devicetree/bindings/regulator/maxim,max8997.yaml new file mode 100644 index 000000000000..d5a44ca3df04 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/maxim,max8997.yaml @@ -0,0 +1,445 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/maxim,max8997.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX8997 Power Management IC + +maintainers: + - Krzysztof Kozlowski + +description: | + The Maxim MAX8997 is a Power Management IC which includes voltage and current + regulators, charger controller with fuel gauge, RTC, clock outputs, haptic + motor driver, flash LED driver and Micro-USB Interface Controller. + + The binding here is not complete and describes only regulator and charger + controller parts. + +properties: + compatible: + const: maxim,max8997-pmic + + charger-supply: + description: | + Regulator node for charging current. + + interrupts: + items: + - description: irq1 interrupt + - description: alert interrupt + + max8997,pmic-buck1-dvs-voltage: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 8 + description: | + A set of 8 voltage values in micro-volt (uV) units for buck1 when + changing voltage using GPIO DVS. + If none of max8997,pmic-buck[1/2/5]-uses-gpio-dvs optional property is + specified, the max8997,pmic-buck[1/2/5]-dvs-voltage property should + specify at least one voltage level (which would be a safe operating + voltage). + + max8997,pmic-buck2-dvs-voltage: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 8 + description: | + A set of 8 voltage values in micro-volt (uV) units for buck2 when + changing voltage using GPIO DVS. + If none of max8997,pmic-buck[1/2/5]-uses-gpio-dvs optional property is + specified, the max8997,pmic-buck[1/2/5]-dvs-voltage property should + specify at least one voltage level (which would be a safe operating + voltage). + + max8997,pmic-buck5-dvs-voltage: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 8 + description: | + A set of 8 voltage values in micro-volt (uV) units for buck5 when + changing voltage using GPIO DVS. + If none of max8997,pmic-buck[1/2/5]-uses-gpio-dvs optional property is + specified, the max8997,pmic-buck[1/2/5]-dvs-voltage property should + specify at least one voltage level (which would be a safe operating + voltage). + + max8997,pmic-buck1-uses-gpio-dvs: + type: boolean + description: | + buck1 can be controlled by GPIO DVS. + + max8997,pmic-buck2-uses-gpio-dvs: + type: boolean + description: | + buck2 can be controlled by GPIO DVS. + + max8997,pmic-buck5-uses-gpio-dvs: + type: boolean + description: | + buck5 can be controlled by GPIO DVS. + + max8997,pmic-buck125-default-dvs-idx: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 7 + default: 0 + description: | + Default voltage setting selected from the possible 8 options selectable + by the dvs gpios. The value of this property should be between 0 and 7. + If not specified or if out of range, the default value of this property + is set to 0. + + max8997,pmic-buck125-dvs-gpios: + minItems: 3 + maxItems: 3 + description: | + GPIO specifiers for three host gpio's used for DVS. + + max8997,pmic-ignore-gpiodvs-side-effect: + type: boolean + description: | + When GPIO-DVS mode is used for multiple bucks, changing the voltage value + of one of the bucks may affect that of another buck, which is the side + effect of the change (set_voltage). Use this property to ignore such + side effects and change the voltage. + + reg: + maxItems: 1 + + regulators: + type: object + description: + List of child nodes that specify the regulators. + + patternProperties: + # 1-18 and 21 LDOs + "^LDO([1-9]|1[0-8]|21)$": + type: object + $ref: regulator.yaml# + description: + Properties for single LDO regulator. + + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + + # 7 bucks + "^BUCK[1-7]$": + type: object + $ref: regulator.yaml# + description: + Properties for single BUCK regulator. + + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + + "^EN32KHZ_[AC]P$": + type: object + $ref: regulator.yaml# + description: + 32768 Hz clock output (modelled as regulator) + + properties: + regulator-name: true + regulator-always-on: true + regulator-boot-on: true + + required: + - regulator-name + + additionalProperties: false + + properties: + CHARGER: + type: object + $ref: regulator.yaml# + description: main battery charger current control + + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + + CHARGER_CV: + type: object + $ref: regulator.yaml# + description: main battery charger voltage control + + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + + CHARGER_TOPOFF: + type: object + $ref: regulator.yaml# + description: end of charge current threshold level + + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + + ENVICHG: + type: object + $ref: regulator.yaml# + description: | + Battery Charging Current Monitor Output. This is a fixed voltage type + regulator + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + + ESAFEOUT1: + type: object + $ref: regulator.yaml# + description: LDO19 + + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + + ESAFEOUT2: + type: object + $ref: regulator.yaml# + description: LDO20 + + properties: + regulator-name: true + + required: + - regulator-name + + unevaluatedProperties: false + +required: + - compatible + - max8997,pmic-buck1-dvs-voltage + - max8997,pmic-buck2-dvs-voltage + - max8997,pmic-buck5-dvs-voltage + - reg + - regulators + +dependencies: + max8997,pmic-buck1-uses-gpio-dvs: [ 'max8997,pmic-buck125-dvs-gpios' ] + max8997,pmic-buck2-uses-gpio-dvs: [ 'max8997,pmic-buck125-dvs-gpios' ] + max8997,pmic-buck5-uses-gpio-dvs: [ 'max8997,pmic-buck125-dvs-gpios' ] + +additionalProperties: false + +if: + anyOf: + - required: + - max8997,pmic-buck1-uses-gpio-dvs + - required: + - max8997,pmic-buck2-uses-gpio-dvs + - required: + - max8997,pmic-buck5-uses-gpio-dvs +then: + properties: + max8997,pmic-buck1-dvs-voltage: + minItems: 8 + maxItems: 8 + max8997,pmic-buck2-dvs-voltage: + minItems: 8 + maxItems: 8 + max8997,pmic-buck5-dvs-voltage: + minItems: 8 + maxItems: 8 + +examples: + - | + #include + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@66 { + compatible = "maxim,max8997-pmic"; + reg = <0x66>; + + interrupts-extended = <&gpx0 7 IRQ_TYPE_LEVEL_LOW>, + <&gpx2 3 IRQ_TYPE_EDGE_FALLING>; + + max8997,pmic-buck1-uses-gpio-dvs; + max8997,pmic-buck2-uses-gpio-dvs; + max8997,pmic-buck5-uses-gpio-dvs; + + max8997,pmic-ignore-gpiodvs-side-effect; + max8997,pmic-buck125-default-dvs-idx = <0>; + + max8997,pmic-buck125-dvs-gpios = <&gpx0 5 GPIO_ACTIVE_HIGH>, + <&gpx0 6 GPIO_ACTIVE_HIGH>, + <&gpl0 0 GPIO_ACTIVE_HIGH>; + + max8997,pmic-buck1-dvs-voltage = <1350000>, <1300000>, + <1250000>, <1200000>, + <1150000>, <1100000>, + <1000000>, <950000>; + + max8997,pmic-buck2-dvs-voltage = <1100000>, <1000000>, + <950000>, <900000>, + <1100000>, <1000000>, + <950000>, <900000>; + + max8997,pmic-buck5-dvs-voltage = <1200000>, <1200000>, + <1200000>, <1200000>, + <1200000>, <1200000>, + <1200000>, <1200000>; + + pinctrl-0 = <&max8997_irq>, <&otg_gp>, <&usb_sel>; + pinctrl-names = "default"; + + charger-supply = <&charger_reg>; + + regulators { + LDO1 { + regulator-name = "VADC_3.3V_C210"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + + LDO2 { + regulator-name = "VALIVE_1.1V_C210"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + regulator-always-on; + }; + + BUCK1 { + regulator-name = "VARM_1.2V_C210"; + regulator-min-microvolt = <65000>; + regulator-max-microvolt = <2225000>; + regulator-always-on; + }; + + // ... + + BUCK7 { + regulator-name = "VCC_SUB_2.0V"; + regulator-min-microvolt = <2000000>; + regulator-max-microvolt = <2000000>; + regulator-always-on; + }; + + ESAFEOUT1 { + regulator-name = "SAFEOUT1"; + }; + + ESAFEOUT2 { + regulator-name = "SAFEOUT2"; + regulator-boot-on; + }; + + EN32KHZ_AP { + regulator-name = "EN32KHZ_AP"; + regulator-always-on; + }; + + EN32KHZ_CP { + regulator-name = "EN32KHZ_CP"; + regulator-always-on; + }; + + CHARGER { + regulator-name = "CHARGER"; + regulator-min-microamp = <200000>; + regulator-max-microamp = <950000>; + }; + + CHARGER_CV { + regulator-name = "CHARGER_CV"; + regulator-min-microvolt = <4200000>; + regulator-max-microvolt = <4200000>; + regulator-always-on; + }; + + CHARGER_TOPOFF { + regulator-name = "CHARGER_TOPOFF"; + regulator-min-microamp = <200000>; + regulator-max-microamp = <200000>; + regulator-always-on; + }; + }; + }; + }; + + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@66 { + compatible = "maxim,max8997-pmic"; + reg = <0x66>; + + interrupt-parent = <&gpx0>; + interrupts = <4 IRQ_TYPE_LEVEL_LOW>, + <3 IRQ_TYPE_EDGE_FALLING>; + pinctrl-names = "default"; + pinctrl-0 = <&max8997_irq>; + + max8997,pmic-buck1-dvs-voltage = <1350000>; + max8997,pmic-buck2-dvs-voltage = <1100000>; + max8997,pmic-buck5-dvs-voltage = <1200000>; + + regulators { + LDO1 { + regulator-name = "VDD_ABB_3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + }; + + // ... + + BUCK1 { + regulator-name = "VDD_ARM_1.2V"; + regulator-min-microvolt = <950000>; + regulator-max-microvolt = <1350000>; + regulator-always-on; + regulator-boot-on; + }; + + // ... + + EN32KHZ_AP { + regulator-name = "EN32KHZ_AP"; + regulator-always-on; + }; + }; + }; + }; From 19cd2b1471878ec30375f88a467f63db08407c47 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 8 Oct 2021 13:47:55 +0200 Subject: [PATCH 17/34] regulator: dt-bindings: maxim,max8973: convert to dtschema Convert the Maxim MAX8973 regulator to DT schema format. Extend the examples with more advanced one for MAX77621 copied from kernel's nvidia/tegra210-smaug.dts, licensed under GPL-2.0. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Message-Id: <20211008114755.148279-1-krzysztof.kozlowski@canonical.com> Signed-off-by: Mark Brown --- .../bindings/regulator/max8973-regulator.txt | 52 ------- .../bindings/regulator/maxim,max8973.yaml | 139 ++++++++++++++++++ 2 files changed, 139 insertions(+), 52 deletions(-) delete mode 100644 Documentation/devicetree/bindings/regulator/max8973-regulator.txt create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max8973.yaml diff --git a/Documentation/devicetree/bindings/regulator/max8973-regulator.txt b/Documentation/devicetree/bindings/regulator/max8973-regulator.txt deleted file mode 100644 index c2c68fcc1b41..000000000000 --- a/Documentation/devicetree/bindings/regulator/max8973-regulator.txt +++ /dev/null @@ -1,52 +0,0 @@ -* Maxim MAX8973 Voltage Regulator - -Required properties: - -- compatible: must be one of following: - "maxim,max8973" - "maxim,max77621". -- reg: the i2c slave address of the regulator. It should be 0x1b. - -Any standard regulator properties can be used to configure the single max8973 -DCDC. - -Optional properties: - --maxim,externally-enable: boolean, externally control the regulator output - enable/disable. --maxim,enable-gpio: GPIO for enable control. If the valid GPIO is provided - then externally enable control will be considered. --maxim,dvs-gpio: GPIO which is connected to DVS pin of device. --maxim,dvs-default-state: Default state of GPIO during initialisation. - 1 for HIGH and 0 for LOW. --maxim,enable-remote-sense: boolean, enable reote sense. --maxim,enable-falling-slew-rate: boolean, enable falling slew rate. --maxim,enable-active-discharge: boolean: enable active discharge. --maxim,enable-frequency-shift: boolean, enable 9% frequency shift. --maxim,enable-bias-control: boolean, enable bias control. By enabling this - startup delay can be reduce to 20us from 220us. --maxim,enable-etr: boolean, enable Enhanced Transient Response. --maxim,enable-high-etr-sensitivity: boolean, Enhanced transient response - circuit is enabled and set for high sensitivity. If this - property is available then etr will be enable default. - -Enhanced transient response (ETR) will affect the configuration of CKADV. - --junction-warn-millicelsius: u32, junction warning temperature threshold - in millicelsius. If die temperature crosses this level then - device generates the warning interrupts. - -Please note that thermal functionality is only supported on MAX77621. The -supported threshold warning temperature for MAX77621 are 120 degC and 140 degC. - -Example: - - max8973@1b { - compatible = "maxim,max8973"; - reg = <0x1b>; - - regulator-min-microvolt = <935000>; - regulator-max-microvolt = <1200000>; - regulator-boot-on; - regulator-always-on; - }; diff --git a/Documentation/devicetree/bindings/regulator/maxim,max8973.yaml b/Documentation/devicetree/bindings/regulator/maxim,max8973.yaml new file mode 100644 index 000000000000..54522827265b --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/maxim,max8973.yaml @@ -0,0 +1,139 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/maxim,max8973.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX8973/MAX77621 voltage regulator + +maintainers: + - Krzysztof Kozlowski + +allOf: + - $ref: regulator.yaml# + +properties: + compatible: + enum: + - maxim,max8973 + - maxim,max77621 + + junction-warn-millicelsius: + description: | + Junction warning temperature threshold in millicelsius. If die + temperature crosses this level then device generates the warning + interrupts. + Please note that thermal functionality is only supported on MAX77621. The + supported threshold warning temperature for MAX77621 are 120 degC and 140 + degC. + + maxim,dvs-gpio: + maxItems: 1 + description: | + GPIO which is connected to DVS pin of device. + + maxim,dvs-default-state: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1] + description: | + Default state of GPIO during initialisation. + 1 for HIGH and 0 for LOW. + + maxim,externally-enable: + type: boolean + description: | + Externally control the regulator output enable/disable. + + maxim,enable-gpio: + maxItems: 1 + description: | + GPIO for enable control. If the valid GPIO is provided then externally + enable control will be considered. + + maxim,enable-remote-sense: + type: boolean + description: Enable remote sense. + + maxim,enable-falling-slew-rate: + type: boolean + description: Enable falling slew rate. + + maxim,enable-active-discharge: + type: boolean + description: Eable active discharge. + + maxim,enable-frequency-shift: + type: boolean + description: Enable 9% frequency shift. + + maxim,enable-bias-control: + type: boolean + description: | + Enable bias control which can reduce the startup delay to 20us from 220us. + + maxim,enable-etr: + type: boolean + description: Enable Enhanced Transient Response. + + maxim,enable-high-etr-sensitivity: + type: boolean + description: | + Enhanced transient response circuit is enabled and set for high + sensitivity. If this property is available then etr will be enable + default. + Enhanced transient response (ETR) will affect the configuration of CKADV. + + reg: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + regulator@1b { + compatible = "maxim,max8973"; + reg = <0x1b>; + + regulator-min-microvolt = <935000>; + regulator-max-microvolt = <1200000>; + regulator-boot-on; + regulator-always-on; + }; + }; + + - | + #include + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + regulator@1b { + compatible = "maxim,max77621"; + reg = <0x1b>; + interrupt-parent = <&gpio>; + interrupts = ; + + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1231250>; + regulator-name = "PPVAR_CPU"; + regulator-ramp-delay = <12500>; + maxim,dvs-default-state = <1>; + maxim,enable-active-discharge; + maxim,enable-bias-control; + maxim,enable-etr; + maxim,enable-gpio = <&pmic 5 GPIO_ACTIVE_HIGH>; + maxim,externally-enable; + }; + }; From b16bef60a9112b1e6daf3afd16484eb06e7ce792 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 8 Oct 2021 13:37:13 +0200 Subject: [PATCH 18/34] regulator: s5m8767: do not use reset value as DVS voltage if GPIO DVS is disabled The driver and its bindings, before commit 04f9f068a619 ("regulator: s5m8767: Modify parsing method of the voltage table of buck2/3/4") were requiring to provide at least one safe/default voltage for DVS registers if DVS GPIO is not being enabled. IOW, if s5m8767,pmic-buck2-uses-gpio-dvs is missing, the s5m8767,pmic-buck2-dvs-voltage should still be present and contain one voltage. This requirement was coming from driver behavior matching this condition (none of DVS GPIO is enabled): it was always initializing the DVS selector pins to 0 and keeping the DVS enable setting at reset value (enabled). Therefore if none of DVS GPIO is enabled in devicetree, driver was configuring the first DVS voltage for buck[234]. Mentioned commit 04f9f068a619 ("regulator: s5m8767: Modify parsing method of the voltage table of buck2/3/4") broke it because DVS voltage won't be parsed from devicetree if DVS GPIO is not enabled. After the change, driver will configure bucks to use the register reset value as voltage which might have unpleasant effects. Fix this by relaxing the bindings constrain: if DVS GPIO is not enabled in devicetree (therefore DVS voltage is also not parsed), explicitly disable it. Cc: Fixes: 04f9f068a619 ("regulator: s5m8767: Modify parsing method of the voltage table of buck2/3/4") Signed-off-by: Krzysztof Kozlowski Acked-by: Rob Herring Message-Id: <20211008113723.134648-2-krzysztof.kozlowski@canonical.com> Signed-off-by: Mark Brown --- .../bindings/regulator/samsung,s5m8767.txt | 21 +++++++------------ drivers/regulator/s5m8767.c | 21 ++++++++----------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt index 093edda0c8df..d9cff1614f7a 100644 --- a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt +++ b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt @@ -13,6 +13,14 @@ common regulator binding documented in: Required properties of the main device node (the parent!): + - s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used + for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines. + + [1] If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional + property is specified, then all the eight voltage values for the + 's5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. + +Optional properties of the main device node (the parent!): - s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) units for buck2 when changing voltage using gpio dvs. Refer to [1] below for additional information. @@ -25,19 +33,6 @@ Required properties of the main device node (the parent!): units for buck4 when changing voltage using gpio dvs. Refer to [1] below for additional information. - - s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used - for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines. - - [1] If none of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional - property is specified, the 's5m8767,pmic-buck[2/3/4]-dvs-voltage' - property should specify atleast one voltage level (which would be a - safe operating voltage). - - If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional - property is specified, then all the eight voltage values for the - 's5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. - -Optional properties of the main device node (the parent!): - s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. - s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs. - s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs. diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 7c111bbdc2af..35269f998210 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -850,18 +850,15 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) /* DS4 GPIO */ gpio_direction_output(pdata->buck_ds[2], 0x0); - if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || - pdata->buck4_gpiodvs) { - 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)); - } + 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++) { From a7fda04bc9b6ad9da8e19c9e6e3b1dab773d068a Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 8 Oct 2021 13:37:14 +0200 Subject: [PATCH 19/34] regulator: dt-bindings: samsung,s5m8767: correct s5m8767,pmic-buck-default-dvs-idx property The driver was always parsing "s5m8767,pmic-buck-default-dvs-idx", not "s5m8767,pmic-buck234-default-dvs-idx". Cc: Fixes: 26aec009f6b6 ("regulator: add device tree support for s5m8767") Signed-off-by: Krzysztof Kozlowski Acked-by: Rob Herring Message-Id: <20211008113723.134648-3-krzysztof.kozlowski@canonical.com> Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt index d9cff1614f7a..6cd83d920155 100644 --- a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt +++ b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt @@ -39,7 +39,7 @@ Optional properties of the main device node (the parent!): Additional properties required if either of the optional properties are used: - - s5m8767,pmic-buck234-default-dvs-idx: Default voltage setting selected from + - s5m8767,pmic-buck-default-dvs-idx: Default voltage setting selected from the possible 8 options selectable by the dvs gpios. The value of this property should be between 0 and 7. If not specified or if out of range, the default value of this property is set to 0. From 1790cd3510cbd1f3f6217e5d9315f6dee369a690 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 8 Oct 2021 13:37:15 +0200 Subject: [PATCH 20/34] dt-bindings: clock: samsung,s2mps11: convert to dtschema Convert the clock provider of Samsung S2MPS11 family of PMICs to DT schema format. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Acked-by: Stephen Boyd Message-Id: <20211008113723.134648-4-krzysztof.kozlowski@canonical.com> Signed-off-by: Mark Brown --- .../bindings/clock/samsung,s2mps11.txt | 49 ------------------- .../bindings/clock/samsung,s2mps11.yaml | 45 +++++++++++++++++ MAINTAINERS | 2 +- 3 files changed, 46 insertions(+), 50 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/samsung,s2mps11.txt create mode 100644 Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml diff --git a/Documentation/devicetree/bindings/clock/samsung,s2mps11.txt b/Documentation/devicetree/bindings/clock/samsung,s2mps11.txt deleted file mode 100644 index 2726c1d58a79..000000000000 --- a/Documentation/devicetree/bindings/clock/samsung,s2mps11.txt +++ /dev/null @@ -1,49 +0,0 @@ -Binding for Samsung S2M and S5M family clock generator block -============================================================ - -This is a part of device tree bindings for S2M and S5M family multi-function -devices. -More information can be found in bindings/mfd/sec-core.txt file. - -The S2MPS11/13/15 and S5M8767 provide three(AP/CP/BT) buffered 32.768 kHz -outputs. The S2MPS14 provides two (AP/BT) buffered 32.768 KHz outputs. - -To register these as clocks with common clock framework instantiate under -main device node a sub-node named "clocks". - -It uses the common clock binding documented in: - - Documentation/devicetree/bindings/clock/clock-bindings.txt - - -Required properties of the "clocks" sub-node: - - #clock-cells: should be 1. - - compatible: Should be one of: "samsung,s2mps11-clk", "samsung,s2mps13-clk", - "samsung,s2mps14-clk", "samsung,s5m8767-clk" - The S2MPS15 uses the same compatible as S2MPS13, as both provides similar - clocks. - - -Each clock is assigned an identifier and client nodes use this identifier -to specify the clock which they consume. - Clock ID Devices - ---------------------------------------------------------- - 32KhzAP 0 S2MPS11/13/14/15, S5M8767 - 32KhzCP 1 S2MPS11/13/15, S5M8767 - 32KhzBT 2 S2MPS11/13/14/15, S5M8767 - -Include dt-bindings/clock/samsung,s2mps11.h file to use preprocessor defines -in device tree sources. - - -Example: - - s2mps11_pmic@66 { - compatible = "samsung,s2mps11-pmic"; - reg = <0x66>; - - s2m_osc: clocks { - compatible = "samsung,s2mps11-clk"; - #clock-cells = <1>; - clock-output-names = "xx", "yy", "zz"; - }; - }; diff --git a/Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml b/Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml new file mode 100644 index 000000000000..1410c51e0e7d --- /dev/null +++ b/Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/samsung,s2mps11.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2M and S5M family clock generator block + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2MPS11/13/15 and S5M8767 provide three(AP/CP/BT) buffered 32.768 kHz + outputs. The S2MPS14 provides two (AP/BT) buffered 32.768 KHz outputs. + + All available clocks are defined as preprocessor macros in + dt-bindings/clock/samsung,s2mps11.h header. + + See also Documentation/devicetree/bindings/mfd/samsung,s2mps11.yaml for + additional information and example. + +properties: + compatible: + enum: + - samsung,s2mps11-clk + - samsung,s2mps13-clk # S2MPS13 and S2MPS15 + - samsung,s2mps14-clk + - samsung,s5m8767-clk + + "#clock-cells": + const: 1 + + clock-output-names: + minItems: 3 + maxItems: 3 + description: Names for AP, CP and BT clocks. + +required: + - compatible + - "#clock-cells" + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index a61f4f3b78a9..a2a8aaa88209 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16330,7 +16330,7 @@ M: Bartlomiej Zolnierkiewicz L: linux-kernel@vger.kernel.org L: linux-samsung-soc@vger.kernel.org S: Supported -F: Documentation/devicetree/bindings/clock/samsung,s2mps11.txt +F: Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml F: Documentation/devicetree/bindings/mfd/samsung,sec-core.txt F: Documentation/devicetree/bindings/regulator/samsung,s2m*.txt F: Documentation/devicetree/bindings/regulator/samsung,s5m*.txt From ea98b9eba05ca01f9f6ef6f1ff74ec530884148a Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 8 Oct 2021 13:39:26 +0200 Subject: [PATCH 21/34] regulator: dt-bindings: samsung,s2m: convert to dtschema Convert the regulators of Samsung S2MPS11/S2MPS13/S2MPS14/S2MPS15/S2MPU02 family of PMICs to DT schema format. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Message-Id: <20211008113931.134847-1-krzysztof.kozlowski@canonical.com> Signed-off-by: Mark Brown --- .../bindings/regulator/samsung,s2mps11.txt | 102 ------------------ .../bindings/regulator/samsung,s2mps11.yaml | 44 ++++++++ .../bindings/regulator/samsung,s2mps13.yaml | 44 ++++++++ .../bindings/regulator/samsung,s2mps14.yaml | 44 ++++++++ .../bindings/regulator/samsung,s2mps15.yaml | 44 ++++++++ .../bindings/regulator/samsung,s2mpu02.yaml | 44 ++++++++ MAINTAINERS | 2 +- 7 files changed, 221 insertions(+), 103 deletions(-) delete mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mps11.txt create mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mps11.yaml create mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mps13.yaml create mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mps14.yaml create mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mps15.yaml create mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mpu02.yaml diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mps11.txt b/Documentation/devicetree/bindings/regulator/samsung,s2mps11.txt deleted file mode 100644 index 27a48bf1b185..000000000000 --- a/Documentation/devicetree/bindings/regulator/samsung,s2mps11.txt +++ /dev/null @@ -1,102 +0,0 @@ -Binding for Samsung S2M family regulator block -============================================== - -This is a part of device tree bindings for S2M family multi-function devices. -More information can be found in bindings/mfd/sec-core.txt file. - -The S2MPS11/13/14/15 and S2MPU02 devices provide buck and LDO regulators. - -To register these with regulator framework instantiate under main device node -a sub-node named "regulators" with more sub-nodes for each regulator using the -common regulator binding documented in: - - Documentation/devicetree/bindings/regulator/regulator.txt - - -Names of regulators supported by different devices: - - LDOn - - valid values for n are: - - S2MPS11: 1 to 38 - - S2MPS13: 1 to 40 - - S2MPS14: 1 to 25 - - S2MPS15: 1 to 27 - - S2MPU02: 1 to 28 - - Example: LDO1, LDO2, LDO28 - - BUCKn - - valid values for n are: - - S2MPS11: 1 to 10 - - S2MPS13: 1 to 10 - - S2MPS14: 1 to 5 - - S2MPS15: 1 to 10 - - S2MPU02: 1 to 7 - - Example: BUCK1, BUCK2, BUCK9 -Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number -as per the datasheet of device. - - -Optional properties of the nodes under "regulators" sub-node: - - regulator-ramp-delay: ramp delay in uV/us. May be 6250, 12500, - 25000 (default) or 50000. - - Additionally S2MPS11 supports disabling ramp delay for BUCK{2,3,4,6} - by setting it to <0>. - - Note: On S2MPS11 some bucks share the ramp rate setting i.e. same ramp value - will be set for a particular group of bucks so provide the same - regulator-ramp-delay value for them. - Groups sharing ramp rate: - - buck{1,6}, - - buck{3,4}, - - buck{7,8,10}. - - - samsung,ext-control-gpios: On S2MPS14 the LDO10, LDO11 and LDO12 can be - configured to external control over GPIO. To turn this feature on this - property must be added to the regulator sub-node: - - samsung,ext-control-gpios: GPIO specifier for one GPIO - controlling this regulator (enable/disable) - Example: - LDO12 { - regulator-name = "V_EMMC_2.8V"; - regulator-min-microvolt = <2800000>; - regulator-max-microvolt = <2800000>; - samsung,ext-control-gpios = <&gpk0 2 0>; - }; - - -Example: - - s2mps11_pmic@66 { - compatible = "samsung,s2mps11-pmic"; - reg = <0x66>; - - regulators { - ldo1_reg: LDO1 { - regulator-name = "VDD_ABB_3.3V"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - }; - - ldo2_reg: LDO2 { - regulator-name = "VDD_ALIVE_1.1V"; - regulator-min-microvolt = <1100000>; - regulator-max-microvolt = <1100000>; - regulator-always-on; - }; - - buck1_reg: BUCK1 { - regulator-name = "vdd_mif"; - regulator-min-microvolt = <950000>; - regulator-max-microvolt = <1350000>; - regulator-always-on; - regulator-boot-on; - }; - - buck2_reg: BUCK2 { - regulator-name = "vdd_arm"; - regulator-min-microvolt = <950000>; - regulator-max-microvolt = <1350000>; - regulator-always-on; - regulator-boot-on; - regulator-ramp-delay = <50000>; - }; - }; - }; diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mps11.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2mps11.yaml new file mode 100644 index 000000000000..e3b780715f44 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2mps11.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2mps11.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPS11 Power Management IC regulators + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2MPS11 provides buck and LDO regulators. + + See also Documentation/devicetree/bindings/mfd/samsung,s2mps11.yaml for + additional information and example. + +patternProperties: + # 38 LDOs + "^LDO([1-9]|[1-2][0-9]|3[0-8])$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + required: + - regulator-name + + # 10 bucks + "^BUCK([1-9]|10)$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + required: + - regulator-name + +additionalProperties: false diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mps13.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2mps13.yaml new file mode 100644 index 000000000000..579d77aefc3f --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2mps13.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2mps13.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPS13 Power Management IC regulators + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2MPS13 provides buck and LDO regulators. + + See also Documentation/devicetree/bindings/mfd/samsung,s2mps11.yaml for + additional information and example. + +patternProperties: + # 40 LDOs + "^LDO([1-9]|[1-3][0-9]|40)$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + required: + - regulator-name + + # 10 bucks + "^BUCK([1-9]|10)$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + required: + - regulator-name + +additionalProperties: false diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mps14.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2mps14.yaml new file mode 100644 index 000000000000..fdea290b3e94 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2mps14.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2mps14.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPS14 Power Management IC regulators + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2MPS14 provides buck and LDO regulators. + + See also Documentation/devicetree/bindings/mfd/samsung,s2mps11.yaml for + additional information and example. + +patternProperties: + # 25 LDOs + "^LDO([1-9]|[1][0-9]|2[0-5])$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + required: + - regulator-name + + # 5 bucks + "^BUCK[1-5]$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + required: + - regulator-name + +additionalProperties: false diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mps15.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2mps15.yaml new file mode 100644 index 000000000000..b3a883c94628 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2mps15.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2mps15.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPS15 Power Management IC regulators + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2MPS15 provides buck and LDO regulators. + + See also Documentation/devicetree/bindings/mfd/samsung,s2mps11.yaml for + additional information and example. + +patternProperties: + # 27 LDOs + "^LDO([1-9]|[1][0-9]|2[0-7])$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + required: + - regulator-name + + # 10 bucks + "^BUCK([1-9]|10)$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + required: + - regulator-name + +additionalProperties: false diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mpu02.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2mpu02.yaml new file mode 100644 index 000000000000..0ded6953e3b6 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2mpu02.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2mpu02.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPU02 Power Management IC regulators + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2MPU02 provides buck and LDO regulators. + + See also Documentation/devicetree/bindings/mfd/samsung,s2mps11.yaml for + additional information and example. + +patternProperties: + # 28 LDOs + "^LDO([1-9]|1[0-9]|2[0-8])$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + required: + - regulator-name + + # 7 bucks + "^BUCK[1-7]$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + required: + - regulator-name + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index a2a8aaa88209..845c7ed123d7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16332,7 +16332,7 @@ L: linux-samsung-soc@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml F: Documentation/devicetree/bindings/mfd/samsung,sec-core.txt -F: Documentation/devicetree/bindings/regulator/samsung,s2m*.txt +F: Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml F: Documentation/devicetree/bindings/regulator/samsung,s5m*.txt F: drivers/clk/clk-s2mps11.c F: drivers/mfd/sec*.c From a52afb0f54faae0366575d47cbd85165ce34deda Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 8 Oct 2021 13:39:27 +0200 Subject: [PATCH 22/34] regulator: dt-bindings: samsung,s2mpa01: convert to dtschema Convert the regulators of Samsung S2MPA01 PMIC to DT schema format. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Message-Id: <20211008113931.134847-2-krzysztof.kozlowski@canonical.com> Signed-off-by: Mark Brown --- .../bindings/regulator/samsung,s2mpa01.txt | 79 ------------------- .../bindings/regulator/samsung,s2mpa01.yaml | 62 +++++++++++++++ 2 files changed, 62 insertions(+), 79 deletions(-) delete mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mpa01.txt create mode 100644 Documentation/devicetree/bindings/regulator/samsung,s2mpa01.yaml diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mpa01.txt b/Documentation/devicetree/bindings/regulator/samsung,s2mpa01.txt deleted file mode 100644 index bae3c7f838cf..000000000000 --- a/Documentation/devicetree/bindings/regulator/samsung,s2mpa01.txt +++ /dev/null @@ -1,79 +0,0 @@ -Binding for Samsung S2MPA01 regulator block -=========================================== - -This is a part of device tree bindings for S2M family multi-function devices. -More information can be found in bindings/mfd/sec-core.txt file. - -The S2MPA01 device provide buck and LDO regulators. - -To register these with regulator framework instantiate under main device node -a sub-node named "regulators" with more sub-nodes for each regulator using the -common regulator binding documented in: - - Documentation/devicetree/bindings/regulator/regulator.txt - - -Names of regulators supported by S2MPA01 device: - - LDOn - - valid values for n are 1 to 26 - - Example: LDO1, LD02, LDO26 - - BUCKn - - valid values for n are 1 to 10. - - Example: BUCK1, BUCK2, BUCK9 -Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number -as per the datasheet of device. - - -Optional properties of buck regulator nodes under "regulators" sub-node: - - regulator-ramp-delay: ramp delay in uV/us. May be 6250, 12500 - (default), 25000, or 50000. May be 0 for disabling the ramp delay on - BUCK{1,2,3,4}. - - In the absence of the regulator-ramp-delay property, the default ramp - delay will be used. - - Note: Some bucks share the ramp rate setting i.e. same ramp value - will be set for a particular group of bucks so provide the same - regulator-ramp-delay value for them. - Groups sharing ramp rate: - - buck{1,6}, - - buck{2,4}, - - buck{8,9,10}. - -Example: - - s2mpa01_pmic@66 { - compatible = "samsung,s2mpa01-pmic"; - reg = <0x66>; - - regulators { - ldo1_reg: LDO1 { - regulator-name = "VDD_ALIVE"; - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <1000000>; - }; - - ldo2_reg: LDO2 { - regulator-name = "VDDQ_MMC2"; - regulator-min-microvolt = <2800000>; - regulator-max-microvolt = <2800000>; - regulator-always-on; - }; - - buck1_reg: BUCK1 { - regulator-name = "vdd_mif"; - regulator-min-microvolt = <950000>; - regulator-max-microvolt = <1350000>; - regulator-always-on; - regulator-boot-on; - }; - - buck2_reg: BUCK2 { - regulator-name = "vdd_arm"; - regulator-min-microvolt = <950000>; - regulator-max-microvolt = <1350000>; - regulator-always-on; - regulator-boot-on; - regulator-ramp-delay = <50000>; - }; - }; - }; diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2mpa01.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2mpa01.yaml new file mode 100644 index 000000000000..0627dec513da --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2mpa01.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2mpa01.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2MPA01 Power Management IC regulators + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2MPA01 provides buck and LDO regulators. + + See also Documentation/devicetree/bindings/mfd/samsung,s2mpa01.yaml for + additional information and example. + +patternProperties: + # 26 LDOs + "^LDO([1-9]|1[0-9]|2[0-6])$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + required: + - regulator-name + + # 10 bucks + "^BUCK([1-9]|10)$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + properties: + regulator-ramp-delay: + enum: [0, 6250, 12500, 25000, 50000] + default: 12500 + description: | + May be 0 for disabling the ramp delay on BUCK{1,2,3,4}. + + In the absence of the regulator-ramp-delay property, the default ramp + delay will be used. + + Note: Some bucks share the ramp rate setting i.e. same ramp value + will be set for a particular group of bucks so provide the same + regulator-ramp-delay value for them. + Groups sharing ramp rate: + * buck{1,6}, + * buck{2,4}, + * buck{8,9,10}. + + required: + - regulator-name + +additionalProperties: false From fab58debc137f66cf97f60c8471ff2f1e3e1b44b Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 8 Oct 2021 13:39:28 +0200 Subject: [PATCH 23/34] regulator: dt-bindings: samsung,s5m8767: convert to dtschema Convert the regulators of Samsung S5M8767 PMIC to DT schema format. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Message-Id: <20211008113931.134847-3-krzysztof.kozlowski@canonical.com> Signed-off-by: Mark Brown --- .../bindings/regulator/samsung,s5m8767.txt | 140 ------------------ .../bindings/regulator/samsung,s5m8767.yaml | 74 +++++++++ MAINTAINERS | 2 +- 3 files changed, 75 insertions(+), 141 deletions(-) delete mode 100644 Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt create mode 100644 Documentation/devicetree/bindings/regulator/samsung,s5m8767.yaml diff --git a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt deleted file mode 100644 index 6cd83d920155..000000000000 --- a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.txt +++ /dev/null @@ -1,140 +0,0 @@ -Binding for Samsung S5M8767 regulator block -=========================================== - -This is a part of device tree bindings for S5M family multi-function devices. -More information can be found in bindings/mfd/sec-core.txt file. - -The S5M8767 device provide buck and LDO regulators. - -To register these with regulator framework instantiate under main device node -a sub-node named "regulators" with more sub-nodes for each regulator using the -common regulator binding documented in: - - Documentation/devicetree/bindings/regulator/regulator.txt - - -Required properties of the main device node (the parent!): - - s5m8767,pmic-buck-ds-gpios: GPIO specifiers for three host gpio's used - for selecting GPIO DVS lines. It is one-to-one mapped to dvs gpio lines. - - [1] If either of the 's5m8767,pmic-buck[2/3/4]-uses-gpio-dvs' optional - property is specified, then all the eight voltage values for the - 's5m8767,pmic-buck[2/3/4]-dvs-voltage' should be specified. - -Optional properties of the main device node (the parent!): - - s5m8767,pmic-buck2-dvs-voltage: A set of 8 voltage values in micro-volt (uV) - units for buck2 when changing voltage using gpio dvs. Refer to [1] below - for additional information. - - - s5m8767,pmic-buck3-dvs-voltage: A set of 8 voltage values in micro-volt (uV) - units for buck3 when changing voltage using gpio dvs. Refer to [1] below - for additional information. - - - s5m8767,pmic-buck4-dvs-voltage: A set of 8 voltage values in micro-volt (uV) - units for buck4 when changing voltage using gpio dvs. Refer to [1] below - for additional information. - - - s5m8767,pmic-buck2-uses-gpio-dvs: 'buck2' can be controlled by gpio dvs. - - s5m8767,pmic-buck3-uses-gpio-dvs: 'buck3' can be controlled by gpio dvs. - - s5m8767,pmic-buck4-uses-gpio-dvs: 'buck4' can be controlled by gpio dvs. - -Additional properties required if either of the optional properties are used: - - - s5m8767,pmic-buck-default-dvs-idx: Default voltage setting selected from - the possible 8 options selectable by the dvs gpios. The value of this - property should be between 0 and 7. If not specified or if out of range, the - default value of this property is set to 0. - - - s5m8767,pmic-buck-dvs-gpios: GPIO specifiers for three host gpio's used - for dvs. The format of the gpio specifier depends in the gpio controller. - - -Names of regulators supported by S5M8767 device: - - LDOn - - valid values for n are 1 to 28 - - Example: LDO1, LDO2, LDO28 - - BUCKn - - valid values for n are 1 to 9. - - Example: BUCK1, BUCK2, BUCK9 -Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number -as per the datasheet of device. - - -Optional properties of the nodes under "regulators" sub-node: - - op_mode: describes the different operating modes of the LDO's with - power mode change in SOC. The different possible values are, - 0 - always off mode - 1 - on in normal mode - 2 - low power mode - 3 - suspend mode - - s5m8767,pmic-ext-control-gpios: (optional) GPIO specifier for one - GPIO controlling this regulator - (enable/disable); This is valid only - for buck9. - -Example: - - s5m8767_pmic@66 { - compatible = "samsung,s5m8767-pmic"; - reg = <0x66>; - - s5m8767,pmic-buck2-uses-gpio-dvs; - s5m8767,pmic-buck3-uses-gpio-dvs; - s5m8767,pmic-buck4-uses-gpio-dvs; - - s5m8767,pmic-buck-default-dvs-idx = <0>; - - s5m8767,pmic-buck-dvs-gpios = <&gpx0 0 0>, /* DVS1 */ - <&gpx0 1 0>, /* DVS2 */ - <&gpx0 2 0>; /* DVS3 */ - - s5m8767,pmic-buck-ds-gpios = <&gpx2 3 0>, /* SET1 */ - <&gpx2 4 0>, /* SET2 */ - <&gpx2 5 0>; /* SET3 */ - - s5m8767,pmic-buck2-dvs-voltage = <1350000>, <1300000>, - <1250000>, <1200000>, - <1150000>, <1100000>, - <1000000>, <950000>; - - s5m8767,pmic-buck3-dvs-voltage = <1100000>, <1100000>, - <1100000>, <1100000>, - <1000000>, <1000000>, - <1000000>, <1000000>; - - s5m8767,pmic-buck4-dvs-voltage = <1200000>, <1200000>, - <1200000>, <1200000>, - <1200000>, <1200000>, - <1200000>, <1200000>; - - regulators { - ldo1_reg: LDO1 { - regulator-name = "VDD_ABB_3.3V"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - op_mode = <1>; /* Normal Mode */ - }; - - ldo2_reg: LDO2 { - regulator-name = "VDD_ALIVE_1.1V"; - regulator-min-microvolt = <1100000>; - regulator-max-microvolt = <1100000>; - regulator-always-on; - }; - - buck1_reg: BUCK1 { - regulator-name = "VDD_MIF_1.2V"; - regulator-min-microvolt = <950000>; - regulator-max-microvolt = <1350000>; - regulator-always-on; - regulator-boot-on; - }; - - vemmc_reg: BUCK9 { - regulator-name = "VMEM_VDD_2.8V"; - regulator-min-microvolt = <2800000>; - regulator-max-microvolt = <2800000>; - op_mode = <3>; /* Standby Mode */ - s5m8767,pmic-ext-control-gpios = <&gpk0 2 0>; - }; - }; - }; diff --git a/Documentation/devicetree/bindings/regulator/samsung,s5m8767.yaml b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.yaml new file mode 100644 index 000000000000..80a63d47790a --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s5m8767.yaml @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s5m8767.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S5M8767 Power Management IC regulators + +maintainers: + - Krzysztof Kozlowski + +description: | + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S5M8767 provides buck and LDO regulators. + + See also Documentation/devicetree/bindings/mfd/samsung,s5m8767.yaml for + additional information and example. + +patternProperties: + # 28 LDOs + "^LDO([1-9]|1[0-9]|2[0-8])$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + properties: + op_mode: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + default: 1 + description: | + Describes the different operating modes of the LDO's with power mode + change in SOC. The different possible values are: + 0 - always off mode + 1 - on in normal mode + 2 - low power mode + 3 - suspend mode + + required: + - regulator-name + + # 8 bucks + "^BUCK[1-8]$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + required: + - regulator-name + + # 9 buck + "^BUCK9$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single BUCK regulator. + + properties: + s5m8767,pmic-ext-control-gpios: + maxItems: 1 + description: | + GPIO specifier for one GPIO controlling this regulator on/off. + + required: + - regulator-name + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index 845c7ed123d7..202da82e0f6d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16333,7 +16333,7 @@ S: Supported F: Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml F: Documentation/devicetree/bindings/mfd/samsung,sec-core.txt F: Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml -F: Documentation/devicetree/bindings/regulator/samsung,s5m*.txt +F: Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml F: drivers/clk/clk-s2mps11.c F: drivers/mfd/sec*.c F: drivers/regulator/s2m*.c From 72bf80cf09c4693780ad93a31b48fa5a4e17a946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= Date: Fri, 15 Oct 2021 12:14:35 -0300 Subject: [PATCH 24/34] regulator: lp872x: replacing legacy gpio interface for gpiod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removing all linux/gpio.h and linux/of_gpio.h dependencies and replacing them with the gpiod interface Signed-off-by: Maíra Canal Message-Id: Signed-off-by: Mark Brown --- drivers/regulator/lp872x.c | 38 +++++++++++++------------------- include/linux/regulator/lp872x.h | 14 ++++++------ 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index e84be29533f4..1dba5dbcd461 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -10,13 +10,12 @@ #include #include #include -#include +#include #include #include #include #include #include -#include #include /* Registers : LP8720/8725 shared */ @@ -250,12 +249,12 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev) } static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel, - int gpio) + struct gpio_desc *gpio) { enum lp872x_dvs_state state; state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW; - gpio_set_value(gpio, state); + gpiod_set_value(gpio, state); lp->dvs_pin = state; } @@ -321,7 +320,7 @@ static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev, u8 addr, mask = LP872X_VOUT_M; struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; - if (dvs && gpio_is_valid(dvs->gpio)) + if (dvs && dvs->gpio) lp872x_set_dvs(lp, dvs->vsel, dvs->gpio); addr = lp872x_select_buck_vout_addr(lp, buck); @@ -675,7 +674,6 @@ static const struct regulator_desc lp8725_regulator_desc[] = { static int lp872x_init_dvs(struct lp872x *lp) { - int ret, gpio; struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; enum lp872x_dvs_state pinstate; u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M }; @@ -684,15 +682,15 @@ static int lp872x_init_dvs(struct lp872x *lp) if (!dvs) goto set_default_dvs_mode; - gpio = dvs->gpio; - if (!gpio_is_valid(gpio)) + if (!dvs->gpio) goto set_default_dvs_mode; pinstate = dvs->init_state; - ret = devm_gpio_request_one(lp->dev, gpio, pinstate, "LP872X DVS"); - if (ret) { - dev_err(lp->dev, "gpio request err: %d\n", ret); - return ret; + dvs->gpio = devm_gpiod_get_optional(lp->dev, "ti,dvs", pinstate); + + if (IS_ERR(dvs->gpio)) { + dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(dvs->gpio)); + return PTR_ERR(dvs->gpio); } lp->dvs_pin = pinstate; @@ -706,20 +704,17 @@ set_default_dvs_mode: static int lp872x_hw_enable(struct lp872x *lp) { - int ret, gpio; - if (!lp->pdata) return -EINVAL; - gpio = lp->pdata->enable_gpio; - if (!gpio_is_valid(gpio)) + if (!lp->pdata->enable_gpio) return 0; /* Always set enable GPIO high. */ - ret = devm_gpio_request_one(lp->dev, gpio, GPIOF_OUT_INIT_HIGH, "LP872X EN"); - if (ret) { - dev_err(lp->dev, "gpio request err: %d\n", ret); - return ret; + lp->pdata->enable_gpio = devm_gpiod_get_optional(lp->dev, "enable", GPIOD_OUT_HIGH); + if (IS_ERR(lp->pdata->enable_gpio)) { + dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(lp->pdata->enable_gpio)); + return PTR_ERR(lp->pdata->enable_gpio); } /* Each chip has a different enable delay. */ @@ -844,13 +839,10 @@ static struct lp872x_platform_data if (!pdata->dvs) return ERR_PTR(-ENOMEM); - pdata->dvs->gpio = of_get_named_gpio(np, "ti,dvs-gpio", 0); of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); of_property_read_u8(np, "ti,dvs-state", &dvs_state); pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; - pdata->enable_gpio = of_get_named_gpio(np, "enable-gpios", 0); - if (of_get_child_count(np) == 0) goto out; diff --git a/include/linux/regulator/lp872x.h b/include/linux/regulator/lp872x.h index d780dbb8b423..8e7e0343c6e1 100644 --- a/include/linux/regulator/lp872x.h +++ b/include/linux/regulator/lp872x.h @@ -10,7 +10,7 @@ #include #include -#include +#include #define LP872X_MAX_REGULATORS 9 @@ -41,8 +41,8 @@ enum lp872x_regulator_id { }; enum lp872x_dvs_state { - DVS_LOW = GPIOF_OUT_INIT_LOW, - DVS_HIGH = GPIOF_OUT_INIT_HIGH, + DVS_LOW = GPIOD_OUT_LOW, + DVS_HIGH = GPIOD_OUT_HIGH, }; enum lp872x_dvs_sel { @@ -52,12 +52,12 @@ enum lp872x_dvs_sel { /** * lp872x_dvs - * @gpio : gpio pin number for dvs control + * @gpio : gpio descriptor for dvs control * @vsel : dvs selector for buck v1 or buck v2 register * @init_state : initial dvs pin state */ struct lp872x_dvs { - int gpio; + struct gpio_desc *gpio; enum lp872x_dvs_sel vsel; enum lp872x_dvs_state init_state; }; @@ -78,14 +78,14 @@ struct lp872x_regulator_data { * @update_config : if LP872X_GENERAL_CFG register is updated, set true * @regulator_data : platform regulator id and init data * @dvs : dvs data for buck voltage control - * @enable_gpio : gpio pin number for enable control + * @enable_gpio : gpio descriptor for enable control */ struct lp872x_platform_data { u8 general_config; bool update_config; struct lp872x_regulator_data regulator_data[LP872X_MAX_REGULATORS]; struct lp872x_dvs *dvs; - int enable_gpio; + struct gpio_desc *enable_gpio; }; #endif From 061514dbfb79910ef60eb40dd9fc528be3f45d62 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 18 Oct 2021 17:43:35 -0700 Subject: [PATCH 25/34] regulator: lp872x: Remove lp872x_dvs_state After this driver was converted to gpiod, clang started warning: vers/regulator/lp872x.c:689:57: error: implicit conversion from enumeration type 'enum lp872x_dvs_state' to different enumeration type 'enum gpiod_flags' [-Werror,-Wenum-conversion] dvs->gpio = devm_gpiod_get_optional(lp->dev, "ti,dvs", pinstate); ~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~ 1 error generated. lp872x_dvs_state was updated to have values from gpiod_flags but this is not enough to avoid an implicit conversion warning from either GCC or clang (although GCC enables this warning under -Wextra instead of -Wall like clang so it is not seen under normal builds). Eliminate lp872x_dvs_state in favor of using gpiod_flags everywhere so that there is no more warning about an implicit conversion. Fixes: 72bf80cf09c4 ("regulator: lp872x: replacing legacy gpio interface for gpiod") Link: https://github.com/ClangBuiltLinux/linux/issues/1481 Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20211019004335.193492-1-nathan@kernel.org Signed-off-by: Mark Brown --- drivers/regulator/lp872x.c | 14 +++++++------- include/linux/regulator/lp872x.h | 7 +------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 1dba5dbcd461..35d826fe9def 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -103,7 +103,7 @@ struct lp872x { enum lp872x_id chipid; struct lp872x_platform_data *pdata; int num_regulators; - enum lp872x_dvs_state dvs_pin; + enum gpiod_flags dvs_pin; }; /* LP8720/LP8725 shared voltage table for LDOs */ @@ -251,9 +251,9 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev) static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel, struct gpio_desc *gpio) { - enum lp872x_dvs_state state; + enum gpiod_flags state; - state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW; + state = dvs_sel == SEL_V1 ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; gpiod_set_value(gpio, state); lp->dvs_pin = state; } @@ -269,7 +269,7 @@ static u8 lp872x_select_buck_vout_addr(struct lp872x *lp, switch (buck) { case LP8720_ID_BUCK: if (val & LP8720_EXT_DVS_M) { - addr = (lp->dvs_pin == DVS_HIGH) ? + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? LP8720_BUCK_VOUT1 : LP8720_BUCK_VOUT2; } else { if (lp872x_read_byte(lp, LP8720_ENABLE, &val)) @@ -283,7 +283,7 @@ static u8 lp872x_select_buck_vout_addr(struct lp872x *lp, if (val & LP8725_DVS1_M) addr = LP8725_BUCK1_VOUT1; else - addr = (lp->dvs_pin == DVS_HIGH) ? + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? LP8725_BUCK1_VOUT1 : LP8725_BUCK1_VOUT2; break; case LP8725_ID_BUCK2: @@ -675,7 +675,7 @@ static const struct regulator_desc lp8725_regulator_desc[] = { static int lp872x_init_dvs(struct lp872x *lp) { struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; - enum lp872x_dvs_state pinstate; + enum gpiod_flags pinstate; u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M }; u8 default_dvs_mode[] = { LP8720_DEFAULT_DVS, LP8725_DEFAULT_DVS }; @@ -841,7 +841,7 @@ static struct lp872x_platform_data of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); of_property_read_u8(np, "ti,dvs-state", &dvs_state); - pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; + pdata->dvs->init_state = dvs_state ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; if (of_get_child_count(np) == 0) goto out; diff --git a/include/linux/regulator/lp872x.h b/include/linux/regulator/lp872x.h index 8e7e0343c6e1..b62e45aa1dd3 100644 --- a/include/linux/regulator/lp872x.h +++ b/include/linux/regulator/lp872x.h @@ -40,11 +40,6 @@ enum lp872x_regulator_id { LP872X_ID_MAX, }; -enum lp872x_dvs_state { - DVS_LOW = GPIOD_OUT_LOW, - DVS_HIGH = GPIOD_OUT_HIGH, -}; - enum lp872x_dvs_sel { SEL_V1, SEL_V2, @@ -59,7 +54,7 @@ enum lp872x_dvs_sel { struct lp872x_dvs { struct gpio_desc *gpio; enum lp872x_dvs_sel vsel; - enum lp872x_dvs_state init_state; + enum gpiod_flags init_state; }; /** From 6a8b5bb0f1350fc4cf398435a1119db12b0bd50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= Date: Sun, 17 Oct 2021 15:06:39 -0300 Subject: [PATCH 26/34] regulator: tps62360: replacing legacy gpio interface for gpiod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removing all linux/gpio.h and linux/of_gpio.h dependencies and replacing them with the gpiod interface. Signed-off-by: Maíra Canal Link: https://lore.kernel.org/r/YWxmL2baF5AdzyHv@fedora Signed-off-by: Mark Brown --- drivers/regulator/tps62360-regulator.c | 59 ++++++++++++-------------- include/linux/regulator/tps62360.h | 6 --- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 315cd5daf480..574958690ace 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -28,13 +28,12 @@ #include #include #include -#include #include #include #include #include #include -#include +#include #include #include #include @@ -65,8 +64,8 @@ struct tps62360_chip { struct regulator_desc desc; struct regulator_dev *rdev; struct regmap *regmap; - int vsel0_gpio; - int vsel1_gpio; + struct gpio_desc *vsel0_gpio; + struct gpio_desc *vsel1_gpio; u8 voltage_reg_mask; bool en_internal_pulldn; bool en_discharge; @@ -165,8 +164,8 @@ static int tps62360_dcdc_set_voltage_sel(struct regulator_dev *dev, /* Select proper VSET register vio gpios */ if (tps->valid_gpios) { - gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); - gpio_set_value_cansleep(tps->vsel1_gpio, + gpiod_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); + gpiod_set_value_cansleep(tps->vsel1_gpio, (new_vset_id >> 1) & 0x1); } return 0; @@ -310,9 +309,6 @@ static struct tps62360_regulator_platform_data * return NULL; } - pdata->vsel0_gpio = of_get_named_gpio(np, "vsel0-gpio", 0); - pdata->vsel1_gpio = of_get_named_gpio(np, "vsel1-gpio", 0); - if (of_find_property(np, "ti,vsel0-state-high", NULL)) pdata->vsel0_def_state = 1; @@ -349,6 +345,7 @@ static int tps62360_probe(struct i2c_client *client, int ret; int i; int chip_id; + int gpio_flags; pdata = dev_get_platdata(&client->dev); @@ -390,8 +387,6 @@ static int tps62360_probe(struct i2c_client *client, tps->en_discharge = pdata->en_discharge; tps->en_internal_pulldn = pdata->en_internal_pulldn; - tps->vsel0_gpio = pdata->vsel0_gpio; - tps->vsel1_gpio = pdata->vsel1_gpio; tps->dev = &client->dev; switch (chip_id) { @@ -426,29 +421,27 @@ static int tps62360_probe(struct i2c_client *client, tps->lru_index[0] = tps->curr_vset_id; tps->valid_gpios = false; - if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { - int gpio_flags; - gpio_flags = (pdata->vsel0_def_state) ? - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - ret = devm_gpio_request_one(&client->dev, tps->vsel0_gpio, - gpio_flags, "tps62360-vsel0"); - if (ret) { - dev_err(&client->dev, - "%s(): Could not obtain vsel0 GPIO %d: %d\n", - __func__, tps->vsel0_gpio, ret); - return ret; - } + gpio_flags = (pdata->vsel0_def_state) ? + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + tps->vsel0_gpio = devm_gpiod_get_optional(&client->dev, "vsel0", gpio_flags); + if (IS_ERR(tps->vsel0_gpio)) { + dev_err(&client->dev, + "%s(): Could not obtain vsel0 GPIO: %ld\n", + __func__, PTR_ERR(tps->vsel0_gpio)); + return PTR_ERR(tps->vsel0_gpio); + } - gpio_flags = (pdata->vsel1_def_state) ? - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - ret = devm_gpio_request_one(&client->dev, tps->vsel1_gpio, - gpio_flags, "tps62360-vsel1"); - if (ret) { - dev_err(&client->dev, - "%s(): Could not obtain vsel1 GPIO %d: %d\n", - __func__, tps->vsel1_gpio, ret); - return ret; - } + gpio_flags = (pdata->vsel1_def_state) ? + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + tps->vsel1_gpio = devm_gpiod_get_optional(&client->dev, "vsel1", gpio_flags); + if (IS_ERR(tps->vsel1_gpio)) { + dev_err(&client->dev, + "%s(): Could not obtain vsel1 GPIO: %ld\n", + __func__, PTR_ERR(tps->vsel1_gpio)); + return PTR_ERR(tps->vsel1_gpio); + } + + if (tps->vsel0_gpio != NULL && tps->vsel1_gpio != NULL) { tps->valid_gpios = true; /* diff --git a/include/linux/regulator/tps62360.h b/include/linux/regulator/tps62360.h index 94a90c06f1e5..398e74a1d941 100644 --- a/include/linux/regulator/tps62360.h +++ b/include/linux/regulator/tps62360.h @@ -19,10 +19,6 @@ * @en_discharge: Enable discharge the output capacitor via internal * register. * @en_internal_pulldn: internal pull down enable or not. - * @vsel0_gpio: Gpio number for vsel0. It should be -1 if this is tied with - * fixed logic. - * @vsel1_gpio: Gpio number for vsel1. It should be -1 if this is tied with - * fixed logic. * @vsel0_def_state: Default state of vsel0. 1 if it is high else 0. * @vsel1_def_state: Default state of vsel1. 1 if it is high else 0. */ @@ -30,8 +26,6 @@ struct tps62360_regulator_platform_data { struct regulator_init_data *reg_init_data; bool en_discharge; bool en_internal_pulldn; - int vsel0_gpio; - int vsel1_gpio; int vsel0_def_state; int vsel1_def_state; }; From cb17820ef71ed70f70ee1eed2b378664746b6fde Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Fri, 15 Oct 2021 22:25:46 +1000 Subject: [PATCH 27/34] regulator: sy7636a: Remove requirement on sy7636a mfd Signed-off-by: Alistair Francis Link: https://lore.kernel.org/r/20211015122551.38951-5-alistair@alistair23.me Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 1 - drivers/regulator/sy7636a-regulator.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 27578e9504d2..43bf4602ff62 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1199,7 +1199,6 @@ config REGULATOR_STW481X_VMMC config REGULATOR_SY7636A tristate "Silergy SY7636A voltage regulator" - depends on MFD_SY7636A help This driver supports Silergy SY3686A voltage regulator. diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c index 8360b3947ead..22fddf868e4c 100644 --- a/drivers/regulator/sy7636a-regulator.c +++ b/drivers/regulator/sy7636a-regulator.c @@ -70,7 +70,7 @@ static const struct regulator_desc desc = { static int sy7636a_regulator_probe(struct platform_device *pdev) { - struct regmap *regmap = dev_get_drvdata(pdev->dev.parent); + struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL); struct regulator_config config = { }; struct regulator_dev *rdev; struct gpio_desc *gdp; From 0adafd62505ccb4787d4918fd0b4ca126b754453 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Thu, 7 Oct 2021 23:24:30 +0200 Subject: [PATCH 28/34] regulator: qcom-rpmh: Add PM6350 regulators Add the configuration for pm6350 regulators. The supplies are not known so leave them out for now. Additionally leave out configuration of smps3 - smps5 and ldo17 as these are not configured in the downstream kernel and the type of them is not known. Signed-off-by: Luca Weiss Link: https://lore.kernel.org/r/20211007212444.328034-4-luca@z3ntu.xyz Signed-off-by: Mark Brown --- drivers/regulator/qcom-rpmh-regulator.c | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c index 7f458d510483..12425f667c00 100644 --- a/drivers/regulator/qcom-rpmh-regulator.c +++ b/drivers/regulator/qcom-rpmh-regulator.c @@ -1047,6 +1047,34 @@ static const struct rpmh_vreg_init_data pm6150l_vreg_data[] = { {} }; +static const struct rpmh_vreg_init_data pm6350_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, NULL), + RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, NULL), + /* smps3 - smps5 not configured */ + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, NULL), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_pldo, NULL), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_pldo, NULL), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, NULL), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, NULL), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, NULL), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, NULL), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, NULL), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, NULL), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, NULL), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, NULL), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo, NULL), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_nldo, NULL), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo, NULL), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_nldo, NULL), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_nldo, NULL), + /* ldo17 not configured */ + RPMH_VREG("ldo18", "ldo%s18", &pmic5_nldo, NULL), + RPMH_VREG("ldo19", "ldo%s19", &pmic5_nldo, NULL), + RPMH_VREG("ldo20", "ldo%s20", &pmic5_nldo, NULL), + RPMH_VREG("ldo21", "ldo%s21", &pmic5_nldo, NULL), + RPMH_VREG("ldo22", "ldo%s22", &pmic5_nldo, NULL), +}; + static const struct rpmh_vreg_init_data pmx55_vreg_data[] = { RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), RPMH_VREG("smps2", "smp%s2", &pmic5_hfsmps510, "vdd-s2"), @@ -1201,6 +1229,10 @@ static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] = { .compatible = "qcom,pm6150l-rpmh-regulators", .data = pm6150l_vreg_data, }, + { + .compatible = "qcom,pm6350-rpmh-regulators", + .data = pm6350_vreg_data, + }, { .compatible = "qcom,pmc8180-rpmh-regulators", .data = pm8150_vreg_data, From 12271ba94530e7476eff09e98a7de10c31f5d474 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Thu, 7 Oct 2021 23:24:29 +0200 Subject: [PATCH 29/34] regulator: qcom,rpmh: Add compatible for PM6350 Add compatible string for pm6350 used in sm6350 boards. Signed-off-by: Luca Weiss Link: https://lore.kernel.org/r/20211007212444.328034-3-luca@z3ntu.xyz Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/qcom,rpmh-regulator.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.yaml b/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.yaml index 34de38377aa6..b959504e0ea4 100644 --- a/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.yaml @@ -35,6 +35,7 @@ description: | PMIC. Supported regulator node names are For PM6150, smps1 - smps5, ldo1 - ldo19 For PM6150L, smps1 - smps8, ldo1 - ldo11, bob + For PM6350, smps1 - smps5, ldo1 - ldo22 For PM7325, smps1 - smps8, ldo1 - ldo19 For PM8005, smps1 - smps4 For PM8009, smps1 - smps2, ldo1 - ldo7 @@ -52,6 +53,7 @@ properties: enum: - qcom,pm6150-rpmh-regulators - qcom,pm6150l-rpmh-regulators + - qcom,pm6350-rpmh-regulators - qcom,pm7325-rpmh-regulators - qcom,pm8005-rpmh-regulators - qcom,pm8009-rpmh-regulators From 32e84faa825e8bc6431186a41b68e0fcff857b72 Mon Sep 17 00:00:00 2001 From: Kunihiko Hayashi Date: Mon, 18 Oct 2021 10:30:05 +0900 Subject: [PATCH 30/34] regulator: uniphier: Add USB-VBUS compatible string for NX1 SoC Add basic support for UniPhier NX1 SoC. This includes a compatible string and the same SoC-dependent data as PXs2 SoC. Signed-off-by: Kunihiko Hayashi Link: https://lore.kernel.org/r/1634520605-16583-3-git-send-email-hayashi.kunihiko@socionext.com Signed-off-by: Mark Brown --- drivers/regulator/uniphier-regulator.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/regulator/uniphier-regulator.c b/drivers/regulator/uniphier-regulator.c index e75b0973e325..39a68b01fc38 100644 --- a/drivers/regulator/uniphier-regulator.c +++ b/drivers/regulator/uniphier-regulator.c @@ -199,6 +199,10 @@ static const struct of_device_id uniphier_regulator_match[] = { .compatible = "socionext,uniphier-pxs3-usb3-regulator", .data = &uniphier_pxs2_usb3_data, }, + { + .compatible = "socionext,uniphier-nx1-usb3-regulator", + .data = &uniphier_pxs2_usb3_data, + }, { /* Sentinel */ }, }; MODULE_DEVICE_TABLE(of, uniphier_regulator_match); From 4c1ef56bd9c7a60efdeac9f1478b5467fb47c093 Mon Sep 17 00:00:00 2001 From: Kunihiko Hayashi Date: Mon, 18 Oct 2021 10:30:04 +0900 Subject: [PATCH 31/34] regulator: uniphier: Add binding for NX1 SoC Update USB-VBUS binding document for UniPhier NX1 SoC. Signed-off-by: Kunihiko Hayashi Link: https://lore.kernel.org/r/1634520605-16583-2-git-send-email-hayashi.kunihiko@socionext.com Signed-off-by: Mark Brown --- .../bindings/regulator/socionext,uniphier-regulator.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/regulator/socionext,uniphier-regulator.yaml b/Documentation/devicetree/bindings/regulator/socionext,uniphier-regulator.yaml index 861d5f3c79e8..1218f21ba320 100644 --- a/Documentation/devicetree/bindings/regulator/socionext,uniphier-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/socionext,uniphier-regulator.yaml @@ -27,6 +27,7 @@ properties: - socionext,uniphier-pxs2-usb3-regulator - socionext,uniphier-ld20-usb3-regulator - socionext,uniphier-pxs3-usb3-regulator + - socionext,uniphier-nx1-usb3-regulator reg: maxItems: 1 From 3253e24bc2b6418727cd05fe3a5f4f24c1118311 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 23 Oct 2021 14:18:05 +0100 Subject: [PATCH 32/34] regulator: Fix SY7636A breakage The MFD for SY7636A still isn't merged so we need a dependency even if it ends up not having a real driver due to the header file. Reported-by: Stephen Rothwell Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 43bf4602ff62..27578e9504d2 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1199,6 +1199,7 @@ config REGULATOR_STW481X_VMMC config REGULATOR_SY7636A tristate "Silergy SY7636A voltage regulator" + depends on MFD_SY7636A help This driver supports Silergy SY3686A voltage regulator. From d7477e646291b2dcdd5521cf926cd390ddd6a7c1 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Thu, 21 Oct 2021 22:22:57 +0300 Subject: [PATCH 33/34] regulator: tps80031: Remove driver Driver was upstreamed in 2013 and never got a user, remove it. Signed-off-by: Dmitry Osipenko Link: https://lore.kernel.org/r/20211021192258.21968-3-digetx@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 9 - drivers/regulator/Makefile | 1 - drivers/regulator/tps80031-regulator.c | 753 ------------------------- 3 files changed, 763 deletions(-) delete mode 100644 drivers/regulator/tps80031-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 27578e9504d2..6be9b1c8a615 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1339,15 +1339,6 @@ config REGULATOR_TPS65912 help This driver supports TPS65912 voltage regulator chip. -config REGULATOR_TPS80031 - tristate "TI TPS80031/TPS80032 power regulator driver" - depends on MFD_TPS80031 - help - TPS80031/ TPS80032 Fully Integrated Power Management with Power - Path and Battery Charger. It has 5 configurable step-down - converters, 11 general purpose LDOs, VBUS generator and digital - output to control regulators. - config REGULATOR_TWL4030 tristate "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" depends on TWL4030_CORE diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 9e382b50a5ef..b07d2a22df0b 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -158,7 +158,6 @@ obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o -obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o obj-$(CONFIG_REGULATOR_TPS65132) += tps65132-regulator.o obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o obj-$(CONFIG_REGULATOR_UNIPHIER) += uniphier-regulator.o diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c deleted file mode 100644 index a29e65230132..000000000000 --- a/drivers/regulator/tps80031-regulator.c +++ /dev/null @@ -1,753 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// tps80031-regulator.c -- TI TPS80031 regulator driver. -// -// Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power -// Management with Power Path and Battery Charger. -// -// Copyright (c) 2012, NVIDIA Corporation. -// -// Author: Laxman Dewangan - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Flags for DCDC Voltage reading */ -#define DCDC_OFFSET_EN BIT(0) -#define DCDC_EXTENDED_EN BIT(1) -#define TRACK_MODE_ENABLE BIT(2) - -#define SMPS_MULTOFFSET_VIO BIT(1) -#define SMPS_MULTOFFSET_SMPS1 BIT(3) -#define SMPS_MULTOFFSET_SMPS2 BIT(4) -#define SMPS_MULTOFFSET_SMPS3 BIT(6) -#define SMPS_MULTOFFSET_SMPS4 BIT(0) - -#define SMPS_CMD_MASK 0xC0 -#define SMPS_VSEL_MASK 0x3F -#define LDO_VSEL_MASK 0x1F -#define LDO_TRACK_VSEL_MASK 0x3F - -#define MISC2_LDOUSB_IN_VSYS BIT(4) -#define MISC2_LDOUSB_IN_PMID BIT(3) -#define MISC2_LDOUSB_IN_MASK 0x18 - -#define MISC2_LDO3_SEL_VIB_VAL BIT(0) -#define MISC2_LDO3_SEL_VIB_MASK 0x1 - -#define BOOST_HW_PWR_EN BIT(5) -#define BOOST_HW_PWR_EN_MASK BIT(5) - -#define OPA_MODE_EN BIT(6) -#define OPA_MODE_EN_MASK BIT(6) - -#define USB_VBUS_CTRL_SET 0x04 -#define USB_VBUS_CTRL_CLR 0x05 -#define VBUS_DISCHRG 0x20 - -struct tps80031_regulator_info { - /* Regulator register address.*/ - u8 trans_reg; - u8 state_reg; - u8 force_reg; - u8 volt_reg; - u8 volt_id; - - /*Power request bits */ - int preq_bit; - - /* used by regulator core */ - struct regulator_desc desc; - -}; - -struct tps80031_regulator { - struct device *dev; - struct tps80031_regulator_info *rinfo; - - u8 device_flags; - unsigned int config_flags; - unsigned int ext_ctrl_flag; -}; - -static inline struct device *to_tps80031_dev(struct regulator_dev *rdev) -{ - return rdev_get_dev(rdev)->parent->parent; -} - -static int tps80031_reg_is_enabled(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - u8 reg_val; - int ret; - - if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ) - return true; - - ret = tps80031_read(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg, - ®_val); - if (ret < 0) { - dev_err(&rdev->dev, "Reg 0x%02x read failed, err = %d\n", - ri->rinfo->state_reg, ret); - return ret; - } - return (reg_val & TPS80031_STATE_MASK) == TPS80031_STATE_ON; -} - -static int tps80031_reg_enable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ) - return 0; - - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg, - TPS80031_STATE_ON, TPS80031_STATE_MASK); - if (ret < 0) { - dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n", - ri->rinfo->state_reg, ret); - return ret; - } - return ret; -} - -static int tps80031_reg_disable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - if (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ) - return 0; - - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg, - TPS80031_STATE_OFF, TPS80031_STATE_MASK); - if (ret < 0) - dev_err(&rdev->dev, "Reg 0x%02x update failed, err = %d\n", - ri->rinfo->state_reg, ret); - return ret; -} - -/* DCDC voltages for the selector of 58 to 63 */ -static const int tps80031_dcdc_voltages[4][5] = { - { 1350, 1500, 1800, 1900, 2100}, - { 1350, 1500, 1800, 1900, 2100}, - { 2084, 2315, 2778, 2932, 3241}, - { 4167, 2315, 2778, 2932, 3241}, -}; - -static int tps80031_dcdc_list_voltage(struct regulator_dev *rdev, unsigned sel) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - int volt_index = ri->device_flags & 0x3; - - if (sel == 0) - return 0; - else if (sel < 58) - return regulator_list_voltage_linear(rdev, sel - 1); - else - return tps80031_dcdc_voltages[volt_index][sel - 58] * 1000; -} - -static int tps80031_dcdc_set_voltage_sel(struct regulator_dev *rdev, - unsigned vsel) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - u8 reg_val; - - if (ri->rinfo->force_reg) { - ret = tps80031_read(parent, ri->rinfo->volt_id, - ri->rinfo->force_reg, ®_val); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - ri->rinfo->force_reg, ret); - return ret; - } - if (!(reg_val & SMPS_CMD_MASK)) { - ret = tps80031_update(parent, ri->rinfo->volt_id, - ri->rinfo->force_reg, vsel, SMPS_VSEL_MASK); - if (ret < 0) - dev_err(ri->dev, - "reg 0x%02x update failed, e = %d\n", - ri->rinfo->force_reg, ret); - return ret; - } - } - ret = tps80031_update(parent, ri->rinfo->volt_id, - ri->rinfo->volt_reg, vsel, SMPS_VSEL_MASK); - if (ret < 0) - dev_err(ri->dev, "reg 0x%02x update failed, e = %d\n", - ri->rinfo->volt_reg, ret); - return ret; -} - -static int tps80031_dcdc_get_voltage_sel(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - uint8_t vsel = 0; - int ret; - - if (ri->rinfo->force_reg) { - ret = tps80031_read(parent, ri->rinfo->volt_id, - ri->rinfo->force_reg, &vsel); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - ri->rinfo->force_reg, ret); - return ret; - } - - if (!(vsel & SMPS_CMD_MASK)) - return vsel & SMPS_VSEL_MASK; - } - ret = tps80031_read(parent, ri->rinfo->volt_id, - ri->rinfo->volt_reg, &vsel); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - ri->rinfo->volt_reg, ret); - return ret; - } - return vsel & SMPS_VSEL_MASK; -} - -static int tps80031_ldo_list_voltage(struct regulator_dev *rdev, - unsigned int sel) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - - /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */ - if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) && - (ri->device_flags & TRACK_MODE_ENABLE)) { - unsigned nvsel = (sel) & 0x1F; - if (((tps80031_get_chip_info(parent) == TPS80031) || - ((tps80031_get_chip_info(parent) == TPS80032) && - (tps80031_get_pmu_version(parent) == 0x0))) && - ((nvsel == 0x0) || (nvsel >= 0x19 && nvsel <= 0x1F))) { - dev_err(ri->dev, - "Invalid sel %d in track mode LDO2\n", - nvsel); - return -EINVAL; - } - } - - return regulator_list_voltage_linear(rdev, sel); -} - -static int tps80031_ldo_map_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - - /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */ - if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) && - (ri->device_flags & TRACK_MODE_ENABLE)) { - if (((tps80031_get_chip_info(parent) == TPS80031) || - ((tps80031_get_chip_info(parent) == TPS80032) && - (tps80031_get_pmu_version(parent) == 0x0)))) { - return regulator_map_voltage_iterate(rdev, min_uV, - max_uV); - } - } - - return regulator_map_voltage_linear(rdev, min_uV, max_uV); -} - -static int tps80031_vbus_is_enabled(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - uint8_t ctrl1 = 0; - uint8_t ctrl3 = 0; - - ret = tps80031_read(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL1, &ctrl1); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL1, ret); - return ret; - } - ret = tps80031_read(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL3, &ctrl3); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL3, ret); - return ret; - } - if ((ctrl1 & OPA_MODE_EN) && (ctrl3 & BOOST_HW_PWR_EN)) - return 1; - return ret; -} - -static int tps80031_vbus_enable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL1, ret); - return ret; - } - - ret = tps80031_set_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x read failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL3, ret); - return ret; - } - return ret; -} - -static int tps80031_vbus_disable(struct regulator_dev *rdev) -{ - struct tps80031_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps80031_dev(rdev); - int ret; - - if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) { - ret = tps80031_write(parent, TPS80031_SLAVE_ID2, - USB_VBUS_CTRL_SET, VBUS_DISCHRG); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n", - USB_VBUS_CTRL_SET, ret); - return ret; - } - } - - ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL1, OPA_MODE_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL1, ret); - return ret; - } - - ret = tps80031_clr_bits(parent, TPS80031_SLAVE_ID2, - TPS80031_CHARGERUSB_CTRL3, BOOST_HW_PWR_EN); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x clearbit failed, e = %d\n", - TPS80031_CHARGERUSB_CTRL3, ret); - return ret; - } - - mdelay(DIV_ROUND_UP(ri->rinfo->desc.enable_time, 1000)); - if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) { - ret = tps80031_write(parent, TPS80031_SLAVE_ID2, - USB_VBUS_CTRL_CLR, VBUS_DISCHRG); - if (ret < 0) { - dev_err(ri->dev, "reg 0x%02x write failed, e = %d\n", - USB_VBUS_CTRL_CLR, ret); - return ret; - } - } - return ret; -} - -static const struct regulator_ops tps80031_dcdc_ops = { - .list_voltage = tps80031_dcdc_list_voltage, - .set_voltage_sel = tps80031_dcdc_set_voltage_sel, - .get_voltage_sel = tps80031_dcdc_get_voltage_sel, - .enable = tps80031_reg_enable, - .disable = tps80031_reg_disable, - .is_enabled = tps80031_reg_is_enabled, -}; - -static const struct regulator_ops tps80031_ldo_ops = { - .list_voltage = tps80031_ldo_list_voltage, - .map_voltage = tps80031_ldo_map_voltage, - .set_voltage_sel = regulator_set_voltage_sel_regmap, - .get_voltage_sel = regulator_get_voltage_sel_regmap, - .enable = tps80031_reg_enable, - .disable = tps80031_reg_disable, - .is_enabled = tps80031_reg_is_enabled, -}; - -static const struct regulator_ops tps80031_vbus_sw_ops = { - .list_voltage = regulator_list_voltage_linear, - .enable = tps80031_vbus_enable, - .disable = tps80031_vbus_disable, - .is_enabled = tps80031_vbus_is_enabled, -}; - -static const struct regulator_ops tps80031_vbus_hw_ops = { - .list_voltage = regulator_list_voltage_linear, -}; - -static const struct regulator_ops tps80031_ext_reg_ops = { - .list_voltage = regulator_list_voltage_linear, - .enable = tps80031_reg_enable, - .disable = tps80031_reg_disable, - .is_enabled = tps80031_reg_is_enabled, -}; - -/* Non-exiting default definition for some register */ -#define TPS80031_SMPS3_CFG_FORCE 0 -#define TPS80031_SMPS4_CFG_FORCE 0 - -#define TPS80031_VBUS_CFG_TRANS 0 -#define TPS80031_VBUS_CFG_STATE 0 - -#define TPS80031_REG_SMPS(_id, _volt_id, _pbit) \ -{ \ - .trans_reg = TPS80031_##_id##_CFG_TRANS, \ - .state_reg = TPS80031_##_id##_CFG_STATE, \ - .force_reg = TPS80031_##_id##_CFG_FORCE, \ - .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \ - .volt_id = TPS80031_SLAVE_##_volt_id, \ - .preq_bit = _pbit, \ - .desc = { \ - .name = "tps80031_"#_id, \ - .id = TPS80031_REGULATOR_##_id, \ - .n_voltages = 63, \ - .ops = &tps80031_dcdc_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .enable_time = 500, \ - }, \ -} - -#define TPS80031_REG_LDO(_id, _preq_bit) \ -{ \ - .trans_reg = TPS80031_##_id##_CFG_TRANS, \ - .state_reg = TPS80031_##_id##_CFG_STATE, \ - .volt_reg = TPS80031_##_id##_CFG_VOLTAGE, \ - .volt_id = TPS80031_SLAVE_ID1, \ - .preq_bit = _preq_bit, \ - .desc = { \ - .owner = THIS_MODULE, \ - .name = "tps80031_"#_id, \ - .id = TPS80031_REGULATOR_##_id, \ - .ops = &tps80031_ldo_ops, \ - .type = REGULATOR_VOLTAGE, \ - .min_uV = 1000000, \ - .uV_step = 100000, \ - .linear_min_sel = 1, \ - .n_voltages = 25, \ - .vsel_reg = TPS80031_##_id##_CFG_VOLTAGE, \ - .vsel_mask = LDO_VSEL_MASK, \ - .enable_time = 500, \ - }, \ -} - -#define TPS80031_REG_FIXED(_id, max_mV, _ops, _delay, _pbit) \ -{ \ - .trans_reg = TPS80031_##_id##_CFG_TRANS, \ - .state_reg = TPS80031_##_id##_CFG_STATE, \ - .volt_id = TPS80031_SLAVE_ID1, \ - .preq_bit = _pbit, \ - .desc = { \ - .name = "tps80031_"#_id, \ - .id = TPS80031_REGULATOR_##_id, \ - .min_uV = max_mV * 1000, \ - .n_voltages = 1, \ - .ops = &_ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - .enable_time = _delay, \ - }, \ -} - -static struct tps80031_regulator_info tps80031_rinfo[TPS80031_REGULATOR_MAX] = { - TPS80031_REG_SMPS(VIO, ID0, 4), - TPS80031_REG_SMPS(SMPS1, ID0, 0), - TPS80031_REG_SMPS(SMPS2, ID0, 1), - TPS80031_REG_SMPS(SMPS3, ID1, 2), - TPS80031_REG_SMPS(SMPS4, ID1, 3), - TPS80031_REG_LDO(VANA, -1), - TPS80031_REG_LDO(LDO1, 8), - TPS80031_REG_LDO(LDO2, 9), - TPS80031_REG_LDO(LDO3, 10), - TPS80031_REG_LDO(LDO4, 11), - TPS80031_REG_LDO(LDO5, 12), - TPS80031_REG_LDO(LDO6, 13), - TPS80031_REG_LDO(LDO7, 14), - TPS80031_REG_LDO(LDOLN, 15), - TPS80031_REG_LDO(LDOUSB, 5), - TPS80031_REG_FIXED(VBUS, 5000, tps80031_vbus_hw_ops, 100000, -1), - TPS80031_REG_FIXED(REGEN1, 3300, tps80031_ext_reg_ops, 0, 16), - TPS80031_REG_FIXED(REGEN2, 3300, tps80031_ext_reg_ops, 0, 17), - TPS80031_REG_FIXED(SYSEN, 3300, tps80031_ext_reg_ops, 0, 18), -}; - -static int tps80031_power_req_config(struct device *parent, - struct tps80031_regulator *ri, - struct tps80031_regulator_platform_data *tps80031_pdata) -{ - int ret = 0; - - if (ri->rinfo->preq_bit < 0) - goto skip_pwr_req_config; - - ret = tps80031_ext_power_req_config(parent, ri->ext_ctrl_flag, - ri->rinfo->preq_bit, ri->rinfo->state_reg, - ri->rinfo->trans_reg); - if (ret < 0) { - dev_err(ri->dev, "ext powerreq config failed, err = %d\n", ret); - return ret; - } - -skip_pwr_req_config: - if (tps80031_pdata->ext_ctrl_flag & TPS80031_PWR_ON_ON_SLEEP) { - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, - ri->rinfo->trans_reg, TPS80031_TRANS_SLEEP_ON, - TPS80031_TRANS_SLEEP_MASK); - if (ret < 0) { - dev_err(ri->dev, "Reg 0x%02x update failed, e %d\n", - ri->rinfo->trans_reg, ret); - return ret; - } - } - return ret; -} - -static int tps80031_regulator_config(struct device *parent, - struct tps80031_regulator *ri, - struct tps80031_regulator_platform_data *tps80031_pdata) -{ - int ret = 0; - - switch (ri->rinfo->desc.id) { - case TPS80031_REGULATOR_LDOUSB: - if (ri->config_flags & (TPS80031_USBLDO_INPUT_VSYS | - TPS80031_USBLDO_INPUT_PMID)) { - unsigned val; - - if (ri->config_flags & TPS80031_USBLDO_INPUT_VSYS) - val = MISC2_LDOUSB_IN_VSYS; - else - val = MISC2_LDOUSB_IN_PMID; - - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, - TPS80031_MISC2, val, - MISC2_LDOUSB_IN_MASK); - if (ret < 0) { - dev_err(ri->dev, - "LDOUSB config failed, e= %d\n", ret); - return ret; - } - } - break; - - case TPS80031_REGULATOR_LDO3: - if (ri->config_flags & TPS80031_LDO3_OUTPUT_VIB) { - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, - TPS80031_MISC2, MISC2_LDO3_SEL_VIB_VAL, - MISC2_LDO3_SEL_VIB_MASK); - if (ret < 0) { - dev_err(ri->dev, - "LDO3 config failed, e = %d\n", ret); - return ret; - } - } - break; - - case TPS80031_REGULATOR_VBUS: - /* Provide SW control Ops if VBUS is SW control */ - if (!(ri->config_flags & TPS80031_VBUS_SW_ONLY)) - ri->rinfo->desc.ops = &tps80031_vbus_sw_ops; - break; - default: - break; - } - - /* Configure Active state to ON, SLEEP to OFF and OFF_state to OFF */ - ret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->trans_reg, - TPS80031_TRANS_ACTIVE_ON | TPS80031_TRANS_SLEEP_OFF | - TPS80031_TRANS_OFF_OFF, TPS80031_TRANS_ACTIVE_MASK | - TPS80031_TRANS_SLEEP_MASK | TPS80031_TRANS_OFF_MASK); - if (ret < 0) { - dev_err(ri->dev, "trans reg update failed, e %d\n", ret); - return ret; - } - - return ret; -} - -static int check_smps_mode_mult(struct device *parent, - struct tps80031_regulator *ri) -{ - int mult_offset; - int ret; - u8 smps_offset; - u8 smps_mult; - - ret = tps80031_read(parent, TPS80031_SLAVE_ID1, - TPS80031_SMPS_OFFSET, &smps_offset); - if (ret < 0) { - dev_err(parent, "Error in reading smps offset register\n"); - return ret; - } - - ret = tps80031_read(parent, TPS80031_SLAVE_ID1, - TPS80031_SMPS_MULT, &smps_mult); - if (ret < 0) { - dev_err(parent, "Error in reading smps mult register\n"); - return ret; - } - - switch (ri->rinfo->desc.id) { - case TPS80031_REGULATOR_VIO: - mult_offset = SMPS_MULTOFFSET_VIO; - break; - case TPS80031_REGULATOR_SMPS1: - mult_offset = SMPS_MULTOFFSET_SMPS1; - break; - case TPS80031_REGULATOR_SMPS2: - mult_offset = SMPS_MULTOFFSET_SMPS2; - break; - case TPS80031_REGULATOR_SMPS3: - mult_offset = SMPS_MULTOFFSET_SMPS3; - break; - case TPS80031_REGULATOR_SMPS4: - mult_offset = SMPS_MULTOFFSET_SMPS4; - break; - case TPS80031_REGULATOR_LDO2: - ri->device_flags = smps_mult & BIT(5) ? TRACK_MODE_ENABLE : 0; - /* TRACK mode the ldo2 varies from 600mV to 1300mV */ - if (ri->device_flags & TRACK_MODE_ENABLE) { - ri->rinfo->desc.min_uV = 600000; - ri->rinfo->desc.uV_step = 12500; - ri->rinfo->desc.n_voltages = 57; - ri->rinfo->desc.vsel_mask = LDO_TRACK_VSEL_MASK; - } - return 0; - default: - return 0; - } - - ri->device_flags = (smps_offset & mult_offset) ? DCDC_OFFSET_EN : 0; - ri->device_flags |= (smps_mult & mult_offset) ? DCDC_EXTENDED_EN : 0; - switch (ri->device_flags) { - case 0: - ri->rinfo->desc.min_uV = 607700; - ri->rinfo->desc.uV_step = 12660; - break; - case DCDC_OFFSET_EN: - ri->rinfo->desc.min_uV = 700000; - ri->rinfo->desc.uV_step = 12500; - break; - case DCDC_EXTENDED_EN: - ri->rinfo->desc.min_uV = 1852000; - ri->rinfo->desc.uV_step = 38600; - break; - case DCDC_OFFSET_EN | DCDC_EXTENDED_EN: - ri->rinfo->desc.min_uV = 2161000; - ri->rinfo->desc.uV_step = 38600; - break; - } - return 0; -} - -static int tps80031_regulator_probe(struct platform_device *pdev) -{ - struct tps80031_platform_data *pdata; - struct tps80031_regulator_platform_data *tps_pdata; - struct tps80031_regulator *ri; - struct tps80031_regulator *pmic; - struct regulator_dev *rdev; - struct regulator_config config = { }; - struct tps80031 *tps80031_mfd = dev_get_drvdata(pdev->dev.parent); - int ret; - int num; - - pdata = dev_get_platdata(pdev->dev.parent); - - if (!pdata) { - dev_err(&pdev->dev, "No platform data\n"); - return -EINVAL; - } - - pmic = devm_kcalloc(&pdev->dev, - TPS80031_REGULATOR_MAX, sizeof(*pmic), GFP_KERNEL); - if (!pmic) - return -ENOMEM; - - for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) { - tps_pdata = pdata->regulator_pdata[num]; - ri = &pmic[num]; - ri->rinfo = &tps80031_rinfo[num]; - ri->dev = &pdev->dev; - - check_smps_mode_mult(pdev->dev.parent, ri); - config.dev = &pdev->dev; - config.init_data = NULL; - config.driver_data = ri; - config.regmap = tps80031_mfd->regmap[ri->rinfo->volt_id]; - - if (tps_pdata) { - config.init_data = tps_pdata->reg_init_data; - ri->config_flags = tps_pdata->config_flags; - ri->ext_ctrl_flag = tps_pdata->ext_ctrl_flag; - ret = tps80031_regulator_config(pdev->dev.parent, - ri, tps_pdata); - if (ret < 0) { - dev_err(&pdev->dev, - "regulator config failed, e %d\n", ret); - return ret; - } - - ret = tps80031_power_req_config(pdev->dev.parent, - ri, tps_pdata); - if (ret < 0) { - dev_err(&pdev->dev, - "pwr_req config failed, err %d\n", ret); - return ret; - } - } - rdev = devm_regulator_register(&pdev->dev, &ri->rinfo->desc, - &config); - if (IS_ERR(rdev)) { - dev_err(&pdev->dev, - "register regulator failed %s\n", - ri->rinfo->desc.name); - return PTR_ERR(rdev); - } - } - - platform_set_drvdata(pdev, pmic); - return 0; -} - -static struct platform_driver tps80031_regulator_driver = { - .driver = { - .name = "tps80031-pmic", - }, - .probe = tps80031_regulator_probe, -}; - -static int __init tps80031_regulator_init(void) -{ - return platform_driver_register(&tps80031_regulator_driver); -} -subsys_initcall(tps80031_regulator_init); - -static void __exit tps80031_regulator_exit(void) -{ - platform_driver_unregister(&tps80031_regulator_driver); -} -module_exit(tps80031_regulator_exit); - -MODULE_ALIAS("platform:tps80031-regulator"); -MODULE_DESCRIPTION("Regulator Driver for TI TPS80031/TPS80032 PMIC"); -MODULE_AUTHOR("Laxman Dewangan "); -MODULE_LICENSE("GPL v2"); From 400d5a5da43c0e84e5aa75151082ea91f0fae3c9 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Thu, 21 Oct 2021 21:33:08 +0300 Subject: [PATCH 34/34] regulator: Don't error out fixed regulator in regulator_sync_voltage() Fixed regulator can't change voltage and regulator_sync_voltage() returns -EINVAL in this case. Make regulator_sync_voltage() to succeed for regulators that are incapable to change voltage. On NVIDIA Tegra power management driver needs to sync voltage and we have one device (Trimslice) that uses fixed regulator which is getting synced. The syncing error isn't treated as fatal, but produces a noisy error message. This patch silences that error. Signed-off-by: Dmitry Osipenko Link: https://lore.kernel.org/r/20211021183308.27786-1-digetx@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 21a2b28ab0ca..f6ca2098cc01 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4249,6 +4249,9 @@ int regulator_sync_voltage(struct regulator *regulator) struct regulator_voltage *voltage = ®ulator->voltage[PM_SUSPEND_ON]; int ret, min_uV, max_uV; + if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_VOLTAGE)) + return 0; + regulator_lock(rdev); if (!rdev->desc->ops->set_voltage &&