Re: [PATCH 6/6] wlan-ng: clean up reused macros
On Mon, Jan 18, 2021 at 02:09:56AM +0100, Johannes Czekay wrote: > This patch cleans up two "macro argument reuse" warnings by checkpatch. > This should also make the code much more readable. > > Signed-off-by: Johannes Czekay > Co-developed-by: Nicolai Fischer > Signed-off-by: Nicolai Fischer > --- > drivers/staging/wlan-ng/p80211metastruct.h | 18 +--- > drivers/staging/wlan-ng/prism2mgmt.c | 48 ++ > 2 files changed, 14 insertions(+), 52 deletions(-) > > diff --git a/drivers/staging/wlan-ng/p80211metastruct.h > b/drivers/staging/wlan-ng/p80211metastruct.h > index 4adc64580185..e963227f797c 100644 > --- a/drivers/staging/wlan-ng/p80211metastruct.h > +++ b/drivers/staging/wlan-ng/p80211metastruct.h > @@ -114,22 +114,8 @@ struct p80211msg_dot11req_scan_results { > struct p80211item_uint32 cfpollreq; > struct p80211item_uint32 privacy; > struct p80211item_uint32 capinfo; > - struct p80211item_uint32 basicrate1; > - struct p80211item_uint32 basicrate2; > - struct p80211item_uint32 basicrate3; > - struct p80211item_uint32 basicrate4; > - struct p80211item_uint32 basicrate5; > - struct p80211item_uint32 basicrate6; > - struct p80211item_uint32 basicrate7; > - struct p80211item_uint32 basicrate8; > - struct p80211item_uint32 supprate1; > - struct p80211item_uint32 supprate2; > - struct p80211item_uint32 supprate3; > - struct p80211item_uint32 supprate4; > - struct p80211item_uint32 supprate5; > - struct p80211item_uint32 supprate6; > - struct p80211item_uint32 supprate7; > - struct p80211item_uint32 supprate8; > + struct p80211item_uint32 basicrate[8]; > + struct p80211item_uint32 supprate[8]; > } __packed; > > struct p80211msg_dot11req_start { > diff --git a/drivers/staging/wlan-ng/prism2mgmt.c > b/drivers/staging/wlan-ng/prism2mgmt.c > index 1bd36dc2b7ff..8540c3336907 100644 > --- a/drivers/staging/wlan-ng/prism2mgmt.c > +++ b/drivers/staging/wlan-ng/prism2mgmt.c > @@ -388,6 +388,7 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, > void *msgp) > struct hfa384x_hscan_result_sub *item = NULL; > > int count; > + int i; > > req = msgp; > > @@ -437,42 +438,17 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, > void *msgp) > if (item->supprates[count] == 0) > break; > > -#define REQBASICRATE(N) \ > - do { \ > - if ((count >= (N)) && DOT11_RATE5_ISBASIC_GET( \ > - item->supprates[(N) - 1])) { \ > - req->basicrate ## N .data = item->supprates[(N) - 1]; \ > - req->basicrate ## N .status = \ > - P80211ENUM_msgitem_status_data_ok; \ > - } \ > - } while (0) > - > - REQBASICRATE(1); > - REQBASICRATE(2); > - REQBASICRATE(3); > - REQBASICRATE(4); > - REQBASICRATE(5); > - REQBASICRATE(6); > - REQBASICRATE(7); > - REQBASICRATE(8); > - > -#define REQSUPPRATE(N) \ > - do { \ > - if (count >= (N)) { \ > - req->supprate ## N .data = item->supprates[(N) - 1]; \ > - req->supprate ## N .status = \ > - P80211ENUM_msgitem_status_data_ok; \ > - } \ > - } while (0) > - > - REQSUPPRATE(1); > - REQSUPPRATE(2); > - REQSUPPRATE(3); > - REQSUPPRATE(4); > - REQSUPPRATE(5); > - REQSUPPRATE(6); > - REQSUPPRATE(7); > - REQSUPPRATE(8); > + for (i = 0; i < 8; i++) { > + if (count > 1) { This should be "i" instead of "1". And conditions are more readable if you put the part that changes first "if (variable < limit)" to avoid backwards think. if (i < count) { Or you could reverse it the other way: if (i >= count) break; > + if (DOT11_RATE5_ISBASIC_GET(item->supprates[i])) { > + req->basicrate[i].data = item->supprates[i]; > + req->basicrate[i].status = > P80211ENUM_msgitem_status_data_ok; > + } > + > + req->supprate[i].data = item->supprates[i]; > + req->supprate[i].status = > P80211ENUM_msgitem_status_data_ok; > + } > + } It's sort of surprising that we can change how we write this information but we don't have to change how it is read. I guess presumably it's just dumped as hex to debugfs or something like that... Who knows. :/ regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 07/18] staging: hikey9xx: hi6421v600-regulator: get rid of an static data
Move it to be inside the private data struct. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 5469089a3daf..e96aab17a499 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -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[] = { 150, 155, 160, 165, @@ -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 */ -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 01/18] staging: hikey9xx: hisilicon, hisi-spmi-controller.yaml fix bindings
Fix a few warnings produced by make dt_binding_check. Signed-off-by: Mauro Carvalho Chehab --- .../hisilicon,hisi-spmi-controller.yaml | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml index f2a56fa4e78e..21f68a9c2df1 100644 --- a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml @@ -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 */ }; }; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 12/18] staging: hikey9xx: hi6421v600-regulator: fix get_optimum_mode
During the driver refactor, a regression broke the logic inside hi6421_spmi_regulator_get_optimum_mode(). Basically, if a LDO has eco_uA == 0, it doesn't support economic mode. So, it should return REGULATOR_MODE_NORMAL. If economic mode is supported, it can return either REGULATOR_MODE_IDLE or REGULATOR_MODE_NORMAL, depending on the load current. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 72dd779d85e6..5fe77b490166 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -206,7 +206,7 @@ hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev, { struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); - if (load_uA || ((unsigned int)load_uA > sreg->eco_uA)) + if (!sreg->eco_uA || ((unsigned int)load_uA > sreg->eco_uA)) return REGULATOR_MODE_NORMAL; return REGULATOR_MODE_IDLE; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 10/18] staging: hikey9xx: hi6421v600-regulator: fix delay logic
The original driver, which can be seen at commit 42f24d9d446a ("staging: regulator: add a regulator driver for HiSilicon 6421v600 SPMI PMIC") had a complex logic to ensure that there won't be multiple power enable/disable commands running at the same time. At the original logic, it were ensured that: - a next power up/down would wait for at least the on/off period; - an extra delay would be granted. It turns that such extra delay has a value of zero, but it was relying on gettimeofday() call, which can take some time. This was later simplified, but there are still some possible issues. In order to avoid that, let's simply add a delay to wait for the power up line to stabilize after powering up a device. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 5 +++-- include/linux/mfd/hi6421-spmi-pmic.h| 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 35a72ea1bd14..f728118e84c0 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -113,14 +113,15 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) /* 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); + /* Avoid powering up multiple devices at the same time */ + usleep_range(rdev->desc->off_on_delay, rdev->desc->off_on_delay + 60); + mutex_unlock(&sreg->enable_mutex); return ret; diff --git a/include/linux/mfd/hi6421-spmi-pmic.h b/include/linux/mfd/hi6421-spmi-pmic.h index 2c8896fd852e..0c2214612c4e 100644 --- a/include/linux/mfd/hi6421-spmi-pmic.h +++ b/include/linux/mfd/hi6421-spmi-pmic.h @@ -13,7 +13,6 @@ #include -#define HISI_REGS_ENA_PROTECT_TIME (0) /* in microseconds */ #define HISI_ECO_MODE_ENABLE (1) #define HISI_ECO_MODE_DISABLE (0) -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 13/18] staging: hikey9xx: hisilicon, hi6421-spmi-pmic.yaml: cleanup a warning
There's no additionalProperties field at the yaml file, causing a warning when checking it. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml index f385146d2bd1..3b23ad56b31a 100644 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml @@ -60,6 +60,8 @@ required: - reg - regulators +additionalProperties: false + examples: - | /* pmic properties */ -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 05/18] staging: hikey9xx: hi6421v600-regulator: move LDO config from DT
Instead of storing regulator LDO configuration inside the DT, move it to be part of the driver itself. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 380 +++--- 1 file changed, 152 insertions(+), 228 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 4ee0444b2b4e..70e4c06c1b2d 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -16,35 +16,97 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +#include #include #include -#include #include -#include #include -#include -#include #include #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[] = { + 150, 155, 160, 165, + 170, 1725000, 175, 1775000, + 180, 1825000, 185, 1875000, + 190, 1925000, 195, 200 +}; + +static const unsigned int ldo4_voltages[] = { + 1725000, 175, 1775000, 180, + 1825000, 185, 1875000, 190 +}; + +static const unsigned int ldo9_voltages[] = { + 175, 180, 1825000, 280, + 285, 295, 300, 330 +}; + +static const unsigned int ldo15_voltages[] = { + 180, 185, 240, 260, + 270, 285, 295, 300 +}; + +static const unsigned int ldo17_voltages[] = { + 250, 260, 270, 280, + 300, 310, 320, 330 +}; + +static const unsigned int ldo34_voltages[] = { + 260, 270, 280, 290, + 300, 310, 320, 330 +}; + /* - * 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(
[PATCH v3 09/18] staging: hikey9xx: hi6421v600-regulator: update copyright
Remove the GPL boilerplate, as SPDX tag already points to the license terms and add a new copyright for Huawei. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 1593256e9057..35a72ea1bd14 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -4,17 +4,9 @@ // // Copyright (c) 2013 Linaro Ltd. // Copyright (c) 2011 Hisilicon. +// Copyright (c) 2020-2021 Huawei Technologies Co., Ltd // // Guodong Xu -// -// 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 #include -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 08/18] staging: hikey9xx: hi6421v600-regulator: do some cleanups
In 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. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 37 --- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index e96aab17a499..1593256e9057 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -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, @@ -164,16 +163,14 @@ static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev, struct hi6421_spmi_pmic *pmic = sreg->pmic; u32 reg_val; - if (unlikely(selector >= rdev->desc->n_voltages)) + if (selector >= rdev->desc->n_voltages) return -EINVAL; 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"); -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 00/18] Move Hisilicon 6421v600 SPMI driver set out of staging
Hi Mark/Lee, 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=hikey970-destage-usb In order to make easier for review, this series was generated with --no-renames. 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. Regards, Mauro v3: - fixed a bug with eco-mode at get_optimum_mode; - changed the sleep logic when enabling/disabling a power line; - additional cleanups, as requested by Mark; v2: - 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. Mauro Carvalho Chehab (18): staging: hikey9xx: hisilicon,hisi-spmi-controller.yaml fix bindings staging: hikey9xx: hisilicon,hi6421-spmi-pmic.yaml: simplify props 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: hi6421v600-regulator: get rid of an static data staging: hikey9xx: hi6421v600-regulator: do some cleanups staging: hikey9xx: hi6421v600-regulator: update copyright staging: hikey9xx: hi6421v600-regulator: fix delay logic staging: hikey9xx: hi6421v600-regulator: cleanup comments staging: hikey9xx: hi6421v600-regulator: fix get_optimum_mode staging: hikey9xx: hisilicon,hi6421-spmi-pmic.yaml: cleanup a warning 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 | 335 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 --- include/linux/mfd/hi6421-spmi-pmic.h | 1 - 26 files changed, 1542 insertions(+), 1473 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/stagin
[PATCH v3 04/18] staging: hikey9xx: hi6421v600-regulator: do some cleanups
Use C99 comments at the beginning of the file and remove uneeded includes. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 43 +++ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 614b03c9ddfb..4ee0444b2b4e 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -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 - * - * 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 +// +// 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 -#include -#include -#include #include #include -#include -#include #include #include #include #include #include #include -#include -#include #include -#include -#include #define rdev_dbg(rdev, fmt, arg...)\ pr_debug("%s: %s: " fmt, (rdev)->desc->name, __func__, ##arg) -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 06/18] staging: hikey9xx: hi6421v600-regulator: cleanup debug msgs
While 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. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 47 ++- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 70e4c06c1b2d..5469089a3daf 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -23,9 +23,6 @@ #include #include -#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,
[PATCH v3 02/18] staging: hikey9xx: hisilicon, hi6421-spmi-pmic.yaml: simplify props
As all regulator-specific properties got moved to be part of the driver, remove them from the DT spec. Signed-off-by: Mauro Carvalho Chehab --- .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 106 +++--- 1 file changed, 40 insertions(+), 66 deletions(-) diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml index 80e74c261e05..f385146d2bd1 100644 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml @@ -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 = <150>; regulator-max-microvolt = <200>; regulator-boot-on; - - enable-mask = <0x01>; - - voltage-table = <150>, <155>, <160>, <165>, - <170>, <1725000>, <175>, <1775000>, - <180>, <1825000>, <185>, <1875000>, - <190>, <1925000>, <195>, <200>; - off-on-delay-us = <2>; - 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 = <190>; regulator-boot-on; +}; - enable-mask = <0x01>; - idle-mode-mask = <0x10>; - eco-microamp = <1>; +ldo9: LDO9 { + regulator-name = "ldo9"; + regulator-min-microvolt = <175>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; - hi6421-vsel = <0x52 0x07>; - voltage-table = <1725000>, <175>, <1775000>, <180>, - <1825000>, <185>, <1875000>, <190>; - off-on-delay-us = <2>; - startup-delay-us = <120>; +ldo15: LDO15 { + regulator-name = "ldo15"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-always-on; +}; + +ldo16: LDO16 { + regulator-name = "ldo16"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-boot-on; +}; + +ldo17: LDO17 { + regulator-name = "ldo17"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; +}; + +ldo33: LDO33 { + regulator-name = "ldo33"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; + +ldo34: LDO34 { + regulator-name = "ldo34"; + regulator-min-microvolt = <260>; + regulator-max-microvolt = <330>; }; }; }; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 11/18] staging: hikey9xx: hi6421v600-regulator: cleanup comments
Remove obvious comments and fix the comment for the HI6421V600_LDO() macro. While on it, use kernel-doc notation for HI6421V600_LDO(), as kernel-doc can check if the arguments match its description. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 27 --- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index f728118e84c0..72dd779d85e6 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -57,17 +57,17 @@ static const unsigned int ldo34_voltages[] = { 300, 310, 320, 330 }; -/* - * _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 +/** + * HI6421V600_LDO() - specify a LDO power line + * @_id: LDO id name string + * @vtable: voltage table + * @ereg: enable register + * @emask: enable mask + * @vreg: voltage select register + * @odelay: off/on delay time in uS + * @etime: enable 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) \ @@ -114,7 +114,6 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) /* cannot enable more than one regulator at one time */ mutex_lock(&sreg->enable_mutex); - /* set enable register */ ret = hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, rdev->desc->enable_mask, rdev->desc->enable_mask); @@ -132,7 +131,6 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev) struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); struct hi6421_spmi_pmic *pmic = sreg->pmic; - /* set enable register to 0 */ return hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, rdev->desc->enable_mask, 0); } @@ -143,7 +141,6 @@ static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev) struct hi6421_spmi_pmic *pmic = sreg->pmic; u32 reg_val; - /* 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); @@ -198,7 +195,6 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev, return -EINVAL; } - /* set mode */ return hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, sreg->eco_mode_mask, val); } @@ -304,7 +300,6 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev) mutex_init(&sreg->enable_mutex); for (i = 0; i < ARRAY_SIZE(regulator_info); i++) { - /* assign per-regulator data */ info = ®ulator_info[i]; config.dev = pdev->dev.parent; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 14/18] spmi: hi6421-spmi-pmic: move driver from staging
The Hisilicon 6421v600 SPMI driver is ready for mainstream. So, move it from staging. Signed-off-by: Mauro Carvalho Chehab --- .../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 diff --git a/Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml b/Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml new file mode 100644 index ..21f68a9c2df1 --- /dev/null +++ b/Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml @@ -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 + +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 */ +}; + }; +}; diff --git a/MAINTAINERS b/MAINTAINERS index 8d858e8d5a52..85e5b6ab57ca 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 +L: linux-ker...@vger.kernel.org +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 L: de...@driverdev.osuosl.org diff --git a/drivers/spmi/Kconfig b/drivers/spmi/Kconfig index a53bad541f1a..2874b6c26028 100644 --- a/drivers/spmi/Kconfig +++ b/drivers/spmi/Kconfig @@ -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 diff --git a/drivers/spmi/Makefile b/drivers/spmi/Makefile index 55a94cadeffe..6e092e6f290c 100644 --- a/drivers/spmi/Makefile +++ b/drivers/spmi/Makefile @@ -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 diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c new file mode 100644 index ..4be2344ad7b5 --- /dev/null +++ b/drivers/spmi/hisi-spmi-controller.c @@ -0,0 +1,358 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include
[PATCH v3 16/18] regulator: hi6421v600-regulator: move it from staging
This driver is ready for mainstream. Move it out of staging. Signed-off-by: Mauro Carvalho Chehab --- MAINTAINERS | 7 +- drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile| 1 + drivers/regulator/hi6421v600-regulator.c | 335 ++ 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 | 335 -- 10 files changed, 345 insertions(+), 363 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 diff --git a/MAINTAINERS b/MAINTAINERS index c5b36a58ede5..138798bbb32e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8012,12 +8012,7 @@ L: linux-ker...@vger.kernel.org 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 -L: de...@driverdev.osuosl.org -S: Maintained -F: drivers/staging/hikey9xx/ +F: drivers/regulator/hi6421v600-regulator.c HISILICON TRUE RANDOM NUMBER GENERATOR V2 SUPPORT M: Zaibo Xu diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 020a00d6696b..ca983e5a7a4d 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -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 diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 6ebae516258e..45d1883de54b 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -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 diff --git a/drivers/regulator/hi6421v600-regulator.c b/drivers/regulator/hi6421v600-regulator.c new file mode 100644 index ..5fe77b490166 --- /dev/null +++ b/drivers/regulator/hi6421v600-regulator.c @@ -0,0 +1,335 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Device driver for regulators in Hisi IC +// +// Copyright (c) 2013 Linaro Ltd. +// Copyright (c) 2011 Hisilicon. +// Copyright (c) 2020-2021 Huawei Technologies Co., Ltd +// +// Guodong Xu + +#include +#include +#include +#include +#include +#include + +struct hi6421_spmi_reg_info { + struct regulator_desc desc; + struct hi6421_spmi_pmic *pmic; + u8 eco_mode_mask; + u32 eco_uA; + + /* Serialize regulator enable logic */ + struct mutex enable_mutex; +}; + +static const unsigned int ldo3_voltages[] = { + 150, 155, 160, 165, + 170, 1725000, 175, 1775000, + 180, 1825000, 185, 1875000, + 190, 1925000, 195, 200 +}; + +static const unsigned int ldo4_voltages[] = { + 1725000, 175, 1775000, 180, + 1825000, 185, 1875000, 190 +}; + +static const unsigned int ldo9_voltages[] = { + 175, 180, 1825000, 280, + 285, 295, 300, 330 +}; + +static const unsigned int ldo15_voltages[] = { + 180, 185, 240, 260, + 270, 285, 295, 300 +}; + +static const unsigned int ldo17_voltages[] = { + 250, 260, 270, 280, + 300, 310, 320, 330 +}; + +static const unsigned int ldo34_voltages[] = { + 260, 270, 280, 290, + 300, 310, 320, 330 +}; + +/** + * HI6421V600_LDO() - specify a LDO power line + * @_id: LDO id name string + * @vtable: voltage table + * @ereg: enable register + * @emask: enable mask + * @vreg: voltage select register + * @odelay: off/on delay time in uS +
[PATCH v3 03/18] staging: hikey9xx: hisi-spmi-controller: clean sparse warnings
Sparse 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 __be32 The conversions there are valid ones. So, add __force macro to disable such warnings. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hisi-spmi-controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hikey9xx/hisi-spmi-controller.c b/drivers/staging/hikey9xx/hisi-spmi-controller.c index f831c43f4783..4be2344ad7b5 100644 --- a/drivers/staging/hikey9xx/hisi-spmi-controller.c +++ b/drivers/staging/hikey9xx/hisi-spmi-controller.c @@ -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); -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 15/18] mfd: hi6421-spmi-pmic: move driver from staging
This driver is ready for mainstream. So, move it out of staging. Signed-off-by: Mauro Carvalho Chehab --- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 135 +++ 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 | 135 --- 9 files changed, 500 insertions(+), 494 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 diff --git a/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml b/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml new file mode 100644 index ..3b23ad56b31a --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml @@ -0,0 +1,135 @@ +# 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 + +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 + +additionalProperties: false + +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 = <150>; + regulator-max-microvolt = <200>; + regulator-boot-on; +}; + +ldo4: LDO4 { + regulator-name = "ldo4"; + regulator-min-microvolt = <1725000>; + regulator-max-microvolt = <190>; + regulator-boot-on; +}; + +ldo9: LDO9 { + regulator-name = "ldo9"; + regulator-min-microvolt = <175>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; + +ldo15: LDO15 { + regulator-name = "ldo15"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-always-on; +}; + +ldo16: LDO16 { + regulator-name = "ldo16"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-boot-on; +}; + +ldo17: LDO17 { + regulator-name = "ldo17"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; +}; + +ldo33: LDO33 { + regulator-name = "ldo33"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; + +ldo34: LDO34 { + regulator-name = "ldo34"; + regulator-min-microvolt = <260>; + regulator-max-microvolt = <330>; +}; + }; +}; diff --git a/MAINTAINERS b/MAINTAINERS index 85e5b6ab57ca..c5b36a58ede5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 +L: linux-ker...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +F: drivers
Re: [PATCH v2 3/4] staging: hikey9xx: phy-hi3670-usb3.c: hi3670_is_abbclk_seleted() returns bool
Em Tue, 19 Jan 2021 09:56:31 +0300 Dan Carpenter escreveu: > On Thu, Jan 14, 2021 at 09:56:41AM -0800, Joe Perches wrote: > > On Thu, 2021-01-14 at 18:35 +0100, Mauro Carvalho Chehab wrote: > > > Instead of using 1/0 for true/false, change the type to boolean > > > and change the returned value. > > [] > > > diff --git a/drivers/staging/hikey9xx/phy-hi3670-usb3.c > > > b/drivers/staging/hikey9xx/phy-hi3670-usb3.c > > [] > > > @@ -326,24 +326,24 @@ static int hi3670_phy_set_params(struct hi3670_priv > > > *priv) > > > return ret; > > > } > > > > > > -static int hi3670_is_abbclk_seleted(struct hi3670_priv *priv) > > > +static bool hi3670_is_abbclk_seleted(struct hi3670_priv *priv) > > > > Presumably this should be "selected" not "seleted" True. I'll fix it. > > > > > { > > > u32 reg; > > > > > > if (!priv->sctrl) { > > > dev_err(priv->dev, "priv->sctrl is null!\n"); > > > - return 1; > > > + return true; > > > } > > > > > > if (regmap_read(priv->sctrl, SCTRL_SCDEEPSLEEPED, ®)) { > > > dev_err(priv->dev, "SCTRL_SCDEEPSLEEPED read failed!\n"); > > > - return 1; > > > + return true; > > > } > > > > > > if ((reg & USB_CLK_SELECTED) == 0) > > > - return 1; > > > + return true; > > > > > > - return 0; > > > + return false; > > > } > > > > if (foo) > > return true; > > return false; > > > > should generally be consolidated into a single test. > > I quite prefer the original format, but you're right about the return > looking reversed. Using "return !!(reg & USB_CLK_SELECTED);" is > especially problematic. I like !! but Linus has commented a couple > times that he doesn't like !!. Me to. "return !!(reg & USB_CLK_SELECTED)" just obfuscates the source code, imho for no good reason. It sounds a lot easier to read something like: if (cond1) return true; if (cond2) return true; if (cond3) return true; return false; Yet, I agree that the logic here seems to be inverted. > > regards, > dan carpenter > > Thanks, Mauro ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 4/4] phy: phy-hi3670-usb3: move driver from staging into phy
Em Thu, 14 Jan 2021 19:47:31 -0600 Rob Herring escreveu: > On Thu, Jan 14, 2021 at 06:35:44PM +0100, Mauro Carvalho Chehab wrote: > > The phy USB3 driver for Hisilicon 970 (hi3670) is ready > > for mainstream. Mode it from staging into the main driver's > > phy/ directory. > > > > Signed-off-by: Mauro Carvalho Chehab > > --- > > .../bindings/phy/phy-hi3670-usb3.yaml | 72 ++ > > MAINTAINERS | 9 +- > > drivers/phy/hisilicon/Kconfig | 10 + > > drivers/phy/hisilicon/Makefile| 1 + > > drivers/phy/hisilicon/phy-hi3670-usb3.c | 668 ++ > > drivers/staging/hikey9xx/Kconfig | 11 - > > drivers/staging/hikey9xx/Makefile | 2 - > > drivers/staging/hikey9xx/phy-hi3670-usb3.c| 668 -- > > drivers/staging/hikey9xx/phy-hi3670-usb3.yaml | 72 -- > > 9 files changed, 759 insertions(+), 754 deletions(-) > > create mode 100644 > > Documentation/devicetree/bindings/phy/phy-hi3670-usb3.yaml > > create mode 100644 drivers/phy/hisilicon/phy-hi3670-usb3.c > > delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.c > > delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.yaml > > > > diff --git a/Documentation/devicetree/bindings/phy/phy-hi3670-usb3.yaml > > b/Documentation/devicetree/bindings/phy/phy-hi3670-usb3.yaml > > new file mode 100644 > > index ..125a5d6546ae > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/phy/phy-hi3670-usb3.yaml > > @@ -0,0 +1,72 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/phy/hisilicon,hi3670-usb3.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Hisilicon Kirin970 USB PHY > > + > > +maintainers: > > + - Mauro Carvalho Chehab > > Blank line. Ok. > > > +description: |+ > > + Bindings for USB3 PHY on HiSilicon Kirin 970. > > + > > +properties: > > + compatible: > > +const: hisilicon,hi3670-usb-phy > > + > > + "#phy-cells": > > +const: 0 > > + > > + hisilicon,pericrg-syscon: > > +$ref: '/schemas/types.yaml#/definitions/phandle' > > +description: phandle of syscon used to control iso refclk. > > + > > + hisilicon,pctrl-syscon: > > +$ref: '/schemas/types.yaml#/definitions/phandle' > > +description: phandle of syscon used to control usb tcxo. > > + > > + hisilicon,sctrl-syscon: > > +$ref: '/schemas/types.yaml#/definitions/phandle' > > +description: phandle of syscon used to control phy deep sleep. > > + > > + hisilicon,eye-diagram-param: > > +$ref: /schemas/types.yaml#/definitions/uint32 > > +description: Eye diagram for phy. > > + > > + hisilicon,tx-vboost-lvl: > > +$ref: /schemas/types.yaml#/definitions/uint32 > > +description: TX level vboost for phy. > > + > > +required: > > + - compatible > > + - hisilicon,pericrg-syscon > > + - hisilicon,pctrl-syscon > > + - hisilicon,sctrl-syscon > > + - hisilicon,eye-diagram-param > > + - hisilicon,tx-vboost-lvl > > + - "#phy-cells" > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > +bus { > > + #address-cells = <2>; > > + #size-cells = <2>; > > + > > + usb3_otg_bc: usb3_otg_bc@ff20 { > > +compatible = "syscon", "simple-mfd"; > > +reg = <0x0 0xff20 0x0 0x1000>; > > + > > +usb_phy { > > Is there a contiguous register region for this sub-block? If so, add > 'reg' even though Linux doesn't need it currently. No. The driver uses 4 syscon regions in order to access the needed registers: priv->peri_crg = syscon_regmap_lookup_by_phandle(dev->of_node, "hisilicon,pericrg-syscon"); if (IS_ERR(priv->peri_crg)) { dev_err(dev, "no hisilicon,pericrg-syscon\n"); return PTR_ERR(priv->peri_crg); } priv->pctrl = syscon_regmap_lookup_by_phandle(dev->of_node, "hisilicon,pctrl-syscon"); if (IS_ERR(priv->pctrl)) { dev_err(dev, "no hisilicon,pctrl-syscon\n"); return PTR_ERR(priv->pctrl); } priv->sctrl = syscon_regmap_lookup_by_phandle(dev->of_node, "hisilicon,sctrl-syscon"); if (IS_ERR(priv->sctrl)) { dev_err(dev, "no hisilicon,sctrl-syscon\n"); return PTR_ERR(priv->sctrl); } /* node of hi3670 phy is a sub-node of usb3_otg_bc */ priv->usb31misc = syscon_node_to_regmap(dev->parent->of_node); if (IS_ERR(priv->usb31misc)) { dev_err(dev, "no hisilicon,usb3-otg-bc-syscon\n"); return PTR_ERR(priv->usb31misc); } So, I don't see what an additional reg would help here. > > + compatible = "hisilicon,hi3670-usb-phy"; > > + #phy-cells = <0>; >
[PATCH v4 4/5] staging: hikey9xx: phy-hi3670-usb3.yaml: add a blank line
Add a blank line after maintainers field. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/phy-hi3670-usb3.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/hikey9xx/phy-hi3670-usb3.yaml b/drivers/staging/hikey9xx/phy-hi3670-usb3.yaml index 125a5d6546ae..ebd78acfe2de 100644 --- a/drivers/staging/hikey9xx/phy-hi3670-usb3.yaml +++ b/drivers/staging/hikey9xx/phy-hi3670-usb3.yaml @@ -8,6 +8,7 @@ title: Hisilicon Kirin970 USB PHY maintainers: - Mauro Carvalho Chehab + description: |+ Bindings for USB3 PHY on HiSilicon Kirin 970. -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 2/5] staging: hikey9xx: phy-hi3670-usb3: adjust retry logic
Instead of running a loop up to 100k times, add a small delay inside it, running it up to 10 times, waiting up to 100-200 us. It should be noticed that I don't have the datasheet for this PHY. So, not sure if this time will cover all situations. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/phy-hi3670-usb3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hikey9xx/phy-hi3670-usb3.c b/drivers/staging/hikey9xx/phy-hi3670-usb3.c index 722cabaa9bd9..cffe6c58dfd7 100644 --- a/drivers/staging/hikey9xx/phy-hi3670-usb3.c +++ b/drivers/staging/hikey9xx/phy-hi3670-usb3.c @@ -185,7 +185,7 @@ static int hi3670_phy_cr_start(struct regmap *usb31misc, int direction) static int hi3670_phy_cr_wait_ack(struct regmap *usb31misc) { u32 reg; - int retry = 10; + int retry = 10; int ret; while (retry-- > 0) { @@ -198,6 +198,8 @@ static int hi3670_phy_cr_wait_ack(struct regmap *usb31misc) ret = hi3670_phy_cr_clk(usb31misc); if (ret) return ret; + + usleep_range(10, 20); } return -ETIMEDOUT; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 0/5] Promote Hikey 970 USB phy out of staging
Hi Vinod/Rob, This series moves the Hikey 970 USB PHY driver out of staging. Patches 1 to 4 contain the fixes from staging. Patch 5 moves the driver from staging: $ git show 82ce73ac9a38 --summary ... rename drivers/staging/hikey9xx/phy-hi3670-usb3.yaml => Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml (100%) rename drivers/{staging/hikey9xx => phy/hisilicon}/phy-hi3670-usb3.c (100%) I opted to use --no-renames on this series in order to make easier to review via e-mail, as the entire driver and DT bindings will be seen at the last patch on this series. v4: - do additional changes at the hi3670_is_abbclk_seleted() function, fixing the typo on its name and reversing the bool return code; - the yaml fix is now on a separate patch. v3: - no changes on patches 1-2 nor at phy-hi3670-usb3.c; - yaml renamed to: hisilicon,hi3670-usb3.yaml - Added a blank line after maintainers at hisilicon,hi3670-usb3.yaml Mauro Carvalho Chehab (5): staging: hikey9xx: phy-hi3670-usb3: use bitfield macros staging: hikey9xx: phy-hi3670-usb3: adjust retry logic staging: hikey9xx: phy-hi3670-usb3: hi3670_is_abbclk_seleted() returns bool staging: hikey9xx: phy-hi3670-usb3.yaml: add a blank line phy: phy-hi3670-usb3: move driver from staging into phy .../bindings/phy/hisilicon,hi3670-usb3.yaml | 73 ++ MAINTAINERS | 9 +- drivers/phy/hisilicon/Kconfig | 10 + drivers/phy/hisilicon/Makefile| 1 + drivers/phy/hisilicon/phy-hi3670-usb3.c | 668 + drivers/staging/hikey9xx/Kconfig | 11 - drivers/staging/hikey9xx/Makefile | 2 - drivers/staging/hikey9xx/phy-hi3670-usb3.c| 671 -- drivers/staging/hikey9xx/phy-hi3670-usb3.yaml | 72 -- 9 files changed, 760 insertions(+), 757 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml create mode 100644 drivers/phy/hisilicon/phy-hi3670-usb3.c delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.c delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.yaml -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 3/5] staging: hikey9xx: phy-hi3670-usb3: hi3670_is_abbclk_seleted() returns bool
There are a few issues on this function: 1. Instead of using 1/0 for true/false, change the type to boolean; 2. there's a typo there: seleted -> selected 3. It's logic is reversed. Address them. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/phy-hi3670-usb3.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/hikey9xx/phy-hi3670-usb3.c b/drivers/staging/hikey9xx/phy-hi3670-usb3.c index cffe6c58dfd7..8918f3665f8e 100644 --- a/drivers/staging/hikey9xx/phy-hi3670-usb3.c +++ b/drivers/staging/hikey9xx/phy-hi3670-usb3.c @@ -326,24 +326,24 @@ static int hi3670_phy_set_params(struct hi3670_priv *priv) return ret; } -static int hi3670_is_abbclk_seleted(struct hi3670_priv *priv) +static bool hi3670_is_abbclk_selected(struct hi3670_priv *priv) { u32 reg; if (!priv->sctrl) { dev_err(priv->dev, "priv->sctrl is null!\n"); - return 1; + return false; } if (regmap_read(priv->sctrl, SCTRL_SCDEEPSLEEPED, ®)) { dev_err(priv->dev, "SCTRL_SCDEEPSLEEPED read failed!\n"); - return 1; + return false; } if ((reg & USB_CLK_SELECTED) == 0) - return 1; + return false; - return 0; + return true; } static int hi3670_config_phy_clock(struct hi3670_priv *priv) @@ -351,7 +351,7 @@ static int hi3670_config_phy_clock(struct hi3670_priv *priv) u32 val, mask; int ret; - if (hi3670_is_abbclk_seleted(priv)) { + if (!hi3670_is_abbclk_selected(priv)) { /* usb refclk iso disable */ ret = regmap_write(priv->peri_crg, PERI_CRG_ISODIS, USB_REFCLK_ISO_EN); @@ -568,7 +568,7 @@ static int hi3670_phy_exit(struct phy *phy) if (ret) goto out; - if (hi3670_is_abbclk_seleted(priv)) { + if (!hi3670_is_abbclk_selected(priv)) { /* disable usb_tcxo_en */ ret = regmap_write(priv->pctrl, PCTRL_PERI_CTRL3, USB_TCXO_EN << PCTRL_PERI_CTRL3_MSK_START); -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 1/5] staging: hikey9xx: phy-hi3670-usb3: use bitfield macros
Cleanup the bitfield macros by using FIELD_PREP() and GENMASK(). While here, place all hexadecimal values in lowercase. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/phy-hi3670-usb3.c | 61 ++ 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/drivers/staging/hikey9xx/phy-hi3670-usb3.c b/drivers/staging/hikey9xx/phy-hi3670-usb3.c index 4fc013911a78..722cabaa9bd9 100644 --- a/drivers/staging/hikey9xx/phy-hi3670-usb3.c +++ b/drivers/staging/hikey9xx/phy-hi3670-usb3.c @@ -8,6 +8,7 @@ * Authors: Yu Chen */ +#include #include #include #include @@ -41,15 +42,15 @@ #define SC_CLK_USB3PHY_3MUX1_SEL BIT(25) #define USB3OTG_CTRL0 (0x00) -#define USB3OTG_CTRL3 (0x0C) +#define USB3OTG_CTRL3 (0x0c) #define USB3OTG_CTRL4 (0x10) #define USB3OTG_CTRL5 (0x14) -#define USB3OTG_CTRL7 (0x1C) +#define USB3OTG_CTRL7 (0x1c) #define USB_MISC_CFG50 (0x50) #define USB_MISC_CFG54 (0x54) #define USB_MISC_CFG58 (0x58) -#define USB_MISC_CFG5C (0x5C) -#define USB_MISC_CFGA0 (0xA0) +#define USB_MISC_CFG5C (0x5c) +#define USB_MISC_CFGA0 (0xa0) #define TCA_CLK_RST(0x200) #define TCA_INTR_EN(0x204) #define TCA_INTR_STS (0x208) @@ -66,14 +67,14 @@ #define CTRL5_USB2_SIDDQ BIT(0) -#define CTRL7_USB2_REFCLKSEL_MASK (3 << 3) -#define CTRL7_USB2_REFCLKSEL_ABB (3 << 3) -#define CTRL7_USB2_REFCLKSEL_PAD (2 << 3) +#define CTRL7_USB2_REFCLKSEL_MASK GENMASK(4, 3) +#define CTRL7_USB2_REFCLKSEL_ABB (BIT(4) | BIT(3)) +#define CTRL7_USB2_REFCLKSEL_PAD BIT(4) #define CFG50_USB3_PHY_TEST_POWERDOWN BIT(23) -#define CFG54_USB31PHY_CR_ADDR_MASK(0x) -#define CFG54_USB31PHY_CR_ADDR_SHIFT (16) +#define CFG54_USB31PHY_CR_ADDR_MASKGENMASK(31, 16) + #define CFG54_USB3PHY_REF_USE_PAD BIT(12) #define CFG54_PHY0_PMA_PWR_STABLE BIT(11) #define CFG54_PHY0_PCS_PWR_STABLE BIT(9) @@ -84,8 +85,7 @@ #define CFG54_USB31PHY_CR_CLK BIT(2) #define CFG54_USB3_PHY0_ANA_PWR_EN BIT(1) -#define CFG58_USB31PHY_CR_DATA_MASK (0x) -#define CFG58_USB31PHY_CR_DATA_RD_START (16) +#define CFG58_USB31PHY_CR_DATA_MASK GENMASK(31, 16) #define CFG5C_USB3_PHY0_SS_MPLLA_SSC_ENBIT(1) @@ -102,20 +102,20 @@ #define CLK_RST_SUSPEND_CLK_EN BIT(0) #define GCFG_ROLE_HSTDEV BIT(4) -#define GCFG_OP_MODE (3 << 0) +#define GCFG_OP_MODE GENMASK(1, 0) #define GCFG_OP_MODE_CTRL_SYNC_MODEBIT(0) #define TCPC_VALID BIT(4) #define TCPC_LOW_POWER_EN BIT(3) -#define TCPC_MUX_CONTROL_MASK (3 << 0) +#define TCPC_MUX_CONTROL_MASK GENMASK(1, 0) #define TCPC_MUX_CONTROL_USB31 BIT(0) #define SYSMODE_CFG_TYPEC_DISABLE BIT(3) -#define VBUS_CTRL_POWERPRESENT_OVERRD (3 << 2) -#define VBUS_CTRL_VBUSVALID_OVERRD (3 << 0) +#define VBUS_CTRL_POWERPRESENT_OVERRD GENMASK(3, 2) +#define VBUS_CTRL_VBUSVALID_OVERRD GENMASK(1, 0) -#define KIRIN970_USB_DEFAULT_PHY_PARAM (0xFDFEE4) +#define KIRIN970_USB_DEFAULT_PHY_PARAM (0xfdfee4) #define KIRIN970_USB_DEFAULT_PHY_VBOOST(0x5) #define TX_VBOOST_LVL_REG (0xf) @@ -162,16 +162,14 @@ static int hi3670_phy_cr_set_sel(struct regmap *usb31misc) static int hi3670_phy_cr_start(struct regmap *usb31misc, int direction) { - int ret; + int ret, reg; if (direction) - ret = regmap_update_bits(usb31misc, USB_MISC_CFG54, -CFG54_USB31PHY_CR_WR_EN, -CFG54_USB31PHY_CR_WR_EN); + reg = CFG54_USB31PHY_CR_WR_EN; else - ret = regmap_update_bits(usb31misc, USB_MISC_CFG54, -CFG54_USB31PHY_CR_RD_EN, -CFG54_USB31PHY_CR_RD_EN); + reg = CFG54_USB31PHY_CR_RD_EN; + + ret = regmap_update_bits(usb31misc, USB_MISC_CFG54, reg, reg); if (ret) return ret; @@ -180,10 +178,8 @@ static int hi3670_phy_cr_start(struct regmap *usb31misc, int direction) if (ret) return ret; - ret = regmap_update_bits(usb31misc, USB_MISC_CFG54, -CFG54_USB31PHY_CR_RD_EN | CFG54_USB31PHY_CR_WR_EN, 0); - - return ret; + return regmap_update_bits(usb31misc, USB_MISC_CFG54, + CFG54_USB31PHY_CR_RD_EN | CFG54_USB31PHY_CR_WR_EN, 0); } static int hi3670_phy_cr_wait_ack(struct regmap *usb31misc) @@ -216,9 +212,9 @@ static int hi3670_phy_cr_set_addr(struct regmap *usb31misc, u32 addr) if
[PATCH v4 5/5] phy: phy-hi3670-usb3: move driver from staging into phy
The phy USB3 driver for Hisilicon 970 (hi3670) is ready for mainstream. Mode it from staging into the main driver's phy/ directory. Signed-off-by: Mauro Carvalho Chehab --- .../bindings/phy/hisilicon,hi3670-usb3.yaml | 73 ++ MAINTAINERS | 9 +- drivers/phy/hisilicon/Kconfig | 10 + drivers/phy/hisilicon/Makefile| 1 + drivers/phy/hisilicon/phy-hi3670-usb3.c | 668 ++ drivers/staging/hikey9xx/Kconfig | 11 - drivers/staging/hikey9xx/Makefile | 2 - drivers/staging/hikey9xx/phy-hi3670-usb3.c| 668 -- drivers/staging/hikey9xx/phy-hi3670-usb3.yaml | 73 -- 9 files changed, 760 insertions(+), 755 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml create mode 100644 drivers/phy/hisilicon/phy-hi3670-usb3.c delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.c delete mode 100644 drivers/staging/hikey9xx/phy-hi3670-usb3.yaml diff --git a/Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml b/Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml new file mode 100644 index ..ebd78acfe2de --- /dev/null +++ b/Documentation/devicetree/bindings/phy/hisilicon,hi3670-usb3.yaml @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/hisilicon,hi3670-usb3.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hisilicon Kirin970 USB PHY + +maintainers: + - Mauro Carvalho Chehab + +description: |+ + Bindings for USB3 PHY on HiSilicon Kirin 970. + +properties: + compatible: +const: hisilicon,hi3670-usb-phy + + "#phy-cells": +const: 0 + + hisilicon,pericrg-syscon: +$ref: '/schemas/types.yaml#/definitions/phandle' +description: phandle of syscon used to control iso refclk. + + hisilicon,pctrl-syscon: +$ref: '/schemas/types.yaml#/definitions/phandle' +description: phandle of syscon used to control usb tcxo. + + hisilicon,sctrl-syscon: +$ref: '/schemas/types.yaml#/definitions/phandle' +description: phandle of syscon used to control phy deep sleep. + + hisilicon,eye-diagram-param: +$ref: /schemas/types.yaml#/definitions/uint32 +description: Eye diagram for phy. + + hisilicon,tx-vboost-lvl: +$ref: /schemas/types.yaml#/definitions/uint32 +description: TX level vboost for phy. + +required: + - compatible + - hisilicon,pericrg-syscon + - hisilicon,pctrl-syscon + - hisilicon,sctrl-syscon + - hisilicon,eye-diagram-param + - hisilicon,tx-vboost-lvl + - "#phy-cells" + +additionalProperties: false + +examples: + - | +bus { + #address-cells = <2>; + #size-cells = <2>; + + usb3_otg_bc: usb3_otg_bc@ff20 { +compatible = "syscon", "simple-mfd"; +reg = <0x0 0xff20 0x0 0x1000>; + +usb_phy { + compatible = "hisilicon,hi3670-usb-phy"; + #phy-cells = <0>; + hisilicon,pericrg-syscon = <&crg_ctrl>; + hisilicon,pctrl-syscon = <&pctrl>; + hisilicon,sctrl-syscon = <&sctrl>; + hisilicon,eye-diagram-param = <0xfdfee4>; + hisilicon,tx-vboost-lvl = <0x5>; +}; + }; +}; diff --git a/MAINTAINERS b/MAINTAINERS index 281de213ef47..8d858e8d5a52 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18088,7 +18088,7 @@ L: linux-...@vger.kernel.org S: Maintained F: drivers/usb/roles/intel-xhci-usb-role-switch.c -USB IP DRIVER FOR HISILICON KIRIN +USB IP DRIVER FOR HISILICON KIRIN 960 M: Yu Chen M: Binghui Wang L: linux-...@vger.kernel.org @@ -18096,6 +18096,13 @@ S: Maintained F: Documentation/devicetree/bindings/phy/hisilicon,hi3660-usb3.yaml F: drivers/phy/hisilicon/phy-hi3660-usb3.c +USB IP DRIVER FOR HISILICON KIRIN 970 +M: Mauro Carvalho Chehab +L: linux-...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/phy/hisilicon,kirin970-usb3.yaml +F: drivers/phy/hisilicon/phy-kirin970-usb3.c + USB ISP116X DRIVER M: Olav Kongas L: linux-...@vger.kernel.org diff --git a/drivers/phy/hisilicon/Kconfig b/drivers/phy/hisilicon/Kconfig index 1c73053bcc98..4d008cfc279c 100644 --- a/drivers/phy/hisilicon/Kconfig +++ b/drivers/phy/hisilicon/Kconfig @@ -23,6 +23,16 @@ config PHY_HI3660_USB To compile this driver as a module, choose M here. +config PHY_HI3670_USB + tristate "hi3670 USB PHY support" + depends on (ARCH_HISI && ARM64) || COMPILE_TEST + select GENERIC_PHY + select MFD_SYSCON + help + Enable this to support the HISILICON HI3670 USB PHY. + + To compile this driver as a module, choose M here. + config PHY_HISTB_COMBPHY tristate "HiSilicon STB SoCs COMBPHY support" depends on (ARCH_HISI && ARM64) || COMPILE_TEST diff --git a/drivers/phy/hisilicon/Makefile b/drivers/phy/hisilicon/Makefile index 92e874ae9
Re: [PATCH v3 15/18] mfd: hi6421-spmi-pmic: move driver from staging
On Tue, Jan 19, 2021 at 11:14:20AM +0100, Mauro Carvalho Chehab wrote: > +int hi6421_spmi_pmic_read(struct hi6421_spmi_pmic *pmic, int reg) > +{ > + struct spmi_device *pdev; > + u8 read_value = 0; > + u32 ret; > + > + pdev = to_spmi_device(pmic->dev); > + if (!pdev) { > + pr_err("%s: pdev get failed!\n", __func__); > + return -ENODEV; > + } > + > + ret = spmi_ext_register_readl(pdev, reg, &read_value, 1); > + if (ret) { > + pr_err("%s: spmi_ext_register_readl failed!\n", __func__); > + return ret; > + } > + return read_value; > +} > +EXPORT_SYMBOL(hi6421_spmi_pmic_read); The I/O here looks a lot like regmap_spmi_ext. signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 15/18] mfd: hi6421-spmi-pmic: move driver from staging
Em Tue, 19 Jan 2021 13:46:22 + Mark Brown escreveu: > On Tue, Jan 19, 2021 at 11:14:20AM +0100, Mauro Carvalho Chehab wrote: > > > +int hi6421_spmi_pmic_read(struct hi6421_spmi_pmic *pmic, int reg) > > +{ > > + struct spmi_device *pdev; > > + u8 read_value = 0; > > + u32 ret; > > + > > + pdev = to_spmi_device(pmic->dev); > > + if (!pdev) { > > + pr_err("%s: pdev get failed!\n", __func__); > > + return -ENODEV; > > + } > > + > > + ret = spmi_ext_register_readl(pdev, reg, &read_value, 1); > > + if (ret) { > > + pr_err("%s: spmi_ext_register_readl failed!\n", __func__); > > + return ret; > > + } > > + return read_value; > > +} > > +EXPORT_SYMBOL(hi6421_spmi_pmic_read); > > The I/O here looks a lot like regmap_spmi_ext. Did a test here converting it to use regmap. It worked. I'm sending a (hopefully) final patchset. Regards, Mauro ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 09/21] staging: hikey9xx: hi6421v600-regulator: update copyright
Remove the GPL boilerplate, as SPDX tag already points to the license terms and add a new copyright for Huawei. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 564d86f0e4dc..5e78eebfc1f3 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -4,17 +4,9 @@ // // Copyright (c) 2013 Linaro Ltd. // Copyright (c) 2011 Hisilicon. +// Copyright (c) 2020-2021 Huawei Technologies Co., Ltd // // Guodong Xu -// -// 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 #include -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 07/21] staging: hikey9xx: hi6421v600-regulator: get rid of an static data
Move it to be inside the private data struct. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 54ad07418ec2..e25e596f58cf 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -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[] = { 150, 155, 160, 165, @@ -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 */ -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 13/21] staging: hikey9xx: hisilicon, hi6421-spmi-pmic.yaml: cleanup a warning
There's no additionalProperties field at the yaml file, causing a warning when checking it. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml index f385146d2bd1..3b23ad56b31a 100644 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml @@ -60,6 +60,8 @@ required: - reg - regulators +additionalProperties: false + examples: - | /* pmic properties */ -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 00/21] Move Hisilicon 6421v600 SPMI driver set out of staging
Hi Mark/Lee, 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=hikey970-destage-usb In order to make easier for review, this series was generated with --no-renames. So, you don't need to take a look at the staging patches, as the entire code will be there on patches 9-11. The last two patches on this series will likely require that other patch series to get merged first. It probably makes sense to be merged via DT tree. Regards, Mauro v4: - use regmap for mfd and spmi drivers; - a few minor cleanups at the mfd driver. v3: - fixed a bug with eco-mode at get_optimum_mode; - changed the sleep logic when enabling/disabling a power line; - additional cleanups, as requested by Mark. v2: - 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. Mauro Carvalho Chehab (21): staging: hikey9xx: hisilicon,hisi-spmi-controller.yaml fix bindings staging: hikey9xx: hisilicon,hi6421-spmi-pmic.yaml: simplify props 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: hi6421v600-regulator: get rid of an static data staging: hikey9xx: hi6421v600-regulator: do some cleanups staging: hikey9xx: hi6421v600-regulator: update copyright staging: hikey9xx: hi6421v600-regulator: fix delay logic staging: hikey9xx: hi6421v600-regulator: cleanup comments staging: hikey9xx: hi6421v600-regulator: fix get_optimum_mode staging: hikey9xx: hisilicon,hi6421-spmi-pmic.yaml: cleanup a warning staging: hikey9xx: spmi driver: convert to regmap staging: hikey9xx: hi6421-spmi-pmic: update copyright staging: hikey9xx: simplify includes spmi: hisi-spmi-controller: 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| 281 ++ drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile| 1 + drivers/regulator/hi6421v600-regulator.c | 338 + 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 --- include/linux/mfd/hi6421-spmi-pmic.h | 8 +- 26 files changed, 1486 insertions(+), 1478 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/sta
[PATCH v4 16/21] staging: hikey9xx: simplify includes
There are several uneeded includes. Remove them. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index 9310a9d699bc..99c4f3359f71 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -7,20 +7,12 @@ // // Copyright (c) 2020-2021 Huawei Technologies Co., Ltd -#include -#include -#include #include -#include #include #include #include #include -#include -#include #include -#include -#include #include #include #include -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 02/21] staging: hikey9xx: hisilicon, hi6421-spmi-pmic.yaml: simplify props
As all regulator-specific properties got moved to be part of the driver, remove them from the DT spec. Signed-off-by: Mauro Carvalho Chehab --- .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 106 +++--- 1 file changed, 40 insertions(+), 66 deletions(-) diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml index 80e74c261e05..f385146d2bd1 100644 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml @@ -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 = <150>; regulator-max-microvolt = <200>; regulator-boot-on; - - enable-mask = <0x01>; - - voltage-table = <150>, <155>, <160>, <165>, - <170>, <1725000>, <175>, <1775000>, - <180>, <1825000>, <185>, <1875000>, - <190>, <1925000>, <195>, <200>; - off-on-delay-us = <2>; - 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 = <190>; regulator-boot-on; +}; - enable-mask = <0x01>; - idle-mode-mask = <0x10>; - eco-microamp = <1>; +ldo9: LDO9 { + regulator-name = "ldo9"; + regulator-min-microvolt = <175>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; - hi6421-vsel = <0x52 0x07>; - voltage-table = <1725000>, <175>, <1775000>, <180>, - <1825000>, <185>, <1875000>, <190>; - off-on-delay-us = <2>; - startup-delay-us = <120>; +ldo15: LDO15 { + regulator-name = "ldo15"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-always-on; +}; + +ldo16: LDO16 { + regulator-name = "ldo16"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-boot-on; +}; + +ldo17: LDO17 { + regulator-name = "ldo17"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; +}; + +ldo33: LDO33 { + regulator-name = "ldo33"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; + +ldo34: LDO34 { + regulator-name = "ldo34"; + regulator-min-microvolt = <260>; + regulator-max-microvolt = <330>; }; }; }; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 03/21] staging: hikey9xx: hisi-spmi-controller: clean sparse warnings
Sparse 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 __be32 The conversions there are valid ones. So, add __force macro to disable such warnings. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hisi-spmi-controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hikey9xx/hisi-spmi-controller.c b/drivers/staging/hikey9xx/hisi-spmi-controller.c index f831c43f4783..4be2344ad7b5 100644 --- a/drivers/staging/hikey9xx/hisi-spmi-controller.c +++ b/drivers/staging/hikey9xx/hisi-spmi-controller.c @@ -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); -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 10/21] staging: hikey9xx: hi6421v600-regulator: fix delay logic
The original driver, which can be seen at commit 42f24d9d446a ("staging: regulator: add a regulator driver for HiSilicon 6421v600 SPMI PMIC") had a complex logic to ensure that there won't be multiple power enable/disable commands running at the same time. At the original logic, it were ensured that: - a next power up/down would wait for at least the on/off period; - an extra delay would be granted. It turns that such extra delay has a value of zero, but it was relying on gettimeofday() call, which can take some time. This was later simplified, but there are still some possible issues. In order to avoid that, let's simply add a delay to wait for the power up line to stabilize after powering up a device. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 5 +++-- include/linux/mfd/hi6421-spmi-pmic.h| 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 5e78eebfc1f3..e5a492ee7121 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -113,14 +113,15 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) /* 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); + /* Avoid powering up multiple devices at the same time */ + usleep_range(rdev->desc->off_on_delay, rdev->desc->off_on_delay + 60); + mutex_unlock(&sreg->enable_mutex); return ret; diff --git a/include/linux/mfd/hi6421-spmi-pmic.h b/include/linux/mfd/hi6421-spmi-pmic.h index 2c8896fd852e..0c2214612c4e 100644 --- a/include/linux/mfd/hi6421-spmi-pmic.h +++ b/include/linux/mfd/hi6421-spmi-pmic.h @@ -13,7 +13,6 @@ #include -#define HISI_REGS_ENA_PROTECT_TIME (0) /* in microseconds */ #define HISI_ECO_MODE_ENABLE (1) #define HISI_ECO_MODE_DISABLE (0) -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 06/21] staging: hikey9xx: hi6421v600-regulator: cleanup debug msgs
While 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. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 47 ++- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 72e301596735..54ad07418ec2 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -23,9 +23,6 @@ #include #include -#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,
[PATCH v4 18/21] mfd: hi6421-spmi-pmic: move driver from staging
This driver is ready for mainstream. So, move it out of staging. Signed-off-by: Mauro Carvalho Chehab --- .../mfd/hisilicon,hi6421-spmi-pmic.yaml | 135 + MAINTAINERS | 7 + drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c| 281 ++ drivers/staging/hikey9xx/Kconfig | 16 - drivers/staging/hikey9xx/Makefile | 1 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 281 -- .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 135 - 9 files changed, 439 insertions(+), 433 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 diff --git a/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml b/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml new file mode 100644 index ..3b23ad56b31a --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml @@ -0,0 +1,135 @@ +# 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 + +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 + +additionalProperties: false + +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 = <150>; + regulator-max-microvolt = <200>; + regulator-boot-on; +}; + +ldo4: LDO4 { + regulator-name = "ldo4"; + regulator-min-microvolt = <1725000>; + regulator-max-microvolt = <190>; + regulator-boot-on; +}; + +ldo9: LDO9 { + regulator-name = "ldo9"; + regulator-min-microvolt = <175>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; + +ldo15: LDO15 { + regulator-name = "ldo15"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-always-on; +}; + +ldo16: LDO16 { + regulator-name = "ldo16"; + regulator-min-microvolt = <180>; + regulator-max-microvolt = <300>; + regulator-boot-on; +}; + +ldo17: LDO17 { + regulator-name = "ldo17"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; +}; + +ldo33: LDO33 { + regulator-name = "ldo33"; + regulator-min-microvolt = <250>; + regulator-max-microvolt = <330>; + regulator-boot-on; +}; + +ldo34: LDO34 { + regulator-name = "ldo34"; + regulator-min-microvolt = <260>; + regulator-max-microvolt = <330>; +}; + }; +}; diff --git a/MAINTAINERS b/MAINTAINERS index 85e5b6ab57ca..c5b36a58ede5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 +L: linux-ker...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +F: dri
[PATCH v4 14/21] staging: hikey9xx: spmi driver: convert to regmap
Instead of doing its own SPMI I/O implementation, use the already-existing regmap one. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 115 ++ .../staging/hikey9xx/hi6421v600-regulator.c | 26 ++-- include/linux/mfd/hi6421-spmi-pmic.h | 7 +- 3 files changed, 52 insertions(+), 96 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index 64b30d263c8d..de6da2779084 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -59,81 +59,22 @@ static const struct mfd_cell hi6421v600_devs[] = { { .name = "hi6421v600-regulator", }, }; -/* - * The PMIC register is only 8-bit. - * Hisilicon SoC use hardware to map PMIC register into SoC mapping. - * At here, we are accessing SoC register with 32-bit. - */ -int hi6421_spmi_pmic_read(struct hi6421_spmi_pmic *pmic, int reg) +static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv) { - struct spmi_device *pdev; - u8 read_value = 0; - u32 ret; - - pdev = to_spmi_device(pmic->dev); - if (!pdev) { - pr_err("%s: pdev get failed!\n", __func__); - return -ENODEV; - } - - ret = spmi_ext_register_readl(pdev, reg, &read_value, 1); - if (ret) { - pr_err("%s: spmi_ext_register_readl failed!\n", __func__); - return ret; - } - return read_value; -} -EXPORT_SYMBOL(hi6421_spmi_pmic_read); - -int hi6421_spmi_pmic_write(struct hi6421_spmi_pmic *pmic, int reg, u32 val) -{ - struct spmi_device *pdev; - u32 ret; - - pdev = to_spmi_device(pmic->dev); - if (!pdev) { - pr_err("%s: pdev get failed!\n", __func__); - return -ENODEV; - } - - ret = spmi_ext_register_writel(pdev, reg, (unsigned char *)&val, 1); - if (ret) - pr_err("%s: spmi_ext_register_writel failed!\n", __func__); - - return ret; -} -EXPORT_SYMBOL(hi6421_spmi_pmic_write); - -int hi6421_spmi_pmic_rmw(struct hi6421_spmi_pmic *pmic, int reg, -u32 mask, u32 bits) -{ - unsigned long flags; - u32 data; - int ret; - - spin_lock_irqsave(&pmic->lock, flags); - data = hi6421_spmi_pmic_read(pmic, reg) & ~mask; - data |= mask & bits; - ret = hi6421_spmi_pmic_write(pmic, reg, data); - spin_unlock_irqrestore(&pmic->lock, flags); - - return ret; -} -EXPORT_SYMBOL(hi6421_spmi_pmic_rmw); - -static irqreturn_t hi6421_spmi_irq_handler(int irq, void *data) -{ - struct hi6421_spmi_pmic *pmic = (struct hi6421_spmi_pmic *)data; + struct hi6421_spmi_pmic *pmic = (struct hi6421_spmi_pmic *)priv; unsigned long pending; + unsigned int data; int i, offset; for (i = 0; i < HISI_IRQ_ARRAY; i++) { - pending = hi6421_spmi_pmic_read(pmic, (i + SOC_PMIC_IRQ0_ADDR)); - pending &= HISI_MASK_FIELD; - if (pending != 0) - pr_debug("pending[%d]=0x%lx\n\r", i, pending); + regmap_read(pmic->map, offset, &data); + data &= HISI_MASK_FIELD; + if (data != 0) + pr_debug("data[%d]=0x%d\n\r", i, data); + regmap_write(pmic->map, i + SOC_PMIC_IRQ0_ADDR, data); - hi6421_spmi_pmic_write(pmic, (i + SOC_PMIC_IRQ0_ADDR), pending); + /* for_each_set_bit() macro requires unsigned long */ + pending = data; /* solve powerkey order */ if ((i == HISI_IRQ_KEY_NUM) && @@ -155,16 +96,18 @@ static irqreturn_t hi6421_spmi_irq_handler(int irq, void *data) static void hi6421_spmi_irq_mask(struct irq_data *d) { struct hi6421_spmi_pmic *pmic = irq_data_get_irq_chip_data(d); - u32 data, offset; unsigned long flags; + unsigned int data; + u32 offset; offset = (irqd_to_hwirq(d) >> 3); offset += SOC_PMIC_IRQ_MASK_0_ADDR; spin_lock_irqsave(&pmic->lock, flags); - data = hi6421_spmi_pmic_read(pmic, offset); + + regmap_read(pmic->map, offset, &data); data |= (1 << (irqd_to_hwirq(d) & 0x07)); - hi6421_spmi_pmic_write(pmic, offset, data); + regmap_write(pmic->map, offset, data); spin_unlock_irqrestore(&pmic->lock, flags); } @@ -178,9 +121,9 @@ static void hi6421_spmi_irq_unmask(struct irq_data *d) offset += SOC_PMIC_IRQ_MASK_0_ADDR; spin_lock_irqsave(&pmic->lock, flags); - data = hi6421_spmi_pmic_read(pmic, offset); + regmap_read(pmic->map, offset, &data); data &= ~(1 << (irqd_to_hwirq(d) & 0x07)); - hi6421_spmi_pmic_write(pmic, offset, data); + regmap_write(pmic->map, offset, data); spin_unlock_irqrestore(&pmic->lock, flags); } @@ -212,27 +155,36 @@ static const struct irq_domain_ops hi6421_spmi_dom
[PATCH v4 01/21] staging: hikey9xx: hisilicon, hisi-spmi-controller.yaml fix bindings
Fix a few warnings produced by make dt_binding_check. Signed-off-by: Mauro Carvalho Chehab --- .../hisilicon,hisi-spmi-controller.yaml | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml index f2a56fa4e78e..21f68a9c2df1 100644 --- a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml @@ -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 */ }; }; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 17/21] spmi: hisi-spmi-controller: move driver from staging
The Hisilicon 6421v600 SPMI driver is ready for mainstream. So, move it from staging. Signed-off-by: Mauro Carvalho Chehab --- .../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 diff --git a/Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml b/Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml new file mode 100644 index ..21f68a9c2df1 --- /dev/null +++ b/Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml @@ -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 + +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 */ +}; + }; +}; diff --git a/MAINTAINERS b/MAINTAINERS index 8d858e8d5a52..85e5b6ab57ca 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 +L: linux-ker...@vger.kernel.org +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 L: de...@driverdev.osuosl.org diff --git a/drivers/spmi/Kconfig b/drivers/spmi/Kconfig index a53bad541f1a..2874b6c26028 100644 --- a/drivers/spmi/Kconfig +++ b/drivers/spmi/Kconfig @@ -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 diff --git a/drivers/spmi/Makefile b/drivers/spmi/Makefile index 55a94cadeffe..6e092e6f290c 100644 --- a/drivers/spmi/Makefile +++ b/drivers/spmi/Makefile @@ -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 diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c new file mode 100644 index ..4be2344ad7b5 --- /dev/null +++ b/drivers/spmi/hisi-spmi-controller.c @@ -0,0 +1,358 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include
[PATCH v4 08/21] staging: hikey9xx: hi6421v600-regulator: do some cleanups
In 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. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 37 --- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index e25e596f58cf..564d86f0e4dc 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -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, @@ -164,16 +163,14 @@ static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev, struct hi6421_spmi_pmic *pmic = sreg->pmic; u32 reg_val; - if (unlikely(selector >= rdev->desc->n_voltages)) + if (selector >= rdev->desc->n_voltages) return -EINVAL; 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; @@ -344,12 +337,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"); -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 05/21] staging: hikey9xx: hi6421v600-regulator: move LDO config from DT
Instead of storing regulator LDO configuration inside the DT, move it to be part of the driver itself. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 381 +++--- 1 file changed, 153 insertions(+), 228 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 4ee0444b2b4e..72e301596735 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -16,35 +16,97 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +#include #include #include -#include #include -#include #include -#include -#include #include #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[] = { + 150, 155, 160, 165, + 170, 1725000, 175, 1775000, + 180, 1825000, 185, 1875000, + 190, 1925000, 195, 200 +}; + +static const unsigned int ldo4_voltages[] = { + 1725000, 175, 1775000, 180, + 1825000, 185, 1875000, 190 +}; + +static const unsigned int ldo9_voltages[] = { + 175, 180, 1825000, 280, + 285, 295, 300, 330 +}; + +static const unsigned int ldo15_voltages[] = { + 180, 185, 240, 260, + 270, 285, 295, 300 +}; + +static const unsigned int ldo17_voltages[] = { + 250, 260, 270, 280, + 300, 310, 320, 330 +}; + +static const unsigned int ldo34_voltages[] = { + 260, 270, 280, 290, + 300, 310, 320, 330 +}; + /* - * 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(
[PATCH v4 11/21] staging: hikey9xx: hi6421v600-regulator: cleanup comments
Remove obvious comments and fix the comment for the HI6421V600_LDO() macro. While on it, use kernel-doc notation for HI6421V600_LDO(), as kernel-doc can check if the arguments match its description. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 27 --- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index e5a492ee7121..9f096d4e46db 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -57,17 +57,17 @@ static const unsigned int ldo34_voltages[] = { 300, 310, 320, 330 }; -/* - * _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 +/** + * HI6421V600_LDO() - specify a LDO power line + * @_id: LDO id name string + * @vtable: voltage table + * @ereg: enable register + * @emask: enable mask + * @vreg: voltage select register + * @odelay: off/on delay time in uS + * @etime: enable 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) \ @@ -114,7 +114,6 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev) /* cannot enable more than one regulator at one time */ mutex_lock(&sreg->enable_mutex); - /* set enable register */ ret = hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, rdev->desc->enable_mask, rdev->desc->enable_mask); @@ -132,7 +131,6 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev) struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); struct hi6421_spmi_pmic *pmic = sreg->pmic; - /* set enable register to 0 */ return hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, rdev->desc->enable_mask, 0); } @@ -143,7 +141,6 @@ static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev) struct hi6421_spmi_pmic *pmic = sreg->pmic; u32 reg_val; - /* 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); @@ -198,7 +195,6 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev, return -EINVAL; } - /* set mode */ return hi6421_spmi_pmic_rmw(pmic, rdev->desc->enable_reg, sreg->eco_mode_mask, val); } @@ -304,7 +300,6 @@ static int hi6421_spmi_regulator_probe(struct platform_device *pdev) mutex_init(&sreg->enable_mutex); for (i = 0; i < ARRAY_SIZE(regulator_info); i++) { - /* assign per-regulator data */ info = ®ulator_info[i]; config.dev = pdev->dev.parent; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 19/21] regulator: hi6421v600-regulator: move it from staging
This driver is ready for mainstream. Move it out of staging. Signed-off-by: Mauro Carvalho Chehab --- MAINTAINERS | 7 +- drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile| 1 + drivers/regulator/hi6421v600-regulator.c | 338 ++ 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 | 338 -- 10 files changed, 348 insertions(+), 366 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 diff --git a/MAINTAINERS b/MAINTAINERS index c5b36a58ede5..138798bbb32e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8012,12 +8012,7 @@ L: linux-ker...@vger.kernel.org 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 -L: de...@driverdev.osuosl.org -S: Maintained -F: drivers/staging/hikey9xx/ +F: drivers/regulator/hi6421v600-regulator.c HISILICON TRUE RANDOM NUMBER GENERATOR V2 SUPPORT M: Zaibo Xu diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 020a00d6696b..ca983e5a7a4d 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -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 diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 6ebae516258e..45d1883de54b 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -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 diff --git a/drivers/regulator/hi6421v600-regulator.c b/drivers/regulator/hi6421v600-regulator.c new file mode 100644 index ..9e319fa11137 --- /dev/null +++ b/drivers/regulator/hi6421v600-regulator.c @@ -0,0 +1,338 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Device driver for regulators in Hisi IC +// +// Copyright (c) 2013 Linaro Ltd. +// Copyright (c) 2011 Hisilicon. +// Copyright (c) 2020-2021 Huawei Technologies Co., Ltd +// +// Guodong Xu + +#include +#include +#include +#include +#include +#include +#include + +struct hi6421_spmi_reg_info { + struct regulator_desc desc; + struct hi6421_spmi_pmic *pmic; + u8 eco_mode_mask; + u32 eco_uA; + + /* Serialize regulator enable logic */ + struct mutex enable_mutex; +}; + +static const unsigned int ldo3_voltages[] = { + 150, 155, 160, 165, + 170, 1725000, 175, 1775000, + 180, 1825000, 185, 1875000, + 190, 1925000, 195, 200 +}; + +static const unsigned int ldo4_voltages[] = { + 1725000, 175, 1775000, 180, + 1825000, 185, 1875000, 190 +}; + +static const unsigned int ldo9_voltages[] = { + 175, 180, 1825000, 280, + 285, 295, 300, 330 +}; + +static const unsigned int ldo15_voltages[] = { + 180, 185, 240, 260, + 270, 285, 295, 300 +}; + +static const unsigned int ldo17_voltages[] = { + 250, 260, 270, 280, + 300, 310, 320, 330 +}; + +static const unsigned int ldo34_voltages[] = { + 260, 270, 280, 290, + 300, 310, 320, 330 +}; + +/** + * HI6421V600_LDO() - specify a LDO power line + * @_id: LDO id name string + * @vtable: voltage table + * @ereg: enable register + * @emask: enable mask + * @vreg: voltage select register + * @odelay: off/on delay t
[PATCH v4 15/21] staging: hikey9xx: hi6421-spmi-pmic: update copyright
Remove the GPL boilerplate, as SPDX tag already points to the license terms and add a new copyright for Huawei. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 24 ++--- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index de6da2779084..9310a9d699bc 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -1,21 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 -/* - * Device driver for regulators in HISI PMIC IC - * - * Copyright (c) 2013 Linaro Ltd. - * Copyright (c) 2011 Hisilicon. - * - * - * 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 PMIC IC +// +// Copyright (c) 2013 Linaro Ltd. +// Copyright (c) 2011 Hisilicon. +// +// Copyright (c) 2020-2021 Huawei Technologies Co., Ltd #include #include -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 12/21] staging: hikey9xx: hi6421v600-regulator: fix get_optimum_mode
During the driver refactor, a regression broke the logic inside hi6421_spmi_regulator_get_optimum_mode(). Basically, if a LDO has eco_uA == 0, it doesn't support economic mode. So, it should return REGULATOR_MODE_NORMAL. If economic mode is supported, it can return either REGULATOR_MODE_IDLE or REGULATOR_MODE_NORMAL, depending on the load current. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/hi6421v600-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 9f096d4e46db..382a0b21643e 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -206,7 +206,7 @@ hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev, { struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev); - if (load_uA || ((unsigned int)load_uA > sreg->eco_uA)) + if (!sreg->eco_uA || ((unsigned int)load_uA > sreg->eco_uA)) return REGULATOR_MODE_NORMAL; return REGULATOR_MODE_IDLE; -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 04/21] staging: hikey9xx: hi6421v600-regulator: do some cleanups
Use C99 comments at the beginning of the file and remove uneeded includes. Signed-off-by: Mauro Carvalho Chehab --- .../staging/hikey9xx/hi6421v600-regulator.c | 43 +++ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c index 614b03c9ddfb..4ee0444b2b4e 100644 --- a/drivers/staging/hikey9xx/hi6421v600-regulator.c +++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c @@ -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 - * - * 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 +// +// 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 -#include -#include -#include #include #include -#include -#include #include #include #include #include #include #include -#include -#include #include -#include -#include #define rdev_dbg(rdev, fmt, arg...)\ pr_debug("%s: %s: " fmt, (rdev)->desc->name, __func__, ##arg) -- 2.29.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4 19/21] regulator: hi6421v600-regulator: move it from staging
On Tue, Jan 19, 2021 at 05:10:45PM +0100, Mauro Carvalho Chehab wrote: > +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) Now that the driver has been converted to regmap these are just duplicates of the regmap helpers. You may also be able to use them for the disable() and is_enabled() operations, I didn't confirm that that's OK with the device using multi-bit enable controls for some reason IIRC. signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4 19/21] regulator: hi6421v600-regulator: move it from staging
Em Tue, 19 Jan 2021 16:19:50 + Mark Brown escreveu: > On Tue, Jan 19, 2021 at 05:10:45PM +0100, Mauro Carvalho Chehab wrote: > > > +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) > > Now that the driver has been converted to regmap these are just > duplicates of the regmap helpers. You may also be able to use them for > the disable() and is_enabled() operations, I didn't confirm that that's > OK with the device using multi-bit enable controls for some reason IIRC. True. In order to avoid re-submitting 21 patches, I sent such change as patch 22/21 . Thanks, Mauro ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel