Skip to contentSkip to conversation

pinctrl: tegra: Add support for IO pad control

PATCH Superseded Laxman Dewangan 2 participants 7 messages Nov 22, 2016 – Nov 24, 2016

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover pinctrl: tegra: Add support for IO pad control

NVIDIA Tegra124 and later SoCs support the multi-voltage level and low power state of some of its IO pads. The IO pads can work in the voltage of the 1.8V and 3.3V of IO power rail sources. When IO interface are not used then IO pads can be configure in low power state to reduce the power from that IO pads.

This series add the support of configuration of IO pad via pinctrl framework. The io pad driver uses the tegra PMC interface.

---
This driver was sent earlier for review along with soc/tegra pmc changes. During review, decided to first conclude in soc/tegra pmc patches and then review this.

Thierry applied the pmc patches in the private tree
https://github.com/thierryreding/linux/tree/tegra186
and he wanted to have the patches for user of the new APIs so that it can be pushed to mainline.

Sending the pinctrl driver. This needs Ack/reviewed from pinctrl subsystem i.e. Linus Welleij to apply in the Thierry's T186 branch along with PMC patches.

---
Changes from V1:
- use the regulator framework to get the IO voltage instead of table from DT. The regulator handle is provided from DT.

Changes from V2:
- Nit fixes and variable/allocation optimisation as per review comment from V2.

Laxman Dewangan (2):
pinctrl: tegra: Add DT binding for io pads control
pinctrl: tegra: Add driver to configure voltage and power of io pads

 .../bindings/pinctrl/nvidia,tegra-io-pad.txt       | 126 +++++
 drivers/pinctrl/tegra/Kconfig                      |  12 +
 drivers/pinctrl/tegra/Makefile                     |   1 +
 drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c       | 530 +++++++++++++++++++++
 4 files changed, 669 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nvidia,tegra-io-pad.txt
 create mode 100644 drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c
Signature · 1 line
2.1.4
#1 lore raw

PATCH v3 1/2 pinctrl: tegra: Add DT binding for io pads control

NVIDIA Tegra124 and later SoCs support the multi-voltage level and low power state of some of its IO pads. The IO pads can work in the voltage of the 1.8V and 3.3V of IO voltage from IO power rail sources. When IO interfaces are not used then IO pads can be configure in low power state to reduce the power consumption from that IO pads.

On Tegra124, the voltage level of IO power rail source is auto detected by hardware(SoC) and hence it is only require to configure in low power mode if IO pads are not used.

On T210 onwards, the auto-detection of voltage level from IO power rail is removed from SoC and hence SW need to configure the PMC register explicitly to set proper voltage in IO pads based on IO rail power source voltage.

Add DT binding document for detailing the DT properties for configuring IO pads voltage levels and its power state.

---
Changes from V1:
New in series based on pinctrl driver requirement.

Changes from V2:
Updated the statement to say 1.8V and 3.3V as nominal voltage. Corrected DT example by adding -supply and taken care of V2 review from Rob.

---
 .../bindings/pinctrl/nvidia,tegra-io-pad.txt       | 126 +++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/nvidia,tegra-io-pad.txt
