Skip to contentSkip to conversation

phy: tegra: xusb: Add Tegra186 support

PATCH Superseded Thierry Reding 3 participants 8 messages Feb 21, 2019 – Mar 18, 2019

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

v2 cover phy: tegra: xusb: Add Tegra186 support

From: Thierry Reding <[email protected]>

This series adds support for Tegra186 to the XUSB pad controller driver. Patch 1 extends the device tree bindings with support for Tegra186 while patches 2-4 are preparatory work for the final patch 5 that adds the Tegra186 specific programming for the UPHY blocks.

Changes in v2:
- address review comments from Kishon
- added Reviewed-by tags from JC

Thierry

JC Kuo (2):
phy: tegra: xusb: Skip single function lane programming
phy: tegra: xusb: Add Tegra186 support

Thierry Reding (3):
dt-bindings: phy: tegra: Add Tegra186 support
phy: tegra: xusb: Parse dual-role mode property
phy: tegra: xusb: Add support for power supplies

 .../phy/nvidia,tegra124-xusb-padctl.txt       |   9 +
 MAINTAINERS                                   |   5 +
 drivers/phy/tegra/Makefile                    |   1 +
 drivers/phy/tegra/xusb-tegra186.c             | 899 ++++++++++++++++++
 drivers/phy/tegra/xusb.c                      |  67 +-
 drivers/phy/tegra/xusb.h                      |  35 +
 6 files changed, 1014 insertions(+), 2 deletions(-)
 create mode 100644 drivers/phy/tegra/xusb-tegra186.c
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/5 dt-bindings: phy: tegra: Add Tegra186 support

From: Thierry Reding <[email protected]>

Extend the bindings to cover the set of features found in Tegra186. Note that, technically, there are four more supplies connected to the XUSB pad controller (DVDD_PEX, DVDD_PEX_PLL, HVDD_PEX and HVDD_PEX_PLL), but the power sequencing requirements of Tegra186 require these to be under the control of the PMIC.

---
 .../bindings/phy/nvidia,tegra124-xusb-padctl.txt         | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.txt +9 -0
index 3742c152c467..daedb15f322e 100644
@@ -36,11 +36,20 @@ Required properties:
   - Tegra124: "nvidia,tegra124-xusb-padctl"
   - Tegra132: "nvidia,tegra132-xusb-padctl", "nvidia,tegra124-xusb-padctl"
   - Tegra210: "nvidia,tegra210-xusb-padctl"
+  - Tegra186: "nvidia,tegra186-xusb-padctl"
 - reg: Physical base address and length of the controller's registers.
 - resets: Must contain an entry for each entry in reset-names.
 - reset-names: Must include the following entries:
   - "padctl"
 
+For Tegra186:
+- avdd-pll-erefeut-supply: UPHY brick and reference clock as well as UTMI PHY
+  power supply. Must supply 1.8 V.
+- avdd-usb-supply: USB I/Os, VBUS, ID, REXT, D+/D- power supply. Must supply
+  3.3 V.
+- vclamp-usb-supply: Bias rail for USB pad. Must supply 1.8 V.
+- vddio-hsic-supply: HSIC PHY power supply. Must supply 1.2 V.
+
 
 Pad nodes:
 ==========
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] dt-bindings: phy: tegra: Add Tegra186 support

Quoted 8 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Extend the bindings to cover the set of features found in Tegra186. Note that, technically, there are four more supplies connected to the XUSB pad controller (DVDD_PEX, DVDD_PEX_PLL, HVDD_PEX and HVDD_PEX_PLL), but the power sequencing requirements of Tegra186 require these to be under the control of the PMIC.

Quoted 6 lines
---
 .../bindings/phy/nvidia,tegra124-xusb-padctl.txt         | 9 +++++++++
 1 file changed, 9 insertions(+)
#3 lore raw

PATCH v2 2/5 phy: tegra: xusb: Skip single function lane programming

In reply to Thierry Reding

From: JC Kuo <[email protected]>

Tegra186 USB2 pads and USB3 pads do not have hardware mux for changing the pad function. For such "lanes", we can skip the lane mux register programming.

---
 drivers/phy/tegra/xusb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/phy/tegra/xusb.c +5 -1
index 5b3b8863363e..e3bc60cfe6a1 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2014-2016, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -313,6 +313,10 @@ static void tegra_xusb_lane_program(struct tegra_xusb_lane *lane)
 	const struct tegra_xusb_lane_soc *soc = lane->soc;
 	u32 value;
 
