linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 01/12] mfd: da9063: Fix failpath in core
@ 2018-06-05 23:10 Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 02/12] mfd: da9063: Use REGMAP_IRQ_REG Marek Vasut
                   ` (12 more replies)
  0 siblings, 13 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

In case mfd_add_devices() fails, da9063_irq_exit() is not called to
undo the IRQchip setup done by da9063_irq_init(). Fix this by adding
the missing fail path.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
V3: New patch
V4: No change
---
 drivers/mfd/da9063-core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
index 6c2870d4e754..8226ebd8b96d 100644
--- a/drivers/mfd/da9063-core.c
+++ b/drivers/mfd/da9063-core.c
@@ -229,10 +229,16 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
 	ret = mfd_add_devices(da9063->dev, -1, da9063_devs,
 			      ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base,
 			      NULL);
-	if (ret)
+	if (ret) {
 		dev_err(da9063->dev, "Cannot add MFD cells\n");
+		goto err_irq_exit;
+	}
 
 	return ret;
+
+err_irq_exit:
+	da9063_irq_exit(da9063);
+	return ret;
 }
 
 void da9063_device_exit(struct da9063 *da9063)
-- 
2.16.2

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

* [PATCH v4 02/12] mfd: da9063: Use REGMAP_IRQ_REG
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE Marek Vasut
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

Convert the regmap_irq table to use REGMAP_IRQ_REG().

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
---
V3: New patch
Note: A sed oneliner was used:
      sed -i "/\[DA9063_IRQ_/ {N;N;N;s/\n//g;s/.*\[\(DA9063_IRQ_[^]]\+\)].*reg_offset = \([^,]\+\),.* = \([^,]\+\),.*/\tREGMAP_IRQ_REG(\1, \2, \3),/}" drivers/mfd/da9063-irq.c
V4: Formatting fixes with "s/,/&\r\t\t      /" on the array
    Drop extra newline in da9063_irq_chip
---
 drivers/mfd/da9063-irq.c | 175 ++++++++++++++++-------------------------------
 1 file changed, 58 insertions(+), 117 deletions(-)

diff --git a/drivers/mfd/da9063-irq.c b/drivers/mfd/da9063-irq.c
index 207bbfe55449..bd448d6cdf8b 100644
--- a/drivers/mfd/da9063-irq.c
+++ b/drivers/mfd/da9063-irq.c
@@ -28,132 +28,73 @@
 
 static const struct regmap_irq da9063_irqs[] = {
 	/* DA9063 event A register */
-	[DA9063_IRQ_ONKEY] = {
-		.reg_offset = DA9063_REG_EVENT_A_OFFSET,
-		.mask = DA9063_M_ONKEY,
-	},
-	[DA9063_IRQ_ALARM] = {
-		.reg_offset = DA9063_REG_EVENT_A_OFFSET,
-		.mask = DA9063_M_ALARM,
-	},
-	[DA9063_IRQ_TICK] = {
-		.reg_offset = DA9063_REG_EVENT_A_OFFSET,
-		.mask = DA9063_M_TICK,
-	},
-	[DA9063_IRQ_ADC_RDY] = {
-		.reg_offset = DA9063_REG_EVENT_A_OFFSET,
-		.mask = DA9063_M_ADC_RDY,
-	},
-	[DA9063_IRQ_SEQ_RDY] = {
-		.reg_offset = DA9063_REG_EVENT_A_OFFSET,
-		.mask = DA9063_M_SEQ_RDY,
-	},
+	REGMAP_IRQ_REG(DA9063_IRQ_ONKEY,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_ONKEY),
+	REGMAP_IRQ_REG(DA9063_IRQ_ALARM,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_ALARM),
+	REGMAP_IRQ_REG(DA9063_IRQ_TICK,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_TICK),
+	REGMAP_IRQ_REG(DA9063_IRQ_ADC_RDY,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_ADC_RDY),
+	REGMAP_IRQ_REG(DA9063_IRQ_SEQ_RDY,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_SEQ_RDY),
 	/* DA9063 event B register */
-	[DA9063_IRQ_WAKE] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_WAKE,
-	},
-	[DA9063_IRQ_TEMP] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_TEMP,
-	},
-	[DA9063_IRQ_COMP_1V2] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_COMP_1V2,
-	},
-	[DA9063_IRQ_LDO_LIM] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_LDO_LIM,
-	},
-	[DA9063_IRQ_REG_UVOV] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_UVOV,
-	},
-	[DA9063_IRQ_DVC_RDY] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_DVC_RDY,
-	},
-	[DA9063_IRQ_VDD_MON] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_VDD_MON,
-	},
-	[DA9063_IRQ_WARN] = {
-		.reg_offset = DA9063_REG_EVENT_B_OFFSET,
-		.mask = DA9063_M_VDD_WARN,
-	},
+	REGMAP_IRQ_REG(DA9063_IRQ_WAKE,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_WAKE),
+	REGMAP_IRQ_REG(DA9063_IRQ_TEMP,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_TEMP),
+	REGMAP_IRQ_REG(DA9063_IRQ_COMP_1V2,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_COMP_1V2),
+	REGMAP_IRQ_REG(DA9063_IRQ_LDO_LIM,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_LDO_LIM),
+	REGMAP_IRQ_REG(DA9063_IRQ_REG_UVOV,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_UVOV),
+	REGMAP_IRQ_REG(DA9063_IRQ_DVC_RDY,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_DVC_RDY),
+	REGMAP_IRQ_REG(DA9063_IRQ_VDD_MON,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_VDD_MON),
+	REGMAP_IRQ_REG(DA9063_IRQ_WARN,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_VDD_WARN),
 	/* DA9063 event C register */
-	[DA9063_IRQ_GPI0] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI0,
-	},
-	[DA9063_IRQ_GPI1] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI1,
-	},
-	[DA9063_IRQ_GPI2] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI2,
-	},
-	[DA9063_IRQ_GPI3] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI3,
-	},
-	[DA9063_IRQ_GPI4] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI4,
-	},
-	[DA9063_IRQ_GPI5] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI5,
-	},
-	[DA9063_IRQ_GPI6] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI6,
-	},
-	[DA9063_IRQ_GPI7] = {
-		.reg_offset = DA9063_REG_EVENT_C_OFFSET,
-		.mask = DA9063_M_GPI7,
-	},
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI0,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI0),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI1,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI1),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI2,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI2),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI3,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI3),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI4,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI4),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI5,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI5),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI6,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI6),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI7,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI7),
 	/* DA9063 event D register */
-	[DA9063_IRQ_GPI8] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI8,
-	},
-	[DA9063_IRQ_GPI9] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI9,
-	},
-	[DA9063_IRQ_GPI10] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI10,
-	},
-	[DA9063_IRQ_GPI11] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI11,
-	},
-	[DA9063_IRQ_GPI12] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI12,
-	},
-	[DA9063_IRQ_GPI13] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI13,
-	},
-	[DA9063_IRQ_GPI14] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI14,
-	},
-	[DA9063_IRQ_GPI15] = {
-		.reg_offset = DA9063_REG_EVENT_D_OFFSET,
-		.mask = DA9063_M_GPI15,
-	},
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI8,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI8),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI9,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI9),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI10,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI10),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI11,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI11),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI12,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI12),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI13,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI13),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI14,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI14),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI15,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI15),
 };
 
 static const struct regmap_irq_chip da9063_irq_chip = {
 	.name = "da9063-irq",
 	.irqs = da9063_irqs,
 	.num_irqs = DA9063_NUM_IRQ,
-
 	.num_regs = 4,
 	.status_base = DA9063_REG_EVENT_A,
 	.mask_base = DA9063_REG_IRQ_MASK_A,
-- 
2.16.2

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

* [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 02/12] mfd: da9063: Use REGMAP_IRQ_REG Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-06  6:25   ` Geert Uytterhoeven
  2018-06-06  6:34   ` Lee Jones
  2018-06-05 23:10 ` [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE Marek Vasut
                   ` (10 subsequent siblings)
  12 siblings, 2 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

Use PLATFORM_DEVID_NONE instead of -1 in mfd_add_devices.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
V4: New patch
---
 drivers/mfd/da9063-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
index 8226ebd8b96d..61ffee5eac2c 100644
--- a/drivers/mfd/da9063-core.c
+++ b/drivers/mfd/da9063-core.c
@@ -226,7 +226,7 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
 
 	da9063->irq_base = regmap_irq_chip_get_base(da9063->regmap_irq);
 
-	ret = mfd_add_devices(da9063->dev, -1, da9063_devs,
+	ret = mfd_add_devices(da9063->dev, PLATFORM_DEVID_NONE, da9063_devs,
 			      ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base,
 			      NULL);
 	if (ret) {
-- 
2.16.2

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

* [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 02/12] mfd: da9063: Use REGMAP_IRQ_REG Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-06  6:28   ` Geert Uytterhoeven
  2018-06-06  6:36   ` Lee Jones
  2018-06-05 23:10 ` [PATCH v4 05/12] mfd: da9063: Rename PMIC_DA9063 to PMIC_CHIP_ID_DA9063 Marek Vasut
                   ` (9 subsequent siblings)
  12 siblings, 2 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

Replace DA9063_NUM_IRQ macro which is not used anywhere with
plain ARRAY_SIZE().

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
V4: New patch
---
 drivers/mfd/da9063-irq.c        | 2 +-
 include/linux/mfd/da9063/core.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mfd/da9063-irq.c b/drivers/mfd/da9063-irq.c
index bd448d6cdf8b..34ea8d0334d7 100644
--- a/drivers/mfd/da9063-irq.c
+++ b/drivers/mfd/da9063-irq.c
@@ -94,7 +94,7 @@ static const struct regmap_irq da9063_irqs[] = {
 static const struct regmap_irq_chip da9063_irq_chip = {
 	.name = "da9063-irq",
 	.irqs = da9063_irqs,
-	.num_irqs = DA9063_NUM_IRQ,
+	.num_irqs = ARRAY_SIZE(da9063_irqs),
 	.num_regs = 4,
 	.status_base = DA9063_REG_EVENT_A,
 	.mask_base = DA9063_REG_IRQ_MASK_A,
diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
index f3ae65db4c86..2622e9822086 100644
--- a/include/linux/mfd/da9063/core.h
+++ b/include/linux/mfd/da9063/core.h
@@ -73,7 +73,6 @@ enum da9063_irqs {
 };
 
 #define DA9063_IRQ_BASE_OFFSET	0
-#define DA9063_NUM_IRQ		(DA9063_IRQ_GPI15 + 1 - DA9063_IRQ_BASE_OFFSET)
 
 struct da9063 {
 	/* Device */
-- 
2.16.2

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

* [PATCH v4 05/12] mfd: da9063: Rename PMIC_DA9063 to PMIC_CHIP_ID_DA9063
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (2 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 06/12] mfd: da9063: Replace model with type Marek Vasut
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

The PMIC_DA9063 is a complete misnomer, it denotes the value of the
DA9063 chip ID register, so rename it as such. It is also the value
of chip ID register of DA9063L though, so drop the enum as all the
DA9063 "models" share the same chip ID and thus the distinction will
have to be made using DT or otherwise.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
---
V2: No change
V3: No change
V4: No change
---
 drivers/mfd/da9063-core.c            | 2 +-
 drivers/mfd/da9063-i2c.c             | 2 +-
 drivers/regulator/da9063-regulator.c | 2 +-
 include/linux/mfd/da9063/core.h      | 4 +---
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
index 61ffee5eac2c..a21a771f6177 100644
--- a/drivers/mfd/da9063-core.c
+++ b/drivers/mfd/da9063-core.c
@@ -192,7 +192,7 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
 		dev_err(da9063->dev, "Cannot read chip model id.\n");
 		return -EIO;
 	}
-	if (model != PMIC_DA9063) {
+	if (model != PMIC_CHIP_ID_DA9063) {
 		dev_err(da9063->dev, "Invalid chip model id: 0x%02x\n", model);
 		return -ENODEV;
 	}
diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
index 981805a2c521..7f84030c8d53 100644
--- a/drivers/mfd/da9063-i2c.c
+++ b/drivers/mfd/da9063-i2c.c
@@ -280,7 +280,7 @@ static int da9063_i2c_remove(struct i2c_client *i2c)
 }
 
 static const struct i2c_device_id da9063_i2c_id[] = {
-	{"da9063", PMIC_DA9063},
+	{ "da9063", PMIC_CHIP_ID_DA9063 },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, da9063_i2c_id);
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 6a8f9cd69f52..87c884ae0064 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -585,7 +585,7 @@ static struct da9063_dev_model regulators_models[] = {
 	{
 		.regulator_info = da9063_regulator_info,
 		.n_regulators = ARRAY_SIZE(da9063_regulator_info),
-		.dev_model = PMIC_DA9063,
+		.dev_model = PMIC_CHIP_ID_DA9063,
 	},
 	{ }
 };
diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
index 2622e9822086..5fed1c874926 100644
--- a/include/linux/mfd/da9063/core.h
+++ b/include/linux/mfd/da9063/core.h
@@ -29,9 +29,7 @@
 #define DA9063_DRVNAME_RTC		"da9063-rtc"
 #define DA9063_DRVNAME_VIBRATION	"da9063-vibration"
 
-enum da9063_models {
-	PMIC_DA9063 = 0x61,
-};
+#define PMIC_CHIP_ID_DA9063		0x61
 
 enum da9063_variant_codes {
 	PMIC_DA9063_AD = 0x3,
-- 
2.16.2

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

* [PATCH v4 06/12] mfd: da9063: Replace model with type
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (3 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 05/12] mfd: da9063: Rename PMIC_DA9063 to PMIC_CHIP_ID_DA9063 Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-06 14:04   ` kbuild test robot
  2018-06-05 23:10 ` [PATCH v4 07/12] mfd: da9063: Add DA9063L type Marek Vasut
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

The model number stored in the struct da9063 is the same for all
variants of the da9063 since it is the chip ID, which is always
the same. Replace that with a separate identifier instead, which
allows us to discern the DA9063 variants by setting the type
based on either DT match or otherwise.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
V2: Drop useless cast of id->driver_data
V3: Fix kernel 0day error , s/dev_model/type/
V4: No change
---
 drivers/mfd/da9063-core.c            | 1 -
 drivers/mfd/da9063-i2c.c             | 5 +++--
 drivers/regulator/da9063-regulator.c | 6 +++---
 include/linux/mfd/da9063/core.h      | 6 +++++-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
index a21a771f6177..9aff815877c0 100644
--- a/drivers/mfd/da9063-core.c
+++ b/drivers/mfd/da9063-core.c
@@ -215,7 +215,6 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
 		return -ENODEV;
 	}
 
-	da9063->model = model;
 	da9063->variant_code = variant_code;
 
 	ret = da9063_irq_init(da9063);
diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
index 7f84030c8d53..048ce55ebc5b 100644
--- a/drivers/mfd/da9063-i2c.c
+++ b/drivers/mfd/da9063-i2c.c
@@ -236,7 +236,7 @@ static const struct of_device_id da9063_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, da9063_dt_ids);
 static int da9063_i2c_probe(struct i2c_client *i2c,
-	const struct i2c_device_id *id)
+			    const struct i2c_device_id *id)
 {
 	struct da9063 *da9063;
 	int ret;
@@ -248,6 +248,7 @@ static int da9063_i2c_probe(struct i2c_client *i2c,
 	i2c_set_clientdata(i2c, da9063);
 	da9063->dev = &i2c->dev;
 	da9063->chip_irq = i2c->irq;
+	da9063->type = id->driver_data;
 
 	if (da9063->variant_code == PMIC_DA9063_AD) {
 		da9063_regmap_config.rd_table = &da9063_ad_readable_table;
@@ -280,7 +281,7 @@ static int da9063_i2c_remove(struct i2c_client *i2c)
 }
 
 static const struct i2c_device_id da9063_i2c_id[] = {
-	{ "da9063", PMIC_CHIP_ID_DA9063 },
+	{ "da9063", PMIC_TYPE_DA9063 },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, da9063_i2c_id);
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 87c884ae0064..eeb0d431dda1 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -98,7 +98,7 @@ struct da9063_regulator_info {
 struct da9063_dev_model {
 	const struct da9063_regulator_info	*regulator_info;
 	unsigned				n_regulators;
-	unsigned				dev_model;
+	enum da9063_type			type;
 };
 
 /* Single regulator settings */
@@ -585,7 +585,7 @@ static struct da9063_dev_model regulators_models[] = {
 	{
 		.regulator_info = da9063_regulator_info,
 		.n_regulators = ARRAY_SIZE(da9063_regulator_info),
-		.dev_model = PMIC_CHIP_ID_DA9063,
+		.type = PMIC_TYPE_DA9063,
 	},
 	{ }
 };
@@ -741,7 +741,7 @@ static int da9063_regulator_probe(struct platform_device *pdev)
 
 	/* Find regulators set for particular device model */
 	for (model = regulators_models; model->regulator_info; model++) {
-		if (model->dev_model == da9063->model)
+		if (model->type == da9063->type)
 			break;
 	}
 	if (!model->regulator_info) {
diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
index 5fed1c874926..6caf23483e8e 100644
--- a/include/linux/mfd/da9063/core.h
+++ b/include/linux/mfd/da9063/core.h
@@ -31,6 +31,10 @@
 
 #define PMIC_CHIP_ID_DA9063		0x61
 
+enum da9063_type {
+	PMIC_TYPE_DA9063 = 0,
+};
+
 enum da9063_variant_codes {
 	PMIC_DA9063_AD = 0x3,
 	PMIC_DA9063_BB = 0x5,
@@ -75,7 +79,7 @@ enum da9063_irqs {
 struct da9063 {
 	/* Device */
 	struct device	*dev;
-	unsigned short	model;
+	enum da9063_type type;
 	unsigned char	variant_code;
 	unsigned int	flags;
 
-- 
2.16.2

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

* [PATCH v4 07/12] mfd: da9063: Add DA9063L type
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (4 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 06/12] mfd: da9063: Replace model with type Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 08/12] mfd: da9063: Add custom regmap for DA9063L Marek Vasut
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

Add type for DA9063L, which is a reduced variant of the DA9063
without RTC block and with less regulators.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
---
V2: No change
V3: No change
V4: No change
---
 include/linux/mfd/da9063/core.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
index 6caf23483e8e..c9b0adfcb068 100644
--- a/include/linux/mfd/da9063/core.h
+++ b/include/linux/mfd/da9063/core.h
@@ -33,6 +33,7 @@
 
 enum da9063_type {
 	PMIC_TYPE_DA9063 = 0,
+	PMIC_TYPE_DA9063L,
 };
 
 enum da9063_variant_codes {
-- 
2.16.2

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

* [PATCH v4 08/12] mfd: da9063: Add custom regmap for DA9063L
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (5 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 07/12] mfd: da9063: Add DA9063L type Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-06  6:39   ` Lee Jones
  2018-06-05 23:10 ` [PATCH v4 09/12] mfd: da9063: Add custom IRQ map " Marek Vasut
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

The DA9063L does not have an RTC. Add custom regmap for DA9063L to
prevent access into that register block.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
V3: New patch
V4: Drop mention of buggy datasheet in the commit message
---
 drivers/mfd/da9063-i2c.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
index 048ce55ebc5b..f0d92a37df6b 100644
--- a/drivers/mfd/da9063-i2c.c
+++ b/drivers/mfd/da9063-i2c.c
@@ -208,6 +208,93 @@ static const struct regmap_access_table da9063_bb_volatile_table = {
 	.n_yes_ranges = ARRAY_SIZE(da9063_bb_volatile_ranges),
 };
 
+static const struct regmap_range da9063l_bb_readable_ranges[] = {
+	{
+		.range_min = DA9063_REG_PAGE_CON,
+		.range_max = DA9063_REG_MON_A10_RES,
+	}, {
+		.range_min = DA9063_REG_SEQ,
+		.range_max = DA9063_REG_ID_32_31,
+	}, {
+		.range_min = DA9063_REG_SEQ_A,
+		.range_max = DA9063_REG_AUTO3_LOW,
+	}, {
+		.range_min = DA9063_REG_T_OFFSET,
+		.range_max = DA9063_BB_REG_GP_ID_19,
+	}, {
+		.range_min = DA9063_REG_CHIP_ID,
+		.range_max = DA9063_REG_CHIP_VARIANT,
+	},
+};
+
+static const struct regmap_range da9063l_bb_writeable_ranges[] = {
+	{
+		.range_min = DA9063_REG_PAGE_CON,
+		.range_max = DA9063_REG_PAGE_CON,
+	}, {
+		.range_min = DA9063_REG_FAULT_LOG,
+		.range_max = DA9063_REG_VSYS_MON,
+	}, {
+		.range_min = DA9063_REG_SEQ,
+		.range_max = DA9063_REG_ID_32_31,
+	}, {
+		.range_min = DA9063_REG_SEQ_A,
+		.range_max = DA9063_REG_AUTO3_LOW,
+	}, {
+		.range_min = DA9063_REG_CONFIG_I,
+		.range_max = DA9063_BB_REG_MON_REG_4,
+	}, {
+		.range_min = DA9063_BB_REG_GP_ID_0,
+		.range_max = DA9063_BB_REG_GP_ID_19,
+	},
+};
+
+static const struct regmap_range da9063l_bb_volatile_ranges[] = {
+	{
+		.range_min = DA9063_REG_PAGE_CON,
+		.range_max = DA9063_REG_EVENT_D,
+	}, {
+		.range_min = DA9063_REG_CONTROL_A,
+		.range_max = DA9063_REG_CONTROL_B,
+	}, {
+		.range_min = DA9063_REG_CONTROL_E,
+		.range_max = DA9063_REG_CONTROL_F,
+	}, {
+		.range_min = DA9063_REG_BCORE2_CONT,
+		.range_max = DA9063_REG_LDO11_CONT,
+	}, {
+		.range_min = DA9063_REG_DVC_1,
+		.range_max = DA9063_REG_ADC_MAN,
+	}, {
+		.range_min = DA9063_REG_ADC_RES_L,
+		.range_max = DA9063_REG_MON_A10_RES,
+	}, {
+		.range_min = DA9063_REG_SEQ,
+		.range_max = DA9063_REG_SEQ,
+	}, {
+		.range_min = DA9063_REG_EN_32K,
+		.range_max = DA9063_REG_EN_32K,
+	}, {
+		.range_min = DA9063_BB_REG_MON_REG_5,
+		.range_max = DA9063_BB_REG_MON_REG_6,
+	},
+};
+
+static const struct regmap_access_table da9063l_bb_readable_table = {
+	.yes_ranges = da9063l_bb_readable_ranges,
+	.n_yes_ranges = ARRAY_SIZE(da9063l_bb_readable_ranges),
+};
+
+static const struct regmap_access_table da9063l_bb_writeable_table = {
+	.yes_ranges = da9063l_bb_writeable_ranges,
+	.n_yes_ranges = ARRAY_SIZE(da9063l_bb_writeable_ranges),
+};
+
+static const struct regmap_access_table da9063l_bb_volatile_table = {
+	.yes_ranges = da9063l_bb_volatile_ranges,
+	.n_yes_ranges = ARRAY_SIZE(da9063l_bb_volatile_ranges),
+};
+
 static const struct regmap_range_cfg da9063_range_cfg[] = {
 	{
 		.range_min = DA9063_REG_PAGE_CON,
@@ -254,6 +341,10 @@ static int da9063_i2c_probe(struct i2c_client *i2c,
 		da9063_regmap_config.rd_table = &da9063_ad_readable_table;
 		da9063_regmap_config.wr_table = &da9063_ad_writeable_table;
 		da9063_regmap_config.volatile_table = &da9063_ad_volatile_table;
+	} else if (da9063->type == PMIC_TYPE_DA9063L) {
+		da9063_regmap_config.rd_table = &da9063l_bb_readable_table;
+		da9063_regmap_config.wr_table = &da9063l_bb_writeable_table;
+		da9063_regmap_config.volatile_table = &da9063l_bb_volatile_table;
 	} else {
 		da9063_regmap_config.rd_table = &da9063_bb_readable_table;
 		da9063_regmap_config.wr_table = &da9063_bb_writeable_table;
-- 
2.16.2

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

* [PATCH v4 09/12] mfd: da9063: Add custom IRQ map for DA9063L
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (6 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 08/12] mfd: da9063: Add custom regmap for DA9063L Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-06  6:40   ` Lee Jones
  2018-06-05 23:10 ` [PATCH v4 10/12] mfd: da9063: Register RTC only on DA9063L Marek Vasut
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

The DA9063L does not have an RTC. Add custom IRQ map for DA9063L to
ignore the Alarm and Tick IRQs from the PMIC.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
V3: New patch
V4: - Formatting fixes
    - Drop extra newline in da9063l_irq_chip
    - Drop mention of the buggy datasheet in commit message
---
 drivers/mfd/da9063-irq.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 79 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/da9063-irq.c b/drivers/mfd/da9063-irq.c
index 34ea8d0334d7..c1bc52428e8c 100644
--- a/drivers/mfd/da9063-irq.c
+++ b/drivers/mfd/da9063-irq.c
@@ -102,8 +102,81 @@ static const struct regmap_irq_chip da9063_irq_chip = {
 	.init_ack_masked = true,
 };
 
+static const struct regmap_irq da9063l_irqs[] = {
+	/* DA9063 event A register */
+	REGMAP_IRQ_REG(DA9063_IRQ_ONKEY,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_ONKEY),
+	REGMAP_IRQ_REG(DA9063_IRQ_ADC_RDY,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_ADC_RDY),
+	REGMAP_IRQ_REG(DA9063_IRQ_SEQ_RDY,
+		       DA9063_REG_EVENT_A_OFFSET, DA9063_M_SEQ_RDY),
+	/* DA9063 event B register */
+	REGMAP_IRQ_REG(DA9063_IRQ_WAKE,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_WAKE),
+	REGMAP_IRQ_REG(DA9063_IRQ_TEMP,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_TEMP),
+	REGMAP_IRQ_REG(DA9063_IRQ_COMP_1V2,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_COMP_1V2),
+	REGMAP_IRQ_REG(DA9063_IRQ_LDO_LIM,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_LDO_LIM),
+	REGMAP_IRQ_REG(DA9063_IRQ_REG_UVOV,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_UVOV),
+	REGMAP_IRQ_REG(DA9063_IRQ_DVC_RDY,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_DVC_RDY),
+	REGMAP_IRQ_REG(DA9063_IRQ_VDD_MON,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_VDD_MON),
+	REGMAP_IRQ_REG(DA9063_IRQ_WARN,
+		       DA9063_REG_EVENT_B_OFFSET, DA9063_M_VDD_WARN),
+	/* DA9063 event C register */
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI0,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI0),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI1,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI1),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI2,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI2),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI3,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI3),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI4,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI4),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI5,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI5),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI6,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI6),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI7,
+		       DA9063_REG_EVENT_C_OFFSET, DA9063_M_GPI7),
+	/* DA9063 event D register */
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI8,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI8),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI9,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI9),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI10,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI10),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI11,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI11),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI12,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI12),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI13,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI13),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI14,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI14),
+	REGMAP_IRQ_REG(DA9063_IRQ_GPI15,
+		       DA9063_REG_EVENT_D_OFFSET, DA9063_M_GPI15),
+};
+
+static const struct regmap_irq_chip da9063l_irq_chip = {
+	.name = "da9063l-irq",
+	.irqs = da9063l_irqs,
+	.num_irqs = ARRAY_SIZE(da9063l_irqs),
+	.num_regs = 4,
+	.status_base = DA9063_REG_EVENT_A,
+	.mask_base = DA9063_REG_IRQ_MASK_A,
+	.ack_base = DA9063_REG_EVENT_A,
+	.init_ack_masked = true,
+};
+
 int da9063_irq_init(struct da9063 *da9063)
 {
+	const struct regmap_irq_chip *irq_chip;
 	int ret;
 
 	if (!da9063->chip_irq) {
@@ -111,10 +184,14 @@ int da9063_irq_init(struct da9063 *da9063)
 		return -EINVAL;
 	}
 
+	if (da9063->type == PMIC_TYPE_DA9063)
+		irq_chip = &da9063_irq_chip;
+	else
+		irq_chip = &da9063l_irq_chip;
+
 	ret = regmap_add_irq_chip(da9063->regmap, da9063->chip_irq,
 			IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED,
-			da9063->irq_base, &da9063_irq_chip,
-			&da9063->regmap_irq);
+			da9063->irq_base, irq_chip, &da9063->regmap_irq);
 	if (ret) {
 		dev_err(da9063->dev, "Failed to reguest IRQ %d: %d\n",
 				da9063->chip_irq, ret);
-- 
2.16.2

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

* [PATCH v4 10/12] mfd: da9063: Register RTC only on DA9063L
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (7 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 09/12] mfd: da9063: Add custom IRQ map " Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-06  6:41   ` Lee Jones
  2018-06-05 23:10 ` [PATCH v4 11/12] regulator: da9063: Handle less LDOs " Marek Vasut
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

The DA9063L does not contain RTC block, unlike the full DA9063.
Split the RTC block into separate mfd cell and register it only
on DA9063.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
---
V2: No change
V3: Rework of mfd: da9063: Disallow RTC on DA9063L
V4: - Change the original failure text
    - Use PLATFORM_DEVID_NONE in mfd_add_devices
---
 drivers/mfd/da9063-core.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
index 9aff815877c0..3443c9321c09 100644
--- a/drivers/mfd/da9063-core.c
+++ b/drivers/mfd/da9063-core.c
@@ -76,7 +76,7 @@ static struct resource da9063_hwmon_resources[] = {
 };
 
 
-static const struct mfd_cell da9063_devs[] = {
+static const struct mfd_cell da9063_common_devs[] = {
 	{
 		.name		= DA9063_DRVNAME_REGULATORS,
 		.num_resources	= ARRAY_SIZE(da9063_regulators_resources),
@@ -100,15 +100,19 @@ static const struct mfd_cell da9063_devs[] = {
 		.resources	= da9063_onkey_resources,
 		.of_compatible = "dlg,da9063-onkey",
 	},
+	{
+		.name		= DA9063_DRVNAME_VIBRATION,
+	},
+};
+
+/* Only present on DA9063 , not on DA9063L */
+static const struct mfd_cell da9063_devs[] = {
 	{
 		.name		= DA9063_DRVNAME_RTC,
 		.num_resources	= ARRAY_SIZE(da9063_rtc_resources),
 		.resources	= da9063_rtc_resources,
 		.of_compatible	= "dlg,da9063-rtc",
 	},
-	{
-		.name		= DA9063_DRVNAME_VIBRATION,
-	},
 };
 
 static int da9063_clear_fault_log(struct da9063 *da9063)
@@ -225,16 +229,29 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq)
 
 	da9063->irq_base = regmap_irq_chip_get_base(da9063->regmap_irq);
 
-	ret = mfd_add_devices(da9063->dev, PLATFORM_DEVID_NONE, da9063_devs,
-			      ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base,
-			      NULL);
+	ret = mfd_add_devices(da9063->dev, PLATFORM_DEVID_NONE,
+			      da9063_common_devs,
+			      ARRAY_SIZE(da9063_common_devs),
+			      NULL, da9063->irq_base, NULL);
 	if (ret) {
-		dev_err(da9063->dev, "Cannot add MFD cells\n");
+		dev_err(da9063->dev, "Failed to add child devices\n");
 		goto err_irq_exit;
 	}
 
+	if (da9063->type == PMIC_TYPE_DA9063) {
+		ret = mfd_add_devices(da9063->dev, PLATFORM_DEVID_NONE,
+				      da9063_devs, ARRAY_SIZE(da9063_devs),
+				      NULL, da9063->irq_base, NULL);
+		if (ret) {
+			dev_err(da9063->dev, "Failed to add child devices\n");
+			goto err_mfd_cleanup;
+		}
+	}
+
 	return ret;
 
+err_mfd_cleanup:
+	mfd_remove_devices(da9063->dev);
 err_irq_exit:
 	da9063_irq_exit(da9063);
 	return ret;
-- 
2.16.2

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

* [PATCH v4 11/12] regulator: da9063: Handle less LDOs on DA9063L
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (8 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 10/12] mfd: da9063: Register RTC only on DA9063L Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-05 23:10 ` [PATCH v4 12/12] mfd: da9063: Add DA9063L support Marek Vasut
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

Move the LDOs present only on DA9063 at the end of the list, so that
the DA9063L can simply indicate less LDOs and still share the list of
regulators with DA9063.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
V2: No change
V3: No change
V4: Change subject s/mfd/regulator/
---
 drivers/regulator/da9063-regulator.c | 76 +++++++++++++++++++++---------------
 1 file changed, 45 insertions(+), 31 deletions(-)

diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index eeb0d431dda1..0c09e73e0b23 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -529,6 +529,32 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
 		.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A,
 				 DA9063_BMEM_ILIM_MASK),
 	},
