linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Add MFD/Regulator support for ATC260x PMICs
@ 2019-06-17 15:50 Manivannan Sadhasivam
  2019-06-17 15:50 ` [PATCH 1/4] dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding Manivannan Sadhasivam
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Manivannan Sadhasivam @ 2019-06-17 15:50 UTC (permalink / raw)
  To: lee.jones, lgirdwood, broonie, robh+dt
  Cc: afaerber, linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij, Manivannan Sadhasivam

Hello,

This patchset adds MFD core and Regulator support for Actions Semi ATC260x
PMICs. ATC260x series PMICs integrates Audio Codec, Power management,
Clock generation, and GPIO controller blocks. There are 3 variants of this
PMIC series exist today:

ATC2603A
ATC2603C
ATC2609A

This patchset adds only ATC2609A PMIC support with regulator functionality.
Regulator driver supports 4 DC-DC converters and 10 LDO regulators.

This series has been tested on 96Boards Bubblegum96 board integrating
ATC2609A. Since the board support depends on the SIRQ driver (being reviewed),
I haven't added any dts changes for now!

Thanks,
Mani

Manivannan Sadhasivam (4):
  dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding
  mfd: Add initial MFD driver for ATC260x PMICs
  regulator: Add regulator driver for ATC260x PMICs
  MAINTAINERS: Add entry for ATC260x PMIC

 .../devicetree/bindings/mfd/atc260x.txt       | 162 ++++++++
 MAINTAINERS                                   |   9 +
 drivers/mfd/Kconfig                           |  22 +
 drivers/mfd/Makefile                          |   7 +
 drivers/mfd/atc2609a-helpers.c                |  91 ++++
 drivers/mfd/atc260x-core.c                    |  85 ++++
 drivers/mfd/atc260x-i2c.c                     |  98 +++++
 drivers/mfd/atc260x.h                         |  22 +
 drivers/regulator/Kconfig                     |   8 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/atc260x-regulator.c         | 389 ++++++++++++++++++
 include/linux/mfd/atc260x/atc2609a_regs.h     | 228 ++++++++++
 include/linux/mfd/atc260x/core.h              |  64 +++
 13 files changed, 1186 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atc260x.txt
 create mode 100644 drivers/mfd/atc2609a-helpers.c
 create mode 100644 drivers/mfd/atc260x-core.c
 create mode 100644 drivers/mfd/atc260x-i2c.c
 create mode 100644 drivers/mfd/atc260x.h
 create mode 100644 drivers/regulator/atc260x-regulator.c
 create mode 100644 include/linux/mfd/atc260x/atc2609a_regs.h
 create mode 100644 include/linux/mfd/atc260x/core.h

-- 
2.17.1


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

* [PATCH 1/4] dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding
  2019-06-17 15:50 [PATCH 0/4] Add MFD/Regulator support for ATC260x PMICs Manivannan Sadhasivam
@ 2019-06-17 15:50 ` Manivannan Sadhasivam
  2019-07-09 16:48   ` Rob Herring
  2019-06-17 15:50 ` [PATCH 2/4] mfd: Add initial MFD driver for ATC260x PMICs Manivannan Sadhasivam
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ messages in thread
From: Manivannan Sadhasivam @ 2019-06-17 15:50 UTC (permalink / raw)
  To: lee.jones, lgirdwood, broonie, robh+dt
  Cc: afaerber, linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij, Manivannan Sadhasivam

Add devicetree binding for Actions Semi ATC260x PMICs.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 .../devicetree/bindings/mfd/atc260x.txt       | 162 ++++++++++++++++++
 1 file changed, 162 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atc260x.txt

