Add AMS AS3722 mfd, pincontrol, regulator and RTC driver.
Subsystems (5)
v3 cover Add AMS AS3722 mfd, pincontrol, regulator and RTC driver.
This series add the driver support for AMS AS3722 PMIC. The driver includes MFD, pincontrol and GPIO, regulator and RTC.
Changes from V1:
- Remove compatible string from DT for subnode.
- Add macro in regmap.h for definign range.
- Nit cleanups in driver and use module_i2c_driver/module_platform_driver.
- Use linear_range and added regulator_map_* on regulators.
- Move OC configuration to regulator_current limit setting.
- Get rid of clk32k out configuration from RTC. Will add clock driver.
Changes from V2:
- Drop the already applied patches on V2 series
regmap: add helper macro to set min/max range of register
regulator: as3722: add regulator driver for AMS AS3722
- Move the GPIo driver to pincontrol driver to expose the pin configuration through pincontrol.
- rewrite the DT binding of the mfd.
Laxman Dewangan (3):
mfd: add support for AMS AS3722 PMIC
pincntrl: add support for AMS AS3722 pin control driver drivers/rtc/rtc-as3722: add RTC driver
Documentation/devicetree/bindings/mfd/as3722.txt | 52 ++ .../devicetree/bindings/pinctrl/pinctrl-as3722.txt | 59 ++ drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 1 + drivers/mfd/as3722.c | 448 ++++++++++++++ drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-as3722.c | 625 ++++++++++++++++++++ drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-as3722.c | 296 +++++++++ include/linux/mfd/as3722.h | 423 +++++++++++++ 12 files changed, 1939 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/as3722.txt create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt create mode 100644 drivers/mfd/as3722.c create mode 100644 drivers/pinctrl/pinctrl-as3722.c create mode 100644 drivers/rtc/rtc-as3722.c create mode 100644 include/linux/mfd/as3722.h
PATCH v3 1/3 mfd: add support for AMS AS3722 PMIC
The AMS AS3722 is a compact system PMU suitable for mobile phones, tablets etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down controller, 11 LDOs, RTC, automatic battery, temperature and over-current monitoring, 8 GPIOs, ADC and watchdog.
Add MFD core driver for the AS3722 to support core functionality.
---
Changes from V1:
- Remove compatible string from DT for subnode.
- Nit cleanups in driver and use module_i2c_driver
Changes from V2:
- Change DT file to reflect the changes in gpio/pincntrl driver. Now there is no extra subnode.
Documentation/devicetree/bindings/mfd/as3722.txt | 52 +++ drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 1 + drivers/mfd/as3722.c | 448 ++++++++++++++++++++++ include/linux/mfd/as3722.h | 423 ++++++++++++++++++++ 5 files changed, 936 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/as3722.txt create mode 100644 drivers/mfd/as3722.c create mode 100644 include/linux/mfd/as3722.h
Documentation/devicetree/bindings/mfd/as3722.txt new file +52 -0
@@ -0,0 +1,52 @@ +* AMS AS3722 Power management IC. + +Required properties: +------------------- +- compatible : Must be "ams,as3722". +- reg: I2C device address. +- interrupt-controller : AS3722 has its own internal IRQs +- #interrupt-cells : should be set to 2 for IRQ number and flags + The first cell is the IRQ number. + The second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupts.txt, using + the #defines found in dt-bindings/irq. +- interrupt-parent : The parent interrupt controller. + +Optional properties: +------------------- +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells: Number of GPIO cells. Refer + Documentation/devicetree/bindings/gpio/gpio.txt +- pinctrl-names: It is define in the + Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt + +Example: +-------- +ams3722 { + compatible = "ams,as3722"; + reg = <0x48> + + interrupt-parent = <&intc>; + interrupt-controller; + #interrupt-cells = <2>; + + gpio-controller; + #gpio-cells = <2>; + + pinctrl-names = "default"; + pinctrl-0 = <&as3722_default>; + + as3722_default: pinmux { + /* + * Default pinmux setting. + * Refer document bindings/pinctrl/pinctrl-as3722.txt + */ + } + + regulators { + /* + * Regulator related properties + * Refer document bindings/regulator/as3722-regulator.txt + */ + }; +};
drivers/mfd/Kconfig +12 -0
@@ -27,6 +27,18 @@ config MFD_AS3711 help Support for the AS3711 PMIC from AMS +config MFD_AS3722 + bool "AMS AS3722 Power Management IC" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C && OF + help + The AMS AS3722 is a compact system PMU suitable for mobile phones, + tablet etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down + controller, 11 LDOs, RTC, automatic battery, temperature and + over current monitoring, GPIOs, ADC, watchdog. + config PMIC_ADP5520 bool "Analog Devices ADP5520/01 MFD PMIC Core Support" depends on I2C=y
drivers/mfd/Makefile +1 -0
@@ -162,3 +162,4 @@ obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o vexpress-sysreg.o obj-$(CONFIG_MFD_RETU) += retu-mfd.o obj-$(CONFIG_MFD_AS3711) += as3711.o +obj-$(CONFIG_MFD_AS3722) += as3722.o
drivers/mfd/as3722.c new file +448 -0
448 lines not on this page · raw message
include/linux/mfd/as3722.h new file +423 -0
423 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Re: [PATCH V3 1/3] mfd: add support for AMS AS3722 PMIC
Hi Lee,
Quoted 6 lines · Laxman Dewangan
The AMS AS3722 is a compact system PMU suitable for mobile phones, tablets etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down controller, 11 LDOs, RTC, automatic battery, temperature and over-current monitoring, 8 GPIOs, ADC and watchdog.
Add MFD core driver for the AS3722 to support core functionality.
Based on discussion on V1/V2, I have only one sub node i.e. for regulator only. Mark B already applied the regualtor patch. Other sub nodes are removed. For pinmux, default is as per pinmux binding and it is not a new sub node.
Can you please review again so that if there is any thing missing, I like to complete this?
Thanks,
Laxman
Re: [PATCH V3 1/3] mfd: add support for AMS AS3722 PMIC
In reply to Laxman DewanganQuoted 1 line · Laxman Dewangan
The AMS AS3722 is a compact system PMU suitable for mobile phones,
s/AMS/ams
Quoted 13 lines
tablets etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down controller, 11 LDOs, RTC, automatic battery, temperature and over-current monitoring, 8 GPIOs, ADC and watchdog.
Add MFD core driver for the AS3722 to support core functionality.
Signed-off-by Laxman Dewangan <[email protected]>Signed-off-by Florian Lobmaier <[email protected]>---
Changes from V1:
- Remove compatible string from DT for subnode.
- Nit cleanups in driver and usemodule_i2c_driver
Quoted 5 lines
Changes from V2:
- Change DT file to reflect the changes in gpio/pincntrl driver. Now there is no extra subnode.Documentation/devicetree/bindings/mfd/as3722.txt | 52 +++
You need an Ack from the Device Tree guys for this.
I see a few nits in the formatting of the document too.
Quoted 15 lines
drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 1 + drivers/mfd/as3722.c | 448 ++++++++++++++++++++++ include/linux/mfd/as3722.h | 423 ++++++++++++++++++++ 5 files changed, 936 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/as3722.txt create mode 100644 drivers/mfd/as3722.c create mode 100644 include/linux/mfd/as3722.hDocumentation/devicetree/bindings/mfd/as3722.txt new file +0
-0
Documentation/devicetree/bindings/mfd/as3722.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/mfd/as3722.txt new file +1
-0@@ -0,0 +1,52 @@ +* AMS AS3722 Power management IC.
s/AMS/ams
Documentation/devicetree/bindings/mfd/as3722.txt line 5
Quoted 3 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +3
-0+Required properties: +------------------- +- compatible : Must be "ams,as3722".
^--- Space here
Documentation/devicetree/bindings/mfd/as3722.txt line 6
Quoted 1 line
Documentation/devicetree/bindings/mfd/as3722.txt new file +1
-0+- reg: I2C device address.
^--- But no Space here and an extra one after ':'.
Documentation/devicetree/bindings/mfd/as3722.txt line 8
Quoted 2 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +2
-0+- interrupt-controller : AS3722 has its own internal IRQs +- #interrupt-cells : should be set to 2 for IRQ number and flags
^--- Uppercase Fullstop ---^
Documentation/devicetree/bindings/mfd/as3722.txt line 12
Quoted 4 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +4
-0+ The first cell is the IRQ number. + The second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupts.txt, using + the #defines found in dt-bindings/irq.
All DTS files should be using the #defines, no need to specify that.
Documentation/devicetree/bindings/mfd/as3722.txt line 20
Quoted 8 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +8
-0+- interrupt-parent : The parent interrupt controller. + +Optional properties: +------------------- +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells: Number of GPIO cells. Refer + Documentation/devicetree/bindings/gpio/gpio.txt +- pinctrl-names: It is define in the
s/define/defined
Documentation/devicetree/bindings/mfd/as3722.txt line 27
Quoted 7 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +7
-0+ Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt + +Example: +-------- +ams3722 { + compatible = "ams,as3722"; + reg = <0x48>
Missing ';'.
Quoted 5 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +5
-0+ + interrupt-parent = <&intc>; + interrupt-controller; + #interrupt-cells = <2>; +
Documentation/devicetree/bindings/mfd/as3722.txt line 42
Quoted 10 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +10
-0+ gpio-controller; + #gpio-cells = <2>; + + pinctrl-names = "default"; + pinctrl-0 = <&as3722_default>; + + as3722_default: pinmux { + /* + * Default pinmux setting. + * Refer document bindings/pinctrl/pinctrl-as3722.txt
s/Refer/Refer to
Quoted 15 lines
Documentation/devicetree/bindings/mfd/as3722.txt new file +10
-0+ */ + } + + regulators { + /* + * Regulator related properties + * Refer document bindings/regulator/as3722-regulator.txt + */ + }; +};drivers/mfd/Kconfig +0
-0
drivers/mfd/Kconfig config MFD_AS3711 · line 28
Quoted 2 lines
drivers/mfd/Kconfig +0
-0@@ -27,6 +27,18 @@ config MFD_AS3711 help Support for the AS3711 PMIC from AMS
s/ams/AMS
drivers/mfd/Kconfig config MFD_AS3711 · line 31
Quoted 2 lines
drivers/mfd/Kconfig +2
-0+config MFD_AS3722 + bool "AMS AS3722 Power Management IC"
s/ams/AMS
etc etc ...
drivers/mfd/Kconfig config MFD_AS3711 · line 38
Quoted 7 lines
drivers/mfd/Kconfig +7
-0+ select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C && OF + help + The AMS AS3722 is a compact system PMU suitable for mobile phones, + tablet etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down
s/tablet/tablets
drivers/mfd/Kconfig config MFD_AS3711 · line 39
Quoted 1 line
drivers/mfd/Kconfig +1
-0+ controller, 11 LDOs, RTC, automatic battery, temperature and
s/controller/controllers
drivers/mfd/Kconfig config MFD_AS3711 · line 40
Quoted 1 line
drivers/mfd/Kconfig +1
-0+ over current monitoring, GPIOs, ADC, watchdog.
... and a watchdog.
Quoted 19 lines
drivers/mfd/Kconfig +1
-0+ config PMIC_ADP5520 bool "Analog Devices ADP5520/01 MFD PMIC Core Support" depends on I2C=ydrivers/mfd/Makefile +1
-0@@ -162,3 +162,4 @@ obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o vexpress-sysreg.o obj-$(CONFIG_MFD_RETU) += retu-mfd.o obj-$(CONFIG_MFD_AS3711) += as3711.o +obj-$(CONFIG_MFD_AS3722) += as3722.odrivers/mfd/as3722.c new file +0
-0
drivers/mfd/as3722.c line 4
Quoted 4 lines
drivers/mfd/as3722.c new file +4
-0@@ -0,0 +1,448 @@ +/* +* Core driver for AMS AS3722 PMICs +* +* Copyright (C) 2013 ams AG
s/ams/AMS
<snip>
drivers/mfd/as3722.c line 334
Quoted 8 lines
drivers/mfd/as3722.c new file +8
-0+static int as3722_i2c_of_probe (struct i2c_client *i2c, +struct as3722 *as3722) +{ +struct device_node *np = i2c->dev.of_node; +struct irq_data *irq_data; + +if (!np) { +dev_err (&i2c->dev,"Device is not having of_node\n" );
En Anglais?
"Device Tree not found"
drivers/mfd/as3722.c line 347
Quoted 13 lines
drivers/mfd/as3722.c new file +13
-0+return -EINVAL ; + } + + irq_data =irq_get_irq_data (i2c->irq); +if (!irq_data) { +dev_err (&i2c->dev,"Invalid IRQ: %d\n" , i2c->irq); +return -EINVAL ; + } + + as3722->en_intern_int_pullup =of_property_read_bool (np, +"ams,enable-internal-int-pullup" ); + as3722->en_intern_i2c_pullup =of_property_read_bool (np, +"ams,enable-internal-i2c-pullup" );
Not sure what this means, or if it's been discussed before, but aren't there generic bindings for these?
drivers/mfd/as3722.c line 349
Quoted 2 lines
drivers/mfd/as3722.c new file +2
-0+ as3722->irq_flags =irqd_get_trigger_type (irq_data); +dev_dbg (&i2c->dev,"Irq flag is 0x%08lx\n" , as3722->irq_flags);
"IRQ flags are"
Quoted 41 lines
drivers/mfd/as3722.c new file +41
-0+return 0 ; +} + +static int as3722_i2c_probe (struct i2c_client *i2c, +const struct i2c_device_id *id) +{ +struct as3722 *as3722; +unsigned long irq_flags; +int ret; + + as3722 =devm_kzalloc (&i2c->dev,sizeof (struct as3722 ),GFP_KERNEL ); +if (!as3722) +return -ENOMEM ; + + as3722->dev = &i2c->dev; + as3722->chip_irq = i2c->irq; +i2c_set_clientdata (i2c, as3722); + + ret =as3722_i2c_of_probe (i2c, as3722); +if (ret <0 ) +return ret; + + as3722->regmap =devm_regmap_init_i2c (i2c, &as3722_regmap_config); +if (IS_ERR (as3722->regmap)) { + ret =PTR_ERR (as3722->regmap); +dev_err (&i2c->dev,"regmap_init failed with err: %d\n" , ret); +return ret; + } + + ret =as3722_check_device_id (as3722); +if (ret <0 ) +return ret; + + irq_flags = as3722->irq_flags |IRQF_ONESHOT ; + ret =regmap_add_irq_chip (as3722->regmap, as3722->chip_irq, + irq_flags,-1 , &as3722_irq_chip, + &as3722->irq_data); +if (ret <0 ) { +dev_err (as3722->dev,"regmap_add_irq failed: %d\n" , ret); +return ret; + }
drivers/mfd/as3722.c line 400
Quoted 10 lines
drivers/mfd/as3722.c new file +10
-0+ + ret =as3722_configure_pullups (as3722); +if (ret <0 ) + goto scrub; + + ret =mfd_add_devices (&i2c->dev,-1 , as3722_devs, +ARRAY_SIZE (as3722_devs),NULL ,0 , +regmap_irq_get_domain (as3722->irq_data)); +if (ret) { +dev_err (as3722->dev,"mfd_add_devices() failed: %d\n" , ret);
Not keen on function names in error messages.
"Failed to add MFD devices"
drivers/mfd/as3722.c line 405
Quoted 5 lines
drivers/mfd/as3722.c new file +5
-0+ goto scrub; + } + +dev_dbg (as3722->dev,"AS3722 core driver initialized successfully\n" ); +return 0 ;
'/n' here please.
Quoted 13 lines
drivers/mfd/as3722.c new file +13
-0+scrub: +regmap_del_irq_chip (as3722->chip_irq, as3722->irq_data); +return ret; +} + +static int as3722_i2c_remove (struct i2c_client *i2c) +{ +struct as3722 *as3722 =i2c_get_clientdata (i2c); + +mfd_remove_devices (as3722->dev); +regmap_del_irq_chip (as3722->chip_irq, as3722->irq_data); +return 0 ; +}
drivers/mfd/as3722.c line 428
Quoted 10 lines
drivers/mfd/as3722.c new file +10
-0+ +static const struct of_device_id as3722_of_match[] = { + { .compatible ="ams,as3722" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, as3722_of_match); + +static const struct i2c_device_id as3722_i2c_id[] = { + {"as3722" ,0 }, + {}
Use the same format throughout, pick '{},' or '{}' for both structs. I suggest the former.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH V3 1/3] mfd: add support for AMS AS3722 PMIC
In reply to Laxman DewanganQuoted 8 lines · Laxman Dewangan
The AMS AS3722 is a compact system PMU suitable for mobile phones, tablets etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down controller, 11 LDOs, RTC, automatic battery, temperature and over-current monitoring, 8 GPIOs, ADC and watchdog.
Add MFD core driver for the AS3722 to support core functionality.
Documentation/devicetree/bindings/mfd/as3722.txt line 7
Quoted 6 lines
Documentation/devicetree/bindings/mfd/as3722.txt +5
-0+Required properties: +------------------- +- compatible : Must be "ams,as3722". +- reg: I2C device address. +- interrupt-controller : AS3722 has its own internal IRQs
You should at least specify that the property is a Boolean.
That description a justification for why that property should be present, not a description of the property.
If the device only has *internal* IRQs, you shouldn't need any of the IRQ properties in DT. Rather, I believe you need the IRQ properties because the device has *external* IRQ inputs via the "gpio-in-interrupt" GPIO mux function.
Quoted 1 line
+- interrupt-parent : The parent interrupt controller.
While that property is allowed, it's not required. It's also unusual to mention it in individual bindings, since it's a system-defined property.
Documentation/devicetree/bindings/mfd/as3722.txt line 21
Quoted 5 lines
Documentation/devicetree/bindings/mfd/as3722.txt +4
-0+Optional properties: +------------------- +- pinctrl-names: It is define in the + Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
You need to specify which values must be present in this property.
Why is the property optional?
If you're going to mention pinctrl-names, shouldn't you also mention pinctrl-$n?
Instead, I would simply say:
==========
Optional properties:
A pinctrl state named "default" must be defined, using the bindings in ../pinctrl/pinctrl-binding.txt.
==========
Oh, and don't use an absolute file-name within the Linux kernel source tree, since that path name will change after the binding docs are moved out of the kernel source tree.
As I mentioned when reviewing the pinmux binding, that binding should be described here.
In the example, I see a regulators binding. That should be here too.
PATCH v3 2/3 pincntrl: add support for AMS AS3722 pin control driver
In reply to Laxman DewanganThe AS3722 is a compact system PMU suitable for mobile phones, tablets etc.
Add a driver to support accessing the GPIO, pinmux and pin configuration of 8 GPIO pins found on the AMS AS3722 through pin control driver and gpiolib.
The driver will register itself as the pincontrol driver and gpio driver.
---
Changes from V1:
- Nit cleanups in driver and use module_platform_driver.
Changes from V2:
- Move the gpio driver from gpio folder to pinctnrl driver and register driver as pincontrol driver.
- Provide pin configuration through pincntrl framework.
.../devicetree/bindings/pinctrl/pinctrl-as3722.txt | 59 ++ drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-as3722.c | 625 ++++++++++++++++++++ 4 files changed, 696 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt create mode 100644 drivers/pinctrl/pinctrl-as3722.c
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt new file +59 -0
@@ -0,0 +1,59 @@ +AMS AS3722 Pincontrol + +The GPIO pins of AMS AS3722 device can be set on different options and provides +the configuration for Pull UP/DOWN, high impedance, open drain etc. + +Please refer to pinctrl-bindings.txt in this directory for details of the +common pinctrl bindings used by client devices, including the meaning of the +phrase "pin configuration node". + +DT node contains the different subnode for pin control to represent +different states. Each of these subnodes represents some desired +configuration for a list of pins. This configuration can include the +mux function to select on those pin(s), and various pin configuration +parameters, such as pull-up, open drain. + +This binding uses the following generic properties as defined in +pinctrl-bindings.txt: + +Required: pins +Options: function, bias-disable, bias-pull-up, bias-pull-down, + bias-pin-default, bias-high-impedance, drive-open-drain. + +Valid values for pin names are: + gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7 + +Valid value of function names are: + gpio, interrupt-out, gpio-in-interrupt, vsup-vbat-low-undebounce-out, + vsup-vbat-low-debounce-out, voltage-in-standby, oc-pg-sd0, oc-pg-sd6, + powergood-out, pwm-in, pwm-out, clk32k-out, watchdog-in, soft-reset-in, + +Example: + as3722: as3722 { + .... + gpio-controller; + #gpio-cells = <2>; + + pinctrl-names = "default"; + pinctrl-0 = <&as3722_default>; + + as3722_default: pinmux { + gpio0 { + pins = "gpio0"; + function = "gpio"; + bias-pull-down; + }; + + gpio1_2_4_7 { + pins = "gpio1", "gpio2", "gpio4", "gpio7"; + function = "gpio"; + bias-pull-up; + }; + + gpio5 { + pins = "gpio5"; + function = "clk32k_out"; + }; + }; + ... + };
drivers/pinctrl/Kconfig +11 -0
@@ -59,6 +59,17 @@ config PINCTRL_ADI2 future processors. This option is selected automatically when specific machine and arch are selected to build. +config PINCTRL_AS3722 + bool "Pinctrl and GPIO driver for the AMS AS3722 PMIC" + depends on MFD_AS3722 && GPIOLIB + select PINMUX + select GENERIC_PINCONF + help + AS3722 device supports the configuration of GPIO pins for different + functionality. This driver supports the pinmux, push-pull and + open drain configuration for the GPIO pins of AS3722 devices. It also + supports the GPIO functionality through gpiolib. + config PINCTRL_BF54x def_bool y if BF54x select PINCTRL_ADI2
drivers/pinctrl/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_PINCTRL_AB8540) += pinctrl-ab8540.o obj-$(CONFIG_PINCTRL_AB9540) += pinctrl-ab9540.o obj-$(CONFIG_PINCTRL_AB8505) += pinctrl-ab8505.o obj-$(CONFIG_PINCTRL_ADI2) += pinctrl-adi2.o +obj-$(CONFIG_PINCTRL_AS3722) += pinctrl-as3722.o obj-$(CONFIG_PINCTRL_BF54x) += pinctrl-adi2-bf54x.o obj-$(CONFIG_PINCTRL_BF60x) += pinctrl-adi2-bf60x.o obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
drivers/pinctrl/pinctrl-as3722.c new file +625 -0
625 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Re: [rtc-linux] [PATCH V3 2/3] pincntrl: add support for AMS AS3722 pin control driver
Quoted 10 lines · Laxman Dewangan
The AS3722 is a compact system PMU suitable for mobile phones, tablets etc.
Add a driver to support accessing the GPIO, pinmux and pin configuration of 8 GPIO pins found on the AMS AS3722 through pin control driver and gpiolib.
The driver will register itself as the pincontrol driver and gpio driver.
Signed-off-by Laxman Dewangan <[email protected]>Signed-off-by Florian Lobmaier <[email protected]>
That was quick! :-)
This is starting to look a lot better.
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+static int as3722_pinconf_group_get (struct pinctrl_dev *pctldev, +unsigned group,unsigned long *config) +{ +dev_err (pctldev->dev,"as3722_pinconf_group_get op not supported\n" ); +return -ENOTSUPP ; +} + +static int as3722_pinconf_group_set (struct pinctrl_dev *pctldev, +unsigned group,unsigned long *configs, +unsigned num_configs)
drivers/pinctrl/pinctrl-as3722.c line 373
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+{ +dev_err (pctldev->dev,"as3722_pinconf_group_set op not supported\n" ); +return -ENOTSUPP ; +} + +static const struct pinconf_ops as3722_pinconf_ops = { + .pin_config_get = as3722_pinconf_get, + .pin_config_set = as3722_pinconf_set, + .pin_config_group_get = as3722_pinconf_group_get, + .pin_config_group_set = as3722_pinconf_group_set,
Can't you just leave .pin_config_group_[get|set] undefined as you don't support that?
drivers/pinctrl/pinctrl-as3722.c line 379
Quoted 4 lines
drivers/pinctrl/pinctrl-as3722.c new file +4
-0+static struct pinctrl_desc as3722_pinctrl_desc = { + .pctlops = (struct pinctrl_ops *)&as3722_pinctrl_ops, + .pmxops = (struct pinmux_ops *)&as3722_pinmux_ops, + .confops = (struct pinconf_ops *)&as3722_pinconf_ops,
Why do you need these casts? Should not be necessary.
Quoted 9 lines
drivers/pinctrl/pinctrl-as3722.c new file +9
-0+static int as_pci_direction_input (struct gpio_chip *chip,unsigned offset) +{ +struct as3722_pctrl_info *as_pci =to_as_pci (chip); +struct as3722 *as3722 = as_pci->as3722; +int mode; + + mode =as_pci_get_mode (as_pci->gpio_control[offset].mode_prop, + true); +if (mode <0 ) {
drivers/pinctrl/pinctrl-as3722.c line 496
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+dev_err (as_pci->dev, +"Input direction for GPIO %d not supported\n" , offset); +return mode; + } + +if (as_pci->gpio_control[offset].enable_gpio_invert) + mode |=AS3722_GPIO_INV ; + +return as3722_write (as3722,AS3722_GPIOn_CONTROL_REG (offset), mode); +}
Why is this function not calling pinctrl_gpio_direction_input(chip->base + offset) instea of setting up the mode intself?
The GPIO part of the driver should use the pinctrl part of the driver as back-end.
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+static int as_pci_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +struct as3722_pctrl_info *as_pci =to_as_pci (chip); +struct as3722 *as3722 = as_pci->as3722; +int mode; + + mode =as_pci_get_mode (as_pci->gpio_control[offset].mode_prop, + false); +if (mode <0 ) {
drivers/pinctrl/pinctrl-as3722.c line 517
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+dev_err (as_pci->dev, +"Output direction for GPIO %d not supported\n" , offset); +return mode; + } + +as_pci_set (chip, offset, value); +if (as_pci->gpio_control[offset].enable_gpio_invert) + mode |=AS3722_GPIO_INV ; +return as3722_write (as3722,AS3722_GPIOn_CONTROL_REG (offset), mode); +}
Dito:pinctrl_gpio_direction_output()
Quoted 5 lines
drivers/pinctrl/pinctrl-as3722.c new file +5
-0+static int as_pci_to_irq (struct gpio_chip *chip,unsigned offset) +{ +struct as3722_pctrl_info *as_pci =to_as_pci (chip); + +return as3722_irq_get_virq (as_pci->as3722, offset);
drivers/pinctrl/pinctrl-as3722.c line 533
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+} + +static int as_pci_request (struct gpio_chip *chip,unsigned offset) +{ +struct as3722_pctrl_info *as_pci =to_as_pci (chip); + +if (as_pci->gpio_control[offset].io_function) +return -EBUSY ; +return 0 ; +}
Why is this not calling pinctrl_request_gpio(as_pci->chip.base + offset) instead of just checking if we happen to be GPIO and failing if we are not?
I would implement .free calling pinctrl_free_gpio(gpio) as well.
See e.g. pinctrl-abx500.c
Quoted 42 lines
drivers/pinctrl/pinctrl-as3722.c new file +42
-0+static const struct gpio_chip as_pci_chip = { + .label ="as3722-gpio" , + .owner =THIS_MODULE , + .direction_input = as_pci_direction_input, + .get = as_pci_get, + .direction_output = as_pci_direction_output, + .set = as_pci_set, + .to_irq = as_pci_to_irq, + .request = as_pci_request, + .can_sleep =1 , + .ngpio =AS3722_PIN_NUM , + .base =-1 , +}; + +static int as3722_pinctrl_probe (struct platform_device *pdev) +{ +struct as3722_pctrl_info *as_pci; +int ret; + + as_pci =devm_kzalloc (&pdev->dev,sizeof (*as_pci),GFP_KERNEL ); +if (!as_pci) +return -ENOMEM ; + + as_pci->dev = &pdev->dev; + as_pci->dev->of_node = pdev->dev.parent->of_node; + as_pci->as3722 =dev_get_drvdata (pdev->dev.parent); +platform_set_drvdata (pdev, as_pci); + + as_pci->pins = as3722_pins_desc; + as_pci->num_pins =ARRAY_SIZE (as3722_pins_desc); + as_pci->functions = as3722_pin_function; + as_pci->num_functions =ARRAY_SIZE (as3722_pin_function); + as_pci->pin_groups = as3722_pingroups; + as_pci->num_pin_groups =ARRAY_SIZE (as3722_pingroups); + as3722_pinctrl_desc.name =dev_name (&pdev->dev); + as3722_pinctrl_desc.pins = as3722_pins_desc; + as3722_pinctrl_desc.npins =ARRAY_SIZE (as3722_pins_desc); + as_pci->pctl =pinctrl_register (&as3722_pinctrl_desc, + &pdev->dev, as_pci); +if (!as_pci->pctl) { +dev_err (&pdev->dev,"Couldn't register pinctrl driver\n" ); +return -ENODEV ;
drivers/pinctrl/pinctrl-as3722.c line 586
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+ } + + as_pci->gpio_chip = as_pci_chip; + as_pci->gpio_chip.dev = &pdev->dev; + as_pci->gpio_chip.of_node = pdev->dev.parent->of_node; + ret =gpiochip_add (&as_pci->gpio_chip); +if (ret <0 ) { +dev_err (&pdev->dev,"Could not register gpiochip, %d\n" , ret); + goto scrub; + }
Right here you should register a GPIO range using gpiochip_add_pin_range() so that all calls from the gpio_chip side can happily fall through to the pinctrl driver and set up pins as GPIO.
It's very nice how you contained the driver in one state container.
Yours,
Linus Walleij
Re: [rtc-linux] [PATCH V3 2/3] pincntrl: add support for AMS AS3722 pin control driver
Quoted 20 lines · Linus Walleij
Quoted 5 lines · Laxman Dewangan
drivers/pinctrl/pinctrl-as3722.c new file +5
-0+static int as_pci_to_irq (struct gpio_chip *chip,unsigned offset) +{ +struct as3722_pctrl_info *as_pci =to_as_pci (chip); + +return as3722_irq_get_virq (as_pci->as3722, offset);drivers/pinctrl/pinctrl-as3722.c line 533
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+} + +static int as_pci_request (struct gpio_chip *chip,unsigned offset) +{ +struct as3722_pctrl_info *as_pci =to_as_pci (chip); + +if (as_pci->gpio_control[offset].io_function) +return -EBUSY ; +return 0 ; +}Why is this not calling
pinctrl_request_gpio(as_pci->chip.base + offset)instead of just checking if we happen to be GPIO and failing if we are not?
Quoted 5 lines
I would implement .free calling
pinctrl_free_gpio(gpio)as well.See e.g.
pinctrl-abx500.c
Wow, cool, I saw and it is simple, the gpios callback is wrapper over the pincontrol mux APIs.
I also see opportunity to re-factor the request/free/direction_input/direction_output to move to core so that need not to implement locally, the gpio_chip's callback can use directly.
Will post once this driver is accepted.
PATCH v3 3/3 drivers/rtc/rtc-as3722: add RTC driver
In reply to Laxman DewanganThe AMS AS3722 is a compact system PMU suitable for mobile phones, tablets etc.
Add a driver to support accessing the RTC found on the AMS AS3722 PMIC using RTC framework.
---
Changes from V1:
- Get rid of clk32k out configuration from RTC. Will add clock driver.
Changes from V2:
- None.
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-as3722.c | 296 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 307 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-as3722.c
drivers/rtc/Kconfig +10 -0
@@ -153,6 +153,16 @@ config RTC_DRV_88PM80X This driver can also be built as a module. If so, the module will be called rtc-88pm80x. +config RTC_DRV_AS3722 + tristate "AMS AS3722 RTC driver" + depends on MFD_AS3722 + help + If you say yes here you get support for the RTC of AMS AS3722 PMIC + chips. + + This driver can also be built as a module. If so, the module + will be called rtc-as3722. + config RTC_DRV_DS1307 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025" help
drivers/rtc/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o +obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
drivers/rtc/rtc-as3722.c new file +296 -0
296 lines not on this page · raw message
Signature · 1 line
1.7.1.1