Add initial support for ATC260x PMICs
Subsystems (7)
Cristian Ciocaltea
maintainerv5 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 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 | 293 ++++++++++ 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, 2362 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
Cristian Ciocaltea
maintainerPATCH v5 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 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
@@ -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
Cristian Ciocaltea
maintainerPATCH v5 2/7 dt-bindings: mfd: Add Actions Semi ATC260x PMIC binding
In reply to Cristian CiocalteaAdd devicetree binding for Actions Semi ATC260x PMICs.
---
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
@@ -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 = <®_5v0>; + dcdc3-supply = <®_5v0>; + ldo5-supply = <®_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
Cristian Ciocaltea
maintainerPATCH v5 3/7 mfd: Add MFD driver for ATC260x PMICs
In reply to Cristian CiocalteaAdd 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 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_idinmod_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 | 293 +++++++++++++++++++++++++ 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, 1025 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
@@ -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
@@ -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 +293 -0
293 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
Re: [PATCH v5 3/7] mfd: Add MFD driver for ATC260x PMICs
Quoted 52 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)Co-developed-by Manivannan Sadhasivam <[email protected]>Signed-off-by Manivannan Sadhasivam <[email protected]>Signed-off-by Cristian Ciocaltea <[email protected]>---
Changes in v5:
- NoneChanges 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 changesChanges in v3:
- Fixed the issues reported by Lee's kernel test robot:
WARNING: modpost: missingMODULE_LICENSE()indrivers/mfd/atc260x-core.oQuoted 1 line
Quoted 1 line
FATAL: modpost:
drivers/mfd/atc260x-i2c:sizeof(struct i2c_device_id)=24 isnot 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_idinmod_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: ...] linedrivers/mfd/Kconfig | 18 ++ drivers/mfd/Makefile | 3 + drivers/mfd/atc260x-core.c | 293 +++++++++++++++++++++++++ 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, 1025 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
[...]
Quoted 20 lines
drivers/mfd/atc260x-core.c new file +20
-0+/** +* atc260x_device_probe(): Probe a configured ATC260x device +* +* @atc260x: ATC260x device to probe (must be configured) +* +* This function lets the ATC260x core register the ATC260x MFD devices +* and IRQCHIP. The ATC260x device passed in must be fully configured +* with atc260x_match_device, its IRQ set, and regmap created. +*/ +int atc260x_device_probe (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 ; + } +
drivers/mfd/atc260x-core.c line 261
Quoted 10 lines
drivers/mfd/atc260x-core.c new file +10
-0+/* Initialize the hardware */ + atc260x->dev_init (atc260x); + + ret =regmap_read (atc260x->regmap, atc260x->rev_reg, &chip_rev); +if (ret) { +dev_err (dev,"Failed to get chip revision\n" ); +return ret; + } + +if (chip_rev >31 ) {
Nit: If you have to respin this, please define this magic number.
Quoted 27 lines
drivers/mfd/atc260x-core.c new file +27
-0+dev_err (dev,"Unknown chip revision: %u\n" , chip_rev); +return -EINVAL ; + } + + atc260x->ic_ver =__ffs (chip_rev +1U ); + +dev_info (dev,"Detected chip type %s rev.%c\n" , + atc260x->type_name,'A' + atc260x->ic_ver); + + ret =devm_regmap_add_irq_chip (dev, 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 child devices: %d\n" , ret); +regmap_del_irq_chip (atc260x->irq, atc260x->irq_data); + } + +return ret; +} +EXPORT_SYMBOL_GPL (atc260x_device_probe);
[...]
drivers/mfd/atc260x-i2c.c line 58
Quoted 7 lines
drivers/mfd/atc260x-i2c.c new file +7
-0+static struct i2c_driver atc260x_i2c_driver = { + .driver = { + .name ="atc260x" , + .of_match_table =of_match_ptr (atc260x_i2c_of_match), + }, + .probe = atc260x_i2c_probe, +};
Nit: These spacings/line-ups just look odd.
Please stick to one ' ' after the '='.
Quoted 1 line
+module_i2c_driver(atc260x_i2c_driver);
[...]
Quoted 9 lines
include/linux/mfd/atc260x/core.h new file +9
-0+struct atc260x { +struct device *dev; + +struct regmap *regmap; +const struct regmap_irq_chip *regmap_irq_chip; +struct regmap_irq_chip_data *irq_data; + +struct mutex *regmap_mutex;/* mutex for custom regmap locking */ +
include/linux/mfd/atc260x/core.h line 50
Quoted 10 lines
include/linux/mfd/atc260x/core.h new file +10
-0+const struct mfd_cell *cells; +int nr_cells; +int irq; + +enum atc260x_type ic_type; +enum atc260x_ver ic_ver; +const char *type_name; +unsigned int rev_reg; + +int (*dev_init)(struct atc260x *atc260x);
Ah, I didn't see this before.
Call-backs of this nature are the devil. Please populate a struct with the differentiating register addresses/values instead and always call a generic deivce_init().
Quoted 8 lines
include/linux/mfd/atc260x/core.h new file +8
-0+}; + +struct regmap_config ; + +int atc260x_match_device (struct atc260x *atc260x,struct regmap_config *regmap_cfg); +int atc260x_device_probe (struct atc260x *atc260x); + +#endif /* __LINUX_MFD_ATC260X_CORE_H */
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Cristian Ciocaltea
maintainerRe: [PATCH v5 3/7] mfd: Add MFD driver for ATC260x PMICs
Quoted 6 lines · Lee Jones
Quoted 4 lines · Cristian Ciocaltea
Add initial support for the Actions Semi ATC260x PMICs which integrates Audio Codec, Power management, Clock generation and GPIO controller blocks.
[...]
Quoted 13 lines
drivers/mfd/atc260x-core.c line 261
Quoted 10 lines
drivers/mfd/atc260x-core.c new file +10
-0+/* Initialize the hardware */ + atc260x->dev_init (atc260x); + + ret =regmap_read (atc260x->regmap, atc260x->rev_reg, &chip_rev); +if (ret) { +dev_err (dev,"Failed to get chip revision\n" ); +return ret; + } + +if (chip_rev >31 ) {Nit: If you have to respin this, please define this magic number.
[...]
Quoted 11 lines
drivers/mfd/atc260x-i2c.c line 58
Quoted 7 lines
drivers/mfd/atc260x-i2c.c new file +7
-0+static struct i2c_driver atc260x_i2c_driver = { + .driver = { + .name ="atc260x" , + .of_match_table =of_match_ptr (atc260x_i2c_of_match), + }, + .probe = atc260x_i2c_probe, +};Nit: These spacings/line-ups just look odd.
Please stick to one ' ' after the '='.
[...]
Quoted 10 lines
include/linux/mfd/atc260x/core.h line 50
Quoted 4 lines
include/linux/mfd/atc260x/core.h new file +4
-0+const char *type_name; +unsigned int rev_reg; + +int (*dev_init)(struct atc260x *atc260x);Ah, I didn't see this before.
Call-backs of this nature are the devil. Please populate a struct with the differentiating register addresses/values instead and always call a generic
deivce_init().
I have implemented this, including the other 2 suggestions above, in the already submitted revision v6.
Thanks,
Cristi
Quoted 14 lines
Quoted 8 lines
include/linux/mfd/atc260x/core.h new file +8
-0+}; + +struct regmap_config ; + +int atc260x_match_device (struct atc260x *atc260x,struct regmap_config *regmap_cfg); +int atc260x_device_probe (struct atc260x *atc260x); + +#endif /* __LINUX_MFD_ATC260X_CORE_H */ Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Cristian Ciocaltea
maintainerPATCH v5 4/7 regulator: Add regulator driver for ATC260x PMICs
In reply to Cristian CiocalteaAdd 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 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
@@ -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
@@ -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
Cristian Ciocaltea
maintainerPATCH v5 5/7 power: reset: Add poweroff driver for ATC260x PMICs
In reply to Cristian CiocalteaThis 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 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
@@ -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
@@ -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
Re: [PATCH v5 5/7] power: reset: Add poweroff driver for ATC260x PMICs
Hi,
Quoted 6 lines · 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.
Signed-off-by Cristian Ciocaltea <[email protected]>---
Thanks, queued to power-supply's for-next branch.
-- Sebastian
Quoted 321 lines
Changes in v5:
- Drop unneeded '#include <linux/of.h>'Changes in v4:
- NoneChanges in v3:
- Removed the unnecessary driver compatiblesdrivers/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.cdrivers/power/reset/Kconfig +7
-1@@ -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@@ -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.odrivers/power/reset/atc260x-poweroff.c new file +262
-0@@ -0,0 +1,262 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Poweroff & reset driver for Actions Semi ATC260x PMICs +* +* Copyright (c) 2020 Cristian Ciocaltea <[email protected]> +*/ + +#include <linux/delay.h> +#include <linux/mfd/atc260x/core.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/power_supply.h> +#include <linux/reboot.h> +#include <linux/regmap.h> + +struct atc260x_pwrc { +struct device *dev; +struct regmap *regmap; +struct notifier_block restart_nb; +int (*do_poweroff)(const struct atc260x_pwrc *pwrc,bool restart); +}; + +/* Global variable needed only for pm_power_off */ +static struct atc260x_pwrc *atc260x_pwrc_data; + +static int atc2603c_do_poweroff (const struct atc260x_pwrc *pwrc,bool restart) +{ +int ret, deep_sleep =0 ; +uint reg_mask, reg_val; + +/* S4-Deep Sleep Mode is NOT available for WALL/USB power */ +if (!restart && !power_supply_is_system_supplied ()) { + deep_sleep =1 ; +dev_info (pwrc->dev,"Enabling S4-Deep Sleep Mode" ); + } + +/* Update wakeup sources */ + reg_val =ATC2603C_PMU_SYS_CTL0_ONOFF_LONG_WK_EN | + (restart ?ATC2603C_PMU_SYS_CTL0_RESET_WK_EN + :ATC2603C_PMU_SYS_CTL0_ONOFF_SHORT_WK_EN ); + + ret =regmap_update_bits (pwrc->regmap,ATC2603C_PMU_SYS_CTL0 , +ATC2603C_PMU_SYS_CTL0_WK_ALL , reg_val); +if (ret) +dev_warn (pwrc->dev,"failed to write SYS_CTL0: %d\n" , ret); + +/* Update power mode */ + reg_mask =ATC2603C_PMU_SYS_CTL3_EN_S2 |ATC2603C_PMU_SYS_CTL3_EN_S3 ; + + ret =regmap_update_bits (pwrc->regmap,ATC2603C_PMU_SYS_CTL3 , reg_mask, + deep_sleep ?0 :ATC2603C_PMU_SYS_CTL3_EN_S3 ); +if (ret) { +dev_err (pwrc->dev,"failed to write SYS_CTL3: %d\n" , ret); +return ret; + } + +/* Trigger poweroff / restart sequence */ + reg_mask = restart ?ATC2603C_PMU_SYS_CTL0_RESTART_EN + :ATC2603C_PMU_SYS_CTL1_EN_S1 ; + reg_val = restart ?ATC2603C_PMU_SYS_CTL0_RESTART_EN :0 ; + + ret =regmap_update_bits (pwrc->regmap, + restart ?ATC2603C_PMU_SYS_CTL0 :ATC2603C_PMU_SYS_CTL1 , + reg_mask, reg_val); +if (ret) { +dev_err (pwrc->dev,"failed to write SYS_CTL%d: %d\n" , + restart ?0 :1 , ret); +return ret; + } + +/* Wait for trigger completion */ +mdelay (200 ); + +return 0 ; +} + +static int atc2609a_do_poweroff (const struct atc260x_pwrc *pwrc,bool restart) +{ +int ret, deep_sleep =0 ; +uint reg_mask, reg_val; + +/* S4-Deep Sleep Mode is NOT available for WALL/USB power */ +if (!restart && !power_supply_is_system_supplied ()) { + deep_sleep =1 ; +dev_info (pwrc->dev,"Enabling S4-Deep Sleep Mode" ); + } + +/* Update wakeup sources */ + reg_val =ATC2609A_PMU_SYS_CTL0_ONOFF_LONG_WK_EN | + (restart ?ATC2609A_PMU_SYS_CTL0_RESET_WK_EN + :ATC2609A_PMU_SYS_CTL0_ONOFF_SHORT_WK_EN ); + + ret =regmap_update_bits (pwrc->regmap,ATC2609A_PMU_SYS_CTL0 , +ATC2609A_PMU_SYS_CTL0_WK_ALL , reg_val); +if (ret) +dev_warn (pwrc->dev,"failed to write SYS_CTL0: %d\n" , ret); + +/* Update power mode */ + reg_mask =ATC2609A_PMU_SYS_CTL3_EN_S2 |ATC2609A_PMU_SYS_CTL3_EN_S3 ; + + ret =regmap_update_bits (pwrc->regmap,ATC2609A_PMU_SYS_CTL3 , reg_mask, + deep_sleep ?0 :ATC2609A_PMU_SYS_CTL3_EN_S3 ); +if (ret) { +dev_err (pwrc->dev,"failed to write SYS_CTL3: %d\n" , ret); +return ret; + } + +/* Trigger poweroff / restart sequence */ + reg_mask = restart ?ATC2609A_PMU_SYS_CTL0_RESTART_EN + :ATC2609A_PMU_SYS_CTL1_EN_S1 ; + reg_val = restart ?ATC2609A_PMU_SYS_CTL0_RESTART_EN :0 ; + + ret =regmap_update_bits (pwrc->regmap, + restart ?ATC2609A_PMU_SYS_CTL0 :ATC2609A_PMU_SYS_CTL1 , + reg_mask, reg_val); +if (ret) { +dev_err (pwrc->dev,"failed to write SYS_CTL%d: %d\n" , + restart ?0 :1 , ret); +return ret; + } + +/* Wait for trigger completion */ +mdelay (200 ); + +return 0 ; +} + +static int atc2603c_init (const struct atc260x_pwrc *pwrc) +{ +int ret; + +/* +* Delay transition from S2/S3 to S1 in order to avoid +* DDR init failure in Bootloader. +*/ + ret =regmap_update_bits (pwrc->regmap,ATC2603C_PMU_SYS_CTL3 , +ATC2603C_PMU_SYS_CTL3_S2S3TOS1_TIMER_EN , +ATC2603C_PMU_SYS_CTL3_S2S3TOS1_TIMER_EN ); +if (ret) +dev_warn (pwrc->dev,"failed to write SYS_CTL3: %d\n" , ret); + +/* Set wakeup sources */ + ret =regmap_update_bits (pwrc->regmap,ATC2603C_PMU_SYS_CTL0 , +ATC2603C_PMU_SYS_CTL0_WK_ALL , +ATC2603C_PMU_SYS_CTL0_HDSW_WK_EN | +ATC2603C_PMU_SYS_CTL0_ONOFF_LONG_WK_EN ); +if (ret) +dev_warn (pwrc->dev,"failed to write SYS_CTL0: %d\n" , ret); + +return ret; +} + +static int atc2609a_init (const struct atc260x_pwrc *pwrc) +{ +int ret; + +/* Set wakeup sources */ + ret =regmap_update_bits (pwrc->regmap,ATC2609A_PMU_SYS_CTL0 , +ATC2609A_PMU_SYS_CTL0_WK_ALL , +ATC2609A_PMU_SYS_CTL0_HDSW_WK_EN | +ATC2609A_PMU_SYS_CTL0_ONOFF_LONG_WK_EN ); +if (ret) +dev_warn (pwrc->dev,"failed to write SYS_CTL0: %d\n" , ret); + +return ret; +} + +static void atc260x_pwrc_pm_handler (void ) +{ + atc260x_pwrc_data->do_poweroff (atc260x_pwrc_data, false); + +WARN_ONCE (1 ,"Unable to power off system\n" ); +} + +static int atc260x_pwrc_restart_handler (struct notifier_block *nb, +unsigned long mode,void *cmd) +{ + struct atc260x_pwrc *pwrc = container_of(nb, struct atc260x_pwrc, + restart_nb); + pwrc->do_poweroff (pwrc, true); + +return NOTIFY_DONE ; +} + +static int atc260x_pwrc_probe (struct platform_device *pdev) +{ +struct atc260x *atc260x =dev_get_drvdata (pdev->dev.parent); +struct atc260x_pwrc *priv; +int ret; + + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + priv->dev = &pdev->dev; + priv->regmap = atc260x->regmap; + priv->restart_nb.notifier_call = atc260x_pwrc_restart_handler; + priv->restart_nb.priority =192 ; + +switch (atc260x->ic_type) { +case ATC2603C : + priv->do_poweroff = atc2603c_do_poweroff; + ret =atc2603c_init (priv); +break ; +case ATC2609A : + priv->do_poweroff = atc2609a_do_poweroff; + ret =atc2609a_init (priv); +break ; +default : +dev_err (priv->dev, +"Poweroff not supported for ATC260x PMIC type: %u\n" , + atc260x->ic_type); +return -EINVAL ; + } + +if (ret) +return ret; + +platform_set_drvdata (pdev, priv); + +if (!pm_power_off) { + atc260x_pwrc_data = priv; + pm_power_off = atc260x_pwrc_pm_handler; + }else { +dev_warn (priv->dev,"Poweroff callback already assigned\n" ); + } + + ret =register_restart_handler (&priv->restart_nb); +if (ret) +dev_err (priv->dev,"failed to register restart handler: %d\n" , + ret); + +return ret; +} + +static int atc260x_pwrc_remove (struct platform_device *pdev) +{ +struct atc260x_pwrc *priv =platform_get_drvdata (pdev); + +if (atc260x_pwrc_data == priv) { + pm_power_off =NULL ; + atc260x_pwrc_data =NULL ; + } + +unregister_restart_handler (&priv->restart_nb); + +return 0 ; +} + +static struct platform_driver atc260x_pwrc_driver = { + .probe = atc260x_pwrc_probe, + .remove = atc260x_pwrc_remove, + .driver = { + .name ="atc260x-pwrc" , + }, +}; + +module_platform_driver (atc260x_pwrc_driver); + +MODULE_DESCRIPTION ("Poweroff & reset driver for ATC260x PMICs" ); +MODULE_AUTHOR ("Cristian Ciocaltea <[email protected]>" ); +MODULE_LICENSE ("GPL" );Signature · 1 line
2.30.0
Cristian Ciocaltea
maintainerPATCH v5 6/7 input: atc260x: Add onkey driver for ATC260x PMICs
In reply to Cristian CiocalteaThe 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 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
@@ -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
@@ -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
Cristian Ciocaltea
maintainerPATCH v5 7/7 MAINTAINERS: Add entry for ATC260x PMIC
In reply to Cristian CiocalteaFrom: 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 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
@@ -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