aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorLi Yang <leoli@freescale.com>2008-01-08 02:18:45 -0500
committerKumar Gala <galak@kernel.crashing.org>2008-01-23 20:33:03 -0500
commite10241d8a1a68955e2f3e74befd9fa6ce61ba2bc (patch)
treeb213f00dbbb0e8a7cb744aae4764d59dc7a04cfc /arch/powerpc
parent5761bc5dae656b96e4bb22fd05480e5beddab24c (diff)
[POWERPC] 83xx: Add MPC837x USB platform support
Add chip specific and board specific initialization for MPC837x USB. Signed-off-by: Li Yang <leoli@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/83xx/mpc837x_mds.c51
-rw-r--r--arch/powerpc/platforms/83xx/mpc83xx.h3
-rw-r--r--arch/powerpc/platforms/83xx/usb.c40
3 files changed, 94 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/83xx/mpc837x_mds.c b/arch/powerpc/platforms/83xx/mpc837x_mds.c
index cfd05487f26e..8a9c26973605 100644
--- a/arch/powerpc/platforms/83xx/mpc837x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc837x_mds.c
@@ -22,6 +22,56 @@
22 22
23#include "mpc83xx.h" 23#include "mpc83xx.h"
24 24
25#define BCSR12_USB_SER_MASK 0x8a
26#define BCSR12_USB_SER_PIN 0x80
27#define BCSR12_USB_SER_DEVICE 0x02
28extern int mpc837x_usb_cfg(void);
29
30static int mpc837xmds_usb_cfg(void)
31{
32 struct device_node *np;
33 const void *phy_type, *mode;
34 void __iomem *bcsr_regs = NULL;
35 u8 bcsr12;
36 int ret;
37
38 ret = mpc837x_usb_cfg();
39 if (ret)
40 return ret;
41 /* Map BCSR area */
42 np = of_find_node_by_name(NULL, "bcsr");
43 if (np) {
44 struct resource res;
45
46 of_address_to_resource(np, 0, &res);
47 bcsr_regs = ioremap(res.start, res.end - res.start + 1);
48 of_node_put(np);
49 }
50 if (!bcsr_regs)
51 return -1;
52
53 np = of_find_node_by_name(NULL, "usb");
54 if (!np)
55 return -ENODEV;
56 phy_type = of_get_property(np, "phy_type", NULL);
57 if (phy_type && !strcmp(phy_type, "ulpi")) {
58 clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN);
59 } else if (phy_type && !strcmp(phy_type, "serial")) {
60 mode = of_get_property(np, "dr_mode", NULL);
61 bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK;
62 bcsr12 |= BCSR12_USB_SER_PIN;
63 if (mode && !strcmp(mode, "peripheral"))
64 bcsr12 |= BCSR12_USB_SER_DEVICE;
65 out_8(bcsr_regs + 12, bcsr12);
66 } else {
67 printk(KERN_ERR "USB DR: unsupported PHY\n");
68 }
69
70 of_node_put(np);
71 iounmap(bcsr_regs);
72 return 0;
73}
74
25/* ************************************************************************ 75/* ************************************************************************
26 * 76 *
27 * Setup the architecture 77 * Setup the architecture
@@ -40,6 +90,7 @@ static void __init mpc837x_mds_setup_arch(void)
40 for_each_compatible_node(np, "pci", "fsl,mpc8349-pci") 90 for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
41 mpc83xx_add_bridge(np); 91 mpc83xx_add_bridge(np);
42#endif 92#endif
93 mpc837xmds_usb_cfg();
43} 94}
44 95
45static struct of_device_id mpc837x_ids[] = { 96static struct of_device_id mpc837x_ids[] = {
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index b778cb4f3fb5..88bb748aff0d 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -14,6 +14,7 @@
14#define MPC83XX_SCCR_USB_DRCM_11 0x00300000 14#define MPC83XX_SCCR_USB_DRCM_11 0x00300000
15#define MPC83XX_SCCR_USB_DRCM_01 0x00100000 15#define MPC83XX_SCCR_USB_DRCM_01 0x00100000
16#define MPC83XX_SCCR_USB_DRCM_10 0x00200000 16#define MPC83XX_SCCR_USB_DRCM_10 0x00200000
17#define MPC837X_SCCR_USB_DRCM_11 0x00c00000
17 18
18/* system i/o configuration register low */ 19/* system i/o configuration register low */
19#define MPC83XX_SICRL_OFFS 0x114 20#define MPC83XX_SICRL_OFFS 0x114
@@ -22,6 +23,8 @@
22#define MPC834X_SICRL_USB1 0x20000000 23#define MPC834X_SICRL_USB1 0x20000000
23#define MPC831X_SICRL_USB_MASK 0x00000c00 24#define MPC831X_SICRL_USB_MASK 0x00000c00
24#define MPC831X_SICRL_USB_ULPI 0x00000800 25#define MPC831X_SICRL_USB_ULPI 0x00000800
26#define MPC837X_SICRL_USB_MASK 0xf0000000
27#define MPC837X_SICRL_USB_ULPI 0x50000000
25 28
26/* system i/o configuration register high */ 29/* system i/o configuration register high */
27#define MPC83XX_SICRH_OFFS 0x118 30#define MPC83XX_SICRH_OFFS 0x118
diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
index b45160f8d084..b1de453a8851 100644
--- a/arch/powerpc/platforms/83xx/usb.c
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -179,3 +179,43 @@ int mpc831x_usb_cfg(void)
179 return ret; 179 return ret;
180} 180}
181#endif /* CONFIG_PPC_MPC831x */ 181#endif /* CONFIG_PPC_MPC831x */
182
183#ifdef CONFIG_PPC_MPC837x
184int mpc837x_usb_cfg(void)
185{
186 void __iomem *immap;
187 struct device_node *np = NULL;
188 const void *prop;
189 int ret = 0;
190
191 np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr");
192 if (!np)
193 return -ENODEV;
194 prop = of_get_property(np, "phy_type", NULL);
195
196 if (!prop || (strcmp(prop, "ulpi") && strcmp(prop, "serial"))) {
197 printk(KERN_WARNING "837x USB PHY type not supported\n");
198 of_node_put(np);
199 return -EINVAL;
200 }
201
202 /* Map IMMR space for pin and clock settings */
203 immap = ioremap(get_immrbase(), 0x1000);
204 if (!immap) {
205 of_node_put(np);
206 return -ENOMEM;
207 }
208
209 /* Configure clock */
210 clrsetbits_be32(immap + MPC83XX_SCCR_OFFS, MPC837X_SCCR_USB_DRCM_11,
211 MPC837X_SCCR_USB_DRCM_11);
212
213 /* Configure pin mux for ULPI/serial */
214 clrsetbits_be32(immap + MPC83XX_SICRL_OFFS, MPC837X_SICRL_USB_MASK,
215 MPC837X_SICRL_USB_ULPI);
216
217 iounmap(immap);
218 of_node_put(np);
219 return ret;
220}
221#endif /* CONFIG_PPC_MPC837x */