Skip to contentSkip to conversation

Add initial support for ATC260x PMICs

PATCH Superseded Cristian Ciocaltea 3 participants 15 messages Jan 20, 2021 – Jan 26, 2021

Subsystems (7)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Cristian Ciocaltea

author maintainer
#0 lore raw

v6 cover Add initial support for ATC260x PMICs

The ATC260x family of PMICs integrates Audio Codec, Power management, Clock generation and GPIO controller blocks. There are currently 3
variants: ATC2603A, ATC2603C and ATC2609A.

This is re-spin of the v1 patch series submitted some time ago by Mani, who provided the MFD and regulator drivers for ATC2609A:
https://lore.kernel.org/lkml/[email protected]/

Since v2, I added support for ATC2603C, together with some new functionalities for both chips: power controller and onkey input. The ATC2603A chip type remains unsupported for the moment.

This has been tested on RoseapplePi, a SBC based on the Actions Semi S500 SoC, which integrates the ATC2603C variant of the PMIC.

Note that enabling the ATC260x PMICs on compatible Actions Semi Owl SoC based boards depends on:

* the Actions Semi SIRQ driver (for PMIC DTS setup), merged in v5.10:
https://lore.kernel.org/lkml/[email protected]/

* the atomic transfers in Owl I2C driver (for power controller), merged in v5.11:
https://lore.kernel.org/lkml/[email protected]/

Additionally, please note that I have taken the authorship for the MFD and regulator drivers patches, considering the original code has been modified to a large extent.

Thanks,
Cristi

Changes in v6 - MFD driver updates as indicated by Lee:
- Defined a magic number for max chip revision
- Adjusted code formatting around i2c_driver struct initialization
- Dropped the device initialization callback in struct atc260x and instead provided a generic function making use of a new member structure to hold the hardware specific register information

Changes in v5:
- Removed an unnecessary '#include' line in the power-off driver, as noticed by Sebastian
- Rebased patchset on v5.11-rc3

Changes in v4:
- Updated MFD driver according to Lee's review
- Handled ATC2603C's LDO12 fixed regulator per Mark's suggestion
- Rebased patchset on v5.11-rc1

Changes in v3:
- Integrated feedback from Mani, Rob, Mark, Sebastian, Dmitry
- Fixed issues reported by Lee's kernel test robot
- Added new patch for 'reset-time-sec' DT binding property
- Rebased patchset on v5.10-rc6

Changes in v2:
- Reworked MFD core & I2C driver
* Integrated Lee's feedback
* Added support for using the regmap within atomic contexts
* Added support for ATC2603C chip variant
* Reorganized KConfig entries
- Improved regulator driver
* Added support for ATC2603C variant
* Used helper macros for more compact specification of regulator_desc items
* Added more regulator capabilities
- Added power controller driver
* Provides system poweroff/reboot functionalities
* Depends on atomic transfers in the Owl I2C driver
- Added onkey driver: exposes the power button as an input device
- Added yaml binding doc
- Rebased patchset on kernel v5.9-rc1

Cristian Ciocaltea (6):
dt-bindings: input: Add reset-time-sec common property
dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding
mfd: Add MFD driver for ATC260x PMICs
regulator: Add regulator driver for ATC260x PMICs
power: reset: Add poweroff driver for ATC260x PMICs
input: atc260x: Add onkey driver for ATC260x PMICs

Manivannan Sadhasivam (1):
MAINTAINERS: Add entry for ATC260x PMIC

 .../devicetree/bindings/input/input.yaml      |   7 +
 .../bindings/mfd/actions,atc260x.yaml         | 183 ++++++
 MAINTAINERS                                   |  12 +
 drivers/input/misc/Kconfig                    |  11 +
 drivers/input/misc/Makefile                   |   2 +-
 drivers/input/misc/atc260x-onkey.c            | 305 ++++++++++
 drivers/mfd/Kconfig                           |  18 +
 drivers/mfd/Makefile                          |   3 +
 drivers/mfd/atc260x-core.c                    | 310 ++++++++++
 drivers/mfd/atc260x-i2c.c                     |  64 +++
 drivers/power/reset/Kconfig                   |   8 +-
 drivers/power/reset/Makefile                  |   1 +
 drivers/power/reset/atc260x-poweroff.c        | 262 +++++++++
 drivers/regulator/Kconfig                     |   8 +
 drivers/regulator/Makefile                    |   1 +
 drivers/regulator/atc260x-regulator.c         | 539 ++++++++++++++++++
 include/linux/mfd/atc260x/atc2603c.h          | 281 +++++++++
 include/linux/mfd/atc260x/atc2609a.h          | 308 ++++++++++
 include/linux/mfd/atc260x/core.h              |  58 ++
 19 files changed, 2379 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/actions,atc260x.yaml
 create mode 100644 drivers/input/misc/atc260x-onkey.c
 create mode 100644 drivers/mfd/atc260x-core.c
 create mode 100644 drivers/mfd/atc260x-i2c.c
 create mode 100644 drivers/power/reset/atc260x-poweroff.c
 create mode 100644 drivers/regulator/atc260x-regulator.c
 create mode 100644 include/linux/mfd/atc260x/atc2603c.h
 create mode 100644 include/linux/mfd/atc260x/atc2609a.h
 create mode 100644 include/linux/mfd/atc260x/core.h
