linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator
@ 2020-08-18 14:58 Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain Mauro Carvalho Chehab
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, John Stultz,
	Manivannan Sadhasivam, devel, linux-kernel, Rob Herring,
	Lee Jones, David S. Miller

Hi Greg,

Patch 1 contains  a Kconfig fixup, addressing the problem you noticed
when building those drivers;

Patches 2 to 4 addresses some issues at the device tree,  pointed by
Rob's review.

Patch 5 adds the DT documentation. As requested, I moved those
also to the staging dir.

Patch 6 adds an entry at MAINTAINERS. I changed the ML to point
to the devel ML.

Thanks!
Mauro


Mauro Carvalho Chehab (6):
  staging: hikey9xx: fix Kconfig dependency chain
  staging: mfd: hi6421-spmi-pmic: get rid of interrupt properties
  staging: spmi: hisi-spmi-controller: change compatible string
  staging: mfd: hi6421-spmi-pmic: Simplify the compatible string
  dt: document HiSilicon SPMI controller and mfd/regulator properties
  MAINTAINERS: add an entry for HiSilicon 6421v600 drivers

 MAINTAINERS                                   |   6 +
 drivers/staging/hikey9xx/Kconfig              |   4 +-
 drivers/staging/hikey9xx/hi6421-spmi-pmic.c   |  82 +++------
 .../staging/hikey9xx/hisi-spmi-controller.c   |   3 +-
 .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml  | 159 ++++++++++++++++++
 .../hisilicon,hisi-spmi-controller.yaml       |  62 +++++++
 include/linux/mfd/hi6421-spmi-pmic.h          |  15 --
 7 files changed, 253 insertions(+), 78 deletions(-)
 create mode 100644 drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml
 create mode 100644 drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml

-- 
2.26.2



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain
  2020-08-18 14:58 [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator Mauro Carvalho Chehab
@ 2020-08-18 14:58 ` Mauro Carvalho Chehab
  2020-08-18 15:07   ` Greg Kroah-Hartman
  2020-08-18 14:58 ` [PATCH 2/6] staging: mfd: hi6421-spmi-pmic: get rid of interrupt properties Mauro Carvalho Chehab
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, John Stultz,
	Manivannan Sadhasivam, devel, linux-kernel

Both the SPMI controller and the SPMI PMIC driver
depends on the SPMI bus support.

The dependency for the regulator is also wrong:
it should depends on the SPMI version of the HiSilicon 6421,
and not on the normal one.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/staging/hikey9xx/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
index 76267b9be562..a004839e8fa9 100644
--- a/drivers/staging/hikey9xx/Kconfig
+++ b/drivers/staging/hikey9xx/Kconfig
@@ -5,6 +5,7 @@ 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
@@ -14,6 +15,7 @@ config SPMI_HISI3670
 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
@@ -28,7 +30,7 @@ config MFD_HI6421_SPMI
 # to be placed at drivers/regulator
 config REGULATOR_HI6421V600
 	tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
-	depends on MFD_HI6421_PMIC && OF
+	depends on MFD_HI6421_SPMI && OF
 	help
 	  This driver provides support for the voltage regulators on
 	  HiSilicon Hi6421v600 PMU / Codec IC.
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/6] staging: mfd: hi6421-spmi-pmic: get rid of interrupt properties
  2020-08-18 14:58 [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain Mauro Carvalho Chehab
@ 2020-08-18 14:58 ` Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 3/6] staging: spmi: hisi-spmi-controller: change compatible string Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, John Stultz,
	Manivannan Sadhasivam, Lee Jones, devel, linux-kernel

Both irqnum and irqarray properties reflect the same thing:
the number of bits and bytes for interrupts at this
chipset. E. g.:

	irqnum = 8 x irqarray

This can be seen by the way pending interrupts are handled:

	/* During probe time */
	pmic->irqs = devm_kzalloc(dev, pmic->irqnum * sizeof(int), GFP_KERNEL);

	/* While handling IRQs */
	for (i = 0; i < pmic->irqarray; i++) {
		pending = hi6421_spmi_pmic_read(pmic, (i + pmic->irq_addr));
		pending &= 0xff;

		for_each_set_bit(offset, &pending, 8)
			generic_handle_irq(pmic->irqs[offset + i * 8]);

	}

Going further, there are some logic at the driver which assumes
that irqarray is 2:

	/* solve powerkey order */
	if ((i == HISI_IRQ_KEY_NUM) &&
	    ((pending & HISI_IRQ_KEY_VALUE) == HISI_IRQ_KEY_VALUE)) {
		generic_handle_irq(pmic->irqs[HISI_IRQ_KEY_DOWN]);
		generic_handle_irq(pmic->irqs[HISI_IRQ_KEY_UP]);
		pending &= (~HISI_IRQ_KEY_VALUE);
	}

As HISI_IRQ_KEY_DOWN and HISI_IRQ_KEY_UP are fixed values
and don't depend on irqnum/irqarray.

The IRQ addr and mask addr seem to be also fixed, based on some
comments at the OF parsing code. So, get rid of them too,
removing the of parsing function completely.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 80 ++++++---------------
 include/linux/mfd/hi6421-spmi-pmic.h        | 15 ----
 2 files changed, 20 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
index 9d73458ca65a..7817c0637737 100644
--- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
+++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
@@ -38,6 +38,12 @@
 /* 8-bit register offset in PMIC */
 #define HISI_MASK_STATE			0xff
 
+#define HISI_IRQ_ARRAY			2
+#define HISI_IRQ_NUM			(HISI_IRQ_ARRAY * 8)
+
+#define SOC_PMIC_IRQ_MASK_0_ADDR	0x0202
+#define SOC_PMIC_IRQ0_ADDR		0x0212
+
 #define HISI_IRQ_KEY_NUM		0
 #define HISI_IRQ_KEY_VALUE		0xc0
 #define HISI_IRQ_KEY_DOWN		7
@@ -121,13 +127,13 @@ static irqreturn_t hi6421_spmi_irq_handler(int irq, void *data)
 	unsigned long pending;
 	int i, offset;
 
-	for (i = 0; i < pmic->irqarray; i++) {
-		pending = hi6421_spmi_pmic_read(pmic, (i + pmic->irq_addr));
+	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);
 