+	{
+		DA9063_LDO(DA9063, LDO3, 900, 20, 3440),
+		.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VLDO3_SEL),
+		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO3_LIM),
+	},
+	{
+		DA9063_LDO(DA9063, LDO7, 900, 50, 3600),
+		.suspend = BFIELD(DA9063_REG_LDO7_CONT, DA9063_VLDO7_SEL),
+		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO7_LIM),
+	},
+	{
+		DA9063_LDO(DA9063, LDO8, 900, 50, 3600),
+		.suspend = BFIELD(DA9063_REG_LDO8_CONT, DA9063_VLDO8_SEL),
+		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO8_LIM),
+	},
+	{
+		DA9063_LDO(DA9063, LDO9, 950, 50, 3600),
+		.suspend = BFIELD(DA9063_REG_LDO9_CONT, DA9063_VLDO9_SEL),
+	},
+	{
+		DA9063_LDO(DA9063, LDO11, 900, 50, 3600),
+		.suspend = BFIELD(DA9063_REG_LDO11_CONT, DA9063_VLDO11_SEL),
+		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO11_LIM),
+	},
+
+	/* The following LDOs are present only on DA9063, not on DA9063L */
 	{
 		DA9063_LDO(DA9063, LDO1, 600, 20, 1860),
 		.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VLDO1_SEL),
@@ -537,11 +563,6 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
 		DA9063_LDO(DA9063, LDO2, 600, 20, 1860),
 		.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VLDO2_SEL),
 	},
-	{
-		DA9063_LDO(DA9063, LDO3, 900, 20, 3440),
-		.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VLDO3_SEL),
-		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO3_LIM),
-	},
 	{
 		DA9063_LDO(DA9063, LDO4, 900, 20, 3440),
 		.suspend = BFIELD(DA9063_REG_DVC_2, DA9063_VLDO4_SEL),
@@ -555,29 +576,11 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
 		DA9063_LDO(DA9063, LDO6, 900, 50, 3600),
 		.suspend = BFIELD(DA9063_REG_LDO6_CONT, DA9063_VLDO6_SEL),
 	},
-	{
-		DA9063_LDO(DA9063, LDO7, 900, 50, 3600),
-		.suspend = BFIELD(DA9063_REG_LDO7_CONT, DA9063_VLDO7_SEL),
-		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO7_LIM),
-	},
-	{
-		DA9063_LDO(DA9063, LDO8, 900, 50, 3600),
-		.suspend = BFIELD(DA9063_REG_LDO8_CONT, DA9063_VLDO8_SEL),
-		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO8_LIM),
-	},
-	{
-		DA9063_LDO(DA9063, LDO9, 950, 50, 3600),
-		.suspend = BFIELD(DA9063_REG_LDO9_CONT, DA9063_VLDO9_SEL),
-	},
+
 	{
 		DA9063_LDO(DA9063, LDO10, 900, 50, 3600),
 		.suspend = BFIELD(DA9063_REG_LDO10_CONT, DA9063_VLDO10_SEL),
 	},