Signature · 1 line
2.30.0
author maintainer
#1 lore raw

PATCH v6 1/7 dt-bindings: input: Add reset-time-sec common property

Add a new common property 'reset-time-sec' to be used in conjunction with the devices supporting the key pressed reset feature.

---
Changes in v6:
- None

Changes in v5:
- None

Changes in v4:
- Added Reviewed-by from Rob

Changes in v3:
- This patch was not present in v2

 Documentation/devicetree/bindings/input/input.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/input/input.yaml +7 -0
index ab407f266bef..caba93209ae7 100644
@@ -34,4 +34,11 @@ properties:
       specify this property.
     $ref: /schemas/types.yaml#/definitions/uint32
 
+  reset-time-sec:
+    description:
+      Duration in seconds which the key should be kept pressed for device to
+      reset automatically. Device with key pressed reset feature can specify
+      this property.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
 additionalProperties: true
Signature · 1 line
2.30.0
author maintainer
#2 lore raw

PATCH v6 2/7 dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding

In reply to Cristian Ciocaltea

Add devicetree binding for Actions Semi ATC260x PMICs.

---
Changes in v6:
- None

Changes in v5:
- None

Changes in v4
- Added Reviewed-by from Rob
- Added support for ATC2603C LDO12 fixed regulator per Mark's suggestion

Changes in v3 (according to Rob's review):
- Dropped the 'pwrc' and 'onkey' nodes
- Used a common 'reset-time-sec' property

 .../bindings/mfd/actions,atc260x.yaml         | 183 ++++++++++++++++++
 1 file changed, 183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/actions,atc260x.yaml
Documentation/devicetree/bindings/mfd/actions,atc260x.yaml new file +183 -0
new file mode 100644
index 000000000000..dd43a0c766f3
@@ -0,0 +1,183 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/actions,atc260x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Actions Semi ATC260x Power Management IC bindings
+
+maintainers:
+  - Manivannan Sadhasivam <[email protected]>
+  - Cristian Ciocaltea <[email protected]>
+
+description: |
+  ATC260x series PMICs integrates Audio Codec, Power Management, RTC, IR
+  and GPIO controller blocks. Currently only the PM related functionalities
+  (i.e. regulators and system power-off/reboot) for the ATC2603C and ATC2609A
+  chip variants are supported.
+  ATC2603C includes 3 programmable DC-DC converters, 9 programmable LDO
+  regulators and 1 fixed LDO regulator.
+  ATC2609A includes 5 programmable DC-DC converters and 10 programmable LDO
+  regulators.
+
+allOf:
+  - $ref: ../input/input.yaml
+
+properties:
+  compatible:
+    enum:
+      - actions,atc2603c
+      - actions,atc2609a
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  reset-time-sec:
+    description: |
+      Duration in seconds which the key should be kept pressed for device
+      to reset automatically. The hardware default is 8. Use 0 to disable
+      this functionality.
+    enum: [0, 6, 8, 10, 12]
+
+  regulators:
+    type: object
+    description: |
+      List of child nodes specifying the regulators, depending on chip variant:
+      * ATC2603C: dcdc[1-3], ldo[1-3,5-8,11,12], switchldo1
+      * ATC2609A: dcdc[0-4], ldo[0-9]
+
+    properties:
+      compatible:
+        enum:
+          - actions,atc2603c-regulator
+          - actions,atc2609a-regulator
+
+      switchldo1:
+        type: object
+        $ref: ../regulator/regulator.yaml
+
+        properties:
+          regulator-name: true
+          regulator-boot-on: true
+          regulator-always-on: true
+          regulator-min-microvolt: true
+          regulator-max-microvolt: true
+          regulator-allow-bypass: true
+          regulator-active-discharge: true
+
+        additionalProperties: false
+
+    patternProperties:
+      "^(dcdc[0-4]|ldo[0-9]|ldo1[1-2]|switchldo1)-supply$":
+        description: ATC260x voltage regulators supplies
+
+      "^(dcdc[0-4]|ldo[0-9]|ldo1[1-2])$":
+        type: object
+        $ref: ../regulator/regulator.yaml
+
+        properties:
+          regulator-name: true
+          regulator-boot-on: true
+          regulator-always-on: true
+          regulator-min-microvolt: true
+          regulator-max-microvolt: true
+          regulator-allow-bypass: true
+
+        additionalProperties: false
+
+    allOf:
+      - if:
+          properties:
+            compatible:
+              contains:
+                const: actions,atc2603c-regulator
+        then:
+          patternProperties:
+            "^(dcdc[0,4]|ldo[0,4,9])(-supply)?$": false
+
+            "^(ldo|dcdc)":
+              properties:
+                regulator-allow-bypass: false
+      - if:
+          properties:
+            compatible:
+              contains:
+                const: actions,atc2609a-regulator
+        then:
+          patternProperties:
+            "^(ldo1[1-2]|switchldo1)(-supply)?$": false
+
+            "^(dcdc|ldo[3-9])":
+              properties:
+                regulator-allow-bypass: false
+
+    required:
+      - compatible
+
+    additionalProperties: false
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    i2c0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@65 {
+            compatible = "actions,atc2603c";
+            reg = <0x65>;
+            interrupt-parent = <&sirq>;
+            interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+
+            reset-time-sec = <6>;
+
+            regulators {
+                compatible = "actions,atc2603c-regulator";
+
+                dcdc1-supply = <&reg_5v0>;
+                dcdc3-supply = <&reg_5v0>;
+                ldo5-supply = <&reg_5v0>;
+                switchldo1-supply = <&vcc>;
+
+                vdd_cpu: dcdc1 {
+                    regulator-name = "VDD_CPU";
+                    regulator-min-microvolt = <700000>;
+                    regulator-max-microvolt = <1400000>;
+                    regulator-always-on;
+                };
+
+                vcc: dcdc3 {
+                    regulator-name = "VCC";
+                    regulator-min-microvolt = <2600000>;
+                    regulator-max-microvolt = <3300000>;
+                    regulator-always-on;
+                };
+
+                vcc_3v1: ldo5 {
+                    regulator-name = "VCC_3V1";
+                    regulator-min-microvolt = <2600000>;
+                    regulator-max-microvolt = <3300000>;
+                };
+
+                sd_vcc: switchldo1 {
+                    regulator-name = "SD_VCC";
+                    regulator-min-microvolt = <3000000>;
+                    regulator-max-microvolt = <3300000>;
+                    regulator-always-on;
+                    regulator-boot-on;
+                };
+            };
+        };
+    };
+
+...
Signature · 1 line
2.30.0
author maintainer
#3 lore raw

PATCH v6 3/7 mfd: Add MFD driver for ATC260x PMICs

In reply to Cristian Ciocaltea

Add initial support for the Actions Semi ATC260x PMICs which integrates Audio Codec, Power management, Clock generation and GPIO controller blocks.

For the moment this driver only supports Regulator, Poweroff and Onkey functionalities for the ATC2603C and ATC2609A chip variants.

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

           -----> atc260x-core.c (Implements core functionalities)
          /
ATC260x --------> atc260x-i2c.c (Implements I2C interface)
          \
           -----> atc260x-spi.c (Implements SPI interface - TODO)

---
Changes in v6 - per Lee's feedback:
- Added ATC260X_CHIP_REV_MAX magic number
- Fixed code formattting arround atc260x_i2c_driver initialization
- Replaced dev_init() callback in struct atc260x with a pointer to a new struct atc260x_init_regs to hold hardware specific registry information
- Added a generic atc260x_dev_init() function and instantiated atc2603c_init_regs and atc2609a_init_regs

Changes in v5:
- None

Changes in v4 - according to Lee's review:
- Replaced 'regmap_add_irq_chip()' with 'devm' counterpart and dropped 'atc260x_device_remove()' and 'atc260x_i2c_remove()' functions
- Moved kerneldoc sections from prototypes to real functions
- Placed single line entries on one line for mfd_cells[]
- Several other minor changes

Changes in v3:
- Fixed the issues reported by Lee's kernel test robot:
WARNING: modpost: missing MODULE_LICENSE() in drivers/mfd/atc260x-core.o

Quoted 1 line
Quoted 1 line

FATAL: modpost: drivers/mfd/atc260x-i2c: sizeof(struct i2c_device_id)=24 is

not a modulo of the size of section __mod_i2c__<identifier>_device_table=588.

Quoted 1 line
Quoted 1 line

Fix definition of struct i2c_device_id in mod_devicetable.h

- Dropped the usage of '.of_compatible' fields in {atc2603c,atc2609a}_mfd_cells[]
- Added 'Co-developed-by' tag in commit message and dropped [cristian: ...] line

 drivers/mfd/Kconfig                  |  18 ++
 drivers/mfd/Makefile                 |   3 +
 drivers/mfd/atc260x-core.c           | 310 +++++++++++++++++++++++++++
 drivers/mfd/atc260x-i2c.c            |  64 ++++++
 include/linux/mfd/atc260x/atc2603c.h | 281 ++++++++++++++++++++++++
 include/linux/mfd/atc260x/atc2609a.h | 308 ++++++++++++++++++++++++++
 include/linux/mfd/atc260x/core.h     |  58 +++++
 7 files changed, 1042 insertions(+)
 create mode 100644 drivers/mfd/atc260x-core.c
 create mode 100644 drivers/mfd/atc260x-i2c.c
 create mode 100644 include/linux/mfd/atc260x/atc2603c.h
 create mode 100644 include/linux/mfd/atc260x/atc2609a.h
 create mode 100644 include/linux/mfd/atc260x/core.h
drivers/mfd/Kconfig +18 -0
index bdfce7b15621..a27ff2e83e7a 100644
@@ -2064,6 +2064,24 @@ config MFD_WCD934X
 	  This driver provides common support WCD934x audio codec and its
 	  associated Pin Controller, Soundwire Controller and Audio codec.
 
+config MFD_ATC260X
+	tristate
+	select MFD_CORE
+	select REGMAP
+	select REGMAP_IRQ
+
+config MFD_ATC260X_I2C
+	tristate "Actions Semi ATC260x PMICs with I2C"
+	select MFD_ATC260X
+	select REGMAP_I2C
+	depends on I2C
+	help
+	  Support for the Actions Semi ATC260x PMICs controlled via I2C.
+
+	  This driver provides common support for accessing the ATC2603C
+	  and ATC2609A chip variants, additional drivers must be enabled
+	  in order to use the functionality of the device.
+
 config MFD_KHADAS_MCU
 	tristate "Support for Khadas System control Microcontroller"
 	depends on I2C
drivers/mfd/Makefile +3 -0
index 14fdb188af02..1ea88d2c83b4 100644
@@ -268,3 +268,6 @@ obj-$(CONFIG_MFD_KHADAS_MCU) 	+= khadas-mcu.o
 obj-$(CONFIG_SGI_MFD_IOC3)	+= ioc3.o
 obj-$(CONFIG_MFD_SIMPLE_MFD_I2C)	+= simple-mfd-i2c.o
 obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
+
+obj-$(CONFIG_MFD_ATC260X)	+= atc260x-core.o
+obj-$(CONFIG_MFD_ATC260X_I2C)	+= atc260x-i2c.o
drivers/mfd/atc260x-core.c new file +310 -0

310 lines not on this page · raw message

drivers/mfd/atc260x-i2c.c new file +64 -0

64 lines not on this page · raw message

include/linux/mfd/atc260x/atc2603c.h new file +281 -0

281 lines not on this page · raw message

include/linux/mfd/atc260x/atc2609a.h new file +308 -0

308 lines not on this page · raw message

include/linux/mfd/atc260x/core.h new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.30.0
author maintainer
#12 lore raw

PATCH v6 5/7 power: reset: Add poweroff driver for ATC260x PMICs

In reply to Cristian Ciocaltea

This driver provides poweroff and reboot support for a system through the ATC2603C and ATC2609A chip variants of the Actions Semi ATC260x family of PMICs.

---
Changes in v6:
- None

Changes in v5:
- Drop unneeded '#include <linux/of.h>'

Changes in v4:
- None

Changes in v3:
- Removed the unnecessary driver compatibles

 drivers/power/reset/Kconfig            |   8 +-
 drivers/power/reset/Makefile           |   1 +
 drivers/power/reset/atc260x-poweroff.c | 262 +++++++++++++++++++++++++
 3 files changed, 270 insertions(+), 1 deletion(-)
 create mode 100644 drivers/power/reset/atc260x-poweroff.c
drivers/power/reset/Kconfig +7 -1
index b22c4fdb2561..1737e227b16e 100644
@@ -39,6 +39,13 @@ config POWER_RESET_AT91_SAMA5D2_SHDWC
 	  This driver supports the alternate shutdown controller for some Atmel
 	  SAMA5 SoCs. It is present for example on SAMA5D2 SoC.
 
+config POWER_RESET_ATC260X
+	tristate "Actions Semi ATC260x PMIC power-off driver"
+	depends on MFD_ATC260X
+	help
+	  This driver provides power-off and restart support for a system
+	  through Actions Semi ATC260x series PMICs.
+
 config POWER_RESET_AXXIA
 	bool "LSI Axxia reset driver"
 	depends on ARCH_AXXIA
@@ -292,4 +299,3 @@ config NVMEM_REBOOT_MODE
 	  action according to the mode.
 
 endif
-
drivers/power/reset/Makefile +1 -0
index 9dc49d3a57ff..b4601c0a96ed 100644
@@ -3,6 +3,7 @@ obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o
 obj-$(CONFIG_POWER_RESET_AT91_POWEROFF) += at91-poweroff.o
 obj-$(CONFIG_POWER_RESET_AT91_RESET) += at91-reset.o
 obj-$(CONFIG_POWER_RESET_AT91_SAMA5D2_SHDWC) += at91-sama5d2_shdwc.o
+obj-$(CONFIG_POWER_RESET_ATC260X) += atc260x-poweroff.o
 obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
 obj-$(CONFIG_POWER_RESET_BRCMKONA) += brcm-kona-reset.o
 obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
drivers/power/reset/atc260x-poweroff.c new file +262 -0

262 lines not on this page · raw message

Signature · 1 line
2.30.0
author maintainer
#14 lore raw

PATCH v6 7/7 MAINTAINERS: Add entry for ATC260x PMIC

In reply to Cristian Ciocaltea

From: Manivannan Sadhasivam <[email protected]>

Add MAINTAINERS entry for ATC260x PMIC.

[cristian: change binding doc file path, add file patterns for onkey and
poweroff drivers, fix ordering, add myself as co-maintainer]

---
Changes in v6:
- None

Changes in v5:
- None

Changes in v4:
- None

Changes in v3:
- Restored the authorship of the patch to Mani

 MAINTAINERS | 12 ++++++++++++
 1 file changed, 12 insertions(+)
MAINTAINERS +12 -0
index 844f05410509..e5e3429a6026 100644
@@ -2892,6 +2892,18 @@ W:	http://www.openaoe.org/
 F:	Documentation/admin-guide/aoe/
 F:	drivers/block/aoe/
 
+ATC260X PMIC MFD DRIVER
+M:	Manivannan Sadhasivam <[email protected]>
+M:	Cristian Ciocaltea <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/actions,atc260x.yaml
+F:	drivers/input/misc/atc260x-onkey.c
+F:	drivers/mfd/atc260*
+F:	drivers/power/reset/atc260x-poweroff.c
+F:	drivers/regulator/atc260x-regulator.c
+F:	include/linux/mfd/atc260x/*
+
 ATHEROS 71XX/9XXX GPIO DRIVER
 M:	Alban Bedel <[email protected]>
 S:	Maintained
Signature · 1 line
2.30.0
author maintainer
#8 lore raw

PATCH v6 4/7 regulator: Add regulator driver for ATC260x PMICs

In reply to Cristian Ciocaltea

Add support for the DC-DC converters and LDO regulators found in the ATC2603C and ATC2609A chip variants of the Actions Semi ATC260x family of PMICs.

---
Changes in v6:
- None

Changes in v5:
- None

Changes in v4
- Included the ATC2603C's LDO12 fixed regulator per Mark's suggestion

Changes in v3:
- Dropped 'last_dcdc_reg_id' from 'atc260x_regulator_data' and, instead, provided separate ops for DCDCs and LDOs, as recommended by Mark
- Removed the unnecessary compatibles, per Mark's review
- Added 'Co-developed-by' tag in commit message and dropped [cristian: ...] line

 drivers/regulator/Kconfig             |   8 +
 drivers/regulator/Makefile            |   1 +
 drivers/regulator/atc260x-regulator.c | 539 ++++++++++++++++++++++++++
 3 files changed, 548 insertions(+)
 create mode 100644 drivers/regulator/atc260x-regulator.c
drivers/regulator/Kconfig +8 -0
index 5abdd29fb9f3..6b1accaaed72 100644
@@ -179,6 +179,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
drivers/regulator/Makefile +1 -0
index 680e539f6579..36a069f36346 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.o
 obj-$(CONFIG_REGULATOR_ARM_SCMI) += scmi-regulator.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
drivers/regulator/atc260x-regulator.c new file +539 -0

539 lines not on this page · raw message

Signature · 1 line
2.30.0
author maintainer
#13 lore raw

PATCH v6 6/7 input: atc260x: Add onkey driver for ATC260x PMICs

In reply to Cristian Ciocaltea

The Actions Semi ATC260x PMICs are able to manage an onkey button. This driver exposes the ATC260x onkey as an input device. It can also be configured to force a system reset on a long key-press with an adjustable duration.

The currently supported chip variants are ATC2603C and ATC2609A.

---
Changes in v6:
- None

Changes in v5:
- None

Changes in v4:
- Added Acked-by from Dmitry

Changes in v3:
- Integrated Dmitry's review:
* Dropped the logic around the check for 'pdev->dev.of_node'
* Renamed 'ret' variable in 'atc260x_onkey_probe()' to 'error'
* Used 'dev_dbg' instead of 'dev_info' on status KEY_RESET_DISABLED
* Dropped 'input_dev->evbit[0] = BIT_MASK(EV_KEY);'
* Removed IRQF_TRIGGER_HIGH flag on 'devm_request_threaded_irq()'
* Implemented open/close to mitigate the racing issue in

     'atc260x_onkey_remove()' which has been dropped now

- Removed the unnecessary driver compatibles
- Used 'reset-time-sec' property of the parent device instead of 'actions,reset-time-sec' of now obsolete and removed 'onkey' DT node

 drivers/input/misc/Kconfig         |  11 ++
 drivers/input/misc/Makefile        |   2 +-
 drivers/input/misc/atc260x-onkey.c | 305 +++++++++++++++++++++++++++++
 3 files changed, 317 insertions(+), 1 deletion(-)
 create mode 100644 drivers/input/misc/atc260x-onkey.c
drivers/input/misc/Kconfig +11 -0
index ad1b6c90bc4d..7237dc440b98 100644
@@ -94,6 +94,17 @@ config INPUT_ARIZONA_HAPTICS
 	  To compile this driver as a module, choose M here: the
 	  module will be called arizona-haptics.
 
+config INPUT_ATC260X_ONKEY
+	tristate "Actions Semi ATC260x PMIC ONKEY"
+	depends on MFD_ATC260X
+	help
+	  Support the ONKEY of ATC260x PMICs as an input device reporting
+	  power button status. ONKEY can be used to wakeup from low power
+	  modes and force a reset on long press.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called atc260x-onkey.
+
 config INPUT_ATMEL_CAPTOUCH
 	tristate "Atmel Capacitive Touch Button Driver"
 	depends on OF || COMPILE_TEST
drivers/input/misc/Makefile +1 -1
index 7f202ba8f775..46db664a8bc4 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_INPUT_ADXL34X_SPI)		+= adxl34x-spi.o
 obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
 obj-$(CONFIG_INPUT_ARIEL_PWRBUTTON)	+= ariel-pwrbutton.o
 obj-$(CONFIG_INPUT_ARIZONA_HAPTICS)	+= arizona-haptics.o
+obj-$(CONFIG_INPUT_ATC260X_ONKEY)	+= atc260x-onkey.o
 obj-$(CONFIG_INPUT_ATI_REMOTE2)		+= ati_remote2.o
 obj-$(CONFIG_INPUT_ATLAS_BTNS)		+= atlas_btns.o
 obj-$(CONFIG_INPUT_ATMEL_CAPTOUCH)	+= atmel_captouch.o
@@ -86,4 +87,3 @@ obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR)	+= ideapad_slidebar.o
-
drivers/input/misc/atc260x-onkey.c new file +305 -0

305 lines not on this page · raw message

Signature · 1 line
2.30.0
author maintainer
#10 lore raw

Re: [PATCH v6 4/7] regulator: Add regulator driver for ATC260x PMICs

In reply to Mark Brown

Hi Mark,

Quoted 10 lines · Mark Brown
Quoted 3 lines · Cristian Ciocaltea

Add support for the DC-DC converters and LDO regulators found in the ATC2603C and ATC2609A chip variants of the Actions Semi ATC260x family of PMICs.

Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.

The patches applied to 'for-next' branches were not modified, but I have (wrongly) assumed I need to keep them in the series until they are eventually merged into master.

So, if I understand correctly, I should have dropped them from the patch series as soon as they had been queued, and only if they need some additional work, I can re-add them as incremental updates.

Thanks,
Cristi

maintainer
#11 lore raw

Re: [PATCH v6 4/7] regulator: Add regulator driver for ATC260x PMICs

Quoted 5 lines · Cristian Ciocaltea
Quoted 2 lines · Mark Brown

Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing

Quoted 7 lines

The patches applied to 'for-next' branches were not modified, but I have (wrongly) assumed I need to keep them in the series until they are eventually merged into master.

So, if I understand correctly, I should have dropped them from the patch series as soon as they had been queued, and only if they need some additional work, I can re-add them as incremental updates.

Yes, once something is applied it shouldn't need sending again.

#4 lore raw

Re: [PATCH v6 3/7] mfd: Add MFD driver for ATC260x PMICs

In reply to Cristian Ciocaltea
Quoted 143 lines · Cristian Ciocaltea

Add initial support for the Actions Semi ATC260x PMICs which integrates Audio Codec, Power management, Clock generation and GPIO controller blocks.

For the moment this driver only supports Regulator, Poweroff and Onkey functionalities for the ATC2603C and ATC2609A chip variants.

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

           -----> atc260x-core.c (Implements core functionalities)
          /
ATC260x --------> atc260x-i2c.c (Implements I2C interface)
          \
           -----> atc260x-spi.c (Implements SPI interface - TODO)

---
Changes in v6 - per Lee's feedback:
- Added ATC260X_CHIP_REV_MAX magic number
- Fixed code formattting arround atc260x_i2c_driver initialization
- Replaced dev_init() callback in struct atc260x with a pointer to a new struct atc260x_init_regs to hold hardware specific registry information
- Added a generic atc260x_dev_init() function and instantiated atc2603c_init_regs and atc2609a_init_regs

Changes in v5:
- None

Changes in v4 - according to Lee's review:
- Replaced 'regmap_add_irq_chip()' with 'devm' counterpart and dropped 'atc260x_device_remove()' and 'atc260x_i2c_remove()' functions
- Moved kerneldoc sections from prototypes to real functions
- Placed single line entries on one line for mfd_cells[]
- Several other minor changes

Changes in v3:
- Fixed the issues reported by Lee's kernel test robot:
WARNING: modpost: missing MODULE_LICENSE() in drivers/mfd/atc260x-core.o

Quoted 1 line
Quoted 1 line

FATAL: modpost: drivers/mfd/atc260x-i2c: sizeof(struct i2c_device_id)=24 is

not a modulo of the size of section __mod_i2c__<identifier>_device_table=588.

Quoted 1 line
Quoted 1 line

Fix definition of struct i2c_device_id in mod_devicetable.h

- Dropped the usage of '.of_compatible' fields in {atc2603c,atc2609a}_mfd_cells[]
- Added 'Co-developed-by' tag in commit message and dropped [cristian: ...] line

 drivers/mfd/Kconfig                  |  18 ++
 drivers/mfd/Makefile                 |   3 +
 drivers/mfd/atc260x-core.c           | 310 +++++++++++++++++++++++++++
 drivers/mfd/atc260x-i2c.c            |  64 ++++++
 include/linux/mfd/atc260x/atc2603c.h | 281 ++++++++++++++++++++++++
 include/linux/mfd/atc260x/atc2609a.h | 308 ++++++++++++++++++++++++++
 include/linux/mfd/atc260x/core.h     |  58 +++++
 7 files changed, 1042 insertions(+)
 create mode 100644 drivers/mfd/atc260x-core.c
 create mode 100644 drivers/mfd/atc260x-i2c.c
 create mode 100644 include/linux/mfd/atc260x/atc2603c.h
 create mode 100644 include/linux/mfd/atc260x/atc2609a.h
 create mode 100644 include/linux/mfd/atc260x/core.h
drivers/mfd/Kconfig +18 -0
index bdfce7b15621..a27ff2e83e7a 100644
@@ -2064,6 +2064,24 @@ config MFD_WCD934X
 	  This driver provides common support WCD934x audio codec and its
 	  associated Pin Controller, Soundwire Controller and Audio codec.
 
+config MFD_ATC260X
+	tristate
+	select MFD_CORE
+	select REGMAP
+	select REGMAP_IRQ
+
+config MFD_ATC260X_I2C
+	tristate "Actions Semi ATC260x PMICs with I2C"
+	select MFD_ATC260X
+	select REGMAP_I2C
+	depends on I2C
+	help
+	  Support for the Actions Semi ATC260x PMICs controlled via I2C.
+
+	  This driver provides common support for accessing the ATC2603C
+	  and ATC2609A chip variants, additional drivers must be enabled
+	  in order to use the functionality of the device.
+
 config MFD_KHADAS_MCU
 	tristate "Support for Khadas System control Microcontroller"
 	depends on I2C
drivers/mfd/Makefile +3 -0
index 14fdb188af02..1ea88d2c83b4 100644
@@ -268,3 +268,6 @@ obj-$(CONFIG_MFD_KHADAS_MCU) 	+= khadas-mcu.o
 obj-$(CONFIG_SGI_MFD_IOC3)	+= ioc3.o
 obj-$(CONFIG_MFD_SIMPLE_MFD_I2C)	+= simple-mfd-i2c.o
 obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
+
+obj-$(CONFIG_MFD_ATC260X)	+= atc260x-core.o
+obj-$(CONFIG_MFD_ATC260X_I2C)	+= atc260x-i2c.o
drivers/mfd/atc260x-core.c new file +36 -0
new file mode 100644
index 000000000000..7148ff5b05b1
@@ -0,0 +1,310 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Core support for ATC260x PMICs
+ *
+ * Copyright (C) 2019 Manivannan Sadhasivam <[email protected]>
+ * Copyright (C) 2020 Cristian Ciocaltea <[email protected]>
+ */
+
+#include <linux/interrupt.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>
+
+#define ATC260X_CHIP_REV_MAX	31
+
+struct atc260x_init_regs {
+	unsigned int cmu_devrst;
+	unsigned int cmu_devrst_ints;
+	unsigned int ints_msk;
+	unsigned int pad_en;
+	unsigned int pad_en_extirq;
+};
+
+static void regmap_lock_mutex(void *__mutex)
+{
+	struct mutex *mutex = __mutex;
+
+	/*
+	 * Using regmap within an atomic context (e.g. accessing a PMIC when
+	 * powering system down) is normally allowed only if the regmap type
+	 * is MMIO and the regcache type is either REGCACHE_NONE or
+	 * REGCACHE_FLAT. For slow buses like I2C and SPI, the regmap is
+	 * internally protected by a mutex which is acquired non-atomically.

drivers/mfd/atc260x-core.c line 46

Quoted 10 lines
drivers/mfd/atc260x-core.c new file +10 -0
+	 *
+	 * Let's improve this by using a customized locking scheme inspired
+	 * from I2C atomic transfer. See i2c_in_atomic_xfer_mode() for a
+	 * starting point.
+	 */
+	if (system_state > SYSTEM_RUNNING && irqs_disabled())
+		mutex_trylock(mutex);
+	else
+		mutex_lock(mutex);
+}

