Skip to contentSkip to conversation

ARM: tegra: rename dummy XUSB padctl implementation

PATCH Superseded Stephen Warren 3 participants 10 messages Oct 5, 2015 – Oct 21, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 ARM: tegra: rename dummy XUSB padctl implementation

From: Stephen Warren <[email protected]>

A future patch will soon move some of the XUSB padctl code into a common file in arch/arm/mach-tegra. Rename the existing dummy XUSB padctl file to avoid conflicting with that, or being confusing.

---
 arch/arm/mach-tegra/Makefile                               | 2 +-
 arch/arm/mach-tegra/{xusb-padctl.c => xusb-padctl-dummy.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/arm/mach-tegra/{xusb-padctl.c => xusb-padctl-dummy.c} (100%)
arch/arm/mach-tegra/Makefile +1 -1
index 98431a91f875..2be6ef41fff6 100644
@@ -23,7 +23,7 @@ obj-y += clock.o
 obj-y += lowlevel_init.o
 obj-y += pinmux-common.o
 obj-y += powergate.o
-obj-y += xusb-padctl.o
+obj-y += xusb-padctl-dummy.o
 obj-$(CONFIG_DISPLAY_CPUINFO) += sys_info.o
 obj-$(CONFIG_TEGRA_GPU) += gpu.o
 obj-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o
arch/arm/mach-tegra/xusb-padctl-dummy.c renamed from arch/arm/mach-tegra/xusb-padctl.c +0 -0
similarity index 100%
rename from arch/arm/mach-tegra/xusb-padctl.c
rename to arch/arm/mach-tegra/xusb-padctl-dummy.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/6 ARM: tegra: rename dummy XUSB padctl implementation

Quoted 5 lines · Stephen Warren

From: Stephen Warren <[email protected]>

A future patch will soon move some of the XUSB padctl code into a common file in arch/arm/mach-tegra. Rename the existing dummy XUSB padctl file to avoid conflicting with that, or being confusing.

Tom,

Is this patch OK? I assume it can be applied now the merge window is over?

#2 lore raw

PATCH 1/6 ARM: tegra: rename dummy XUSB padctl implementation

Stephen,

-----Original Message-----
From: Stephen Warren [mailto:swarren at wwwdotorg.org]
Sent: Wednesday, October 21, 2015 9:40 AM
To: Tom Warren <[email protected]>
Cc: u-boot at lists.denx.de; Simon Glass <[email protected]>; Stephen Warren <[email protected]>; Thierry Reding <[email protected]>
Subject: Re: [U-Boot] [PATCH 1/6] ARM: tegra: rename dummy XUSB padctl implementation

Quoted 5 lines · Stephen Warren

From: Stephen Warren <[email protected]>

A future patch will soon move some of the XUSB padctl code into a common file in arch/arm/mach-tegra. Rename the existing dummy XUSB padctl file to avoid conflicting with that, or being confusing.

Tom,

Is this patch OK? I assume it can be applied now the merge window is over?

I was waiting on ACKs or reviews from Thierry or Simon (someone w/more USB chops then me). Let me check the history, and see if I can get them in (same for the PCI/PCIe stuff). --
nvpublic

#3 lore raw

PATCH 2/6 ARM: tegra: create common XUSB padctl driver file

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

A fair amount of the XUSB padctl driver will be common between Tegra124 and Tegra210. To avoid cut/paste between the two chips, create a new file that will contain the common code, and convert the Tegra124 code to use it. This change doesn't move every last piece of code that can/will be shared, but rather concentrates on moving code that can be moved with zero changes, so there are no other diffs mixed in.

It'd be nice if "git format-patch -C" recognized this as a copy, since that's why I created a separate patch, but it doesn't seem to:-(

---
 arch/arm/mach-tegra/tegra124/Makefile      |   1 +
 arch/arm/mach-tegra/tegra124/xusb-padctl.c | 349 +----------------------------
 arch/arm/mach-tegra/xusb-padctl-common.c   | 277 +++++++++++++++++++++++
 arch/arm/mach-tegra/xusb-padctl-common.h   | 103 +++++++++
 4 files changed, 386 insertions(+), 344 deletions(-)
 create mode 100644 arch/arm/mach-tegra/xusb-padctl-common.c
 create mode 100644 arch/arm/mach-tegra/xusb-padctl-common.h
arch/arm/mach-tegra/tegra124/Makefile +1 -0
index f577f459be0f..c00de6151e2d 100644
@@ -11,6 +11,7 @@ obj-y	+= clock.o
 obj-y	+= funcmux.o
 obj-y	+= pinmux.o
 obj-y	+= xusb-padctl.o
+obj-y	+= ../xusb-padctl-common.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_ARMV7_NONSEC) += psci.o
arch/arm/mach-tegra/tegra124/xusb-padctl.c +5 -344

