Skip to contentSkip to conversation

pinctrl: add pincontrol driver for palmas device.

PATCH In review Laxman Dewangan 3 participants 11 messages Aug 6, 2013 – Aug 14, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 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.

Changes from V2:
- Rebased the DT binding document on top of Stephen's cleanup.
- Convert name of propery "pinctrl-pins" to "pins" and "pinctrl-function" to function.

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          |    3 +
 .../devicetree/bindings/pinctrl/pinctrl-palmas.txt |   96 ++
 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, 1499 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
#1 lore raw

PATCH v3 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.

Changes from V2:
- Nothing in code.
- Added Reviewed by Stephen.

 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
index d64563b..bc03a6e 100644
@@ -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
#2 lore raw

Re: [PATCH V3 1/3] pinctrl: add utility functions for add map/configs

Quoted 9 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.

Quoted 7 lines

---
Changes from V1:
- Add this files in this patch and add common utility APIs to here.

Changes from V2:
- Nothing in code.
- Added Reviewed by Stephen.

This v3 version applied, thanks!

Would it be complicated to create a few follow-on patches to other drivers pulling their boilerplate into these utils?

Yours,
Linus Walleij

#3 lore raw

PATCH v3 2/3 pinctrl: pinconf-generic: add generic APIs for mapping pinctrl node

In reply to 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 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.
Changes from V2:
- Rebased the pinctrl binding doc on top of Stephen's cleanup.
- Rename properties "pinctrl-pins" and "pinctrl-function" to "pins" and "function".

 .../bindings/pinctrl/pinctrl-bindings.txt          |    3 +
 drivers/pinctrl/pinconf-generic.c                  |   96 ++++++++++++++++++++
 include/linux/pinctrl/pinconf-generic.h            |    6 ++
 3 files changed, 105 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +3 -0
index 237823a..4546b23 100644
@@ -172,3 +172,6 @@ arguments are described below.
 
 More in-depth documentation on these parameters can be found in
 <include/linux/pinctrl/pinconfig-generic.h>
+
+The valid pin names and function are device/chip specific and it can be
+found from the device/chip specific binding documents.
drivers/pinctrl/pinconf-generic.c +96 -0

106 lines not on this page · raw message

include/linux/pinctrl/pinconf-generic.h +6 -0
index bf7e989..a472b93 100644
@@ -137,6 +137,12 @@ static inline unsigned long pinconf_to_config_packed(enum pin_config_param param
 	return 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
#4 lore raw

Re: [PATCH V3 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 uses the pinconf generic APIs for defining their nodes.

Changes from V2:
- Rebased the pinctrl binding doc on top of Stephen's cleanup.
- Rename properties "pinctrl-pins" and "pinctrl-function" to "pins" and "function".

Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt arguments are described below. · line 177

Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +3 -0
 
+
+The valid pin names and function are device/chip specific and it can be
+found from the device/chip specific binding documents.

Oh, I ended up posting a V2 of my cleanup of that file with a wordier version of that text added:-) Linus may want to drop those 3 lines when applying this.

#5 lore raw

Re: [PATCH V3 2/3] pinctrl: pinconf-generic: add generic APIs for mapping pinctrl node

In reply to Laxman Dewangan
Quoted 6 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 uses the pinconf generic APIs for defining their nodes.

Quoted 10 lines

---
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.
Changes from V2:
- Rebased the pinctrl binding doc on top of Stephen's cleanup.
- Rename properties "pinctrl-pins" and "pinctrl-function" to "pins" and "function".

This v3 patch applied, dropping the three lines indicated by Stephen to be added by another patch in my queue.

Yours,
Linus Walleij

#6 lore raw

PATCH v3 3/3 pinctrl: palmas: add pincontrol driver

In reply to 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.

---
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.
Changes from V2:
- Add ack by Lee.
- Correct the binding docs.

 .../devicetree/bindings/pinctrl/pinctrl-palmas.txt |   96 ++
 drivers/pinctrl/Kconfig                            |   10 +
 drivers/pinctrl/Makefile                           |    1 +
 drivers/pinctrl/pinctrl-palmas.c                   | 1085 ++++++++++++++++++++
 include/linux/mfd/palmas.h                         |   35 +-
 5 files changed, 1216 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 +96 -0
new file mode 100644
index 0000000..8748614
@@ -0,0 +1,96 @@
+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
+
+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.
+
+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:
+	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.
+
+Valid value of function names are:
+	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 are 4 special functions: opt0, opt1, opt2 and opt3. If any of these
+functions is selected then directly pins register will be written with 0, 1, 2
+or 3 respectively if it is valid for that pins or list of 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 {
+					pins = "gpio0";
+					function = "id";
+					bias-pull-up;
+				};
+
+				vac {
+					pins = "vac";
+					function = "vacok";
+					bias-pull-down;
+				};
+
+				gpio5 {
+					pins = "gpio5";
+					function = "opt0";
+					drive-open-drain = <1>;
+				};
+			};
+		};
+		....	
+	};
drivers/pinctrl/Kconfig +10 -0
index bc830af..8542cd4 100644
@@ -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
index bc03a6e..496d9bf 100644
@@ -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
index 1a8dd7a..2891f7c 100644
@@ -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
Reviewed-by on v3 3/3
#7 lore raw

Re: [PATCH V3 3/3] pinctrl: palmas: add pincontrol driver

Quoted 7 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.

I think this binding is reasonable enough, so that part,

#8 lore raw

Re: [PATCH V3 3/3] pinctrl: palmas: add pincontrol driver

Hi Linus,

Quoted 11 lines · Stephen Warren
Quoted 7 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.

I think this binding is reasonable enough, so that part,

Can you please review this series?
I have some follow on patches on cleanups of tegra pincontrol driver to use the utils function which is introduced on this series which I want to send.

Thanks,
Laxman

#9 lore raw

Re: [PATCH V3 3/3] pinctrl: palmas: add pincontrol driver

Quoted 1 line · Laxman Dewangan

Can you please review this series?

It is a fine driver, so applied it.

Quoted 2 lines

I have some follow on patches on cleanups of tegra pincontrol driver to use the utils function which is introduced on this series which I want to send.

Hit me with all you have.

Yours,
Linus Walleij

#10 lore raw

Re: [PATCH V3 3/3] pinctrl: palmas: add pincontrol driver

In reply to Laxman Dewangan
Quoted 10 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.

Quoted 9 lines

---
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.
Changes from V2:
- Add ack by Lee.
- Correct the binding docs.

This v3 version applied with Stepgen's Reviewed-by.

Yours,
Linus Walleij