-	{
-		DA9063_LDO(DA9063, LDO11, 900, 50, 3600),
-		.suspend = BFIELD(DA9063_REG_LDO11_CONT, DA9063_VLDO11_SEL),
-		.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO11_LIM),
-	},
 };
 
 /* Link chip model with regulators info table */
@@ -587,6 +590,11 @@ static struct da9063_dev_model regulators_models[] = {
 		.n_regulators = ARRAY_SIZE(da9063_regulator_info),
 		.type = PMIC_TYPE_DA9063,
 	},
+	{
+		.regulator_info = da9063_regulator_info,
+		.n_regulators = ARRAY_SIZE(da9063_regulator_info) - 6,
+		.type = PMIC_TYPE_DA9063L,
+	},
 	{ }
 };
 
@@ -641,28 +649,34 @@ static struct of_regulator_match da9063_matches[] = {
 	[DA9063_ID_BPERI]            = { .name = "bperi",           },
 	[DA9063_ID_BCORES_MERGED]    = { .name = "bcores-merged"    },
 	[DA9063_ID_BMEM_BIO_MERGED]  = { .name = "bmem-bio-merged", },
+	[DA9063_ID_LDO3]             = { .name = "ldo3",            },
+	[DA9063_ID_LDO7]             = { .name = "ldo7",            },
+	[DA9063_ID_LDO8]             = { .name = "ldo8",            },
+	[DA9063_ID_LDO9]             = { .name = "ldo9",            },
+	[DA9063_ID_LDO11]            = { .name = "ldo11",           },
+	/* The following LDOs are present only on DA9063, not on DA9063L */
 	[DA9063_ID_LDO1]             = { .name = "ldo1",            },
 	[DA9063_ID_LDO2]             = { .name = "ldo2",            },
-	[DA9063_ID_LDO3]             = { .name = "ldo3",            },
 	[DA9063_ID_LDO4]             = { .name = "ldo4",            },
 	[DA9063_ID_LDO5]             = { .name = "ldo5",            },
 	[DA9063_ID_LDO6]             = { .name = "ldo6",            },
-	[DA9063_ID_LDO7]             = { .name = "ldo7",            },
-	[DA9063_ID_LDO8]             = { .name = "ldo8",            },
-	[DA9063_ID_LDO9]             = { .name = "ldo9",            },
 	[DA9063_ID_LDO10]            = { .name = "ldo10",           },
-	[DA9063_ID_LDO11]            = { .name = "ldo11",           },
 };
 
 static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
 		struct platform_device *pdev,
 		struct of_regulator_match **da9063_reg_matches)
 {
+	struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent);
 	struct da9063_regulators_pdata *pdata;
 	struct da9063_regulator_data *rdata;
 	struct device_node *node;
+	int da9063_matches_len = ARRAY_SIZE(da9063_matches);
 	int i, n, num;
 
