Skip to contentSkip to conversation

pinctrl: msm: Add support for MSM TLMM pinmux

PATCH Superseded Hanumant Singh 2 participants 3 messages Jun 27, 2013 – Jul 11, 2013 1 message not in the archive

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 pinctrl: msm: Add support for MSM TLMM pinmux

Add a new device tree enabled pinctrl driver for Qualcomm MSM SoC's. This driver provides an extensible framework to interface all MSM's that use a TLMM pinmux, with the pinctrl subsytem.

This driver is split into two parts: the pinctrl interface and the TLMM version specific implementation. The pinctrl interface parses the device tree and registers with the pinctrl subsytem. The TLMM version specific implementation supports pin configuration/register programming for the different pin types present on a given TLMM pinmux version.

Add support only for TLMM version 3 pinmux right now, as well as, only two of the different pin types present on the TLMM v3 pinmux.
Pintype 1: General purpose pins.
Pintype 2: SDC pins.

---
 .../devicetree/bindings/pinctrl/msm-pinctrl.txt    | 171 +++++
 drivers/pinctrl/Kconfig                            |  10 +
 drivers/pinctrl/Makefile                           |   2 +
 drivers/pinctrl/pinctrl-msm-tlmm-v3.c              | 261 +++++++
 drivers/pinctrl/pinctrl-msm.c                      | 791 +++++++++++++++++++++
 drivers/pinctrl/pinctrl-msm.h                      | 112 +++
 6 files changed, 1347 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt
 create mode 100644 drivers/pinctrl/pinctrl-msm-tlmm-v3.c
 create mode 100644 drivers/pinctrl/pinctrl-msm.c
 create mode 100644 drivers/pinctrl/pinctrl-msm.h
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +171 -0
new file mode 100644
index 0000000..9b25794
@@ -0,0 +1,171 @@
+MSM TLMM pinmux controller
+
+Qualcomm MSM integrates a GPIO and Pin mux/config hardware, (TOP Level Mode
+Multiplexper in short TLMM). It controls the input/output settings on the
+available pads/pins and also provides ability to multiplex and configure the
+output of various on-chip controllers onto these pads. The pins are also of
+different types, encapsulating different functions and having differing register
+semantics.
+
+Required Properties:
+- compatible: should be one of the following.
+  - "qcom,msm-tlmm-v3": for MSM with TLMM version 3.
+
+- reg: Base address of the pin controller hardware module and length of
+  the address space it occupies.
+
+- Pin types as child nodes: Pin types supported by a particular controller
+  instance are represented as child nodes of the controller node. Each
+  pin type node must contain following properties:
+
+Required Properties
+  - qcom,pin-type: identifies the pin type.
+  - qcom,pin-cells: number of cells in the pin type specifier.
+  - qcom,num-pins: number of pins of given type present on the MSM.
+
+- Pin groups as child nodes: The pin mux (selecting pin function
+  mode) and pin config (pull up/down, driver strength, direction) settings are
+  represented as child nodes of the pin-controller node. There is no limit on
+  the count of these child nodes.
+
+  Required Properties
+    -qcom,pins: phandle specifying pin type and a pin number.
+
+  Optional Properties
+    -qcom,pin-func: function setting for the pin group.
+
+  The child node should contain a list of pin(s) on which a particular pin
+  function selection or pin configuration (or both) have to applied. This
+  list of pins is specified using the property name "qcom,pins". There
+  should be atleast one pin specfied for this property and there is no upper
+  limit on the count of pins that can be specified. The pins are specified
+  using the pintype phandle and the pin number within that pintype.
+
+  The pin function selection that should be applied on the pins listed in the
+  child node is specified using the "qcom,pin-func" property. The value
+  of this property that should be applied to each of the pins listed in the
+  "qcom,pins" property, should be picked from the hardware manual of the SoC.
+  This property is optional in the child node if no specific function
+  selection is desired for the pins listed in the child node or if the pin is
+  to be used for bit bang. The value of this property is used as-is to program
+  the pin-controller
+
+  The pin group node must additionally have a pin configuration node as its own
+  child node. There can be more then one such configuration node for a pin group
+  node. There can be one or more configurations within the configuration
+  node. These configurations are applied to all pins mentoned above using the
+  "qcom,pins" property. These configurations are specific to the pintype of the
+  pins. For the pin configuration properties supported by general purpose and
+  sdc pins lookup Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+  Of the above only, bias-disable,-pull-up,-pull-down, drive-strength and
+  output-high/low are supported.
+
+  The values specified by these config properties should be derived from the
+  hardware manual and these values are programmed as-is into the pin
+  configuration register for the corresponding pintype.
+
+  NOTE: A pin group node should be formed for all pins that are going to have
+  the same function and configuration settings. If a subset of pins to be used
+  by a client require different function or configuration settings or both
+  then they should be modelled as a separate pin group node to be used by
+  the client.
+
+  The client nodes that require a particular pin function selection and/or
+  pin configuration should use the bindings listed in the "pinctrl-bindings txt"
+  file.
+
+Example 1: A pin-controller node with pin types
+
+	pinctrl@fd5110000 {
+		compatible = "qcom,msm-tlmm-v3";
+		reg = <0x11400000 0x4000>;
+
+		/* General purpose pin type */
+		gp: gp {
+			qcom,pin-type = "gp";
+			qcom,num-pins = <117>;
+			#qcom,pin-cells = <1>;
+		};
+	};
+
+Example 2: Spi pin entries within the pincontroller node
+	pinctrl@fd511000 {
+		....
+		..
+		spi-bus {
+			/*
+			 * MOSI, MISO and CLK lines
+			 * all sharing same function and config
+			 * settings for each configuration node.
+			 */
+			qcom,pins = <&gp 0>, <&gp 1>, <&gp 3>;
+			qcom,pin-func = <1>;
+
+			/* Active configuration of bus pins */
+			spi-bus-active: spi-bus-active {
+				drive-strength = <3>; /* 8 MA */
+				bias-disable; /* No PULL */
+			};
+			/* Sleep configuration of bus pins */
+			spi-bus-sleep: spi-bus-sleep {
+				drive-strength = <0>; /* 2 MA */
+				bias-disable; /* No PULL */
+			};
+		};
+
+		spi-cs {
+			/*
+			 * Chip select for SPI
+			 * different config
+			 * settings as compared to bus pins.
+			 */
+			qcom,pins = <&Gp 2>;
+			qcom,num-grp-pins = <1>;
+			qcom,pin-func = <1>;
+
+			/* Active configuration of cs pin */
+			spi-cs-active: spi-cs-active {
+				drive-strength = <2>; /* 4 MA */
+				bias-disable; /* No PULL */
+			};
+			/* Sleep configuration of cs pin */
+			spi-bus-sleep: spi-bus-sleep {
+				drive-strength = <0>; /* 2 MA */
+				bias-disable = <0>; /* No PULL */
+			};
+		};
+	};
+
+Example 3: A SPI client node that supports 'active' and 'sleep' states.
+
+	spi_0: spi@f9923000 { /* BLSP1 QUP1 */
+			compatible = "qcom,spi-qup-v2";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg-names = "spi_physical", "spi_bam_physical";
+			reg = <0xf9923000 0x1000>,
+			<0xf9904000 0xF000>;
+			interrupt-names = "spi_irq", "spi_bam_irq";
+			interrupts = <0 95 0>, <0 238 0>;
+			spi-max-frequency = <19200000>;
+
+			/* pins used by spi controllers */
+			pinctrl-names = "default", "sleep";
+			pinctrl-0 = <&spi-bus-active &spi-cs-active>;
+			pinctrl-1 = <&spi-bus-sleep &spi-cs-sleep>;
+
+			qcom,infinite-mode = <0>;
+			qcom,use-bam;
+			qcom,ver-reg-exists;
+		qcom,bam-consumer-pipe-index = <12>;
+		qcom,bam-producer-pipe-index = <13>;
+		 };
+
+Example 4: Set up the default pin state for spi controller.
+
+	static inline int msm_spi_request_pins{struct msm_spi *dd)
+	{
+		/* ... */
+		state = pinctrl_lookup_state(dd->dev->pins->p, "sleep");
+		pinctrl_select_state(dd->dev->pins->p, state);
+	}
drivers/pinctrl/Kconfig +10 -0
index 34f51d2..480cb26 100644
@@ -133,6 +133,16 @@ config PINCTRL_IMX28
 	bool
 	select PINCTRL_MXS
 