diff --git a/Documentation/devicetree/bindings/mfd/atc260x.txt b/Documentation/devicetree/bindings/mfd/atc260x.txt
new file mode 100644
index 000000000000..c72790132ed7
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atc260x.txt
@@ -0,0 +1,162 @@
+Actions Semi ATC260X PMIC
+
+The atc260x family current members:
+atc2609a
+
+Required properties:
+- compatible: "actions,atc2609a"
+- reg: I2C slave address
+- interrupts: The interrupt line the IRQ signal for the device is connected to
+
+Optional ATC2609A properties:
+- vcc0-supply:  The input supply for DCDC_REG0
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG0
+- vcc6-supply:  The input supply for LDO_REG1
+- vcc7-supply:  The input supply for LDO_REG2
+- vcc8-supply:  The input supply for LDO_REG3
+- vcc9-supply:  The input supply for LDO_REG4
+- vcc10-supply:  The input supply for LDO_REG5
+- vcc11-supply:  The input supply for LDO_REG6
+- vcc12-supply: The input supply for LDO_REG7
+- vcc13-supply: The input supply for LDO_REG8
+- vcc14-supply: The input supply for LDO_REG9
+
+Regulators: All the regulators of ATC260X to be instantiated shall be
+listed in a child node named 'regulators'. Each regulator is represented
+by a child node of the 'regulators' node.
+
+	regulator-name {
+		/* standard regulator bindings here */
+	};
+
+Following regulators of the ATC2609A PMIC regulators are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in ATC2609A datasheet.
+
+	- DCDC_REGn
+		- valid values for n are 0 to 4.
+	- LDO_REGn
+		- valid values for n are 0 to 9
+
+Standard regulator bindings are used inside regulator subnodes. Check
+  Documentation/devicetree/bindings/regulator/regulator.txt
+for more details
+
+Example:
+	atc260x: pmic@65 {
+		compatible = "actions,atc2609a";
+		reg = <0x65>;
+		interrupt-parent = <&sirq>;
+		interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
+
+		vcc0-supply = <&reg_5v0>;
+		vcc1-supply = <&reg_5v0>;
+		vcc2-supply = <&reg_5v0>;
+		vcc3-supply = <&reg_5v0>;
+		vcc4-supply = <&reg_5v0>;
+		vcc5-supply = <&reg_3v1>;
+		vcc6-supply = <&reg_5v0>;
+		vcc7-supply = <&reg_5v0>;
+		vcc9-supply = <&reg_5v0>;
+		vcc10-supply = <&reg_5v0>;
+		vcc11-supply = <&reg_3v1>;
+		vcc12-supply = <&reg_3v1>;
+		vcc13-supply = <&reg_5v0>;
+		vddio-supply = <&reg_3v1>;
+
+		regulators {
+			vdd_core: DCDC_REG0 {
+				regulator-name = "vdd_core";
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <1300000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			vdd_cpu: DCDC_REG1 {
+				regulator-name = "vdd_cpu";
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <1300000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			vddq_1v2: DCDC_REG2 {
+				regulator-name = "vddq_1v2";
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			vcc_3v1: DCDC_REG3 {
+				regulator-name = "vcc_3v1";
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <3500000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			vdd_cpum: DCDC_REG4 {
+				regulator-name = "vdd_cpum";
+				regulator-min-microvolt = <600000>;
+				regulator-max-microvolt = <1300000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			sd_vcc: LDO_REG0 {
+				regulator-name = "sd_vcc";
+				regulator-min-microvolt = <2300000>;
+				regulator-max-microvolt = <3400000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			wifi_3v3: LDO_REG1 {
+				regulator-name = "wifi_3v3";
+				regulator-min-microvolt = <2300000>;
+				regulator-max-microvolt = <3400000>;
+			};
+
+			avcc_3v1: LDO_REG2 {
+				regulator-name = "avcc_3v1";
+				regulator-min-microvolt = <2300000>;
+				regulator-max-microvolt = <3400000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			avcc_1v8: LDO_REG4 {
+				regulator-name = "avcc_1v8";
+				regulator-min-microvolt = <700000>;
+				regulator-max-microvolt = <2200000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			avcc_1v0: LDO_REG6 {
+				regulator-name = "avcc_1v0";
+				regulator-min-microvolt = <850000>;
+				regulator-max-microvolt = <2200000>;
+				regulator-always-on;
+				regulator-boot-on;
+			};
+
+			vcc1v8_io: LDO_REG7 {
+				regulator-name = "vcc1v8_io";
+				regulator-min-microvolt = <700000>;
+				regulator-max-microvolt = <2200000>;
+			};
+
+			tpvcc_3v1: LDO_REG8 {
+				regulator-name = "tpvcc_3v1";
+				regulator-min-microvolt = <2100000>;
+				regulator-max-microvolt = <3300000>;
+			};
+		};
+	};
-- 
2.17.1


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

* [PATCH 2/4] mfd: Add initial MFD driver for ATC260x PMICs
  2019-06-17 15:50 [PATCH 0/4] Add MFD/Regulator support for ATC260x PMICs Manivannan Sadhasivam
  2019-06-17 15:50 ` [PATCH 1/4] dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding Manivannan Sadhasivam
@ 2019-06-17 15:50 ` Manivannan Sadhasivam
  2019-06-26  6:56   ` Lee Jones
  2019-06-17 15:50 ` [PATCH 3/4] regulator: Add regulator " Manivannan Sadhasivam
  2019-06-17 15:50 ` [PATCH 4/4] MAINTAINERS: Add entry for ATC260x PMIC Manivannan Sadhasivam
  3 siblings, 1 reply; 16+ messages in thread
From: Manivannan Sadhasivam @ 2019-06-17 15:50 UTC (permalink / raw)
  To: lee.jones, lgirdwood, broonie, robh+dt
  Cc: afaerber, linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij, Manivannan Sadhasivam

Add initial MFD driver for Actions Semi ATC260x PMICs. ATC260x series
PMICs integrates Audio Codec, Power management, Clock generation, and GPIO
controller blocks. This driver only supports Regulator functionality on
ATC2609A PMIC variant for now.

Since the PMICs can be accessed using both I2C and SPI busses, following
driver structure has been adapted:

           ----->atc260x-core.c (Implements core funtionalities)
          /
ATC260x--------->atc260x-i2c.c (Implements I2C interface)
          \
           ----->atc2609a-helpers.c (Implements ATC2609A specific helpers)

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/mfd/Kconfig                       |  22 +++
 drivers/mfd/Makefile                      |   7 +
 drivers/mfd/atc2609a-helpers.c            |  91 +++++++++
 drivers/mfd/atc260x-core.c                |  85 ++++++++
 drivers/mfd/atc260x-i2c.c                 |  98 ++++++++++
 drivers/mfd/atc260x.h                     |  22 +++
 include/linux/mfd/atc260x/atc2609a_regs.h | 228 ++++++++++++++++++++++
 include/linux/mfd/atc260x/core.h          |  64 ++++++
 8 files changed, 617 insertions(+)
 create mode 100644 drivers/mfd/atc2609a-helpers.c
 create mode 100644 drivers/mfd/atc260x-core.c
 create mode 100644 drivers/mfd/atc260x-i2c.c
 create mode 100644 drivers/mfd/atc260x.h
 create mode 100644 include/linux/mfd/atc260x/atc2609a_regs.h
 create mode 100644 include/linux/mfd/atc260x/core.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index a17d275bf1d4..eb388505357b 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1945,6 +1945,28 @@ config MFD_STMFX
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_ATC260X
+	tristate "Actions Semi ATC260x PMICs"
+	select MFD_CORE
+	select REGMAP
+	select REGMAP_IRQ
+	help
+	  Support for the Actions Semi ATC260x PMICs.
+
+config MFD_ATC260X_I2C
+	tristate "Actions Semi ATC260x PMICs with I2C"
+	depends on MFD_ATC260X
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Support for the Actions Semi ATC260x PMICs controlled via I2C.
+
+config MFD_ATC2609A
+	bool "Actions Semi ATC2609A PMIC"
+	depends on MFD_ATC260X
+	help
+	  Support for Actions Semi ATC2609A PMIC
+
 menu "Multimedia Capabilities Port drivers"
 	depends on ARCH_SA1100
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 52b1a90ff515..a87e7ed55a02 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -249,3 +249,10 @@ obj-$(CONFIG_MFD_SC27XX_PMIC)	+= sprd-sc27xx-spi.o
 obj-$(CONFIG_RAVE_SP_CORE)	+= rave-sp.o
 obj-$(CONFIG_MFD_ROHM_BD718XX)	+= rohm-bd718x7.o
 obj-$(CONFIG_MFD_STMFX) 	+= stmfx.o
+
+atc260x-objs			:= atc260x-core.o
+ifeq ($(CONFIG_MFD_ATC2609A),y)
+atc260x-objs			+= atc2609a-helpers.o
+endif
+obj-$(CONFIG_MFD_ATC260X)	+= atc260x.o
+obj-$(CONFIG_MFD_ATC260X_I2C)	+= atc260x-i2c.o
diff --git a/drivers/mfd/atc2609a-helpers.c b/drivers/mfd/atc2609a-helpers.c
new file mode 100644
index 000000000000..6d304ea61552
--- /dev/null
+++ b/drivers/mfd/atc2609a-helpers.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Helper functions for ATC2609A PMIC
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+ */
+
+#include <linux/mfd/atc260x/core.h>
+#include <linux/mfd/core.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+
+#include "atc260x.h"
+
+const struct regmap_config atc2609a_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 16,
+	.max_register = ATC2609A_SADDR,
+	.cache_type = REGCACHE_NONE,
+};
+
+const struct regmap_irq atc2609a_irqs[] = {
+	[ATC2609A_IRQ_AUDIO] = {
+		.reg_offset = 0,
+		.mask = BIT(0),
+	},
+	[ATC2609A_IRQ_OV] = {
+		.reg_offset = 0,
+		.mask = BIT(1),
+	},
+	[ATC2609A_IRQ_OC] = {
+		.reg_offset = 0,
+		.mask = BIT(2),
+	},
+	[ATC2609A_IRQ_OT] = {
+		.reg_offset = 0,
+		.mask = BIT(3),
+	},
+	[ATC2609A_IRQ_UV] = {
+		.reg_offset = 0,
+		.mask = BIT(4),
+	},
+	[ATC2609A_IRQ_ALARM] = {
+		.reg_offset = 0,
+		.mask = BIT(5),
+	},
+	[ATC2609A_IRQ_ONOFF] = {
+		.reg_offset = 0,
+		.mask = BIT(6),
+	},
+	[ATC2609A_IRQ_WKUP] = {
+		.reg_offset = 0,
+		.mask = BIT(7),
+	},
+	[ATC2609A_IRQ_IR] = {
+		.reg_offset = 0,
+		.mask = BIT(8),
+	},
+	[ATC2609A_IRQ_REMCON] = {
+		.reg_offset = 0,
+		.mask = BIT(9),
+	},
+	[ATC2609A_IRQ_POWER_IN] = {
+		.reg_offset = 0,
+		.mask = BIT(10),
+	},
+};
+
+const struct regmap_irq_chip atc2609a_regmap_irq_chip = {
+	.name = "atc2609a",
+	.irqs = atc2609a_irqs,
+	.num_irqs = ARRAY_SIZE(atc2609a_irqs),
+	.num_regs = 1,
+	.status_base = ATC2609A_INTS_PD,
+	.mask_base = ATC2609A_INTS_MSK,
+	.mask_invert = true,
+};
+
+int atc2609a_dev_init(struct atc260x *atc260x)
+{
+	/* Initialize interrupt block */
+	atc260x_cmu_reset(atc260x, ATC2609A_CMU_DEVRST, ATC260X_CMU_INTS,
+			  ATC260X_CMU_INTS);
+
+	/* Disable all interrupt sources */
+	regmap_write(atc260x->regmap, ATC2609A_INTS_MSK, 0);
+
+	/* Enable EXTIRQ pad */
+	return regmap_update_bits(atc260x->regmap, ATC2609A_PAD_EN,
+				  BIT(0), BIT(0));
+}
diff --git a/drivers/mfd/atc260x-core.c b/drivers/mfd/atc260x-core.c
new file mode 100644
index 000000000000..e65f1cb2648b
--- /dev/null
+++ b/drivers/mfd/atc260x-core.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Core MFD support for ATC260x PMICs
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+ */
+
+#include <linux/interrupt.h>
+#include <linux/mfd/atc260x/core.h>
+#include <linux/mfd/core.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+
+#include "atc260x.h"
+
+void atc260x_cmu_reset(struct atc260x *atc260x, u32 reg, u8 mask, u32 bit)
+{
+	/* Assert reset */
+	regmap_update_bits(atc260x->regmap, reg, mask, ~bit);
+
+	/* De-assert reset */
+	regmap_update_bits(atc260x->regmap, reg, mask, bit);
+}
+
+int atc260x_core_init(struct atc260x *atc260x)
+{
+	struct device *dev = atc260x->dev;
+	unsigned int chip_rev;
+	int ret;
+
+	if (!atc260x->irq) {
+		dev_err(dev, "No interrupt support\n");
+		return -EINVAL;
+	}
+
+	/* Initialize the hardware */
+	atc260x->dev_init(atc260x);
+
+	ret = regmap_read(atc260x->regmap, atc260x->rev_reg, &chip_rev);
+	if (ret) {
+		dev_err(dev, "Failed to read revision register\n");
+		return ret;
+	}
+
+	if (chip_rev < 0 || chip_rev > 31) {
+		dev_err(dev, "Unknown chip revision: %d\n", ret);
+		return -EINVAL;
+	}
+
+	chip_rev = __ffs(chip_rev + 1U);
+
+	dev_info(dev, "%s chip revision: %d\n", atc260x->type_name, chip_rev);
+
+	ret = regmap_add_irq_chip(atc260x->regmap, atc260x->irq,
+				  IRQF_ONESHOT, -1,
+				  atc260x->regmap_irq_chip, &atc260x->irq_data);
+	if (ret) {
+		dev_err(dev, "Failed to add irq_chip %d\n", ret);
+		return ret;
+	}
+
+	ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE,
+				   atc260x->cells, atc260x->nr_cells, NULL, 0,
+				   regmap_irq_get_domain(atc260x->irq_data));
+	if (ret) {
+		dev_err(dev, "Failed to add MFD devices %d\n", ret);
+		goto err_irq;
+	}
+
+	return 0;
+
+err_irq:
+	regmap_del_irq_chip(atc260x->irq, atc260x->irq_data);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(atc260x_core_init);
+
+int atc260x_core_exit(struct atc260x *atc260x)
+{
+	regmap_del_irq_chip(atc260x->irq, atc260x->irq_data);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(atc260x_core_exit);
diff --git a/drivers/mfd/atc260x-i2c.c b/drivers/mfd/atc260x-i2c.c
new file mode 100644
index 000000000000..3b7e8c1f5ac5
--- /dev/null
+++ b/drivers/mfd/atc260x-i2c.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * I2C bus interface for ATC260x PMICs
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+ */
+
+#include <linux/i2c.h>
+#include <linux/mfd/atc260x/core.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+
+#include "atc260x.h"
+
+const struct mfd_cell atc2609a_mfd_cells[] = {
+	{ .name = "atc260x-regulator", },
+};
+
+static int atc260x_i2c_probe(struct i2c_client *client,
+			     const struct i2c_device_id *id)
+{
+	struct atc260x *atc260x;
+	const void *of_data;
+	unsigned long atc260x_type;
+
+	atc260x = devm_kzalloc(&client->dev, sizeof(*atc260x), GFP_KERNEL);
+	if (!atc260x)
+		return -ENOMEM;
+
+	of_data = of_device_get_match_data(&client->dev);
+	if (!of_data)
+		return -ENODEV;
+
+	atc260x_type = (unsigned long)of_data;
+
+	switch (atc260x_type) {
+	case ATC2609A:
+		atc260x->regmap_cfg = &atc2609a_regmap_config;
+		atc260x->regmap_irq_chip = &atc2609a_regmap_irq_chip;
+		atc260x->cells = atc2609a_mfd_cells;
+		atc260x->nr_cells = ARRAY_SIZE(atc2609a_mfd_cells);
+		atc260x->type_name = "atc2609a";
+		atc260x->rev_reg = ATC2609A_CHIP_VER;
+		atc260x->dev_init = atc2609a_dev_init;
+		break;
+	default:
+		dev_err(&client->dev,
+			"Unsupported ATC260x I2C device type %ld\n",
+			atc260x_type);
+		return -EINVAL;
+	}
+
+	atc260x->regmap = devm_regmap_init_i2c(client, atc260x->regmap_cfg);
+	if (IS_ERR(atc260x->regmap)) {
+		dev_err(&client->dev, "regmap initialization failed\n");
+		return PTR_ERR(atc260x->regmap);
+	}
+
+	i2c_set_clientdata(client, atc260x);
+	atc260x->type = atc260x_type;
+	atc260x->dev = &client->dev;
+	atc260x->irq = client->irq;
+
+	return atc260x_core_init(atc260x);
+}
+
+static int atc260x_i2c_remove(struct i2c_client *client)
+{
+	struct atc260x *atc260x = dev_get_drvdata(&client->dev);
+
+	atc260x_core_exit(atc260x);
+
+	return 0;
+}
+
+const struct of_device_id atc260x_of_match[] = {
+	{ .compatible = "actions,atc2609a", .data = (void *)ATC2609A },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(i2c, atc260x_of_match);
+
+static struct i2c_driver atc260x_i2c_driver = {
+	.driver = {
+		.name	= "atc260x",
+		.of_match_table	= of_match_ptr(atc260x_of_match),
+	},
+	.probe		= atc260x_i2c_probe,
+	.remove		= atc260x_i2c_remove,
+};
+
+module_i2c_driver(atc260x_i2c_driver);
+
+MODULE_DESCRIPTION("ATC260x PMICs I2C bus interface");
+MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/mfd/atc260x.h b/drivers/mfd/atc260x.h
new file mode 100644
index 000000000000..30fc66dfba04
--- /dev/null
+++ b/drivers/mfd/atc260x.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * MFD internals for ATC260x PMICs
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+ */
+
+#ifndef ATC260X_MFD_H
+#define ATC260X_MFD_H
+
+extern const struct of_device_id atc260x_of_match[];
+int atc260x_core_init(struct atc260x *atc260x);
+int atc260x_core_exit(struct atc260x *atc260x);
+void atc260x_cmu_reset(struct atc260x *atc260x, u32 reg, u8 mask, u32 bit);
+
+extern const struct regmap_config atc2609a_regmap_config;
+extern const struct mfd_cell atc2609a_mfd_cells[];
+extern const struct regmap_irq_chip atc2609a_regmap_irq_chip;
+extern const struct regmap_irq atc2609a_irqs[];
+int atc2609a_dev_init(struct atc260x *atc260x);
+
+#endif /* ATC260X_MFD_H */
diff --git a/include/linux/mfd/atc260x/atc2609a_regs.h b/include/linux/mfd/atc260x/atc2609a_regs.h
new file mode 100644
index 000000000000..851fb3dadd4f
--- /dev/null
+++ b/include/linux/mfd/atc260x/atc2609a_regs.h
@@ -0,0 +1,228 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * ATC2609A PMIC register definitions
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+ */
+
+#ifndef __ATC2609A_REGS_H__
+#define __ATC2609A_REGS_H__
+
+enum atc2609a_irq_def {
+	ATC2609A_IRQ_AUDIO = 0,
+	ATC2609A_IRQ_OV = 1,
+	ATC2609A_IRQ_OC = 2,
+	ATC2609A_IRQ_OT = 3,
+	ATC2609A_IRQ_UV = 4,
+	ATC2609A_IRQ_ALARM = 5,
+	ATC2609A_IRQ_ONOFF = 6,
+	ATC2609A_IRQ_WKUP = 7,
+	ATC2609A_IRQ_IR = 8,
+	ATC2609A_IRQ_REMCON = 9,
+	ATC2609A_IRQ_POWER_IN = 10,
+};
+
+/* PMU Register */
+#define ATC2609A_PMU_SYS_CTL0			0x00
+#define ATC2609A_PMU_SYS_CTL1			0x01
+#define ATC2609A_PMU_SYS_CTL2			0x02
+#define ATC2609A_PMU_SYS_CTL3			0x03
+#define ATC2609A_PMU_SYS_CTL4			0x04
+#define ATC2609A_PMU_SYS_CTL5			0x05
+#define ATC2609A_PMU_SYS_CTL6			0x06
+#define ATC2609A_PMU_SYS_CTL7			0x07
+#define ATC2609A_PMU_SYS_CTL8			0x08
+#define ATC2609A_PMU_SYS_CTL9			0x09
+#define ATC2609A_PMU_BAT_CTL0			0x0A
+#define ATC2609A_PMU_BAT_CTL1			0x0B
+#define ATC2609A_PMU_VBUS_CTL0			0x0C
+#define ATC2609A_PMU_VBUS_CTL1			0x0D
+#define ATC2609A_PMU_WALL_CTL0			0x0E
+#define ATC2609A_PMU_WALL_CTL1			0x0F
+#define ATC2609A_PMU_SYS_PENDING		0x10
+#define ATC2609A_PMU_APDS_CTL0			0x11
+#define ATC2609A_PMU_APDS_CTL1			0x12
+#define ATC2609A_PMU_APDS_CTL2			0x13
+#define ATC2609A_PMU_CHARGER_CTL		0x14
+#define ATC2609A_PMU_BAKCHARGER_CTL		0x15
+#define ATC2609A_PMU_SWCHG_CTL0			0x16
+#define ATC2609A_PMU_SWCHG_CTL1			0x17
+#define ATC2609A_PMU_SWCHG_CTL2			0x18
+#define ATC2609A_PMU_SWCHG_CTL3			0x19
+#define ATC2609A_PMU_SWCHG_CTL4			0x1A
+#define ATC2609A_PMU_DC_OSC			0x1B
+#define ATC2609A_PMU_DC0_CTL0			0x1C
+#define ATC2609A_PMU_DC0_CTL1			0x1D
+#define ATC2609A_PMU_DC0_CTL2			0x1E
+#define ATC2609A_PMU_DC0_CTL3			0x1F
+#define ATC2609A_PMU_DC0_CTL4			0x20
+#define ATC2609A_PMU_DC0_CTL5			0x21
+#define ATC2609A_PMU_DC0_CTL6			0x22
+#define ATC2609A_PMU_DC1_CTL0			0x23
+#define ATC2609A_PMU_DC1_CTL1			0x24
+#define ATC2609A_PMU_DC1_CTL2			0x25
+#define ATC2609A_PMU_DC1_CTL3			0x26
+#define ATC2609A_PMU_DC1_CTL4			0x27
+#define ATC2609A_PMU_DC1_CTL5			0x28
+#define ATC2609A_PMU_DC1_CTL6			0x29
+#define ATC2609A_PMU_DC2_CTL0			0x2A
+#define ATC2609A_PMU_DC2_CTL1			0x2B
+#define ATC2609A_PMU_DC2_CTL2			0x2C
+#define ATC2609A_PMU_DC2_CTL3			0x2D
+#define ATC2609A_PMU_DC2_CTL4			0x2E
+#define ATC2609A_PMU_DC2_CTL5			0x2F
+#define ATC2609A_PMU_DC2_CTL6			0x30
+#define ATC2609A_PMU_DC3_CTL0			0x31
+#define ATC2609A_PMU_DC3_CTL1			0x32
+#define ATC2609A_PMU_DC3_CTL2			0x33
+#define ATC2609A_PMU_DC3_CTL3			0x34
+#define ATC2609A_PMU_DC3_CTL4			0x35
+#define ATC2609A_PMU_DC3_CTL5			0x36
+#define ATC2609A_PMU_DC3_CTL6			0x37
+#define ATC2609A_PMU_DC_ZR			0x38
+#define ATC2609A_PMU_LDO0_CTL0			0x39
+#define ATC2609A_PMU_LDO0_CTL1			0x3A
+#define ATC2609A_PMU_LDO1_CTL0			0x3B
+#define ATC2609A_PMU_LDO1_CTL1			0x3C
+#define ATC2609A_PMU_LDO2_CTL0			0x3D
+#define ATC2609A_PMU_LDO2_CTL1			0x3E
+#define ATC2609A_PMU_LDO3_CTL0			0x3F
+#define ATC2609A_PMU_LDO3_CTL1			0x40
+#define ATC2609A_PMU_LDO4_CTL0			0x41
+#define ATC2609A_PMU_LDO4_CTL1			0x42
+#define ATC2609A_PMU_LDO5_CTL0			0x43
+#define ATC2609A_PMU_LDO5_CTL1			0x44
+#define ATC2609A_PMU_LDO6_CTL0			0x45
+#define ATC2609A_PMU_LDO6_CTL1			0x46
+#define ATC2609A_PMU_LDO7_CTL0			0x47
+#define ATC2609A_PMU_LDO7_CTL1			0x48
+#define ATC2609A_PMU_LDO8_CTL0			0x49
+#define ATC2609A_PMU_LDO8_CTL1			0x4A
+#define ATC2609A_PMU_LDO9_CTL			0x4B
+#define ATC2609A_PMU_OV_INT_EN			0x4C
+#define ATC2609A_PMU_OV_STATUS			0x4D
+#define ATC2609A_PMU_UV_INT_EN			0x4E
+#define ATC2609A_PMU_UV_STATUS			0x4F
+#define ATC2609A_PMU_OC_INT_EN			0x50
+#define ATC2609A_PMU_OC_STATUS			0x51
+#define ATC2609A_PMU_OT_CTL			0x52
+#define ATC2609A_PMU_CM_CTL0			0x53
+#define ATC2609A_PMU_FW_USE0			0x54
+#define ATC2609A_PMU_FW_USE1			0x55
+#define ATC2609A_PMU_ADC12B_I			0x56
+#define ATC2609A_PMU_ADC12B_V			0x57
+#define ATC2609A_PMU_ADC12B_DUMMY		0x58
+#define ATC2609A_PMU_AUXADC_CTL0		0x59
+#define ATC2609A_PMU_AUXADC_CTL1		0x5A
+#define ATC2609A_PMU_BATVADC			0x5B
+#define ATC2609A_PMU_BATIADC			0x5C
+#define ATC2609A_PMU_WALLVADC			0x5D
+#define ATC2609A_PMU_WALLIADC			0x5E
+#define ATC2609A_PMU_VBUSVADC			0x5F
+#define ATC2609A_PMU_VBUSIADC			0x60
+#define ATC2609A_PMU_SYSPWRADC			0x61
+#define ATC2609A_PMU_REMCONADC			0x62
+#define ATC2609A_PMU_SVCCADC			0x63
+#define ATC2609A_PMU_CHGIADC			0x64
+#define ATC2609A_PMU_IREFADC			0x65
+#define ATC2609A_PMU_BAKBATADC			0x66
+#define ATC2609A_PMU_ICTEMPADC			0x67
+#define ATC2609A_PMU_AUXADC0			0x68
+#define ATC2609A_PMU_AUXADC1			0x69
+#define ATC2609A_PMU_AUXADC2			0x6A
+#define ATC2609A_PMU_AUXADC3			0x6B
+#define ATC2609A_PMU_ICTEMPADC_ADJ		0x6C
+#define ATC2609A_PMU_BDG_CTL			0x6D
+#define ATC2609A_RTC_CTL			0x6E
+#define ATC2609A_RTC_MSALM			0x6F
+#define ATC2609A_RTC_HALM			0x70
+#define ATC2609A_RTC_YMDALM			0x71
+#define ATC2609A_RTC_MS				0x72
+#define ATC2609A_RTC_H				0x73
+#define ATC2609A_RTC_DC				0x74
+#define ATC2609A_RTC_YMD			0x75
+#define ATC2609A_EFUSE_DAT			0x76
+#define ATC2609A_EFUSECRTL1			0x77
+#define ATC2609A_EFUSECRTL2			0x78
+#define ATC2609A_PMU_DC4_CTL0			0x79
+#define ATC2609A_PMU_DC4_CTL1			0x7A
+#define ATC2609A_PMU_DC4_CTL2			0x7B
+#define ATC2609A_PMU_DC4_CTL3			0x7C
+#define ATC2609A_PMU_DC4_CTL4			0x7D
+#define ATC2609A_PMU_DC4_CTL5			0x7E
+#define ATC2609A_PMU_DC4_CTL6			0x7F
+#define ATC2609A_PMU_PWR_STATUS			0x80
+#define ATC2609A_PMU_S2_PWR			0x81
+#define ATC2609A_CLMT_CTL0			0x82
+#define ATC2609A_CLMT_DATA0			0x83
+#define ATC2609A_CLMT_DATA1			0x84
+#define ATC2609A_CLMT_DATA2			0x85
+#define ATC2609A_CLMT_DATA3			0x86
+#define ATC2609A_CLMT_ADD0			0x87
+#define ATC2609A_CLMT_ADD1			0x88
+#define ATC2609A_CLMT_OCV_TABLE			0x89
+#define ATC2609A_CLMT_R_TABLE			0x8A
+#define ATC2609A_PMU_PWRON_CTL0			0x8D
+#define ATC2609A_PMU_PWRON_CTL1			0x8E
+#define ATC2609A_PMU_PWRON_CTL2			0x8F
+#define ATC2609A_IRC_CTL			0x90
+#define ATC2609A_IRC_STAT			0x91
+#define ATC2609A_IRC_CC				0x92
+#define ATC2609A_IRC_KDC			0x93
+#define ATC2609A_IRC_WK				0x94
+#define ATC2609A_IRC_RCC			0x95
+
+/* AUDIO_OUT Register */
+#define ATC2609A_AUDIOINOUT_CTL			0xA0
+#define ATC2609A_AUDIO_DEBUGOUTCTL		0xA1
+#define ATC2609A_DAC_DIGITALCTL			0xA2
+#define ATC2609A_DAC_VOLUMECTL0			0xA3
+#define ATC2609A_DAC_ANALOG0			0xA4
+#define ATC2609A_DAC_ANALOG1			0xA5
+#define ATC2609A_DAC_ANALOG2			0xA6
+#define ATC2609A_DAC_ANALOG3			0xA7
+
+/* AUDIO_IN Register */
+#define ATC2609A_ADC_DIGITALCTL			0xA8
+#define ATC2609A_ADC_HPFCTL			0xA9
+#define ATC2609A_ADC_CTL			0xAA
+#define ATC2609A_AGC_CTL0			0xAB
+#define ATC2609A_AGC_CTL1			0xAC
+#define ATC2609A_AGC_CTL2			0xAD
+#define ATC2609A_ADC_ANALOG0			0xAE
+#define ATC2609A_ADC_ANALOG1			0xAF
+
+/* PCM_IF Register */
+#define ATC2609A_PCM0_CTL			0xB0
+#define ATC2609A_PCM1_CTL			0xB1
+#define ATC2609A_PCM2_CTL			0xB2
+#define ATC2609A_PCMIF_CTL			0xB3
+
+/* CMU_CONTROL Register */
+#define ATC2609A_CMU_DEVRST			0xC1
+
+/* INTS Register */
+#define ATC2609A_INTS_PD			0xC8
+#define ATC2609A_INTS_MSK			0xC9
+
+/* MFP Register */
+#define ATC2609A_MFP_CTL			0xD0
+#define ATC2609A_PAD_VSEL			0xD1
+#define ATC2609A_GPIO_OUTEN			0xD2
+#define ATC2609A_GPIO_INEN			0xD3
+#define ATC2609A_GPIO_DAT			0xD4
+#define ATC2609A_PAD_DRV			0xD5
+#define ATC2609A_PAD_EN				0xD6
+#define ATC2609A_DEBUG_SEL			0xD7
+#define ATC2609A_DEBUG_IE			0xD8
+#define ATC2609A_DEBUG_OE			0xD9
+#define ATC2609A_CHIP_VER			0xDC
+
+/* PWSI Register */
+#define ATC2609A_PWSI_CTL			0xF0
+#define ATC2609A_PWSI_STATUS			0xF1
+
+/* TWSI Register */
+#define ATC2609A_SADDR				0xFF
+
+#endif /* __ATC2609A_REGS_H__ */
diff --git a/include/linux/mfd/atc260x/core.h b/include/linux/mfd/atc260x/core.h
new file mode 100644
index 000000000000..9d75eca731d4
--- /dev/null
+++ b/include/linux/mfd/atc260x/core.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Core MFD defines for ATC260x PMICs
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+ */
+
+#ifndef __ATC260X_CORE_H__
+#define __ATC260X_CORE_H__
+
+#include <linux/mfd/atc260x/atc2609a_regs.h>
+
+enum atc260x_type {
+	ATC2603A = 0,
+	ATC2603C = 1,
+	ATC2609A = 2,
+};
+
+enum atc260x_reg {
+	ATC2609A_ID_DCDC0,
+	ATC2609A_ID_DCDC1,
+	ATC2609A_ID_DCDC2,
+	ATC2609A_ID_DCDC3,
+	ATC2609A_ID_DCDC4,
+	ATC2609A_ID_LDO0,
+	ATC2609A_ID_LDO1,
+	ATC2609A_ID_LDO2,
+	ATC2609A_ID_LDO3,
+	ATC2609A_ID_LDO4,
+	ATC2609A_ID_LDO5,
+	ATC2609A_ID_LDO6,
+	ATC2609A_ID_LDO7,
+	ATC2609A_ID_LDO8,
+	ATC2609A_ID_LDO9,
+	ATC2609A_ID_MAX,
+};
+
+enum atc260x_cmu_bits {
+	ATC260X_CMU_TP = 0,
+	ATC260X_CMU_MFP = 1,
+	ATC260X_CMU_INTS = 2,
+	ATC260X_CMU_ETHPHY = 3,
+	ATC260X_CMU_AUDIO = 4,
+	ATC260X_CMU_PWSI = 5,
+};
+
+struct atc260x {
+	struct device *dev;
+	struct regmap_irq_chip_data *irq_data;
+	struct regmap *regmap;
+	const struct regmap_config *regmap_cfg;
+	const struct regmap_irq_chip *regmap_irq_chip;
+	const struct mfd_cell *cells;
+	int nr_cells;
+	int irq;
+
+	enum atc260x_type type;
+	const char *type_name;
+	unsigned int rev_reg;
+
+	int (*dev_init)(struct atc260x *atc260x);
+};
+
+#endif /* __ATC260X_CORE_H__ */
-- 
2.17.1


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

* [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 15:50 [PATCH 0/4] Add MFD/Regulator support for ATC260x PMICs Manivannan Sadhasivam
  2019-06-17 15:50 ` [PATCH 1/4] dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding Manivannan Sadhasivam
  2019-06-17 15:50 ` [PATCH 2/4] mfd: Add initial MFD driver for ATC260x PMICs Manivannan Sadhasivam
@ 2019-06-17 15:50 ` Manivannan Sadhasivam
  2019-06-17 16:30   ` Mark Brown
  2019-06-17 15:50 ` [PATCH 4/4] MAINTAINERS: Add entry for ATC260x PMIC Manivannan Sadhasivam
  3 siblings, 1 reply; 16+ messages in thread
From: Manivannan Sadhasivam @ 2019-06-17 15:50 UTC (permalink / raw)
  To: lee.jones, lgirdwood, broonie, robh+dt
  Cc: afaerber, linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij, Manivannan Sadhasivam

Add regulator driver for Actions Semi ATC260x PMICs. This driver
supports 5 DC-DC converters and 10 LDO regulators found in ATC2609A
PMIC variant.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/regulator/Kconfig             |   8 +
 drivers/regulator/Makefile            |   1 +
 drivers/regulator/atc260x-regulator.c | 389 ++++++++++++++++++++++++++
 3 files changed, 398 insertions(+)
 create mode 100644 drivers/regulator/atc260x-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 8553bdf87c1d..acaf447ecdc6 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -166,6 +166,14 @@ config REGULATOR_AS3722
 	  AS3722 PMIC. This will enable support for all the software
 	  controllable DCDC/LDO regulators.
 
+config REGULATOR_ATC260X
+	tristate "Actions Semi ATC260x PMIC Regulators"
+	depends on MFD_ATC260X
+	help
+	  This driver provides support for the voltage regulators on the
+	  ATC260x PMICs. This will enable support for all the software
+	  controllable DCDC/LDO regulators.
+
 config REGULATOR_AXP20X
 	tristate "X-POWERS AXP20X PMIC Regulators"
 	depends on MFD_AXP20X
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 93f53840e8f1..600d01d082a3 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_REGULATOR_ARIZONA_LDO1) += arizona-ldo1.o
 obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.o
 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
+obj-$(CONFIG_REGULATOR_ATC260X) += atc260x-regulator.o
 obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
 obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o
 obj-$(CONFIG_REGULATOR_BD70528) += bd70528-regulator.o
diff --git a/drivers/regulator/atc260x-regulator.c b/drivers/regulator/atc260x-regulator.c
new file mode 100644
index 000000000000..e9e11f2567b2
--- /dev/null
+++ b/drivers/regulator/atc260x-regulator.c
@@ -0,0 +1,389 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Regulator driver for ATC260x PMICs
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+ */
+
+#include <linux/mfd/atc260x/core.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/regulator/driver.h>
+
+#define ATC2609A_DCDC_VSEL_MASK 0xff00
+#define ATC2609A_DCDC_MIN_UV 600000
+#define ATC2609A_DCDC_UV_STEP 6250
+#define ATC2609A_DCDC_NR_VOLT 256
+
+#define ATC2609A_LDO_VSEL_MASK0 0x003c
+#define ATC2609A_LDO_VSEL_MASK1 0x001e
+#define ATC2609A_LDO_VSEL_MASK2 0xe000
+#define ATC2609A_LDO_VSEL_RANGE_MASK 0x0020
+
+static const struct regulator_linear_range atc260x_ldo_voltage_ranges0[] = {
+	REGULATOR_LINEAR_RANGE(700000, 0, 15, 100000),
+	REGULATOR_LINEAR_RANGE(2100000, 16, 28, 100000),
+};
+
+static const struct regulator_linear_range atc260x_ldo_voltage_ranges1[] = {
+	REGULATOR_LINEAR_RANGE(850000, 0, 15, 100000),
+	REGULATOR_LINEAR_RANGE(2100000, 16, 27, 100000),
+};
+
+static const unsigned int atc260x_ldo_voltage_range_sel[] = {
+	0x0, 0x1,
+};
+
+static const struct regulator_linear_range atc260x_dcdc_voltage_ranges[] = {
+	REGULATOR_LINEAR_RANGE(600000, 0, 127, 6250),
+	REGULATOR_LINEAR_RANGE(1400000, 128, 232, 25000),
+};
+
+static const struct regulator_ops atc260x_reg_ops = {
+	.enable	= regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
+	.list_voltage = regulator_list_voltage_linear,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
+};
+
+static const struct regulator_ops atc260x_reg_fixed_ops = {
+	.list_voltage = regulator_list_voltage_linear,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
+};
+
+static const struct regulator_ops atc260x_reg_range0_ops = {
+	.enable	= regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
+	.list_voltage = regulator_list_voltage_pickable_linear_range,
+	.set_voltage_sel = regulator_set_voltage_sel_pickable_regmap,
+	.get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
+};
+
+static const struct regulator_ops atc260x_reg_range1_ops = {
+	.enable	= regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
+	.list_voltage = regulator_list_voltage_linear_range,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
+};
+
+static const struct regulator_desc atc2609a_reg[] = {
+	{
+		.name = "DCDC_REG0",
+		.supply_name = "vcc0",
+		.of_match = of_match_ptr("DCDC_REG0"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_DCDC0,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = ATC2609A_DCDC_MIN_UV,
+		.uV_step = ATC2609A_DCDC_UV_STEP,
+		.n_voltages = ATC2609A_DCDC_NR_VOLT,
+		.vsel_reg = ATC2609A_PMU_DC0_CTL0,
+		.vsel_mask = ATC2609A_DCDC_VSEL_MASK,
+		.enable_reg = ATC2609A_PMU_DC_OSC,
+		.enable_mask = BIT(4),
+		.enable_time = 800,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG1",
+		.supply_name = "vcc1",
+		.of_match = of_match_ptr("DCDC_REG1"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_DCDC1,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = ATC2609A_DCDC_MIN_UV,
+		.uV_step = ATC2609A_DCDC_UV_STEP,
+		.n_voltages = ATC2609A_DCDC_NR_VOLT,
+		.vsel_reg = ATC2609A_PMU_DC1_CTL0,
+		.vsel_mask = ATC2609A_DCDC_VSEL_MASK,
+		.enable_reg = ATC2609A_PMU_DC_OSC,
+		.enable_mask = BIT(5),
+		.enable_time = 800,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG2",
+		.supply_name = "vcc2",
+		.of_match = of_match_ptr("DCDC_REG2"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_DCDC2,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = ATC2609A_DCDC_MIN_UV,
+		.uV_step = ATC2609A_DCDC_UV_STEP,
+		.n_voltages = ATC2609A_DCDC_NR_VOLT,
+		.vsel_reg = ATC2609A_PMU_DC2_CTL0,
+		.vsel_mask = ATC2609A_DCDC_VSEL_MASK,
+		.enable_reg = ATC2609A_PMU_DC_OSC,
+		.enable_mask = BIT(6),
+		.enable_time = 800,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG3",
+		.supply_name = "vcc3",
+		.of_match = of_match_ptr("DCDC_REG3"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_DCDC3,
+		.ops = &atc260x_reg_range1_ops,
+		.type = REGULATOR_VOLTAGE,
+		.n_voltages = 233,
+		.linear_ranges = atc260x_dcdc_voltage_ranges,
+		.n_linear_ranges = ARRAY_SIZE(atc260x_dcdc_voltage_ranges),
+		.vsel_reg = ATC2609A_PMU_DC3_CTL0,
+		.vsel_mask = ATC2609A_DCDC_VSEL_MASK,
+		.enable_reg = ATC2609A_PMU_DC_OSC,
+		.enable_mask = BIT(7),
+		.enable_time = 800,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "DCDC_REG4",
+		.supply_name = "vcc4",
+		.of_match = of_match_ptr("DCDC_REG4"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_DCDC4,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = ATC2609A_DCDC_MIN_UV,
+		.uV_step = ATC2609A_DCDC_UV_STEP,
+		.n_voltages = ATC2609A_DCDC_NR_VOLT,
+		.vsel_reg = ATC2609A_PMU_DC4_CTL0,
+		.vsel_mask = ATC2609A_DCDC_VSEL_MASK,
+		.enable_reg = ATC2609A_PMU_DC_OSC,
+		.enable_mask = BIT(8),
+		.enable_time = 800,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG0",
+		.supply_name = "vcc5",
+		.of_match = of_match_ptr("LDO_REG0"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO0,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = 2300000,
+		.uV_step = 100000,
+		.n_voltages = 12,
+		.vsel_reg = ATC2609A_PMU_LDO0_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK0,
+		.enable_reg = ATC2609A_PMU_LDO0_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG1",
+		.supply_name = "vcc6",
+		.of_match = of_match_ptr("LDO_REG1"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO1,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = 2300000,
+		.uV_step = 100000,
+		.n_voltages = 12,
+		.vsel_reg = ATC2609A_PMU_LDO1_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK0,
+		.enable_reg = ATC2609A_PMU_LDO1_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG2",
+		.supply_name = "vcc7",
+		.of_match = of_match_ptr("LDO_REG2"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO2,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = 2300000,
+		.uV_step = 100000,
+		.n_voltages = 12,
+		.vsel_reg = ATC2609A_PMU_LDO2_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK0,
+		.enable_reg = ATC2609A_PMU_LDO2_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG3",
+		.supply_name = "vcc8",
+		.of_match = of_match_ptr("LDO_REG3"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO3,
+		.ops = &atc260x_reg_range0_ops,
+		.type = REGULATOR_VOLTAGE,
+		.linear_ranges = atc260x_ldo_voltage_ranges0,
+		.n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0),
+		.vsel_reg = ATC2609A_PMU_LDO3_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK1,
+		.vsel_range_reg = ATC2609A_PMU_LDO3_CTL0,
+		.vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK,
+		.linear_range_selectors = atc260x_ldo_voltage_range_sel,
+		.enable_reg = ATC2609A_PMU_LDO3_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG4",
+		.supply_name = "vcc9",
+		.of_match = of_match_ptr("LDO_REG4"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO4,
+		.ops = &atc260x_reg_range0_ops,
+		.type = REGULATOR_VOLTAGE,
+		.linear_ranges = atc260x_ldo_voltage_ranges0,
+		.n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0),
+		.vsel_reg = ATC2609A_PMU_LDO4_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK1,
+		.vsel_range_reg = ATC2609A_PMU_LDO4_CTL0,
+		.vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK,
+		.linear_range_selectors = atc260x_ldo_voltage_range_sel,
+		.enable_reg = ATC2609A_PMU_LDO4_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG5",
+		.supply_name = "vcc10",
+		.of_match = of_match_ptr("LDO_REG5"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO5,
+		.ops = &atc260x_reg_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = 700000,
+		.uV_step = 100000,
+		.n_voltages = 16,
+		.vsel_reg = ATC2609A_PMU_LDO5_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK1,
+		.enable_reg = ATC2609A_PMU_LDO5_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG6",
+		.supply_name = "vcc11",
+		.of_match = of_match_ptr("LDO_REG6"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO6,
+		.ops = &atc260x_reg_range0_ops,
+		.type = REGULATOR_VOLTAGE,
+		.linear_ranges = atc260x_ldo_voltage_ranges1,
+		.n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges1),
+		.vsel_reg = ATC2609A_PMU_LDO6_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK1,
+		.vsel_range_reg = ATC2609A_PMU_LDO6_CTL0,
+		.vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK,
+		.linear_range_selectors = atc260x_ldo_voltage_range_sel,
+		.enable_reg = ATC2609A_PMU_LDO6_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG7",
+		.supply_name = "vcc12",
+		.of_match = of_match_ptr("LDO_REG7"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO7,
+		.ops = &atc260x_reg_range0_ops,
+		.type = REGULATOR_VOLTAGE,
+		.linear_ranges = atc260x_ldo_voltage_ranges0,
+		.n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0),
+		.vsel_reg = ATC2609A_PMU_LDO7_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK1,
+		.vsel_range_reg = ATC2609A_PMU_LDO7_CTL0,
+		.vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK,
+		.linear_range_selectors = atc260x_ldo_voltage_range_sel,
+		.enable_reg = ATC2609A_PMU_LDO7_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG8",
+		.supply_name = "vcc13",
+		.of_match = of_match_ptr("LDO_REG8"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO8,
+		.ops = &atc260x_reg_range0_ops,
+		.type = REGULATOR_VOLTAGE,
+		.linear_ranges = atc260x_ldo_voltage_ranges0,
+		.n_linear_ranges = ARRAY_SIZE(atc260x_ldo_voltage_ranges0),
+		.vsel_reg = ATC2609A_PMU_LDO8_CTL0,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK1,
+		.vsel_range_reg = ATC2609A_PMU_LDO8_CTL0,
+		.vsel_range_mask = ATC2609A_LDO_VSEL_RANGE_MASK,
+		.linear_range_selectors = atc260x_ldo_voltage_range_sel,
+		.enable_reg = ATC2609A_PMU_LDO8_CTL0,
+		.enable_mask = BIT(0),
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	}, {
+		.name = "LDO_REG9",
+		.supply_name = "vcc14",
+		.of_match = of_match_ptr("LDO_REG9"),
+		.regulators_node = of_match_ptr("regulators"),
+		.id = ATC2609A_ID_LDO9,
+		.ops = &atc260x_reg_fixed_ops,
+		.type = REGULATOR_VOLTAGE,
+		.min_uV = 2600000,
+		.uV_step = 100000,
+		.n_voltages = 8,
+		.vsel_reg = ATC2609A_PMU_LDO9_CTL,
+		.vsel_mask = ATC2609A_LDO_VSEL_MASK2,
+		.enable_time = 2000,
+		.owner = THIS_MODULE,
+	},
+};
+
+static int atc260x_regulator_probe(struct platform_device *pdev)
+{
+	struct atc260x *atc260x = dev_get_drvdata(pdev->dev.parent);
+	struct device *dev = atc260x->dev;
+	struct regulator_config config = {};
+	struct regulator_dev *atc260x_rdev;
+	const struct regulator_desc *regulators;
+	int i, nregulators;
+
+	switch (atc260x->type) {
+	case ATC2609A:
+		regulators = atc2609a_reg;
+		nregulators = ATC2609A_ID_MAX;
+		break;
+	default:
+		dev_err(dev, "unsupported ATC260X ID %d\n", atc260x->type);
+		return -EINVAL;
+	}
+
+	config.dev = dev;
+	config.regmap = atc260x->regmap;
+
+	/* Instantiate the regulators */
+	for (i = 0; i < nregulators; i++) {
+		atc260x_rdev = devm_regulator_register(&pdev->dev,
+						       &regulators[i], &config);
+		if (IS_ERR(atc260x_rdev)) {
+			dev_err(dev, "failed to register regulator: %d\n", i);
+			return PTR_ERR(atc260x_rdev);
+		}
+	}
+
+	return 0;
+}
+
+static struct platform_driver atc260x_regulator_driver = {
+	.probe = atc260x_regulator_probe,
+	.driver = {
+		.name = "atc260x-regulator"
+	},
+};
+
+module_platform_driver(atc260x_regulator_driver);
+
+MODULE_DESCRIPTION("Regulator driver for ATC260x PMICs");
+MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>");
+MODULE_LICENSE("GPL");
-- 
2.17.1


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

* [PATCH 4/4] MAINTAINERS: Add entry for ATC260x PMIC
  2019-06-17 15:50 [PATCH 0/4] Add MFD/Regulator support for ATC260x PMICs Manivannan Sadhasivam
                   ` (2 preceding siblings ...)
  2019-06-17 15:50 ` [PATCH 3/4] regulator: Add regulator " Manivannan Sadhasivam
@ 2019-06-17 15:50 ` Manivannan Sadhasivam
  3 siblings, 0 replies; 16+ messages in thread
From: Manivannan Sadhasivam @ 2019-06-17 15:50 UTC (permalink / raw)
  To: lee.jones, lgirdwood, broonie, robh+dt
  Cc: afaerber, linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij, Manivannan Sadhasivam

Add MAINTAINERS entry for ATC260x PMIC.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 11d6937c4688..57112194cd90 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2646,6 +2646,15 @@ S:	Supported
 F:	Documentation/aoe/
 F:	drivers/block/aoe/
 
+ATC260X PMIC MFD DRIVER
+M:	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
+S:	Maintained
+L:	linux-actions@lists.infradead.org
+F:	Documentation/devicetree/bindings/mfd/atc260x.txt
+F:	include/linux/mfd/atc260x/*
+F:	drivers/mfd/atc260*
+F:	drivers/regulator/atc260x-regulator.c
+
 ATHEROS 71XX/9XXX GPIO DRIVER
 M:	Alban Bedel <albeu@free.fr>
 W:	https://github.com/AlbanBedel/linux
-- 
2.17.1


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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 15:50 ` [PATCH 3/4] regulator: Add regulator " Manivannan Sadhasivam
@ 2019-06-17 16:30   ` Mark Brown
  2019-06-17 16:34     ` Manivannan Sadhasivam
  0 siblings, 1 reply; 16+ messages in thread
From: Mark Brown @ 2019-06-17 16:30 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: lee.jones, lgirdwood, robh+dt, afaerber, linux-actions,
	linux-kernel, thomas.liau, devicetree, linus.walleij

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

On Mon, Jun 17, 2019 at 09:20:10PM +0530, Manivannan Sadhasivam wrote:

> +++ b/drivers/regulator/atc260x-regulator.c
> @@ -0,0 +1,389 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Regulator driver for ATC260x PMICs

Please make the entire comment a C++ one so this looks more intentional.

> + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

You definitely didn't assign copyright to your employer?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 16:30   ` Mark Brown
@ 2019-06-17 16:34     ` Manivannan Sadhasivam
  2019-06-17 16:38       ` Andreas Färber
  2019-06-17 17:03       ` Mark Brown
  0 siblings, 2 replies; 16+ messages in thread
From: Manivannan Sadhasivam @ 2019-06-17 16:34 UTC (permalink / raw)
  To: Mark Brown
  Cc: lee.jones, lgirdwood, robh+dt, afaerber, linux-actions,
	linux-kernel, thomas.liau, devicetree, linus.walleij

Hi Mark,

On Mon, Jun 17, 2019 at 05:30:15PM +0100, Mark Brown wrote:
> On Mon, Jun 17, 2019 at 09:20:10PM +0530, Manivannan Sadhasivam wrote:
> 
> > +++ b/drivers/regulator/atc260x-regulator.c
> > @@ -0,0 +1,389 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Regulator driver for ATC260x PMICs
> 
> Please make the entire comment a C++ one so this looks more intentional.
> 

Okay.

> > + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> 
> You definitely didn't assign copyright to your employer?

Yeah, that was intentional. This work is not part of Linaro working hours and
falls into my spare time works where I'm trying to complete the upstream support
for Actions Semi Owl series SoCs and target boards which I'm co-maintaining
(sort of)...

Thanks,
Mani



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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 16:34     ` Manivannan Sadhasivam
@ 2019-06-17 16:38       ` Andreas Färber
  2019-06-17 16:54         ` Mark Brown
  2019-06-17 20:30         ` Greg Kroah-Hartman
  2019-06-17 17:03       ` Mark Brown
  1 sibling, 2 replies; 16+ messages in thread
From: Andreas Färber @ 2019-06-17 16:38 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Mark Brown
  Cc: lee.jones, lgirdwood, robh+dt, linux-actions, linux-kernel,
	thomas.liau, devicetree, linus.walleij, Greg Kroah-Hartman

Hi,

Am 17.06.19 um 18:34 schrieb Manivannan Sadhasivam:
> On Mon, Jun 17, 2019 at 05:30:15PM +0100, Mark Brown wrote:
>> On Mon, Jun 17, 2019 at 09:20:10PM +0530, Manivannan Sadhasivam wrote:
>>
>>> +++ b/drivers/regulator/atc260x-regulator.c
>>> @@ -0,0 +1,389 @@
>>> +// SPDX-License-Identifier: GPL-2.0+
>>> +/*
>>> + * Regulator driver for ATC260x PMICs
>>
>> Please make the entire comment a C++ one so this looks more intentional.

No, this is intentional and the official style requested by GregKH.

He suggested I patch the SPDX documentation to make this clearer, but I
did not find time for this yet (and am not the one making this rule).

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)

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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 16:38       ` Andreas Färber
@ 2019-06-17 16:54         ` Mark Brown
  2019-06-17 20:30         ` Greg Kroah-Hartman
  1 sibling, 0 replies; 16+ messages in thread
From: Mark Brown @ 2019-06-17 16:54 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Manivannan Sadhasivam, lee.jones, lgirdwood, robh+dt,
	linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij, Greg Kroah-Hartman

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

On Mon, Jun 17, 2019 at 06:38:53PM +0200, Andreas Färber wrote:
> Am 17.06.19 um 18:34 schrieb Manivannan Sadhasivam:
> > On Mon, Jun 17, 2019 at 05:30:15PM +0100, Mark Brown wrote:

> >>> @@ -0,0 +1,389 @@
> >>> +// SPDX-License-Identifier: GPL-2.0+
> >>> +/*
> >>> + * Regulator driver for ATC260x PMICs

> >> Please make the entire comment a C++ one so this looks more intentional.

> No, this is intentional and the official style requested by GregKH.

The important bit for the tools is the first line, the rest of it the
tools don't care about.

> He suggested I patch the SPDX documentation to make this clearer, but I
> did not find time for this yet (and am not the one making this rule).

The other regulator API files are all the way I suggest...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 16:34     ` Manivannan Sadhasivam
  2019-06-17 16:38       ` Andreas Färber
@ 2019-06-17 17:03       ` Mark Brown
  2019-06-17 17:24         ` Manivannan Sadhasivam
  2019-06-18  8:13         ` Lee Jones
  1 sibling, 2 replies; 16+ messages in thread
From: Mark Brown @ 2019-06-17 17:03 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: lee.jones, lgirdwood, robh+dt, afaerber, linux-actions,
	linux-kernel, thomas.liau, devicetree, linus.walleij

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

On Mon, Jun 17, 2019 at 10:04:13PM +0530, Manivannan Sadhasivam wrote:

> > > + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

> > You definitely didn't assign copyright to your employer?

> Yeah, that was intentional. This work is not part of Linaro working hours and
> falls into my spare time works where I'm trying to complete the upstream support
> for Actions Semi Owl series SoCs and target boards which I'm co-maintaining
> (sort of)...

OK...  seems very weird to use your work address for developing on
products closely associated with your employer in non-work time.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 17:03       ` Mark Brown
@ 2019-06-17 17:24         ` Manivannan Sadhasivam
  2019-06-18  8:13         ` Lee Jones
  1 sibling, 0 replies; 16+ messages in thread
From: Manivannan Sadhasivam @ 2019-06-17 17:24 UTC (permalink / raw)
  To: Mark Brown
  Cc: lee.jones, lgirdwood, robh+dt, afaerber, linux-actions,
	linux-kernel, thomas.liau, devicetree, linus.walleij

On Mon, Jun 17, 2019 at 06:03:56PM +0100, Mark Brown wrote:
> On Mon, Jun 17, 2019 at 10:04:13PM +0530, Manivannan Sadhasivam wrote:
> 
> > > > + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> 
> > > You definitely didn't assign copyright to your employer?
> 
> > Yeah, that was intentional. This work is not part of Linaro working hours and
> > falls into my spare time works where I'm trying to complete the upstream support
> > for Actions Semi Owl series SoCs and target boards which I'm co-maintaining
> > (sort of)...
> 
> OK...  seems very weird to use your work address for developing on
> products closely associated with your employer in non-work time.

Agree. I was trying to setup my kernel.org mail address with git for
unofficial works like this but haven't done with it yet :/

Regards,
Mani



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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 16:38       ` Andreas Färber
  2019-06-17 16:54         ` Mark Brown
@ 2019-06-17 20:30         ` Greg Kroah-Hartman
  1 sibling, 0 replies; 16+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-17 20:30 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Manivannan Sadhasivam, Mark Brown, lee.jones, lgirdwood, robh+dt,
	linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij

On Mon, Jun 17, 2019 at 06:38:53PM +0200, Andreas Färber wrote:
> Hi,
> 
> Am 17.06.19 um 18:34 schrieb Manivannan Sadhasivam:
> > On Mon, Jun 17, 2019 at 05:30:15PM +0100, Mark Brown wrote:
> >> On Mon, Jun 17, 2019 at 09:20:10PM +0530, Manivannan Sadhasivam wrote:
> >>
> >>> +++ b/drivers/regulator/atc260x-regulator.c
> >>> @@ -0,0 +1,389 @@
> >>> +// SPDX-License-Identifier: GPL-2.0+
> >>> +/*
> >>> + * Regulator driver for ATC260x PMICs
> >>
> >> Please make the entire comment a C++ one so this looks more intentional.
> 
> No, this is intentional and the official style requested by GregKH.

Mark likes them all to be // at the top of the file.

I only required that the SPDX line be that way.

Mark can ask for more if he wants to :)

thanks,

greg k-h

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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-17 17:03       ` Mark Brown
  2019-06-17 17:24         ` Manivannan Sadhasivam
@ 2019-06-18  8:13         ` Lee Jones
  2019-06-18 10:44           ` Mark Brown
  1 sibling, 1 reply; 16+ messages in thread
From: Lee Jones @ 2019-06-18  8:13 UTC (permalink / raw)
  To: Mark Brown
  Cc: Manivannan Sadhasivam, lgirdwood, robh+dt, afaerber,
	linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij

On Mon, 17 Jun 2019, Mark Brown wrote:

> On Mon, Jun 17, 2019 at 10:04:13PM +0530, Manivannan Sadhasivam wrote:
> 
> > > > + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> 
> > > You definitely didn't assign copyright to your employer?
> 
> > Yeah, that was intentional. This work is not part of Linaro working hours and
> > falls into my spare time works where I'm trying to complete the upstream support
> > for Actions Semi Owl series SoCs and target boards which I'm co-maintaining
> > (sort of)...
> 
> OK...  seems very weird to use your work address for developing on
> products closely associated with your employer in non-work time.

I use my Linaro address for everything.  So long as the work is of the
required standard, I cannot see anyone having reservations.

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

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

* Re: [PATCH 3/4] regulator: Add regulator driver for ATC260x PMICs
  2019-06-18  8:13         ` Lee Jones
@ 2019-06-18 10:44           ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2019-06-18 10:44 UTC (permalink / raw)
  To: Lee Jones
  Cc: Manivannan Sadhasivam, lgirdwood, robh+dt, afaerber,
	linux-actions, linux-kernel, thomas.liau, devicetree,
	linus.walleij

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

On Tue, Jun 18, 2019 at 09:13:24AM +0100, Lee Jones wrote:
> On Mon, 17 Jun 2019, Mark Brown wrote:

> > OK...  seems very weird to use your work address for developing on
> > products closely associated with your employer in non-work time.

> I use my Linaro address for everything.  So long as the work is of the
> required standard, I cannot see anyone having reservations.

It's not a problem to use it - I was querying the copyright statement
due to the Linaro address and work in conjunction with the non-Linaro
copyright to make sure it wasn't a mistake.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 2/4] mfd: Add initial MFD driver for ATC260x PMICs
  2019-06-17 15:50 ` [PATCH 2/4] mfd: Add initial MFD driver for ATC260x PMICs Manivannan Sadhasivam
@ 2019-06-26  6:56   ` Lee Jones
  0 siblings, 0 replies; 16+ messages in thread
From: Lee Jones @ 2019-06-26  6:56 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: lgirdwood, broonie, robh+dt, afaerber, linux-actions,
	linux-kernel, thomas.liau, devicetree, linus.walleij

On Mon, 17 Jun 2019, Manivannan Sadhasivam wrote:

> Add initial MFD driver for Actions Semi ATC260x PMICs. ATC260x series
> PMICs integrates Audio Codec, Power management, Clock generation, and GPIO
> controller blocks. This driver only supports Regulator functionality on
> ATC2609A PMIC variant for now.

Until you supply other functionality, this is not an MFD.

Please add additional support for more child devices.

> Since the PMICs can be accessed using both I2C and SPI busses, following
> driver structure has been adapted:
> 
>            ----->atc260x-core.c (Implements core funtionalities)
>           /
> ATC260x--------->atc260x-i2c.c (Implements I2C interface)
>           \
>            ----->atc2609a-helpers.c (Implements ATC2609A specific helpers)
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/mfd/Kconfig                       |  22 +++
>  drivers/mfd/Makefile                      |   7 +
>  drivers/mfd/atc2609a-helpers.c            |  91 +++++++++
>  drivers/mfd/atc260x-core.c                |  85 ++++++++
>  drivers/mfd/atc260x-i2c.c                 |  98 ++++++++++

Taking this set on it's own merits alone, I don't see a good reason to
split these up.  Please either supply the SPI interface within this
patch-set or amalgamate them into a single file.

>  drivers/mfd/atc260x.h                     |  22 +++
>  include/linux/mfd/atc260x/atc2609a_regs.h | 228 ++++++++++++++++++++++
>  include/linux/mfd/atc260x/core.h          |  64 ++++++
>  8 files changed, 617 insertions(+)
>  create mode 100644 drivers/mfd/atc2609a-helpers.c
>  create mode 100644 drivers/mfd/atc260x-core.c
>  create mode 100644 drivers/mfd/atc260x-i2c.c
>  create mode 100644 drivers/mfd/atc260x.h
>  create mode 100644 include/linux/mfd/atc260x/atc2609a_regs.h
>  create mode 100644 include/linux/mfd/atc260x/core.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index a17d275bf1d4..eb388505357b 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -1945,6 +1945,28 @@ config MFD_STMFX
>  	  additional drivers must be enabled in order to use the functionality
>  	  of the device.
>  
> +config MFD_ATC260X
> +	tristate "Actions Semi ATC260x PMICs"
> +	select MFD_CORE
> +	select REGMAP
> +	select REGMAP_IRQ
> +	help
> +	  Support for the Actions Semi ATC260x PMICs.
> +
> +config MFD_ATC260X_I2C
> +	tristate "Actions Semi ATC260x PMICs with I2C"
> +	depends on MFD_ATC260X
> +	depends on I2C
> +	select REGMAP_I2C
> +	help
> +	  Support for the Actions Semi ATC260x PMICs controlled via I2C.
> +
> +config MFD_ATC2609A
> +	bool "Actions Semi ATC2609A PMIC"
> +	depends on MFD_ATC260X
> +	help
> +	  Support for Actions Semi ATC2609A PMIC
> +
>  menu "Multimedia Capabilities Port drivers"
>  	depends on ARCH_SA1100
>  
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 52b1a90ff515..a87e7ed55a02 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -249,3 +249,10 @@ obj-$(CONFIG_MFD_SC27XX_PMIC)	+= sprd-sc27xx-spi.o
>  obj-$(CONFIG_RAVE_SP_CORE)	+= rave-sp.o
>  obj-$(CONFIG_MFD_ROHM_BD718XX)	+= rohm-bd718x7.o
>  obj-$(CONFIG_MFD_STMFX) 	+= stmfx.o
> +
> +atc260x-objs			:= atc260x-core.o
> +ifeq ($(CONFIG_MFD_ATC2609A),y)
> +atc260x-objs			+= atc2609a-helpers.o
> +endif
> +obj-$(CONFIG_MFD_ATC260X)	+= atc260x.o
> +obj-$(CONFIG_MFD_ATC260X_I2C)	+= atc260x-i2c.o
> diff --git a/drivers/mfd/atc2609a-helpers.c b/drivers/mfd/atc2609a-helpers.c
> new file mode 100644
> index 000000000000..6d304ea61552
> --- /dev/null
> +++ b/drivers/mfd/atc2609a-helpers.c
> @@ -0,0 +1,91 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Helper functions for ATC2609A PMIC
> + *
> + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> + */
> +
> +#include <linux/mfd/atc260x/core.h>
> +#include <linux/mfd/core.h>
> +#include <linux/of.h>
> +#include <linux/regmap.h>
> +
> +#include "atc260x.h"
> +
> +const struct regmap_config atc2609a_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 16,
> +	.max_register = ATC2609A_SADDR,
> +	.cache_type = REGCACHE_NONE,
> +};
> +
> +const struct regmap_irq atc2609a_irqs[] = {
> +	[ATC2609A_IRQ_AUDIO] = {
> +		.reg_offset = 0,
> +		.mask = BIT(0),
> +	},
> +	[ATC2609A_IRQ_OV] = {
> +		.reg_offset = 0,
> +		.mask = BIT(1),
> +	},
> +	[ATC2609A_IRQ_OC] = {
> +		.reg_offset = 0,
> +		.mask = BIT(2),
> +	},
> +	[ATC2609A_IRQ_OT] = {
> +		.reg_offset = 0,
> +		.mask = BIT(3),
> +	},
> +	[ATC2609A_IRQ_UV] = {
> +		.reg_offset = 0,
> +		.mask = BIT(4),
> +	},
> +	[ATC2609A_IRQ_ALARM] = {
> +		.reg_offset = 0,
> +		.mask = BIT(5),
> +	},
> +	[ATC2609A_IRQ_ONOFF] = {
> +		.reg_offset = 0,
> +		.mask = BIT(6),
> +	},
> +	[ATC2609A_IRQ_WKUP] = {
> +		.reg_offset = 0,
> +		.mask = BIT(7),
> +	},
> +	[ATC2609A_IRQ_IR] = {
> +		.reg_offset = 0,
> +		.mask = BIT(8),
> +	},
> +	[ATC2609A_IRQ_REMCON] = {
> +		.reg_offset = 0,
> +		.mask = BIT(9),
> +	},
> +	[ATC2609A_IRQ_POWER_IN] = {
> +		.reg_offset = 0,
> +		.mask = BIT(10),
> +	},
> +};

Please use REGMAP_IRQ_REG()

> +const struct regmap_irq_chip atc2609a_regmap_irq_chip = {
> +	.name = "atc2609a",
> +	.irqs = atc2609a_irqs,
> +	.num_irqs = ARRAY_SIZE(atc2609a_irqs),
> +	.num_regs = 1,
> +	.status_base = ATC2609A_INTS_PD,
> +	.mask_base = ATC2609A_INTS_MSK,
> +	.mask_invert = true,
> +};
> +
> +int atc2609a_dev_init(struct atc260x *atc260x)
> +{
> +	/* Initialize interrupt block */
> +	atc260x_cmu_reset(atc260x, ATC2609A_CMU_DEVRST, ATC260X_CMU_INTS,
> +			  ATC260X_CMU_INTS);
> +
> +	/* Disable all interrupt sources */
> +	regmap_write(atc260x->regmap, ATC2609A_INTS_MSK, 0);
> +
> +	/* Enable EXTIRQ pad */
> +	return regmap_update_bits(atc260x->regmap, ATC2609A_PAD_EN,
> +				  BIT(0), BIT(0));
> +}

No need for this to be in a separate file.  We can support multiple
chips from a single source file.  Only split them out when the level
of complexity makes it difficult to read/maintain.

> diff --git a/drivers/mfd/atc260x-core.c b/drivers/mfd/atc260x-core.c
> new file mode 100644
> index 000000000000..e65f1cb2648b
> --- /dev/null
> +++ b/drivers/mfd/atc260x-core.c
> @@ -0,0 +1,85 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Core MFD support for ATC260x PMICs
> + *
> + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> + */
> +
> +#include <linux/interrupt.h>
> +#include <linux/mfd/atc260x/core.h>
> +#include <linux/mfd/core.h>
> +#include <linux/of.h>
> +#include <linux/regmap.h>
> +
> +#include "atc260x.h"
> +
> +void atc260x_cmu_reset(struct atc260x *atc260x, u32 reg, u8 mask, u32 bit)
> +{
> +	/* Assert reset */
> +	regmap_update_bits(atc260x->regmap, reg, mask, ~bit);
> +
> +	/* De-assert reset */
> +	regmap_update_bits(atc260x->regmap, reg, mask, bit);
> +}

I only see one call-site.  Are you planning on reusing this?

> +int atc260x_core_init(struct atc260x *atc260x)
> +{
> +	struct device *dev = atc260x->dev;
> +	unsigned int chip_rev;
> +	int ret;
> +
> +	if (!atc260x->irq) {
> +		dev_err(dev, "No interrupt support\n");
> +		return -EINVAL;
> +	}
> +
> +	/* Initialize the hardware */
> +	atc260x->dev_init(atc260x);

I don't think we need to mess around with pointers to functions in
this simple driver.

> +	ret = regmap_read(atc260x->regmap, atc260x->rev_reg, &chip_rev);
> +	if (ret) {
> +		dev_err(dev, "Failed to read revision register\n");

End users don't care about registers.

"Failed to obtain chip revision"

> +		return ret;
> +	}
> +
> +	if (chip_rev < 0 || chip_rev > 31) {

Do you really support 32 revisions?

> +		dev_err(dev, "Unknown chip revision: %d\n", ret);
> +		return -EINVAL;
> +	}
> +
> +	chip_rev = __ffs(chip_rev + 1U);

1 bit per revision?  That is highly inefficient.

> +	dev_info(dev, "%s chip revision: %d\n", atc260x->type_name, chip_rev);
> +
> +	ret = regmap_add_irq_chip(atc260x->regmap, atc260x->irq,
> +				  IRQF_ONESHOT, -1,
> +				  atc260x->regmap_irq_chip, &atc260x->irq_data);
> +	if (ret) {
> +		dev_err(dev, "Failed to add irq_chip %d\n", ret);

"Failed to add IRQ Chip"

> +		return ret;
> +	}
> +
> +	ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE,
> +				   atc260x->cells, atc260x->nr_cells, NULL, 0,
> +				   regmap_irq_get_domain(atc260x->irq_data));
> +	if (ret) {
> +		dev_err(dev, "Failed to add MFD devices %d\n", ret);

"Failed to add child devices"

> +		goto err_irq;
> +	}
> +
> +	return 0;
> +
> +err_irq:
> +	regmap_del_irq_chip(atc260x->irq, atc260x->irq_data);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(atc260x_core_init);
> +
> +int atc260x_core_exit(struct atc260x *atc260x)
> +{
> +	regmap_del_irq_chip(atc260x->irq, atc260x->irq_data);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(atc260x_core_exit);
> diff --git a/drivers/mfd/atc260x-i2c.c b/drivers/mfd/atc260x-i2c.c
> new file mode 100644
> index 000000000000..3b7e8c1f5ac5
> --- /dev/null
> +++ b/drivers/mfd/atc260x-i2c.c
> @@ -0,0 +1,98 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * I2C bus interface for ATC260x PMICs
> + *
> + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/mfd/atc260x/core.h>
> +#include <linux/mfd/core.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/regmap.h>
> +
> +#include "atc260x.h"
> +
> +const struct mfd_cell atc2609a_mfd_cells[] = {
> +	{ .name = "atc260x-regulator", },
> +};

What other child devices are there?

Please add more, or this is not an MFD.

> +static int atc260x_i2c_probe(struct i2c_client *client,
> +			     const struct i2c_device_id *id)
> +{
> +	struct atc260x *atc260x;
> +	const void *of_data;
> +	unsigned long atc260x_type;
> +
> +	atc260x = devm_kzalloc(&client->dev, sizeof(*atc260x), GFP_KERNEL);
> +	if (!atc260x)
> +		return -ENOMEM;
> +
> +	of_data = of_device_get_match_data(&client->dev);
> +	if (!of_data)
> +		return -ENODEV;
> +
> +	atc260x_type = (unsigned long)of_data;
> +
> +	switch (atc260x_type) {
> +	case ATC2609A:

How many more models are you expecting to support?

> +		atc260x->regmap_cfg = &atc2609a_regmap_config;
> +		atc260x->regmap_irq_chip = &atc2609a_regmap_irq_chip;
> +		atc260x->cells = atc2609a_mfd_cells;
> +		atc260x->nr_cells = ARRAY_SIZE(atc2609a_mfd_cells);
> +		atc260x->type_name = "atc2609a";
> +		atc260x->rev_reg = ATC2609A_CHIP_VER;
> +		atc260x->dev_init = atc2609a_dev_init;
> +		break;
> +	default:
> +		dev_err(&client->dev,
> +			"Unsupported ATC260x I2C device type %ld\n",
> +			atc260x_type);
> +		return -EINVAL;
> +	}

I'd assume you'd have to replicate all of this for SPI too.  That does
not sound like a good idea.  Please find a better, more succinct way
to handle this i.e. in the core driver.

> +	atc260x->regmap = devm_regmap_init_i2c(client, atc260x->regmap_cfg);
> +	if (IS_ERR(atc260x->regmap)) {
> +		dev_err(&client->dev, "regmap initialization failed\n");
> +		return PTR_ERR(atc260x->regmap);
> +	}
> +
> +	i2c_set_clientdata(client, atc260x);
> +	atc260x->type = atc260x_type;

> +	atc260x->dev = &client->dev;
> +	atc260x->irq = client->irq;

You already have 'dev' and 'irq' stored in 'client', which you need in
order retrieve them back anyway.  So why store them again?

> +	return atc260x_core_init(atc260x);
> +}
> +
> +static int atc260x_i2c_remove(struct i2c_client *client)
> +{
> +	struct atc260x *atc260x = dev_get_drvdata(&client->dev);
> +
> +	atc260x_core_exit(atc260x);
> +
> +	return 0;
> +}
> +
> +const struct of_device_id atc260x_of_match[] = {
> +	{ .compatible = "actions,atc2609a", .data = (void *)ATC2609A },

Is there no way to dynamically request chip ID from the H/W?

> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(i2c, atc260x_of_match);
> +
> +static struct i2c_driver atc260x_i2c_driver = {
> +	.driver = {
> +		.name	= "atc260x",
> +		.of_match_table	= of_match_ptr(atc260x_of_match),
> +	},
> +	.probe		= atc260x_i2c_probe,
> +	.remove		= atc260x_i2c_remove,
> +};
> +
> +module_i2c_driver(atc260x_i2c_driver);
> +
> +MODULE_DESCRIPTION("ATC260x PMICs I2C bus interface");
> +MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/mfd/atc260x.h b/drivers/mfd/atc260x.h
> new file mode 100644
> index 000000000000..30fc66dfba04
> --- /dev/null
> +++ b/drivers/mfd/atc260x.h
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * MFD internals for ATC260x PMICs
> + *
> + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> + */
> +
> +#ifndef ATC260X_MFD_H
> +#define ATC260X_MFD_H
> +
> +extern const struct of_device_id atc260x_of_match[];
> +int atc260x_core_init(struct atc260x *atc260x);
> +int atc260x_core_exit(struct atc260x *atc260x);
> +void atc260x_cmu_reset(struct atc260x *atc260x, u32 reg, u8 mask, u32 bit);
> +
> +extern const struct regmap_config atc2609a_regmap_config;
> +extern const struct mfd_cell atc2609a_mfd_cells[];
> +extern const struct regmap_irq_chip atc2609a_regmap_irq_chip;
> +extern const struct regmap_irq atc2609a_irqs[];

Yuck!  Please don't do this.  Please put this stuff in one file.

> +int atc2609a_dev_init(struct atc260x *atc260x);
> +
> +#endif /* ATC260X_MFD_H */
> diff --git a/include/linux/mfd/atc260x/atc2609a_regs.h b/include/linux/mfd/atc260x/atc2609a_regs.h
> new file mode 100644
> index 000000000000..851fb3dadd4f
> --- /dev/null
> +++ b/include/linux/mfd/atc260x/atc2609a_regs.h
> @@ -0,0 +1,228 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * ATC2609A PMIC register definitions
> + *
> + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> + */
> +
> +#ifndef __ATC2609A_REGS_H__
> +#define __ATC2609A_REGS_H__
> +
> +enum atc2609a_irq_def {
> +	ATC2609A_IRQ_AUDIO = 0,
> +	ATC2609A_IRQ_OV = 1,
> +	ATC2609A_IRQ_OC = 2,
> +	ATC2609A_IRQ_OT = 3,
> +	ATC2609A_IRQ_UV = 4,
> +	ATC2609A_IRQ_ALARM = 5,
> +	ATC2609A_IRQ_ONOFF = 6,
> +	ATC2609A_IRQ_WKUP = 7,
> +	ATC2609A_IRQ_IR = 8,
> +	ATC2609A_IRQ_REMCON = 9,
> +	ATC2609A_IRQ_POWER_IN = 10,
> +};
> +
> +/* PMU Register */
> +#define ATC2609A_PMU_SYS_CTL0			0x00
> +#define ATC2609A_PMU_SYS_CTL1			0x01
> +#define ATC2609A_PMU_SYS_CTL2			0x02
> +#define ATC2609A_PMU_SYS_CTL3			0x03
> +#define ATC2609A_PMU_SYS_CTL4			0x04
> +#define ATC2609A_PMU_SYS_CTL5			0x05
> +#define ATC2609A_PMU_SYS_CTL6			0x06
> +#define ATC2609A_PMU_SYS_CTL7			0x07
> +#define ATC2609A_PMU_SYS_CTL8			0x08
> +#define ATC2609A_PMU_SYS_CTL9			0x09
> +#define ATC2609A_PMU_BAT_CTL0			0x0A
> +#define ATC2609A_PMU_BAT_CTL1			0x0B
> +#define ATC2609A_PMU_VBUS_CTL0			0x0C
> +#define ATC2609A_PMU_VBUS_CTL1			0x0D
> +#define ATC2609A_PMU_WALL_CTL0			0x0E
> +#define ATC2609A_PMU_WALL_CTL1			0x0F
> +#define ATC2609A_PMU_SYS_PENDING		0x10
> +#define ATC2609A_PMU_APDS_CTL0			0x11
> +#define ATC2609A_PMU_APDS_CTL1			0x12
> +#define ATC2609A_PMU_APDS_CTL2			0x13
> +#define ATC2609A_PMU_CHARGER_CTL		0x14
> +#define ATC2609A_PMU_BAKCHARGER_CTL		0x15
> +#define ATC2609A_PMU_SWCHG_CTL0			0x16
> +#define ATC2609A_PMU_SWCHG_CTL1			0x17
> +#define ATC2609A_PMU_SWCHG_CTL2			0x18
> +#define ATC2609A_PMU_SWCHG_CTL3			0x19
> +#define ATC2609A_PMU_SWCHG_CTL4			0x1A
> +#define ATC2609A_PMU_DC_OSC			0x1B
> +#define ATC2609A_PMU_DC0_CTL0			0x1C
> +#define ATC2609A_PMU_DC0_CTL1			0x1D
> +#define ATC2609A_PMU_DC0_CTL2			0x1E
> +#define ATC2609A_PMU_DC0_CTL3			0x1F
> +#define ATC2609A_PMU_DC0_CTL4			0x20
> +#define ATC2609A_PMU_DC0_CTL5			0x21
> +#define ATC2609A_PMU_DC0_CTL6			0x22
> +#define ATC2609A_PMU_DC1_CTL0			0x23
> +#define ATC2609A_PMU_DC1_CTL1			0x24
> +#define ATC2609A_PMU_DC1_CTL2			0x25
> +#define ATC2609A_PMU_DC1_CTL3			0x26
> +#define ATC2609A_PMU_DC1_CTL4			0x27
> +#define ATC2609A_PMU_DC1_CTL5			0x28
> +#define ATC2609A_PMU_DC1_CTL6			0x29
> +#define ATC2609A_PMU_DC2_CTL0			0x2A
> +#define ATC2609A_PMU_DC2_CTL1			0x2B
> +#define ATC2609A_PMU_DC2_CTL2			0x2C
> +#define ATC2609A_PMU_DC2_CTL3			0x2D
> +#define ATC2609A_PMU_DC2_CTL4			0x2E
> +#define ATC2609A_PMU_DC2_CTL5			0x2F
> +#define ATC2609A_PMU_DC2_CTL6			0x30
> +#define ATC2609A_PMU_DC3_CTL0			0x31
> +#define ATC2609A_PMU_DC3_CTL1			0x32
> +#define ATC2609A_PMU_DC3_CTL2			0x33
> +#define ATC2609A_PMU_DC3_CTL3			0x34
> +#define ATC2609A_PMU_DC3_CTL4			0x35
> +#define ATC2609A_PMU_DC3_CTL5			0x36
> +#define ATC2609A_PMU_DC3_CTL6			0x37
> +#define ATC2609A_PMU_DC_ZR			0x38
> +#define ATC2609A_PMU_LDO0_CTL0			0x39
> +#define ATC2609A_PMU_LDO0_CTL1			0x3A
> +#define ATC2609A_PMU_LDO1_CTL0			0x3B
> +#define ATC2609A_PMU_LDO1_CTL1			0x3C
> +#define ATC2609A_PMU_LDO2_CTL0			0x3D
> +#define ATC2609A_PMU_LDO2_CTL1			0x3E
> +#define ATC2609A_PMU_LDO3_CTL0			0x3F
> +#define ATC2609A_PMU_LDO3_CTL1			0x40
> +#define ATC2609A_PMU_LDO4_CTL0			0x41
> +#define ATC2609A_PMU_LDO4_CTL1			0x42
> +#define ATC2609A_PMU_LDO5_CTL0			0x43
> +#define ATC2609A_PMU_LDO5_CTL1			0x44
> +#define ATC2609A_PMU_LDO6_CTL0			0x45
> +#define ATC2609A_PMU_LDO6_CTL1			0x46
> +#define ATC2609A_PMU_LDO7_CTL0			0x47
> +#define ATC2609A_PMU_LDO7_CTL1			0x48
> +#define ATC2609A_PMU_LDO8_CTL0			0x49
> +#define ATC2609A_PMU_LDO8_CTL1			0x4A
> +#define ATC2609A_PMU_LDO9_CTL			0x4B
> +#define ATC2609A_PMU_OV_INT_EN			0x4C
> +#define ATC2609A_PMU_OV_STATUS			0x4D
> +#define ATC2609A_PMU_UV_INT_EN			0x4E
> +#define ATC2609A_PMU_UV_STATUS			0x4F
> +#define ATC2609A_PMU_OC_INT_EN			0x50
> +#define ATC2609A_PMU_OC_STATUS			0x51
> +#define ATC2609A_PMU_OT_CTL			0x52
> +#define ATC2609A_PMU_CM_CTL0			0x53
> +#define ATC2609A_PMU_FW_USE0			0x54
> +#define ATC2609A_PMU_FW_USE1			0x55
> +#define ATC2609A_PMU_ADC12B_I			0x56
> +#define ATC2609A_PMU_ADC12B_V			0x57
> +#define ATC2609A_PMU_ADC12B_DUMMY		0x58
> +#define ATC2609A_PMU_AUXADC_CTL0		0x59
> +#define ATC2609A_PMU_AUXADC_CTL1		0x5A
> +#define ATC2609A_PMU_BATVADC			0x5B
> +#define ATC2609A_PMU_BATIADC			0x5C
> +#define ATC2609A_PMU_WALLVADC			0x5D
> +#define ATC2609A_PMU_WALLIADC			0x5E
> +#define ATC2609A_PMU_VBUSVADC			0x5F
> +#define ATC2609A_PMU_VBUSIADC			0x60
> +#define ATC2609A_PMU_SYSPWRADC			0x61
> +#define ATC2609A_PMU_REMCONADC			0x62
> +#define ATC2609A_PMU_SVCCADC			0x63
> +#define ATC2609A_PMU_CHGIADC			0x64
> +#define ATC2609A_PMU_IREFADC			0x65
> +#define ATC2609A_PMU_BAKBATADC			0x66
> +#define ATC2609A_PMU_ICTEMPADC			0x67
> +#define ATC2609A_PMU_AUXADC0			0x68
> +#define ATC2609A_PMU_AUXADC1			0x69
> +#define ATC2609A_PMU_AUXADC2			0x6A
> +#define ATC2609A_PMU_AUXADC3			0x6B
> +#define ATC2609A_PMU_ICTEMPADC_ADJ		0x6C
> +#define ATC2609A_PMU_BDG_CTL			0x6D
> +#define ATC2609A_RTC_CTL			0x6E
> +#define ATC2609A_RTC_MSALM			0x6F
> +#define ATC2609A_RTC_HALM			0x70
> +#define ATC2609A_RTC_YMDALM			0x71
> +#define ATC2609A_RTC_MS				0x72
> +#define ATC2609A_RTC_H				0x73
> +#define ATC2609A_RTC_DC				0x74
> +#define ATC2609A_RTC_YMD			0x75
> +#define ATC2609A_EFUSE_DAT			0x76
> +#define ATC2609A_EFUSECRTL1			0x77
> +#define ATC2609A_EFUSECRTL2			0x78
> +#define ATC2609A_PMU_DC4_CTL0			0x79
> +#define ATC2609A_PMU_DC4_CTL1			0x7A
> +#define ATC2609A_PMU_DC4_CTL2			0x7B
> +#define ATC2609A_PMU_DC4_CTL3			0x7C
> +#define ATC2609A_PMU_DC4_CTL4			0x7D
> +#define ATC2609A_PMU_DC4_CTL5			0x7E
> +#define ATC2609A_PMU_DC4_CTL6			0x7F
> +#define ATC2609A_PMU_PWR_STATUS			0x80
> +#define ATC2609A_PMU_S2_PWR			0x81
> +#define ATC2609A_CLMT_CTL0			0x82
> +#define ATC2609A_CLMT_DATA0			0x83
> +#define ATC2609A_CLMT_DATA1			0x84
> +#define ATC2609A_CLMT_DATA2			0x85
> +#define ATC2609A_CLMT_DATA3			0x86
> +#define ATC2609A_CLMT_ADD0			0x87
> +#define ATC2609A_CLMT_ADD1			0x88
> +#define ATC2609A_CLMT_OCV_TABLE			0x89
> +#define ATC2609A_CLMT_R_TABLE			0x8A
> +#define ATC2609A_PMU_PWRON_CTL0			0x8D
> +#define ATC2609A_PMU_PWRON_CTL1			0x8E
> +#define ATC2609A_PMU_PWRON_CTL2			0x8F
> +#define ATC2609A_IRC_CTL			0x90
> +#define ATC2609A_IRC_STAT			0x91
> +#define ATC2609A_IRC_CC				0x92
> +#define ATC2609A_IRC_KDC			0x93
> +#define ATC2609A_IRC_WK				0x94
> +#define ATC2609A_IRC_RCC			0x95
> +
> +/* AUDIO_OUT Register */
> +#define ATC2609A_AUDIOINOUT_CTL			0xA0
> +#define ATC2609A_AUDIO_DEBUGOUTCTL		0xA1
> +#define ATC2609A_DAC_DIGITALCTL			0xA2
> +#define ATC2609A_DAC_VOLUMECTL0			0xA3
> +#define ATC2609A_DAC_ANALOG0			0xA4
> +#define ATC2609A_DAC_ANALOG1			0xA5
> +#define ATC2609A_DAC_ANALOG2			0xA6
> +#define ATC2609A_DAC_ANALOG3			0xA7
> +
> +/* AUDIO_IN Register */
> +#define ATC2609A_ADC_DIGITALCTL			0xA8
> +#define ATC2609A_ADC_HPFCTL			0xA9
> +#define ATC2609A_ADC_CTL			0xAA
> +#define ATC2609A_AGC_CTL0			0xAB
> +#define ATC2609A_AGC_CTL1			0xAC
> +#define ATC2609A_AGC_CTL2			0xAD
> +#define ATC2609A_ADC_ANALOG0			0xAE
> +#define ATC2609A_ADC_ANALOG1			0xAF
> +
> +/* PCM_IF Register */
> +#define ATC2609A_PCM0_CTL			0xB0
> +#define ATC2609A_PCM1_CTL			0xB1
> +#define ATC2609A_PCM2_CTL			0xB2
> +#define ATC2609A_PCMIF_CTL			0xB3
> +
> +/* CMU_CONTROL Register */
> +#define ATC2609A_CMU_DEVRST			0xC1
> +
> +/* INTS Register */
> +#define ATC2609A_INTS_PD			0xC8
> +#define ATC2609A_INTS_MSK			0xC9
> +
> +/* MFP Register */
> +#define ATC2609A_MFP_CTL			0xD0
> +#define ATC2609A_PAD_VSEL			0xD1
> +#define ATC2609A_GPIO_OUTEN			0xD2
> +#define ATC2609A_GPIO_INEN			0xD3
> +#define ATC2609A_GPIO_DAT			0xD4
> +#define ATC2609A_PAD_DRV			0xD5
> +#define ATC2609A_PAD_EN				0xD6
> +#define ATC2609A_DEBUG_SEL			0xD7
> +#define ATC2609A_DEBUG_IE			0xD8
> +#define ATC2609A_DEBUG_OE			0xD9
> +#define ATC2609A_CHIP_VER			0xDC
> +
> +/* PWSI Register */
> +#define ATC2609A_PWSI_CTL			0xF0
> +#define ATC2609A_PWSI_STATUS			0xF1
> +
> +/* TWSI Register */
> +#define ATC2609A_SADDR				0xFF
> +
> +#endif /* __ATC2609A_REGS_H__ */
> diff --git a/include/linux/mfd/atc260x/core.h b/include/linux/mfd/atc260x/core.h
> new file mode 100644
> index 000000000000..9d75eca731d4
> --- /dev/null
> +++ b/include/linux/mfd/atc260x/core.h
> @@ -0,0 +1,64 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Core MFD defines for ATC260x PMICs
> + *
> + * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> + */
> +
> +#ifndef __ATC260X_CORE_H__
> +#define __ATC260X_CORE_H__
> +
> +#include <linux/mfd/atc260x/atc2609a_regs.h>
> +
> +enum atc260x_type {
> +	ATC2603A = 0,
> +	ATC2603C = 1,
> +	ATC2609A = 2,

Why don't you let the enum enumerate these numbers for you?

> +};
> +
> +enum atc260x_reg {
> +	ATC2609A_ID_DCDC0,
> +	ATC2609A_ID_DCDC1,
> +	ATC2609A_ID_DCDC2,
> +	ATC2609A_ID_DCDC3,
> +	ATC2609A_ID_DCDC4,
> +	ATC2609A_ID_LDO0,
> +	ATC2609A_ID_LDO1,
> +	ATC2609A_ID_LDO2,
> +	ATC2609A_ID_LDO3,
> +	ATC2609A_ID_LDO4,
> +	ATC2609A_ID_LDO5,
> +	ATC2609A_ID_LDO6,
> +	ATC2609A_ID_LDO7,
> +	ATC2609A_ID_LDO8,
> +	ATC2609A_ID_LDO9,
> +	ATC2609A_ID_MAX,
> +};
> +
> +enum atc260x_cmu_bits {
> +	ATC260X_CMU_TP = 0,
> +	ATC260X_CMU_MFP = 1,
> +	ATC260X_CMU_INTS = 2,
> +	ATC260X_CMU_ETHPHY = 3,
> +	ATC260X_CMU_AUDIO = 4,
> +	ATC260X_CMU_PWSI = 5,
> +};

Why don't you let the enum enumerate these numbers for you?

> +struct atc260x {
> +	struct device *dev;
> +	struct regmap_irq_chip_data *irq_data;
> +	struct regmap *regmap;
> +	const struct regmap_config *regmap_cfg;
> +	const struct regmap_irq_chip *regmap_irq_chip;
> +	const struct mfd_cell *cells;
> +	int nr_cells;
> +	int irq;
> +
> +	enum atc260x_type type;
> +	const char *type_name;
> +	unsigned int rev_reg;
> +
> +	int (*dev_init)(struct atc260x *atc260x);
> +};

If you do this right, you could probably remove this struct
completely.

> +#endif /* __ATC260X_CORE_H__ */

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

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

* Re: [PATCH 1/4] dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding
  2019-06-17 15:50 ` [PATCH 1/4] dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding Manivannan Sadhasivam
@ 2019-07-09 16:48   ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-07-09 16:48 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: lee.jones, lgirdwood, broonie, robh+dt, afaerber, linux-actions,
	linux-kernel, thomas.liau, devicetree, linus.walleij,
	Manivannan Sadhasivam

On Mon, 17 Jun 2019 21:20:08 +0530, Manivannan Sadhasivam wrote:
> Add devicetree binding for Actions Semi ATC260x PMICs.
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  .../devicetree/bindings/mfd/atc260x.txt       | 162 ++++++++++++++++++
>  1 file changed, 162 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/atc260x.txt
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

end of thread, other threads:[~2019-07-09 16:49 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 15:50 [PATCH 0/4] Add MFD/Regulator support for ATC260x PMICs Manivannan Sadhasivam
2019-06-17 15:50 ` [PATCH 1/4] dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding Manivannan Sadhasivam
2019-07-09 16:48   ` Rob Herring
2019-06-17 15:50 ` [PATCH 2/4] mfd: Add initial MFD driver for ATC260x PMICs Manivannan Sadhasivam
2019-06-26  6:56   ` Lee Jones
2019-06-17 15:50 ` [PATCH 3/4] regulator: Add regulator " Manivannan Sadhasivam
2019-06-17 16:30   ` Mark Brown
2019-06-17 16:34     ` Manivannan Sadhasivam
2019-06-17 16:38       ` Andreas Färber
2019-06-17 16:54         ` Mark Brown
2019-06-17 20:30         ` Greg Kroah-Hartman
2019-06-17 17:03       ` Mark Brown
2019-06-17 17:24         ` Manivannan Sadhasivam
2019-06-18  8:13         ` Lee Jones
2019-06-18 10:44           ` Mark Brown
2019-06-17 15:50 ` [PATCH 4/4] MAINTAINERS: Add entry for ATC260x PMIC Manivannan Sadhasivam

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