+	if (da9063->type == PMIC_TYPE_DA9063L)
+		da9063_matches_len -= 6;
+
 	node = of_get_child_by_name(pdev->dev.parent->of_node, "regulators");
 	if (!node) {
 		dev_err(&pdev->dev, "Regulators device node not found\n");
@@ -670,7 +684,7 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
 	}
 
 	num = of_regulator_match(&pdev->dev, node, da9063_matches,
-				 ARRAY_SIZE(da9063_matches));
+				 da9063_matches_len);
 	of_node_put(node);
 	if (num < 0) {
 		dev_err(&pdev->dev, "Failed to match regulators\n");
@@ -689,7 +703,7 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
 	pdata->n_regulators = num;
 
 	n = 0;
-	for (i = 0; i < ARRAY_SIZE(da9063_matches); i++) {
+	for (i = 0; i < da9063_matches_len; i++) {
 		if (!da9063_matches[i].init_data)
 			continue;
 
-- 
2.16.2

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

* [PATCH v4 12/12] mfd: da9063: Add DA9063L support
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (9 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 11/12] regulator: da9063: Handle less LDOs " Marek Vasut
@ 2018-06-05 23:10 ` Marek Vasut
  2018-06-06  6:24 ` [PATCH v4 01/12] mfd: da9063: Fix failpath in core Geert Uytterhoeven
  2018-06-06  6:35 ` Lee Jones
  12 siblings, 0 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-05 23:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Geert Uytterhoeven, Lee Jones, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

Add support for DA9063L, which is a reduced variant of the DA9063
with less regulators and without RTC.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Steve Twiss <stwiss.opensource@diasemi.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
---
V2: No change
V3: No change
V4: No change
---
 drivers/mfd/da9063-i2c.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
index f0d92a37df6b..74a3b10a7208 100644
--- a/drivers/mfd/da9063-i2c.c
+++ b/drivers/mfd/da9063-i2c.c
@@ -319,6 +319,7 @@ static struct regmap_config da9063_regmap_config = {
 
 static const struct of_device_id da9063_dt_ids[] = {
 	{ .compatible = "dlg,da9063", },
+	{ .compatible = "dlg,da9063l", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, da9063_dt_ids);
@@ -373,6 +374,7 @@ static int da9063_i2c_remove(struct i2c_client *i2c)
 
 static const struct i2c_device_id da9063_i2c_id[] = {
 	{ "da9063", PMIC_TYPE_DA9063 },
+	{ "da9063l", PMIC_TYPE_DA9063L },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, da9063_i2c_id);
-- 
2.16.2

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

* Re: [PATCH v4 01/12] mfd: da9063: Fix failpath in core
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (10 preceding siblings ...)
  2018-06-05 23:10 ` [PATCH v4 12/12] mfd: da9063: Add DA9063L support Marek Vasut
@ 2018-06-06  6:24 ` Geert Uytterhoeven
  2018-06-06  6:35 ` Lee Jones
  12 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2018-06-06  6:24 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Linux Kernel Mailing List, Marek Vasut, Geert Uytterhoeven,
	Lee Jones, Mark Brown, Steve Twiss, Wolfram Sang, Linux-Renesas

Hi Marek,

On Wed, Jun 6, 2018 at 1:10 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
> In case mfd_add_devices() fails, da9063_irq_exit() is not called to
> undo the IRQchip setup done by da9063_irq_init(). Fix this by adding
> the missing fail path.

Thanks for your patch!

> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>

Please retain Reviewed-by tags (from Vaishali and me).

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE
  2018-06-05 23:10 ` [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE Marek Vasut
@ 2018-06-06  6:25   ` Geert Uytterhoeven
  2018-06-06  6:34   ` Lee Jones
  1 sibling, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2018-06-06  6:25 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Linux Kernel Mailing List, Marek Vasut, Geert Uytterhoeven,
	Lee Jones, Mark Brown, Steve Twiss, Wolfram Sang, Linux-Renesas

On Wed, Jun 6, 2018 at 1:10 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
> Use PLATFORM_DEVID_NONE instead of -1 in mfd_add_devices.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE
  2018-06-05 23:10 ` [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE Marek Vasut
@ 2018-06-06  6:28   ` Geert Uytterhoeven
  2018-06-06  6:36   ` Lee Jones
  1 sibling, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2018-06-06  6:28 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Linux Kernel Mailing List, Marek Vasut, Geert Uytterhoeven,
	Lee Jones, Mark Brown, Steve Twiss, Wolfram Sang, Linux-Renesas

Hi Marek,

On Wed, Jun 6, 2018 at 1:10 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
> Replace DA9063_NUM_IRQ macro which is not used anywhere with
> plain ARRAY_SIZE().

Thanks for your patch!

> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>

With the issue below fixed:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/include/linux/mfd/da9063/core.h
> +++ b/include/linux/mfd/da9063/core.h
> @@ -73,7 +73,6 @@ enum da9063_irqs {
>  };
>
>  #define DA9063_IRQ_BASE_OFFSET 0

DA9063_IRQ_BASE_OFFSET is now unused, so please remove it
(before someone starts using it, and makes it non-zero ;-)

> -#define DA9063_NUM_IRQ         (DA9063_IRQ_GPI15 + 1 - DA9063_IRQ_BASE_OFFSET)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE
  2018-06-05 23:10 ` [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE Marek Vasut
  2018-06-06  6:25   ` Geert Uytterhoeven
@ 2018-06-06  6:34   ` Lee Jones
  1 sibling, 0 replies; 23+ messages in thread
From: Lee Jones @ 2018-06-06  6:34 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

On Wed, 06 Jun 2018, Marek Vasut wrote:

> Use PLATFORM_DEVID_NONE instead of -1 in mfd_add_devices.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Steve Twiss <stwiss.opensource@diasemi.com>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V4: New patch
> ---
>  drivers/mfd/da9063-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v4 01/12] mfd: da9063: Fix failpath in core
  2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
                   ` (11 preceding siblings ...)
  2018-06-06  6:24 ` [PATCH v4 01/12] mfd: da9063: Fix failpath in core Geert Uytterhoeven
@ 2018-06-06  6:35 ` Lee Jones
  12 siblings, 0 replies; 23+ messages in thread
From: Lee Jones @ 2018-06-06  6:35 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

On Wed, 06 Jun 2018, Marek Vasut wrote:

> In case mfd_add_devices() fails, da9063_irq_exit() is not called to
> undo the IRQchip setup done by da9063_irq_init(). Fix this by adding
> the missing fail path.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Steve Twiss <stwiss.opensource@diasemi.com>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V3: New patch
> V4: No change
> ---
>  drivers/mfd/da9063-core.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE
  2018-06-05 23:10 ` [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE Marek Vasut
  2018-06-06  6:28   ` Geert Uytterhoeven
@ 2018-06-06  6:36   ` Lee Jones
  1 sibling, 0 replies; 23+ messages in thread
From: Lee Jones @ 2018-06-06  6:36 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

On Wed, 06 Jun 2018, Marek Vasut wrote:

> Replace DA9063_NUM_IRQ macro which is not used anywhere with
> plain ARRAY_SIZE().
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Steve Twiss <stwiss.opensource@diasemi.com>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V4: New patch
> ---
>  drivers/mfd/da9063-irq.c        | 2 +-
>  include/linux/mfd/da9063/core.h | 1 -
>  2 files changed, 1 insertion(+), 2 deletions(-)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v4 08/12] mfd: da9063: Add custom regmap for DA9063L
  2018-06-05 23:10 ` [PATCH v4 08/12] mfd: da9063: Add custom regmap for DA9063L Marek Vasut
@ 2018-06-06  6:39   ` Lee Jones
  2018-06-06  9:47     ` Marek Vasut
  0 siblings, 1 reply; 23+ messages in thread
From: Lee Jones @ 2018-06-06  6:39 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

On Wed, 06 Jun 2018, Marek Vasut wrote:

> The DA9063L does not have an RTC. Add custom regmap for DA9063L to
> prevent access into that register block.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Steve Twiss <stwiss.opensource@diasemi.com>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V3: New patch
> V4: Drop mention of buggy datasheet in the commit message
> ---
>  drivers/mfd/da9063-i2c.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 91 insertions(+)
> 
> diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
> index 048ce55ebc5b..f0d92a37df6b 100644
> --- a/drivers/mfd/da9063-i2c.c
> +++ b/drivers/mfd/da9063-i2c.c
> @@ -208,6 +208,93 @@ static const struct regmap_access_table da9063_bb_volatile_table = {
>  	.n_yes_ranges = ARRAY_SIZE(da9063_bb_volatile_ranges),
>  };
>  
> +static const struct regmap_range da9063l_bb_readable_ranges[] = {
> +	{
> +		.range_min = DA9063_REG_PAGE_CON,
> +		.range_max = DA9063_REG_MON_A10_RES,
> +	}, {
> +		.range_min = DA9063_REG_SEQ,
> +		.range_max = DA9063_REG_ID_32_31,
> +	}, {
> +		.range_min = DA9063_REG_SEQ_A,
> +		.range_max = DA9063_REG_AUTO3_LOW,
> +	}, {
> +		.range_min = DA9063_REG_T_OFFSET,
> +		.range_max = DA9063_BB_REG_GP_ID_19,
> +	}, {
> +		.range_min = DA9063_REG_CHIP_ID,
> +		.range_max = DA9063_REG_CHIP_VARIANT,
> +	},
> +};
> +
> +static const struct regmap_range da9063l_bb_writeable_ranges[] = {
> +	{
> +		.range_min = DA9063_REG_PAGE_CON,
> +		.range_max = DA9063_REG_PAGE_CON,
> +	}, {
> +		.range_min = DA9063_REG_FAULT_LOG,
> +		.range_max = DA9063_REG_VSYS_MON,
> +	}, {
> +		.range_min = DA9063_REG_SEQ,
> +		.range_max = DA9063_REG_ID_32_31,
> +	}, {
> +		.range_min = DA9063_REG_SEQ_A,
> +		.range_max = DA9063_REG_AUTO3_LOW,
> +	}, {
> +		.range_min = DA9063_REG_CONFIG_I,
> +		.range_max = DA9063_BB_REG_MON_REG_4,
> +	}, {
> +		.range_min = DA9063_BB_REG_GP_ID_0,
> +		.range_max = DA9063_BB_REG_GP_ID_19,
> +	},
> +};
> +
> +static const struct regmap_range da9063l_bb_volatile_ranges[] = {
> +	{
> +		.range_min = DA9063_REG_PAGE_CON,
> +		.range_max = DA9063_REG_EVENT_D,
> +	}, {
> +		.range_min = DA9063_REG_CONTROL_A,
> +		.range_max = DA9063_REG_CONTROL_B,
> +	}, {
> +		.range_min = DA9063_REG_CONTROL_E,
> +		.range_max = DA9063_REG_CONTROL_F,
> +	}, {
> +		.range_min = DA9063_REG_BCORE2_CONT,
> +		.range_max = DA9063_REG_LDO11_CONT,
> +	}, {
> +		.range_min = DA9063_REG_DVC_1,
> +		.range_max = DA9063_REG_ADC_MAN,
> +	}, {
> +		.range_min = DA9063_REG_ADC_RES_L,
> +		.range_max = DA9063_REG_MON_A10_RES,
> +	}, {
> +		.range_min = DA9063_REG_SEQ,
> +		.range_max = DA9063_REG_SEQ,
> +	}, {
> +		.range_min = DA9063_REG_EN_32K,
> +		.range_max = DA9063_REG_EN_32K,
> +	}, {
> +		.range_min = DA9063_BB_REG_MON_REG_5,
> +		.range_max = DA9063_BB_REG_MON_REG_6,
> +	},
> +};

Not sure why the regmap_reg_range() MACRO is lower case, but still,
please make use of it to save a few lines.

Once changed, please add my:

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v4 09/12] mfd: da9063: Add custom IRQ map for DA9063L
  2018-06-05 23:10 ` [PATCH v4 09/12] mfd: da9063: Add custom IRQ map " Marek Vasut
@ 2018-06-06  6:40   ` Lee Jones
  0 siblings, 0 replies; 23+ messages in thread
From: Lee Jones @ 2018-06-06  6:40 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

On Wed, 06 Jun 2018, Marek Vasut wrote:

> The DA9063L does not have an RTC. Add custom IRQ map for DA9063L to
> ignore the Alarm and Tick IRQs from the PMIC.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Steve Twiss <stwiss.opensource@diasemi.com>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V3: New patch
> V4: - Formatting fixes
>     - Drop extra newline in da9063l_irq_chip
>     - Drop mention of the buggy datasheet in commit message

Sweet.  Looks great and makes checkpatch.pl happy.  Thanks.

> ---
>  drivers/mfd/da9063-irq.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 79 insertions(+), 2 deletions(-)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v4 10/12] mfd: da9063: Register RTC only on DA9063L
  2018-06-05 23:10 ` [PATCH v4 10/12] mfd: da9063: Register RTC only on DA9063L Marek Vasut
@ 2018-06-06  6:41   ` Lee Jones
  0 siblings, 0 replies; 23+ messages in thread
From: Lee Jones @ 2018-06-06  6:41 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

On Wed, 06 Jun 2018, Marek Vasut wrote:

> The DA9063L does not contain RTC block, unlike the full DA9063.
> Split the RTC block into separate mfd cell and register it only
> on DA9063.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Steve Twiss <stwiss.opensource@diasemi.com>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V2: No change
> V3: Rework of mfd: da9063: Disallow RTC on DA9063L
> V4: - Change the original failure text
>     - Use PLATFORM_DEVID_NONE in mfd_add_devices
> ---
>  drivers/mfd/da9063-core.c | 33 +++++++++++++++++++++++++--------
>  1 file changed, 25 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
> index 9aff815877c0..3443c9321c09 100644
> --- a/drivers/mfd/da9063-core.c
> +++ b/drivers/mfd/da9063-core.c
> @@ -76,7 +76,7 @@ static struct resource da9063_hwmon_resources[] = {
>  };
>  
>  
> -static const struct mfd_cell da9063_devs[] = {
> +static const struct mfd_cell da9063_common_devs[] = {
>  	{
>  		.name		= DA9063_DRVNAME_REGULATORS,
>  		.num_resources	= ARRAY_SIZE(da9063_regulators_resources),
> @@ -100,15 +100,19 @@ static const struct mfd_cell da9063_devs[] = {
>  		.resources	= da9063_onkey_resources,
>  		.of_compatible = "dlg,da9063-onkey",
>  	},
> +	{
> +		.name		= DA9063_DRVNAME_VIBRATION,
> +	},
> +};

Still not a fan of multi-line single entries, but seeing as it was
already multi-line and you are just moving it, I'll let it go.

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v4 08/12] mfd: da9063: Add custom regmap for DA9063L
  2018-06-06  6:39   ` Lee Jones
@ 2018-06-06  9:47     ` Marek Vasut
  0 siblings, 0 replies; 23+ messages in thread
From: Marek Vasut @ 2018-06-06  9:47 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, Mark Brown,
	Steve Twiss, Wolfram Sang, linux-renesas-soc

On 06/06/2018 08:39 AM, Lee Jones wrote:
> On Wed, 06 Jun 2018, Marek Vasut wrote:
> 
>> The DA9063L does not have an RTC. Add custom regmap for DA9063L to
>> prevent access into that register block.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
>> Cc: Lee Jones <lee.jones@linaro.org>
>> Cc: Mark Brown <broonie@kernel.org>
>> Cc: Steve Twiss <stwiss.opensource@diasemi.com>
>> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
>> Cc: linux-renesas-soc@vger.kernel.org
>> ---
>> V3: New patch
>> V4: Drop mention of buggy datasheet in the commit message
>> ---
>>  drivers/mfd/da9063-i2c.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 91 insertions(+)
>>
>> diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
>> index 048ce55ebc5b..f0d92a37df6b 100644
>> --- a/drivers/mfd/da9063-i2c.c
>> +++ b/drivers/mfd/da9063-i2c.c
>> @@ -208,6 +208,93 @@ static const struct regmap_access_table da9063_bb_volatile_table = {
>>  	.n_yes_ranges = ARRAY_SIZE(da9063_bb_volatile_ranges),
>>  };
>>  
>> +static const struct regmap_range da9063l_bb_readable_ranges[] = {
>> +	{
>> +		.range_min = DA9063_REG_PAGE_CON,
>> +		.range_max = DA9063_REG_MON_A10_RES,
>> +	}, {
>> +		.range_min = DA9063_REG_SEQ,
>> +		.range_max = DA9063_REG_ID_32_31,
>> +	}, {
>> +		.range_min = DA9063_REG_SEQ_A,
>> +		.range_max = DA9063_REG_AUTO3_LOW,
>> +	}, {
>> +		.range_min = DA9063_REG_T_OFFSET,
>> +		.range_max = DA9063_BB_REG_GP_ID_19,
>> +	}, {
>> +		.range_min = DA9063_REG_CHIP_ID,
>> +		.range_max = DA9063_REG_CHIP_VARIANT,
>> +	},
>> +};
>> +
>> +static const struct regmap_range da9063l_bb_writeable_ranges[] = {
>> +	{
>> +		.range_min = DA9063_REG_PAGE_CON,
>> +		.range_max = DA9063_REG_PAGE_CON,
>> +	}, {
>> +		.range_min = DA9063_REG_FAULT_LOG,
>> +		.range_max = DA9063_REG_VSYS_MON,
>> +	}, {
>> +		.range_min = DA9063_REG_SEQ,
>> +		.range_max = DA9063_REG_ID_32_31,
>> +	}, {
>> +		.range_min = DA9063_REG_SEQ_A,
>> +		.range_max = DA9063_REG_AUTO3_LOW,
>> +	}, {
>> +		.range_min = DA9063_REG_CONFIG_I,
>> +		.range_max = DA9063_BB_REG_MON_REG_4,
>> +	}, {
>> +		.range_min = DA9063_BB_REG_GP_ID_0,
>> +		.range_max = DA9063_BB_REG_GP_ID_19,
>> +	},
>> +};
>> +
>> +static const struct regmap_range da9063l_bb_volatile_ranges[] = {
>> +	{
>> +		.range_min = DA9063_REG_PAGE_CON,
>> +		.range_max = DA9063_REG_EVENT_D,
>> +	}, {
>> +		.range_min = DA9063_REG_CONTROL_A,
>> +		.range_max = DA9063_REG_CONTROL_B,
>> +	}, {
>> +		.range_min = DA9063_REG_CONTROL_E,
>> +		.range_max = DA9063_REG_CONTROL_F,
>> +	}, {
>> +		.range_min = DA9063_REG_BCORE2_CONT,
>> +		.range_max = DA9063_REG_LDO11_CONT,
>> +	}, {
>> +		.range_min = DA9063_REG_DVC_1,
>> +		.range_max = DA9063_REG_ADC_MAN,
>> +	}, {
>> +		.range_min = DA9063_REG_ADC_RES_L,
>> +		.range_max = DA9063_REG_MON_A10_RES,
>> +	}, {
>> +		.range_min = DA9063_REG_SEQ,
>> +		.range_max = DA9063_REG_SEQ,
>> +	}, {
>> +		.range_min = DA9063_REG_EN_32K,
>> +		.range_max = DA9063_REG_EN_32K,
>> +	}, {
>> +		.range_min = DA9063_BB_REG_MON_REG_5,
>> +		.range_max = DA9063_BB_REG_MON_REG_6,
>> +	},
>> +};
> 
> Not sure why the regmap_reg_range() MACRO is lower case, but still,
> please make use of it to save a few lines.

Ha, OK

> Once changed, please add my:
> 
> For my own reference:
>   Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
> 


-- 
Best regards,
Marek Vasut

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

* Re: [PATCH v4 06/12] mfd: da9063: Replace model with type
  2018-06-05 23:10 ` [PATCH v4 06/12] mfd: da9063: Replace model with type Marek Vasut
@ 2018-06-06 14:04   ` kbuild test robot
  0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2018-06-06 14:04 UTC (permalink / raw)
  To: Marek Vasut
  Cc: kbuild-all, linux-kernel, Marek Vasut, Geert Uytterhoeven,
	Lee Jones, Mark Brown, Steve Twiss, Wolfram Sang,
	linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 13262 bytes --]

Hi Marek,

I love your patch! Yet something to improve:

[auto build test ERROR on ljones-mfd/for-mfd-next]
[also build test ERROR on v4.17 next-20180605]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Marek-Vasut/mfd-da9063-Fix-failpath-in-core/20180606-212247
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
config: i386-randconfig-x079-201822 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/regulator/da9063-regulator.c: In function 'da9063_regulator_probe':
>> drivers/regulator/da9063-regulator.c:749:10: error: 'struct da9063' has no member named 'model'
       da9063->model);
             ^~

vim +749 drivers/regulator/da9063-regulator.c

69ca3e58 Krystian Garbaciak 2013-07-29  715  
69ca3e58 Krystian Garbaciak 2013-07-29  716  static int da9063_regulator_probe(struct platform_device *pdev)
69ca3e58 Krystian Garbaciak 2013-07-29  717  {
69ca3e58 Krystian Garbaciak 2013-07-29  718  	struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent);
69ca3e58 Krystian Garbaciak 2013-07-29  719  	struct da9063_pdata *da9063_pdata = dev_get_platdata(da9063->dev);
0fdfd40a Geert Uytterhoeven 2013-09-09  720  	struct of_regulator_match *da9063_reg_matches = NULL;
69ca3e58 Krystian Garbaciak 2013-07-29  721  	struct da9063_regulators_pdata *regl_pdata;
69ca3e58 Krystian Garbaciak 2013-07-29  722  	const struct da9063_dev_model *model;
69ca3e58 Krystian Garbaciak 2013-07-29  723  	struct da9063_regulators *regulators;
69ca3e58 Krystian Garbaciak 2013-07-29  724  	struct da9063_regulator *regl;
69ca3e58 Krystian Garbaciak 2013-07-29  725  	struct regulator_config config;
69ca3e58 Krystian Garbaciak 2013-07-29  726  	bool bcores_merged, bmem_bio_merged;
69ca3e58 Krystian Garbaciak 2013-07-29  727  	int id, irq, n, n_regulators, ret, val;
69ca3e58 Krystian Garbaciak 2013-07-29  728  	size_t size;
69ca3e58 Krystian Garbaciak 2013-07-29  729  
69ca3e58 Krystian Garbaciak 2013-07-29  730  	regl_pdata = da9063_pdata ? da9063_pdata->regulators_pdata : NULL;
69ca3e58 Krystian Garbaciak 2013-07-29  731  
69ca3e58 Krystian Garbaciak 2013-07-29  732  	if (!regl_pdata)
69ca3e58 Krystian Garbaciak 2013-07-29  733  		regl_pdata = da9063_parse_regulators_dt(pdev,
69ca3e58 Krystian Garbaciak 2013-07-29  734  							&da9063_reg_matches);
69ca3e58 Krystian Garbaciak 2013-07-29  735  
69ca3e58 Krystian Garbaciak 2013-07-29  736  	if (IS_ERR(regl_pdata) || regl_pdata->n_regulators == 0) {
69ca3e58 Krystian Garbaciak 2013-07-29  737  		dev_err(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  738  			"No regulators defined for the platform\n");
b6615659 Dan Carpenter      2017-08-30  739  		return -ENODEV;
69ca3e58 Krystian Garbaciak 2013-07-29  740  	}
69ca3e58 Krystian Garbaciak 2013-07-29  741  
69ca3e58 Krystian Garbaciak 2013-07-29  742  	/* Find regulators set for particular device model */
69ca3e58 Krystian Garbaciak 2013-07-29  743  	for (model = regulators_models; model->regulator_info; model++) {
9a58dfc5 Marek Vasut        2018-06-06  744  		if (model->type == da9063->type)
69ca3e58 Krystian Garbaciak 2013-07-29  745  			break;
69ca3e58 Krystian Garbaciak 2013-07-29  746  	}
69ca3e58 Krystian Garbaciak 2013-07-29  747  	if (!model->regulator_info) {
69ca3e58 Krystian Garbaciak 2013-07-29  748  		dev_err(&pdev->dev, "Chip model not recognised (%u)\n",
69ca3e58 Krystian Garbaciak 2013-07-29 @749  			da9063->model);
69ca3e58 Krystian Garbaciak 2013-07-29  750  		return -ENODEV;
69ca3e58 Krystian Garbaciak 2013-07-29  751  	}
69ca3e58 Krystian Garbaciak 2013-07-29  752  
69ca3e58 Krystian Garbaciak 2013-07-29  753  	ret = regmap_read(da9063->regmap, DA9063_REG_CONFIG_H, &val);
69ca3e58 Krystian Garbaciak 2013-07-29  754  	if (ret < 0) {
69ca3e58 Krystian Garbaciak 2013-07-29  755  		dev_err(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  756  			"Error while reading BUCKs configuration\n");
8a7963d5 Sachin Kamat       2014-02-18  757  		return ret;
69ca3e58 Krystian Garbaciak 2013-07-29  758  	}
69ca3e58 Krystian Garbaciak 2013-07-29  759  	bcores_merged = val & DA9063_BCORE_MERGE;
69ca3e58 Krystian Garbaciak 2013-07-29  760  	bmem_bio_merged = val & DA9063_BUCK_MERGE;
69ca3e58 Krystian Garbaciak 2013-07-29  761  
69ca3e58 Krystian Garbaciak 2013-07-29  762  	n_regulators = model->n_regulators;
69ca3e58 Krystian Garbaciak 2013-07-29  763  	if (bcores_merged)
69ca3e58 Krystian Garbaciak 2013-07-29  764  		n_regulators -= 2; /* remove BCORE1, BCORE2 */
69ca3e58 Krystian Garbaciak 2013-07-29  765  	else
69ca3e58 Krystian Garbaciak 2013-07-29  766  		n_regulators--;    /* remove BCORES_MERGED */
69ca3e58 Krystian Garbaciak 2013-07-29  767  	if (bmem_bio_merged)
69ca3e58 Krystian Garbaciak 2013-07-29  768  		n_regulators -= 2; /* remove BMEM, BIO */
69ca3e58 Krystian Garbaciak 2013-07-29  769  	else
69ca3e58 Krystian Garbaciak 2013-07-29  770  		n_regulators--;    /* remove BMEM_BIO_MERGED */
69ca3e58 Krystian Garbaciak 2013-07-29  771  
69ca3e58 Krystian Garbaciak 2013-07-29  772  	/* Allocate memory required by usable regulators */
69ca3e58 Krystian Garbaciak 2013-07-29  773  	size = sizeof(struct da9063_regulators) +
69ca3e58 Krystian Garbaciak 2013-07-29  774  		n_regulators * sizeof(struct da9063_regulator);
69ca3e58 Krystian Garbaciak 2013-07-29  775  	regulators = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
8b5baa56 Sachin Kamat       2014-02-20  776  	if (!regulators)
69ca3e58 Krystian Garbaciak 2013-07-29  777  		return -ENOMEM;
69ca3e58 Krystian Garbaciak 2013-07-29  778  
69ca3e58 Krystian Garbaciak 2013-07-29  779  	regulators->n_regulators = n_regulators;
69ca3e58 Krystian Garbaciak 2013-07-29  780  	platform_set_drvdata(pdev, regulators);
69ca3e58 Krystian Garbaciak 2013-07-29  781  
69ca3e58 Krystian Garbaciak 2013-07-29  782  	/* Register all regulators declared in platform information */
69ca3e58 Krystian Garbaciak 2013-07-29  783  	n = 0;
69ca3e58 Krystian Garbaciak 2013-07-29  784  	id = 0;
69ca3e58 Krystian Garbaciak 2013-07-29  785  	while (n < regulators->n_regulators) {
69ca3e58 Krystian Garbaciak 2013-07-29  786  		/* Skip regulator IDs depending on merge mode configuration */
69ca3e58 Krystian Garbaciak 2013-07-29  787  		switch (id) {
69ca3e58 Krystian Garbaciak 2013-07-29  788  		case DA9063_ID_BCORE1:
69ca3e58 Krystian Garbaciak 2013-07-29  789  		case DA9063_ID_BCORE2:
69ca3e58 Krystian Garbaciak 2013-07-29  790  			if (bcores_merged) {
69ca3e58 Krystian Garbaciak 2013-07-29  791  				id++;
69ca3e58 Krystian Garbaciak 2013-07-29  792  				continue;
69ca3e58 Krystian Garbaciak 2013-07-29  793  			}
69ca3e58 Krystian Garbaciak 2013-07-29  794  			break;
69ca3e58 Krystian Garbaciak 2013-07-29  795  		case DA9063_ID_BMEM:
69ca3e58 Krystian Garbaciak 2013-07-29  796  		case DA9063_ID_BIO:
69ca3e58 Krystian Garbaciak 2013-07-29  797  			if (bmem_bio_merged) {
69ca3e58 Krystian Garbaciak 2013-07-29  798  				id++;
69ca3e58 Krystian Garbaciak 2013-07-29  799  				continue;
69ca3e58 Krystian Garbaciak 2013-07-29  800  			}
69ca3e58 Krystian Garbaciak 2013-07-29  801  			break;
69ca3e58 Krystian Garbaciak 2013-07-29  802  		case DA9063_ID_BCORES_MERGED:
69ca3e58 Krystian Garbaciak 2013-07-29  803  			if (!bcores_merged) {
69ca3e58 Krystian Garbaciak 2013-07-29  804  				id++;
69ca3e58 Krystian Garbaciak 2013-07-29  805  				continue;
69ca3e58 Krystian Garbaciak 2013-07-29  806  			}
69ca3e58 Krystian Garbaciak 2013-07-29  807  			break;
69ca3e58 Krystian Garbaciak 2013-07-29  808  		case DA9063_ID_BMEM_BIO_MERGED:
69ca3e58 Krystian Garbaciak 2013-07-29  809  			if (!bmem_bio_merged) {
69ca3e58 Krystian Garbaciak 2013-07-29  810  				id++;
69ca3e58 Krystian Garbaciak 2013-07-29  811  				continue;
69ca3e58 Krystian Garbaciak 2013-07-29  812  			}
69ca3e58 Krystian Garbaciak 2013-07-29  813  			break;
69ca3e58 Krystian Garbaciak 2013-07-29  814  		}
69ca3e58 Krystian Garbaciak 2013-07-29  815  
69ca3e58 Krystian Garbaciak 2013-07-29  816  		/* Initialise regulator structure */
69ca3e58 Krystian Garbaciak 2013-07-29  817  		regl = &regulators->regulator[n];
69ca3e58 Krystian Garbaciak 2013-07-29  818  		regl->hw = da9063;
69ca3e58 Krystian Garbaciak 2013-07-29  819  		regl->info = &model->regulator_info[id];
69ca3e58 Krystian Garbaciak 2013-07-29  820  		regl->desc = regl->info->desc;
69ca3e58 Krystian Garbaciak 2013-07-29  821  		regl->desc.type = REGULATOR_VOLTAGE;
69ca3e58 Krystian Garbaciak 2013-07-29  822  		regl->desc.owner = THIS_MODULE;
69ca3e58 Krystian Garbaciak 2013-07-29  823  
69ca3e58 Krystian Garbaciak 2013-07-29  824  		if (regl->info->mode.reg)
69ca3e58 Krystian Garbaciak 2013-07-29  825  			regl->mode = devm_regmap_field_alloc(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  826  					da9063->regmap, regl->info->mode);
69ca3e58 Krystian Garbaciak 2013-07-29  827  		if (regl->info->suspend.reg)
69ca3e58 Krystian Garbaciak 2013-07-29  828  			regl->suspend = devm_regmap_field_alloc(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  829  					da9063->regmap, regl->info->suspend);
69ca3e58 Krystian Garbaciak 2013-07-29  830  		if (regl->info->sleep.reg)
69ca3e58 Krystian Garbaciak 2013-07-29  831  			regl->sleep = devm_regmap_field_alloc(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  832  					da9063->regmap, regl->info->sleep);
69ca3e58 Krystian Garbaciak 2013-07-29  833  		if (regl->info->suspend_sleep.reg)
69ca3e58 Krystian Garbaciak 2013-07-29  834  			regl->suspend_sleep = devm_regmap_field_alloc(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  835  					da9063->regmap, regl->info->suspend_sleep);
69ca3e58 Krystian Garbaciak 2013-07-29  836  		if (regl->info->ilimit.reg)
69ca3e58 Krystian Garbaciak 2013-07-29  837  			regl->ilimit = devm_regmap_field_alloc(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  838  					da9063->regmap, regl->info->ilimit);
69ca3e58 Krystian Garbaciak 2013-07-29  839  
69ca3e58 Krystian Garbaciak 2013-07-29  840  		/* Register regulator */
69ca3e58 Krystian Garbaciak 2013-07-29  841  		memset(&config, 0, sizeof(config));
69ca3e58 Krystian Garbaciak 2013-07-29  842  		config.dev = &pdev->dev;
69ca3e58 Krystian Garbaciak 2013-07-29  843  		config.init_data = da9063_get_regulator_initdata(regl_pdata, id);
69ca3e58 Krystian Garbaciak 2013-07-29  844  		config.driver_data = regl;
69ca3e58 Krystian Garbaciak 2013-07-29  845  		if (da9063_reg_matches)
69ca3e58 Krystian Garbaciak 2013-07-29  846  			config.of_node = da9063_reg_matches[id].of_node;
69ca3e58 Krystian Garbaciak 2013-07-29  847  		config.regmap = da9063->regmap;
e97bba91 Jingoo Han         2013-09-30  848  		regl->rdev = devm_regulator_register(&pdev->dev, &regl->desc,
e97bba91 Jingoo Han         2013-09-30  849  						     &config);
e515800b Axel Lin           2013-08-30  850  		if (IS_ERR(regl->rdev)) {
69ca3e58 Krystian Garbaciak 2013-07-29  851  			dev_err(&pdev->dev,
69ca3e58 Krystian Garbaciak 2013-07-29  852  				"Failed to register %s regulator\n",
69ca3e58 Krystian Garbaciak 2013-07-29  853  				regl->desc.name);
e97bba91 Jingoo Han         2013-09-30  854  			return PTR_ERR(regl->rdev);
69ca3e58 Krystian Garbaciak 2013-07-29  855  		}
69ca3e58 Krystian Garbaciak 2013-07-29  856  		id++;
69ca3e58 Krystian Garbaciak 2013-07-29  857  		n++;
69ca3e58 Krystian Garbaciak 2013-07-29  858  	}
69ca3e58 Krystian Garbaciak 2013-07-29  859  
69ca3e58 Krystian Garbaciak 2013-07-29  860  	/* LDOs overcurrent event support */
69ca3e58 Krystian Garbaciak 2013-07-29  861  	irq = platform_get_irq_byname(pdev, "LDO_LIM");
69ca3e58 Krystian Garbaciak 2013-07-29  862  	if (irq < 0) {
69ca3e58 Krystian Garbaciak 2013-07-29  863  		dev_err(&pdev->dev, "Failed to get IRQ.\n");
e97bba91 Jingoo Han         2013-09-30  864  		return irq;
69ca3e58 Krystian Garbaciak 2013-07-29  865  	}
69ca3e58 Krystian Garbaciak 2013-07-29  866  
d87aef91 Axel Lin           2015-05-31  867  	ret = devm_request_threaded_irq(&pdev->dev, irq,
69ca3e58 Krystian Garbaciak 2013-07-29  868  				NULL, da9063_ldo_lim_event,
69ca3e58 Krystian Garbaciak 2013-07-29  869  				IRQF_TRIGGER_LOW | IRQF_ONESHOT,
69ca3e58 Krystian Garbaciak 2013-07-29  870  				"LDO_LIM", regulators);
69ca3e58 Krystian Garbaciak 2013-07-29  871  	if (ret) {
d87aef91 Axel Lin           2015-05-31  872  		dev_err(&pdev->dev, "Failed to request LDO_LIM IRQ.\n");
d87aef91 Axel Lin           2015-05-31  873  		return ret;
69ca3e58 Krystian Garbaciak 2013-07-29  874  	}
69ca3e58 Krystian Garbaciak 2013-07-29  875  
69ca3e58 Krystian Garbaciak 2013-07-29  876  	return 0;
69ca3e58 Krystian Garbaciak 2013-07-29  877  }
69ca3e58 Krystian Garbaciak 2013-07-29  878  

