Skip to contentSkip to conversation

ppc44x:PHY fixup for USB on canyonlands board

PATCH Superseded Rupjyoti Sarmah 3 participants 3 messages Dec 9, 2010 – Dec 13, 2010

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 ppc44x:PHY fixup for USB on canyonlands board

This fix is a reset for USB PHY that requires some amount of time for power to be stable on Canyonlands.

---
changes from previous version:
-- dts node correction, removed the address and size parameters -- Kconfig file updated removing dependency on PPC44x_SIMPLE -- 44x prefixes in the function names changed
-- Error paths updated in canyonlands.c

 arch/powerpc/boot/dts/canyonlands.dts      |   11 +++
 arch/powerpc/platforms/44x/44x.h           |    4 +
 arch/powerpc/platforms/44x/Kconfig         |    1 -
 arch/powerpc/platforms/44x/Makefile        |    1 +
 arch/powerpc/platforms/44x/canyonlands.c   |  125 ++++++++++++++++++++++++++++
 arch/powerpc/platforms/44x/ppc44x_simple.c |    1 -
 6 files changed, 141 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/platforms/44x/canyonlands.c
arch/powerpc/boot/dts/canyonlands.dts +11 -0
index a303703..8ff1f3f 100644
@@ -224,6 +224,11 @@
 					};
 				};
 
+				cpld@2,0 {
+					compatible = "amcc,ppc460ex-bcsr";
+					reg = <2 0x0 0x9>;
+				};
+
 				ndfc@3,0 {
 					compatible = "ibm,ndfc";
 					reg = <0x00000003 0x00000000 0x00002000>;
@@ -320,6 +325,12 @@
 				interrupts = <0x3 0x4>;
 			};
 
+			GPIO0: gpio@ef600b00 {
+				compatible = "ibm,ppc4xx-gpio";
+				reg = <0xef600b00 0x00000048>;
+				gpio-controller;
+			};
+
 			ZMII0: emac-zmii@ef600d00 {
 				compatible = "ibm,zmii-460ex", "ibm,zmii";
 				reg = <0xef600d00 0x0000000c>;
arch/powerpc/platforms/44x/44x.h +4 -0
index dbc4d2b..63f703e 100644
@@ -4,4 +4,8 @@
 extern u8 as1_readb(volatile u8 __iomem  *addr);
 extern void as1_writeb(u8 data, volatile u8 __iomem *addr);
 
+#define GPIO0_OSRH	0xC
+#define GPIO0_TSRH	0x14
+#define GPIO0_ISR1H	0x34
+
 #endif /* __POWERPC_PLATFORMS_44X_44X_H */
arch/powerpc/platforms/44x/Kconfig +0 -1
index 0f979c5..f485fc5 100644
@@ -115,7 +115,6 @@ config CANYONLANDS
 	bool "Canyonlands"
 	depends on 44x
 	default n
-	select PPC44x_SIMPLE
 	select 460EX
 	select PCI
 	select PPC4xx_PCI_EXPRESS
arch/powerpc/platforms/44x/Makefile +1 -0
index 82ff326..6854e73 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_WARP)	+= warp.o
 obj-$(CONFIG_XILINX_VIRTEX_5_FXT) += virtex.o
 obj-$(CONFIG_XILINX_ML510) += virtex_ml510.o
 obj-$(CONFIG_ISS4xx)	+= iss4xx.o
+obj-$(CONFIG_CANYONLANDS)+= canyonlands.o
arch/powerpc/platforms/44x/canyonlands.c new file +125 -0

125 lines not on this page · raw message

arch/powerpc/platforms/44x/ppc44x_simple.c +0 -1
index 7ddcba3..c81c19c 100644
@@ -53,7 +53,6 @@ static char *board[] __initdata = {
 	"amcc,arches",
 	"amcc,bamboo",
 	"amcc,bluestone",
-	"amcc,canyonlands",
 	"amcc,glacier",
 	"ibm,ebony",
 	"amcc,eiger",
Signature · 1 line
1.5.6.3
#1 lore raw

On Thu, Dec 09, 2010 at 09:54:01AM +0530, Rupjyoti Sarmah wrote:

A few error path issues, plus one leak in the good case. I'll wait to see if there are any more comments for a couple of days.

Quoted 12 lines
arch/powerpc/platforms/44x/canyonlands.c new file +12 -0
+static int __init ppc460ex_canyonlands_fixup(void)
+{
+	u8 __iomem *bcsr ;
+	void __iomem *vaddr;
+	struct device_node *np;
+	int ret = 0;
+
+	np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-bcsr");
+	if (!np) {
+		printk(KERN_ERR "failed did not find amcc, ppc460ex bcsr node\n");
+		return -ENODEV;
+	}

arch/powerpc/platforms/44x/canyonlands.c line 87

Quoted 10 lines
arch/powerpc/platforms/44x/canyonlands.c new file +10 -0
+
+	bcsr = of_iomap(np, 0);
+	of_node_put(np);
+
+	if (!bcsr) {
+		printk(KERN_CRIT "Could not remap bcsr\n");
+		ret = -ENODEV;
+	}
+
+	np = of_find_compatible_node(NULL, NULL, "ibm,ppc4xx-gpio");

This can fail if you boot a new kernel on a board with an old FDT that lacks the gpio node. Calling of_iomap with a NULL np seems like it would work without crashing anything, so maybe that's not a huge issue.

arch/powerpc/platforms/44x/canyonlands.c line 93

Quoted 6 lines
arch/powerpc/platforms/44x/canyonlands.c new file +6 -0
+	vaddr = of_iomap(np, 0);
+	if (!vaddr) {
+		printk(KERN_CRIT "Could not get gpio node address\n");
+		ret = -ENODEV;
+		goto err_bcsr;
+	}

A reference count is leaked for the node in this error case because of_node_put isn't called for the gpio node. Also, iounmap is never called on vaddr.

Quoted 13 lines
arch/powerpc/platforms/44x/canyonlands.c new file +13 -0
+	/* Disable USB, through the BCSR7 bits */
+	setbits8(&bcsr[7], BCSR_USB_EN);
+
+	/* Wait for a while after reset */
+	msleep(100);
+
+	/* Enable USB here */
+	clrbits8(&bcsr[7], BCSR_USB_EN);
+
+	/*
+	 * Configure multiplexed gpio16 and gpio19 as alternate1 output
+	 * source after USB reset. In this configuration gpio16 will be
+	 * USB2HStop and gpio19 will be USB2DStop. For more details refer to

arch/powerpc/platforms/44x/canyonlands.c line 116

Quoted 10 lines
arch/powerpc/platforms/44x/canyonlands.c new file +10 -0
+	 * table 34-7 of PPC460EX user manual.
+	 */
+	setbits32((vaddr + GPIO0_OSRH), 0x42000000);
+	setbits32((vaddr + GPIO0_TSRH), 0x42000000);
+	of_node_put(np);
+err_bcsr:
+	iounmap(bcsr);
+	return ret;
+}
+machine_device_initcall(canyonlands, ppc460ex_canyonlands_fixup);

josh

#2 lore raw
Quoted 1 line

This can fail if you boot a new kernel on a board with an old FDT that

lacks the gpio node. Calling of_iomap with a NULL np seems like it would work without crashing anything, so maybe that's not a huge issue.

Quoted 8 lines

arch/powerpc/platforms/44x/canyonlands.c line 93

Quoted 6 lines
arch/powerpc/platforms/44x/canyonlands.c new file +6 -0
+	vaddr = of_iomap(np, 0);
+	if (!vaddr) {
+		printk(KERN_CRIT "Could not get gpio node address\n");
+		ret = -ENODEV;
+		goto err_bcsr;
+	}

A reference count is leaked for the node in this error case because

of_node_put isn't called for the gpio node. Also, iounmap is never called on vaddr.

Quoted 1 line

arch/powerpc/platforms/44x/canyonlands.c line 94

Quoted 1 line
arch/powerpc/platforms/44x/canyonlands.c new file +1 -0
+	/* Disable USB, through the BCSR7 bits */

Thanks for your inputs. I will fix and resubmit.

Regards,
Rup