From 04a99ce605a780c275e2e9d2547d43fbba3f4d24 Mon Sep 17 00:00:00 2001 From: Pragnesh Patel Date: Thu, 19 Sep 2019 12:09:04 +0530 Subject: fixed-regulator: dt-bindings: Fixed building error for compatible property Compatible property is not of type 'string', so remove const: from it. Signed-off-by: Pragnesh Patel Acked-by: Rob Herring Link: https://lore.kernel.org/r/1568875145-2864-1-git-send-email-pragnesh.patel@sifive.com Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/fixed-regulator.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml b/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml index a78150c47aa2..f32416968197 100644 --- a/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml @@ -30,8 +30,8 @@ if: properties: compatible: enum: - - const: regulator-fixed - - const: regulator-fixed-clock + - regulator-fixed + - regulator-fixed-clock regulator-name: true -- cgit v1.2.3-59-g8ed1b From e4ff1710885c07550e80a074f1cfa8d2597355ff Mon Sep 17 00:00:00 2001 From: "Angelo G. Del Regno" Date: Sat, 21 Sep 2019 11:50:40 +0200 Subject: regulator: qcom_spmi: Add PM8950 SPMI regulator The PM8950 has 5 HFSMPS, 1 FTSMPS2.5 (s5, controlling APC voltage) and 23 LDO regulators. Add the configuration for this chip. Signed-off-by: Angelo G. Del Regno Link: https://lore.kernel.org/r/20190921095043.62593-3-kholk11@gmail.com Signed-off-by: Mark Brown --- .../bindings/regulator/qcom,spmi-regulator.txt | 21 +++++++++++++ drivers/regulator/qcom_spmi-regulator.c | 34 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt index 430b8622bda1..76885fd8a3c9 100644 --- a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt @@ -8,6 +8,7 @@ Qualcomm SPMI Regulators "qcom,pm8841-regulators" "qcom,pm8916-regulators" "qcom,pm8941-regulators" + "qcom,pm8950-regulators" "qcom,pm8994-regulators" "qcom,pmi8994-regulators" "qcom,pms405-regulators" @@ -72,6 +73,26 @@ Qualcomm SPMI Regulators Definition: Reference to regulator supplying the input pin, as described in the data sheet. +- vdd_s1-supply: +- vdd_s2-supply: +- vdd_s3-supply: +- vdd_s4-supply: +- vdd_s4-supply: +- vdd_s5-supply: +- vdd_s6-supply: +- vdd_l1_l19-supply: +- vdd_l2_l23-supply: +- vdd_l3-supply: +- vdd_l4_l5_l6_l7_l16-supply: +- vdd_l8_l11_l12_l17_l22-supply: +- vdd_l9_l10_l13_l14_l15_l18-supply: +- vdd_l20-supply: +- vdd_l21-supply: + Usage: optional (pm8950 only) + Value type: + Definition: reference to regulator supplying the input pin, as + described in the data sheet + - vdd_s1-supply: - vdd_s2-supply: - vdd_s3-supply: diff --git a/drivers/regulator/qcom_spmi-regulator.c b/drivers/regulator/qcom_spmi-regulator.c index 7f51c5fc8194..049ac3887ecd 100644 --- a/drivers/regulator/qcom_spmi-regulator.c +++ b/drivers/regulator/qcom_spmi-regulator.c @@ -1869,6 +1869,39 @@ static const struct spmi_regulator_data pm8916_regulators[] = { { } }; +static const struct spmi_regulator_data pm8950_regulators[] = { + { "s1", 0x1400, "vdd_s1", }, + { "s2", 0x1700, "vdd_s2", }, + { "s3", 0x1a00, "vdd_s3", }, + { "s4", 0x1d00, "vdd_s4", }, + { "s5", 0x2000, "vdd_s5", }, + { "s6", 0x2300, "vdd_s6", }, + { "l1", 0x4000, "vdd_l1_l19", }, + { "l2", 0x4100, "vdd_l2_l23", }, + { "l3", 0x4200, "vdd_l3", }, + { "l4", 0x4300, "vdd_l4_l5_l6_l7_l16", }, + { "l5", 0x4400, "vdd_l4_l5_l6_l7_l16", }, + { "l6", 0x4500, "vdd_l4_l5_l6_l7_l16", }, + { "l7", 0x4600, "vdd_l4_l5_l6_l7_l16", }, + { "l8", 0x4700, "vdd_l8_l11_l12_l17_l22", }, + { "l9", 0x4800, "vdd_l9_l10_l13_l14_l15_l18", }, + { "l10", 0x4900, "vdd_l9_l10_l13_l14_l15_l18", }, + { "l11", 0x4a00, "vdd_l8_l11_l12_l17_l22", }, + { "l12", 0x4b00, "vdd_l8_l11_l12_l17_l22", }, + { "l13", 0x4c00, "vdd_l9_l10_l13_l14_l15_l18", }, + { "l14", 0x4d00, "vdd_l9_l10_l13_l14_l15_l18", }, + { "l15", 0x4e00, "vdd_l9_l10_l13_l14_l15_l18", }, + { "l16", 0x4f00, "vdd_l4_l5_l6_l7_l16", }, + { "l17", 0x5000, "vdd_l8_l11_l12_l17_l22", }, + { "l18", 0x5100, "vdd_l9_l10_l13_l14_l15_l18", }, + { "l19", 0x5200, "vdd_l1_l19", }, + { "l20", 0x5300, "vdd_l20", }, + { "l21", 0x5400, "vdd_l21", }, + { "l22", 0x5500, "vdd_l8_l11_l12_l17_l22", }, + { "l23", 0x5600, "vdd_l2_l23", }, + { } +}; + static const struct spmi_regulator_data pm8994_regulators[] = { { "s1", 0x1400, "vdd_s1", }, { "s2", 0x1700, "vdd_s2", }, @@ -1945,6 +1978,7 @@ static const struct of_device_id qcom_spmi_regulator_match[] = { { .compatible = "qcom,pm8841-regulators", .data = &pm8841_regulators }, { .compatible = "qcom,pm8916-regulators", .data = &pm8916_regulators }, { .compatible = "qcom,pm8941-regulators", .data = &pm8941_regulators }, + { .compatible = "qcom,pm8950-regulators", .data = &pm8950_regulators }, { .compatible = "qcom,pm8994-regulators", .data = &pm8994_regulators }, { .compatible = "qcom,pmi8994-regulators", .data = &pmi8994_regulators }, { .compatible = "qcom,pms405-regulators", .data = &pms405_regulators }, -- cgit v1.2.3-59-g8ed1b From e44adca5fa25943ca44fcec02ef7b118ce9bb8f5 Mon Sep 17 00:00:00 2001 From: "Angelo G. Del Regno" Date: Sat, 21 Sep 2019 11:50:41 +0200 Subject: regulator: qcom_smd: Add PM8950 regulators The PM8950 provides 6 SMPS regulators, of which 5 HFSMPS and one FTSMPS2.5 (s5), and 23 LDOs. Add these to the RPM regulator driver. Signed-off-by: Angelo G. Del Regno Link: https://lore.kernel.org/r/20190921095043.62593-4-kholk11@gmail.com Signed-off-by: Mark Brown --- .../bindings/regulator/qcom,smd-rpm-regulator.txt | 21 +++++ drivers/regulator/qcom_smd-regulator.c | 92 ++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt b/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt index 45025b5b67f6..d126df043403 100644 --- a/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt @@ -22,6 +22,7 @@ Regulator nodes are identified by their compatible: "qcom,rpm-pm8841-regulators" "qcom,rpm-pm8916-regulators" "qcom,rpm-pm8941-regulators" + "qcom,rpm-pm8950-regulators" "qcom,rpm-pm8994-regulators" "qcom,rpm-pm8998-regulators" "qcom,rpm-pma8084-regulators" @@ -54,6 +55,26 @@ Regulator nodes are identified by their compatible: Definition: reference to regulator supplying the input pin, as described in the data sheet +- vdd_s1-supply: +- vdd_s2-supply: +- vdd_s3-supply: +- vdd_s4-supply: +- vdd_s4-supply: +- vdd_s5-supply: +- vdd_s6-supply: +- vdd_l1_l19-supply: +- vdd_l2_l23-supply: +- vdd_l3-supply: +- vdd_l4_l5_l6_l7_l16-supply: +- vdd_l8_l11_l12_l17_l22-supply: +- vdd_l9_l10_l13_l14_l15_l18-supply: +- vdd_l20-supply: +- vdd_l21-supply: + Usage: optional (pm8950 only) + Value type: + Definition: reference to regulator supplying the input pin, as + described in the data sheet + - vdd_s1-supply: - vdd_s2-supply: - vdd_s3-supply: diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index 3b0828c79e2b..fff8d5fdef6a 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -338,6 +338,63 @@ static const struct regulator_desc pm8916_buck_hvo_smps = { .ops = &rpm_smps_ldo_ops, }; +static const struct regulator_desc pm8950_hfsmps = { + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(375000, 0, 95, 12500), + REGULATOR_LINEAR_RANGE(1550000, 96, 127, 25000), + }, + .n_linear_ranges = 2, + .n_voltages = 128, + .ops = &rpm_smps_ldo_ops, +}; + +static const struct regulator_desc pm8950_ftsmps2p5 = { + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(80000, 0, 255, 5000), + REGULATOR_LINEAR_RANGE(160000, 256, 460, 10000), + }, + .n_linear_ranges = 2, + .n_voltages = 461, + .ops = &rpm_smps_ldo_ops, +}; + +static const struct regulator_desc pm8950_ult_nldo = { + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(375000, 0, 202, 12500), + }, + .n_linear_ranges = 1, + .n_voltages = 203, + .ops = &rpm_smps_ldo_ops, +}; + +static const struct regulator_desc pm8950_ult_pldo = { + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(1750000, 0, 127, 12500), + }, + .n_linear_ranges = 1, + .n_voltages = 128, + .ops = &rpm_smps_ldo_ops, +}; + +static const struct regulator_desc pm8950_pldo_lv = { + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(1500000, 0, 16, 25000), + }, + .n_linear_ranges = 1, + .n_voltages = 17, + .ops = &rpm_smps_ldo_ops, +}; + +static const struct regulator_desc pm8950_pldo = { + .linear_ranges = (struct regulator_linear_range[]) { + REGULATOR_LINEAR_RANGE(975000, 0, 164, 12500), + }, + .n_linear_ranges = 1, + .n_voltages = 165, + .ops = &rpm_smps_ldo_ops, +}; + + static const struct regulator_desc pm8994_hfsmps = { .linear_ranges = (struct regulator_linear_range[]) { REGULATOR_LINEAR_RANGE( 375000, 0, 95, 12500), @@ -638,6 +695,40 @@ static const struct rpm_regulator_data rpm_pma8084_regulators[] = { {} }; +static const struct rpm_regulator_data rpm_pm8950_regulators[] = { + { "s1", QCOM_SMD_RPM_SMPA, 1, &pm8950_hfsmps, "vdd_s1" }, + { "s2", QCOM_SMD_RPM_SMPA, 2, &pm8950_hfsmps, "vdd_s2" }, + { "s3", QCOM_SMD_RPM_SMPA, 3, &pm8950_hfsmps, "vdd_s3" }, + { "s4", QCOM_SMD_RPM_SMPA, 4, &pm8950_hfsmps, "vdd_s4" }, + { "s5", QCOM_SMD_RPM_SMPA, 5, &pm8950_ftsmps2p5, "vdd_s5" }, + { "s6", QCOM_SMD_RPM_SMPA, 6, &pm8950_hfsmps, "vdd_s6" }, + + { "l1", QCOM_SMD_RPM_LDOA, 1, &pm8950_ult_nldo, "vdd_l1_l19" }, + { "l2", QCOM_SMD_RPM_LDOA, 2, &pm8950_ult_nldo, "vdd_l2_l23" }, + { "l3", QCOM_SMD_RPM_LDOA, 3, &pm8950_ult_nldo, "vdd_l3" }, + { "l4", QCOM_SMD_RPM_LDOA, 4, &pm8950_ult_pldo, "vdd_l4_l5_l6_l7_l16" }, + { "l5", QCOM_SMD_RPM_LDOA, 5, &pm8950_pldo_lv, "vdd_l4_l5_l6_l7_l16" }, + { "l6", QCOM_SMD_RPM_LDOA, 6, &pm8950_pldo_lv, "vdd_l4_l5_l6_l7_l16" }, + { "l7", QCOM_SMD_RPM_LDOA, 7, &pm8950_pldo_lv, "vdd_l4_l5_l6_l7_l16" }, + { "l8", QCOM_SMD_RPM_LDOA, 8, &pm8950_ult_pldo, "vdd_l8_l11_l12_l17_l22" }, + { "l9", QCOM_SMD_RPM_LDOA, 9, &pm8950_ult_pldo, "vdd_l9_l10_l13_l14_l15_l18" }, + { "l10", QCOM_SMD_RPM_LDOA, 10, &pm8950_ult_nldo, "vdd_l9_l10_l13_l14_l15_l18"}, + { "l11", QCOM_SMD_RPM_LDOA, 11, &pm8950_ult_pldo, "vdd_l8_l11_l12_l17_l22"}, + { "l12", QCOM_SMD_RPM_LDOA, 12, &pm8950_ult_pldo, "vdd_l8_l11_l12_l17_l22"}, + { "l13", QCOM_SMD_RPM_LDOA, 13, &pm8950_ult_pldo, "vdd_l9_l10_l13_l14_l15_l18"}, + { "l14", QCOM_SMD_RPM_LDOA, 14, &pm8950_ult_pldo, "vdd_l9_l10_l13_l14_l15_l18"}, + { "l15", QCOM_SMD_RPM_LDOA, 15, &pm8950_ult_pldo, "vdd_l9_l10_l13_l14_l15_l18"}, + { "l16", QCOM_SMD_RPM_LDOA, 16, &pm8950_ult_pldo, "vdd_l4_l5_l6_l7_l16"}, + { "l17", QCOM_SMD_RPM_LDOA, 17, &pm8950_ult_pldo, "vdd_l8_l11_l12_l17_l22"}, + { "l18", QCOM_SMD_RPM_LDOA, 18, &pm8950_ult_pldo, "vdd_l9_l10_l13_l14_l15_l18"}, + { "l19", QCOM_SMD_RPM_LDOA, 18, &pm8950_pldo, "vdd_l1_l19"}, + { "l20", QCOM_SMD_RPM_LDOA, 18, &pm8950_pldo, "vdd_l20"}, + { "l21", QCOM_SMD_RPM_LDOA, 18, &pm8950_pldo, "vdd_l21"}, + { "l22", QCOM_SMD_RPM_LDOA, 18, &pm8950_pldo, "vdd_l8_l11_l12_l17_l22"}, + { "l23", QCOM_SMD_RPM_LDOA, 18, &pm8950_pldo, "vdd_l2_l23"}, + {} +}; + static const struct rpm_regulator_data rpm_pm8994_regulators[] = { { "s1", QCOM_SMD_RPM_SMPA, 1, &pm8994_ftsmps, "vdd_s1" }, { "s2", QCOM_SMD_RPM_SMPA, 2, &pm8994_ftsmps, "vdd_s2" }, @@ -767,6 +858,7 @@ static const struct of_device_id rpm_of_match[] = { { .compatible = "qcom,rpm-pm8841-regulators", .data = &rpm_pm8841_regulators }, { .compatible = "qcom,rpm-pm8916-regulators", .data = &rpm_pm8916_regulators }, { .compatible = "qcom,rpm-pm8941-regulators", .data = &rpm_pm8941_regulators }, + { .compatible = "qcom,rpm-pm8950-regulators", .data = &rpm_pm8950_regulators }, { .compatible = "qcom,rpm-pm8994-regulators", .data = &rpm_pm8994_regulators }, { .compatible = "qcom,rpm-pm8998-regulators", .data = &rpm_pm8998_regulators }, { .compatible = "qcom,rpm-pma8084-regulators", .data = &rpm_pma8084_regulators }, -- cgit v1.2.3-59-g8ed1b From 2e36e140b8b8de4023dd0b85e099567ee88cf872 Mon Sep 17 00:00:00 2001 From: "Angelo G. Del Regno" Date: Sat, 21 Sep 2019 11:50:43 +0200 Subject: regulator: qcom_spmi: Add support for PM8004 regulators This Power IC is used in combination with various PMIC combos, generally found on boards with MSM8992, MSM8994, MSM8996, MSM8956, MSM8976 and others, usually at address 0x5 on the SPMI bus, and its usual usage is to provide power to the GPU and/or to the CPU clusters (APC0/APC1). Signed-off-by: Angelo G. Del Regno Link: https://lore.kernel.org/r/20190921095043.62593-6-kholk11@gmail.com Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/qcom,spmi-regulator.txt | 4 ++++ drivers/regulator/qcom_spmi-regulator.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt index 76885fd8a3c9..f5cdac8b2847 100644 --- a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt @@ -4,6 +4,7 @@ Qualcomm SPMI Regulators Usage: required Value type: Definition: must be one of: + "qcom,pm8004-regulators" "qcom,pm8005-regulators" "qcom,pm8841-regulators" "qcom,pm8916-regulators" @@ -160,6 +161,9 @@ The regulator node houses sub-nodes for each regulator within the device. Each sub-node is identified using the node's name, with valid values listed for each of the PMICs below. +pm8005: + s2, s5 + pm8005: s1, s2, s3, s4 diff --git a/drivers/regulator/qcom_spmi-regulator.c b/drivers/regulator/qcom_spmi-regulator.c index 049ac3887ecd..95737e4dd6bb 100644 --- a/drivers/regulator/qcom_spmi-regulator.c +++ b/drivers/regulator/qcom_spmi-regulator.c @@ -1960,6 +1960,12 @@ static const struct spmi_regulator_data pmi8994_regulators[] = { { } }; +static const struct spmi_regulator_data pm8004_regulators[] = { + { "s2", 0x1700, "vdd_s2", }, + { "s5", 0x2000, "vdd_s5", }, + { } +}; + static const struct spmi_regulator_data pm8005_regulators[] = { { "s1", 0x1400, "vdd_s1", }, { "s2", 0x1700, "vdd_s2", }, @@ -1974,6 +1980,7 @@ static const struct spmi_regulator_data pms405_regulators[] = { }; static const struct of_device_id qcom_spmi_regulator_match[] = { + { .compatible = "qcom,pm8004-regulators", .data = &pm8004_regulators }, { .compatible = "qcom,pm8005-regulators", .data = &pm8005_regulators }, { .compatible = "qcom,pm8841-regulators", .data = &pm8841_regulators }, { .compatible = "qcom,pm8916-regulators", .data = &pm8916_regulators }, -- cgit v1.2.3-59-g8ed1b From 41145b980e3f4c7c26763fae0379f1cb8f336868 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 25 Sep 2019 18:12:56 +0800 Subject: regulator: pbias: Use of_device_get_match_data Use of_device_get_match_data to simplify the code a bit. Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20190925101256.19030-1-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/pbias-regulator.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index 92b41a6a4dc2..a59811060bdc 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c @@ -164,7 +164,6 @@ static int pbias_regulator_probe(struct platform_device *pdev) const struct pbias_reg_info *info; int ret = 0; int count, idx, data_idx = 0; - const struct of_device_id *match; const struct pbias_of_data *data; unsigned int offset; @@ -183,9 +182,8 @@ static int pbias_regulator_probe(struct platform_device *pdev) if (IS_ERR(syscon)) return PTR_ERR(syscon); - match = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev); - if (match && match->data) { - data = match->data; + data = of_device_get_match_data(&pdev->dev); + if (data) { offset = data->offset; } else { res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -- cgit v1.2.3-59-g8ed1b From e62cb0e0002ceb1a761b4dd7bb6a2bfc77a1ae77 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 26 Sep 2019 13:51:28 +0800 Subject: regulator: da9063: Simplify da9063_buck_set_mode for BUCK_MODE_MANUAL case The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same. Signed-off-by: Axel Lin Reviewed-by: Adam Thomson Link: https://lore.kernel.org/r/20190926055128.23434-2-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/da9063-regulator.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index 28b1b20f45bd..2aceb3b7afc2 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c @@ -225,7 +225,7 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev) { struct da9063_regulator *regl = rdev_get_drvdata(rdev); struct regmap_field *field; - unsigned int val, mode = 0; + unsigned int val; int ret; ret = regmap_field_read(regl->mode, &val); @@ -235,7 +235,6 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev) switch (val) { default: case BUCK_MODE_MANUAL: - mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY; /* Sleep flag bit decides the mode */ break; case BUCK_MODE_SLEEP: @@ -262,11 +261,9 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev) return 0; if (val) - mode &= REGULATOR_MODE_STANDBY; + return REGULATOR_MODE_STANDBY; else - mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST; - - return mode; + return REGULATOR_MODE_FAST; } /* -- cgit v1.2.3-59-g8ed1b From 182a1d8bc4ed30f5e0bb7fb52606fa1888430ca4 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Sat, 28 Sep 2019 16:55:40 +0800 Subject: regulator: pcap-regulator: remove unused variable 'SW3_table' drivers/regulator/pcap-regulator.c:89:27: warning: SW3_table defined but not used [-Wunused-const-variable=] It is never used, so can be removed. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20190928085540.45332-1-yuehaibing@huawei.com Signed-off-by: Mark Brown --- drivers/regulator/pcap-regulator.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c index c2469263db95..0345f38f6f78 100644 --- a/drivers/regulator/pcap-regulator.c +++ b/drivers/regulator/pcap-regulator.c @@ -86,10 +86,6 @@ static const unsigned int SW1_table[] = { #define SW2_table SW1_table -static const unsigned int SW3_table[] = { - 4000000, 4500000, 5000000, 5500000, -}; - struct pcap_regulator { const u8 reg; const u8 en; -- cgit v1.2.3-59-g8ed1b From 95bddd8bbf912a9a7980fde2a376fabf1ff7cd4b Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 30 Sep 2019 22:26:00 +0200 Subject: regulator: bd718x7: Add MODULE_ALIAS() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes device probing when built as a module Signed-off-by: Guido Günther Link: https://lore.kernel.org/r/46ce3400e227dd88d51486c02a6152c9ec52acbb.1569875042.git.agx@sigxcpu.org Signed-off-by: Mark Brown --- drivers/regulator/bd718x7-regulator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c index bdab46a5c461..13a43eee2e46 100644 --- a/drivers/regulator/bd718x7-regulator.c +++ b/drivers/regulator/bd718x7-regulator.c @@ -1293,3 +1293,4 @@ module_platform_driver(bd718xx_regulator); MODULE_AUTHOR("Matti Vaittinen "); MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:bd718xx-pmic"); -- cgit v1.2.3-59-g8ed1b From 87fd0db6d7df1cf4cc6e9b09e2155d1f324bf836 Mon Sep 17 00:00:00 2001 From: Douglas Anderson Date: Tue, 1 Oct 2019 12:45:54 -0700 Subject: regulator: Document "regulator-boot-on" binding more thoroughly The description of "regulator-boot-on" was a little unclear, at least to me. Did this property mean that we should turn the regulator on at boot? Or perhaps it was intended only to be used for regulators where we couldn't read the state at bootup to indicate what state we should assume? The answer, it turns out, is both [1]. Let's document this. [1] https://lore.kernel.org/r/20190923181431.GU2036@sirena.org.uk Signed-off-by: Douglas Anderson Link: https://lore.kernel.org/r/20191001124531.v2.1.Ice34ad5970a375c3c03cb15c3859b3ee501561bf@changeid Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/regulator.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/regulator/regulator.yaml b/Documentation/devicetree/bindings/regulator/regulator.yaml index 02c3043ce419..92ff2e8ad572 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/regulator.yaml @@ -38,7 +38,12 @@ properties: type: boolean regulator-boot-on: - description: bootloader/firmware enabled regulator + description: bootloader/firmware enabled regulator. + It's expected that this regulator was left on by the bootloader. + If the bootloader didn't leave it on then OS should turn it on + at boot but shouldn't prevent it from being turned off later. + This property is intended to only be used for regulators where + software cannot read the state of the regulator. type: boolean regulator-allow-bypass: -- cgit v1.2.3-59-g8ed1b From 2d2f116d69c127099553afe0d87cf9c0bbe2759e Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 12 Sep 2019 20:22:38 -0700 Subject: gpiolib: introduce devm_fwnode_gpiod_get_index() devm_fwnode_get_index_gpiod_from_child() is too long, besides the fwnode in question does not have to be a child of device node. Let's rename it to devm_fwnode_gpiod_get_index() and keep the old name for compatibility for now. Also let's add a devm_fwnode_gpiod_get() wrapper as majority of the callers need a single GPIO. Reviewed-by: Andy Shevchenko Signed-off-by: Dmitry Torokhov Reviewed-by: Mika Westerberg Link: https://lore.kernel.org/r/20190913032240.50333-2-dmitry.torokhov@gmail.com Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib-devres.c | 19 +++++++++---------- include/linux/gpio/consumer.h | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c index 98e3c20d9730..9a0475c87f95 100644 --- a/drivers/gpio/gpiolib-devres.c +++ b/drivers/gpio/gpiolib-devres.c @@ -185,12 +185,11 @@ struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, EXPORT_SYMBOL_GPL(devm_gpiod_get_from_of_node); /** - * devm_fwnode_get_index_gpiod_from_child - get a GPIO descriptor from a - * device's child node + * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node * @dev: GPIO consumer + * @fwnode: firmware node containing GPIO reference * @con_id: function within the GPIO consumer * @index: index of the GPIO to obtain in the consumer - * @child: firmware node (child of @dev) * @flags: GPIO initialization flags * @label: label to attach to the requested GPIO * @@ -200,11 +199,11 @@ EXPORT_SYMBOL_GPL(devm_gpiod_get_from_of_node); * On successful request the GPIO pin is configured in accordance with * provided @flags. */ -struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, - const char *con_id, int index, - struct fwnode_handle *child, - enum gpiod_flags flags, - const char *label) +struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, + struct fwnode_handle *fwnode, + const char *con_id, int index, + enum gpiod_flags flags, + const char *label) { char prop_name[32]; /* 32 is max size of property name */ struct gpio_desc **dr; @@ -224,7 +223,7 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, snprintf(prop_name, sizeof(prop_name), "%s", gpio_suffixes[i]); - desc = fwnode_get_named_gpiod(child, prop_name, index, flags, + desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags, label); if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) break; @@ -239,7 +238,7 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, return desc; } -EXPORT_SYMBOL_GPL(devm_fwnode_get_index_gpiod_from_child); +EXPORT_SYMBOL_GPL(devm_fwnode_gpiod_get_index); /** * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional() diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index b70af921c614..dc0ddcd30515 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -176,11 +176,11 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, const char *propname, int index, enum gpiod_flags dflags, const char *label); -struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, - const char *con_id, int index, - struct fwnode_handle *child, - enum gpiod_flags flags, - const char *label); +struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, + struct fwnode_handle *child, + const char *con_id, int index, + enum gpiod_flags flags, + const char *label); #else /* CONFIG_GPIOLIB */ @@ -531,6 +531,29 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, return ERR_PTR(-ENOSYS); } +static inline +struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, + struct fwnode_handle *fwnode, + const char *con_id, int index, + enum gpiod_flags flags, + const char *label) +{ + return ERR_PTR(-ENOSYS); +} + +#endif /* CONFIG_GPIOLIB */ + +static inline +struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev, + struct fwnode_handle *fwnode, + const char *con_id, + enum gpiod_flags flags, + const char *label) +{ + return devm_fwnode_gpiod_get_index(dev, fwnode, con_id, 0, + flags, label); +} + static inline struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, const char *con_id, int index, @@ -538,11 +561,10 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, enum gpiod_flags flags, const char *label) { - return ERR_PTR(-ENOSYS); + return devm_fwnode_gpiod_get_index(dev, child, con_id, index, + flags, label); } -#endif /* CONFIG_GPIOLIB */ - static inline struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev, const char *con_id, @@ -550,8 +572,7 @@ struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev, enum gpiod_flags flags, const char *label) { - return devm_fwnode_get_index_gpiod_from_child(dev, con_id, 0, child, - flags, label); + return devm_fwnode_gpiod_get_index(dev, child, con_id, 0, flags, label); } #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_OF_GPIO) -- cgit v1.2.3-59-g8ed1b From 13949fa9daa91a60c7cfef40755f7611cc2cf653 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 12 Sep 2019 20:22:39 -0700 Subject: gpiolib: introduce fwnode_gpiod_get_index() This introduces fwnode_gpiod_get_index() that iterates through common gpio suffixes when trying to locate a GPIO within a given firmware node. We also switch devm_fwnode_gpiod_get_index() to call fwnode_gpiod_get_index() instead of iterating through GPIO suffixes on its own. Reviewed-by: Andy Shevchenko Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20190913032240.50333-3-dmitry.torokhov@gmail.com Reviewed-by: Mika Westerberg Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib-devres.c | 16 +-------------- drivers/gpio/gpiolib.c | 48 +++++++++++++++++++++++++++++++++++++++++++ include/linux/gpio/consumer.h | 13 ++++++++++++ 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c index 9a0475c87f95..4421be09b960 100644 --- a/drivers/gpio/gpiolib-devres.c +++ b/drivers/gpio/gpiolib-devres.c @@ -205,29 +205,15 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, enum gpiod_flags flags, const char *label) { - char prop_name[32]; /* 32 is max size of property name */ struct gpio_desc **dr; struct gpio_desc *desc; - unsigned int i; dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *), GFP_KERNEL); if (!dr) return ERR_PTR(-ENOMEM); - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { - if (con_id) - snprintf(prop_name, sizeof(prop_name), "%s-%s", - con_id, gpio_suffixes[i]); - else - snprintf(prop_name, sizeof(prop_name), "%s", - gpio_suffixes[i]); - - desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags, - label); - if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) - break; - } + desc = fwnode_gpiod_get_index(fwnode, con_id, index, flags, label); if (IS_ERR(desc)) { devres_free(dr); return desc; diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bdbc1649eafa..2342deaace17 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -4324,6 +4324,54 @@ static int platform_gpio_count(struct device *dev, const char *con_id) return count; } +/** + * fwnode_gpiod_get_index - obtain a GPIO from firmware node + * @fwnode: handle of the firmware node + * @con_id: function within the GPIO consumer + * @index: index of the GPIO to obtain for the consumer + * @flags: GPIO initialization flags + * @label: label to attach to the requested GPIO + * + * This function can be used for drivers that get their configuration + * from opaque firmware. + * + * The function properly finds the corresponding GPIO using whatever is the + * underlying firmware interface and then makes sure that the GPIO + * descriptor is requested before it is returned to the caller. + * + * Returns: + * On successful request the GPIO pin is configured in accordance with + * provided @flags. + * + * In case of error an ERR_PTR() is returned. + */ +struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, + const char *con_id, int index, + enum gpiod_flags flags, + const char *label) +{ + struct gpio_desc *desc; + char prop_name[32]; /* 32 is max size of property name */ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { + if (con_id) + snprintf(prop_name, sizeof(prop_name), "%s-%s", + con_id, gpio_suffixes[i]); + else + snprintf(prop_name, sizeof(prop_name), "%s", + gpio_suffixes[i]); + + desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags, + label); + if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) + break; + } + + return desc; +} +EXPORT_SYMBOL_GPL(fwnode_gpiod_get_index); + /** * gpiod_count - return the number of GPIOs associated with a device / function * or -ENOENT if no GPIO has been assigned to the requested function diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index dc0ddcd30515..5215fdba6b9a 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -176,6 +176,10 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, const char *propname, int index, enum gpiod_flags dflags, const char *label); +struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, + const char *con_id, int index, + enum gpiod_flags flags, + const char *label); struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, struct fwnode_handle *child, const char *con_id, int index, @@ -531,6 +535,15 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, return ERR_PTR(-ENOSYS); } +static inline +struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, + const char *con_id, int index, + enum gpiod_flags flags, + const char *label) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, struct fwnode_handle *fwnode, -- cgit v1.2.3-59-g8ed1b From 472b39c3d1bba0616eb0e9a8fa3ad0f56927c7d7 Mon Sep 17 00:00:00 2001 From: Yizhuo Date: Thu, 3 Oct 2019 10:58:13 -0700 Subject: regulator: max8907: Fix the usage of uninitialized variable in max8907_regulator_probe() Inside function max8907_regulator_probe(), variable val could be uninitialized if regmap_read() fails. However, val is used later in the if statement to decide the content written to "pmic", which is potentially unsafe. Signed-off-by: Yizhuo Link: https://lore.kernel.org/r/20191003175813.16415-1-yzhai003@ucr.edu Signed-off-by: Mark Brown --- drivers/regulator/max8907-regulator.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c index 76152aaa330b..96dc0eea7659 100644 --- a/drivers/regulator/max8907-regulator.c +++ b/drivers/regulator/max8907-regulator.c @@ -296,7 +296,10 @@ static int max8907_regulator_probe(struct platform_device *pdev) memcpy(pmic->desc, max8907_regulators, sizeof(pmic->desc)); /* Backwards compatibility with MAX8907B; SD1 uses different voltages */ - regmap_read(max8907->regmap_gen, MAX8907_REG_II2RR, &val); + ret = regmap_read(max8907->regmap_gen, MAX8907_REG_II2RR, &val); + if (ret) + return ret; + if ((val & MAX8907_II2RR_VERSION_MASK) == MAX8907_II2RR_VERSION_REV_B) { pmic->desc[MAX8907_SD1].min_uV = 637500; @@ -333,14 +336,20 @@ static int max8907_regulator_probe(struct platform_device *pdev) } if (pmic->desc[i].ops == &max8907_ldo_ops) { - regmap_read(config.regmap, pmic->desc[i].enable_reg, + ret = regmap_read(config.regmap, pmic->desc[i].enable_reg, &val); + if (ret) + return ret; + if ((val & MAX8907_MASK_LDO_SEQ) != MAX8907_MASK_LDO_SEQ) pmic->desc[i].ops = &max8907_ldo_hwctl_ops; } else if (pmic->desc[i].ops == &max8907_out5v_ops) { - regmap_read(config.regmap, pmic->desc[i].enable_reg, + ret = regmap_read(config.regmap, pmic->desc[i].enable_reg, &val); + if (ret) + return ret; + if ((val & (MAX8907_MASK_OUT5V_VINEN | MAX8907_MASK_OUT5V_ENSRC)) != MAX8907_MASK_OUT5V_ENSRC) -- cgit v1.2.3-59-g8ed1b From 0c06b311c053ab12a9690e17a98ff4e4a90ab3e5 Mon Sep 17 00:00:00 2001 From: Kiran Gunda Date: Fri, 4 Oct 2019 15:38:53 +0530 Subject: regulator: dt-bindings: Add PM6150x compatibles Add PM6150 and PM6150L compatibles for Qualcomm SC7180 platfrom. Signed-off-by: Kiran Gunda Link: https://lore.kernel.org/r/1570183734-30706-2-git-send-email-kgunda@codeaurora.org Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt b/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt index bab9f71140b8..97c3e0b7611c 100644 --- a/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt @@ -28,6 +28,8 @@ Supported regulator node names: PM8150L: smps1 - smps8, ldo1 - ldo11, bob, flash, rgb PM8998: smps1 - smps13, ldo1 - ldo28, lvs1 - lvs2 PMI8998: bob + PM6150: smps1 - smps5, ldo1 - ldo19 + PM6150L: smps1 - smps8, ldo1 - ldo11, bob ======================== First Level Nodes - PMIC @@ -43,6 +45,8 @@ First Level Nodes - PMIC "qcom,pm8150l-rpmh-regulators" "qcom,pm8998-rpmh-regulators" "qcom,pmi8998-rpmh-regulators" + "qcom,pm6150-rpmh-regulators" + "qcom,pm6150l-rpmh-regulators" - qcom,pmic-id Usage: required -- cgit v1.2.3-59-g8ed1b From 75bb518e9bbf666a851cd43a9aba8e085b5008d8 Mon Sep 17 00:00:00 2001 From: Kiran Gunda Date: Fri, 4 Oct 2019 15:38:54 +0530 Subject: regulator: qcom-rpmh: add PM6150/PM6150L regulator support Add support for PM6150/PM6150L regulators. This ensures that consumers are able to modify the physical state of PMIC regulators. Signed-off-by: Kiran Gunda Link: https://lore.kernel.org/r/1570183734-30706-3-git-send-email-kgunda@codeaurora.org Signed-off-by: Mark Brown --- drivers/regulator/qcom-rpmh-regulator.c | 62 ++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c index db6c085da65e..8ae7ddf93b52 100644 --- a/drivers/regulator/qcom-rpmh-regulator.c +++ b/drivers/regulator/qcom-rpmh-regulator.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (c) 2018, The Linux Foundation. All rights reserved. +// Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. #define pr_fmt(fmt) "%s: " fmt, __func__ @@ -878,6 +878,58 @@ static const struct rpmh_vreg_init_data pm8009_vreg_data[] = { {}, }; +static const struct rpmh_vreg_init_data pm6150_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_hfsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_hfsmps510, "vdd-s5"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4-l7-l8"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_nldo, "vdd-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_nldo, "vdd-l4-l7-l8"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_nldo, "vdd-l4-l7-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_nldo, "vdd-l9"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo_lv, "vdd-l10-l14-l15"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo_lv, "vdd-l11-l12-l13"), + RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l11-l12-l13"), + RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo_lv, "vdd-l11-l12-l13"), + RPMH_VREG("ldo14", "ldo%s14", &pmic5_pldo_lv, "vdd-l10-l14-l15"), + RPMH_VREG("ldo15", "ldo%s15", &pmic5_pldo_lv, "vdd-l10-l14-l15"), + RPMH_VREG("ldo16", "ldo%s16", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo17", "ldo%s17", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo18", "ldo%s18", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + RPMH_VREG("ldo19", "ldo%s19", &pmic5_pldo, "vdd-l5-l16-l17-l18-l19"), + {}, +}; + +static const struct rpmh_vreg_init_data pm6150l_vreg_data[] = { + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps510, "vdd-s2"), + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps510, "vdd-s3"), + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps510, "vdd-s4"), + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps510, "vdd-s5"), + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps510, "vdd-s6"), + RPMH_VREG("smps7", "smp%s7", &pmic5_ftsmps510, "vdd-s7"), + RPMH_VREG("smps8", "smp%s8", &pmic5_hfsmps510, "vdd-s8"), + RPMH_VREG("ldo1", "ldo%s1", &pmic5_pldo_lv, "vdd-l1-l8"), + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l2-l3"), + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l4-l5-l6"), + RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo, "vdd-l7-l11"), + RPMH_VREG("ldo8", "ldo%s8", &pmic5_pldo, "vdd-l1-l8"), + RPMH_VREG("ldo9", "ldo%s9", &pmic5_pldo, "vdd-l9-l10"), + RPMH_VREG("ldo10", "ldo%s10", &pmic5_pldo, "vdd-l9-l10"), + RPMH_VREG("ldo11", "ldo%s11", &pmic5_pldo, "vdd-l7-l11"), + RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), + {}, +}; + static int rpmh_regulator_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -940,6 +992,14 @@ static const struct of_device_id rpmh_regulator_match_table[] = { .compatible = "qcom,pmi8998-rpmh-regulators", .data = pmi8998_vreg_data, }, + { + .compatible = "qcom,pm6150-rpmh-regulators", + .data = pm6150_vreg_data, + }, + { + .compatible = "qcom,pm6150l-rpmh-regulators", + .data = pm6150l_vreg_data, + }, {} }; MODULE_DEVICE_TABLE(of, rpmh_regulator_match_table); -- cgit v1.2.3-59-g8ed1b From 151b03791e4acb09bb9a9af2a87bca1240937d6c Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 7 Oct 2019 19:50:08 +0800 Subject: regulator: da9062: Simplify the code iterating all regulators It's more straightforward to use for statement here. Signed-off-by: Axel Lin Acked-by: Steve Twiss Link: https://lore.kernel.org/r/20191007115009.25672-1-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/da9062-regulator.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c index 56f3f72d7707..1028db242f91 100644 --- a/drivers/regulator/da9062-regulator.c +++ b/drivers/regulator/da9062-regulator.c @@ -966,8 +966,7 @@ static int da9062_regulator_probe(struct platform_device *pdev) regulators->n_regulators = max_regulators; platform_set_drvdata(pdev, regulators); - n = 0; - while (n < regulators->n_regulators) { + for (n = 0; n < regulators->n_regulators; n++) { /* Initialise regulator structure */ regl = ®ulators->regulator[n]; regl->hw = chip; @@ -1026,8 +1025,6 @@ static int da9062_regulator_probe(struct platform_device *pdev) regl->desc.name); return PTR_ERR(regl->rdev); } - - n++; } /* LDOs overcurrent event support */ -- cgit v1.2.3-59-g8ed1b From df8c542ee853f22dc0e5584ba0a70de397a3d73e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 7 Oct 2019 19:43:20 +0800 Subject: regulator: pbias: Get rid of struct pbias_regulator_data Only the desc field is really used, so use struct regulator_desc instead. Then struct pbias_regulator_data can be removed. Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20191007114320.20977-1-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/pbias-regulator.c | 69 ++++++++++++++----------------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index a59811060bdc..bfc15dd3f730 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c @@ -38,15 +38,6 @@ struct pbias_reg_info { int n_voltages; }; -struct pbias_regulator_data { - struct regulator_desc desc; - void __iomem *pbias_addr; - struct regulator_dev *dev; - struct regmap *syscon; - const struct pbias_reg_info *info; - int voltage; -}; - struct pbias_of_data { unsigned int offset; }; @@ -157,13 +148,13 @@ MODULE_DEVICE_TABLE(of, pbias_of_match); static int pbias_regulator_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct pbias_regulator_data *drvdata; struct resource *res; struct regulator_config cfg = { }; + struct regulator_desc *desc; + struct regulator_dev *rdev; struct regmap *syscon; const struct pbias_reg_info *info; - int ret = 0; - int count, idx, data_idx = 0; + int ret, count, idx; const struct pbias_of_data *data; unsigned int offset; @@ -172,10 +163,8 @@ static int pbias_regulator_probe(struct platform_device *pdev) if (count < 0) return count; - drvdata = devm_kcalloc(&pdev->dev, - count, sizeof(struct pbias_regulator_data), - GFP_KERNEL); - if (!drvdata) + desc = devm_kcalloc(&pdev->dev, count, sizeof(*desc), GFP_KERNEL); + if (!desc) return -ENOMEM; syscon = syscon_regmap_lookup_by_phandle(np, "syscon"); @@ -198,7 +187,7 @@ static int pbias_regulator_probe(struct platform_device *pdev) cfg.regmap = syscon; cfg.dev = &pdev->dev; - for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { + for (idx = 0; idx < PBIAS_NUM_REGS && count; idx++) { if (!pbias_matches[idx].init_data || !pbias_matches[idx].of_node) continue; @@ -207,41 +196,35 @@ static int pbias_regulator_probe(struct platform_device *pdev) if (!info) return -ENODEV; - drvdata[data_idx].syscon = syscon; - drvdata[data_idx].info = info; - drvdata[data_idx].desc.name = info->name; - drvdata[data_idx].desc.owner = THIS_MODULE; - drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; - drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; - drvdata[data_idx].desc.volt_table = info->pbias_volt_table; - drvdata[data_idx].desc.n_voltages = info->n_voltages; - drvdata[data_idx].desc.enable_time = info->enable_time; - drvdata[data_idx].desc.vsel_reg = offset; - drvdata[data_idx].desc.vsel_mask = info->vmode; - drvdata[data_idx].desc.enable_reg = offset; - drvdata[data_idx].desc.enable_mask = info->enable_mask; - drvdata[data_idx].desc.enable_val = info->enable; - drvdata[data_idx].desc.disable_val = info->disable_val; + desc->name = info->name; + desc->owner = THIS_MODULE; + desc->type = REGULATOR_VOLTAGE; + desc->ops = &pbias_regulator_voltage_ops; + desc->volt_table = info->pbias_volt_table; + desc->n_voltages = info->n_voltages; + desc->enable_time = info->enable_time; + desc->vsel_reg = offset; + desc->vsel_mask = info->vmode; + desc->enable_reg = offset; + desc->enable_mask = info->enable_mask; + desc->enable_val = info->enable; + desc->disable_val = info->disable_val; cfg.init_data = pbias_matches[idx].init_data; - cfg.driver_data = &drvdata[data_idx]; cfg.of_node = pbias_matches[idx].of_node; - drvdata[data_idx].dev = devm_regulator_register(&pdev->dev, - &drvdata[data_idx].desc, &cfg); - if (IS_ERR(drvdata[data_idx].dev)) { - ret = PTR_ERR(drvdata[data_idx].dev); + rdev = devm_regulator_register(&pdev->dev, desc, &cfg); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); - goto err_regulator; + return ret; } - data_idx++; + desc++; + count--; } - platform_set_drvdata(pdev, drvdata); - -err_regulator: - return ret; + return 0; } static struct platform_driver pbias_regulator_driver = { -- cgit v1.2.3-59-g8ed1b From 5be0e549e18f8ad7efa81b3e054ca094b7782f55 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 4 Oct 2019 16:10:11 -0700 Subject: regulator: s5m8767: switch to using devm_fwnode_gpiod_get devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes. Let's switch this driver over. Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20191004231017.130290-2-dmitry.torokhov@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/s5m8767.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 6ca27e9d5ef7..bdc07739e9a2 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -567,11 +567,10 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, continue; } - rdata->ext_control_gpiod = devm_gpiod_get_from_of_node( + rdata->ext_control_gpiod = devm_fwnode_gpiod_get( &pdev->dev, - reg_np, - "s5m8767,pmic-ext-control-gpios", - 0, + of_fwnode_handle(reg_np), + "s5m8767,pmic-ext-control", GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, "s5m8767"); if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT) -- cgit v1.2.3-59-g8ed1b From de2cd1a552673f370f8ea39a0241f764fbcf39e5 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 4 Oct 2019 16:10:12 -0700 Subject: regulator: slg51000: switch to using fwnode_gpiod_get_index devm_gpiod_get_from_of_node() is being retired in favor of [devm_]fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes. Let's switch this driver over. Note that now that we have a good non-devm API for getting GPIO from arbitrary firmware node, there is no reason to use devm API here as regulator core takes care of managing lifetime of "enable" GPIO and we were immediately detaching requested GPIO from devm anyway. Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20191004231017.130290-3-dmitry.torokhov@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/slg51000-regulator.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/slg51000-regulator.c b/drivers/regulator/slg51000-regulator.c index a0565daecace..bf1a3508ebc4 100644 --- a/drivers/regulator/slg51000-regulator.c +++ b/drivers/regulator/slg51000-regulator.c @@ -198,17 +198,14 @@ static int slg51000_of_parse_cb(struct device_node *np, const struct regulator_desc *desc, struct regulator_config *config) { - struct slg51000 *chip = config->driver_data; struct gpio_desc *ena_gpiod; - enum gpiod_flags gflags = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE; - ena_gpiod = devm_gpiod_get_from_of_node(chip->dev, np, - "enable-gpios", 0, - gflags, "gpio-en-ldo"); - if (!IS_ERR(ena_gpiod)) { + ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0, + GPIOD_OUT_LOW | + GPIOD_FLAGS_BIT_NONEXCLUSIVE, + "gpio-en-ldo"); + if (!IS_ERR(ena_gpiod)) config->ena_gpiod = ena_gpiod; - devm_gpiod_unhinge(chip->dev, config->ena_gpiod); - } return 0; } -- cgit v1.2.3-59-g8ed1b From 51d98ff8616a3c46233bdd1b714b8f19537bc9a8 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 4 Oct 2019 16:10:13 -0700 Subject: regulator: tps65090: switch to using devm_fwnode_gpiod_get devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes. Let's switch this driver over. Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20191004231017.130290-4-dmitry.torokhov@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/tps65090-regulator.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 10ea4b5a0f55..f0b660e9f15f 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -346,16 +346,20 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( for (idx = 0; idx < ARRAY_SIZE(tps65090_matches); idx++) { struct regulator_init_data *ri_data; struct tps65090_regulator_plat_data *rpdata; + struct device_node *np; rpdata = ®_pdata[idx]; ri_data = tps65090_matches[idx].init_data; - if (!ri_data || !tps65090_matches[idx].of_node) + if (!ri_data) + continue; + + np = tps65090_matches[idx].of_node; + if (!np) continue; rpdata->reg_init_data = ri_data; - rpdata->enable_ext_control = of_property_read_bool( - tps65090_matches[idx].of_node, - "ti,enable-ext-control"); + rpdata->enable_ext_control = of_property_read_bool(np, + "ti,enable-ext-control"); if (rpdata->enable_ext_control) { enum gpiod_flags gflags; @@ -366,11 +370,12 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( gflags = GPIOD_OUT_LOW; gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE; - rpdata->gpiod = devm_gpiod_get_from_of_node(&pdev->dev, - tps65090_matches[idx].of_node, - "dcdc-ext-control-gpios", 0, - gflags, - "tps65090"); + rpdata->gpiod = devm_fwnode_gpiod_get( + &pdev->dev, + of_fwnode_handle(np), + "dcdc-ext-control", + gflags, + "tps65090"); if (PTR_ERR(rpdata->gpiod) == -ENOENT) { dev_err(&pdev->dev, "could not find DCDC external control GPIO\n"); @@ -379,8 +384,7 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( return ERR_CAST(rpdata->gpiod); } - if (of_property_read_u32(tps65090_matches[idx].of_node, - "ti,overcurrent-wait", + if (of_property_read_u32(np, "ti,overcurrent-wait", &rpdata->overcurrent_wait) == 0) rpdata->overcurrent_wait_valid = true; -- cgit v1.2.3-59-g8ed1b From de2792b507675641885075bc99e283de861b1ce6 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 4 Oct 2019 16:10:14 -0700 Subject: regulator: s2mps11: switch to using devm_fwnode_gpiod_get devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes. Let's switch this driver over. Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20191004231017.130290-5-dmitry.torokhov@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 5bc00884cf51..4f2dc5ebffdc 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -844,10 +844,9 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, if (!rdata[reg].init_data || !rdata[reg].of_node) continue; - gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev, - rdata[reg].of_node, - "samsung,ext-control-gpios", - 0, + gpio[reg] = devm_fwnode_gpiod_get(&pdev->dev, + of_fwnode_handle(rdata[reg].of_node), + "samsung,ext-control", GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, "s2mps11-regulator"); if (PTR_ERR(gpio[reg]) == -ENOENT) -- cgit v1.2.3-59-g8ed1b From 61d2fc3cf8f557193c8c362ea75f06fa5a0abcfe Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 4 Oct 2019 16:10:15 -0700 Subject: regulator: da9211: switch to using devm_fwnode_gpiod_get devm_gpiod_get_from_of_node() is being retired in favor of devm_fwnode_gpiod_get_index(), that behaves similar to devm_gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes. Let's switch this driver over. Signed-off-by: Dmitry Torokhov Acked-by: Adam Thomson Link: https://lore.kernel.org/r/20191004231017.130290-6-dmitry.torokhov@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/da9211-regulator.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c index bf80748f1ccc..523dc1b95826 100644 --- a/drivers/regulator/da9211-regulator.c +++ b/drivers/regulator/da9211-regulator.c @@ -283,12 +283,12 @@ static struct da9211_pdata *da9211_parse_regulators_dt( pdata->init_data[n] = da9211_matches[i].init_data; pdata->reg_node[n] = da9211_matches[i].of_node; - pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev, - da9211_matches[i].of_node, - "enable-gpios", - 0, - GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, - "da9211-enable"); + pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev, + of_fwnode_handle(pdata->reg_node[n]), + "enable", + GPIOD_OUT_HIGH | + GPIOD_FLAGS_BIT_NONEXCLUSIVE, + "da9211-enable"); if (IS_ERR(pdata->gpiod_ren[n])) pdata->gpiod_ren[n] = NULL; n++; -- cgit v1.2.3-59-g8ed1b From 22803ca3c56b02e5bb8a4eb14104114009fd1c65 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 4 Oct 2019 16:10:16 -0700 Subject: regulator: tps65132: switch to using devm_fwnode_gpiod_get() devm_fwnode_get_index_gpiod_from_child() is going away as the name is too unwieldy, let's switch to using the new devm_fwnode_gpiod_get(). Note that we no longer need to check for NULL as devm_fwnode_gpiod_get() will return -ENOENT if GPIO is missing. Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20191004231017.130290-7-dmitry.torokhov@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/tps65132-regulator.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/regulator/tps65132-regulator.c b/drivers/regulator/tps65132-regulator.c index e302bd01a084..7b0e38f8d627 100644 --- a/drivers/regulator/tps65132-regulator.c +++ b/drivers/regulator/tps65132-regulator.c @@ -136,9 +136,10 @@ static int tps65132_of_parse_cb(struct device_node *np, struct tps65132_reg_pdata *rpdata = &tps->reg_pdata[desc->id]; int ret; - rpdata->en_gpiod = devm_fwnode_get_index_gpiod_from_child(tps->dev, - "enable", 0, &np->fwnode, 0, "enable"); - if (IS_ERR_OR_NULL(rpdata->en_gpiod)) { + rpdata->en_gpiod = devm_fwnode_gpiod_get(tps->dev, of_fwnode_handle(np), + "enable", GPIOD_ASIS, + "enable"); + if (IS_ERR(rpdata->en_gpiod)) { ret = PTR_ERR(rpdata->en_gpiod); /* Ignore the error other than probe defer */ @@ -147,10 +148,12 @@ static int tps65132_of_parse_cb(struct device_node *np, return 0; } - rpdata->act_dis_gpiod = devm_fwnode_get_index_gpiod_from_child( - tps->dev, "active-discharge", 0, - &np->fwnode, 0, "active-discharge"); - if (IS_ERR_OR_NULL(rpdata->act_dis_gpiod)) { + rpdata->act_dis_gpiod = devm_fwnode_gpiod_get(tps->dev, + of_fwnode_handle(np), + "active-discharge", + GPIOD_ASIS, + "active-discharge"); + if (IS_ERR(rpdata->act_dis_gpiod)) { ret = PTR_ERR(rpdata->act_dis_gpiod); /* Ignore the error other than probe defer */ -- cgit v1.2.3-59-g8ed1b From 0b2ba815fb5cbfab253f175d0b0d0d93d7ab9b5d Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Fri, 4 Oct 2019 16:10:17 -0700 Subject: regulator: max77686: switch to using fwnode_gpiod_get_index gpiod_get_from_of_node() is being retired in favor of fwnode_gpiod_get_index(), that behaves similar to gpiod_get_index(), but can work with arbitrary firmware node. It will also be able to support secondary software nodes. Let's switch this driver over. Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20191004231017.130290-8-dmitry.torokhov@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/max77686-regulator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c index c8e579e99316..9089ec608fcc 100644 --- a/drivers/regulator/max77686-regulator.c +++ b/drivers/regulator/max77686-regulator.c @@ -256,8 +256,9 @@ static int max77686_of_parse_cb(struct device_node *np, case MAX77686_BUCK8: case MAX77686_BUCK9: case MAX77686_LDO20 ... MAX77686_LDO22: - config->ena_gpiod = gpiod_get_from_of_node(np, - "maxim,ena-gpios", + config->ena_gpiod = fwnode_gpiod_get_index( + of_fwnode_handle(np), + "maxim,ena", 0, GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, "max77686-regulator"); -- cgit v1.2.3-59-g8ed1b From 2e67f32296e3f1841793e36ce796f1497614c687 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 8 Oct 2019 09:06:26 +0800 Subject: regulator: rk808: Constify rk817 regulator_ops These regulator_ops variables never need to be modified, make them const so compiler can put them to .rodata. Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20191008010628.8513-1-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/rk808-regulator.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index 61bd5ef0806c..eda056fce65f 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -686,7 +686,7 @@ static const struct regulator_linear_range rk805_buck_1_2_voltage_ranges[] = { REGULATOR_LINEAR_RANGE(2300000, 63, 63, 0), }; -static struct regulator_ops rk809_buck5_ops_range = { +static const struct regulator_ops rk809_buck5_ops_range = { .list_voltage = regulator_list_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range, .get_voltage_sel = regulator_get_voltage_sel_regmap, @@ -700,7 +700,7 @@ static struct regulator_ops rk809_buck5_ops_range = { .set_suspend_disable = rk817_set_suspend_disable, }; -static struct regulator_ops rk817_reg_ops = { +static const struct regulator_ops rk817_reg_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, .get_voltage_sel = regulator_get_voltage_sel_regmap, @@ -713,7 +713,7 @@ static struct regulator_ops rk817_reg_ops = { .set_suspend_disable = rk817_set_suspend_disable, }; -static struct regulator_ops rk817_boost_ops = { +static const struct regulator_ops rk817_boost_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, .get_voltage_sel = regulator_get_voltage_sel_regmap, @@ -725,7 +725,7 @@ static struct regulator_ops rk817_boost_ops = { .set_suspend_disable = rk817_set_suspend_disable, }; -static struct regulator_ops rk817_buck_ops_range = { +static const struct regulator_ops rk817_buck_ops_range = { .list_voltage = regulator_list_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range, .get_voltage_sel = regulator_get_voltage_sel_regmap, @@ -743,7 +743,7 @@ static struct regulator_ops rk817_buck_ops_range = { .set_suspend_disable = rk817_set_suspend_disable, }; -static struct regulator_ops rk817_switch_ops = { +static const struct regulator_ops rk817_switch_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = rk8xx_is_enabled_wmsk_regmap, -- cgit v1.2.3-59-g8ed1b From cc37038fe344e6000d30879c27521ee47c534fc8 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 8 Oct 2019 09:06:27 +0800 Subject: regulator: rk808: Fix warning message in rk817_set_ramp_delay The default in rk817_set_ramp_delay is 25MV rather than 10MV. Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20191008010628.8513-2-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/rk808-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index eda056fce65f..d0d1b868b0cd 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -388,7 +388,7 @@ static int rk817_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) break; default: dev_warn(&rdev->dev, - "%s ramp_delay: %d not supported, setting 10000\n", + "%s ramp_delay: %d not supported, setting 25000\n", rdev->desc->name, ramp_delay); } -- cgit v1.2.3-59-g8ed1b From 9306a733f8eac86400b9149db6d047dc371e46a2 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 8 Oct 2019 09:06:28 +0800 Subject: regulator: rk808: Remove rk817_set_suspend_voltage function The implement is exactly the same as rk808_set_suspend_voltage, so just use rk808_set_suspend_voltage instead. Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20191008010628.8513-3-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/rk808-regulator.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index d0d1b868b0cd..5b4003226484 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -411,21 +411,6 @@ static int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv) sel); } -static int rk817_set_suspend_voltage(struct regulator_dev *rdev, int uv) -{ - unsigned int reg; - int sel = regulator_map_voltage_linear(rdev, uv, uv); - /* only ldo1~ldo9 */ - if (sel < 0) - return -EINVAL; - - reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; - - return regmap_update_bits(rdev->regmap, reg, - rdev->desc->vsel_mask, - sel); -} - static int rk808_set_suspend_voltage_range(struct regulator_dev *rdev, int uv) { unsigned int reg; @@ -708,7 +693,7 @@ static const struct regulator_ops rk817_reg_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = rk8xx_is_enabled_wmsk_regmap, - .set_suspend_voltage = rk817_set_suspend_voltage, + .set_suspend_voltage = rk808_set_suspend_voltage, .set_suspend_enable = rk817_set_suspend_enable, .set_suspend_disable = rk817_set_suspend_disable, }; -- cgit v1.2.3-59-g8ed1b From be446f183ae35a8c76687ea8203fdd86f3f9678e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 7 Oct 2019 19:50:09 +0800 Subject: regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same. Signed-off-by: Axel Lin Reviewed-by: Adam Thomson Link: https://lore.kernel.org/r/20191007115009.25672-2-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/da9062-regulator.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c index 9bb895006455..4b24518f75b5 100644 --- a/drivers/regulator/da9062-regulator.c +++ b/drivers/regulator/da9062-regulator.c @@ -136,7 +136,7 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode) static unsigned da9062_buck_get_mode(struct regulator_dev *rdev) { struct da9062_regulator *regl = rdev_get_drvdata(rdev); - unsigned int val, mode = 0; + unsigned int val; int ret; ret = regmap_field_read(regl->mode, &val); @@ -146,7 +146,6 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev) switch (val) { default: case BUCK_MODE_MANUAL: - mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY; /* Sleep flag bit decides the mode */ break; case BUCK_MODE_SLEEP: @@ -162,11 +161,9 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev) return 0; if (val) - mode &= REGULATOR_MODE_STANDBY; + return REGULATOR_MODE_STANDBY; else - mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST; - - return mode; + return REGULATOR_MODE_FAST; } /* -- cgit v1.2.3-59-g8ed1b From 73511a90b74c9cfb6509dae63ec4db2d96b7b203 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 9 Oct 2019 23:01:38 +0800 Subject: regulator: stm32-vrefbuf: use devm_platform_ioremap_resource() to simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191009150138.11640-1-yuehaibing@huawei.com Signed-off-by: Mark Brown --- drivers/regulator/stm32-vrefbuf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c index 8919a5130bec..bdfaf7edb75a 100644 --- a/drivers/regulator/stm32-vrefbuf.c +++ b/drivers/regulator/stm32-vrefbuf.c @@ -181,7 +181,6 @@ static const struct regulator_desc stm32_vrefbuf_regu = { static int stm32_vrefbuf_probe(struct platform_device *pdev) { - struct resource *res; struct stm32_vrefbuf *priv; struct regulator_config config = { }; struct regulator_dev *rdev; @@ -192,8 +191,7 @@ static int stm32_vrefbuf_probe(struct platform_device *pdev) return -ENOMEM; priv->dev = &pdev->dev; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - priv->base = devm_ioremap_resource(&pdev->dev, res); + priv->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->base)) return PTR_ERR(priv->base); -- cgit v1.2.3-59-g8ed1b From 907becb2638df95b78581381bed225c4f3e35799 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 9 Oct 2019 23:02:03 +0800 Subject: regulator: uniphier: use devm_platform_ioremap_resource() to simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191009150203.8052-1-yuehaibing@huawei.com Signed-off-by: Mark Brown --- drivers/regulator/uniphier-regulator.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/regulator/uniphier-regulator.c b/drivers/regulator/uniphier-regulator.c index 2311924c3103..2e02e26b516c 100644 --- a/drivers/regulator/uniphier-regulator.c +++ b/drivers/regulator/uniphier-regulator.c @@ -45,7 +45,6 @@ static int uniphier_regulator_probe(struct platform_device *pdev) struct regulator_config config = { }; struct regulator_dev *rdev; struct regmap *regmap; - struct resource *res; void __iomem *base; const char *name; int i, ret, nr; @@ -58,8 +57,7 @@ static int uniphier_regulator_probe(struct platform_device *pdev) if (WARN_ON(!priv->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); -- cgit v1.2.3-59-g8ed1b From 55d5f62c3fa005a6a8010363d7d1855909ceefbc Mon Sep 17 00:00:00 2001 From: Matti Vaittinen Date: Wed, 23 Oct 2019 15:14:52 +0300 Subject: regulator: bd70528: Add MODULE_ALIAS to allow module auto loading The bd70528 regulator driver is probed by MFD driver. Add MODULE_ALIAS in order to allow udev to load the module when MFD sub-device cell for regulators is added. Fixes: 99ea37bd1e7d7 ("regulator: bd70528: Support ROHM BD70528 regulator block") Signed-off-by: Matti Vaittinen Link: https://lore.kernel.org/r/20191023121452.GA1812@localhost.localdomain Signed-off-by: Mark Brown --- drivers/regulator/bd70528-regulator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/bd70528-regulator.c b/drivers/regulator/bd70528-regulator.c index 0248a61f1006..ec764022621f 100644 --- a/drivers/regulator/bd70528-regulator.c +++ b/drivers/regulator/bd70528-regulator.c @@ -286,3 +286,4 @@ module_platform_driver(bd70528_regulator); MODULE_AUTHOR("Matti Vaittinen "); MODULE_DESCRIPTION("BD70528 voltage regulator driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:bd70528-pmic"); -- cgit v1.2.3-59-g8ed1b From 26c2c997aa1a6c5522f6619910ba025e53e69763 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Fri, 25 Oct 2019 03:22:39 +0300 Subject: regulator: core: Release coupled_rdevs on regulator_init_coupling() error This patch fixes memory leak which should happen if regulator's coupling fails to initialize. Fixes: d8ca7d184b33 ("regulator: core: Introduce API for regulators coupling customization") Signed-off-by: Dmitry Osipenko Link: https://lore.kernel.org/r/20191025002240.25288-1-digetx@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a46be221dbdc..51ce280c1ce1 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5198,6 +5198,7 @@ unset_supplies: regulator_remove_coupling(rdev); mutex_unlock(®ulator_list_mutex); wash: + kfree(rdev->coupling_desc.coupled_rdevs); kfree(rdev->constraints); mutex_lock(®ulator_list_mutex); regulator_ena_gpio_free(rdev); -- cgit v1.2.3-59-g8ed1b From e381bfe45a891a5894465f072c5bbf3ed3e33b8a Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Fri, 25 Oct 2019 03:22:40 +0300 Subject: regulator: core: Allow generic coupling only for always-on regulators The generic voltage balancer doesn't work correctly if one of regulator couples turns off. Currently there are no users in kernel for that case, although let's explicitly show that this case is unsupported for those who will try to use that feature. Link: https://lore.kernel.org/linux-samsung-soc/20191008170503.yd6GscYPLxjgrXqDuCO7AJc6i6egNZGJkVWHLlCxvA4@z/ Signed-off-by: Dmitry Osipenko Link: https://lore.kernel.org/r/20191025002240.25288-2-digetx@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a46be221dbdc..a5b2a9b02108 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4963,6 +4963,12 @@ static int generic_coupler_attach(struct regulator_coupler *coupler, return -EPERM; } + if (!rdev->constraints->always_on) { + rdev_err(rdev, + "Coupling of a non always-on regulator is unimplemented\n"); + return -ENOTSUPP; + } + return 0; } -- cgit v1.2.3-59-g8ed1b From 96da2d9c905b36a30052a5e38ae5d47c3dc988e6 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 29 Oct 2019 01:21:27 +0000 Subject: dt-bindings: regulator: fixed: add off-on-delay-us property When disabling a fixed regulator, it may take some time to let the voltage drop to the expected value, such as zero. If not delay enough time, the regulator might have been always enabled. Signed-off-by: Peng Fan Link: https://lore.kernel.org/r/1572311875-22880-2-git-send-email-peng.fan@nxp.com Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/regulator/fixed-regulator.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml b/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml index f32416968197..59b4b73d4051 100644 --- a/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.yaml @@ -50,6 +50,10 @@ properties: description: startup time in microseconds $ref: /schemas/types.yaml#/definitions/uint32 + off-on-delay-us: + description: off delay time in microseconds + $ref: /schemas/types.yaml#/definitions/uint32 + enable-active-high: description: Polarity of GPIO is Active high. If this property is missing, -- cgit v1.2.3-59-g8ed1b From f7907e57aea2adcd0b57ebcca410e125412ab680 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 29 Oct 2019 01:21:31 +0000 Subject: regulator: fixed: add off-on-delay Depends on board design, the gpio controlling regulator may connects with a big capacitance. When need off, it takes some time to let the regulator to be truly off. If not add enough delay, the regulator might have always been on, so introduce off-on-delay to handle such case. Signed-off-by: Peng Fan Link: https://lore.kernel.org/r/1572311875-22880-3-git-send-email-peng.fan@nxp.com Signed-off-by: Mark Brown --- drivers/regulator/fixed.c | 2 ++ include/linux/regulator/fixed.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index f81533070058..bc0bbd99e98d 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -123,6 +123,7 @@ of_get_fixed_voltage_config(struct device *dev, config->enabled_at_boot = true; of_property_read_u32(np, "startup-delay-us", &config->startup_delay); + of_property_read_u32(np, "off-on-delay-us", &config->off_on_delay); if (of_find_property(np, "vin-supply", NULL)) config->input_supply = "vin"; @@ -189,6 +190,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) } drvdata->desc.enable_time = config->startup_delay; + drvdata->desc.off_on_delay = config->off_on_delay; if (config->input_supply) { drvdata->desc.supply_name = devm_kstrdup(&pdev->dev, diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index d44ce5f18a56..55319943fcc5 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h @@ -36,6 +36,7 @@ struct fixed_voltage_config { const char *input_supply; int microvolts; unsigned startup_delay; + unsigned int off_on_delay; unsigned enabled_at_boot:1; struct regulator_init_data *init_data; }; -- cgit v1.2.3-59-g8ed1b From 5365e3df422938e6b34e1afdd2ff1cfc5768290e Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Wed, 6 Nov 2019 08:12:11 -0800 Subject: regulator: fan53555: add chip id for Silergy SYR83X SYR83X is used in Rockpro64 and it has die ID == 9. All other registers are the same as in SYR82X Signed-off-by: Vasily Khoruzhick Link: https://lore.kernel.org/r/20191106161211.1700663-1-anarsoul@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/fan53555.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index dbe477da4e55..00c83492f774 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -83,6 +83,7 @@ enum { enum { SILERGY_SYR82X = 8, + SILERGY_SYR83X = 9, }; struct fan53555_device_info { @@ -302,6 +303,7 @@ static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di) /* Init voltage range and step */ switch (di->chip_id) { case SILERGY_SYR82X: + case SILERGY_SYR83X: di->vsel_min = 712500; di->vsel_step = 12500; break; -- cgit v1.2.3-59-g8ed1b From 99c4f70df3a6446c56ca817c2d0f9c12d85d4e7c Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Wed, 6 Nov 2019 18:31:24 +0100 Subject: regulator: ab8500: Remove AB8505 USB regulator The USB regulator was removed for AB8500 in commit 41a06aa738ad ("regulator: ab8500: Remove USB regulator"). It was then added for AB8505 in commit 547f384f33db ("regulator: ab8500: add support for ab8505"). However, there was never an entry added for it in ab8505_regulator_match. This causes all regulators after it to be initialized with the wrong device tree data, eventually leading to an out-of-bounds array read. Given that it is not used anywhere in the kernel, it seems likely that similar arguments against supporting it exist for AB8505 (it is controlled by hardware). Therefore, simply remove it like for AB8500 instead of adding an entry in ab8505_regulator_match. Fixes: 547f384f33db ("regulator: ab8500: add support for ab8505") Cc: Linus Walleij Signed-off-by: Stephan Gerhold Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20191106173125.14496-1-stephan@gerhold.net Signed-off-by: Mark Brown --- drivers/regulator/ab8500.c | 17 ----------------- include/linux/regulator/ab8500.h | 1 - 2 files changed, 18 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index efb2f01a9101..f60e1b26c2d2 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -953,23 +953,6 @@ static struct ab8500_regulator_info .update_val_idle = 0x82, .update_val_normal = 0x02, }, - [AB8505_LDO_USB] = { - .desc = { - .name = "LDO-USB", - .ops = &ab8500_regulator_mode_ops, - .type = REGULATOR_VOLTAGE, - .id = AB8505_LDO_USB, - .owner = THIS_MODULE, - .n_voltages = 1, - .volt_table = fixed_3300000_voltage, - }, - .update_bank = 0x03, - .update_reg = 0x82, - .update_mask = 0x03, - .update_val = 0x01, - .update_val_idle = 0x03, - .update_val_normal = 0x01, - }, [AB8505_LDO_AUDIO] = { .desc = { .name = "LDO-AUDIO", diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h index 7cf8f797e13a..505e94a6e3e8 100644 --- a/include/linux/regulator/ab8500.h +++ b/include/linux/regulator/ab8500.h @@ -37,7 +37,6 @@ enum ab8505_regulator_id { AB8505_LDO_AUX6, AB8505_LDO_INTCORE, AB8505_LDO_ADC, - AB8505_LDO_USB, AB8505_LDO_AUDIO, AB8505_LDO_ANAMIC1, AB8505_LDO_ANAMIC2, -- cgit v1.2.3-59-g8ed1b From 458ea3ad033fc86e291712ce50cbe60c3428cf30 Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Wed, 6 Nov 2019 18:31:25 +0100 Subject: regulator: ab8500: Remove SYSCLKREQ from enum ab8505_regulator_id Those regulators are not actually supported by the AB8500 regulator driver. There is no ab8500_regulator_info for them and no entry in ab8505_regulator_match. As such, they cannot be registered successfully, and looking them up in ab8505_regulator_match causes an out-of-bounds array read. Fixes: 547f384f33db ("regulator: ab8500: add support for ab8505") Cc: Linus Walleij Signed-off-by: Stephan Gerhold Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20191106173125.14496-2-stephan@gerhold.net Signed-off-by: Mark Brown --- include/linux/regulator/ab8500.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h index 505e94a6e3e8..3ab1ddf151a2 100644 --- a/include/linux/regulator/ab8500.h +++ b/include/linux/regulator/ab8500.h @@ -42,8 +42,6 @@ enum ab8505_regulator_id { AB8505_LDO_ANAMIC2, AB8505_LDO_AUX8, AB8505_LDO_ANA, - AB8505_SYSCLKREQ_2, - AB8505_SYSCLKREQ_4, AB8505_NUM_REGULATORS, }; -- cgit v1.2.3-59-g8ed1b From b59b654478093fa429ad4c7897ae29f201146a00 Mon Sep 17 00:00:00 2001 From: Saravana Kannan Date: Thu, 14 Nov 2019 16:04:38 -0800 Subject: regulator: core: Don't try to remove device links if add failed device_link_add() might not always succeed depending on the type of device link and the rest of the dependencies in the system. If device_link_add() didn't succeed, then we shouldn't try to remove the link later on as it might remove a link someone else created. Signed-off-by: Saravana Kannan Link: https://lore.kernel.org/r/20191115000438.45970-1-saravanak@google.com Signed-off-by: Mark Brown --- drivers/regulator/core.c | 8 ++++++-- drivers/regulator/internal.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 51ce280c1ce1..df49f35ae20f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1844,6 +1844,7 @@ struct regulator *_regulator_get(struct device *dev, const char *id, struct regulator_dev *rdev; struct regulator *regulator; const char *devname = dev ? dev_name(dev) : "deviceless"; + struct device_link *link; int ret; if (get_type >= MAX_GET_TYPE) { @@ -1951,7 +1952,9 @@ struct regulator *_regulator_get(struct device *dev, const char *id, rdev->use_count = 0; } - device_link_add(dev, &rdev->dev, DL_FLAG_STATELESS); + link = device_link_add(dev, &rdev->dev, DL_FLAG_STATELESS); + if (!IS_ERR_OR_NULL(link)) + regulator->device_link = true; return regulator; } @@ -2046,7 +2049,8 @@ static void _regulator_put(struct regulator *regulator) debugfs_remove_recursive(regulator->debugfs); if (regulator->dev) { - device_link_remove(regulator->dev, &rdev->dev); + if (regulator->device_link) + device_link_remove(regulator->dev, &rdev->dev); /* remove any sysfs entries */ sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h index 83ae442f515b..2391b565ef11 100644 --- a/drivers/regulator/internal.h +++ b/drivers/regulator/internal.h @@ -36,6 +36,7 @@ struct regulator { struct list_head list; unsigned int always_on:1; unsigned int bypass:1; + unsigned int device_link:1; int uA_load; unsigned int enable_count; unsigned int deferred_disables; -- cgit v1.2.3-59-g8ed1b From 089b3f61ecfc43ca4ea26d595e1d31ead6de3f7b Mon Sep 17 00:00:00 2001 From: Pascal Paillet Date: Wed, 13 Nov 2019 11:27:37 +0100 Subject: regulator: core: Let boot-on regulators be powered off Boot-on regulators are always kept on because their use_count value is now incremented at boot time and never cleaned. Only increment count value for alway-on regulators. regulator_late_cleanup() is now able to power off boot-on regulators when unused. Fixes: 05f224ca6693 ("regulator: core: Clean enabling always-on regulators + their supplies") Signed-off-by: Pascal Paillet Link: https://lore.kernel.org/r/20191113102737.27831-1-p.paillet@st.com Signed-off-by: Mark Brown --- drivers/regulator/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a5b2a9b02108..5e6c629806e4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1403,7 +1403,9 @@ static int set_machine_constraints(struct regulator_dev *rdev, rdev_err(rdev, "failed to enable\n"); return ret; } - rdev->use_count++; + + if (rdev->constraints->always_on) + rdev->use_count++; } print_constraints(rdev); -- cgit v1.2.3-59-g8ed1b From 9ebde17c5d0387a5e1f71e687ac35d36e01208cc Mon Sep 17 00:00:00 2001 From: Pascal Paillet Date: Wed, 13 Nov 2019 17:15:29 +0100 Subject: regulator: stpmic1: Set a default ramp delay value Set a default ramp delay value to the regulators with the worst case value. Signed-off-by: pascal paillet Link: https://lore.kernel.org/r/20191113161529.27739-1-p.paillet@st.com Signed-off-by: Mark Brown --- drivers/regulator/stpmic1_regulator.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c index f09061473613..f3d7d007ecbb 100644 --- a/drivers/regulator/stpmic1_regulator.c +++ b/drivers/regulator/stpmic1_regulator.c @@ -54,6 +54,8 @@ enum { /* Enable time worst case is 5000mV/(2250uV/uS) */ #define PMIC_ENABLE_TIME_US 2200 +/* Ramp delay worst case is (2250uV/uS) */ +#define PMIC_RAMP_DELAY 2200 static const struct regulator_linear_range buck1_ranges[] = { REGULATOR_LINEAR_RANGE(725000, 0, 4, 0), @@ -208,6 +210,7 @@ static const struct regulator_ops stpmic1_switch_regul_ops = { .enable_val = 1, \ .disable_val = 0, \ .enable_time = PMIC_ENABLE_TIME_US, \ + .ramp_delay = PMIC_RAMP_DELAY, \ .supply_name = #base, \ } @@ -227,6 +230,7 @@ static const struct regulator_ops stpmic1_switch_regul_ops = { .enable_val = 1, \ .disable_val = 0, \ .enable_time = PMIC_ENABLE_TIME_US, \ + .ramp_delay = PMIC_RAMP_DELAY, \ .bypass_reg = LDO3_ACTIVE_CR, \ .bypass_mask = LDO_BYPASS_MASK, \ .bypass_val_on = LDO_BYPASS_MASK, \ @@ -248,6 +252,7 @@ static const struct regulator_ops stpmic1_switch_regul_ops = { .enable_val = 1, \ .disable_val = 0, \ .enable_time = PMIC_ENABLE_TIME_US, \ + .ramp_delay = PMIC_RAMP_DELAY, \ .supply_name = #base, \ } @@ -267,6 +272,7 @@ static const struct regulator_ops stpmic1_switch_regul_ops = { .enable_val = 1, \ .disable_val = 0, \ .enable_time = PMIC_ENABLE_TIME_US, \ + .ramp_delay = PMIC_RAMP_DELAY, \ .of_map_mode = stpmic1_map_mode, \ .pull_down_reg = ids##_PULL_DOWN_REG, \ .pull_down_mask = ids##_PULL_DOWN_MASK, \ -- cgit v1.2.3-59-g8ed1b From 7d34aec52d292197d6b13395b023c718cac4630f Mon Sep 17 00:00:00 2001 From: Christoph Fritz Date: Wed, 13 Nov 2019 14:40:13 +0100 Subject: regulator: da9062: refactor buck modes into header This patch refactors buck modes into a header file so that device trees can make use of these mode constants. The new header filename uses da9063 because DA9063 was the earlier chip and its driver code will want updating at some point in a similar manner. Signed-off-by: Christoph Fritz Link: https://lore.kernel.org/r/1573652416-9848-2-git-send-email-chf.fritz@googlemail.com Signed-off-by: Mark Brown --- drivers/regulator/da9062-regulator.c | 28 ++++++++-------------- .../dt-bindings/regulator/dlg,da9063-regulator.h | 16 +++++++++++++ 2 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 include/dt-bindings/regulator/dlg,da9063-regulator.h diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c index 4b24518f75b5..601002e3e012 100644 --- a/drivers/regulator/da9062-regulator.c +++ b/drivers/regulator/da9062-regulator.c @@ -16,6 +16,7 @@ #include #include #include +#include /* Regulator IDs */ enum { @@ -75,14 +76,6 @@ struct da9062_regulators { struct da9062_regulator regulator[0]; }; -/* BUCK modes */ -enum { - BUCK_MODE_MANUAL, /* 0 */ - BUCK_MODE_SLEEP, /* 1 */ - BUCK_MODE_SYNC, /* 2 */ - BUCK_MODE_AUTO /* 3 */ -}; - /* Regulator operations */ /* Current limits array (in uA) @@ -112,13 +105,13 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode) switch (mode) { case REGULATOR_MODE_FAST: - val = BUCK_MODE_SYNC; + val = DA9063_BUCK_MODE_SYNC; break; case REGULATOR_MODE_NORMAL: - val = BUCK_MODE_AUTO; + val = DA9063_BUCK_MODE_AUTO; break; case REGULATOR_MODE_STANDBY: - val = BUCK_MODE_SLEEP; + val = DA9063_BUCK_MODE_SLEEP; break; default: return -EINVAL; @@ -145,14 +138,13 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev) switch (val) { default: - case BUCK_MODE_MANUAL: /* Sleep flag bit decides the mode */ break; - case BUCK_MODE_SLEEP: + case DA9063_BUCK_MODE_SLEEP: return REGULATOR_MODE_STANDBY; - case BUCK_MODE_SYNC: + case DA9063_BUCK_MODE_SYNC: return REGULATOR_MODE_FAST; - case BUCK_MODE_AUTO: + case DA9063_BUCK_MODE_AUTO: return REGULATOR_MODE_NORMAL; } @@ -279,13 +271,13 @@ static int da9062_buck_set_suspend_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_FAST: - val = BUCK_MODE_SYNC; + val = DA9063_BUCK_MODE_SYNC; break; case REGULATOR_MODE_NORMAL: - val = BUCK_MODE_AUTO; + val = DA9063_BUCK_MODE_AUTO; break; case REGULATOR_MODE_STANDBY: - val = BUCK_MODE_SLEEP; + val = DA9063_BUCK_MODE_SLEEP; break; default: return -EINVAL; diff --git a/include/dt-bindings/regulator/dlg,da9063-regulator.h b/include/dt-bindings/regulator/dlg,da9063-regulator.h new file mode 100644 index 000000000000..1de710dd0899 --- /dev/null +++ b/include/dt-bindings/regulator/dlg,da9063-regulator.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _DT_BINDINGS_REGULATOR_DLG_DA9063_H +#define _DT_BINDINGS_REGULATOR_DLG_DA9063_H + +/* + * These buck mode constants may be used to specify values in device tree + * properties (e.g. regulator-initial-mode). + * A description of the following modes is in the manufacturers datasheet. + */ + +#define DA9063_BUCK_MODE_SLEEP 1 +#define DA9063_BUCK_MODE_SYNC 2 +#define DA9063_BUCK_MODE_AUTO 3 + +#endif -- cgit v1.2.3-59-g8ed1b From 844e7492ee3da1a8714bf3cc1dd54d777a5257c2 Mon Sep 17 00:00:00 2001 From: Christoph Fritz Date: Wed, 13 Nov 2019 14:40:14 +0100 Subject: regulator: da9062: add of_map_mode support for bucks This patch adds of_map_mode support for bucks to set regulator modes from within regulator framework. Signed-off-by: Christoph Fritz Signed-off-by: Christian Hemp Signed-off-by: Stefan Riedmueller Link: https://lore.kernel.org/r/1573652416-9848-3-git-send-email-chf.fritz@googlemail.com Signed-off-by: Mark Brown --- drivers/regulator/da9062-regulator.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c index 601002e3e012..29f4a60398a3 100644 --- a/drivers/regulator/da9062-regulator.c +++ b/drivers/regulator/da9062-regulator.c @@ -98,6 +98,20 @@ static const unsigned int da9062_buck_b_limits[] = { 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 }; +static unsigned int da9062_map_buck_mode(unsigned int mode) +{ + switch (mode) { + case DA9063_BUCK_MODE_SLEEP: + return REGULATOR_MODE_STANDBY; + case DA9063_BUCK_MODE_SYNC: + return REGULATOR_MODE_FAST; + case DA9063_BUCK_MODE_AUTO: + return REGULATOR_MODE_NORMAL; + default: + return -EINVAL; + } +} + static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode) { struct da9062_regulator *regl = rdev_get_drvdata(rdev); @@ -360,6 +374,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK1_A, .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_buck_mode, .sleep = REG_FIELD(DA9062AA_VBUCK1_A, __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -396,6 +411,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK3_A, .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_buck_mode, .sleep = REG_FIELD(DA9062AA_VBUCK3_A, __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -432,6 +448,7 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK4_A, .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_buck_mode, .sleep = REG_FIELD(DA9062AA_VBUCK4_A, __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -604,6 +621,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK1_A, .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_buck_mode, .sleep = REG_FIELD(DA9062AA_VBUCK1_A, __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -640,6 +658,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK2_A, .desc.vsel_mask = DA9062AA_VBUCK2_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_buck_mode, .sleep = REG_FIELD(DA9062AA_VBUCK2_A, __builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -676,6 +695,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK3_A, .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_buck_mode, .sleep = REG_FIELD(DA9062AA_VBUCK3_A, __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -712,6 +732,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK4_A, .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_buck_mode, .sleep = REG_FIELD(DA9062AA_VBUCK4_A, __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - -- cgit v1.2.3-59-g8ed1b From a4bb429811bd4a5be94873ae218062c83c476ed9 Mon Sep 17 00:00:00 2001 From: Christoph Fritz Date: Wed, 13 Nov 2019 14:40:15 +0100 Subject: dt-bindings: mfd: da9062: describe buck modes This patch adds DT description of da9062 buck regulator modes. Signed-off-by: Christoph Fritz Link: https://lore.kernel.org/r/1573652416-9848-4-git-send-email-chf.fritz@googlemail.com Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/mfd/da9062.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/da9062.txt b/Documentation/devicetree/bindings/mfd/da9062.txt index edca653a5777..bc4b59de6a55 100644 --- a/Documentation/devicetree/bindings/mfd/da9062.txt +++ b/Documentation/devicetree/bindings/mfd/da9062.txt @@ -66,6 +66,9 @@ Sub-nodes: details of individual regulator device can be found in: Documentation/devicetree/bindings/regulator/regulator.txt + regulator-initial-mode may be specified for buck regulators using mode values + from include/dt-bindings/regulator/dlg,da9063-regulator.h. + - rtc : This node defines settings required for the Real-Time Clock associated with the DA9062. There are currently no entries in this binding, however compatible = "dlg,da9062-rtc" should be added if a node is created. @@ -96,6 +99,7 @@ Example: regulator-max-microvolt = <1570000>; regulator-min-microamp = <500000>; regulator-max-microamp = <2000000>; + regulator-initial-mode = ; regulator-boot-on; }; DA9062_LDO1: ldo1 { -- cgit v1.2.3-59-g8ed1b From 1d7c4c115f7a835fec387d7f61767781381db5db Mon Sep 17 00:00:00 2001 From: zhengbin Date: Mon, 18 Nov 2019 18:59:22 +0800 Subject: regulator: vexpress: Use PTR_ERR_OR_ZERO() to simplify code Fixes coccicheck warning: drivers/regulator/vexpress-regulator.c:78:1-3: WARNING: PTR_ERR_OR_ZERO can be used Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1574074762-34629-1-git-send-email-zhengbin13@huawei.com Signed-off-by: Mark Brown --- drivers/regulator/vexpress-regulator.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/regulator/vexpress-regulator.c b/drivers/regulator/vexpress-regulator.c index 1235f46e633e..5d39663efcaa 100644 --- a/drivers/regulator/vexpress-regulator.c +++ b/drivers/regulator/vexpress-regulator.c @@ -75,10 +75,7 @@ static int vexpress_regulator_probe(struct platform_device *pdev) config.of_node = pdev->dev.of_node; rdev = devm_regulator_register(&pdev->dev, desc, &config); - if (IS_ERR(rdev)) - return PTR_ERR(rdev); - - return 0; + return PTR_ERR_OR_ZERO(rdev); } static const struct of_device_id vexpress_regulator_of_match[] = { -- cgit v1.2.3-59-g8ed1b From 3f1a9e630b6e124c387cc57f6fea517cec68b44f Mon Sep 17 00:00:00 2001 From: Andreas Kemnade Date: Wed, 13 Nov 2019 19:26:43 +0100 Subject: regulator: rn5t618: fix rc5t619 ldo10 enable LDO9 and LDO10 were listed with the same enable bits. That looks insane and there are no provisions in the code for handling such a special case. Also other out-of-tree drivers use a separate bit to enable it. Example: https://github.com/brunotl/kernel-kobo-mx6sl-ntx/blob/master/drivers/regulator/ricoh619-regulator.c So it seems to be clearly a bug. I cannot fully check it on my board without schematics and just discovered this during code analysis for another problem. Signed-off-by: Andreas Kemnade Link: https://lore.kernel.org/r/20191113182643.23885-1-andreas@kemnade.info Signed-off-by: Mark Brown --- drivers/regulator/rn5t618-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/rn5t618-regulator.c b/drivers/regulator/rn5t618-regulator.c index eb807a059479..4a91be0ad5ae 100644 --- a/drivers/regulator/rn5t618-regulator.c +++ b/drivers/regulator/rn5t618-regulator.c @@ -90,7 +90,7 @@ static const struct regulator_desc rc5t619_regulators[] = { REG(LDO7, LDOEN1, BIT(6), LDO7DAC, 0x7f, 900000, 3500000, 25000), REG(LDO8, LDOEN1, BIT(7), LDO8DAC, 0x7f, 900000, 3500000, 25000), REG(LDO9, LDOEN2, BIT(0), LDO9DAC, 0x7f, 900000, 3500000, 25000), - REG(LDO10, LDOEN2, BIT(0), LDO10DAC, 0x7f, 900000, 3500000, 25000), + REG(LDO10, LDOEN2, BIT(1), LDO10DAC, 0x7f, 900000, 3500000, 25000), /* LDO RTC */ REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1700000, 3500000, 25000), REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), -- cgit v1.2.3-59-g8ed1b From 62f7f3eca4c30064ab37b42d97cef4292d75fdd0 Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Tue, 19 Nov 2019 10:46:08 -0500 Subject: tps6105x: add optional devicetree support This driver currently requires platform data to specify the operational mode and regulator init data (in case of regulator mode). Optionally specify the operational mode by looking at the name of the devicetree child node. Example: put chip in regulator mode: i2c0 { tps61052@33 { compatible = "ti,tps61052"; reg = <0x33>; regulator { regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; regulator-always-on; }; }; }; Tree: linux-next Signed-off-by: Sven Van Asbroeck Link: https://lore.kernel.org/r/20191119154611.29625-2-TheSven73@gmail.com Signed-off-by: Mark Brown --- drivers/mfd/tps6105x.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c index 6ac3607a79c2..c906324d293e 100644 --- a/drivers/mfd/tps6105x.c +++ b/drivers/mfd/tps6105x.c @@ -91,6 +91,32 @@ static int tps6105x_add_device(struct tps6105x *tps6105x, PLATFORM_DEVID_AUTO, cell, 1, NULL, 0, NULL); } +static struct tps6105x_platform_data *tps6105x_parse_dt(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct tps6105x_platform_data *pdata; + struct device_node *child; + + if (!np) + return ERR_PTR(-EINVAL); + if (of_get_available_child_count(np) > 1) { + dev_err(dev, "cannot support multiple operational modes"); + return ERR_PTR(-EINVAL); + } + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + pdata->mode = TPS6105X_MODE_SHUTDOWN; + for_each_available_child_of_node(np, child) { + if (child->name && !of_node_cmp(child->name, "regulator")) + pdata->mode = TPS6105X_MODE_VOLTAGE; + else if (child->name && !of_node_cmp(child->name, "led")) + pdata->mode = TPS6105X_MODE_TORCH; + } + + return pdata; +} + static int tps6105x_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -99,9 +125,11 @@ static int tps6105x_probe(struct i2c_client *client, int ret; pdata = dev_get_platdata(&client->dev); - if (!pdata) { - dev_err(&client->dev, "missing platform data\n"); - return -ENODEV; + if (!pdata) + pdata = tps6105x_parse_dt(&client->dev); + if (IS_ERR(pdata)) { + dev_err(&client->dev, "No platform data or DT found"); + return PTR_ERR(pdata); } tps6105x = devm_kmalloc(&client->dev, sizeof(*tps6105x), GFP_KERNEL); -- cgit v1.2.3-59-g8ed1b From f0a19fa823fb7b1f98d54b22a3ae0e5de88a1e50 Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Tue, 19 Nov 2019 10:46:09 -0500 Subject: regulator: tps6105x: add optional devicetree support Tell the regulator framework to retrieve regulator init data from the 'regulator' subnode, or from the parent mfd device's platform data. Example: i2c0 { tps61052@33 { compatible = "ti,tps61052"; reg = <0x33>; regulator { regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; regulator-always-on; }; }; }; Tree: next-20191118 Signed-off-by: Sven Van Asbroeck Link: https://lore.kernel.org/r/20191119154611.29625-3-TheSven73@gmail.com Signed-off-by: Mark Brown --- drivers/regulator/tps6105x-regulator.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c index 06059a94f7c6..f8939af0bd2c 100644 --- a/drivers/regulator/tps6105x-regulator.c +++ b/drivers/regulator/tps6105x-regulator.c @@ -37,6 +37,7 @@ static struct regulator_ops tps6105x_regulator_ops = { static const struct regulator_desc tps6105x_regulator_desc = { .name = "tps6105x-boost", + .of_match = of_match_ptr("regulator"), .ops = &tps6105x_regulator_ops, .type = REGULATOR_VOLTAGE, .id = 0, @@ -71,6 +72,7 @@ static int tps6105x_regulator_probe(struct platform_device *pdev) config.dev = &tps6105x->client->dev; config.init_data = pdata->regulator_data; config.driver_data = tps6105x; + config.of_node = pdev->dev.parent->of_node; config.regmap = tps6105x->regmap; /* Register regulator with framework */ -- cgit v1.2.3-59-g8ed1b From 76bec25b32363f47225d35a70ccb97d6d0f09dd9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 20 Nov 2019 21:39:49 +0800 Subject: regulator: Fix Kconfig indentation Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^ /\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20191120133949.13996-1-krzk@kernel.org Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 3ee63531f6d5..74eb5af7295f 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -841,10 +841,10 @@ config REGULATOR_SKY81452 will be called sky81452-regulator. config REGULATOR_SLG51000 - tristate "Dialog Semiconductor SLG51000 regulators" - depends on I2C - select REGMAP_I2C - help + tristate "Dialog Semiconductor SLG51000 regulators" + depends on I2C + select REGMAP_I2C + help Say y here to support for the Dialog Semiconductor SLG51000. The SLG51000 is seven compact and customizable low dropout regulators. -- cgit v1.2.3-59-g8ed1b From c15d5a645875bc9b89f68f5d3fb608f691ac78d7 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 22 Nov 2019 12:51:54 +0800 Subject: regulator: da9062: Return REGULATOR_MODE_INVALID for invalid mode -EINVAL is not a valid return value for .of_map_mode, return REGULATOR_MODE_INVALID instead. Fixes: 844e7492ee3d ("regulator: da9062: add of_map_mode support for bucks") Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20191122045154.802-1-axel.lin@ingics.com Signed-off-by: Mark Brown --- drivers/regulator/da9062-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c index 29f4a60398a3..d3ce0278bfbe 100644 --- a/drivers/regulator/da9062-regulator.c +++ b/drivers/regulator/da9062-regulator.c @@ -108,7 +108,7 @@ static unsigned int da9062_map_buck_mode(unsigned int mode) case DA9063_BUCK_MODE_AUTO: return REGULATOR_MODE_NORMAL; default: - return -EINVAL; + return REGULATOR_MODE_INVALID; } } -- cgit v1.2.3-59-g8ed1b