Re: [PATCH v4 19/21] regulator: hi6421v600-regulator: move it from staging

2021-01-20 Thread Mark Brown
On Wed, Jan 20, 2021 at 12:02:44AM +0100, Mauro Carvalho Chehab wrote:
> Mark Brown  escreveu:

> > 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 .

Unfortunately I can't actually apply the regulator bits as things are as
the MAINTAINERS changes are incremental against the prior patches in the
series.  What's the plan for getting these merged?


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 10/21] staging: hikey9xx: hi6421v600-regulator: fix delay logic

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 06/21] staging: hikey9xx: hi6421v600-regulator: cleanup debug msgs

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 07/21] staging: hikey9xx: hi6421v600-regulator: get rid of an static data

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 13/21] staging: hikey9xx: hisilicon, hi6421-spmi-pmic.yaml: cleanup a warning

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 04/21] staging: hikey9xx: hi6421v600-regulator: do some cleanups

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 15/21] staging: hikey9xx: hi6421-spmi-pmic: update copyright

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 20/21] regulator: hi6421v600-regulator: move it from staging

2021-01-20 Thread Mauro Carvalho Chehab
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 +
 .../hikey9xx => regulator}/hi6421v600-regulator.c  |  0
 drivers/staging/Kconfig|  2 --
 drivers/staging/Makefile   |  1 -
 drivers/staging/hikey9xx/Kconfig   | 10 --
 drivers/staging/hikey9xx/Makefile  |  2 --
 8 files changed, 10 insertions(+), 21 deletions(-)
 rename drivers/{staging/hikey9xx => regulator}/hi6421v600-regulator.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 120f14620f56..808fdcdd98ad 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/staging/hikey9xx/hi6421v600-regulator.c 
b/drivers/regulator/hi6421v600-regulator.c
similarity index 100%
rename from drivers/staging/hikey9xx/hi6421v600-regulator.c
rename to drivers/regulator/hi6421v600-regulator.c
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 2d0310448eba..e6c831c6 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -116,6 +116,4 @@ source "drivers/staging/qlge/Kconfig"
 
 source "drivers/staging/wfx/Kconfig"
 
-source "drivers/staging/hikey9xx/Kconfig"
-
 endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 757a892ab5b9..a3b1fd0622f9 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -48,4 +48,3 @@ obj-$(CONFIG_FIELDBUS_DEV) += fieldbus/
 obj-$(CONFIG_KPC2000)  += kpc2000/
 obj-$(CONFIG_QLGE) += qlge/
 obj-$(CONFIG_WFX)  += wfx/
-obj-y  += hikey9xx/
diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
index 76337be330f8..d77aa6db9b6e 100644
--- a/drivers/staging/hikey9xx/Kconfig
+++ b/drivers/staging/hikey9xx/Kconfig
@@ -10,13 +10,3 @@ config PHY_HI3670_USB
  Enable this to support the HISILICON HI3670 USB PHY.
 
  To compile this driver as a module, choose M here.
-
-# to be placed at drivers/regulator
-config REGULATOR_HI6421V600
-   tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
-   depends on MFD_HI6421_SPMI && OF
-   depends on REGULATOR
-   help
- This driver provides support for the voltage regulators on
- HiSilicon Hi6421v600 PMU / Codec IC.
- This is used on Kirin 3670 boards, like HiKey 970.
diff --git a/drivers/staging/hikey9xx/Makefile 
b/drivers/staging/hikey9xx/Makefile
index d26af65baf8b..f5e12c19ddf6 100644
--- a/drivers/staging/hikey9xx/Makefile
+++ b/drivers/staging/hikey9xx/Makefile
@@ -1,5 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_PHY_HI3670_USB)   += phy-hi3670-usb3.o
-
-obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
-- 
2.29.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproje

[PATCH v5 03/21] staging: hikey9xx: hisi-spmi-controller: clean sparse warnings

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 12/21] staging: hikey9xx: hi6421v600-regulator: fix get_optimum_mode

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 16/21] staging: hikey9xx: hi6421-spmi-pmic: simplify includes

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 09/21] staging: hikey9xx: hi6421v600-regulator: update copyright

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 11/21] staging: hikey9xx: hi6421v600-regulator: cleanup comments

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 19/21] mfd: hi6421-spmi-pmic: move driver from staging

2021-01-20 Thread Mauro Carvalho Chehab
This driver is ready for mainstream. So, move it out of staging.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../mfd}/hisilicon,hi6421-spmi-pmic.yaml |  0
 MAINTAINERS  |  7 +++
 drivers/mfd/Kconfig  | 15 +++
 drivers/mfd/Makefile |  1 +
 .../{staging/hikey9xx => mfd}/hi6421-spmi-pmic.c |  0
 drivers/staging/hikey9xx/Kconfig | 16 
 drivers/staging/hikey9xx/Makefile|  1 -
 7 files changed, 23 insertions(+), 17 deletions(-)
 rename {drivers/staging/hikey9xx => 
Documentation/devicetree/bindings/mfd}/hisilicon,hi6421-spmi-pmic.yaml (100%)
 rename drivers/{staging/hikey9xx => mfd}/hi6421-spmi-pmic.c (100%)

diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml 
b/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
similarity index 100%
rename from drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml
rename to Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
diff --git a/MAINTAINERS b/MAINTAINERS
index 056777397c68..120f14620f56 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/mfd/hi6421-spmi-pmic.c
+
 HISILICON STAGING DRIVERS FOR HIKEY 960/970
 M: Mauro Carvalho Chehab 
 L: de...@driverdev.osuosl.org
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 8b99a13669bf..c04c2f6be1d9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -509,6 +509,21 @@ config MFD_HI6421_PMIC
  menus in order to enable them.
  We communicate with the Hi6421 via memory-mapped I/O.
 
+config MFD_HI6421_SPMI
+   tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC"
+   depends on OF
+   depends on SPMI
+   select MFD_CORE
+   help
+ Add support for HiSilicon Hi6421v600 SPMI PMIC. Hi6421 includes
+ multi-functions, such as regulators, RTC, codec, Coulomb counter,
+ etc.
+
+ This driver includes core APIs _only_. You have to select
+ individual components like voltage regulators under corresponding
+ menus in order to enable them.
+ We communicate with the Hi6421v600 via a SPMI bus.
+
 config MFD_HI655X_PMIC
tristate "HiSilicon Hi655X series PMU/Codec IC"
depends on ARCH_HISI || COMPILE_TEST
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 1780019d2474..7744993c42bc 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -233,6 +233,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
 obj-$(CONFIG_MFD_IQS62X)   += iqs62x.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
+obj-$(CONFIG_MFD_HI6421_SPMI)  += hi6421-spmi-pmic.o
 obj-$(CONFIG_MFD_HI655X_PMIC)   += hi655x-pmic.o
 obj-$(CONFIG_MFD_DLN2) += dln2.o
 obj-$(CONFIG_MFD_RT5033)   += rt5033.o
diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c 
b/drivers/mfd/hi6421-spmi-pmic.c
similarity index 100%
rename from drivers/staging/hikey9xx/hi6421-spmi-pmic.c
rename to drivers/mfd/hi6421-spmi-pmic.c
diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
index 6dc9f9307510..76337be330f8 100644
--- a/drivers/staging/hikey9xx/Kconfig
+++ b/drivers/staging/hikey9xx/Kconfig
@@ -11,22 +11,6 @@ config PHY_HI3670_USB
 
  To compile this driver as a module, choose M here.
 
-# to be placed at drivers/mfd
-config MFD_HI6421_SPMI
-   tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC"
-   depends on OF
-   depends on SPMI
-   select MFD_CORE
-   help
- Add support for HiSilicon Hi6421v600 SPMI PMIC. Hi6421 includes
- multi-functions, such as regulators, RTC, codec, Coulomb counter,
- etc.
-
- This driver includes core APIs _only_. You have to select
- individual components like voltage regulators under corresponding
- menus in order to enable them.
- We communicate with the Hi6421v600 via a SPMI bus.
-
 # to be placed at drivers/regulator
 config REGULATOR_HI6421V600
tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
diff --git a/drivers/staging/hikey9xx/Makefile 
b/drivers/staging/hikey9xx/Makefile
index 64b419cf7bca..d26af65baf8b 100644
--- a/drivers/staging/hikey9xx/Makefile
+++ b/drivers/staging/hikey9xx/Makefile
@@ -2,5 +2,4 @@
 
 obj-$(CONFIG_PHY_HI3670_USB)   += phy-hi3670-usb3.o
 
-obj-$(CONFIG_MFD_HI6421_SPMI)  += hi6421-spmi-pmic.o
 obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
-- 
2.29.2

_

[PATCH v5 18/21] spmi: hisi-spmi-controller: move driver from staging

2021-01-20 Thread Mauro Carvalho Chehab
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 |  0
 MAINTAINERS   |  7 +++
 drivers/spmi/Kconfig  |  9 +
 drivers/spmi/Makefile |  1 +
 .../{staging/hikey9xx => spmi}/hisi-spmi-controller.c |  0
 drivers/staging/hikey9xx/Kconfig  | 11 ---
 drivers/staging/hikey9xx/Makefile |  1 -
 7 files changed, 17 insertions(+), 12 deletions(-)
 rename {drivers/staging/hikey9xx => 
Documentation/devicetree/bindings/spmi}/hisilicon,hisi-spmi-controller.yaml 
(100%)
 rename drivers/{staging/hikey9xx => spmi}/hisi-spmi-controller.c (100%)

diff --git a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml 
b/Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml
similarity index 100%
rename from drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
rename to 
Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml
diff --git a/MAINTAINERS b/MAINTAINERS
index 281de213ef47..056777397c68 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/staging/hikey9xx/hisi-spmi-controller.c 
b/drivers/spmi/hisi-spmi-controller.c
similarity index 100%
rename from drivers/staging/hikey9xx/hisi-spmi-controller.c
rename to drivers/spmi/hisi-spmi-controller.c
diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
index b29f5d5df134..6dc9f9307510 100644
--- a/drivers/staging/hikey9xx/Kconfig
+++ b/drivers/staging/hikey9xx/Kconfig
@@ -11,17 +11,6 @@ config PHY_HI3670_USB
 
  To compile this driver as a module, choose M here.
 
-# to be placed at drivers/spmi
-config SPMI_HISI3670
-   tristate "Hisilicon 3670 SPMI Controller"
-   select IRQ_DOMAIN_HIERARCHY
-   depends on HAS_IOMEM
-   depends on SPMI
-   help
- If you say yes to this option, support will be included for the
- built-in SPMI PMIC Arbiter interface on Hisilicon 3670
- processors.
-
 # to be placed at drivers/mfd
 config MFD_HI6421_SPMI
tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC"
diff --git a/drivers/staging/hikey9xx/Makefile 
b/drivers/staging/hikey9xx/Makefile
index 1924fadac952..64b419cf7bca 100644
--- a/drivers/staging/hikey9xx/Makefile
+++ b/drivers/staging/hikey9xx/Makefile
@@ -2,6 +2,5 @@
 
 obj-$(CONFIG_PHY_HI3670_USB)   += phy-hi3670-usb3.o
 
-obj-$(CONFIG_SPMI_HISI3670)+= hisi-spmi-controller.o
 obj-$(CONFIG_MFD_HI6421_SPMI)  += hi6421-spmi-pmic.o
 obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
-- 
2.29.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 00/21] Move Hisilicon 6421v600 SPMI driver set out of staging

2021-01-20 Thread Mauro Carvalho Chehab
Hi Mark/Lee,