:::::: The code at line 749 was first introduced by commit
:::::: 69ca3e58d17854f8fa72d85aea6bf4614ad25a56 regulator: da9063: Add Dialog DA9063 voltage regulators support.

:::::: TO: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
:::::: CC: Mark Brown <broonie@linaro.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29017 bytes --]

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

end of thread, other threads:[~2018-06-06 14:04 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 23:10 [PATCH v4 01/12] mfd: da9063: Fix failpath in core Marek Vasut
2018-06-05 23:10 ` [PATCH v4 02/12] mfd: da9063: Use REGMAP_IRQ_REG Marek Vasut
2018-06-05 23:10 ` [PATCH v4 03/12] mfd: da9063: Use PLATFORM_DEVID_NONE Marek Vasut
2018-06-06  6:25   ` Geert Uytterhoeven
2018-06-06  6:34   ` Lee Jones
2018-06-05 23:10 ` [PATCH v4 04/12] mfd: da9063: Replace DA9063_NUM_IRQ with ARRAY_SIZE Marek Vasut
2018-06-06  6:28   ` Geert Uytterhoeven
2018-06-06  6:36   ` Lee Jones
2018-06-05 23:10 ` [PATCH v4 05/12] mfd: da9063: Rename PMIC_DA9063 to PMIC_CHIP_ID_DA9063 Marek Vasut
2018-06-05 23:10 ` [PATCH v4 06/12] mfd: da9063: Replace model with type Marek Vasut
2018-06-06 14:04   ` kbuild test robot
2018-06-05 23:10 ` [PATCH v4 07/12] mfd: da9063: Add DA9063L type Marek Vasut
2018-06-05 23:10 ` [PATCH v4 08/12] mfd: da9063: Add custom regmap for DA9063L Marek Vasut
2018-06-06  6:39   ` Lee Jones
2018-06-06  9:47     ` Marek Vasut
2018-06-05 23:10 ` [PATCH v4 09/12] mfd: da9063: Add custom IRQ map " Marek Vasut
2018-06-06  6:40   ` Lee Jones
2018-06-05 23:10 ` [PATCH v4 10/12] mfd: da9063: Register RTC only on DA9063L Marek Vasut
2018-06-06  6:41   ` Lee Jones
2018-06-05 23:10 ` [PATCH v4 11/12] regulator: da9063: Handle less LDOs " Marek Vasut
2018-06-05 23:10 ` [PATCH v4 12/12] mfd: da9063: Add DA9063L support Marek Vasut
2018-06-06  6:24 ` [PATCH v4 01/12] mfd: da9063: Fix failpath in core Geert Uytterhoeven
2018-06-06  6:35 ` Lee Jones

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