Move Hisilicon 6421v600 SPMI driver set out of staging
Subsystems (9)
Mauro Carvalho Chehab
maintainerv2 cover Move Hisilicon 6421v600 SPMI driver set out of staging
Hi Mark,
This patch series finish addressing support for Hikey 970 SPMI controller, PMIC and regulators.
I removed some unrelated DT patches from this series, plus the Hikey 970 PHY USB3 code from it, in order to avoid mixing different stuff on this series[1].
[1] Those unrelated patches were submitted last week on separate series.
The entire patchset is on this branch:
https://git.linuxtv.org/mchehab/experimental.git/log/?h=devel/destage-usb
In order to make easier for review, this series was generated with --no-merges. So, you don't need to take a look at the staging patches, as the entire code will be there on patches 9-11.
Patches 12 and 13 on this series will require that the other patch series to get merged first. It probably makes sense to be merged via DT tree. I opted to add them here just because, on the last submission, you asked to see the DT patches.
On this version 2, I addressed almost all issues you pointed during your review:
- this driver's probe routine is very similar to the one at the non-SPMI variant of Hisilicon 6421;
- The register/voltage data were moved from DT into the driver itself;
- It doesn't have anymore any static data;
- All debug messages got removed;
- Addressed a few be32 warnings from sparse.
Regards,
Mauro
Mauro Carvalho Chehab (13):
staging: hikey9xx: hisilicon,hisi-spmi-controller.yaml fix bindings
staging: hikey9xx: hisi-spmi-controller: clean sparse warnings
staging: hikey9xx: hi6421v600-regulator: do some cleanups
staging: hikey9xx: hi6421v600-regulator: move LDO config from DT
staging: hikey9xx: hi6421v600-regulator: cleanup debug msgs
staging: hikey9xx: hisilicon,hi6421-spmi-pmic.yaml: simplify props
staging: hikey970: get rid of an static data
staging: hikey9xx: hi6421v600-regulator: do some cleanups
spmi: hi6421-spmi-pmic: move driver from staging
mfd: hi6421-spmi-pmic: move driver from staging
regulator: hi6421v600-regulator: move it from staging
dts: hisilicon: add support for USB3 on Hikey 970
dts: hisilicon: add support for the PMIC found on Hikey 970
.../mfd/hisilicon,hi6421-spmi-pmic.yaml | 135 +++++ .../spmi/hisilicon,hisi-spmi-controller.yaml | 75 +++ MAINTAINERS | 15 +- .../boot/dts/hisilicon/hi3670-hikey970.dts | 124 ++++- arch/arm64/boot/dts/hisilicon/hi3670.dtsi | 58 +++ .../boot/dts/hisilicon/hikey970-pmic.dtsi | 87 ++++ drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c | 342 +++++++++++++ drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/hi6421v600-regulator.c | 347 +++++++++++++ drivers/spmi/Kconfig | 9 + drivers/spmi/Makefile | 1 + drivers/spmi/hisi-spmi-controller.c | 358 +++++++++++++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/hikey9xx/Kconfig | 38 -- drivers/staging/hikey9xx/Makefile | 5 - drivers/staging/hikey9xx/TODO | 5 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 342 ------------- .../staging/hikey9xx/hi6421v600-regulator.c | 478 ------------------ .../staging/hikey9xx/hisi-spmi-controller.c | 358 ------------- .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 159 ------ .../hisilicon,hisi-spmi-controller.yaml | 62 --- 25 files changed, 1554 insertions(+), 1472 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml create mode 100644 Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml create mode 100644 arch/arm64/boot/dts/hisilicon/hikey970-pmic.dtsi create mode 100644 drivers/mfd/hi6421-spmi-pmic.c create mode 100644 drivers/regulator/hi6421v600-regulator.c create mode 100644 drivers/spmi/hisi-spmi-controller.c delete mode 100644 drivers/staging/hikey9xx/Kconfig delete mode 100644 drivers/staging/hikey9xx/Makefile delete mode 100644 drivers/staging/hikey9xx/TODO delete mode 100644 drivers/staging/hikey9xx/hi6421-spmi-pmic.c delete mode 100644 drivers/staging/hikey9xx/hi6421v600-regulator.c delete mode 100644 drivers/staging/hikey9xx/hisi-spmi-controller.c delete mode 100644 drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml delete mode 100644 drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
Signature · 8 lines
2.29.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mauro Carvalho Chehab
maintainerPATCH v2 1/13 staging: hikey9xx: hisilicon,hisi-spmi-controller.yaml fix bindings
Fix a few warnings produced by make dt_binding_check.
--- .../hisilicon,hisi-spmi-controller.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml +16 -3
@@ -26,14 +26,22 @@ properties: reg: maxItems: 1 + "#address-cells": + const: 2 + + "#size-cells": + const: 0 + spmi-channel: description: | number of the Kirin 970 SPMI channel where the SPMI devices are connected. required: - - compatible - - reg - - spmi-channel + - compatible + - reg + - spmi-channel + - "#address-cells" + - "#size-cells" patternProperties: "^pmic@[0-9a-f]$":
@@ -43,6 +51,8 @@ patternProperties: are documented at drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml. +additionalProperties: false + examples: - | bus {
@@ -51,11 +61,14 @@ examples: spmi: spmi@fff24000 { compatible = "hisilicon,kirin970-spmi-controller"; + #address-cells = <2>; + #size-cells = <0>; status = "ok"; reg = <0x0 0xfff24000 0x0 0x1000>; spmi-channel = <2>; pmic@0 { + reg = <0 0>; /* pmic properties */ }; };
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 2/13 staging: hikey9xx: hisi-spmi-controller: clean sparse warnings
In reply to Mauro Carvalho ChehabSparse complains about __be32 conversions:
drivers/spmi/hisi-spmi-controller.c drivers/spmi/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/spmi/hisi-spmi-controller.c drivers/spmi/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/spmi/hisi-spmi-controller.c drivers/spmi/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/spmi/hisi-spmi-controller.c drivers/spmi/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/spmi/hisi-spmi-controller.c drivers/spmi/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/spmi/hisi-spmi-controller.c drivers/spmi/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/spmi/hisi-spmi-controller.c drivers/spmi/hisi-spmi-controller.c:239:17: warning: cast from restricted __be32The conversions there are valid ones. So, add __force macro to disable such warnings.
--- drivers/staging/hikey9xx/hisi-spmi-controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/hikey9xx/hisi-spmi-controller.c +2 -2
@@ -161,7 +161,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,SPMI_SLAVE_OFFSET * slave_id +SPMI_APB_SPMI_RDATA0_BASE_ADDR + i * SPMI_PER_DATAREG_BYTE); - data =be32_to_cpu ((__be32 )data); + data =be32_to_cpu ((__force __be32 )data);if ((bc - i *SPMI_PER_DATAREG_BYTE ) >>2 ) {memcpy (buf, &data,sizeof (data)); buf +=sizeof (data);
@@ -236,7 +236,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, buf += (bc %SPMI_PER_DATAREG_BYTE ); } -writel ((u32 )cpu_to_be32 (data), +writel ((__force u32 )cpu_to_be32 (data), spmi_controller->base + chnl_ofst +SPMI_APB_SPMI_WDATA0_BASE_ADDR +SPMI_PER_DATAREG_BYTE * i);
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 3/13 staging: hikey9xx: hi6421v600-regulator: do some cleanups
In reply to Mauro Carvalho ChehabUse C99 comments at the beginning of the file and remove uneeded includes.
--- .../staging/hikey9xx/hi6421v600-regulator.c | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-)
drivers/staging/hikey9xx/hi6421v600-regulator.c +16 -27
@@ -1,41 +1,30 @@// SPDX-License-Identifier: GPL-2.0 -/* -* Device driver for regulators in Hisi IC -* -* Copyright (c) 2013 Linaro Ltd. -* Copyright (c) 2011 Hisilicon. -* -* Guodong Xu <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ +// +// Device driver for regulators in Hisi IC +// +// Copyright (c) 2013 Linaro Ltd. +// Copyright (c) 2011 Hisilicon. +// +// Guodong Xu <[email protected]> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. -#include <linux/delay.h> -#include <linux/device.h> -#include <linux/err.h> -#include <linux/io.h> #include <linux/mfd/hi6421-spmi-pmic.h> #include <linux/module.h> -#include <linux/of_address.h> -#include <linux/of_device.h> #include <linux/of.h> #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <linux/regulator/of_regulator.h> -#include <linux/seq_file.h> -#include <linux/slab.h> #include <linux/spmi.h> -#include <linux/time.h> -#include <linux/uaccess.h> #define rdev_dbg(rdev, fmt, arg...) \ pr_debug("%s: %s: " fmt, (rdev)->desc->name, __func__, ##arg)
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 4/13 staging: hikey9xx: hi6421v600-regulator: move LDO config from DT
In reply to Mauro Carvalho ChehabInstead of storing regulator LDO configuration inside the DT, move it to be part of the driver itself.
--- .../staging/hikey9xx/hi6421v600-regulator.c | 380 +++++++----------- 1 file changed, 152 insertions(+), 228 deletions(-)
drivers/staging/hikey9xx/hi6421v600-regulator.c +152 -228
@@ -16,35 +16,97 @@// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +#include <linux/delay.h> #include <linux/mfd/hi6421-spmi-pmic.h> #include <linux/module.h> -#include <linux/of.h> #include <linux/platform_device.h> -#include <linux/regmap.h> #include <linux/regulator/driver.h> -#include <linux/regulator/machine.h> -#include <linux/regulator/of_regulator.h> #include <linux/spmi.h> #define rdev_dbg(rdev, fmt, arg...) \ pr_debug("%s: %s: " fmt, (rdev)->desc->name, __func__, ##arg) -struct hi6421v600_regulator { -struct regulator_desc rdesc; +struct hi6421_spmi_reg_info { +struct regulator_desc desc;struct hi6421_spmi_pmic *pmic; -u32 eco_mode_mask, eco_uA; +u8 eco_mode_mask; +u32 eco_uA; };static DEFINE_MUTEX (enable_mutex); +static const unsigned int ldo3_voltages[] = { +1500000 ,1550000 ,1600000 ,1650000 , +1700000 ,1725000 ,1750000 ,1775000 , +1800000 ,1825000 ,1850000 ,1875000 , +1900000 ,1925000 ,1950000 ,2000000 +}; + +static const unsigned int ldo4_voltages[] = { +1725000 ,1750000 ,1775000 ,1800000 , +1825000 ,1850000 ,1875000 ,1900000 +}; + +static const unsigned int ldo9_voltages[] = { +1750000 ,1800000 ,1825000 ,2800000 , +2850000 ,2950000 ,3000000 ,3300000 +}; + +static const unsigned int ldo15_voltages[] = { +1800000 ,1850000 ,2400000 ,2600000 , +2700000 ,2850000 ,2950000 ,3000000 +}; + +static const unsigned int ldo17_voltages[] = { +2500000 ,2600000 ,2700000 ,2800000 , +3000000 ,3100000 ,3200000 ,3300000 +}; + +static const unsigned int ldo34_voltages[] = { +2600000 ,2700000 ,2800000 ,2900000 , +3000000 ,3100000 ,3200000 ,3300000 +}; +/* -* helper function to ensure when it returns it is at least 'delay_us' -* microseconds after 'since'. +* _id - LDO id name string +* _match - of match name string +* v_table - voltage table +* vreg - voltage select register +* vmask - voltage select mask +* ereg - enable register +* emask - enable mask +* odelay - off/on delay time in uS +* ecomask - eco mode mask +* ecoamp - eco mode load uppler limit in uA */ +#define HI6421V600_LDO (_id, vtable, ereg, emask, vreg, \ + odelay, etime, ecomask, ecoamp) \ + [HI6421V600_##_id] = { \ + .desc = { \ + .name = #_id, \ + .of_match = of_match_ptr(#_id), \ + .regulators_node = of_match_ptr("regulators"), \ + .ops = &hi6421_spmi_ldo_rops, \ + .type = REGULATOR_VOLTAGE, \ + .id = HI6421V600_##_id, \ + .owner = THIS_MODULE, \ + .volt_table = vtable, \ + .n_voltages = ARRAY_SIZE(vtable), \ + .vsel_mask = (1 << (ARRAY_SIZE(vtable) - 1)) - 1, \ + .vsel_reg = vreg, \ + .enable_reg = ereg, \ + .enable_mask = emask, \ + .enable_time = etime, \ + .ramp_delay = etime, \ + .off_on_delay = odelay, \ + }, \ + .eco_mode_mask = ecomask, \ + .eco_uA = ecoamp, \ + }static int hi6421_spmi_regulator_is_enabled (struct regulator_dev *rdev) { -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); +struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic;u32 reg_val;
@@ -60,7 +122,7 @@ static int hi6421_spmi_regulator_is_enabled(struct regulator_dev *rdev)static int hi6421_spmi_regulator_enable (struct regulator_dev *rdev) { -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); +struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic;/* cannot enable more than one regulator at one time */
@@ -85,7 +147,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)static int hi6421_spmi_regulator_disable (struct regulator_dev *rdev) { -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); +struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic;/* set enable register to 0 */
@@ -100,7 +162,7 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev)static int hi6421_spmi_regulator_get_voltage_sel (struct regulator_dev *rdev) { -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); +struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic;u32 reg_val, selector;
@@ -120,7 +182,7 @@ static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev)static int hi6421_spmi_regulator_set_voltage_sel (struct regulator_dev *rdev,unsigned int selector) { -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); +struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic;u32 reg_val;
@@ -143,7 +205,7 @@ static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev,static unsigned int hi6421_spmi_regulator_get_mode (struct regulator_dev *rdev) { -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); +struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic;unsigned int mode;u32 reg_val;
@@ -166,7 +228,7 @@ static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev)static int hi6421_spmi_regulator_set_mode (struct regulator_dev *rdev,unsigned int mode) { -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); +struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic;u32 val;
@@ -196,7 +258,7 @@ hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev, int input_uV, int output_uV, int load_uA) { - struct hi6421v600_regulator *sreg = rdev_get_drvdata(rdev); + struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);if (load_uA || ((unsigned int )load_uA > sreg->eco_uA))return REGULATOR_MODE_NORMAL ;
@@ -204,99 +266,6 @@ hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev,return REGULATOR_MODE_IDLE ; } -static int hi6421_spmi_dt_parse (struct platform_device *pdev, -struct hi6421v600_regulator *sreg, -struct regulator_desc *rdesc) -{ -struct device *dev = &pdev->dev; -struct device_node *np = dev->of_node; -unsigned int *v_table; -int ret; - - ret =of_property_read_u32 (np,"reg" , &rdesc->enable_reg); -if (ret) { -dev_err (dev,"missing reg property\n" ); -return ret; - } - - ret =of_property_read_u32 (np,"vsel-reg" , &rdesc->vsel_reg); -if (ret) { -dev_err (dev,"missing vsel-reg property\n" ); -return ret; - } - - ret =of_property_read_u32 (np,"enable-mask" , &rdesc->enable_mask); -if (ret) { -dev_err (dev,"missing enable-mask property\n" ); -return ret; - } - -/* -* Not all regulators work on idle mode -*/ - ret =of_property_read_u32 (np,"idle-mode-mask" , &sreg->eco_mode_mask); -if (ret) { -dev_dbg (dev,"LDO doesn't support economy mode.\n" ); - sreg->eco_mode_mask =0 ; - sreg->eco_uA =0 ; - }else { - ret =of_property_read_u32 (np,"eco-microamp" , &sreg->eco_uA); -if (ret) { -dev_err (dev,"missing eco-microamp property\n" ); -return ret; - } - } - -/* parse .off-on-delay */ - ret =of_property_read_u32 (np,"off-on-delay-us" , - &rdesc->off_on_delay); -if (ret) { -dev_err (dev,"missing off-on-delay-us property\n" ); -return ret; - } - -/* parse .enable_time */ - ret =of_property_read_u32 (np,"startup-delay-us" , - &rdesc->enable_time); -if (ret) { -dev_err (dev,"missing startup-delay-us property\n" ); -return ret; - } - -/* FIXME: are there a better value for this? */ - rdesc->ramp_delay = rdesc->enable_time; - -/* parse volt_table */ - - rdesc->n_voltages =of_property_count_u32_elems (np,"voltage-table" ); - - v_table =devm_kzalloc (dev,sizeof (unsigned int ) * rdesc->n_voltages, -GFP_KERNEL ); -if (unlikely (!v_table)) -return -ENOMEM ; - rdesc->volt_table = v_table; - - ret =of_property_read_u32_array (np,"voltage-table" , - v_table, rdesc->n_voltages); -if (ret) { -dev_err (dev,"missing voltage-table property\n" ); -return ret; - } - -/* -* Instead of explicitly requiring a mask for the voltage selector, -* as they all start from bit zero (at least on the known LDOs), -* just use the number of voltages at the voltage table, getting the -* minimal mask that would pick everything. -*/ - rdesc->vsel_mask = (1 << (fls (rdesc->n_voltages) -1 )) -1 ; - -dev_dbg (dev,"voltage selector settings: reg: 0x%x, mask: 0x%x\n" , - rdesc->vsel_reg, rdesc->vsel_mask); - -return 0 ; -} -static const struct regulator_ops hi6421_spmi_ldo_rops = { .is_enabled = hi6421_spmi_regulator_is_enabled, .enable = hi6421_spmi_regulator_enable,
@@ -310,85 +279,63 @@ static const struct regulator_ops hi6421_spmi_ldo_rops = { .get_optimum_mode = hi6421_spmi_regulator_get_optimum_mode, }; -static int hi6421_spmi_regulator_probe_ldo (struct platform_device *pdev, -struct device_node *np, -struct hi6421_spmi_pmic *pmic) -{ -struct regulation_constraints *constraint; -struct regulator_init_data *initdata; -struct regulator_config config = { }; -struct hi6421v600_regulator *sreg; -struct device *dev = &pdev->dev; -struct regulator_desc *rdesc; -struct regulator_dev *rdev; -const char *supplyname; -int ret; - - initdata =of_get_regulator_init_data (dev, np,NULL ); -if (!initdata) { -dev_err (dev,"failed to get regulator data\n" ); -return -EINVAL ; - } - - sreg =devm_kzalloc (dev,sizeof (*sreg),GFP_KERNEL ); -if (!sreg) -return -ENOMEM ; - - sreg->pmic = pmic; - rdesc = &sreg->rdesc; - - rdesc->name = initdata->constraints.name; - rdesc->ops = &hi6421_spmi_ldo_rops; - rdesc->type =REGULATOR_VOLTAGE ; - rdesc->min_uV = initdata->constraints.min_uV; - - supplyname =of_get_property (np,"supply_name" ,NULL ); -if (supplyname) - initdata->supply_regulator = supplyname; - -/* parse device tree data for regulator specific */ - ret =hi6421_spmi_dt_parse (pdev, sreg, rdesc); -if (ret) -return ret; - -/* hisi regulator supports two modes */ - constraint = &initdata->constraints; - - constraint->valid_modes_mask =REGULATOR_MODE_NORMAL ; -if (sreg->eco_mode_mask) { - constraint->valid_modes_mask |=REGULATOR_MODE_IDLE ; - constraint->valid_ops_mask |=REGULATOR_CHANGE_MODE ; - } - - config.dev = &pdev->dev; - config.init_data = initdata; - config.driver_data = sreg; - config.of_node = pdev->dev.of_node; - -/* register regulator */ - rdev =regulator_register (rdesc, &config); -if (IS_ERR (rdev)) { -dev_err (dev,"failed to register %s\n" , - rdesc->name); -return PTR_ERR (rdev); - } - -rdev_dbg (rdev,"valid_modes_mask: 0x%x, valid_ops_mask: 0x%x\n" , - constraint->valid_modes_mask, constraint->valid_ops_mask); - -dev_set_drvdata (dev, rdev); - -return 0 ; -} +/* HI6421v600 regulators with known registers */ +enum hi6421_spmi_regulator_id { +HI6421V600_LDO3 , +HI6421V600_LDO4 , +HI6421V600_LDO9 , +HI6421V600_LDO15 , +HI6421V600_LDO16 , +HI6421V600_LDO17 , +HI6421V600_LDO33 , +HI6421V600_LDO34 , +}; + +static struct hi6421_spmi_reg_info regulator_info[] = { +HI6421V600_LDO (LDO3 , ldo3_voltages, +0x16 ,0x01 ,0x51 , +20000 ,120 , +0 ,0 ), +HI6421V600_LDO (LDO4 , ldo4_voltages, +0x17 ,0x01 ,0x52 , +20000 ,120 , +0x10 ,10000 ), +HI6421V600_LDO (LDO9 , ldo9_voltages, +0x1c ,0x01 ,0x57 , +20000 ,360 , +0x10 ,10000 ), +HI6421V600_LDO (LDO15 , ldo15_voltages, +0x21 ,0x01 ,0x5c , +20000 ,360 , +0x10 ,10000 ), +HI6421V600_LDO (LDO16 , ldo15_voltages, +0x22 ,0x01 ,0x5d , +20000 ,360 , +0x10 ,10000 ), +HI6421V600_LDO (LDO17 , ldo17_voltages, +0x23 ,0x01 ,0x5e , +20000 ,120 , +0x10 ,10000 ), +HI6421V600_LDO (LDO33 , ldo17_voltages, +0x32 ,0x01 ,0x6d , +20000 ,120 , +0 ,0 ), +HI6421V600_LDO (LDO34 , ldo34_voltages, +0x33 ,0x01 ,0x6e , +20000 ,120 , +0 ,0 ), +};static int hi6421_spmi_regulator_probe (struct platform_device *pdev) {struct device *pmic_dev = pdev->dev.parent; -struct device_node *np = pmic_dev->of_node; -struct device_node *regulators, *child; -struct platform_device *new_pdev; +struct regulator_config config = { }; +struct hi6421_spmi_reg_info *sreg; +struct hi6421_spmi_reg_info *info; +struct device *dev = &pdev->dev;struct hi6421_spmi_pmic *pmic; -int ret; +struct regulator_dev *rdev; +int i;/* * This driver is meant to be called by hi6421-spmi-core,
@@ -399,68 +346,45 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)if (WARN_ON (!pmic))return -ENODEV ; - regulators =of_get_child_by_name (np,"regulators" ); -if (!regulators) { -dev_err (&pdev->dev,"regulator node not found\n" ); -return -ENODEV ; - } + sreg =devm_kzalloc (dev,sizeof (*sreg),GFP_KERNEL ); +if (!sreg) +return -ENOMEM ; -/* -* Parse all LDO regulator nodes -*/ -for_each_child_of_node (regulators, child) { -dev_dbg (&pdev->dev,"adding child %pOF\n" , child); + sreg->pmic = pmic; - new_pdev =platform_device_alloc (child->name,-1 ); - new_pdev->dev.parent = pmic_dev; - new_pdev->dev.of_node =of_node_get (child); +for (i =0 ; i <ARRAY_SIZE (regulator_info); i++) { +/* assign per-regulator data */ + info = ®ulator_info[i]; - ret =platform_device_add (new_pdev); -if (ret <0 ) { -platform_device_put (new_pdev); -continue ; +dev_dbg (dev,"adding regulator %s\n" , info->desc.name); + + config.dev = pdev->dev.parent; + config.driver_data = sreg; + + rdev =devm_regulator_register (dev, &info->desc, &config); +if (IS_ERR (rdev)) { +dev_err (dev,"failed to register %s\n" , sreg->desc.name); +return PTR_ERR (rdev); } - - ret =hi6421_spmi_regulator_probe_ldo (new_pdev, child, pmic); -if (ret <0 ) -platform_device_put (new_pdev); } -of_node_put (regulators); - -return 0 ; -} - -static int hi6421_spmi_regulator_remove (struct platform_device *pdev) -{ -struct regulator_dev *rdev =dev_get_drvdata (&pdev->dev); -struct hi6421v600_regulator *sreg =rdev_get_drvdata (rdev); - -regulator_unregister (rdev); - -if (rdev->desc->volt_table) -devm_kfree (&pdev->dev, (unsigned int *)rdev->desc->volt_table); - -kfree (sreg); -return 0 ; } -static const struct platform_device_id hi6421v600_regulator_table[] = { +static const struct platform_device_id hi6421_spmi_regulator_table[] = { { .name ="hi6421v600-regulator" }, {}, }; -MODULE_DEVICE_TABLE (platform, hi6421v600_regulator_table); +MODULE_DEVICE_TABLE (platform, hi6421_spmi_regulator_table); -static struct platform_driver hi6421v600_regulator_driver = { - .id_table = hi6421v600_regulator_table, +static struct platform_driver hi6421_spmi_regulator_driver = { + .id_table = hi6421_spmi_regulator_table, .driver = { .name ="hi6421v600-regulator" , }, .probe = hi6421_spmi_regulator_probe, - .remove = hi6421_spmi_regulator_remove, }; -module_platform_driver (hi6421v600_regulator_driver); +module_platform_driver (hi6421_spmi_regulator_driver);MODULE_DESCRIPTION ("Hi6421v600 regulator driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 5/13 staging: hikey9xx: hi6421v600-regulator: cleanup debug msgs
In reply to Mauro Carvalho ChehabWhile those were useful during port time from downstream version, let's get rid of them for good, as it is possible to get about the same things by enabling regulator debugging code.
--- .../staging/hikey9xx/hi6421v600-regulator.c | 47 ++----------------- 1 file changed, 4 insertions(+), 43 deletions(-)
drivers/staging/hikey9xx/hi6421v600-regulator.c +4 -43
@@ -23,9 +23,6 @@#include <linux/regulator/driver.h> #include <linux/spmi.h> -#define rdev_dbg(rdev, fmt, arg...) \ - pr_debug("%s: %s: " fmt, (rdev)->desc->name, __func__, ##arg) -struct hi6421_spmi_reg_info {struct regulator_desc desc;struct hi6421_spmi_pmic *pmic;
@@ -112,11 +109,6 @@ static int hi6421_spmi_regulator_is_enabled(struct regulator_dev *rdev) reg_val =hi6421_spmi_pmic_read (pmic, rdev->desc->enable_reg); -rdev_dbg (rdev, -"enable_reg=0x%x, val= 0x%x, enable_state=%d\n" , - rdev->desc->enable_reg, - reg_val, (reg_val & rdev->desc->enable_mask)); -return ((reg_val & rdev->desc->enable_mask) !=0 ); }
@@ -131,11 +123,6 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) HISI_REGS_ENA_PROTECT_TIME + 1000);/* set enable register */ -rdev_dbg (rdev, -"off_on_delay=%d us, enable_reg=0x%x, enable_mask=0x%x\n" , - rdev->desc->off_on_delay, rdev->desc->enable_reg, - rdev->desc->enable_mask); -hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, rdev->desc->enable_mask, rdev->desc->enable_mask);
@@ -151,9 +138,6 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev)struct hi6421_spmi_pmic *pmic = sreg->pmic;/* set enable register to 0 */ -rdev_dbg (rdev,"enable_reg=0x%x, enable_mask=0x%x\n" , - rdev->desc->enable_reg, rdev->desc->enable_mask); -hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, rdev->desc->enable_mask,0 );
@@ -164,19 +148,12 @@ static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev) {struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic; -u32 reg_val, selector; +u32 reg_val;/* get voltage selector */ reg_val =hi6421_spmi_pmic_read (pmic, rdev->desc->vsel_reg); - selector = (reg_val & rdev->desc->vsel_mask) >> (ffs (rdev->desc->vsel_mask) -1 ); - -rdev_dbg (rdev, -"vsel_reg=0x%x, value=0x%x, entry=0x%x, voltage=%d mV\n" , - rdev->desc->vsel_reg, reg_val, selector, - rdev->desc->ops->list_voltage (rdev, selector) /1000 ); - -return selector; +return (reg_val & rdev->desc->vsel_mask) >> (ffs (rdev->desc->vsel_mask) -1 ); } static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev,
@@ -192,11 +169,6 @@ static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev, reg_val = selector << (ffs (rdev->desc->vsel_mask) -1 );/* set voltage selector */ -rdev_dbg (rdev, -"vsel_reg=0x%x, mask=0x%x, value=0x%x, voltage=%d mV\n" , - rdev->desc->vsel_reg, rdev->desc->vsel_mask, reg_val, - rdev->desc->ops->list_voltage (rdev, selector) /1000 ); -hi6421_spmi_pmic_rmw (pmic, rdev->desc->vsel_reg, rdev->desc->vsel_mask, reg_val);
@@ -207,22 +179,14 @@ static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev) {struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic; -unsigned int mode;u32 reg_val; reg_val =hi6421_spmi_pmic_read (pmic, rdev->desc->enable_reg);if (reg_val & sreg->eco_mode_mask) - mode =REGULATOR_MODE_IDLE ; -else - mode =REGULATOR_MODE_NORMAL ; +return REGULATOR_MODE_IDLE ; -rdev_dbg (rdev, -"enable_reg=0x%x, eco_mode_mask=0x%x, reg_val=0x%x, %s mode\n" , - rdev->desc->enable_reg, sreg->eco_mode_mask, reg_val, - mode ==REGULATOR_MODE_IDLE ?"idle" :"normal" ); - -return mode; +return REGULATOR_MODE_NORMAL ; } static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev,
@@ -244,9 +208,6 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev, }/* set mode */ -rdev_dbg (rdev,"enable_reg=0x%x, eco_mode_mask=0x%x, value=0x%x\n" , - rdev->desc->enable_reg, sreg->eco_mode_mask, val); -hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, sreg->eco_mode_mask, val);
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 6/13 staging: hikey9xx: hisilicon,hi6421-spmi-pmic.yaml: simplify props
In reply to Mauro Carvalho ChehabAs all regulator-specific properties got moved to be part of the driver, remove them from the DT spec.
--- .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 106 +++++++----------- 1 file changed, 40 insertions(+), 66 deletions(-)
drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +40 -66
@@ -55,47 +55,6 @@ properties: $ref: "/schemas/regulator/regulator.yaml#" - properties: - reg: - description: Enable register. - - '#address-cells': - const: 1 - - '#size-cells': - const: 0 - - vsel-reg: - description: Voltage selector register. - - enable-mask: - description: Bitmask used to enable the regulator. - - voltage-table: - description: Table with the selector items for the voltage regulator. - minItems: 2 - maxItems: 16 - - off-on-delay-us: - description: Time required for changing state to enabled in microseconds. - - startup-delay-us: - description: Startup time in microseconds. - - idle-mode-mask: - description: Bitmask used to put the regulator on idle mode. - - eco-microamp: - description: Maximum current while on idle mode. - - required: - - reg - - vsel-reg - - enable-mask - - voltage-table - - off-on-delay-us - - startup-delay-us - required: - compatible - reg
@@ -117,43 +76,58 @@ examples: #address-cells = <1>; #size-cells = <0>; - ldo3: ldo3@16 { - reg = <0x16>; - vsel-reg = <0x51>; - + ldo3: LDO3 { regulator-name = "ldo3"; regulator-min-microvolt = <1500000>; regulator-max-microvolt = <2000000>; regulator-boot-on; - - enable-mask = <0x01>; - - voltage-table = <1500000>, <1550000>, <1600000>, <1650000>, - <1700000>, <1725000>, <1750000>, <1775000>, - <1800000>, <1825000>, <1850000>, <1875000>, - <1900000>, <1925000>, <1950000>, <2000000>; - off-on-delay-us = <20000>; - startup-delay-us = <120>; }; - ldo4: ldo4@17 { /* 40 PIN */ - reg = <0x17>; - vsel-reg = <0x52>; - + ldo4: LDO4 { regulator-name = "ldo4"; regulator-min-microvolt = <1725000>; regulator-max-microvolt = <1900000>; regulator-boot-on; + }; - enable-mask = <0x01>; - idle-mode-mask = <0x10>; - eco-microamp = <10000>; + ldo9: LDO9 { + regulator-name = "ldo9"; + regulator-min-microvolt = <1750000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + }; - hi6421-vsel = <0x52 0x07>; - voltage-table = <1725000>, <1750000>, <1775000>, <1800000>, - <1825000>, <1850000>, <1875000>, <1900000>; - off-on-delay-us = <20000>; - startup-delay-us = <120>; + ldo15: LDO15 { + regulator-name = "ldo15"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + }; + + ldo16: LDO16 { + regulator-name = "ldo16"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-boot-on; + }; + + ldo17: LDO17 { + regulator-name = "ldo17"; + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <3300000>; + }; + + ldo33: LDO33 { + regulator-name = "ldo33"; + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + }; + + ldo34: LDO34 { + regulator-name = "ldo34"; + regulator-min-microvolt = <2600000>; + regulator-max-microvolt = <3300000>; }; }; };
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 7/13 staging: hikey970: get rid of an static data
In reply to Mauro Carvalho ChehabMove it to be inside the private data struct.
--- drivers/staging/hikey9xx/hi6421v600-regulator.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/hikey9xx/hi6421v600-regulator.c +6 -4
@@ -28,9 +28,10 @@ struct hi6421_spmi_reg_info {struct hi6421_spmi_pmic *pmic;u8 eco_mode_mask;u32 eco_uA; -}; -static DEFINE_MUTEX (enable_mutex); +/* Serialize regulator enable logic */ +struct mutex enable_mutex; +};static const unsigned int ldo3_voltages[] = {1500000 ,1550000 ,1600000 ,1650000 ,
@@ -118,7 +119,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)struct hi6421_spmi_pmic *pmic = sreg->pmic;/* cannot enable more than one regulator at one time */ -mutex_lock (&enable_mutex); +mutex_lock (&sreg->enable_mutex);usleep_range (HISI_REGS_ENA_PROTECT_TIME ,HISI_REGS_ENA_PROTECT_TIME +1000 );
@@ -127,7 +128,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) rdev->desc->enable_mask, rdev->desc->enable_mask); -mutex_unlock (&enable_mutex); +mutex_unlock (&sreg->enable_mutex);return 0 ; }
@@ -312,6 +313,7 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)return -ENOMEM ; sreg->pmic = pmic; +mutex_init (&sreg->enable_mutex);for (i =0 ; i <ARRAY_SIZE (regulator_info); i++) {/* assign per-regulator data */
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 8/13 staging: hikey9xx: hi6421v600-regulator: do some cleanups
In reply to Mauro Carvalho ChehabIn preparation for de-staging, do some cleanups:
- Return error codes from hi6421_spmi_pmic_rmw();
- Remove a debug message;
- Change the module description;
- a few minor coding style adjustments.
--- .../staging/hikey9xx/hi6421v600-regulator.c | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-)
drivers/staging/hikey9xx/hi6421v600-regulator.c +14 -21
@@ -117,6 +117,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) {struct hi6421_spmi_reg_info *sreg =rdev_get_drvdata (rdev);struct hi6421_spmi_pmic *pmic = sreg->pmic; +int ret;/* cannot enable more than one regulator at one time */ mutex_lock (&sreg->enable_mutex);
@@ -124,13 +125,13 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) HISI_REGS_ENA_PROTECT_TIME + 1000);/* set enable register */ -hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, - rdev->desc->enable_mask, - rdev->desc->enable_mask); + ret =hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, + rdev->desc->enable_mask, + rdev->desc->enable_mask);mutex_unlock (&sreg->enable_mutex); -return 0 ; +return ret; }static int hi6421_spmi_regulator_disable (struct regulator_dev *rdev)
@@ -139,10 +140,8 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev)struct hi6421_spmi_pmic *pmic = sreg->pmic;/* set enable register to 0 */ -hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, - rdev->desc->enable_mask,0 ); - -return 0 ; +return hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, + rdev->desc->enable_mask,0 ); }static int hi6421_spmi_regulator_get_voltage_sel (struct regulator_dev *rdev)
@@ -154,7 +153,7 @@ static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev)/* get voltage selector */ reg_val =hi6421_spmi_pmic_read (pmic, rdev->desc->vsel_reg); -return (reg_val & rdev->desc->vsel_mask) >> (ffs (rdev->desc->vsel_mask) -1 ); +return (reg_val & rdev->desc->vsel_mask) >> (ffs (rdev->desc->vsel_mask) -1 ); } static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev,
@@ -170,10 +169,8 @@ static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev, reg_val = selector << (ffs (rdev->desc->vsel_mask) -1 );/* set voltage selector */ -hi6421_spmi_pmic_rmw (pmic, rdev->desc->vsel_reg, - rdev->desc->vsel_mask, reg_val); - -return 0 ; +return hi6421_spmi_pmic_rmw (pmic, rdev->desc->vsel_reg, + rdev->desc->vsel_mask, reg_val); }static unsigned int hi6421_spmi_regulator_get_mode (struct regulator_dev *rdev)
@@ -209,10 +206,8 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev, }/* set mode */ -hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, - sreg->eco_mode_mask, val); - -return 0 ; +return hi6421_spmi_pmic_rmw (pmic, rdev->desc->enable_reg, + sreg->eco_mode_mask, val); } static unsigned int
@@ -319,8 +314,6 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev)/* assign per-regulator data */ info = ®ulator_info[i]; -dev_dbg (dev,"adding regulator %s\n" , info->desc.name); - config.dev = pdev->dev.parent; config.driver_data = sreg;
@@ -343,12 +336,12 @@ MODULE_DEVICE_TABLE(platform, hi6421_spmi_regulator_table);static struct platform_driver hi6421_spmi_regulator_driver = { .id_table = hi6421_spmi_regulator_table, .driver = { - .name ="hi6421v600-regulator" , + .name ="hi6421v600-regulator" , }, .probe = hi6421_spmi_regulator_probe, };module_platform_driver (hi6421_spmi_regulator_driver); -MODULE_DESCRIPTION ("Hi6421v600 regulator driver" ); +MODULE_DESCRIPTION ("Hi6421v600 SPMI regulator driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 9/13 spmi: hi6421-spmi-pmic: move driver from staging
In reply to Mauro Carvalho ChehabThe Hisilicon 6421v600 SPMI driver is ready for mainstream.
So, move it from staging.
--- .../spmi/hisilicon,hisi-spmi-controller.yaml | 75 ++++ MAINTAINERS | 7 + drivers/spmi/Kconfig | 9 + drivers/spmi/Makefile | 1 + drivers/spmi/hisi-spmi-controller.c | 358 ++++++++++++++++++ drivers/staging/hikey9xx/Kconfig | 11 - drivers/staging/hikey9xx/Makefile | 1 - .../staging/hikey9xx/hisi-spmi-controller.c | 358 ------------------ .../hisilicon,hisi-spmi-controller.yaml | 75 ---- 9 files changed, 450 insertions(+), 445 deletions(-) create mode 100644 Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml create mode 100644 drivers/spmi/hisi-spmi-controller.c delete mode 100644 drivers/staging/hikey9xx/hisi-spmi-controller.c delete mode 100644 drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml new file +75 -0
@@ -0,0 +1,75 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/spmi/hisilicon,hisi-spmi-controller.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HiSilicon SPMI controller + +maintainers: + - Mauro Carvalho Chehab <[email protected]> + +description: | + The HiSilicon SPMI BUS controller is found on some Kirin-based designs. + It is a MIPI System Power Management (SPMI) controller. + + The PMIC part is provided by + drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml. + +properties: + $nodename: + pattern: "spmi@[0-9a-f]" + + compatible: + const: hisilicon,kirin970-spmi-controller + + reg: + maxItems: 1 + + "#address-cells": + const: 2 + + "#size-cells": + const: 0 + + spmi-channel: + description: | + number of the Kirin 970 SPMI channel where the SPMI devices are connected. + +required: + - compatible + - reg + - spmi-channel + - "#address-cells" + - "#size-cells" + +patternProperties: + "^pmic@[0-9a-f]$": + description: | + PMIC properties, which are specific to the used SPMI PMIC device(s). + When used in combination with HiSilicon 6421v600, the properties + are documented at + drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml. + +additionalProperties: false + +examples: + - | + bus { + #address-cells = <2>; + #size-cells = <2>; + + spmi: spmi@fff24000 { + compatible = "hisilicon,kirin970-spmi-controller"; + #address-cells = <2>; + #size-cells = <0>; + status = "ok"; + reg = <0x0 0xfff24000 0x0 0x1000>; + spmi-channel = <2>; + + pmic@0 { + reg = <0 0>; + /* pmic properties */ + }; + }; + };
MAINTAINERS +7 -0
@@ -7999,6 +7999,13 @@ F: drivers/crypto/hisilicon/sec2/sec_crypto.c F: drivers/crypto/hisilicon/sec2/sec_crypto.h F: drivers/crypto/hisilicon/sec2/sec_main.c +HISILICON SPMI CONTROLLER DRIVER FOR HIKEY 970 +M: Mauro Carvalho Chehab <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml +F: drivers/spmi/hisi-spmi-controller.c + HISILICON STAGING DRIVERS FOR HIKEY 960/970 M: Mauro Carvalho Chehab <[email protected]> L: [email protected]
drivers/spmi/Kconfig +9 -0
@@ -11,6 +11,15 @@ menuconfig SPMI if SPMI +config SPMI_HISI3670 + tristate "Hisilicon 3670 SPMI Controller" + select IRQ_DOMAIN_HIERARCHY + depends on HAS_IOMEM + help + If you say yes to this option, support will be included for the + built-in SPMI PMIC Arbiter interface on Hisilicon 3670 + processors. + config SPMI_MSM_PMIC_ARB tristate "Qualcomm MSM SPMI Controller (PMIC Arbiter)" select IRQ_DOMAIN_HIERARCHY
drivers/spmi/Makefile +1 -0
@@ -4,4 +4,5 @@ # obj-$(CONFIG_SPMI) += spmi.o +obj-$(CONFIG_SPMI_HISI3670) += hisi-spmi-controller.o obj-$(CONFIG_SPMI_MSM_PMIC_ARB) += spmi-pmic-arb.o
drivers/spmi/hisi-spmi-controller.c new file +358 -0
358 lines not on this page · raw message
drivers/staging/hikey9xx/Kconfig +0 -11
@@ -1,16 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -# to be placed at drivers/spmi -config SPMI_HISI3670 - tristate "Hisilicon 3670 SPMI Controller" - select IRQ_DOMAIN_HIERARCHY - depends on HAS_IOMEM - depends on SPMI - help - If you say yes to this option, support will be included for the - built-in SPMI PMIC Arbiter interface on Hisilicon 3670 - processors. - # to be placed at drivers/mfd config MFD_HI6421_SPMI tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC"
drivers/staging/hikey9xx/Makefile +0 -1
@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_SPMI_HISI3670) += hisi-spmi-controller.o obj-$(CONFIG_MFD_HI6421_SPMI) += hi6421-spmi-pmic.o obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
drivers/staging/hikey9xx/hisi-spmi-controller.c deleted +0 -358
358 lines not on this page · raw message
drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml deleted +0 -75
75 lines not on this page · raw message
Signature · 1 line
2.29.2
Mauro Carvalho Chehab
maintainerPATCH v2 10/13 mfd: hi6421-spmi-pmic: move driver from staging
In reply to Mauro Carvalho ChehabThis driver is ready for mainstream. So, move it out of staging.
--- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 133 +++++++ MAINTAINERS | 7 + drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c | 342 ++++++++++++++++++ drivers/staging/hikey9xx/Kconfig | 16 - drivers/staging/hikey9xx/Makefile | 1 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 342 ------------------ .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 133 ------- 9 files changed, 498 insertions(+), 492 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml create mode 100644 drivers/mfd/hi6421-spmi-pmic.c delete mode 100644 drivers/staging/hikey9xx/hi6421-spmi-pmic.c delete mode 100644 drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml new file +133 -0
@@ -0,0 +1,133 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/hisilicon,hi6421-spmi-pmic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HiSilicon 6421v600 SPMI PMIC + +maintainers: + - Mauro Carvalho Chehab <[email protected]> + +description: | + HiSilicon 6421v600 should be connected inside a MIPI System Power Management + (SPMI) bus. It provides interrupts and power supply. + + The GPIO and interrupt settings are represented as part of the top-level PMIC + node. + + The SPMI controller part is provided by + drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml. + +properties: + $nodename: + pattern: "pmic@[0-9a-f]" + + compatible: + const: hisilicon,hi6421v600-spmi + + reg: + maxItems: 1 + + '#interrupt-cells': + const: 2 + + interrupt-controller: + description: + Identify that the PMIC is capable of behaving as an interrupt controller. + + gpios: + maxItems: 1 + + regulators: + type: object + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^ldo[0-9]+@[0-9a-f]$': + type: object + + $ref: "/schemas/regulator/regulator.yaml#" + +required: + - compatible + - reg + - regulators + +examples: + - | + /* pmic properties */ + + pmic: pmic@0 { + compatible = "hisilicon,hi6421-spmi"; + reg = <0 0>; + + #interrupt-cells = <2>; + interrupt-controller; + gpios = <&gpio28 0 0>; + + regulators { + #address-cells = <1>; + #size-cells = <0>; + + ldo3: LDO3 { + regulator-name = "ldo3"; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <2000000>; + regulator-boot-on; + }; + + ldo4: LDO4 { + regulator-name = "ldo4"; + regulator-min-microvolt = <1725000>; + regulator-max-microvolt = <1900000>; + regulator-boot-on; + }; + + ldo9: LDO9 { + regulator-name = "ldo9"; + regulator-min-microvolt = <1750000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + }; + + ldo15: LDO15 { + regulator-name = "ldo15"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + }; + + ldo16: LDO16 { + regulator-name = "ldo16"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-boot-on; + }; + + ldo17: LDO17 { + regulator-name = "ldo17"; + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <3300000>; + }; + + ldo33: LDO33 { + regulator-name = "ldo33"; + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + }; + + ldo34: LDO34 { + regulator-name = "ldo34"; + regulator-min-microvolt = <2600000>; + regulator-max-microvolt = <3300000>; + }; + }; + };
MAINTAINERS +7 -0
@@ -8006,6 +8006,13 @@ S: Maintained F: Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml F: drivers/spmi/hisi-spmi-controller.c +HISILICON SPMI PMIC DRIVER FOR HIKEY 6421v600 +M: Mauro Carvalho Chehab <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +F: drivers/mfd/hi6421-spmi-pmic.c + HISILICON STAGING DRIVERS FOR HIKEY 960/970 M: Mauro Carvalho Chehab <[email protected]> L: [email protected]
drivers/mfd/Kconfig +15 -0
@@ -509,6 +509,21 @@ config MFD_HI6421_PMIC menus in order to enable them. We communicate with the Hi6421 via memory-mapped I/O. +config MFD_HI6421_SPMI + tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC" + depends on OF + depends on SPMI + select MFD_CORE + help + Add support for HiSilicon Hi6421v600 SPMI PMIC. Hi6421 includes + multi-functions, such as regulators, RTC, codec, Coulomb counter, + etc. + + This driver includes core APIs _only_. You have to select + individual components like voltage regulators under corresponding + menus in order to enable them. + We communicate with the Hi6421v600 via a SPMI bus. + config MFD_HI655X_PMIC tristate "HiSilicon Hi655X series PMU/Codec IC" depends on ARCH_HISI || COMPILE_TEST
drivers/mfd/Makefile +1 -0
@@ -233,6 +233,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o obj-$(CONFIG_MFD_IQS62X) += iqs62x.o obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o +obj-$(CONFIG_MFD_HI6421_SPMI) += hi6421-spmi-pmic.o obj-$(CONFIG_MFD_HI655X_PMIC) += hi655x-pmic.o obj-$(CONFIG_MFD_DLN2) += dln2.o obj-$(CONFIG_MFD_RT5033) += rt5033.o
drivers/mfd/hi6421-spmi-pmic.c new file +342 -0
342 lines not on this page · raw message
drivers/staging/hikey9xx/Kconfig +0 -16
@@ -1,21 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -# to be placed at drivers/mfd -config MFD_HI6421_SPMI - tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC" - depends on OF - depends on SPMI - select MFD_CORE - help - Add support for HiSilicon Hi6421v600 SPMI PMIC. Hi6421 includes - multi-functions, such as regulators, RTC, codec, Coulomb counter, - etc. - - This driver includes core APIs _only_. You have to select - individual components like voltage regulators under corresponding - menus in order to enable them. - We communicate with the Hi6421v600 via a SPMI bus. - # to be placed at drivers/regulator config REGULATOR_HI6421V600 tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
drivers/staging/hikey9xx/Makefile +0 -1
@@ -1,4 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_MFD_HI6421_SPMI) += hi6421-spmi-pmic.o obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
drivers/staging/hikey9xx/hi6421-spmi-pmic.c deleted +0 -342
342 lines not on this page · raw message
drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml deleted +0 -133
133 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v2 10/13] mfd: hi6421-spmi-pmic: move driver from staging
Quoted 14 lines · Mauro Carvalho Chehab
This driver is ready for mainstream. So, move it out of staging.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 133 +++++++ MAINTAINERS | 7 + drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c | 342 ++++++++++++++++++ drivers/staging/hikey9xx/Kconfig | 16 - drivers/staging/hikey9xx/Makefile | 1 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 342 ------------------ .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 133 ------- 9 files changed, 498 insertions(+), 492 deletions(-)
Could you please resubmit this will the correct flags.
I believe it's the git format-patch -M flag that you want.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Mauro Carvalho Chehab
maintainerRe: [PATCH v2 10/13] mfd: hi6421-spmi-pmic: move driver from staging
Em Mon, 18 Jan 2021 15:12:27 +0000
Lee Jones <[email protected]> escreveu:
Quoted 17 lines · Mauro Carvalho Chehab
Quoted 4 lines
This driver is ready for mainstream. So, move it out of staging.
Signed-off-by Mauro Carvalho Chehab <[email protected]>Quoted 11 lines
--- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 133 +++++++ MAINTAINERS | 7 + drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c | 342 ++++++++++++++++++ drivers/staging/hikey9xx/Kconfig | 16 - drivers/staging/hikey9xx/Makefile | 1 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 342 ------------------ .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 133 ------- 9 files changed, 498 insertions(+), 492 deletions(-)
Quoted 3 lines
Could you please resubmit this will the correct flags.
I believe it's the
git format-patch-M flag that you want.
As explained at patch 00/13, this was intentionally generated with --no-merges, in order to allow reviewers to view the entire source code at the patch.
Anyway, I'll re-send the series with -M, as it makes easier to merge, if everything is ok.
Thanks,
Mauro
Re: [PATCH v2 10/13] mfd: hi6421-spmi-pmic: move driver from staging
Quoted 20 lines · Mauro Carvalho Chehab
Em Mon, 18 Jan 2021 15:12:27 +0000
Lee Jones <[email protected]> escreveu:Quoted 17 lines · Mauro Carvalho Chehab
Quoted 15 lines
This driver is ready for mainstream. So, move it out of staging.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 133 +++++++ MAINTAINERS | 7 + drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c | 342 ++++++++++++++++++ drivers/staging/hikey9xx/Kconfig | 16 - drivers/staging/hikey9xx/Makefile | 1 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 342 ------------------ .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 133 ------- 9 files changed, 498 insertions(+), 492 deletions(-)
Quoted 7 lines
Quoted 3 lines
Could you please resubmit this will the correct flags.
I believe it's the
git format-patch-M flag that you want.As explained at patch 00/13, this was intentionally generated with --no-merges, in order to allow reviewers to view the entire source code at the patch.
That's a fair point. Please leave it as it is for now then.
I'll get around to the review soon I hope.
Quoted 2 lines
Anyway, I'll re-send the series with -M, as it makes easier to merge, if everything is ok.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Rob Herring
maintainerRe: [PATCH v2 10/13] mfd: hi6421-spmi-pmic: move driver from staging
In reply to Mauro Carvalho ChehabQuoted 19 lines · Mauro Carvalho Chehab
This driver is ready for mainstream. So, move it out of staging.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 133 +++++++ MAINTAINERS | 7 + drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c | 342 ++++++++++++++++++ drivers/staging/hikey9xx/Kconfig | 16 - drivers/staging/hikey9xx/Makefile | 1 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 342 ------------------ .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 133 ------- 9 files changed, 498 insertions(+), 492 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml create mode 100644 drivers/mfd/hi6421-spmi-pmic.c delete mode 100644 drivers/staging/hikey9xx/hi6421-spmi-pmic.c delete mode 100644 drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml: 'additionalProperties' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml: ignoring, error in schema:
warning: no schema found in file: ./Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
See https://patchwork.ozlabs.org/patch/1428169
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Mauro Carvalho Chehab
maintainerPATCH v2 11/13 regulator: hi6421v600-regulator: move it from staging
In reply to Mauro Carvalho ChehabThis driver is ready for mainstream. Move it out of staging.
--- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 2 + MAINTAINERS | 7 +- drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/hi6421v600-regulator.c | 347 ++++++++++++++++++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/hikey9xx/Kconfig | 11 - drivers/staging/hikey9xx/Makefile | 3 - drivers/staging/hikey9xx/TODO | 5 - .../staging/hikey9xx/hi6421v600-regulator.c | 347 ------------------ 11 files changed, 359 insertions(+), 375 deletions(-) create mode 100644 drivers/regulator/hi6421v600-regulator.c delete mode 100644 drivers/staging/hikey9xx/Kconfig delete mode 100644 drivers/staging/hikey9xx/Makefile delete mode 100644 drivers/staging/hikey9xx/TODO delete mode 100644 drivers/staging/hikey9xx/hi6421v600-regulator.c
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +2 -0
@@ -60,6 +60,8 @@ required: - reg - regulators +additionalProperties: false + examples: - | /* pmic properties */
MAINTAINERS +1 -6
@@ -8012,12 +8012,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml F: drivers/mfd/hi6421-spmi-pmic.c - -HISILICON STAGING DRIVERS FOR HIKEY 960/970 -M: Mauro Carvalho Chehab <[email protected]> -L: [email protected] -S: Maintained -F: drivers/staging/hikey9xx/ +F: drivers/regulator/hi6421v600-regulator.c HISILICON TRUE RANDOM NUMBER GENERATOR V2 SUPPORT M: Zaibo Xu <[email protected]>
drivers/regulator/Kconfig +8 -0
@@ -394,6 +394,14 @@ config REGULATOR_HI655X This driver provides support for the voltage regulators of the Hisilicon Hi655x PMIC device. +config REGULATOR_HI6421V600 + tristate "HiSilicon Hi6421v600 PMIC voltage regulator support" + depends on MFD_HI6421_SPMI && OF + help + This driver provides support for the voltage regulators on + HiSilicon Hi6421v600 PMU / Codec IC. + This is used on Kirin 3670 boards, like HiKey 970. + config REGULATOR_ISL9305 tristate "Intersil ISL9305 regulator" depends on I2C
drivers/regulator/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_REGULATOR_FAN53880) += fan53880.o obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o obj-$(CONFIG_REGULATOR_HI6421V530) += hi6421v530-regulator.o +obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o
drivers/regulator/hi6421v600-regulator.c new file +347 -0
347 lines not on this page · raw message
drivers/staging/Kconfig +0 -2
@@ -116,6 +116,4 @@ source "drivers/staging/qlge/Kconfig" source "drivers/staging/wfx/Kconfig" -source "drivers/staging/hikey9xx/Kconfig" - endif # STAGING
drivers/staging/Makefile +0 -1
@@ -48,4 +48,3 @@ obj-$(CONFIG_FIELDBUS_DEV) += fieldbus/ obj-$(CONFIG_KPC2000) += kpc2000/ obj-$(CONFIG_QLGE) += qlge/ obj-$(CONFIG_WFX) += wfx/ -obj-y += hikey9xx/
drivers/staging/hikey9xx/Kconfig deleted +0 -11
@@ -1,11 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -# to be placed at drivers/regulator -config REGULATOR_HI6421V600 - tristate "HiSilicon Hi6421v600 PMIC voltage regulator support" - depends on MFD_HI6421_SPMI && OF - depends on REGULATOR - help - This driver provides support for the voltage regulators on - HiSilicon Hi6421v600 PMU / Codec IC. - This is used on Kirin 3670 boards, like HiKey 970.
drivers/staging/hikey9xx/Makefile deleted +0 -3
@@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
drivers/staging/hikey9xx/TODO deleted +0 -5
@@ -1,5 +0,0 @@ -ToDo list: - -- Port other drivers needed by Hikey 960/970; -- Test drivers on Hikey 960; -- Validate device tree bindings.
drivers/staging/hikey9xx/hi6421v600-regulator.c deleted +0 -347
347 lines not on this page · raw message
Signature · 1 line
2.29.2
Mark Brown
maintainerRe: [PATCH v2 11/13] regulator: hi6421v600-regulator: move it from staging
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml required: · line 67
Quoted 12 lines · Mauro Carvalho Chehab
index
f385146d2bd1..3b23ad56b31a100644Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +2
-0@@ -60,6 +60,8 @@ required: - reg - regulators +additionalProperties: false + examples: - | /* pmic properties */
Why is this part of this patch?
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 7 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +7
-0+// SPDX-License-Identifier: GPL-2.0 +// +// Device driver for regulators in Hisi IC +// +// Copyright (c) 2013 Linaro Ltd. +// Copyright (c) 2011 Hisilicon. +//
This looks like it needs an update.
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 8 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +8
-0+// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details.
This boilerplate can be removed.
Quoted 5 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +5
-0+static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) +{ + struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); + struct hi6421_spmi_pmic *pmic = sreg->pmic; + int ret;
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 10 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +10
-0+ + /* cannot enable more than one regulator at one time */ + mutex_lock(&sreg->enable_mutex); + usleep_range(HISI_REGS_ENA_PROTECT_TIME, + HISI_REGS_ENA_PROTECT_TIME + 1000); + + /* set enable register */ + ret = hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, + rdev->desc->enable_mask, + rdev->desc->enable_mask);
If for some reason the PMIC is sufficiently fragile to need a delay between enables it's not clear why the driver is doing it before enabling rather than after, presumably there's issues with the regulator ramping up and stabalising its output
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 3 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +3
-0+ /* set enable register to 0 */ + return hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, + rdev->desc->enable_mask, 0);
I'm not sure all these comments are adding anything.
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 2 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +2
-0+ if (unlikely(selector >= rdev->desc->n_voltages)) + return -EINVAL;
This should not be a hot path that needs an unlikely() annotation.
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 9 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +9
-0+static unsigned int +hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev, + int input_uV, int output_uV, + int load_uA) +{ + struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); + + if (load_uA || ((unsigned int)load_uA > sreg->eco_uA)) + return REGULATOR_MODE_NORMAL;
This means that for *any* load at all we select NORMAL - I'm not convinced this is intentional?
Mauro Carvalho Chehab
maintainerRe: [PATCH v2 11/13] regulator: hi6421v600-regulator: move it from staging
Em Mon, 18 Jan 2021 13:54:40 +0000
Mark Brown <[email protected]> escreveu:
Quoted 9 lines · Mauro Carvalho Chehab
Quoted 8 lines
index
f385146d2bd1..3b23ad56b31a100644Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +0
-0@@ -60,6 +60,8 @@ required: - reg - regulators
Quoted 7 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml required: · line 67
Quoted 5 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +2
-0+additionalProperties: false + examples: - | /* pmic properties */Why is this part of this patch?
I'll place on a separate one.
Quoted 10 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 8 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +7
-0+// SPDX-License-Identifier: GPL-2.0 +// +// Device driver for regulators in Hisi IC +// +// Copyright (c) 2013 Linaro Ltd. +// Copyright (c) 2011 Hisilicon. +//This looks like it needs an update.
Ok.
Quoted 11 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 9 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +8
-0+// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details.This boilerplate can be removed.
Ok.
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +12
-0+static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) +{ + struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); + struct hi6421_spmi_pmic *pmic = sreg->pmic; + int ret; + + /* cannot enable more than one regulator at one time */ + mutex_lock(&sreg->enable_mutex); + usleep_range(HISI_REGS_ENA_PROTECT_TIME, + HISI_REGS_ENA_PROTECT_TIME + 1000); + + /* set enable register */
Quoted 8 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 3 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +3
-0+ ret = hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, + rdev->desc->enable_mask, + rdev->desc->enable_mask);If for some reason the PMIC is sufficiently fragile to need a delay between enables it's not clear why the driver is doing it before enabling rather than after, presumably there's issues with the regulator ramping up and stabalising its output
I don't have any datasheets or documentation from this device, except for the Linaro's official driver for Kernel 4.9 (from where this driver was originally ported), and a high-level documentation for this hardware at 96boards site, which doesn't cover any details.
-
My understanding is that the issue here seems to be different.
This is the original code (which can be seen on changeset 42f24d9d446a, already upstream):
struct timeval last_enabled;
static void ensured_time_after(struct timeval since, u32 delay_us)
{
struct timeval now;
u64 elapsed_ns64, delay_ns64;
u32 actual_us32;
delay_ns64 = delay_us * NSEC_PER_USEC;
do_gettimeofday(&now);
elapsed_ns64 = timeval_to_ns(&now) - timeval_to_ns(&since);
if (delay_ns64 > elapsed_ns64) {
actual_us32 = ((u32)(delay_ns64 - elapsed_ns64) /
NSEC_PER_USEC);
if (actual_us32 >= 1000) {
mdelay(actual_us32 / 1000); /*lint !e647 */
udelay(actual_us32 % 1000);
} else if (actual_us32 > 0) {
udelay(actual_us32);
}
}
return;
}
static int hisi_regulator_enable(struct regulator_dev *dev)
{
struct hisi_regulator *sreg = rdev_get_drvdata(dev);
struct hisi_pmic *pmic = rdev_to_pmic(dev);
/* keep a distance of off_on_delay from last time disabled */
ensured_time_after(sreg->last_off_time, sreg->off_on_delay);
BRAND_DEBUG("<[%s]: off_on_delay=%dus>\n", __func__, sreg->off_on_delay);
/* cannot enable more than one regulator at one time */
mutex_lock(&enable_mutex);
ensured_time_after(last_enabled, HISI_REGS_ENA_PROTECT_TIME);
/* set enable register */
hisi_pmic_rmw(pmic, sreg->register_info.ctrl_reg,
sreg->register_info.enable_mask,
sreg->register_info.enable_mask);
BRAND_DEBUG("<[%s]: ctrl_reg=0x%x,enable_mask=0x%x>\n", __func__, sreg->register_info.ctrl_reg,\
sreg->register_info.enable_mask);
do_gettimeofday(&last_enabled);
mutex_unlock(&enable_mutex);
return 0;
}What I did here was to play safe. So, I removed the static var and the call to gettimeofday() and replaced by just a delay.
As, on this device, the power lines don't change too often: only the USB power supply changes over time during its reset sequence.
The other power lines are powered during the boot and remain powered if the hardware is detected.
Quoted 5 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 3 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +3
-0+ /* set enable register to 0 */ + return hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, + rdev->desc->enable_mask, 0);I'm not sure all these comments are adding anything.
I'll drop on a next version.
Quoted 5 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 3 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +2
-0+ if (unlikely(selector >= rdev->desc->n_voltages)) + return -EINVAL;This should not be a hot path that needs an
unlikely()annotation.
I'll drop unlikely().
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +4
-0+static unsigned int +hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev, + int input_uV, int output_uV, + int load_uA)
Quoted 8 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
Quoted 5 lines
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +5
-0+{ + struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); + + if (load_uA || ((unsigned int)load_uA > sreg->eco_uA)) + return REGULATOR_MODE_NORMAL;This means that for *any* load at all we select NORMAL - I'm not convinced this is intentional?
Indeed this seems to be a bug. Thanks for noticing it!
I'll fix that.
Thanks,
Mauro
Mark Brown
maintainerRe: [PATCH v2 11/13] regulator: hi6421v600-regulator: move it from staging
Quoted 11 lines · Mauro Carvalho Chehab
Mark Brown <[email protected]> escreveu:
Quoted 4 lines
If for some reason the PMIC is sufficiently fragile to need a delay between enables it's not clear why the driver is doing it before enabling rather than after, presumably there's issues with the regulator ramping up and stabalising its output
I don't have any datasheets or documentation from this device, except for the Linaro's official driver for Kernel 4.9 (from where this driver was originally ported), and a high-level documentation for this hardware at 96boards site, which doesn't cover any details.
This misses the point. To repeat, if the driver is hard coding a delay why is the driver doing this *before* rather than *after* enabling?
Mauro Carvalho Chehab
maintainerPATCH v2 12/13 dts: hisilicon: add support for USB3 on Hikey 970
In reply to Mauro Carvalho ChehabAdd the USB3 bindings for Kirin 970 phy and Hikey 970 board.
--- .../boot/dts/hisilicon/hi3670-hikey970.dts | 102 ++++++++++++++++++ arch/arm64/boot/dts/hisilicon/hi3670.dtsi | 58 ++++++++++ 2 files changed, 160 insertions(+)
arch/arm64/boot/dts/hisilicon/hi3670-hikey970.dts +102 -0
@@ -69,6 +69,29 @@ wlan_en: wlan-en-1-8v { startup-delay-us = <70000>; enable-active-high; }; + hikey_usbhub: hikey_usbhub { + compatible = "hisilicon,kirin970_hikey_usbhub"; + + typec-vbus-gpios = <&gpio26 1 0>; + otg-switch-gpios = <&gpio4 2 0>; + hub_reset_en_gpio = <&gpio0 3 0>; + hub-vdd-supply = <&ldo17>; + usb-role-switch; + + port { + #address-cells = <1>; + #size-cells = <0>; + + hikey_usb_ep0: endpoint@0 { + reg = <0>; + remote-endpoint = <&dwc3_role_switch>; + }; + hikey_usb_ep1: endpoint@1 { + reg = <1>; + remote-endpoint = <&rt1711h_ep>; + }; + }; + }; }; /*
@@ -446,3 +469,82 @@ &uart6 { label = "LS-UART1"; status = "okay"; }; + +&i2c1 { + status = "okay"; + + rt1711h: rt1711h@4e { + compatible = "richtek,rt1711h"; + reg = <0x4e>; + status = "okay"; + interrupt-parent = <&gpio27>; + interrupts = <5 IRQ_TYPE_LEVEL_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&usb_cfg_func>; + + usb_con: connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "dual"; + try-power-role = "sink"; + source-pdos = <PDO_FIXED(5000, 500, PDO_FIXED_USB_COMM)>; + sink-pdos = <PDO_FIXED(5000, 500, PDO_FIXED_USB_COMM) + PDO_VAR(5000, 5000, 1000)>; + op-sink-microwatt = <10000000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@1 { + reg = <1>; + usb_con_ss: endpoint { + remote-endpoint = <&dwc3_ss>; + }; + }; + }; + }; + port { + #address-cells = <1>; + #size-cells = <0>; + + rt1711h_ep: endpoint@0 { + reg = <0>; + remote-endpoint = <&hikey_usb_ep1>; + }; + }; + }; +}; + +&i2c2 { + /* USB HUB is on this bus at address 0x44 */ + status = "okay"; +}; + +&dwc3 { /* USB */ + dr_mode = "otg"; + maximum-speed = "super-speed"; + phy_type = "utmi"; + snps,dis-del-phy-power-chg-quirk; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + snps,tx_de_emphasis_quirk; + snps,tx_de_emphasis = <1>; + snps,dis-split-quirk; + snps,gctl-reset-quirk; + usb-role-switch; + role-switch-default-mode = "host"; + port { + #address-cells = <1>; + #size-cells = <0>; + dwc3_role_switch: endpoint@0 { + reg = <0>; + remote-endpoint = <&hikey_usb_ep0>; + }; + + dwc3_ss: endpoint@1 { + reg = <1>; + remote-endpoint = <&usb_con_ss>; + }; + }; +};
arch/arm64/boot/dts/hisilicon/hi3670.dtsi +58 -0
69 lines not on this page · raw message
Signature · 7 lines
2.29.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mauro Carvalho Chehab
maintainerPATCH v2 13/13 dts: hisilicon: add support for the PMIC found on Hikey 970
In reply to Mauro Carvalho ChehabAdd a device tree for the HiSilicon 6421v600 SPMI PMIC, used on HiKey970 board.
As we now have support for it, change the fixed regulators used by the SD I/O to use the proper LDO supplies.
--- .../boot/dts/hisilicon/hi3670-hikey970.dts | 22 +---- .../boot/dts/hisilicon/hikey970-pmic.dtsi | 87 +++++++++++++++++++ 2 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 arch/arm64/boot/dts/hisilicon/hikey970-pmic.dtsi
arch/arm64/boot/dts/hisilicon/hi3670-hikey970.dts +3 -19
@@ -12,6 +12,7 @@ #include "hi3670.dtsi" #include "hikey970-pinctrl.dtsi" +#include "hikey970-pmic.dtsi" / { model = "HiKey970";
@@ -39,23 +40,6 @@ memory@0 { reg = <0x0 0x0 0x0 0x0>; }; - sd_1v8: regulator-1v8 { - compatible = "regulator-fixed"; - regulator-name = "fixed-1.8V"; - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <1800000>; - regulator-always-on; - }; - - sd_3v3: regulator-3v3 { - compatible = "regulator-fixed"; - regulator-name = "fixed-3.3V"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; - wlan_en: wlan-en-1-8v { compatible = "regulator-fixed"; regulator-name = "wlan-en-regulator";
@@ -425,8 +409,8 @@ &dwmmc1 { pinctrl-0 = <&sd_pmx_func &sd_clk_cfg_func &sd_cfg_func>; - vmmc-supply = <&sd_3v3>; - vqmmc-supply = <&sd_1v8>; + vmmc-supply = <&ldo16>; + vqmmc-supply = <&ldo9>; status = "okay"; };
arch/arm64/boot/dts/hisilicon/hikey970-pmic.dtsi new file +87 -0
87 lines not on this page · raw message
Signature · 7 lines
2.29.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel