pincntrl: add support for AMS AS3722 pin control driver
Subsystems (3)
PATCH v4 2/3 pincntrl: add support for AMS AS3722 pin control driver
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.
---
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.
Changes from V3:
- Added gpio ranges and pinctrl_gpio calls.
- Used pinctrl_gpio_* calls on gpio chips callback.
- Remove dummy function which just return not supported.
- Nit cleanups.
Notes: As there is only change in pincontrol driver, I am respinning this patch only. Other patches are same as V3 and so not sending it again.
.../devicetree/bindings/pinctrl/pinctrl-as3722.txt | 59 ++ drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-as3722.c | 630 ++++++++++++++++++++ 4 files changed, 701 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 +630 -0
630 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Quoted 18 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]>---
Changes from V1:
- Nit cleanups in driver and usemodule_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.
Quoted 5 lines
Changes from V3:
- Added gpio ranges andpinctrl_gpiocalls.
- Used pinctrl_gpio_* calls on gpio chips callback.
- Remove dummy function which just return not supported.
- Nit cleanups.
This is getting a lot better quickly.
I'd like someone from [email protected] to say something about the DT bindings, can you convince one of
the DT custodians to ACK this?
Remaining issues though:
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt line 19
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt new file +4
-0+This binding uses the following generic properties as defined in +pinctrl-bindings.txt: + +Required: pins
You're not explaining what this property does.
Normally the set of pins are defined by the driver, not by the device tree, since it's a property of the hardware, i.e. the driver defines what hardware we have, and the DT defines only how to set it up to do what we want to do.
Quoted 17 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt new file +17
-0+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 {
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt line 57
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt new file +10
-0+ pins = "gpio1", "gpio2", "gpio4", "gpio7"; + function = "gpio"; + bias-pull-up; + }; + + gpio5 { + pins = "gpio5"; + function = "clk32k_out"; + }; + };
As you see the name "gpio0" thru "gpio5" is quite confusing here, as it is referring to pins, not GPIO lines (which is something else in Linux).
I guess you know for sure whatever it is, and if the hardware manual names the pins like this then there is not much we can do. On most chips the actual pins have better names, like chessboard coordinates, "D1" etc on BGAs or other good names.
Can you just inspect your HW docs and verify that your pins really have these confusing names?
So it's this:
Quoted 9 lines
drivers/pinctrl/pinctrl-as3722.c new file +9
-0+#define AS3722_PIN_GPIO0 0 +#define AS3722_PIN_GPIO1 1 +#define AS3722_PIN_GPIO2 2 +#define AS3722_PIN_GPIO3 3 +#define AS3722_PIN_GPIO4 4 +#define AS3722_PIN_GPIO5 5 +#define AS3722_PIN_GPIO6 6 +#define AS3722_PIN_GPIO7 7 +#define AS3722_PIN_NUM (AS3722_PIN_GPIO7 + 1)
(...)
Quoted 11 lines
drivers/pinctrl/pinctrl-as3722.c new file +11
-0+static const struct pinctrl_pin_desc as3722_pins_desc[] = { +PINCTRL_PIN (AS3722_PIN_GPIO0 ,"gpio0" ), +PINCTRL_PIN (AS3722_PIN_GPIO1 ,"gpio1" ), +PINCTRL_PIN (AS3722_PIN_GPIO2 ,"gpio2" ), +PINCTRL_PIN (AS3722_PIN_GPIO3 ,"gpio3" ), +PINCTRL_PIN (AS3722_PIN_GPIO4 ,"gpio4" ), +PINCTRL_PIN (AS3722_PIN_GPIO5 ,"gpio5" ), +PINCTRL_PIN (AS3722_PIN_GPIO6 ,"gpio6" ), +PINCTRL_PIN (AS3722_PIN_GPIO7 ,"gpio7" ), +}; +
drivers/pinctrl/pinctrl-as3722.c line 113
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+static const char *const gpio_groups[] = { +"gpio0" , +"gpio1" , +"gpio2" , +"gpio3" , +"gpio4" , +"gpio5" , +"gpio6" , +"gpio7" , +};
That is really, really confusing.
And this one-pin-per-group:
drivers/pinctrl/pinctrl-as3722.c line 173
Quoted 10 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+static const struct as3722_pingroup as3722_pingroups[] = { +AS3722_PINGROUP (gpio0,GPIO0 ), +AS3722_PINGROUP (gpio1,GPIO1 ), +AS3722_PINGROUP (gpio2,GPIO2 ), +AS3722_PINGROUP (gpio3,GPIO3 ), +AS3722_PINGROUP (gpio4,GPIO4 ), +AS3722_PINGROUP (gpio5,GPIO5 ), +AS3722_PINGROUP (gpio6,GPIO6 ), +AS3722_PINGROUP (gpio7,GPIO7 ), +};
Also makes my head twist.
But as I said, if they are named like this, then there is not much we can do. But maybe we can put in something clarifying....
drivers/pinctrl/pinctrl-as3722.c line 505
Quoted 6 lines
drivers/pinctrl/pinctrl-as3722.c new file +6
-0+static int as3722_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +as3722_gpio_set (chip, offset, value); +return pinctrl_gpio_direction_output (chip->base + offset); +}
Son't you want to set the direction first, then output the value? This order is OK with some hardware, I'm just asking...
Overall this is looking very good.
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Linus Walleij
Quoted 2 lines · Laxman Dewangan
function which just return not supported.
- Nit cleanups.This is getting a lot better quickly.
I'd like someone from [email protected] to say something about the DT bindings, can you convince one of the DT custodians to ACK this?
I will request Stephen to review this.
Quoted 8 lines
Remaining issues though:
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt line 19
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt new file +4
-0+This binding uses the following generic properties as defined in +pinctrl-bindings.txt: + +Required: pinsYou're not explaining what this property does.
Quoted 4 lines
Normally the set of pins are defined by the driver, not by the device tree, since it's a property of the hardware, i.e. the driver defines what hardware we have, and the DT defines only how to set it up to do what we want to do.
pins are defined in the pinctrl-bindings and hence not duplicated here.
But some where we need to document that what are valid pin names which driver entertain. I have referred the other dt document and I derived this from there.
Quoted 38 lines
Quoted 18 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt new file +17
-0+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 {Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt line 57
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt new file +10
-0+ pins = "gpio1", "gpio2", "gpio4", "gpio7"; + function = "gpio"; + bias-pull-up; + }; + + gpio5 { + pins = "gpio5"; + function = "clk32k_out"; + }; + };As you see the name "gpio0" thru "gpio5" is quite confusing here, as it is referring to pins, not GPIO lines (which is something else in Linux).
I guess you know for sure whatever it is, and if the hardware manual names the pins like this then there is not much we can do. On most chips the actual pins have better names, like chessboard coordinates, "D1" etc on BGAs or other good names.
Quoted 4 lines
Can you just inspect your HW docs and verify that your pins really have these confusing names?
So it's this:
The pin diagram in datasheet of the device names these pins as GPIO0..GPIO7. So hardly we can do here.
For GPIO3 on BGA124, it is E4 but CSP108, it is C9 so the other names defined on package. But both places, it is said as GPIO3.
Quoted 13 lines
drivers/pinctrl/pinctrl-as3722.c new file +10
-0+static const char *const gpio_groups[] = { +"gpio0" , +"gpio1" , +"gpio2" , +"gpio3" , +"gpio4" , +"gpio5" , +"gpio6" , +"gpio7" , +};That is really, really confusing.
Quoted 1 line
And this one-pin-per-group:
Yaah, typical device, all io function available on all GPIO pins.
Quoted 8 lines
drivers/pinctrl/pinctrl-as3722.c line 505
Quoted 6 lines
drivers/pinctrl/pinctrl-as3722.c new file +6
-0+static int as3722_gpio_direction_output (struct gpio_chip *chip, +unsigned offset,int value) +{ +as3722_gpio_set (chip, offset, value); +return pinctrl_gpio_direction_output (chip->base + offset); +}Son't you want to set the direction first, then output the value? This order is OK with some hardware, I'm just asking...
Avoid glitches, we need to set output value first and the output mode.
Quoted 8 lines · Laxman Dewangan
Quoted 7 lines · Linus Walleij
Quoted 2 lines · Laxman Dewangan
function which just return not supported.
- Nit cleanups.
Quoted 7 lines
Quoted 5 lines
This is getting a lot better quickly.
I'd like someone from [email protected] to say something about the DT bindings, can you convince one of the DT custodians to ACK this?
I will request Stephen to review this.
OK I buy the rest of your explantions and I'm ready to merge this if the device tree people give green light.
Yours,
Linus Walleij
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt
Quoted 11 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.
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt +1
-0+AMS AS3722 Pincontrol
This binding document doesn't appear to define any compatible value. I think there should be one binding document per compatible value, rather than splitting up the documentation of a particular binding into lots of different files. As such, shouldn't this documentation all be part of Documentation/devicetree/bindings/regulator/as3722-regulator.txt?
Quoted 1 line
+DT node contains the different subnode for pin control to represent
Which "DT node"? This paragraph doesn't make much sense...
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt line 14
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt +4
-0+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.
I think that paragraph is meant to say the following, as part of as3722-regulator.txt:
==========
Optional sub-nodes:
- pinmux: Represents the pinmux configuration of the AS3722 GPIO pins. This node contains pin configuration nodes, as defined by pinctrl-bindings.txt
==========
(and then go on to describe the required/optional properties within the pin configuration nodes)
Quoted 1 line
+Valid values for pin names are:
I would say "pin property" rather than "pin names" here, to make it obvious where these values are used.
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt line 26
Quoted 3 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-as3722.txt +3
-0+ gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7 + +Valid value of function names are:
Similarly, "function property" here. (and values for not value of).
Other than that, this binding looks reasonable.