+	/* skip single function lanes */
+	if (soc->num_funcs < 2)
+		return;
+
 	/* choose function */
 	value = padctl_readl(padctl, soc->offset);
 	value &= ~(soc->mask << soc->shift);
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 3/5 phy: tegra: xusb: Parse dual-role mode property

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

The device tree bindings document the "mode" property of "ports" subnodes, but the driver was not parsing the property. In preparation for adding role switching, parse the property at probe time.

Based on work by JC Kuo <[email protected]>.

---
 drivers/phy/tegra/xusb.c | 21 +++++++++++++++++++++
 drivers/phy/tegra/xusb.h |  3 +++
 2 files changed, 24 insertions(+)
drivers/phy/tegra/xusb.c +21 -0
index e3bc60cfe6a1..57a2d08ef6da 100644
@@ -546,13 +546,34 @@ static void tegra_xusb_port_unregister(struct tegra_xusb_port *port)
 	device_unregister(&port->dev);
 }
 
+static const char *const modes[] = {
+	[USB_DR_MODE_UNKNOWN] = "",
+	[USB_DR_MODE_HOST] = "host",
+	[USB_DR_MODE_PERIPHERAL] = "peripheral",
+	[USB_DR_MODE_OTG] = "otg",
+};
+
 static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)
 {
 	struct tegra_xusb_port *port = &usb2->base;
 	struct device_node *np = port->dev.of_node;
+	const char *mode;
 
 	usb2->internal = of_property_read_bool(np, "nvidia,internal");
 
+	if (!of_property_read_string(np, "mode", &mode)) {
+		int err = match_string(modes, ARRAY_SIZE(modes), mode);
+		if (err < 0) {
+			dev_err(&port->dev, "invalid value %s for \"mode\"\n",
+				mode);
+			usb2->mode = USB_DR_MODE_UNKNOWN;
+		} else {
+			usb2->mode = err;
+		}
+	} else {
+		usb2->mode = USB_DR_MODE_HOST;
+	}
+
 	usb2->supply = devm_regulator_get(&port->dev, "vbus");
 	return PTR_ERR_OR_ZERO(usb2->supply);
 }
drivers/phy/tegra/xusb.h +3 -0
index b49dbc36efa3..bb60fc09c752 100644
@@ -19,6 +19,8 @@
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
 
+#include <linux/usb/otg.h>
+
 /* legacy entry points for backwards-compatibility */
 int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev);
 int tegra_xusb_padctl_legacy_remove(struct platform_device *pdev);
@@ -271,6 +273,7 @@ struct tegra_xusb_usb2_port {
 	struct tegra_xusb_port base;
 
 	struct regulator *supply;
+	enum usb_dr_mode mode;
 	bool internal;
 };
 
Signature · 1 line
2.20.1
#5 lore raw

PATCH v2 4/5 phy: tegra: xusb: Add support for power supplies

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Support enabling various supplies needed to provide power to the PLLs and logic used to drive the USB, PCI and SATA pads.

---
 drivers/phy/tegra/xusb.c | 34 +++++++++++++++++++++++++++++++++-
 drivers/phy/tegra/xusb.h |  5 +++++
 2 files changed, 38 insertions(+), 1 deletion(-)
drivers/phy/tegra/xusb.c +33 -1
index 57a2d08ef6da..e510629f4f1c 100644
@@ -864,6 +864,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 	struct tegra_xusb_padctl *padctl;
 	const struct of_device_id *match;
 	struct resource *res;
+	unsigned int i;
 	int err;
 
 	/* for backwards compatibility with old device trees */
@@ -901,14 +902,38 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 		goto remove;
 	}
 
+	padctl->supplies = devm_kcalloc(&pdev->dev, padctl->soc->num_supplies,
+					sizeof(*padctl->supplies), GFP_KERNEL);
+	if (!padctl->supplies) {
+		err = -ENOMEM;
+		goto remove;
+	}
+
+	for (i = 0; i < padctl->soc->num_supplies; i++)
+		padctl->supplies[i].supply = padctl->soc->supply_names[i];
+
+	err = devm_regulator_bulk_get(&pdev->dev, padctl->soc->num_supplies,
+				      padctl->supplies);
+	if (err < 0) {
+		dev_err(&pdev->dev, "failed to get regulators: %d\n", err);
+		goto remove;
+	}
+
 	err = reset_control_deassert(padctl->rst);
 	if (err < 0)
 		goto remove;
 