389 lines not on this page · raw message

arch/arm/mach-tegra/xusb-padctl-common.c new file +277 -0

277 lines not on this page · raw message

arch/arm/mach-tegra/xusb-padctl-common.h new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

PATCH 2/6 ARM: tegra: create common XUSB padctl driver file

On Mon, Oct 05, 2015 at 04:59:17PM -0600, Stephen Warren wrote:
[...]

Quoted 2 lines

It'd be nice if "git format-patch -C" recognized this as a copy, since that's why I created a separate patch, but it doesn't seem to:-(

Have you tried tuning the behaviour by passing the similarity index to -C? I've had some success using that approach.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151006/a4550ea3/attachment.sig>

#5 lore raw

PATCH 2/6 ARM: tegra: create common XUSB padctl driver file

Quoted 7 lines · Thierry Reding

On Mon, Oct 05, 2015 at 04:59:17PM -0600, Stephen Warren wrote:
[...]

Quoted 2 lines

It'd be nice if "git format-patch -C" recognized this as a copy, since that's why I created a separate patch, but it doesn't seem to:-(

Have you tried tuning the behaviour by passing the similarity index to -C? I've had some success using that approach.

Ah, -C25 (a random number I tried that's less than the default) does seem to work much better. Unfortunately the diff isn't quite as useful as it could be since I moved the phy-related functions from the end to the start of the file to keep the DT and phy related code separate. I guess I could do that in a separate commit or drop that change.

Anyway, I'll try to remember this if I need to post a V2, but I'm not going to spam the lists just to repost it with a better diff unless someone really wants.

Thanks for the tip.

#6 lore raw

PATCH 3/6 ARM: tegra: parameterize common XUSB code

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

There are some differences between the Tegra124 and Tegra210 XUSB padctl code. So far, the common XUSB padctl code only supports Tegra124. Add some parameters etc. so that it can work for both chips.

This also allows moving Tegra124's process_nodes() into the common file; something that would have requires edits during the move if done in the previous commit.

---
 arch/arm/mach-tegra/tegra124/xusb-padctl.c | 86 +++++++-----------------------
 arch/arm/mach-tegra/xusb-padctl-common.c   | 74 +++++++++++++++++--------
 arch/arm/mach-tegra/xusb-padctl-common.h   | 32 ++++++-----
 3 files changed, 87 insertions(+), 105 deletions(-)
arch/arm/mach-tegra/tegra124/xusb-padctl.c +19 -67
index 709b02e1b7f7..ed6c1456bc71 100644
@@ -8,16 +8,9 @@
 
 #include <common.h>
 #include <errno.h>
-#include <fdtdec.h>
-#include <malloc.h>
 
 #include "../xusb-padctl-common.h"
 
-#include <asm/io.h>
-
-#include <asm/arch/clock.h>
-#include <asm/arch-tegra/xusb-padctl.h>
-
 #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h>
 
 #define XUSB_PADCTL_ELPG_PROGRAM 0x01c
@@ -302,68 +295,27 @@ static const struct tegra_xusb_phy_ops sata_phy_ops = {
 	.unprepare = phy_unprepare,
 };
 
-struct tegra_xusb_padctl *padctl = &(struct tegra_xusb_padctl) {
-	.phys = {
-		[0] = {
-			.ops = &pcie_phy_ops,
-		},
-		[1] = {
-			.ops = &sata_phy_ops,
-		},
+static struct tegra_xusb_phy tegra124_phys[] = {
+	{
+		.type = TEGRA_XUSB_PADCTL_PCIE,
+		.ops = &pcie_phy_ops,
+		.padctl = &padctl,
+	},
+	{
+		.type = TEGRA_XUSB_PADCTL_SATA,
+		.ops = &sata_phy_ops,
+		.padctl = &padctl,
 	},
 };
 
-int process_nodes(const void *fdt, int nodes[], unsigned int count)
-{
-	unsigned int i;
-
-	for (i = 0; i < count; i++) {
-		enum fdt_compat_id id;
-		int err;
-
-		if (!fdtdec_get_is_enabled(fdt, nodes[i]))
-			continue;
-
-		id = fdtdec_lookup(fdt, nodes[i]);
-		switch (id) {
-		case COMPAT_NVIDIA_TEGRA124_XUSB_PADCTL:
-			break;
-
-		default:
-			error("tegra-xusb-padctl: unsupported compatible: %s",
-			      fdtdec_get_compatible(id));
-			continue;
-		}
-
-		padctl->num_lanes = ARRAY_SIZE(tegra124_lanes);
-		padctl->lanes = tegra124_lanes;
-
-		padctl->num_functions = ARRAY_SIZE(tegra124_functions);
-		padctl->functions = tegra124_functions;
-
-		err = tegra_xusb_padctl_parse_dt(padctl, fdt, nodes[i]);
-		if (err < 0) {
-			error("tegra-xusb-padctl: failed to parse DT: %d",
-			      err);
-			continue;
-		}
-
-		/* deassert XUSB padctl reset */
-		reset_set_enable(PERIPH_ID_XUSB_PADCTL, 0);
-
-		err = tegra_xusb_padctl_config_apply(padctl, &padctl->config);
-		if (err < 0) {
-			error("tegra-xusb-padctl: failed to apply pinmux: %d",
-			      err);
-			continue;
-		}
-
-		/* only a single instance is supported */
-		break;
-	}
-
-	return 0;
-}
+static const struct tegra_xusb_padctl_soc tegra124_socdata = {
+	.lanes = tegra124_lanes,
+	.num_lanes = ARRAY_SIZE(tegra124_lanes),
+	.functions = tegra124_functions,
+	.num_functions = ARRAY_SIZE(tegra124_functions),
+	.phys = tegra124_phys,
+	.num_phys = ARRAY_SIZE(tegra124_phys),
+};
 
 void tegra_xusb_padctl_init(const void *fdt)
 {
@@ -372,6 +324,6 @@ void tegra_xusb_padctl_init(const void *fdt)
 	count = fdtdec_find_aliases_for_id(fdt, "padctl",
 					   COMPAT_NVIDIA_TEGRA124_XUSB_PADCTL,
 					   nodes, ARRAY_SIZE(nodes));
-	if (process_nodes(fdt, nodes, count))
+	if (tegra_xusb_process_nodes(fdt, nodes, count, &tegra124_socdata))
 		return;
 }
arch/arm/mach-tegra/xusb-padctl-common.c +53 -21

116 lines not on this page · raw message

arch/arm/mach-tegra/xusb-padctl-common.h +15 -17
index a65b754f6b7d..11ecb99b749d 100644
@@ -33,8 +33,8 @@ struct tegra_xusb_phy_ops {
 };
 
 struct tegra_xusb_phy {
+	unsigned int type;
 	const struct tegra_xusb_phy_ops *ops;
-
 	struct tegra_xusb_padctl *padctl;
 };
 
@@ -58,6 +58,15 @@ struct tegra_xusb_padctl_group {
 	int iddq;
 };
 
+struct tegra_xusb_padctl_soc {
+	const struct tegra_xusb_padctl_lane *lanes;
+	unsigned int num_lanes;
+	const char *const *functions;
+	unsigned int num_functions;
+	struct tegra_xusb_phy *phys;
+	unsigned int num_phys;
+};
+
 struct tegra_xusb_padctl_config {
 	const char *name;
 
@@ -66,20 +75,13 @@ struct tegra_xusb_padctl_config {
 };
 
 struct tegra_xusb_padctl {
+	const struct tegra_xusb_padctl_soc *socdata;
+	struct tegra_xusb_padctl_config config;
 	struct fdt_resource regs;
-
 	unsigned int enable;
 
-	struct tegra_xusb_phy phys[2];
-
-	const struct tegra_xusb_padctl_lane *lanes;
-	unsigned int num_lanes;
-
-	const char *const *functions;
-	unsigned int num_functions;
-
-	struct tegra_xusb_padctl_config config;
 };
+extern struct tegra_xusb_padctl padctl;
 
 static inline u32 padctl_readl(struct tegra_xusb_padctl *padctl,
 			       unsigned long offset)
@@ -93,11 +95,7 @@ static inline void padctl_writel(struct tegra_xusb_padctl *padctl,
 	writel(value, padctl->regs.start + offset);
 }
 
-extern struct tegra_xusb_padctl *padctl;
-
-int tegra_xusb_padctl_parse_dt(struct tegra_xusb_padctl *padctl,
-			       const void *fdt, int node);
-int tegra_xusb_padctl_config_apply(struct tegra_xusb_padctl *padctl,
-				   struct tegra_xusb_padctl_config *config);
+int tegra_xusb_process_nodes(const void *fdt, int nodes[], unsigned int count,
+	const struct tegra_xusb_padctl_soc *socdata);
 
 #endif
Signature · 1 line
1.9.1
#7 lore raw

PATCH 4/6 ARM: tegra: switch Tegra210 to common XUSB padctl

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

This change simply deletes code from the Tegra210 XUSB padctl driver that is already present in the common XUSB padctl code. Since all the arrays in tegra210_socdata are empty, this update may leave the Tegra210 XUSB padctl driver non-functional at run-time. However, (a) this driver is not used yet so no regression can be observed and (b) the next commit will immediately fix this up.

---
 arch/arm/mach-tegra/tegra210/Makefile      |   1 +
 arch/arm/mach-tegra/tegra210/xusb-padctl.c | 173 +++--------------------------
 2 files changed, 16 insertions(+), 158 deletions(-)
arch/arm/mach-tegra/tegra210/Makefile +1 -0
index 1fb8d1ac7483..b6012fc7baac 100644
@@ -9,3 +9,4 @@ obj-y	+= clock.o
 obj-y	+= funcmux.o
 obj-y	+= pinmux.o
 obj-y	+= xusb-padctl.o
+obj-y	+= ../xusb-padctl-common.o
arch/arm/mach-tegra/tegra210/xusb-padctl.c +15 -158

200 lines not on this page · raw message

Signature · 1 line
1.9.1
#8 lore raw

PATCH 5/6 ARM: tegra: add lane tables to Tegra210 XUSB padctl

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

Add the tables defining which pads and mux options exist in the Tegra210 XUSB padctl hardware.

---
 arch/arm/mach-tegra/tegra210/xusb-padctl.c | 78 ++++++++++++++++++++++++++++--
 arch/arm/mach-tegra/xusb-padctl-common.h   |  4 +-
 2 files changed, 76 insertions(+), 6 deletions(-)
arch/arm/mach-tegra/tegra210/xusb-padctl.c +74 -4
index 503354344067..6022f1614bda 100644
@@ -15,6 +15,76 @@
 
 #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h>
 
+enum tegra210_function {
+	TEGRA210_FUNC_SNPS,
+	TEGRA210_FUNC_XUSB,
+	TEGRA210_FUNC_UART,
+	TEGRA210_FUNC_PCIE_X1,
+	TEGRA210_FUNC_PCIE_X4,
+	TEGRA210_FUNC_USB3,
+	TEGRA210_FUNC_SATA,
+	TEGRA210_FUNC_RSVD,
+};
+
+static const char *const tegra210_functions[] = {
+	"snps",
+	"xusb",
+	"uart",
+	"pcie-x1",
+	"pcie-x4",
+	"usb3",
+	"sata",
+	"rsvd",
+};
+
+static const unsigned int tegra210_otg_functions[] = {
+	TEGRA210_FUNC_SNPS,
+	TEGRA210_FUNC_XUSB,
+	TEGRA210_FUNC_UART,
+	TEGRA210_FUNC_RSVD,
+};
+
+static const unsigned int tegra210_usb_functions[] = {
+	TEGRA210_FUNC_SNPS,
+	TEGRA210_FUNC_XUSB,
+};
+
+static const unsigned int tegra210_pci_functions[] = {
+	TEGRA210_FUNC_PCIE_X1,
+	TEGRA210_FUNC_USB3,
+	TEGRA210_FUNC_SATA,
+	TEGRA210_FUNC_PCIE_X4,
+};
+
+#define TEGRA210_LANE(_name, _offset, _shift, _mask, _iddq, _funcs)	\
+	{								\
+		.name = _name,						\
+		.offset = _offset,					\
+		.shift = _shift,					\
+		.mask = _mask,						\
+		.iddq = _iddq,						\
+		.num_funcs = ARRAY_SIZE(tegra210_##_funcs##_functions),	\
+		.funcs = tegra210_##_funcs##_functions,			\
+	}
+
+static const struct tegra_xusb_padctl_lane tegra210_lanes[] = {
+	TEGRA210_LANE("otg-0",     0x004,  0, 0x3, 0, otg),
+	TEGRA210_LANE("otg-1",     0x004,  2, 0x3, 0, otg),
+	TEGRA210_LANE("otg-2",     0x004,  4, 0x3, 0, otg),
+	TEGRA210_LANE("otg-3",     0x004,  6, 0x3, 0, otg),
+	TEGRA210_LANE("usb2-bias", 0x004, 18, 0x3, 0, otg),
+	TEGRA210_LANE("hsic-0",    0x004, 14, 0x1, 0, usb),
+	TEGRA210_LANE("hsic-1",    0x004, 15, 0x1, 0, usb),
+	TEGRA210_LANE("pcie-0",    0x028, 12, 0x3, 1, pci),
+	TEGRA210_LANE("pcie-1",    0x028, 14, 0x3, 2, pci),
+	TEGRA210_LANE("pcie-2",    0x028, 16, 0x3, 3, pci),
+	TEGRA210_LANE("pcie-3",    0x028, 18, 0x3, 4, pci),
+	TEGRA210_LANE("pcie-4",    0x028, 20, 0x3, 5, pci),
+	TEGRA210_LANE("pcie-5",    0x028, 22, 0x3, 6, pci),
+	TEGRA210_LANE("pcie-6",    0x028, 24, 0x3, 7, pci),
+	TEGRA210_LANE("sata-0",    0x028, 30, 0x3, 8, pci),
+};
+
 #define XUSB_PADCTL_ELPG_PROGRAM 0x024
 #define  XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_VCORE_DOWN (1 << 31)
 #define  XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN_EARLY (1 << 30)
@@ -328,10 +398,10 @@ static struct tegra_xusb_phy tegra210_phys[] = {
 };
 
 static const struct tegra_xusb_padctl_soc tegra210_socdata = {
-	.lanes = NULL,
-	.num_lanes = 0,
-	.functions = NULL,
-	.num_functions = 0,
+	.lanes = tegra210_lanes,
+	.num_lanes = ARRAY_SIZE(tegra210_lanes),
+	.functions = tegra210_functions,
+	.num_functions = ARRAY_SIZE(tegra210_functions),
 	.phys = tegra210_phys,
 	.num_phys = ARRAY_SIZE(tegra210_phys),
 };
arch/arm/mach-tegra/xusb-padctl-common.h +2 -2
index 11ecb99b749d..f44790a65004 100644
@@ -45,8 +45,8 @@ struct tegra_xusb_padctl_pin {
 	int iddq;
 };
 
-#define MAX_GROUPS 3
-#define MAX_PINS 6
+#define MAX_GROUPS 5
+#define MAX_PINS 7
 
 struct tegra_xusb_padctl_group {
 	const char *name;
Signature · 1 line
1.9.1
#9 lore raw

PATCH 6/6 ARM: tegra: error check Tegra210 XUSB padctl waits

In reply to Stephen Warren

From: Stephen Warren <[email protected]>

Add code to detect timeouts when waiting for HW events such as PLL lock done. Any errors are logged and trigger an error return code.

---
 arch/arm/mach-tegra/tegra210/xusb-padctl.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
arch/arm/mach-tegra/tegra210/xusb-padctl.c +20 -5
index 6022f1614bda..9ec93e7c4c4c 100644
@@ -279,7 +279,10 @@ static int pcie_phy_enable(struct tegra_xusb_phy *phy)
 		if (value & XUSB_PADCTL_UPHY_PLL_P0_CTL2_CAL_DONE)
 			break;
 	}
-
+	if (!(value & XUSB_PADCTL_UPHY_PLL_P0_CTL2_CAL_DONE)) {
+		debug("  timeout\n");
+		return -ETIMEDOUT;
+	}
 	debug("  done\n");
 
 	value = padctl_readl(padctl, XUSB_PADCTL_UPHY_PLL_P0_CTL2);
@@ -295,7 +298,10 @@ static int pcie_phy_enable(struct tegra_xusb_phy *phy)
 		if ((value & XUSB_PADCTL_UPHY_PLL_P0_CTL2_CAL_DONE) == 0)
 			break;
 	}
-
+	if (value & XUSB_PADCTL_UPHY_PLL_P0_CTL2_CAL_DONE) {
+		debug("  timeout\n");
+		return -ETIMEDOUT;
+	}
 	debug("  done\n");
 
 	value = padctl_readl(padctl, XUSB_PADCTL_UPHY_PLL_P0_CTL1);
@@ -310,7 +316,10 @@ static int pcie_phy_enable(struct tegra_xusb_phy *phy)
 		if (value & XUSB_PADCTL_UPHY_PLL_P0_CTL1_LOCKDET_STATUS)
 			break;
 	}
-
+	if (!(value & XUSB_PADCTL_UPHY_PLL_P0_CTL1_LOCKDET_STATUS)) {
+		debug("  timeout\n");
+		return -ETIMEDOUT;
+	}
 	debug("  done\n");
 
 	value = padctl_readl(padctl, XUSB_PADCTL_UPHY_PLL_P0_CTL8);
@@ -326,7 +335,10 @@ static int pcie_phy_enable(struct tegra_xusb_phy *phy)
 		if (value & XUSB_PADCTL_UPHY_PLL_P0_CTL8_RCAL_DONE)
 			break;
 	}
-
+	if (!(value & XUSB_PADCTL_UPHY_PLL_P0_CTL8_RCAL_DONE)) {
+		debug("  timeout\n");
+		return -ETIMEDOUT;
+	}
 	debug("  done\n");
 
 	value = padctl_readl(padctl, XUSB_PADCTL_UPHY_PLL_P0_CTL8);
@@ -341,7 +353,10 @@ static int pcie_phy_enable(struct tegra_xusb_phy *phy)
 		if ((value & XUSB_PADCTL_UPHY_PLL_P0_CTL8_RCAL_DONE) == 0)
 			break;
 	}
-
+	if (value & XUSB_PADCTL_UPHY_PLL_P0_CTL8_RCAL_DONE) {
+		debug("  timeout\n");
+		return -ETIMEDOUT;
+	}
 	debug("  done\n");
 
 	value = padctl_readl(padctl, XUSB_PADCTL_UPHY_PLL_P0_CTL8);
Signature · 1 line
1.9.1