Skip to contentSkip to conversation

Qualcomm SPMI PMIC pin controller drivers

PATCH Superseded Ivan T. Ivanov 3 participants 11 messages Sep 15, 2014 – Oct 7, 2014

Subsystems (5)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Qualcomm SPMI PMIC pin controller drivers

Hi,

This is forth version of the patches posted earlier here[1].

Changes:
- Driver for SSBI PMIC dropped from this patchest - let Bjorn to handle it.
- Separate MPP and GPIO drivers.
- Second value in 'reg' propriety is used to specify address range length and this number of GPIO/MPP's that drivers should handle.
- Using generic compatible = "qcom,spmi-pmic-gpio" in GPIO driver to handle any PMIC SPMI based GPIO block.
- Using generic compatible = "qcom,spmi-pmic-mpp" in MPP driver to handle any PMIC SPMI based MPP block.
- Analog functionality for MPP's is activated with qcom,analog-mode.
- Fixed review comments and driver issues.

Short description:

Patches adds pin control drivers for Multi-Purpose Pin (MPP) and General-purpose pin (GPIO) controllers found in Qualcomm SPMI based PMIC chips.

MPP's are enhanced GPIO's with analog circuits, which support analog and digital input/output.

[1] https://www.mail-archive.com/[email protected]/msg10095.html

Bjorn Andersson (1):
pinctrl: Device tree bindings for Qualcomm PMIC GPIO block

Ivan T. Ivanov (3):
pinctrl: Device tree bindings for Qualcomm PMIC MPP block
pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver
pinctrl: Qualcomm SPMI PMIC MPP pin controller driver

 .../devicetree/bindings/pinctrl/qcom,pmic-gpio.txt | 214 +++++
 .../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt  | 159 ++++
 drivers/pinctrl/qcom/Kconfig                       |  12 +
 drivers/pinctrl/qcom/Makefile                      |   2 +
 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c      | 944 ++++++++++++++++++++
 drivers/pinctrl/qcom/pinctrl-spmi-pmic-mpp.c       | 958 +++++++++++++++++++++
 include/dt-bindings/pinctrl/qcom,pmic-gpio.h       | 142 +++
 include/dt-bindings/pinctrl/qcom,pmic-mpp.h        |  44 +
 8 files changed, 2475 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
 create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
 create mode 100644 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c
 create mode 100644 drivers/pinctrl/qcom/pinctrl-spmi-pmic-mpp.c
 create mode 100644 include/dt-bindings/pinctrl/qcom,pmic-gpio.h
 create mode 100644 include/dt-bindings/pinctrl/qcom,pmic-mpp.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v4 1/4 pinctrl: Device tree bindings for Qualcomm PMIC GPIO block

From: Bjorn Andersson <[email protected]>

This introduced the device tree bindings for the GPIO block found in PMIC's from Qualcomm.

---
 .../devicetree/bindings/pinctrl/qcom,pmic-gpio.txt | 214 +++++++++++++++++++++
 include/dt-bindings/pinctrl/qcom,pmic-gpio.h       | 142 ++++++++++++++
 2 files changed, 356 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
 create mode 100644 include/dt-bindings/pinctrl/qcom,pmic-gpio.h
Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt new file +214 -0
new file mode 100644
index 0000000..e146496
@@ -0,0 +1,214 @@
+Qualcomm PMIC GPIO block
+
+This binding describes the GPIO block(s) found in the 8xxx series of
+PMIC's from Qualcomm.
+
+- compatible:
+	Usage: required
+	Value type: <string>
+	Definition: must be one of:
+		    "qcom,pm8018-gpio"
+		    "qcom,pm8038-gpio"
+		    "qcom,pm8058-gpio"
+		    "qcom,pm8917-gpio"
+		    "qcom,pm8921-gpio"
+		    "qcom,spmi-pmic-gpio"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: Register base of the GPIO block and length.
+
+- interrupts:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: Must contain an array of encoded interrupt specifiers for
+		    each available GPIO
+
+- gpio-controller:
+	Usage: required
+	Value type: <none>
+	Definition: Mark the device node as a GPIO controller
+
+- #gpio-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: Must be 2;
+		    the first cell will be used to define gpio number and the
+		    second denotes the flags for this gpio
+
+Please refer to ../gpio/gpio.txt and ../interrupt-controller/interrupts.txt for
+a general description of GPIO and interrupt bindings.
+
+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".
+
+The pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for a
+pin or a list of pins. This configuration can include the
+mux function to select on those pin(s), and various pin configuration
+parameters, as listed below.
+
+
+SUBNODES:
+
+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.
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+
+- pins:
+	Usage: required
+	Value type: <string-array>
+	Definition: List of gpio pins affected by the properties specified in
+		    this subnode.  Valid pins are:
+		    gpio1-gpio6 for pm8018
+		    gpio1-gpio12 for pm8038
+		    gpio1-gpio40 for pm8058
+		    gpio1-gpio38 for pm8917
+		    gpio1-gpio44 for pm8921
+		    gpio1-gpio36 for pm8941
+		    gpio1-gpio22 for pma8084
+
+- function:
+	Usage: required
+	Value type: <string>
+	Definition: Specify the alternative function to be configured for the
+		    specified pins.  Valid values are:
+		    "normal",
+		    "paired",
+		    "func1",
+		    "func2",
+		    "dtest1",
+		    "dtest2",
+		    "dtest3",
+		    "dtest4"
+
+- bias-disable:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configured as no pull.
+
+- bias-pull-down:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configured as pull down.
+
+- bias-pull-up:
+	Usage: optional
+	Value type: <empty>
+	Definition: The specified pins should be configured as pull up.
+
+- qcom,pull-up-strength:
+	Usage: optional
+	Value type: <u32>
+	Definition: Specifies the strength to use for pull up, if selected.
+		    Valid values are; as defined in
+		    <dt-bindings/pinctrl/qcom,pmic-gpio.h>:
+		    1: 30uA                     (PMIC_GPIO_PULL_UP_30)
+		    2: 1.5uA                    (PMIC_GPIO_PULL_UP_1P5)
+		    3: 31.5uA                   (PMIC_GPIO_PULL_UP_31P5)
+		    4: 1.5uA + 30uA boost       (PMIC_GPIO_PULL_UP_1P5_30)
+		    If this property is ommited 30uA strength will be used if
+		    pull up is selected
+
+- bias-high-impedance:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins will put in high-Z mode and disabled.
+
+- input-enable:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are put in input mode.
+
+- output-high:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    high.
+
+- output-low:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    low.
+
+- power-source:
+	Usage: optional
+	Value type: <u32>
+	Definition: Selects the power source for the specified pins. Valid
+		    power sources are defined per chip in
+		    <dt-bindings/pinctrl/qcom,pmic-gpio.h>
+
+- qcom,drive-strength:
+	Usage: optional
+	Value type: <u32>
+	Definition: Selects the drive strength for the specified pins. Value
+		    drive strengths are:
+		    0: no (PMIC_GPIO_STRENGTH_NO)
+		    1: high (PMIC_GPIO_STRENGTH_HIGH) 0.9mA @ 1.8V - 1.9mA @ 2.6V
+		    2: medium (PMIC_GPIO_STRENGTH_MED) 0.6mA @ 1.8V - 1.25mA @ 2.6V
+		    3: low (PMIC_GPIO_STRENGTH_LOW) 0.15mA @ 1.8V - 0.3mA @ 2.6V
+		    as defined in <dt-bindings/pinctrl/qcom,pmic-gpio.h>
+
+- drive-push-pull:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in push-pull mode.
+
+- drive-open-drain:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in open-drain mode.
+
+- drive-open-source:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in open-source mode.
+
+Example:
+
+	pm8921_gpio: gpio@150 {
+		compatible = "qcom,pm8921-gpio";
+		reg = <0x150 0x160>;
+		interrupts = <192 1>, <193 1>, <194 1>,
+			     <195 1>, <196 1>, <197 1>,
+			     <198 1>, <199 1>, <200 1>,
+			     <201 1>, <202 1>, <203 1>,
+			     <204 1>, <205 1>, <206 1>,
+			     <207 1>, <208 1>, <209 1>,
+			     <210 1>, <211 1>, <212 1>,
+			     <213 1>, <214 1>, <215 1>,
+			     <216 1>, <217 1>, <218 1>,
+			     <219 1>, <220 1>, <221 1>,
+			     <222 1>, <223 1>, <224 1>,
+			     <225 1>, <226 1>, <227 1>,
+			     <228 1>, <229 1>, <230 1>,
+			     <231 1>, <232 1>, <233 1>,
+			     <234 1>, <235 1>;
+
+		gpio-controller;
+		#gpio-cells = <2>;
+
+		pm8921_gpio_keys: gpio-keys {
+			volume-keys {
+				pins = "gpio20", "gpio21";
+				function = "normal";
+
+				input-enable;
+				bias-pull-up;
+				drive-push-pull;
+				qcom,drive-strength = <PMIC_GPIO_STRENGTH_NO>;
+				power-source = <PM8921_GPIO_S4>;
+			};
+		};
+	};
include/dt-bindings/pinctrl/qcom,pmic-gpio.h new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH v4 2/4 pinctrl: Device tree bindings for Qualcomm PMIC MPP block