Would this be useful to anyone else?

For my own reference (apply this as-is to your sign-off block):

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
author maintainer
#5 lore raw

Re: [PATCH v6 3/7] mfd: Add MFD driver for ATC260x PMICs

Hi Lee,

Quoted 8 lines · Lee Jones
Quoted 6 lines · Cristian Ciocaltea

Add initial support for the Actions Semi ATC260x PMICs which integrates Audio Codec, Power management, Clock generation and GPIO controller blocks.

For the moment this driver only supports Regulator, Poweroff and Onkey functionalities for the ATC2603C and ATC2609A chip variants.

[...]

Quoted 14 lines
Quoted 14 lines
drivers/mfd/atc260x-core.c new file +14 -0
+static void regmap_lock_mutex(void *__mutex)
+{
+	struct mutex *mutex = __mutex;
+
+	/*
+	 * Using regmap within an atomic context (e.g. accessing a PMIC when
+	 * powering system down) is normally allowed only if the regmap type
+	 * is MMIO and the regcache type is either REGCACHE_NONE or
+	 * REGCACHE_FLAT. For slow buses like I2C and SPI, the regmap is
+	 * internally protected by a mutex which is acquired non-atomically.
+	 *
+	 * Let's improve this by using a customized locking scheme inspired
+	 * from I2C atomic transfer. See i2c_in_atomic_xfer_mode() for a
+	 * starting point.
Quoted 8 lines

drivers/mfd/atc260x-core.c line 46

Quoted 6 lines
drivers/mfd/atc260x-core.c new file +6 -0
+	 */
+	if (system_state > SYSTEM_RUNNING && irqs_disabled())
+		mutex_trylock(mutex);
+	else
+		mutex_lock(mutex);
+}

Would this be useful to anyone else?

If you refer to the locking scheme, it is currently required by the power-off driver to handle atomic contexts.

Quoted 1 line

For my own reference (apply this as-is to your sign-off block):

Please note the patches "[4/7] regulator: ..." and "[5/7] power: ..." have been already picked up by Mark and Sebastian, respectively, while Dmitry suggested to merge "[6/7] input: ..." through MFD.

Quoted 7 lines
Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

Thanks,
Cristi

maintainer
#9 lore raw

Re: [PATCH v6 4/7] regulator: Add regulator driver for ATC260x PMICs

In reply to Cristian Ciocaltea
Quoted 3 lines · Cristian Ciocaltea

Add support for the DC-DC converters and LDO regulators found in the ATC2603C and ATC2609A chip variants of the Actions Semi ATC260x family of PMICs.

Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.

#6 lore raw

Re: [PATCH v6 3/7] mfd: Add MFD driver for ATC260x PMICs

In reply to Cristian Ciocaltea
Quoted 37 lines · Cristian Ciocaltea

Hi Lee,

Quoted 8 lines · Lee Jones
Quoted 6 lines · Cristian Ciocaltea

Add initial support for the Actions Semi ATC260x PMICs which integrates Audio Codec, Power management, Clock generation and GPIO controller blocks.

For the moment this driver only supports Regulator, Poweroff and Onkey functionalities for the ATC2603C and ATC2609A chip variants.

[...]

Quoted 14 lines
Quoted 14 lines
drivers/mfd/atc260x-core.c new file +14 -0
+static void regmap_lock_mutex(void *__mutex)
+{
+	struct mutex *mutex = __mutex;
+
+	/*
+	 * Using regmap within an atomic context (e.g. accessing a PMIC when
+	 * powering system down) is normally allowed only if the regmap type
+	 * is MMIO and the regcache type is either REGCACHE_NONE or
+	 * REGCACHE_FLAT. For slow buses like I2C and SPI, the regmap is
+	 * internally protected by a mutex which is acquired non-atomically.
+	 *
+	 * Let's improve this by using a customized locking scheme inspired
+	 * from I2C atomic transfer. See i2c_in_atomic_xfer_mode() for a
+	 * starting point.
Quoted 8 lines

drivers/mfd/atc260x-core.c line 46

Quoted 6 lines
drivers/mfd/atc260x-core.c new file +6 -0
+	 */
+	if (system_state > SYSTEM_RUNNING && irqs_disabled())
+		mutex_trylock(mutex);
+	else
+		mutex_lock(mutex);
+}

Would this be useful to anyone else?

Quoted 2 lines

If you refer to the locking scheme, it is currently required by the power-off driver to handle atomic contexts.

Right, but would this be helpful to any non-Actions drivers?

If so, perhaps it should reside as a Regmap helper?

Quoted 5 lines
Quoted 1 line

For my own reference (apply this as-is to your sign-off block):

Please note the patches "[4/7] regulator: ..." and "[5/7] power: ..." have been already picked up by Mark and Sebastian, respectively, while Dmitry suggested to merge "[6/7] input: ..." through MFD.

That's fine.

Please re-submit the patches which have not been applied already.

Quoted 5 lines
Quoted 2 lines

Thanks,
Cristi

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
author maintainer
#7 lore raw

Re: [PATCH v6 3/7] mfd: Add MFD driver for ATC260x PMICs

Quoted 39 lines · Lee Jones
Quoted 37 lines · Cristian Ciocaltea

Hi Lee,

Quoted 8 lines · Lee Jones
Quoted 6 lines · Cristian Ciocaltea

Add initial support for the Actions Semi ATC260x PMICs which integrates Audio Codec, Power management, Clock generation and GPIO controller blocks.

For the moment this driver only supports Regulator, Poweroff and Onkey functionalities for the ATC2603C and ATC2609A chip variants.

[...]

Quoted 22 lines
Quoted 10 lines
drivers/mfd/atc260x-core.c new file +10 -0
+static void regmap_lock_mutex(void *__mutex)
+{
+	struct mutex *mutex = __mutex;
+
+	/*
+	 * Using regmap within an atomic context (e.g. accessing a PMIC when
+	 * powering system down) is normally allowed only if the regmap type
+	 * is MMIO and the regcache type is either REGCACHE_NONE or
+	 * REGCACHE_FLAT. For slow buses like I2C and SPI, the regmap is
+	 * internally protected by a mutex which is acquired non-atomically.

drivers/mfd/atc260x-core.c line 46

Quoted 10 lines
drivers/mfd/atc260x-core.c new file +10 -0
+	 *
+	 * Let's improve this by using a customized locking scheme inspired
+	 * from I2C atomic transfer. See i2c_in_atomic_xfer_mode() for a
+	 * starting point.
+	 */
+	if (system_state > SYSTEM_RUNNING && irqs_disabled())
+		mutex_trylock(mutex);
+	else
+		mutex_lock(mutex);
+}

Would this be useful to anyone else?

Quoted 6 lines
Quoted 2 lines

If you refer to the locking scheme, it is currently required by the power-off driver to handle atomic contexts.

Right, but would this be helpful to any non-Actions drivers?

If so, perhaps it should reside as a Regmap helper?

I got it now, thanks for the suggestion. As a matter of fact this was my initial intention, but since I was not aware of any other use case I decided to keep it private for the moment.

Most probably this hardware design is not specific to Actions only, so it might be helpful to other drivers as well. Therefore I am going to reconsider this and if/when it is accepted upstream, I will come back with a separate update patch for this driver.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

For my own reference (apply this as-is to your sign-off block):

Please note the patches "[4/7] regulator: ..." and "[5/7] power: ..." have been already picked up by Mark and Sebastian, respectively, while Dmitry suggested to merge "[6/7] input: ..." through MFD.

That's fine.

Please re-submit the patches which have not been applied already.

I have just submitted v7 with the two patches dropped.

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

Thanks,
Cristi

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog