linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Li Yang <leoli@freescale.com>
To: linuxppc-dev@ozlabs.org, galak@kernel.crashing.org
Cc: Li Yang <leoli@freescale.com>
Subject: [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
Date: Wed,  6 Aug 2008 15:04:44 +0800	[thread overview]
Message-ID: <1218006285-27138-5-git-send-email-leoli@freescale.com> (raw)
In-Reply-To: <1218006285-27138-4-git-send-email-leoli@freescale.com>

Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/boot/dts/mpc836x_mds.dts     |   15 ++++++-
 arch/powerpc/platforms/83xx/mpc836x_mds.c |   19 ++++++++-
 arch/powerpc/platforms/83xx/mpc83xx.h     |    1 +
 arch/powerpc/platforms/83xx/usb.c         |   67 +++++++++++++++++++++++++++++
 4 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc836x_mds.dts b/arch/powerpc/boot/dts/mpc836x_mds.dts
index a3b76a7..596377b 100644
--- a/arch/powerpc/boot/dts/mpc836x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc836x_mds.dts
@@ -235,6 +235,17 @@
 					0  2  1  0  1  0>; /* MDC */
 			};
 
+			pio_usb: usb_pin@01 {
+				pio-map = <
+			/* port  pin  dir  open_drain  assignment  has_irq */
+					1  2  1  0  3  0        /* USBOE  */
+					1  3  1  0  3  0        /* USBTP  */
+					1  8  1  0  1  0        /* USBTN  */
+					1 10  2  0  3  0        /* USBRXD */
+					1  9  2  1  3  0        /* USBRP  */
+					1 11  2  1  3  0>;      /* USBRN  */
+			};
+
 		};
 	};
 
@@ -280,11 +291,13 @@
 		};
 
 		usb@6c0 {
-			compatible = "qe_udc";
+			compatible = "fsl,qe_udc";
 			reg = <0x6c0 0x40 0x8b00 0x100>;
 			interrupts = <11>;
 			interrupt-parent = <&qeic>;
 			mode = "slave";
+			usb-clock = <21>;
+			pio-handle = <&pio_usb>;
 		};
 
 		enet0: ucc@2000 {
diff --git a/arch/powerpc/platforms/83xx/mpc836x_mds.c b/arch/powerpc/platforms/83xx/mpc836x_mds.c
index 9d46e5b..92afd40 100644
--- a/arch/powerpc/platforms/83xx/mpc836x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc836x_mds.c
@@ -93,6 +93,12 @@ static void __init mpc836x_mds_setup_arch(void)
 
 		for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
 			par_io_of_config(np);
+
+		np = of_find_compatible_node(NULL, NULL, "fsl,qe_udc");
+		if (np) {
+			par_io_of_config(np);
+			qe_usb_clock_set(np);
+		}
 	}
 
 	if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))
@@ -127,9 +133,20 @@ static void __init mpc836x_mds_setup_arch(void)
 			iounmap(immap);
 		}
 
-		iounmap(bcsr_regs);
 		of_node_put(np);
 	}
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,qe_udc");
+	if (np != NULL) {
+		/* Set the TESCs run on RGMII mode */
+		bcsr_regs[8] &= ~0xf0;
+		/* Enable the USB Device PHY */
+		bcsr_regs[13] &= ~0x0f;
+		udelay(1000);
+		bcsr_regs[13] |= 0x05;
+		of_node_put(np);
+	}
+	iounmap(bcsr_regs);
 #endif				/* CONFIG_QUICC_ENGINE */
 }
 
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index 2a7cbab..d025b47 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -63,5 +63,6 @@ extern void mpc83xx_restart(char *cmd);
 extern long mpc83xx_time_init(void);
 extern int mpc834x_usb_cfg(void);
 extern int mpc831x_usb_cfg(void);
+extern int qe_usb_clock_set(struct device_node *np);
 
 #endif				/* __MPC83XX_H__ */
diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
index cc99c28..3d04ab5 100644
--- a/arch/powerpc/platforms/83xx/usb.c
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -18,6 +18,7 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <sysdev/fsl_soc.h>
+#include <asm/qe.h>
 
 #include "mpc83xx.h"
 
@@ -240,3 +241,69 @@ int mpc837x_usb_cfg(void)
 	return ret;
 }
 #endif /* CONFIG_PPC_MPC837x */
+
+#ifdef CONFIG_QUICC_ENGINE
+/* QE USB_CLOCK configure functions */
+int qe_usb_clock_set(struct device_node *np)
+{
+	u32 tmpreg = 0;
+	struct qe_mux *qemux = NULL;
+	const int *clock;
+
+	qemux = &qe_immr->qmx;
+
+	clock = of_get_property(np, "usb-clock", NULL);
+	if (!clock)
+		return -EINVAL;
+
+	/* CLK21 -> USBCLK on MPC8360-PB*/
+	tmpreg = in_be32(&qemux->cmxgcr) & ~QE_CMXGCR_USBCS;
+	switch (*clock) {
+	case 21:
+		tmpreg |= 0x8;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 20, 2, 0, 1, 0);  /* PC20 for CLK21 */
+		break;
+	case 19:
+		tmpreg |= 0x7;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 18, 2, 0, 1, 0);  /* PC18 for CLK19 */
+		break;
+	case 17:
+		tmpreg |= 0x6;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 16, 2, 0, 1, 0);  /* PC16 for CLK17 */
+		break;
+	case 13:
+		tmpreg |= 0x5;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 12, 2, 0, 1, 0);  /* PC12 for CLK13 */
+		break;
+	case 9:
+		tmpreg |= 0x4;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 8, 2, 0, 1, 0);  /* PC8 for CLK9 */
+		break;
+	case 7:
+		tmpreg |= 0x3;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 6, 2, 0, 1, 0);  /* PC6 for CLK7 */
+		break;
+	case 5:
+		tmpreg |= 0x2;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 4, 2, 0, 1, 0);  /* PC4 for CLK5 */
+		break;
+	case 3:
+		tmpreg |= 0x1;
+		out_be32(&qemux->cmxgcr, tmpreg);
+		par_io_config_pin(2, 2, 2, 0, 1, 0);  /* PC2 for CLK3 */
+		break;
+	default:
+		printk(KERN_ERR "Unsupport usb-clock input pin\n");
+	}
+
+	return 0;
+}
+#endif
+
-- 
1.5.5.1.248.g4b17

  reply	other threads:[~2008-08-06  6:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06  7:04 [PATCH 1/6] powerpc: update flash size and partition in mpc8272ads dts Li Yang
2008-08-06  7:04 ` [PATCH 2/6] powerpc: export cpm2_immr symbol for CPM2 drivers to compile as module Li Yang
2008-08-06  7:04   ` [PATCH 3/6] powerpc: update QE/CPM2 headers for USB support Li Yang
2008-08-06  7:04     ` [PATCH 4/6] powerpc: add USB peripheral support to MPC8272ADS Li Yang
2008-08-06  7:04       ` Li Yang [this message]
2008-08-06  7:04         ` [PATCH 6/6] powerpc: add 82xx platform level support to SEC engine Li Yang
2008-08-06 17:27           ` Scott Wood
2008-08-06  7:50         ` [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS Stephen Rothwell
2008-08-06 12:07         ` Anton Vorontsov
2008-08-07  9:31           ` Li Yang
2008-08-07 13:23             ` Anton Vorontsov
2008-08-06 17:29         ` Scott Wood
2008-08-07  3:32           ` Li Yang
2008-08-06  7:48       ` [PATCH 4/6] powerpc: add USB peripheral support to MPC8272ADS Stephen Rothwell
2008-08-06 17:19       ` Scott Wood
2008-08-07  3:50         ` Li Yang
2008-08-07 14:19           ` Scott Wood
2008-08-06 15:24   ` [PATCH 2/6] powerpc: export cpm2_immr symbol for CPM2 drivers to compile as module Anton Vorontsov
2008-08-07 10:19     ` Li Yang
2008-08-07 11:38       ` Anton Vorontsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1218006285-27138-5-git-send-email-leoli@freescale.com \
    --to=leoli@freescale.com \
    --cc=galak@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).