+config PINCTRL_MSM
+	depends on OF
+	bool
+	select PINMUX
+	select GENERIC_PINCONF
+
+config PINCTRL_MSM_TLMM_V3
+	bool
+	select PINCTRL_MSM
+
 config PINCTRL_NOMADIK
 	bool "Nomadik pin controller driver"
 	depends on ARCH_U8500 || ARCH_NOMADIK
drivers/pinctrl/Makefile +2 -0
index f82cc5b..3cf8fba 100644
@@ -27,6 +27,8 @@ obj-$(CONFIG_PINCTRL_MMP2)	+= pinctrl-mmp2.o
 obj-$(CONFIG_PINCTRL_MXS)	+= pinctrl-mxs.o
 obj-$(CONFIG_PINCTRL_IMX23)	+= pinctrl-imx23.o
 obj-$(CONFIG_PINCTRL_IMX28)	+= pinctrl-imx28.o
+obj-$(CONFIG_PINCTRL_MSM)	+= pinctrl-msm.o
+obj-$(CONFIG_PINCTRL_MSM_TLMM_V3)	+= pinctrl-msm-tlmm-v3.o
 obj-$(CONFIG_PINCTRL_NOMADIK)	+= pinctrl-nomadik.o
 obj-$(CONFIG_PINCTRL_STN8815)	+= pinctrl-nomadik-stn8815.o
 obj-$(CONFIG_PINCTRL_DB8500)	+= pinctrl-nomadik-db8500.o
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +261 -0