This patch series finish addressing support for Hikey 970
SPMI controller, PMIC and regulators.

This version was generated with -M, in order to make easier
to merge upstream.  Also, rebased on the top of v5.10,
without any dependencies from the other patch series
I'm submitting for this board.

Yet,  patch 18 to 20 modifies drivers/staging/hikey9xx/Kconfig
and drivers/staging/hikey9xx/Makefile. So, trivial conflicts
will rise if they're applied via different trees, as they all
remove some lines from such files. 

Regards,
Mauro

v5:
- rebased to not depend on USB PHY patchset;
- removed an USB-specific DT binding;
- changed the subject of one of the patches;
- no driver nor DT contents were changed.

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: hi6421-spmi-pmic: simplify includes
  staging: hikey9xx: hi6421v600-regulator: use some regmap helpers
  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 the PMIC found on Hikey 970

 .../mfd/hisilicon,hi6421-spmi-pmic.yaml   | 135 +
 .../spmi}/hisilicon,hisi-spmi-controller.yaml |  19 +-
 MAINTAINERS   |  15 +-
 .../boot/dts/hisilicon/hi3670-hikey970.dts|  22 +-
 .../boot/dts/hisilicon/hikey970-pmic.dtsi |  87 
 drivers/mfd/Kconfig   |  15 +
 drivers/mfd/Makefile  |   1 +
 .../hikey9xx => mfd}/hi6421-spmi-pmic.c   | 147 ++
 drivers/regulator/Kconfig |   8 +
 drivers/regulator/Makefile|   1 +
 drivers/regulator/hi6421v600-regulator.c  | 299 +++
 drivers/spmi/Kconfig  |   9 +
 drivers/spmi/Makefile |   1 +
 .../hikey9xx => spmi}/hisi-spmi-controller.c  |   4 +-
 drivers/staging/Kconfig   |   2 -
 drivers/staging/Makefile  |   1 -
 drivers/staging/hikey9xx/Kconfig  |  37 --
 drivers/staging/hikey9xx/Makefile |   4 -
 .../staging/hikey9xx/hi6421v600-regulator.c   | 478 --
 .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml  | 159 --
 include/linux/mfd/hi6421-spmi-pmic.h  |   8 +-
 21 files changed, 634 insertions(+), 818 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml
 rename {drivers/staging/hikey9xx => 
Documentation/devicetree/bindings/spmi}/hisilicon,hisi-spmi-controller.yaml 
(84%)
 create mode 100644 arch/arm64/boot/dts/hisilicon/hikey970-pmic.dtsi
 rename drivers/{staging/hikey9xx => mfd}/hi6421-spmi-pmic.c (65%)
 create mode 100644 drivers/regulator/hi6421v600-regulator.c
 rename drivers/{staging/hikey9xx => spmi}/hisi-spmi-controller.c (99%)
 delete mode 100644 drivers/staging/hikey9xx/hi6421v600-regulator.c
 delete mode 100644 drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml

-- 
2.29.2


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 01/21] staging: hikey9xx: hisilicon, hisi-spmi-controller.yaml fix bindings

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 17/21] staging: hikey9xx: hi6421v600-regulator: use some regmap helpers

2021-01-20 Thread Mauro Carvalho Chehab
Now that the driver was ported to use regmap, let's use
some help functions in order to simplify the code a little
bit.

Suggested-by: Mark Brown 
Signed-off-by: Mauro Carvalho Chehab 
---
 .../staging/hikey9xx/hi6421v600-regulator.c   | 45 ++-
 1 file changed, 3 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c 
b/drivers/staging/hikey9xx/hi6421v600-regulator.c
index 9e319fa11137..7090107b9ec2 100644
--- a/drivers/staging/hikey9xx/hi6421v600-regulator.c
+++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c
@@ -95,17 +95,6 @@ static const unsigned int ldo34_voltages[] = {
.eco_uA = ecoamp,  \
}
 