In reply to Ivan T. Ivanov

DeviceTree binding documentation for Qualcomm SPMI PMIC MPP pinctrl drivers.

---
 .../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt  | 159 +++++++++++++++++++++
 include/dt-bindings/pinctrl/qcom,pmic-mpp.h        |  44 ++++++
 2 files changed, 203 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
 create mode 100644 include/dt-bindings/pinctrl/qcom,pmic-mpp.h
Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt new file +159 -0
new file mode 100644
index 0000000..9d4779f
@@ -0,0 +1,159 @@
+Qualcomm PMIC Multi-Purpose Pin (MPP) block
+
+This binding describes the MPP block(s) found in the 8xxx series
+of PMIC's from Qualcomm.
+
+- compatible:
+	Usage: required
+	Value type: <string>
+	Definition: Should contain "qcom,spmi-pmic-mpp"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: Register base of the MPP block and length.
+
+- interrupts:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: Must contain an array of encoded interrupt specifiers for
+		    each available gpio
+
+- gpio-controller:
+	Usage: required
+	Value type: <none>
+	Definition: Mark the device node as a GPIO controller
+
+- #gpio-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: Must be 2;
+		    the first cell will be used to define gpio number and the
+		    second denotes the flags for this gpio
+
+Please refer to ../gpio/gpio.txt and ../interrupt-controller/interrupts.txt for
+a general description of GPIO and interrupt bindings.
+
+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".
+
+The pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for a
+pin or a list of pins. This configuration can include the
+mux function to select on those pin(s), and various pin configuration
+parameters, as listed below.
+
+SUBNODES:
+
+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.
+
+The following generic properties as defined in pinctrl-bindings.txt are valid
+to specify in a pin configuration subnode:
+
+- pins:
+	Usage: required
+	Value type: <string-array>
+	Definition: List of gpio pins affected by the properties specified in
+		    this subnode.  Valid pins are:
+		    mpp1-mpp4 for pm8841
+		    mpp1-mpp8 for pm8941
+		    mpp1-mpp4 for pma8084
+
+- function:
+	Usage: required
+	Value type: <string>
+	Definition: Specify the alternative function to be configured for the
+		    specified pins.  Valid values are:
+		    "normal",
+		    "paired",
+		    "dtest1",
+		    "dtest2",
+		    "dtest3",
+		    "dtest4"
+
+- bias-disable:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins should be configured as no pull.
+
+- bias-pull-up:
+	Usage: optional
+	Value type: <u32>
+	Definition: The specified pins should be configured as pull up.
+		    Valid values are 600, 10000 and 30000 in bidirectional mode only,
+		    i.e. when operating in qcom,analog-mode and input and outputs are
+		    enabled. The hardware ignores the configuration when operating in
+		    other modes.
+
+- bias-high-impedance:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins will put in high-Z mode and disabled.
+
+- input-enable:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are put in input mode, i.e. thier input
+		    buffer is enabled
+
+- output-high:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    high.
+
+- output-low:
+	Usage: optional
+	Value type: <none>
+	Definition: The specified pins are configured in output mode, driven
+		    low.
+
+- power-source:
+	Usage: optional
+	Value type: <u32>
+	Definition: Selects the power source for the specified pins. Valid power
+		    sources are defined in <dt-bindings/pinctrl/qcom,pmic-mpp.h>
+
+- qcom,analog-mode:
+	Usage: optional
+	Value type: <none>
+	Definition: Selects Analog mode of operation: combined with input-enable
+		    and/or output-high, output-log MPP could operate as Bidirectional
+		    Logic, Analog Input, Analog Output.
+
+- qcom,amux-route:
+	Usage: optional
+	Value type: <u32>
+	Definition: Selects the source for analog input. Valid values are
+		    defined in <dt-bindings/pinctrl/qcom,pmic-mpp.h>
+		    PMIC_MPP_AMUX_ROUTE_CH5, PMIC_MPP_AMUX_ROUTE_CH6...
+
+Example:
+
+	mpps@a000 {
+		compatible = "qcom,pm8841-mpp";
+		reg = <0xa000>;
+		gpio-controller;
+		#gpio-cells = <2>;
+		interrupts = <4 0xa0 0 0>, <4 0xa1 0 0>, <4 0xa2 0 0>, <4 0xa3 0 0>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&pm8841_default>;
+
+		pm8841_default: default {
+			gpio {
+				pins = "mpp1", "mpp2", "mpp3", "mpp4";
+				function = "normal";
+				input-enable;
+				power-source = <PM8841_MPP_S3>;
+			};
+		};
+	};
include/dt-bindings/pinctrl/qcom,pmic-mpp.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH v4 3/4 pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver

In reply to Ivan T. Ivanov

This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm GPIO sub-function blocks found in the PMIC chips.

---
 drivers/pinctrl/qcom/Kconfig                  |  12 +
 drivers/pinctrl/qcom/Makefile                 |   1 +
 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c | 942 ++++++++++++++++++++++++++
 3 files changed, 955 insertions(+)
 create mode 100644 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c
drivers/pinctrl/qcom/Kconfig +12 -0
index d160a71..123248f 100644
@@ -39,4 +39,16 @@ config PINCTRL_MSM8X74
 	  This is the pinctrl, pinmux, pinconf and gpiolib driver for the
 	  Qualcomm TLMM block found in the Qualcomm 8974 platform.
 
+config PINCTRL_SPMI_PMIC
+       tristate "Qualcomm SPMI PMIC pin controller driver"
+       depends on GPIOLIB && OF
+       select PINMUX
+       select PINCONF
+       select GENERIC_PINCONF
+       help
+         This is the pinctrl, pinmux, pinconf and gpiolib driver for the
+         Qualcomm GPIO and MPP blocks found in the Qualcomm PMIC's chips,
+         which are using SPMI for communication with SoC. Example PMIC's
+         devices are pm8841, pm8941 and pma8084.
+
 endif
drivers/pinctrl/qcom/Makefile +1 -0
index 2a02602..396130c 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_PINCTRL_APQ8064)	+= pinctrl-apq8064.o
 obj-$(CONFIG_PINCTRL_IPQ8064)	+= pinctrl-ipq8064.o
 obj-$(CONFIG_PINCTRL_MSM8960)	+= pinctrl-msm8960.o
 obj-$(CONFIG_PINCTRL_MSM8X74)	+= pinctrl-msm8x74.o
+obj-$(CONFIG_PINCTRL_SPMI_PMIC)	+= pinctrl-spmi-pmic-gpio.o
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +942 -0

942 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH v4 3/4] pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver

Quoted 4 lines · Ivan T. Ivanov

This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm GPIO sub-function blocks found in the PMIC chips.

I think this looks pretty good, just some minor comments. Mostly on the future compatibility of the Kconfig and compatible.

It's much in line with what I hacked up for pm8xxx, I was just hoping to get something from Thomas regarding irq_read_line() before pushing it again...

Quoted 12 lines
---
 drivers/pinctrl/qcom/Kconfig                  |  12 +
 drivers/pinctrl/qcom/Makefile                 |   1 +
 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c | 942 ++++++++++++++++++++++++++
 3 files changed, 955 insertions(+)
 create mode 100644 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c
drivers/pinctrl/qcom/Kconfig +0 -0
index d160a71..123248f 100644

drivers/pinctrl/qcom/Kconfig config PINCTRL_MSM8X74 · line 42

Quoted 4 lines
drivers/pinctrl/qcom/Kconfig +1 -0
@@ -39,4 +39,16 @@ config PINCTRL_MSM8X74
          This is the pinctrl, pinmux, pinconf and gpiolib driver for the
          Qualcomm TLMM block found in the Qualcomm 8974 platform.
 
+config PINCTRL_SPMI_PMIC

As SPMI is a MIPI specification for doing power management I think it's safe to assume that this is not going to be the only "spmi pmic" pinctrl driver. So please make this a little bit more specific by throwing in a QCOM here.

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c

Quoted 26 lines
drivers/pinctrl/qcom/Kconfig +11 -0
+       tristate "Qualcomm SPMI PMIC pin controller driver"
+       depends on GPIOLIB && OF
+       select PINMUX
+       select PINCONF
+       select GENERIC_PINCONF
+       help
+         This is the pinctrl, pinmux, pinconf and gpiolib driver for the
+         Qualcomm GPIO and MPP blocks found in the Qualcomm PMIC's chips,
+         which are using SPMI for communication with SoC. Example PMIC's
+         devices are pm8841, pm8941 and pma8084.
+
 endif