Documentation/devicetree/bindings/pinctrl/nvidia,tegra-io-pad.txt new file +126 -0
new file mode 100644
index 0000000..a88c484
@@ -0,0 +1,126 @@
+NVIDIA Tegra PMC IO pad controller
+
+NVIDIA Tegra124 and later SoCs support the multi-voltage level and low power
+state of some of its IO pads. When IO interface are not used then IO pads can
+be configure in low power state to reduce the power from that IO pads. The IO
+pads can work in the nominal IO voltage of 1.8V and 3.3V from power rail
+sources.
+
+On Tegra124, the voltage of IO power rail source is auto detected by SoC and
+hence it is only require to configure in low power mode if IO pads are not
+used.
+
+On T210 onwards, the HW based auto-detection for IO voltage is removed and
+hence SW need to configure the PMC register explicitly, to set proper voltage
+in IO pads, based on IO rail power source voltage.
+
+The voltage configurations and low power state of IO pads should be done in
+boot if it is not going to change otherwise dynamically based on IO rail
+voltage on that IO pads and usage of IO pads
+
+The DT property of the IO pads must be under the node of pmc i.e.
+pmc@7000e400 for Tegra124 onwards.
+
+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".
+
+Tegra's pin configuration nodes act as a container for an arbitrary number of
+subnodes. Each of these subnodes represents some desired configuration for an
+IO pads, or a list of IO pads. This configuration can include the voltage and
+power enable/disable control
+
+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. Unspecified is represented as an absent
+property,
+
+See the TRM to determine which properties and values apply to each IO pads.
+
+Required subnode-properties:
+==========================
+- pins : An array of strings. Each string contains the name of an IO pads. Valid
+	 values for these names are listed below.
+
+Optional subnode-properties:
+==========================
+Following properties are supported from generic pin configuration explained
+in <dt-bindings/pinctrl/pinctrl-binding.txt>.
+low-power-enable:		enable low power mode.
+low-power-disable:		disable low power mode.
+
+Valid values for pin for T124 are:
+	audio, bb, cam, comp, csia, csib, csie, dsi, dsib, dsic, dsid, hdmi,
+	hsic, hv, lvds, mipi-bias, nand, pex-bias, pex-clk1, pex-clk2,
+	pex-ctrl, sdmmc1, sdmmc3, sdmmc4, sys-ddc, uart, usb0, usb1, usb2,
+	usb-bias
+
+Valid values for pin for T210 are:
+	audio, audio-hv, cam, csia, csib, csic, csid, csie, csif,
+	dbg, debug-nonao, dmic, dp, dsi, dsib, dsic, dsid, emmc, emmc2,
+	gpio, hdmi, hsic, lvds, mipi-bias, pex-bias, pex-clk1, pex-clk2,
+	pex-ctrl, sdmmc1, sdmmc3, spi, spi-hv, uart, usb-bias, usb0,
+	usb1, usb2, usb3.
+
+To find out the IO rail voltage for setting the voltage of IO pad by SW,
+the regulator supply handle must provided from the DT and it is explained
+in the regulator DT binding document
+	<devicetree/bindings/regulator/regulator.txt>.
+For example, for GPIO rail the supply name is vddio-gpio and regulator
+handle is supplied from DT as
+	vddio-gpio-supply = <&regulator_xyz>;
+
+For T210, following IO pads support the 1.8V/3.3V and the corresponding
+IO voltage pin names are as follows:
+	audio -> vddio-audio
+	audio-hv -> vddio-audio-hv
+	cam ->vddio-cam
+	dbg -> vddio-dbg
+	dmic -> vddio-dmic
+	gpio -> vddio-gpio
+	pex-ctrl -> vddio-pex-ctrl
+	sdmmc1 -> vddio-sdmmc1
+	sdmmc3 -> vddio-sdmmc3
+	spi -> vddio-spi
+	spi-hv -> vddio-spi-hv
+	uart -> vddio-uart
+
+Example:
+	i2c@7000d000 {
+		pmic@3c {
+			regulators {
+				vddio_sdmmc1: ldo2 {
+					/* Regulator entries for LDO2 */
+				};
+
+				vdd_cam: ldo3 {
+					/* Regulator entries for LDO3 */
+				};
+			};
+		};
+	};
+
+	pmc@7000e400 {
+		vddio-cam-supply = <&vdd_cam>;
+		vddio-sdmmc1-supply = <&vddio_sdmmc1>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&tegra_io_pad_volt_default>;
+		tegra_io_pad_volt_default: common {
+			audio-hv {
+				pins = "audio-hv";
+				low-power-disable;
+			};
+
+			gpio {
+				pins = "gpio";
+				low-power-disable;
+			};
+
+			audio {
+				pins = "audio", "dmic", "sdmmc3";
+				low-power-enable;
+			};
+		};
+
+	};
Signature · 1 line
2.1.4
#2 lore raw

PATCH v3 2/2 pinctrl: tegra: Add driver to configure voltage and power of io pads

In reply to Laxman Dewangan

NVIDIA Tegra124 and later SoCs support the multi-voltage level and low power state of some of its IO pads. The IO pads can work in the voltage of the 1.8V and 3.3V of IO voltage from IO power rail sources. When IO interfaces are not used then IO pads can be configure in low power state to reduce the power consumption from that IO pads.

On Tegra124, the voltage level of IO power rail source is auto detected by hardware(SoC) and hence it is only require to configure in low power mode if IO pads are not used.

On T210 onwards, the auto-detection of voltage level from IO power rail is removed from SoC and hence SW need to configure the PMC register explicitly to set proper voltage in IO pads based on IO rail power source voltage.

This driver adds the IO pad driver to configure the power state and IO pad voltage based on the usage and power tree via pincontrol framework. The configuration can be static and dynamic.

---
Changes from V1:
- Dropped the custom properties to set pad voltage and use regulator.
- Added support for regulator to get vottage in boot and configure IO pad voltage.
- Add support for callback to handle regulator notification and configure IO pad voltage based on voltage change.

Changes from V2:
Mostly nit changes per Jon's feedback i.e. use macros for voltage, added comment on macros, reduce the structure and variable name size, optimise number of variables, and allocate memory for regulator info when it needed.

---
 drivers/pinctrl/tegra/Kconfig                |  12 +
 drivers/pinctrl/tegra/Makefile               |   1 +
 drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c | 530 +++++++++++++++++++++++++++
 3 files changed, 543 insertions(+)
 create mode 100644 drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c
drivers/pinctrl/tegra/Kconfig +12 -0
index 24e20cc..6004e5c 100644
@@ -23,6 +23,18 @@ config PINCTRL_TEGRA210
 	bool
 	select PINCTRL_TEGRA
 
+config PINCTRL_TEGRA_IO_PAD
+	bool "Tegra IO pad Control Driver"
+	depends on ARCH_TEGRA && REGULATOR
+	select PINCONF
+	select PINMUX
+	help
+	  NVIDIA Tegra124/210 SoC has IO pads which supports multi-voltage
+	  level of interfacing and deep power down mode of IO pads. The
+	  voltage of IO pads are SW configurable based on IO rail of that
+	  pads on T210. This driver provides the interface to change IO pad
+	  voltage and power state via pincontrol interface.
+
 config PINCTRL_TEGRA_XUSB
 	def_bool y if ARCH_TEGRA
 	select GENERIC_PHY
drivers/pinctrl/tegra/Makefile +1 -0
index d9ea2be..3ebaaa2 100644
@@ -4,4 +4,5 @@ obj-$(CONFIG_PINCTRL_TEGRA30)		+= pinctrl-tegra30.o
 obj-$(CONFIG_PINCTRL_TEGRA114)		+= pinctrl-tegra114.o
 obj-$(CONFIG_PINCTRL_TEGRA124)		+= pinctrl-tegra124.o
 obj-$(CONFIG_PINCTRL_TEGRA210)		+= pinctrl-tegra210.o
+obj-$(CONFIG_PINCTRL_TEGRA_IO_PAD)	+= pinctrl-tegra-io-pad.o
 obj-$(CONFIG_PINCTRL_TEGRA_XUSB)	+= pinctrl-tegra-xusb.o
drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c new file +530 -0

530 lines not on this page · raw message

Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Re: [PATCH V3 2/2] pinctrl: tegra: Add driver to configure voltage and power of io pads

Quoted 16 lines · Laxman Dewangan

NVIDIA Tegra124 and later SoCs support the multi-voltage level and low power state of some of its IO pads. The IO pads can work in the voltage of the 1.8V and 3.3V of IO voltage from IO power rail sources. When IO interfaces are not used then IO pads can be configure in low power state to reduce the power consumption from that IO pads.

On Tegra124, the voltage level of IO power rail source is auto detected by hardware(SoC) and hence it is only require to configure in low power mode if IO pads are not used.

On T210 onwards, the auto-detection of voltage level from IO power rail is removed from SoC and hence SW need to configure the PMC register explicitly to set proper voltage in IO pads based on IO rail power source voltage.

Quoted 5 lines

This driver adds the IO pad driver to configure the power state and IO pad voltage based on the usage and power tree via pincontrol framework. The configuration can be static and dynamic.

Overall very nice!

drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c line 336

Quoted 2 lines
drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c new file +2 -0
+               rinfo->regulator = devm_regulator_get_optional(dev,
+                                               soc_data->cfg[i].vsupply);

Please just use devm_regulator_get().

As has been discussed at lenth elsewhere "optional" in regulator_get_optional does *not* mean "software optional", it means "hardware optional".

Such as a terminal that may have a voltage connected or not be connected to anything at all.

If the system does not define a regulator you will anyway get a dummy regulator.

Yours,
Linus Walleij

#4 lore raw

Re: [PATCH V3 2/2] pinctrl: tegra: Add driver to configure voltage and power of io pads

Quoted 6 lines · Linus Walleij

drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c line 336

Quoted 2 lines · Laxman Dewangan
drivers/pinctrl/tegra/pinctrl-tegra-io-pad.c new file +2 -0
+               rinfo->regulator = devm_regulator_get_optional(dev,
+                                               soc_data->cfg[i].vsupply);

Please just use devm_regulator_get().

Quoted 9 lines

As has been discussed at lenth elsewhere "optional" in regulator_get_optional does *not* mean "software optional", it means "hardware optional".

Such as a terminal that may have a voltage connected or not be connected to anything at all.

If the system does not define a regulator you will anyway get a dummy regulator.

The issue with dummy regulator is that the other regulator APIs with dummy regulator fails.
Once we get the dummy regulator, there is no way to know whether the returned regulator is actual or dummy and when calling the regulator_get_voltage() it failed.

[    2.917176] pinctrl-t210-io-pad.0 supply vddio-audio-hv not found, using dummy regulator
[    2.925510] pinctrl-tegra-io-pad pinctrl-t210-io-pad.0: Failed to get voltage for rail vddio-aud2

Here, we need the regulator handle which can support the other regulator APIs.

In some of platforms, we do not use some of the io-pins and on this case, we do not connect the IO rail supply for these pins. So this is like a hardware optional.

If the IO pins are used then it need to have the proper regulator handle. Missing regulator handle on DT will be like that IO pads are not used.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH V3 2/2] pinctrl: tegra: Add driver to configure voltage and power of io pads

Quoted 9 lines · Laxman Dewangan

Here, we need the regulator handle which can support the other regulator APIs.

In some of platforms, we do not use some of the io-pins and on this case, we do not connect the IO rail supply for these pins. So this is like a hardware optional.

If the IO pins are used then it need to have the proper regulator handle. Missing regulator handle on DT will be like that IO pads are not used.

OK I buy that argument, unless Mark (Brown) has comments.

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH V3 2/2] pinctrl: tegra: Add driver to configure voltage and power of io pads

Quoted 5 lines · Linus Walleij
Quoted 3 lines · Laxman Dewangan

Here, we need the regulator handle which can support the other regulator APIs.

Quoted 8 lines
Quoted 6 lines

In some of platforms, we do not use some of the io-pins and on this case, we do not connect the IO rail supply for these pins. So this is like a hardware optional.

If the IO pins are used then it need to have the proper regulator handle. Missing regulator handle on DT will be like that IO pads are not used.

OK I buy that argument, unless Mark (Brown) has comments.

BTW, I resolved this in different way in V4 which I sent today, if regulator_get() succeed for dummy then regulator_get_voltage() failed and if it failed then assume that it is dummy and just ignore the further handling based on regulator.

So when we really need the configuration based on voltage, we must supply the regulator handle.