+	err = regulator_bulk_enable(padctl->soc->num_supplies,
+				    padctl->supplies);
+	if (err < 0) {
+		dev_err(&pdev->dev, "failed to enable supplies: %d\n", err);
+		goto reset;
+	}
+
 	err = tegra_xusb_setup_pads(padctl);
 	if (err < 0) {
 		dev_err(&pdev->dev, "failed to setup pads: %d\n", err);
-		goto reset;
+		goto power_down;
 	}
 
 	err = tegra_xusb_setup_ports(padctl);
@@ -921,6 +946,8 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 
 remove_pads:
 	tegra_xusb_remove_pads(padctl);
+power_down:
+	regulator_bulk_disable(padctl->soc->num_supplies, padctl->supplies);
 reset:
 	reset_control_assert(padctl->rst);
 remove:
@@ -936,6 +963,11 @@ static int tegra_xusb_padctl_remove(struct platform_device *pdev)
 	tegra_xusb_remove_ports(padctl);
 	tegra_xusb_remove_pads(padctl);
 
+	err = regulator_bulk_disable(padctl->soc->num_supplies,
+				     padctl->supplies);
+	if (err < 0)
+		dev_err(&pdev->dev, "failed to disable supplies: %d\n", err);
+
 	err = reset_control_assert(padctl->rst);
 	if (err < 0)
 		dev_err(&pdev->dev, "failed to assert reset: %d\n", err);
drivers/phy/tegra/xusb.h +5 -0
index bb60fc09c752..5d5d22f6cb41 100644
@@ -370,6 +370,9 @@ struct tegra_xusb_padctl_soc {
 	} ports;
 
 	const struct tegra_xusb_padctl_ops *ops;
+
+	const char * const *supply_names;
+	unsigned int num_supplies;
 };
 
 struct tegra_xusb_padctl {
@@ -393,6 +396,8 @@ struct tegra_xusb_padctl {
 	unsigned int enable;
 
 	struct clk *clk;
+
+	struct regulator_bulk_data *supplies;
 };
 
 static inline void padctl_writel(struct tegra_xusb_padctl *padctl, u32 value,
Signature · 1 line
2.20.1
#6 lore raw

PATCH v2 5/5 phy: tegra: xusb: Add Tegra186 support

In reply to Thierry Reding

From: JC Kuo <[email protected]>

Add support for the XUSB pad controller found on Tegra186 SoCs. It is mostly similar to the same IP found on earlier chips, but the number of pads exposed differs, as do the programming sequences.

Note that the DVDD_PEX, DVDD_PEX_PLL, HVDD_PEX and HVDD_PEX_PLL power supplies of the XUSB pad controller require strict power sequencing and are therefore controlled by the PMIC on Tegra186.

---
Changes in v2:
- use SPDX-License-Identifier and remove license text
- remove unnecessary parentheses
- use BIT() where appropriate

 MAINTAINERS                       |   5 +
 drivers/phy/tegra/Makefile        |   1 +
 drivers/phy/tegra/xusb-tegra186.c | 899 ++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.c          |   6 +
 drivers/phy/tegra/xusb.h          |  27 +
 5 files changed, 938 insertions(+)
 create mode 100644 drivers/phy/tegra/xusb-tegra186.c
MAINTAINERS +5 -0
index 8b53eb3db271..183283ea7ea1 100644
@@ -15274,6 +15274,11 @@ M:	Laxman Dewangan <[email protected]>
 S:	Supported
 F:	drivers/spi/spi-tegra*
 
+TEGRA XUSB PADCTL DRIVER
+M:	JC Kuo <[email protected]>
+S:	Supported
+F:	drivers/phy/tegra/xusb*
+
 TEHUTI ETHERNET DRIVER
 M:	Andy Gospodarek <[email protected]>
 L:	[email protected]
drivers/phy/tegra/Makefile +1 -0
index 898589238fd9..a93cd9a499b2 100644
@@ -4,3 +4,4 @@ phy-tegra-xusb-y += xusb.o
 phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_124_SOC) += xusb-tegra124.o
 phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_132_SOC) += xusb-tegra124.o
 phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_210_SOC) += xusb-tegra210.o
+phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_186_SOC) += xusb-tegra186.o
drivers/phy/tegra/xusb-tegra186.c new file +899 -0

899 lines not on this page · raw message

drivers/phy/tegra/xusb.c +6 -0
index e510629f4f1c..0417213ed68b 100644
@@ -67,6 +67,12 @@ static const struct of_device_id tegra_xusb_padctl_of_match[] = {
 		.compatible = "nvidia,tegra210-xusb-padctl",
 		.data = &tegra210_xusb_padctl_soc,
 	},
+#endif
+#if defined(CONFIG_ARCH_TEGRA_186_SOC)
+	{
+		.compatible = "nvidia,tegra186-xusb-padctl",
+		.data = &tegra186_xusb_padctl_soc,
+	},
 #endif
 	{ }
 };
drivers/phy/tegra/xusb.h +27 -0
index 5d5d22f6cb41..e0028b9fe702 100644
@@ -56,10 +56,21 @@ struct tegra_xusb_lane {
 int tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane,
 			     struct device_node *np);
 
+struct tegra_xusb_usb3_lane {
+	struct tegra_xusb_lane base;
+};
+
+static inline struct tegra_xusb_usb3_lane *
+to_usb3_lane(struct tegra_xusb_lane *lane)
+{
+	return container_of(lane, struct tegra_xusb_usb3_lane, base);
+}
+
 struct tegra_xusb_usb2_lane {
 	struct tegra_xusb_lane base;
 
 	u32 hs_curr_level_offset;
+	bool powered_on;
 };
 
 static inline struct tegra_xusb_usb2_lane *
@@ -170,6 +181,19 @@ int tegra_xusb_pad_register(struct tegra_xusb_pad *pad,
 			    const struct phy_ops *ops);
 void tegra_xusb_pad_unregister(struct tegra_xusb_pad *pad);
 
+struct tegra_xusb_usb3_pad {
+	struct tegra_xusb_pad base;
+
+	unsigned int enable;
+	struct mutex lock;
+};
+
+static inline struct tegra_xusb_usb3_pad *
+to_usb3_pad(struct tegra_xusb_pad *pad)
+{
+	return container_of(pad, struct tegra_xusb_usb3_pad, base);
+}
+
 struct tegra_xusb_usb2_pad {
 	struct tegra_xusb_pad base;
 
@@ -425,5 +449,8 @@ extern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc;
 #if defined(CONFIG_ARCH_TEGRA_210_SOC)
 extern const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc;
 #endif
+#if defined(CONFIG_ARCH_TEGRA_186_SOC)
+extern const struct tegra_xusb_padctl_soc tegra186_xusb_padctl_soc;
+#endif
 
 #endif /* __PHY_TEGRA_XUSB_H */
Signature · 1 line
2.20.1
#7 lore raw
In reply to Thierry Reding

Hi Thierry,

Quoted 10 lines · Thierry Reding

From: Thierry Reding <[email protected]>

This series adds support for Tegra186 to the XUSB pad controller driver. Patch 1 extends the device tree bindings with support for Tegra186 while patches 2-4 are preparatory work for the final patch 5 that adds the Tegra186 specific programming for the UPHY blocks.

Changes in v2:
- address review comments from Kishon
- added Reviewed-by tags from JC

I've merged this series.
However I'd like to see if we can add the features of xusb.c to phy-core.c and remove xusb.c. This will be useful if there are other PHY vendors with similar design as Tegra.

Thanks
Kishon

Quoted 21 lines

Thierry

JC Kuo (2):
phy: tegra: xusb: Skip single function lane programming
phy: tegra: xusb: Add Tegra186 support

Thierry Reding (3):
dt-bindings: phy: tegra: Add Tegra186 support
phy: tegra: xusb: Parse dual-role mode property
phy: tegra: xusb: Add support for power supplies

 .../phy/nvidia,tegra124-xusb-padctl.txt       |   9 +
 MAINTAINERS                                   |   5 +
 drivers/phy/tegra/Makefile                    |   1 +
 drivers/phy/tegra/xusb-tegra186.c             | 899 ++++++++++++++++++
 drivers/phy/tegra/xusb.c                      |  67 +-
 drivers/phy/tegra/xusb.h                      |  35 +
 6 files changed, 1014 insertions(+), 2 deletions(-)
 create mode 100644 drivers/phy/tegra/xusb-tegra186.c