drivers/pinctrl/qcom/Makefile +1 -0
index 2a02602..396130c 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_PINCTRL_APQ8064)   += pinctrl-apq8064.o
 obj-$(CONFIG_PINCTRL_IPQ8064)  += pinctrl-ipq8064.o
 obj-$(CONFIG_PINCTRL_MSM8960)  += pinctrl-msm8960.o
 obj-$(CONFIG_PINCTRL_MSM8X74)  += pinctrl-msm8x74.o
+obj-$(CONFIG_PINCTRL_SPMI_PMIC)        += pinctrl-spmi-pmic-gpio.o
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +0 -0
new file mode 100644
index 0000000..493f0d3

This is fine, no need to change as we have qcom in the path...

[..]

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 95

Quoted 3 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +3 -0
+
+/**
+ * struct pmic_gpio_pad - keep current GPIO settings

Some indentation in this table would be nice.
Content look sane though.

Quoted 31 lines

+ * @base: Address base in SPMI device.
+ * @irq: IRQ number which this GPIO generate.
+ * @is_enabled: Set to false when GPIO should be put in high Z state.
+ * @out_value: Cached pin output value
+ * @have_buffer: Set to true if GPIO output could be configured in push-pull,
+ * open-drain or open-source mode.
+ * @output_enabled: Set to true if GPIO output logic is enabled.
+ * @input_enabled: Set to true if GPIO input buffer logic is enabled.
+ * @num_sources: Number of power-sources supported by this GPIO.
+ * @power_source: Current power-source used.
+ * @buffer_type: Push-pull, open-drain or open-source.
+ * @pullup: Constant current which flow trough GPIO output buffer.
+ * @strength: No, Low, Medium, High
+ * @function: See pmic_gpio_functions[]
+ */

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +16 -0
+struct pmic_gpio_pad {
+       u16 base;
+       int irq;
+       bool is_enabled;
+       bool out_value;
+       bool have_buffer;
+       bool output_enabled;
+       bool input_enabled;
+       unsigned int num_sources;
+       unsigned int power_source;
+       unsigned int buffer_type;
+       unsigned int pullup;
+       unsigned int strength;
+       unsigned int function;
+};
+

[..]

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 218