-static int hi6421_spmi_regulator_is_enabled(struct regulator_dev *rdev)
-{
-   struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
-   struct hi6421_spmi_pmic *pmic = sreg->pmic;
-   u32 reg_val;
-
-   regmap_read(pmic->map, rdev->desc->enable_reg, ®_val);
-
-   return ((reg_val & rdev->desc->enable_mask) != 0);
-}
-
 static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
 {
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
@@ -136,34 +125,6 @@ static int hi6421_spmi_regulator_disable(struct 
regulator_dev *rdev)
  rdev->desc->enable_mask, 0);
 }
 
-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;
-
-   regmap_read(pmic->map, rdev->desc->vsel_reg, ®_val);
-
-   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,
-unsigned int selector)
-{
-   struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
-   struct hi6421_spmi_pmic *pmic = sreg->pmic;
-   u32 reg_val;
-
-   if (selector >= rdev->desc->n_voltages)
-   return -EINVAL;
-
-   reg_val = selector << (ffs(rdev->desc->vsel_mask) - 1);
-
-   /* set voltage selector */
-   return regmap_update_bits(pmic->map, rdev->desc->vsel_reg,
- rdev->desc->vsel_mask, reg_val);
-}
-
 static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev)
 {
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
@@ -214,13 +175,13 @@ hi6421_spmi_regulator_get_optimum_mode(struct 
regulator_dev *rdev,
 }
 
 static const struct regulator_ops hi6421_spmi_ldo_rops = {
-   .is_enabled = hi6421_spmi_regulator_is_enabled,
+   .is_enabled = regulator_is_enabled_regmap,
.enable = hi6421_spmi_regulator_enable,
.disable = hi6421_spmi_regulator_disable,
.list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_iterate,
-   .get_voltage_sel = hi6421_spmi_regulator_get_voltage_sel,
-   .set_voltage_sel = hi6421_spmi_regulator_set_voltage_sel,
+   .get_voltage_sel = regulator_get_voltage_sel_regmap,
+   .set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_mode = hi6421_spmi_regulator_get_mode,
.set_mode = hi6421_spmi_regulator_set_mode,
.get_optimum_mode = hi6421_spmi_regulator_get_optimum_mode,
-- 
2.29.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 05/21] staging: hikey9xx: hi6421v600-regulator: move LDO config from DT

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 08/21] staging: hikey9xx: hi6421v600-regulator: do some cleanups

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 02/21] staging: hikey9xx: hisilicon, hi6421-spmi-pmic.yaml: simplify props

2021-01-20 Thread Mauro Carvalho Chehab
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 v5 14/21] staging: hikey9xx: spmi driver: convert to regmap

2021-01-20 Thread Mauro Carvalho Chehab
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

Re: [PATCH v4 19/21] regulator: hi6421v600-regulator: move it from staging

2021-01-20 Thread Mauro Carvalho Chehab
Em Wed, 20 Jan 2021 17:07:44 +
Mark Brown  escreveu:

> On Wed, Jan 20, 2021 at 12:02:44AM +0100, Mauro Carvalho Chehab wrote:
> > Mark Brown  escreveu:  
> 
> > > 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 .  
> 
> Unfortunately I can't actually apply the regulator bits as things are as
> the MAINTAINERS changes are incremental against the prior patches in the
> series.  What's the plan for getting these merged?

I submitted the USB3 PHY patch series to Vinod on Jan, 19. There's also a 
second series with 3 dts patches, submitted to Rob on Jan, 15 which is
needed by the USB3 PHY dts file, but this doesn't affect the regulator
series. I'm currently waiting for review on such series.

In any case, just sent you a v5 of this patch series that doesn't depend
on the USB3 PHY related patches. As they'll be applied on a different
tree, it is expected a conflict at linux-next when both gets merged,
which will be trivial: the fix would be to simply remove all lines
from drivers/staging/hikey9xx/Makefile and 
drivers/staging/hikey9xx/Kconfig.

Thanks,
Mauro
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel