pinctrl: add pincontrol driver for palmas device.
Subsystems (3)
v2 cover pinctrl: add pincontrol driver for palmas device.
Changes from V1:
- Split the additon of common code into pinctrl-utils and pinconf-generic.
- Use the pinconf-generic APIs for mapping node.
- Use pinconf generic properties to define the Palmas pincontrol nodes.
- Nit and cleanups, typo fixes, rephrasing the sentences etc.
- Use pin specific APIs for setting pin configuration rather than group specific.
Laxman Dewangan (3):
pinctrl: add utility functions for add map/configs
pinctrl: pinconf-generic: add generic APIs for mapping pinctrl node
pinctrl: palmas: add pincontrol driver
.../bindings/pinctrl/pinctrl-bindings.txt | 16 + .../devicetree/bindings/pinctrl/pinctrl-palmas.txt | 97 ++ drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 3 +- drivers/pinctrl/pinconf-generic.c | 96 ++ drivers/pinctrl/pinctrl-palmas.c | 1085 ++++++++++++++++++++ drivers/pinctrl/pinctrl-utils.c | 135 +++ drivers/pinctrl/pinctrl-utils.h | 42 + include/linux/mfd/palmas.h | 35 +- include/linux/pinctrl/pinconf-generic.h | 6 + 10 files changed, 1513 insertions(+), 12 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt create mode 100644 drivers/pinctrl/pinctrl-palmas.c create mode 100644 drivers/pinctrl/pinctrl-utils.c create mode 100644 drivers/pinctrl/pinctrl-utils.h
PATCH v2 1/3 pinctrl: add utility functions for add map/configs
Some of pincontrol driver needs the utility function to create map list. The utility function needed for adding mux, configs etc.
In place of duplicating this in each driver, add the common utility function in common file and use from device specific driver. This will reduce the duplicating of code across drivers.
---
Changes from V1:
- Add this files in this patch and add common utility APIs to here.
drivers/pinctrl/Makefile | 2 +- drivers/pinctrl/pinctrl-utils.c | 135 +++++++++++++++++++++++++++++++++++++++ drivers/pinctrl/pinctrl-utils.h | 42 ++++++++++++ 3 files changed, 178 insertions(+), 1 deletions(-) create mode 100644 drivers/pinctrl/pinctrl-utils.c create mode 100644 drivers/pinctrl/pinctrl-utils.h
drivers/pinctrl/Makefile +1 -1
@@ -2,7 +2,7 @@ ccflags-$(CONFIG_DEBUG_PINCTRL) += -DDEBUG -obj-$(CONFIG_PINCTRL) += core.o +obj-$(CONFIG_PINCTRL) += core.o pinctrl-utils.o obj-$(CONFIG_PINMUX) += pinmux.o obj-$(CONFIG_PINCONF) += pinconf.o ifeq ($(CONFIG_OF),y)
drivers/pinctrl/pinctrl-utils.c new file +135 -0
135 lines not on this page · raw message
drivers/pinctrl/pinctrl-utils.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Re: [PATCH V2 1/3] pinctrl: add utility functions for add map/configs
Quoted 6 lines · Laxman Dewangan
Some of pincontrol driver needs the utility function to create map list. The utility function needed for adding mux, configs etc.
In place of duplicating this in each driver, add the common utility function in common file and use from device specific driver. This will reduce the duplicating of code across drivers.
This patch,
Some more documentation mnight be useful though, now these are common utility functions rather than just some internal functions in the Tegra pinctrl driver.
Hopefully there will be a patch to convert at least the Tegra pinctrl driver to use these new functions.
Re: [PATCH V2 1/3] pinctrl: add utility functions for add map/configs
Quoted 9 lines · Stephen Warren
Quoted 6 lines · Laxman Dewangan
Some of pincontrol driver needs the utility function to create map list. The utility function needed for adding mux, configs etc.
In place of duplicating this in each driver, add the common utility function in common file and use from device specific driver. This will reduce the duplicating of code across drivers.
This patch,
Reviewed-by Stephen Warren <[email protected]>
Thanks for review.
Quoted 7 lines
Some more documentation mnight be useful though, now these are common utility functions rather than just some internal functions in the Tegra pinctrl driver.
Hopefully there will be a patch to convert at least the Tegra pinctrl driver to use these new functions.
Yes, I will have the patches for Tegra also to use these common utils functions.
PATCH v2 2/3 pinctrl: pinconf-generic: add generic APIs for mapping pinctrl node
In reply to Laxman DewanganAdd generic APIs to map the DT node and its sub node in pinconf generic driver. These APIs can be used from driver to parse the DT node who uses the pinconf generic APIs for defining their nodes.
---
Changes from V1:
- Add generic property for pins and functions in pinconf-generic.
- Add APIs to map the DT and subnode.
- Move common utils APIs to the pinctrl-utils from this file.
- Update the binding document accordingly.
.../bindings/pinctrl/pinctrl-bindings.txt | 16 ++++ drivers/pinctrl/pinconf-generic.c | 96 ++++++++++++++++++++ include/linux/pinctrl/pinconf-generic.h | 6 ++ 3 files changed, 118 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +16 -0
@@ -174,3 +174,19 @@ All parameters not listed here, do not take an argument. More in-depth documentation on these parameters can be found in <include/linux/pinctrl/pinconfig-generic.h> + +Generic pinconfig option also support the defining of pins and functions. +The properties are: +pinctrl-pins: This property tells the name of pins or list of pins for which + configuration is needed. The valid pin names are device/chip specific and + it can be found from the device/chip specific binding documents. +pinctrl-function: This property tells the configuration of the pins on to the + given function. The valid functions are device/chip specific and it can be + found from the device/chip specific binding documents. + +Example: +gpio0_id:gpio0 { + pinctrl-pins = "gpio0"; + pinctrl-function = "id"; + bias-pull-up; +};
drivers/pinctrl/pinconf-generic.c +96 -0
106 lines not on this page · raw message
include/linux/pinctrl/pinconf-generic.h +6 -0
@@ -137,6 +137,12 @@ static inline unsigned long pinconf_to_config_packed(enum pin_config_param paramreturn PIN_CONF_PACKED (param, argument); } +int pinconf_generic_dt_subnode_to_map (struct pinctrl_dev *pctldev, +struct device_node *np,struct pinctrl_map **map, +unsigned *reserved_maps,unsigned *num_maps); +int pinconf_generic_dt_node_to_map (struct pinctrl_dev *pctldev, +struct device_node *np_config,struct pinctrl_map **map, +unsigned *num_maps);#endif /* CONFIG_GENERIC_PINCONF */ #endif /* __LINUX_PINCTRL_PINCONF_GENERIC_H */
Signature · 1 line
1.7.1.1
Re: [PATCH V2 2/3] pinctrl: pinconf-generic: add generic APIs for mapping pinctrl node
Quoted 10 lines · Laxman Dewangan
Add generic APIs to map the DT node and its sub node in pinconf generic driver. These APIs can be used from driver to parse the DT node who
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +0
-0@@ -174,3 +174,19 @@ All parameters not listed here, do not take an argument. More in-depth documentation on these parameters can be found in
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt All parameters not listed here, do not take an argument. · line 185
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +9
-0<include/linux/pinctrl/pinconfig-generic.h> + +Generic pinconfig option also support the defining of pins and functions. +The properties are: +pinctrl-pins: This property tells the name of pins or list of pins for which + configuration is needed. The valid pin names are device/chip specific and + it can be found from the device/chip specific binding documents. +pinctrl-function: This property tells the configuration of the pins on to the + given function. The valid functions are device/chip specific and it can be + found from the device/chip specific binding documents.
This text feels like it's just been bolted on the end rather than integrated into the existing description of generic pinconfig options. Also, the existing text for generic pinconfig options doesn't feel at all right to me. I'll send a patch to clean that up, and integrate these new properties.
I would name the new properties just pins and functions, given their scope is explicitly limited to pinctrl configuration nodes, so "pinctrl-" is a little redundant.
With the properties renamed, and this patch rebased on top of the patch I'll send out later, this patch,
PATCH v2 3/3 pinctrl: palmas: add pincontrol driver
In reply to Laxman DewanganTI Palmas series Power Management IC have multiple pins which can be configured for different functionality. This pins can be configured for different function. Also their properties like pull up/down, open drain enable/disable are configurable.
Add support for pincontrol driver Palmas series device like TPS65913, TPS80036. The driver supports to be register from DT only.
---
Changes from V1:
- Use pinconf generic properties to define the Palmas pincontrol nodes.
- Nit and cleanups, typo fixes, rephrasing the sentences etc.
- Use pin specific APIs for setting pin configuration rather than group specific.
.../devicetree/bindings/pinctrl/pinctrl-palmas.txt | 107 ++ drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-palmas.c | 1085 ++++++++++++++++++++ include/linux/mfd/palmas.h | 35 +- 5 files changed, 1227 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt create mode 100644 drivers/pinctrl/pinctrl-palmas.c
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt new file +107 -0
@@ -0,0 +1,107 @@ +Palmas Pincontrol bindings + +The pins of Palmas device can be set on different option and provides +the configuration for Pull UP/DOWN, open drain etc. + +Required properties: +- compatible: It must be one of following: + - "ti,palmas-pinctrl" for Palma series of the pincontrol. + - "ti,tps65913-pinctrl" for Palma series device TPS65913. + - "ti,tps80036-pinctrl" for Palma series device TPS80036. + +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". + +Palmas's pin configuration nodes act as a container for an arbitrary number of +subnodes. 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. + +The name of each subnode is not important; all subnodes should be enumerated +and processed purely based on their content. + +Each subnode only affects those parameters that are explicitly listed. In +other words, a subnode that lists a mux function but no pin configuration +parameters implies no information about any pin configuration parameters. +Similarly, a pin subnode that describes a pullup parameter implies no +information about e.g. the mux function. + +Optional properties: +- ti,palmas-enable-dvfs1: Enable DVFS1. Configure pins for DVFS1 mode. + Selection primary or secondary function associated to I2C2_SCL_SCE, + I2C2_SDA_SDO pin/pad for DVFS1 interface +- ti,palmas-enable-dvfs2: Enable DVFS2. Configure pins for DVFS2 mode. + Selection primary or secondary function associated to GPADC_START + and SYSEN2 pin/pad for DVFS2 interface + +Required subnode-properties: +- pinctrl-pins: An array of strings. Each string contains the name of a pin. + Valid values for these names are listed below. + +Optional subnode-properties: +- pinctrl-function: string containing the name of the function to mux to the + pin. Valid values for function names are listed below. Please refer the + datasheet of the device to determine which are valid for each pin. + +The properties "pinctrl-pins" and "pinctrl-function" ara generic pincontrol +properties and described in pinctrl-bindings.txt. + +Following are other valid propeties for Palams pinctrol dt node which are +described in pinctrl-bindings.txt. +bias-disable, bias-pull-up, bias-pull-down, bias-pull-pin-default +drive-open-drain: Value will represent the open drain to be enable/disable + of pins. + 0: Disable, 1: Enable. + +Note that many of these properties are only valid for certain specific pins. +See the Palmas device datasheet for complete details regarding which pins +support which functionality. + +Valid values for pin names are: +pins: gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7, gpio8, gpio9, + gpio10, gpio11, gpio12, gpio13, gpio14, gpio15, vac, powergood, + nreswarm, pwrdown, gpadc_start, reset_in, nsleep, enable1, enable2, + int. + +function: gpio, led, pwm, regen, sysen, clk32kgaudio, id, vbus_det, chrg_det, + vac, vacok, powergood, usb_psel, msecure, pwrhold, int, nreswarm, + simrsto, simrsti, low_vbat, wireless_chrg1, rcm, pwrdown, gpadc_start, + reset_in, nsleep, enable. + +There is 4 special function: opt0, opt1, opt2 and opt3. If this functions are +selected then directly pins register will be written with 0, 1, 2 and 3 +repectively if it is valid for that pins. + +Example: + palmas: tps65913 { + .... + pinctrl { + compatible = "ti,tps65913-pinctrl"; + ti,palmas-enable-dvfs1; + pinctrl-names = "default"; + pinctrl-0 = <&palmas_pins_state>; + + palmas_pins_state: pinmux { + gpio0 { + pinctrl-pins = "gpio0"; + pinctrl-function = "id"; + bias-pull-up; + }; + + vac { + pinctrl-pins = "vac"; + pinctrl-function = "vacok"; + bias-pull-down; + }; + + gpio5 { + pinctrl-pins = "gpio5"; + pinctrl-function = "opt0"; + drive-open-drain = <1>; + }; + }; + }; + .... + };
drivers/pinctrl/Kconfig +10 -0
@@ -261,6 +261,16 @@ config PINCTRL_EXYNOS5440 select PINMUX select PINCONF +config PINCTRL_PALMAS + bool "Pinctrl driver for the PALMA Series MFD devices" + depends on OF && MFD_PALMAS + select GENERIC_PINCONF + help + Palmas device supports the configuration of pins for different + functionality. This driver supports the pinmux, push-pull and + open drain configuration for the Palmas series devices like + TPS65913, TPS80036 etc. + config PINCTRL_S3C24XX bool "Samsung S3C24XX SoC pinctrl driver" depends on ARCH_S3C24XX
drivers/pinctrl/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_PINCTRL_NOMADIK) += pinctrl-nomadik.o obj-$(CONFIG_PINCTRL_STN8815) += pinctrl-nomadik-stn8815.o obj-$(CONFIG_PINCTRL_DB8500) += pinctrl-nomadik-db8500.o obj-$(CONFIG_PINCTRL_DB8540) += pinctrl-nomadik-db8540.o +obj-$(CONFIG_PINCTRL_PALMAS) += pinctrl-palmas.o obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o obj-$(CONFIG_PINCTRL_SIRF) += sirf/
drivers/pinctrl/pinctrl-palmas.c new file +1085 -0
1,085 lines not on this page · raw message
include/linux/mfd/palmas.h +24 -11
@@ -449,7 +449,7 @@ enum usb_irq_events {#define PALMAS_DVFS_BASE 0x180#define PALMAS_PMU_CONTROL_BASE 0x1A0#define PALMAS_RESOURCE_BASE 0x1D4 -#define PALMAS_PU_PD_OD_BASE 0x1F4 +#define PALMAS_PU_PD_OD_BASE 0x1F0#define PALMAS_LED_BASE 0x200#define PALMAS_INTERRUPT_BASE 0x210#define PALMAS_USB_OTG_BASE 0x250
@@ -1734,16 +1734,20 @@ enum usb_irq_events {#define PALMAS_REGEN3_CTRL_MODE_ACTIVE_SHIFT 0/* Registers for function PAD_CONTROL */ -#define PALMAS_PU_PD_INPUT_CTRL1 0x0 -#define PALMAS_PU_PD_INPUT_CTRL2 0x1 -#define PALMAS_PU_PD_INPUT_CTRL3 0x2 -#define PALMAS_OD_OUTPUT_CTRL 0x4 -#define PALMAS_POLARITY_CTRL 0x5 -#define PALMAS_PRIMARY_SECONDARY_PAD1 0x6 -#define PALMAS_PRIMARY_SECONDARY_PAD2 0x7 -#define PALMAS_I2C_SPI 0x8 -#define PALMAS_PU_PD_INPUT_CTRL4 0x9 -#define PALMAS_PRIMARY_SECONDARY_PAD3 0xA +#define PALMAS_OD_OUTPUT_CTRL2 0x2 +#define PALMAS_POLARITY_CTRL2 0x3 +#define PALMAS_PU_PD_INPUT_CTRL1 0x4 +#define PALMAS_PU_PD_INPUT_CTRL2 0x5 +#define PALMAS_PU_PD_INPUT_CTRL3 0x6 +#define PALMAS_PU_PD_INPUT_CTRL5 0x7 +#define PALMAS_OD_OUTPUT_CTRL 0x8 +#define PALMAS_POLARITY_CTRL 0x9 +#define PALMAS_PRIMARY_SECONDARY_PAD1 0xA +#define PALMAS_PRIMARY_SECONDARY_PAD2 0xB +#define PALMAS_I2C_SPI 0xC +#define PALMAS_PU_PD_INPUT_CTRL4 0xD +#define PALMAS_PRIMARY_SECONDARY_PAD3 0xE +#define PALMAS_PRIMARY_SECONDARY_PAD4 0xF/* Bit definitions for PU_PD_INPUT_CTRL1 */ #define PALMAS_PU_PD_INPUT_CTRL1_RESET_IN_PD 0x40
@@ -2501,6 +2505,15 @@ enum usb_irq_events {#define PALMAS_PU_PD_GPIO_CTRL1 0x6#define PALMAS_PU_PD_GPIO_CTRL2 0x7#define PALMAS_OD_OUTPUT_GPIO_CTRL 0x8 +#define PALMAS_GPIO_DATA_IN2 0x9 +#define PALMAS_GPIO_DATA_DIR2 0x0A +#define PALMAS_GPIO_DATA_OUT2 0x0B +#define PALMAS_GPIO_DEBOUNCE_EN2 0x0C +#define PALMAS_GPIO_CLEAR_DATA_OUT2 0x0D +#define PALMAS_GPIO_SET_DATA_OUT2 0x0E +#define PALMAS_PU_PD_GPIO_CTRL3 0x0F +#define PALMAS_PU_PD_GPIO_CTRL4 0x10 +#define PALMAS_OD_OUTPUT_GPIO_CTRL2 0x11/* Bit definitions for GPIO_DATA_IN */ #define PALMAS_GPIO_DATA_IN_GPIO_7_IN 0x80
Signature · 1 line
1.7.1.1
Re: [PATCH V2 3/3] pinctrl: palmas: add pincontrol driver
Quoted 16 lines · Laxman Dewangan
TI Palmas series Power Management IC have multiple pins which can be configured for different functionality. This pins can be configured for different function. Also their properties like pull up/down, open drain enable/disable are configurable.
Add support for pincontrol driver Palmas series device like TPS65913, TPS80036. The driver supports to be register from DT only.
Signed-off-by Laxman Dewangan <[email protected]>---
Changes from V1:
- Use pinconf generic properties to define the Palmas pincontrol nodes.
- Nit and cleanups, typo fixes, rephrasing the sentences etc.
- Use pin specific APIs for setting pin configuration rather than group specific.
Quoted 5 lines
.../devicetree/bindings/pinctrl/pinctrl-palmas.txt | 107 ++ drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-palmas.c | 1085 ++++++++++++++++++++ include/linux/mfd/palmas.h | 35 +-
For the MFD stuff:
Quoted 3 lines
5 files changed, 1227 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt create mode 100644 drivers/pinctrl/pinctrl-palmas.c
Signature · 4 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH V2 3/3] pinctrl: palmas: add pincontrol driver
In reply to Laxman DewanganDocumentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt line 41
Quoted 13 lines · Laxman Dewangan
TI Palmas series Power Management IC have multiple pins which can be configured for different functionality. This pins can be configured for different function. Also their properties like pull up/down, open drain enable/disable are configurable.
Add support for pincontrol driver Palmas series device like TPS65913, TPS80036. The driver supports to be register from DT only.
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt +3
-0+Required subnode-properties: +- pinctrl-pins: An array of strings. Each string contains the name of a pin. + Valid values for these names are listed below.
s/pinctrl-pins/pins/ I think.
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt line 46
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt +4
-0+Optional subnode-properties: +- pinctrl-function: string containing the name of the function to mux to the + pin. Valid values for function names are listed below. Please refer the + datasheet of the device to determine which are valid for each pin.
s/pinctrl-function/function/ I think.
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt line 56
Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt +9
-0+The properties "pinctrl-pins" and "pinctrl-function" ara generic pincontrol +properties and described in pinctrl-bindings.txt. + +Following are other valid propeties for Palams pinctrol dt node which are +described in pinctrl-bindings.txt. +bias-disable, bias-pull-up, bias-pull-down, bias-pull-pin-default +drive-open-drain: Value will represent the open drain to be enable/disable + of pins. + 0: Disable, 1: Enable.
I'd be tempted to replace everything I quoted above with something a little simpler to avoid any redundancy with pinctrl-bindings.txt:
==========
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, drive-open-drain.
==========
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt line 63
Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt +6
-0+Note that many of these properties are only valid for certain specific pins. +See the Palmas device datasheet for complete details regarding which pins +support which functionality. + +Valid values for pin names are: +pins: gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7, gpio8, gpio9,
"pins:" is redundant here.
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt line 68
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-palmas.txt +5
-0+ gpio10, gpio11, gpio12, gpio13, gpio14, gpio15, vac, powergood, + nreswarm, pwrdown, gpadc_start, reset_in, nsleep, enable1, enable2, + int. + +function: gpio, led, pwm, regen, sysen, clk32kgaudio, id, vbus_det, chrg_det,
I think you would want to structure this list the same as the pins list, so prefix it with "Valid values for function names are:", and delete "function:" at the start of the list.
Quoted 1 line
+There is 4 special function: opt0, opt1, opt2 and opt3. If this functions are
s/this/any of these/
Quoted 1 line
+selected then directly pins register will be written with 0, 1, 2 and 3
s/and/or/
Quoted 1 line
+repectively if it is valid for that pins.
s/repectively/respectively/
Hmm. I'm not sure I like mixing those functions with the more "semantic" function names above. I'd prefer the driver support either the semantic names or the raw names, but not both. It's not really a big deal though I suppose.
I didn't review the code, just the binding.