Quoted 13 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +13 -0
+
+static int pmic_gpio_parse_dt_config(struct device_node *np,
+                                    struct pinctrl_dev *pctldev,
+                                    unsigned long **configs,
+                                    unsigned int *nconfs)
+{
+       struct pmic_gpio_bindings *par;
+       unsigned long cfg;
+       int ret, i;
+       u32 val;
+
+       for (i = 0; i < ARRAY_SIZE(pmic_gpio_bindings); i++) {
+

Empty line

Quoted 24 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +24 -0
+               par = &pmic_gpio_bindings[i];
+               ret = of_property_read_u32(np, par->property, &val);
+
+               /* property not found */
+               if (ret == -EINVAL)
+                       continue;
+
+               /* use zero as default value */
+               if (ret)
+                       val = 0;
+
+               dev_dbg(pctldev->dev, "found %s with value %u\n",
+                       par->property, val);
+
+               cfg = pinconf_to_config_packed(par->param, val);
+
+               ret = pinctrl_utils_add_config(pctldev, configs, nconfs, cfg);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+

[..]

Quoted 8 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +8 -0
+
+static int pmic_gpio_dt_node_to_map(struct pinctrl_dev *pctldev,
+                                   struct device_node *np_config,
+                                   struct pinctrl_map **map, unsigned *nmaps)
+{
+       enum pinctrl_map_type type;
+       struct device_node *np;
+       unsigned reserv;

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 298

Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +10 -0
+       int ret;
+
+       ret = 0;
+       *map = NULL;
+       *nmaps = 0;
+       reserv = 0;
+       type = PIN_MAP_TYPE_CONFIGS_GROUP;
+
+       for_each_child_of_node(np_config, np) {
+

Empty line

Quoted 17 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +17 -0
+               ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
+                                                       &reserv, nmaps, type);
+               if (ret)
+                       break;
+
+               ret = pmic_gpio_dt_subnode_to_map(pctldev, np, map, &reserv,
+                                                 nmaps, type);
+               if (ret)
+                       break;
+       }
+
+       if (ret < 0)
+               pinctrl_utils_dt_free_map(pctldev, *map, *nmaps);
+
+       return ret;
+}
+

[..]

Quoted 19 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +19 -0
+
+static int pmic_gpio_config_get(struct pinctrl_dev *pctldev,
+                               unsigned int pin, unsigned long *config)
+{
+       unsigned param = pinconf_to_config_param(*config);
+       struct pmic_gpio_pad *pad;
+       unsigned arg;
+
+       pad = pctldev->desc->pins[pin].drv_data;
+
+       switch (param) {
+       case PIN_CONFIG_DRIVE_PUSH_PULL:
+               arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_CMOS;
+               break;
+       case PIN_CONFIG_DRIVE_OPEN_DRAIN:
+               arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS;
+               break;
+       case PIN_CONFIG_DRIVE_OPEN_SOURCE:
+               arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS;

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 411

Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +10 -0
+               break;
+       case PIN_CONFIG_BIAS_PULL_DOWN:
+               arg = pad->pullup == PMIC_GPIO_PULL_DOWN;
+               break;
+       case PIN_CONFIG_BIAS_DISABLE:
+               arg = pad->pullup = PMIC_GPIO_PULL_DISABLE;
+               break;
+       case PIN_CONFIG_BIAS_PULL_UP:
+               arg = pad->pullup == PMIC_GPIO_PULL_UP_30;
+               break;

Extra break;

Quoted 27 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +27 -0
+               break;
+       case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+               arg = !pad->is_enabled;
+               break;
+       case PIN_CONFIG_POWER_SOURCE:
+               arg = pad->power_source;
+               break;
+       case PIN_CONFIG_INPUT_ENABLE:
+               arg = pad->input_enabled;
+               break;
+       case PIN_CONFIG_OUTPUT:
+               arg = pad->out_value;
+               break;
+       case PMIC_GPIO_CONF_PULL_UP:
+               arg = pad->pullup;
+               break;
+       case PMIC_GPIO_CONF_STRENGTH:
+               arg = pad->strength;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       *config = pinconf_to_config_packed(param, arg);
+       return 0;
+}
+

[..]

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 601

Quoted 6 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +6 -0
+static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
+{
+       struct pmic_gpio_state *state;
+       unsigned long config;
+
+       state = container_of(chip, struct pmic_gpio_state, chip);

You use this container_of plenty of times, consider breaking it out to a to_gpio_state() helper function and you can fit it on the declaration line.

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +5 -0
+       config = pinconf_to_config_packed(PIN_CONFIG_INPUT_ENABLE, 1);
+
+       return pmic_gpio_config_set(state->ctrl, pin, &config, 1);
+}
+

[..]

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 674

Quoted 13 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +13 -0
+
+static int pmic_gpio_of_xlate(struct gpio_chip *chip,
+                             const struct of_phandle_args *gpio_desc,
+                             u32 *flags)
+{
+       if (chip->of_gpio_n_cells < 2)
+               return -EINVAL;
+
+       if (flags)
+               *flags = gpio_desc->args[1];
+
+       return gpio_desc->args[0] - PMIC_GPIO_PHYSICAL_OFFSET;
+}

If you change:
gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
to:
gpiochip_add_pin_range(&state->chip, dev_name(dev), 1, 0, npins);

And you treat the gpio functions as taking the gpio number instead of pinctrl number (i.e. subtract 1 in those), then gpiolib will provide this function for you.

[..]

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 921

Quoted 3 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +3 -0
+
+static const struct of_device_id pmic_gpio_of_match[] = {
+       { .compatible = "qcom,spmi-pmic-gpio" },

I think this should be more specific, because hopefully the spmi specification will outlive the current pmic gpio block.

So I think you need to list the pmic blocks here (e.g. "qcom,pm8941-gpio").

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 929

Quoted 8 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +8 -0
+       { },
+};
+
+MODULE_DEVICE_TABLE(of, pmic_gpio_of_match);
+
+static struct platform_driver pmic_gpio_driver = {
+       .driver = {
+                  .name = "spmi-pmic-gpio",

The name should include "qcom" as well, to make it less prone to collisions.

Quoted 1 line

+ .owner = THIS_MODULE,

owner filled in for you by module_platform_driver()

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 938

Quoted 8 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +8 -0
+                  .of_match_table = pmic_gpio_of_match,
+       },
+       .probe  = pmic_gpio_probe,
+       .remove = pmic_gpio_remove,
+};
+
+module_platform_driver(pmic_gpio_driver);
+

Regards,
Bjorn

#5 lore raw

Re: [PATCH v4 3/4] pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver

Quoted 9 lines · Bjorn Andersson
Quoted 4 lines · Ivan T. Ivanov

This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm GPIO sub-function blocks found in the PMIC chips.

I think this looks pretty good, just some minor comments. Mostly on the future compatibility of the Kconfig and compatible.

Thanks.

Quoted 10 lines

It's much in line with what I hacked up for pm8xxx, I was just hoping to get something from Thomas regarding irq_read_line() before pushing it again...

Quoted 6 lines
---
 drivers/pinctrl/qcom/Kconfig                  |  12 +
 drivers/pinctrl/qcom/Makefile                 |   1 +
 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c | 942 ++++++++++++++++++++++++++
 3 files changed, 955 insertions(+)
 create mode 100644 drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c

I am planing to remove pmic part from the file name.

Comments will be fixed in next version.

Thank you.
Ivan

#6 lore raw

Re: [PATCH v4 3/4] pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver

In reply to Bjorn Andersson
Quoted 2 lines · Bjorn Andersson

On Mon 15 Sep 07:44 PDT 2014, Ivan T. Ivanov wrote:

<snip>

Quoted 18 lines

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 674

Quoted 12 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +12 -0
+static int pmic_gpio_of_xlate(struct gpio_chip *chip,
+                             const struct of_phandle_args *gpio_desc,
+                             u32 *flags)
+{
+       if (chip->of_gpio_n_cells < 2)
+               return -EINVAL;
+
+       if (flags)
+               *flags = gpio_desc->args[1];
+
+       return gpio_desc->args[0] - PMIC_GPIO_PHYSICAL_OFFSET;
+}

If you change:
gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
to:
gpiochip_add_pin_range(&state->chip, dev_name(dev), 1, 0, npins);

Quoted 4 lines

And you treat the gpio functions as taking the gpio number instead of pinctrl number (i.e. subtract 1 in those), then gpiolib will provide this function for you.

I am unable to make this work. of_gpio_simple_xlate() didn't know that GPIO range is offset with 1. Requesting last GPIO return error. And debug output looks weird, for example:

# cat /sys/kernel/debug/gpio
...
GPIOs 220-255, platform/0.c000.gpios, 0.c000.gpios:
...
# cat /sys/kernel/debug/pinctrl/0.c000.gpios/gpio-ranges 
GPIO ranges handled:
1: 0.c000.gpios GPIOS [221 - 256] PINS [0 - 35]

Advice, please.

Quoted 9 lines

[..]

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 921

Quoted 3 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +3 -0
+
+static const struct of_device_id pmic_gpio_of_match[] = {
+       { .compatible = "qcom,spmi-pmic-gpio" },

I think this should be more specific, because hopefully the spmi specification will outlive the current pmic gpio block.

So I think you need to list the pmic blocks here (e.g. "qcom,pm8941-gpio").

I can rename this to lovely "qcom,qpnp-gpio" :-), in this way driver can outlive bus on which device is connected this time.

Regards,
Ivan

#7 lore raw

Re: [PATCH v4 3/4] pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver

Quoted 38 lines · Ivan T. Ivanov
Quoted 2 lines · Bjorn Andersson

On Mon 15 Sep 07:44 PDT 2014, Ivan T. Ivanov wrote:

<snip>

Quoted 18 lines

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 674

Quoted 12 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +12 -0
+static int pmic_gpio_of_xlate(struct gpio_chip *chip,
+                             const struct of_phandle_args *gpio_desc,
+                             u32 *flags)
+{
+       if (chip->of_gpio_n_cells < 2)
+               return -EINVAL;
+
+       if (flags)
+               *flags = gpio_desc->args[1];
+
+       return gpio_desc->args[0] - PMIC_GPIO_PHYSICAL_OFFSET;
+}

If you change:
gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
to:
gpiochip_add_pin_range(&state->chip, dev_name(dev), 1, 0, npins);

Quoted 4 lines

And you treat the gpio functions as taking the gpio number instead of pinctrl number (i.e. subtract 1 in those), then gpiolib will provide this function for you.

I am unable to make this work. of_gpio_simple_xlate() didn't know that GPIO range is offset with 1. Requesting last GPIO return error. And debug output looks weird, for example:

# cat /sys/kernel/debug/gpio
...
GPIOs 220-255, platform/0.c000.gpios, 0.c000.gpios:
...
Quoted 6 lines
# cat /sys/kernel/debug/pinctrl/0.c000.gpios/gpio-ranges 
GPIO ranges handled:
1: 0.c000.gpios GPIOS [221 - 256] PINS [0 - 35]

Advice, please.

Looking at of_gpio_simple_xlate() shows that you're right. It doesn't seem to be possible to have a gpiochip that is not 0-based. Then I guess you have to have your own "off-by-one-xlate".

@Linus, any comments on this? All documentation states that we have gpio1-gpioXX in these chips, so we have to expose it as such or things will be messy.

Quoted 8 lines
Quoted 8 lines

[..]

drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c line 921

Quoted 3 lines
drivers/pinctrl/qcom/pinctrl-spmi-pmic-gpio.c new file +3 -0
+
+static const struct of_device_id pmic_gpio_of_match[] = {
+       { .compatible = "qcom,spmi-pmic-gpio" },

I think this should be more specific, because hopefully the spmi specification will outlive the current pmic gpio block.

Quoted 5 lines
Quoted 1 line

So I think you need to list the pmic blocks here (e.g. "qcom,pm8941-gpio").

I can rename this to lovely "qcom,qpnp-gpio" :-), in this way driver can outlive bus on which device is connected this time.

If the mythical qpnp spec actually include a specification for how a gpio block looks like then sure. Otherwise you would have to list all the pmics that contain this block.

Regards,
Bjorn

#8 lore raw

Re: [PATCH v4 3/4] pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver

Quoted 17 lines · Bjorn Andersson
Quoted 9 lines · Ivan T. Ivanov

I am unable to make this work. of_gpio_simple_xlate() didn't know that GPIO range is offset with 1. Requesting last GPIO return error. And debug output looks weird, for example:

# cat /sys/kernel/debug/gpio
...
GPIOs 220-255, platform/0.c000.gpios, 0.c000.gpios:
...
Quoted 5 lines
# cat /sys/kernel/debug/pinctrl/0.c000.gpios/gpio-ranges
GPIO ranges handled:
1: 0.c000.gpios GPIOS [221 - 256] PINS [0 - 35]

Advice, please.

Quoted 7 lines

Looking at of_gpio_simple_xlate() shows that you're right. It doesn't seem to be possible to have a gpiochip that is not 0-based. Then I guess you have to have your own "off-by-one-xlate".

@Linus, any comments on this? All documentation states that we have gpio1-gpioXX in these chips, so we have to expose it as such or things will be messy.

I remember that drivers/pinctrl/nomadik/pinctrl-abx500.c had the same problem, but I don't remember how we solved it sadly :-/

Yours,
Linus Walleij

#9 lore raw

PATCH v4 4/4 pinctrl: Qualcomm SPMI PMIC MPP pin controller driver

In reply to Ivan T. Ivanov

This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm MPP sub-function blocks found in the PMIC chips.

---
 drivers/pinctrl/qcom/Makefile                |   1 +
 drivers/pinctrl/qcom/pinctrl-spmi-pmic-mpp.c | 956 +++++++++++++++++++++++++++
 2 files changed, 957 insertions(+)
 create mode 100644 drivers/pinctrl/qcom/pinctrl-spmi-pmic-mpp.c
drivers/pinctrl/qcom/Makefile +1 -0
index 396130c..1c3d14c 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_PINCTRL_IPQ8064)	+= pinctrl-ipq8064.o
 obj-$(CONFIG_PINCTRL_MSM8960)	+= pinctrl-msm8960.o
 obj-$(CONFIG_PINCTRL_MSM8X74)	+= pinctrl-msm8x74.o
 obj-$(CONFIG_PINCTRL_SPMI_PMIC)	+= pinctrl-spmi-pmic-gpio.o
+obj-$(CONFIG_PINCTRL_SPMI_PMIC)	+= pinctrl-spmi-pmic-mpp.o
drivers/pinctrl/qcom/pinctrl-spmi-pmic-mpp.c new file +956 -0

956 lines not on this page · raw message

Signature · 1 line
1.9.1
#10 lore raw
In reply to Ivan T. Ivanov
Quoted 1 line · Ivan T. Ivanov

This is forth version of the patches posted earlier here[1].

I mainly want you and Björn to cross-ACK each others' patches and then I'm ready to merge this.

Björn are these 4 patches OK with you?

Yours,
Linus Walleij