261 lines not on this page · raw message

drivers/pinctrl/pinctrl-msm.c new file +791 -0

791 lines not on this page · raw message

drivers/pinctrl/pinctrl-msm.h new file +112 -0

112 lines not on this page · raw message

Signature · 7 lines
1.8.2.1

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum, hosted by The Linux Foundation
-- 
#2 lore raw
Quoted 12 lines · Hanumant Singh

Add a new device tree enabled pinctrl driver for Qualcomm MSM SoC's. This driver provides an extensible framework to interface all MSM's that use a TLMM pinmux, with the pinctrl subsytem.

This driver is split into two parts: the pinctrl interface and the TLMM version specific implementation. The pinctrl interface parses the device tree and registers with the pinctrl subsytem. The TLMM version specific implementation supports pin configuration/register programming for the different pin types present on a given TLMM pinmux version.

Quoted 7 lines

Add support only for TLMM version 3 pinmux right now, as well as, only two of the different pin types present on the TLMM v3 pinmux.
Pintype 1: General purpose pins.
Pintype 2: SDC pins.

This is looking better. (Sorry for late feedback...)

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 22

Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +2 -0
+Required Properties
+  - qcom,pin-type: identifies the pin type.

Define the possible types. If these are enumerable, don't pass a generic string, use an hard identifier, e.g:

qcom,pin-type-gp;
qcom,pin-type-sdc;

(...)

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 85

Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +9 -0
+Example 1: A pin-controller node with pin types
+
+       pinctrl@fd5110000 {
+               compatible = "qcom,msm-tlmm-v3";
+               reg = <0x11400000 0x4000>;
+
+               /* General purpose pin type */
+               gp: gp {
+                       qcom,pin-type = "gp";

Can we use qcom,pin-type-gp; ?

(...)

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +6 -0
+Example 2: Spi pin entries within the pincontroller node
+       pinctrl@fd511000 {
+               ....
+               ..
+               spi-bus {
+                       /*

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 106

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +10 -0
+                        * MOSI, MISO and CLK lines
+                        * all sharing same function and config
+                        * settings for each configuration node.
+                        */
+                       qcom,pins = <&gp 0>, <&gp 1>, <&gp 3>;
+                       qcom,pin-func = <1>;
+
+                       /* Active configuration of bus pins */
+                       spi-bus-active: spi-bus-active {
+                               drive-strength = <3>; /* 8 MA */

No that shall be <8>.

If you need a translation table to translate this into your magic constants, put a cross-reference table in your driver.

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 111

Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +5 -0
+                               bias-disable; /* No PULL */
+                       };
+                       /* Sleep configuration of bus pins */
+                       spi-bus-sleep: spi-bus-sleep {
+                               drive-strength = <0>; /* 2 MA */

This shall be <2>;

Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +7 -0
+                               bias-disable; /* No PULL */
+                       };
+               };
+
+               spi-cs {
+                       /*
+                        * Chip select for SPI

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 128

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +10 -0
+                        * different config
+                        * settings as compared to bus pins.
+                        */
+                       qcom,pins = <&Gp 2>;
+                       qcom,num-grp-pins = <1>;
+                       qcom,pin-func = <1>;
+
+                       /* Active configuration of cs pin */
+                       spi-cs-active: spi-cs-active {
+                               drive-strength = <2>; /* 4 MA */

This shall be <4>;

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 133

Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +5 -0
+                               bias-disable; /* No PULL */
+                       };
+                       /* Sleep configuration of cs pin */
+                       spi-bus-sleep: spi-bus-sleep {
+                               drive-strength = <0>; /* 2 MA */

This shall be <2>;

Quoted 1 line

+ bias-disable = <0>; /* No PULL */

Just bias-disable;

(...)

Quoted 14 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +14 -0
+Example 3: A SPI client node that supports 'active' and 'sleep' states.
+
+       spi_0: spi@f9923000 { /* BLSP1 QUP1 */
+                       compatible = "qcom,spi-qup-v2";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg-names = "spi_physical", "spi_bam_physical";
+                       reg = <0xf9923000 0x1000>,
+                       <0xf9904000 0xF000>;
+                       interrupt-names = "spi_irq", "spi_bam_irq";
+                       interrupts = <0 95 0>, <0 238 0>;
+                       spi-max-frequency = <19200000>;
+
+                       /* pins used by spi controllers */

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 162

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +10 -0
+                       pinctrl-names = "default", "sleep";
+                       pinctrl-0 = <&spi-bus-active &spi-cs-active>;
+                       pinctrl-1 = <&spi-bus-sleep &spi-cs-sleep>;
+
+                       qcom,infinite-mode = <0>;
+                       qcom,use-bam;
+                       qcom,ver-reg-exists;
+               qcom,bam-consumer-pipe-index = <12>;
+               qcom,bam-producer-pipe-index = <13>;
+                };

Looks good.

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 171

Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +8 -0
+Example 4: Set up the default pin state for spi controller.
+
+       static inline int msm_spi_request_pins{struct msm_spi *dd)
+       {
+               /* ... */
+               state = pinctrl_lookup_state(dd->dev->pins->p, "sleep");
+               pinctrl_select_state(dd->dev->pins->p, state);
+       }

Do not put such things into the OS-neutral devicetree bindings documentation.

(...)

Quoted 19 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +19 -0
+static int msm_tlmm_v3_sdc_cfg(uint pin_no, unsigned long *config,
+                                               void __iomem *reg_base,
+                                               bool write)
+{
+       unsigned int val, id, data;
+       u32 mask, shft;
+       void __iomem *cfg_reg;
+
+       cfg_reg = reg_base + sdc_regs[pin_no].offset;
+       id = pinconf_to_config_param(*config);
+       /* Get mask and shft values for this config type */
+       switch (id) {
+       case PIN_CONFIG_BIAS_DISABLE:
+       case PIN_CONFIG_BIAS_PULL_DOWN:
+       case PIN_CONFIG_BIAS_PULL_UP:
+               mask = sdc_regs[pin_no].pull_mask;
+               shft = sdc_regs[pin_no].pull_shft;
+               break;
+       case PIN_CONFIG_DRIVE_STRENGTH:

drivers/pinctrl/pinctrl-msm-tlmm-v3.c line 153

Quoted 10 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +10 -0
+               mask = sdc_regs[pin_no].drv_mask;
+               shft = sdc_regs[pin_no].drv_shft;
+               break;
+       default:
+               return -EINVAL;
+       };
+
+       val = readl_relaxed(cfg_reg);
+       if (write) {
+               data = pinconf_to_config_argument(*config);

This data needs to be treated per-config option and be more optional. This makes it look like you want to supply a <1> with any pull up or pull down configuration to nail it in when in fact they do not take any argument, and if they do it should be the number of Ohms in the resistor, not <1>.

For drive strength you need a mA -> selector translation table as mentioned.

drivers/pinctrl/pinctrl-msm-tlmm-v3.c line 160

Quoted 7 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +7 -0
+               val &= ~(mask << shft);
+               val |= (data << shft);
+               writel_relaxed(val, cfg_reg);
+       } else {
+               val >>= shft;
+               val &= mask;
+               *config = pinconf_to_config_packed(id, val);

Same thing applies in reverse here.

drivers/pinctrl/pinctrl-msm-tlmm-v3.c line 169

Quoted 5 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +5 -0
+static void msm_tlmm_v3_sdc_set_reg_base(void __iomem **ptype_base,
+                                                       void __iomem *tlmm_base)
+{
+       *ptype_base = tlmm_base + 0x2044;
+}

0x2044 looks a bit magic, use a #define for this or atleast put in some comment...

Quoted 32 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +32 -0
+static int msm_tlmm_v3_gp_cfg(uint pin_no, unsigned long *config,
+                                               void *reg_base, bool write)
+{
+       unsigned int val, id, data;
+       u32 mask = 0, shft = 0;
+       void __iomem *inout_reg = NULL;
+       void __iomem *cfg_reg = TLMMV3_GP_CFG(reg_base, pin_no);
+
+       id = pinconf_to_config_param(*config);
+       /* Get mask and shft values for this config type */
+       switch (id) {
+       case PIN_CONFIG_BIAS_DISABLE:
+       case PIN_CONFIG_BIAS_PULL_DOWN:
+       case PIN_CONFIG_BIAS_PULL_UP:
+               mask = TLMMV3_GP_PULL_MASK;
+               shft = TLMMV3_GP_PULL_SHFT;
+               break;
+       case PIN_CONFIG_DRIVE_STRENGTH:
+               mask = TLMMV3_GP_DRV_MASK;
+               shft = TLMMV3_GP_DRV_SHFT;
+               break;
+       case PIN_CONFIG_OUTPUT:
+               mask = TLMMV3_GP_DIR_MASK;
+               shft = TLMMV3_GP_DIR_SHFT;
+               break;
+       default:
+               return -EINVAL;
+       };
+
+       val = readl_relaxed(cfg_reg);
+       if (write) {
+               data = pinconf_to_config_argument(*config);

drivers/pinctrl/pinctrl-msm-tlmm-v3.c line 212

Quoted 10 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +10 -0
+               if (id == PIN_CONFIG_OUTPUT) {
+                       if (data == TLMMV3_GP_OUT) {
+                               inout_reg = TLMMV3_GP_INOUT(reg_base, pin_no);
+                               writel_relaxed(TLMMV3_GP_OUT, inout_reg);
+                       }
+                       if (data > TLMMV3_GP_IN)
+                               data = TLMMV3_GP_OUT;
+               }
+               val &= ~(mask << shft);
+               val |= (data << shft);

Again I don't like how the argument is propagated directly into the registers like this, treat each case in the switch clause and handle any specific register bit flipping there on a per-config-option basis.

(...)

Quoted 1 line
drivers/pinctrl/pinctrl-msm.c +0 -0

(...)

Quoted 24 lines
drivers/pinctrl/pinctrl-msm.c +24 -0
+static int msm_pinconf_parse_dt(struct device_node *cfg_np,
+                               unsigned long **configs, unsigned int *cnt,
+                               struct msm_pintype_info *pinfo)
+{
+       struct msm_tlmm_cfg_params const *cfg_params;
+       unsigned int num_cfg_params, idx = 0, cfg_cnt = 0;
+       unsigned long *cfg = NULL;
+       unsigned int val = 0;
+
+       cfg_params = pinfo->tlmm_cfg_param;
+       num_cfg_params = pinfo->num_cfg_params;
+
+       for (idx = 0; idx < num_cfg_params; idx++) {
+               if (!of_find_property(cfg_np, cfg_params[idx].name, NULL))
+                       continue;
+               cfg_cnt++;
+       }
+       if (!cfg_cnt)
+               return -EINVAL;
+       /* Allocate memory to hold configs */
+       cfg = kzalloc(sizeof(*cfg) * cfg_cnt, GFP_KERNEL);
+       if (!cfg)
+               return -ENOMEM;
+       /* read cfg property values from cfg device tree node */

drivers/pinctrl/pinctrl-msm.c line 276

Quoted 10 lines
drivers/pinctrl/pinctrl-msm.c +10 -0
+       for (idx = 0, cfg_cnt = 0; idx < num_cfg_params; idx++) {
+               if (!of_find_property(cfg_np, cfg_params[idx].name, NULL))
+                       continue;
+               of_property_read_u32(cfg_np, cfg_params[idx].name, &val);
+               cfg[cfg_cnt++] = pinfo->pack_cfg(val, &cfg_params[idx]);
+       }
+       *cnt = cfg_cnt;
+       *configs = cfg;
+       return 0;
+}

What is this? As far as I can see you're not using any non-standard configs yet so don't implement code for it.

drivers/pinctrl/pinctrl-msm.c line 334

Quoted 10 lines
drivers/pinctrl/pinctrl-msm.c +10 -0
+       /*
+        * If no pin type specifc config parameters are specified
+        * use general puropse pin config parsing
+        */
+       if (!pinfo->tlmm_cfg_param)
+               ret = pinconf_generic_parse_dt_config(cfg_np, &cfg,
+                                                               &cfg_cnt);
+
+        else
+               ret = msm_pinconf_parse_dt(cfg_np, &cfg, &cfg_cnt, pinfo);

This looks like *either* generic *or* custom pin configuration, but in the previous mail you mentioned using *both* simultaneously. I don't see how this could work?

drivers/pinctrl/pinctrl-msm.c

Quoted 10 lines
drivers/pinctrl/pinctrl-msm.c +10 -0
+/**
+ * struct msm_tlmm_cfgs: represent config properties of a pin type.
+ * @name: name of config.
+ * @id: id of the config.
+ */
+
+struct msm_tlmm_cfg_params {
+       const char *name;
+       unsigned int id;
+};

Since these have no device tree bindings, don't implement them. This looks like a free pass to encode just anything in here...

Yours,
Linus Walleij

author
#3 lore raw
Quoted 25 lines · Linus Walleij
Quoted 12 lines · Hanumant Singh

Add a new device tree enabled pinctrl driver for Qualcomm MSM SoC's. This driver provides an extensible framework to interface all MSM's that use a TLMM pinmux, with the pinctrl subsytem.

This driver is split into two parts: the pinctrl interface and the TLMM version specific implementation. The pinctrl interface parses the device tree and registers with the pinctrl subsytem. The TLMM version specific implementation supports pin configuration/register programming for the different pin types present on a given TLMM pinmux version.

Quoted 7 lines

Add support only for TLMM version 3 pinmux right now, as well as, only two of the different pin types present on the TLMM v3 pinmux.
Pintype 1: General purpose pins.
Pintype 2: SDC pins.

This is looking better. (Sorry for late feedback...)

Quoted 8 lines

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 22

Quoted 2 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +2 -0
+Required Properties
+  - qcom,pin-type: identifies the pin type.

Define the possible types. If these are enumerable, don't pass a generic string, use an hard identifier, e.g:

qcom,pin-type-gp;
qcom,pin-type-sdc;

will do

Quoted 34 lines

(...)

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 85

Quoted 9 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +9 -0
+Example 1: A pin-controller node with pin types
+
+       pinctrl@fd5110000 {
+               compatible = "qcom,msm-tlmm-v3";
+               reg = <0x11400000 0x4000>;
+
+               /* General purpose pin type */
+               gp: gp {
+                       qcom,pin-type = "gp";

Can we use qcom,pin-type-gp; ?

(...)

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +6 -0
+Example 2: Spi pin entries within the pincontroller node
+       pinctrl@fd511000 {
+               ....
+               ..
+               spi-bus {
+                       /*

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 106

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +10 -0
+                        * MOSI, MISO and CLK lines
+                        * all sharing same function and config
+                        * settings for each configuration node.
+                        */
+                       qcom,pins = <&gp 0>, <&gp 1>, <&gp 3>;
+                       qcom,pin-func = <1>;
+
+                       /* Active configuration of bus pins */
+                       spi-bus-active: spi-bus-active {
+                               drive-strength = <3>; /* 8 MA */

No that shall be <8>.

Quoted 3 lines

If you need a translation table to translate this into your magic constants, put a cross-reference table in your driver.

Will do

Quoted 39 lines

Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt line 111

Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/msm-pinctrl.txt new file +5 -0
+                               bias-disable; /* No PULL */
+                       };
+                       /* Sleep configuration of bus pins */
+                       spi-bus-sleep: spi-bus-sleep {
+                               drive-strength = <0>; /* 2 MA */

This shall be <2>;

(...)

Quoted 27 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +27 -0
+static int msm_tlmm_v3_sdc_cfg(uint pin_no, unsigned long *config,
+                                               void __iomem *reg_base,
+                                               bool write)
+{
+       unsigned int val, id, data;
+       u32 mask, shft;
+       void __iomem *cfg_reg;
+
+       cfg_reg = reg_base + sdc_regs[pin_no].offset;
+       id = pinconf_to_config_param(*config);
+       /* Get mask and shft values for this config type */
+       switch (id) {
+       case PIN_CONFIG_BIAS_DISABLE:
+       case PIN_CONFIG_BIAS_PULL_DOWN:
+       case PIN_CONFIG_BIAS_PULL_UP:
+               mask = sdc_regs[pin_no].pull_mask;
+               shft = sdc_regs[pin_no].pull_shft;
+               break;
+       case PIN_CONFIG_DRIVE_STRENGTH:
+               mask = sdc_regs[pin_no].drv_mask;
+               shft = sdc_regs[pin_no].drv_shft;
+               break;
+       default:
+               return -EINVAL;
+       };
+
+       val = readl_relaxed(cfg_reg);
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       if (write) {
+               data = pinconf_to_config_argument(*config);

This data needs to be treated per-config option and be more optional. This makes it look like you want to supply a <1> with any pull up or pull down configuration to nail it in when in fact they do not take any argument, and if they do it should be the number of Ohms in the resistor, not <1>.

OK I will supply the register magic values for each of the pull config options.
Resistor value is not configurable, so I don't need that.

Quoted 2 lines

For drive strength you need a mA -> selector translation table as mentioned.

I will implement the translation table.

Quoted 11 lines

drivers/pinctrl/pinctrl-msm-tlmm-v3.c line 160

Quoted 8 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +7 -0
+               val &= ~(mask << shft);
+               val |= (data << shft);
+               writel_relaxed(val, cfg_reg);
+       } else {
+               val >>= shft;
+               val &= mask;
+               *config = pinconf_to_config_packed(id, val);

Same thing applies in reverse here.

In that case, for get_config
1) For pull configs: I suppose I can return the default config value instead of the register magic value?
2) For drive-strength I can return the reverse translation.

Quoted 9 lines

drivers/pinctrl/pinctrl-msm-tlmm-v3.c line 169

Quoted 5 lines
drivers/pinctrl/pinctrl-msm-tlmm-v3.c new file +5 -0
+static void msm_tlmm_v3_sdc_set_reg_base(void __iomem **ptype_base,
+                                                       void __iomem *tlmm_base)
+{
+       *ptype_base = tlmm_base + 0x2044;
+}

0x2044 looks a bit magic, use a #define for this or atleast put in some comment...

Will do

Quoted 11 lines

drivers/pinctrl/pinctrl-msm.c line 334

Quoted 10 lines
drivers/pinctrl/pinctrl-msm.c new file +10 -0
+       /*
+        * If no pin type specifc config parameters are specified
+        * use general puropse pin config parsing
+        */
+       if (!pinfo->tlmm_cfg_param)
+               ret = pinconf_generic_parse_dt_config(cfg_np, &cfg,
+                                                               &cfg_cnt);
+
+        else
+               ret = msm_pinconf_parse_dt(cfg_np, &cfg, &cfg_cnt, pinfo);
Quoted 4 lines

This looks like *either* generic *or* custom pin configuration, but in the previous mail you mentioned using *both* simultaneously. I don't see how this could work?

Currently the pin types fall in the either or cattegory. Not in both. But for the currently implemented pintypes I don't need custom pin configuration. So I will remove the support.

Quoted 5 lines
Quoted 5 lines

+/**
+ * struct msm_tlmm_cfgs: represent config properties of a pin type.
+ * @name: name of config.
+ * @id: id of the config.
+ */

Quoted 9 lines

drivers/pinctrl/pinctrl-msm.h line 55

Quoted 5 lines
drivers/pinctrl/pinctrl-msm.h new file +5 -0
+
+struct msm_tlmm_cfg_params {
+       const char *name;
+       unsigned int id;
+};

Since these have no device tree bindings, don't implement them. This looks like a free pass to encode just anything in here...

As mentioned above I will remove the customer configs.

Quoted 3 lines

Yours,
Linus Walleij

Thanks
Hanumant

Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--