-		hi6421_spmi_pmic_write(pmic, (i + pmic->irq_addr), pending);
+		hi6421_spmi_pmic_write(pmic, (i + SOC_PMIC_IRQ0_ADDR), pending);
 
 		/* solve powerkey order */
 		if ((i == HISI_IRQ_KEY_NUM) &&
@@ -153,7 +159,7 @@ static void hi6421_spmi_irq_mask(struct irq_data *d)
 	unsigned long flags;
 
 	offset = (irqd_to_hwirq(d) >> 3);
-	offset += pmic->irq_mask_addr;
+	offset += SOC_PMIC_IRQ_MASK_0_ADDR;
 
 	spin_lock_irqsave(&pmic->lock, flags);
 	data = hi6421_spmi_pmic_read(pmic, offset);
@@ -169,7 +175,7 @@ static void hi6421_spmi_irq_unmask(struct irq_data *d)
 	unsigned long flags;
 
 	offset = (irqd_to_hwirq(d) >> 3);
-	offset += pmic->irq_mask_addr;
+	offset += SOC_PMIC_IRQ_MASK_0_ADDR;
 
 	spin_lock_irqsave(&pmic->lock, flags);
 	data = hi6421_spmi_pmic_read(pmic, offset);
@@ -204,60 +210,20 @@ static const struct irq_domain_ops hi6421_spmi_domain_ops = {
 	.xlate	= irq_domain_xlate_twocell,
 };
 
-static int get_pmic_device_tree_data(struct device_node *np,
-				     struct hi6421_spmi_pmic *pmic)
-{
-	int ret = 0;
-
-	/* IRQ number */
-	ret = of_property_read_u32(np, "irq-num", &pmic->irqnum);
-	if (ret) {
-		pr_err("no irq-num property set\n");
-		ret = -ENODEV;
-		return ret;
-	}
-
-	/* Size of IRQ array */
-	ret = of_property_read_u32(np, "irq-array", &pmic->irqarray);
-	if (ret) {
-		pr_err("no irq-array property set\n");
-		ret = -ENODEV;
-		return ret;
-	}
-
-	/* SOC_PMIC_IRQ_MASK_0_ADDR */
-	ret = of_property_read_u32(np, "irq-mask-addr", &pmic->irq_mask_addr);
-	if (ret) {
-		pr_err("no irq-mask-addr property set\n");
-		ret = -ENODEV;
-		return ret;
-	}
-
-	/* SOC_PMIC_IRQ0_ADDR */
-	ret = of_property_read_u32(np, "irq-addr", &pmic->irq_addr);
-	if (ret) {
-		pr_err("no irq-addr property set\n");
-		ret = -ENODEV;
-		return ret;
-	}
-
-	return ret;
-}
-
 static void hi6421_spmi_pmic_irq_prc(struct hi6421_spmi_pmic *pmic)
 {
 	int i, pending;
 
-	for (i = 0 ; i < pmic->irqarray; i++)
-		hi6421_spmi_pmic_write(pmic, pmic->irq_mask_addr + i,
+	for (i = 0 ; i < HISI_IRQ_ARRAY; i++)
+		hi6421_spmi_pmic_write(pmic, SOC_PMIC_IRQ_MASK_0_ADDR + i,
 				       HISI_MASK_STATE);
 
-	for (i = 0 ; i < pmic->irqarray; i++) {
-		pending = hi6421_spmi_pmic_read(pmic, pmic->irq_addr + i);
+	for (i = 0 ; i < HISI_IRQ_ARRAY; i++) {
+		pending = hi6421_spmi_pmic_read(pmic, SOC_PMIC_IRQ0_ADDR + i);
 
 		pr_debug("PMU IRQ address value:irq[0x%x] = 0x%x\n",
-			 pmic->irq_addr + i, pending);
-		hi6421_spmi_pmic_write(pmic, pmic->irq_addr + i,
+			 SOC_PMIC_IRQ0_ADDR + i, pending);
+		hi6421_spmi_pmic_write(pmic, SOC_PMIC_IRQ0_ADDR + i,
 				       HISI_MASK_STATE);
 	}
 }
@@ -274,12 +240,6 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
 	if (!pmic)
 		return -ENOMEM;
 
-	ret = get_pmic_device_tree_data(np, pmic);
-	if (ret) {
-		dev_err(dev, "Error reading hisi pmic dts\n");
-		return ret;
-	}
-
 	spin_lock_init(&pmic->lock);
 
 	pmic->dev = dev;
@@ -301,11 +261,11 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
 
 	hi6421_spmi_pmic_irq_prc(pmic);
 
-	pmic->irqs = devm_kzalloc(dev, pmic->irqnum * sizeof(int), GFP_KERNEL);
+	pmic->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL);
 	if (!pmic->irqs)
 		goto irq_malloc;
 
-	pmic->domain = irq_domain_add_simple(np, pmic->irqnum, 0,
+	pmic->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0,
 					     &hi6421_spmi_domain_ops, pmic);
 	if (!pmic->domain) {
 		dev_err(dev, "failed irq domain add simple!\n");
@@ -313,7 +273,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
 		goto irq_malloc;
 	}
 
-	for (i = 0; i < pmic->irqnum; i++) {
+	for (i = 0; i < HISI_IRQ_NUM; i++) {
 		virq = irq_create_mapping(pmic->domain, i);
 		if (!virq) {
 			dev_err(dev, "Failed mapping hwirq\n");
diff --git a/include/linux/mfd/hi6421-spmi-pmic.h b/include/linux/mfd/hi6421-spmi-pmic.h
index ff3adfa7b3ec..2c8896fd852e 100644
--- a/include/linux/mfd/hi6421-spmi-pmic.h
+++ b/include/linux/mfd/hi6421-spmi-pmic.h
@@ -17,16 +17,6 @@
 #define HISI_ECO_MODE_ENABLE		(1)
 #define HISI_ECO_MODE_DISABLE		(0)
 
-struct hi6421_spmi_irq_mask_info {
-	int start_addr;
-	int array;
-};
-
-struct hi6421_spmi_irq_info {
-	int start_addr;
-	int array;
-};
-
 struct hi6421_spmi_pmic {
 	struct resource				*res;
 	struct device				*dev;
@@ -36,11 +26,6 @@ struct hi6421_spmi_pmic {
 	int					irq;
 	int					gpio;
 	unsigned int				*irqs;
-
-	int					irqnum;
-	int					irqarray;
-	int					irq_mask_addr;
-	int					irq_addr;
 };
 
 int hi6421_spmi_pmic_read(struct hi6421_spmi_pmic *pmic, int reg);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/6] staging: spmi: hisi-spmi-controller: change compatible string
  2020-08-18 14:58 [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 2/6] staging: mfd: hi6421-spmi-pmic: get rid of interrupt properties Mauro Carvalho Chehab
@ 2020-08-18 14:58 ` Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 4/6] staging: mfd: hi6421-spmi-pmic: Simplify the " Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, John Stultz,
	Manivannan Sadhasivam, devel, linux-kernel

Add the chipset name at the compatible string, as other
HiSilicon chipsets with SPMI bus might require something
different.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/staging/hikey9xx/hisi-spmi-controller.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/hikey9xx/hisi-spmi-controller.c b/drivers/staging/hikey9xx/hisi-spmi-controller.c
index 513d962b8bce..66a0b296e06f 100644
--- a/drivers/staging/hikey9xx/hisi-spmi-controller.c
+++ b/drivers/staging/hikey9xx/hisi-spmi-controller.c
@@ -324,7 +324,8 @@ static int spmi_del_controller(struct platform_device *pdev)
 }
 
 static const struct of_device_id spmi_controller_match_table[] = {
-	{	.compatible = "hisilicon,spmi-controller",
+	{
+		.compatible = "hisilicon,kirin970-spmi-controller",
 	},
 	{}
 };
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/6] staging: mfd: hi6421-spmi-pmic: Simplify the compatible string
  2020-08-18 14:58 [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2020-08-18 14:58 ` [PATCH 3/6] staging: spmi: hisi-spmi-controller: change compatible string Mauro Carvalho Chehab
@ 2020-08-18 14:58 ` Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 5/6] dt: document HiSilicon SPMI controller and mfd/regulator properties Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 6/6] MAINTAINERS: add an entry for HiSilicon 6421v600 drivers Mauro Carvalho Chehab
  5 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, John Stultz,
	Manivannan Sadhasivam, devel, linux-kernel

It is clear that this driver is for PMIC. So, get rid of
it at the compatible.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
index 7817c0637737..64b30d263c8d 100644
--- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
+++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
@@ -323,7 +323,7 @@ static void hi6421_spmi_pmic_remove(struct spmi_device *pdev)
 }
 
 static const struct of_device_id pmic_spmi_id_table[] = {
-	{ .compatible = "hisilicon,hi6421-spmi-pmic" },
+	{ .compatible = "hisilicon,hi6421-spmi" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, pmic_spmi_id_table);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/6] dt: document HiSilicon SPMI controller and mfd/regulator properties
  2020-08-18 14:58 [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2020-08-18 14:58 ` [PATCH 4/6] staging: mfd: hi6421-spmi-pmic: Simplify the " Mauro Carvalho Chehab
@ 2020-08-18 14:58 ` Mauro Carvalho Chehab
  2020-08-18 14:58 ` [PATCH 6/6] MAINTAINERS: add an entry for HiSilicon 6421v600 drivers Mauro Carvalho Chehab
  5 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, John Stultz,
	Manivannan Sadhasivam, linux-kernel, devel

Add documentation for the properties needed by the HiSilicon
6421v600 driver, and by the SPMI controller used to access
the chipset.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml  | 159 ++++++++++++++++++
 .../hisilicon,hisi-spmi-controller.yaml       |  62 +++++++
 2 files changed, 221 insertions(+)
 create mode 100644 drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml
 create mode 100644 drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml

diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml
new file mode 100644
index 000000000000..c76093f320f1
--- /dev/null
+++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml
@@ -0,0 +1,159 @@
+# 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 <mchehab+huawei@kernel.org>
+
+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
+  Documentation/devicetree/bindings/spmi/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#"
+
+        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
+  - regulators
+
+examples:
+  - |
+    /* pmic properties */
+
+    pmic: pmic@0 {
+      compatible = "hisilicon,hi6421-spmi";
+      reg = <0 0>;
+
+      #interrupt-cells = <2>;
+      interrupt-controller;
+      gpios = <&gpio28 0 0>;
+
+      regulators {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ldo3: ldo3@16 {
+          reg = <0x16>;
+          vsel-reg = <0x51>;
+
+          regulator-name = "ldo3";
+          regulator-min-microvolt = <1500000>;
+          regulator-max-microvolt = <2000000>;
+          regulator-boot-on;
+
+          enable-mask = <0x01>;
+
+          voltage-table = <1500000>, <1550000>, <1600000>, <1650000>,
+                          <1700000>, <1725000>, <1750000>, <1775000>,
+                          <1800000>, <1825000>, <1850000>, <1875000>,
+                          <1900000>, <1925000>, <1950000>, <2000000>;
+          off-on-delay-us = <20000>;
+          startup-delay-us = <120>;
+        };
+
+        ldo4: ldo4@17 { /* 40 PIN */
+          reg = <0x17>;
+          vsel-reg = <0x52>;
+
+          regulator-name = "ldo4";
+          regulator-min-microvolt = <1725000>;
+          regulator-max-microvolt = <1900000>;
+          regulator-boot-on;
+
+          enable-mask = <0x01>;
+          idle-mode-mask = <0x10>;
+          eco-microamp = <10000>;
+
+          hi6421-vsel = <0x52 0x07>;
+          voltage-table = <1725000>, <1750000>, <1775000>, <1800000>,
+                          <1825000>, <1850000>, <1875000>, <1900000>;
+          off-on-delay-us = <20000>;
+          startup-delay-us = <120>;
+        };
+      };
+    };
diff --git a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
new file mode 100644
index 000000000000..b1cfa9c3aca6
--- /dev/null
+++ b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
@@ -0,0 +1,62 @@
+# 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 <mchehab+huawei@kernel.org>
+
+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
+  Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml.
+
+properties:
+  $nodename:
+    pattern: "spmi@[0-9a-f]"
+
+  compatible:
+    const: hisilicon,kirin970-spmi-controller
+
+  reg:
+    maxItems: 1
+
+  spmi-channel:
+    description: |
+      number of the Kirin 970 SPMI channel where the SPMI devices are connected.
+
+required:
+ - compatible
+ - reg
+ - spmi-channel
+
+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
+      Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml.
+
+examples:
+  - |
+    bus {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      spmi: spmi@fff24000 {
+        compatible = "hisilicon,kirin970-spmi-controller";
+        status = "ok";
+        reg = <0x0 0xfff24000 0x0 0x1000>;
+        spmi-channel = <2>;
+
+        pmic@0 {
+          /* pmic properties */
+        };
+      };
+    };
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/6] MAINTAINERS: add an entry for HiSilicon 6421v600 drivers
  2020-08-18 14:58 [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2020-08-18 14:58 ` [PATCH 5/6] dt: document HiSilicon SPMI controller and mfd/regulator properties Mauro Carvalho Chehab
@ 2020-08-18 14:58 ` Mauro Carvalho Chehab
  5 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 14:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, John Stultz,
	Manivannan Sadhasivam, David S. Miller, Rob Herring,
	linux-kernel

Add an entry for the SPMI, MFD and PMIC parts of the
HiSilicon 6421v600 support.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 956ecd5ba426..2f497c7d659c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7824,6 +7824,12 @@ 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 STAGING DRIVERS FOR HIKEY 960/970
+M:	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
+L:	devel@driverdev.osuosl.org
+S:	Maintained
+F:	drivers/staging/hikey9xx/
+
 HISILICON TRUE RANDOM NUMBER GENERATOR V2 SUPPORT
 M:	Zaibo Xu <xuzaibo@huawei.com>
 S:	Maintained
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain
  2020-08-18 14:58 ` [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain Mauro Carvalho Chehab
@ 2020-08-18 15:07   ` Greg Kroah-Hartman
  2020-08-18 16:07     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2020-08-18 15:07 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: devel, Manivannan Sadhasivam, linuxarm, linux-kernel,
	John Stultz, mauro.chehab

On Tue, Aug 18, 2020 at 04:58:53PM +0200, Mauro Carvalho Chehab wrote:
> Both the SPMI controller and the SPMI PMIC driver
> depends on the SPMI bus support.
> 
> The dependency for the regulator is also wrong:
> it should depends on the SPMI version of the HiSilicon 6421,
> and not on the normal one.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  drivers/staging/hikey9xx/Kconfig | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
> index 76267b9be562..a004839e8fa9 100644
> --- a/drivers/staging/hikey9xx/Kconfig
> +++ b/drivers/staging/hikey9xx/Kconfig
> @@ -5,6 +5,7 @@ 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
> @@ -14,6 +15,7 @@ config SPMI_HISI3670
>  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
> @@ -28,7 +30,7 @@ config MFD_HI6421_SPMI
>  # to be placed at drivers/regulator
>  config REGULATOR_HI6421V600
>  	tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
> -	depends on MFD_HI6421_PMIC && OF
> +	depends on MFD_HI6421_SPMI && OF
>  	help
>  	  This driver provides support for the voltage regulators on
>  	  HiSilicon Hi6421v600 PMU / Codec IC.

Better, but now I get the following build error:

ERROR: modpost: "regulator_map_voltage_iterate" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
ERROR: modpost: "regulator_list_voltage_table" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
ERROR: modpost: "of_get_regulator_init_data" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
ERROR: modpost: "regulator_register" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
ERROR: modpost: "regulator_unregister" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
ERROR: modpost: "rdev_get_drvdata" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!

Someone need CONFIG_REGULATOR enabled?

Another follow-on patch?  :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain
  2020-08-18 15:07   ` Greg Kroah-Hartman
@ 2020-08-18 16:07     ` Mauro Carvalho Chehab
  2020-08-18 17:15       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2020-08-18 16:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, Manivannan Sadhasivam, linuxarm, linux-kernel,
	John Stultz, mauro.chehab

Em Tue, 18 Aug 2020 17:07:04 +0200
Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:

> On Tue, Aug 18, 2020 at 04:58:53PM +0200, Mauro Carvalho Chehab wrote:
> > Both the SPMI controller and the SPMI PMIC driver
> > depends on the SPMI bus support.
> > 
> > The dependency for the regulator is also wrong:
> > it should depends on the SPMI version of the HiSilicon 6421,
> > and not on the normal one.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > ---
> >  drivers/staging/hikey9xx/Kconfig | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
> > index 76267b9be562..a004839e8fa9 100644
> > --- a/drivers/staging/hikey9xx/Kconfig
> > +++ b/drivers/staging/hikey9xx/Kconfig
> > @@ -5,6 +5,7 @@ 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
> > @@ -14,6 +15,7 @@ config SPMI_HISI3670
> >  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
> > @@ -28,7 +30,7 @@ config MFD_HI6421_SPMI
> >  # to be placed at drivers/regulator
> >  config REGULATOR_HI6421V600
> >  	tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
> > -	depends on MFD_HI6421_PMIC && OF
> > +	depends on MFD_HI6421_SPMI && OF
> >  	help
> >  	  This driver provides support for the voltage regulators on
> >  	  HiSilicon Hi6421v600 PMU / Codec IC.  
> 
> Better, but now I get the following build error:
> 
> ERROR: modpost: "regulator_map_voltage_iterate" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> ERROR: modpost: "regulator_list_voltage_table" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> ERROR: modpost: "of_get_regulator_init_data" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> ERROR: modpost: "regulator_register" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> ERROR: modpost: "regulator_unregister" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> ERROR: modpost: "rdev_get_drvdata" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> 
> Someone need CONFIG_REGULATOR enabled?

Yep. Sorry for that!
> 
> Another follow-on patch?  :)

:)

Just to make sure, I did a clean compilation here, starting from
nomodconfig, and adding just CONFIG_ARCH* and the dependencies
needed by those symbols. It build fine here. So, I guess it
should be ok this time (famous last words...)

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain
  2020-08-18 16:07     ` Mauro Carvalho Chehab
@ 2020-08-18 17:15       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2020-08-18 17:15 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: devel, Manivannan Sadhasivam, linux-kernel, linuxarm,
	John Stultz, mauro.chehab

On Tue, Aug 18, 2020 at 06:07:16PM +0200, Mauro Carvalho Chehab wrote:
> Em Tue, 18 Aug 2020 17:07:04 +0200
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:
> 
> > On Tue, Aug 18, 2020 at 04:58:53PM +0200, Mauro Carvalho Chehab wrote:
> > > Both the SPMI controller and the SPMI PMIC driver
> > > depends on the SPMI bus support.
> > > 
> > > The dependency for the regulator is also wrong:
> > > it should depends on the SPMI version of the HiSilicon 6421,
> > > and not on the normal one.
> > > 
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> > > ---
> > >  drivers/staging/hikey9xx/Kconfig | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
> > > index 76267b9be562..a004839e8fa9 100644
> > > --- a/drivers/staging/hikey9xx/Kconfig
> > > +++ b/drivers/staging/hikey9xx/Kconfig
> > > @@ -5,6 +5,7 @@ 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
> > > @@ -14,6 +15,7 @@ config SPMI_HISI3670
> > >  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
> > > @@ -28,7 +30,7 @@ config MFD_HI6421_SPMI
> > >  # to be placed at drivers/regulator
> > >  config REGULATOR_HI6421V600
> > >  	tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
> > > -	depends on MFD_HI6421_PMIC && OF
> > > +	depends on MFD_HI6421_SPMI && OF
> > >  	help
> > >  	  This driver provides support for the voltage regulators on
> > >  	  HiSilicon Hi6421v600 PMU / Codec IC.  
> > 
> > Better, but now I get the following build error:
> > 
> > ERROR: modpost: "regulator_map_voltage_iterate" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> > ERROR: modpost: "regulator_list_voltage_table" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> > ERROR: modpost: "of_get_regulator_init_data" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> > ERROR: modpost: "regulator_register" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> > ERROR: modpost: "regulator_unregister" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> > ERROR: modpost: "rdev_get_drvdata" [drivers/staging/hikey9xx/hi6421v600-regulator.ko] undefined!
> > 
> > Someone need CONFIG_REGULATOR enabled?
> 
> Yep. Sorry for that!
> > 
> > Another follow-on patch?  :)
> 
> :)
> 
> Just to make sure, I did a clean compilation here, starting from
> nomodconfig, and adding just CONFIG_ARCH* and the dependencies
> needed by those symbols. It build fine here. So, I guess it
> should be ok this time (famous last words...)

Let's see what falls out in linux-next, that's the best test :)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-08-18 17:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 14:58 [PATCH 0/6] Do some cleanups at the HiSilicon 6421 regulator Mauro Carvalho Chehab
2020-08-18 14:58 ` [PATCH 1/6] staging: hikey9xx: fix Kconfig dependency chain Mauro Carvalho Chehab
2020-08-18 15:07   ` Greg Kroah-Hartman
2020-08-18 16:07     ` Mauro Carvalho Chehab
2020-08-18 17:15       ` Greg Kroah-Hartman
2020-08-18 14:58 ` [PATCH 2/6] staging: mfd: hi6421-spmi-pmic: get rid of interrupt properties Mauro Carvalho Chehab
2020-08-18 14:58 ` [PATCH 3/6] staging: spmi: hisi-spmi-controller: change compatible string Mauro Carvalho Chehab
2020-08-18 14:58 ` [PATCH 4/6] staging: mfd: hi6421-spmi-pmic: Simplify the " Mauro Carvalho Chehab
2020-08-18 14:58 ` [PATCH 5/6] dt: document HiSilicon SPMI controller and mfd/regulator properties Mauro Carvalho Chehab
2020-08-18 14:58 ` [PATCH 6/6] MAINTAINERS: add an entry for HiSilicon 6421v600 drivers Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).