diff options
Diffstat (limited to 'arch/powerpc/platforms/83xx')
-rw-r--r-- | arch/powerpc/platforms/83xx/Kconfig | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc8313_rdb.c | 8 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc832x_mds.c | 7 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc832x_rdb.c | 7 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc834x_itx.c | 9 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc834x_mds.c | 56 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc836x_mds.c | 7 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc83xx.h | 34 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/pci.c | 18 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/usb.c | 181 |
11 files changed, 231 insertions, 100 deletions
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig index 19cafdf6df93..ec305f18abd8 100644 --- a/arch/powerpc/platforms/83xx/Kconfig +++ b/arch/powerpc/platforms/83xx/Kconfig | |||
@@ -1,5 +1,5 @@ | |||
1 | choice | 1 | choice |
2 | prompt "Machine Type" | 2 | prompt "83xx Board Type" |
3 | depends on PPC_83xx | 3 | depends on PPC_83xx |
4 | default MPC834x_MDS | 4 | default MPC834x_MDS |
5 | 5 | ||
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile index 31a91b53f528..5a98f885779f 100644 --- a/arch/powerpc/platforms/83xx/Makefile +++ b/arch/powerpc/platforms/83xx/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the PowerPC 83xx linux kernel. | 2 | # Makefile for the PowerPC 83xx linux kernel. |
3 | # | 3 | # |
4 | obj-y := misc.o | 4 | obj-y := misc.o usb.o |
5 | obj-$(CONFIG_PCI) += pci.o | 5 | obj-$(CONFIG_PCI) += pci.o |
6 | obj-$(CONFIG_MPC8313_RDB) += mpc8313_rdb.o | 6 | obj-$(CONFIG_MPC8313_RDB) += mpc8313_rdb.o |
7 | obj-$(CONFIG_MPC832x_RDB) += mpc832x_rdb.o | 7 | obj-$(CONFIG_MPC832x_RDB) += mpc832x_rdb.o |
diff --git a/arch/powerpc/platforms/83xx/mpc8313_rdb.c b/arch/powerpc/platforms/83xx/mpc8313_rdb.c index 96970ac887ee..3edfe170a03b 100644 --- a/arch/powerpc/platforms/83xx/mpc8313_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc8313_rdb.c | |||
@@ -28,11 +28,6 @@ | |||
28 | #define DBG(fmt...) | 28 | #define DBG(fmt...) |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifndef CONFIG_PCI | ||
32 | unsigned long isa_io_base = 0; | ||
33 | unsigned long isa_mem_base = 0; | ||
34 | #endif | ||
35 | |||
36 | /* ************************************************************************ | 31 | /* ************************************************************************ |
37 | * | 32 | * |
38 | * Setup the architecture | 33 | * Setup the architecture |
@@ -49,10 +44,11 @@ static void __init mpc8313_rdb_setup_arch(void) | |||
49 | 44 | ||
50 | #ifdef CONFIG_PCI | 45 | #ifdef CONFIG_PCI |
51 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) | 46 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) |
52 | add_bridge(np); | 47 | mpc83xx_add_bridge(np); |
53 | 48 | ||
54 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; | 49 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; |
55 | #endif | 50 | #endif |
51 | mpc831x_usb_cfg(); | ||
56 | } | 52 | } |
57 | 53 | ||
58 | void __init mpc8313_rdb_init_IRQ(void) | 54 | void __init mpc8313_rdb_init_IRQ(void) |
diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.c b/arch/powerpc/platforms/83xx/mpc832x_mds.c index 94843ed52a93..b39cb52c6fb9 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc832x_mds.c | |||
@@ -49,11 +49,6 @@ | |||
49 | #define DBG(fmt...) | 49 | #define DBG(fmt...) |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #ifndef CONFIG_PCI | ||
53 | unsigned long isa_io_base = 0; | ||
54 | unsigned long isa_mem_base = 0; | ||
55 | #endif | ||
56 | |||
57 | static u8 *bcsr_regs = NULL; | 52 | static u8 *bcsr_regs = NULL; |
58 | 53 | ||
59 | /* ************************************************************************ | 54 | /* ************************************************************************ |
@@ -80,7 +75,7 @@ static void __init mpc832x_sys_setup_arch(void) | |||
80 | 75 | ||
81 | #ifdef CONFIG_PCI | 76 | #ifdef CONFIG_PCI |
82 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) | 77 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) |
83 | add_bridge(np); | 78 | mpc83xx_add_bridge(np); |
84 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; | 79 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; |
85 | #endif | 80 | #endif |
86 | 81 | ||
diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c index 3db68b73fc32..b2b28a44738c 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c | |||
@@ -32,11 +32,6 @@ | |||
32 | #define DBG(fmt...) | 32 | #define DBG(fmt...) |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #ifndef CONFIG_PCI | ||
36 | unsigned long isa_io_base = 0; | ||
37 | unsigned long isa_mem_base = 0; | ||
38 | #endif | ||
39 | |||
40 | /* ************************************************************************ | 35 | /* ************************************************************************ |
41 | * | 36 | * |
42 | * Setup the architecture | 37 | * Setup the architecture |
@@ -53,7 +48,7 @@ static void __init mpc832x_rdb_setup_arch(void) | |||
53 | 48 | ||
54 | #ifdef CONFIG_PCI | 49 | #ifdef CONFIG_PCI |
55 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) | 50 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) |
56 | add_bridge(np); | 51 | mpc83xx_add_bridge(np); |
57 | 52 | ||
58 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; | 53 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; |
59 | #endif | 54 | #endif |
diff --git a/arch/powerpc/platforms/83xx/mpc834x_itx.c b/arch/powerpc/platforms/83xx/mpc834x_itx.c index 40a01947d684..47ba5446f63c 100644 --- a/arch/powerpc/platforms/83xx/mpc834x_itx.c +++ b/arch/powerpc/platforms/83xx/mpc834x_itx.c | |||
@@ -38,11 +38,6 @@ | |||
38 | 38 | ||
39 | #include "mpc83xx.h" | 39 | #include "mpc83xx.h" |
40 | 40 | ||
41 | #ifndef CONFIG_PCI | ||
42 | unsigned long isa_io_base = 0; | ||
43 | unsigned long isa_mem_base = 0; | ||
44 | #endif | ||
45 | |||
46 | /* ************************************************************************ | 41 | /* ************************************************************************ |
47 | * | 42 | * |
48 | * Setup the architecture | 43 | * Setup the architecture |
@@ -59,10 +54,12 @@ static void __init mpc834x_itx_setup_arch(void) | |||
59 | 54 | ||
60 | #ifdef CONFIG_PCI | 55 | #ifdef CONFIG_PCI |
61 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) | 56 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) |
62 | add_bridge(np); | 57 | mpc83xx_add_bridge(np); |
63 | 58 | ||
64 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; | 59 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; |
65 | #endif | 60 | #endif |
61 | |||
62 | mpc834x_usb_cfg(); | ||
66 | } | 63 | } |
67 | 64 | ||
68 | static void __init mpc834x_itx_init_IRQ(void) | 65 | static void __init mpc834x_itx_init_IRQ(void) |
diff --git a/arch/powerpc/platforms/83xx/mpc834x_mds.c b/arch/powerpc/platforms/83xx/mpc834x_mds.c index 10394b2d7e7a..4c9ff9cadfe4 100644 --- a/arch/powerpc/platforms/83xx/mpc834x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc834x_mds.c | |||
@@ -38,61 +38,17 @@ | |||
38 | 38 | ||
39 | #include "mpc83xx.h" | 39 | #include "mpc83xx.h" |
40 | 40 | ||
41 | #ifndef CONFIG_PCI | ||
42 | unsigned long isa_io_base = 0; | ||
43 | unsigned long isa_mem_base = 0; | ||
44 | #endif | ||
45 | |||
46 | #define BCSR5_INT_USB 0x02 | 41 | #define BCSR5_INT_USB 0x02 |
47 | /* Note: This is only for PB, not for PB+PIB | 42 | static int mpc834xemds_usb_cfg(void) |
48 | * On PB only port0 is connected using ULPI */ | ||
49 | static int mpc834x_usb_cfg(void) | ||
50 | { | 43 | { |
51 | unsigned long sccr, sicrl; | 44 | struct device_node *np; |
52 | void __iomem *immap; | ||
53 | void __iomem *bcsr_regs = NULL; | 45 | void __iomem *bcsr_regs = NULL; |
54 | u8 bcsr5; | 46 | u8 bcsr5; |
55 | struct device_node *np = NULL; | ||
56 | int port0_is_dr = 0; | ||
57 | |||
58 | if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) != NULL) | ||
59 | port0_is_dr = 1; | ||
60 | if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-mph")) != NULL){ | ||
61 | if (port0_is_dr) { | ||
62 | printk(KERN_WARNING | ||
63 | "There is only one USB port on PB board! \n"); | ||
64 | return -1; | ||
65 | } else if (!port0_is_dr) | ||
66 | /* No usb port enabled */ | ||
67 | return -1; | ||
68 | } | ||
69 | |||
70 | immap = ioremap(get_immrbase(), 0x1000); | ||
71 | if (!immap) | ||
72 | return -1; | ||
73 | |||
74 | /* Configure clock */ | ||
75 | sccr = in_be32(immap + MPC83XX_SCCR_OFFS); | ||
76 | if (port0_is_dr) | ||
77 | sccr |= MPC83XX_SCCR_USB_DRCM_11; /* 1:3 */ | ||
78 | else | ||
79 | sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */ | ||
80 | out_be32(immap + MPC83XX_SCCR_OFFS, sccr); | ||
81 | |||
82 | /* Configure Pin */ | ||
83 | sicrl = in_be32(immap + MPC83XX_SICRL_OFFS); | ||
84 | /* set port0 only */ | ||
85 | if (port0_is_dr) | ||
86 | sicrl |= MPC83XX_SICRL_USB0; | ||
87 | else | ||
88 | sicrl &= ~(MPC83XX_SICRL_USB0); | ||
89 | out_be32(immap + MPC83XX_SICRL_OFFS, sicrl); | ||
90 | |||
91 | iounmap(immap); | ||
92 | 47 | ||
48 | mpc834x_usb_cfg(); | ||
93 | /* Map BCSR area */ | 49 | /* Map BCSR area */ |
94 | np = of_find_node_by_name(NULL, "bcsr"); | 50 | np = of_find_node_by_name(NULL, "bcsr"); |
95 | if (np != 0) { | 51 | if (np) { |
96 | struct resource res; | 52 | struct resource res; |
97 | 53 | ||
98 | of_address_to_resource(np, 0, &res); | 54 | of_address_to_resource(np, 0, &res); |
@@ -129,12 +85,12 @@ static void __init mpc834x_mds_setup_arch(void) | |||
129 | 85 | ||
130 | #ifdef CONFIG_PCI | 86 | #ifdef CONFIG_PCI |
131 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) | 87 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) |
132 | add_bridge(np); | 88 | mpc83xx_add_bridge(np); |
133 | 89 | ||
134 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; | 90 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; |
135 | #endif | 91 | #endif |
136 | 92 | ||
137 | mpc834x_usb_cfg(); | 93 | mpc834xemds_usb_cfg(); |
138 | } | 94 | } |
139 | 95 | ||
140 | static void __init mpc834x_mds_init_IRQ(void) | 96 | static void __init mpc834x_mds_init_IRQ(void) |
diff --git a/arch/powerpc/platforms/83xx/mpc836x_mds.c b/arch/powerpc/platforms/83xx/mpc836x_mds.c index bceeff8bbfd2..0e615fd65c1f 100644 --- a/arch/powerpc/platforms/83xx/mpc836x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc836x_mds.c | |||
@@ -55,11 +55,6 @@ | |||
55 | #define DBG(fmt...) | 55 | #define DBG(fmt...) |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #ifndef CONFIG_PCI | ||
59 | unsigned long isa_io_base = 0; | ||
60 | unsigned long isa_mem_base = 0; | ||
61 | #endif | ||
62 | |||
63 | static u8 *bcsr_regs = NULL; | 58 | static u8 *bcsr_regs = NULL; |
64 | 59 | ||
65 | /* ************************************************************************ | 60 | /* ************************************************************************ |
@@ -86,7 +81,7 @@ static void __init mpc836x_mds_setup_arch(void) | |||
86 | 81 | ||
87 | #ifdef CONFIG_PCI | 82 | #ifdef CONFIG_PCI |
88 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) | 83 | for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) |
89 | add_bridge(np); | 84 | mpc83xx_add_bridge(np); |
90 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; | 85 | ppc_md.pci_exclude_device = mpc83xx_exclude_device; |
91 | #endif | 86 | #endif |
92 | 87 | ||
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h index 9cd03b59c8f4..589ee55730f3 100644 --- a/arch/powerpc/platforms/83xx/mpc83xx.h +++ b/arch/powerpc/platforms/83xx/mpc83xx.h | |||
@@ -3,9 +3,11 @@ | |||
3 | 3 | ||
4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
5 | #include <linux/device.h> | 5 | #include <linux/device.h> |
6 | #include <asm/pci-bridge.h> | ||
6 | 7 | ||
7 | /* System Clock Control Register */ | 8 | /* System Clock Control Register */ |
8 | #define MPC83XX_SCCR_OFFS 0xA08 | 9 | #define MPC83XX_SCCR_OFFS 0xA08 |
10 | #define MPC83XX_SCCR_USB_MASK 0x00f00000 | ||
9 | #define MPC83XX_SCCR_USB_MPHCM_11 0x00c00000 | 11 | #define MPC83XX_SCCR_USB_MPHCM_11 0x00c00000 |
10 | #define MPC83XX_SCCR_USB_MPHCM_01 0x00400000 | 12 | #define MPC83XX_SCCR_USB_MPHCM_01 0x00400000 |
11 | #define MPC83XX_SCCR_USB_MPHCM_10 0x00800000 | 13 | #define MPC83XX_SCCR_USB_MPHCM_10 0x00800000 |
@@ -15,21 +17,43 @@ | |||
15 | 17 | ||
16 | /* system i/o configuration register low */ | 18 | /* system i/o configuration register low */ |
17 | #define MPC83XX_SICRL_OFFS 0x114 | 19 | #define MPC83XX_SICRL_OFFS 0x114 |
18 | #define MPC83XX_SICRL_USB0 0x40000000 | 20 | #define MPC834X_SICRL_USB_MASK 0x60000000 |
19 | #define MPC83XX_SICRL_USB1 0x20000000 | 21 | #define MPC834X_SICRL_USB0 0x40000000 |
22 | #define MPC834X_SICRL_USB1 0x20000000 | ||
23 | #define MPC831X_SICRL_USB_MASK 0x00000c00 | ||
24 | #define MPC831X_SICRL_USB_ULPI 0x00000800 | ||
20 | 25 | ||
21 | /* system i/o configuration register high */ | 26 | /* system i/o configuration register high */ |
22 | #define MPC83XX_SICRH_OFFS 0x118 | 27 | #define MPC83XX_SICRH_OFFS 0x118 |
23 | #define MPC83XX_SICRH_USB_UTMI 0x00020000 | 28 | #define MPC834X_SICRH_USB_UTMI 0x00020000 |
29 | #define MPC831X_SICRH_USB_MASK 0x000000e0 | ||
30 | #define MPC831X_SICRH_USB_ULPI 0x000000a0 | ||
31 | |||
32 | /* USB Control Register */ | ||
33 | #define FSL_USB2_CONTROL_OFFS 0x500 | ||
34 | #define CONTROL_UTMI_PHY_EN 0x00000200 | ||
35 | #define CONTROL_REFSEL_48MHZ 0x00000080 | ||
36 | #define CONTROL_PHY_CLK_SEL_ULPI 0x00000400 | ||
37 | #define CONTROL_OTG_PORT 0x00000020 | ||
38 | |||
39 | /* USB PORTSC Registers */ | ||
40 | #define FSL_USB2_PORTSC1_OFFS 0x184 | ||
41 | #define FSL_USB2_PORTSC2_OFFS 0x188 | ||
42 | #define PORTSCX_PTW_16BIT 0x10000000 | ||
43 | #define PORTSCX_PTS_UTMI 0x00000000 | ||
44 | #define PORTSCX_PTS_ULPI 0x80000000 | ||
24 | 45 | ||
25 | /* | 46 | /* |
26 | * Declaration for the various functions exported by the | 47 | * Declaration for the various functions exported by the |
27 | * mpc83xx_* files. Mostly for use by mpc83xx_setup | 48 | * mpc83xx_* files. Mostly for use by mpc83xx_setup |
28 | */ | 49 | */ |
29 | 50 | ||
30 | extern int add_bridge(struct device_node *dev); | 51 | extern int mpc83xx_add_bridge(struct device_node *dev); |
31 | extern int mpc83xx_exclude_device(u_char bus, u_char devfn); | 52 | extern int mpc83xx_exclude_device(struct pci_controller *hose, |
53 | u_char bus, u_char devfn); | ||
32 | extern void mpc83xx_restart(char *cmd); | 54 | extern void mpc83xx_restart(char *cmd); |
33 | extern long mpc83xx_time_init(void); | 55 | extern long mpc83xx_time_init(void); |
56 | extern int mpc834x_usb_cfg(void); | ||
57 | extern int mpc831x_usb_cfg(void); | ||
34 | 58 | ||
35 | #endif /* __MPC83XX_H__ */ | 59 | #endif /* __MPC83XX_H__ */ |
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c index 774457d09e94..c0e2b89154e5 100644 --- a/arch/powerpc/platforms/83xx/pci.c +++ b/arch/powerpc/platforms/83xx/pci.c | |||
@@ -33,19 +33,14 @@ | |||
33 | #define DBG(x...) | 33 | #define DBG(x...) |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | int mpc83xx_pci2_busno; | 36 | int mpc83xx_exclude_device(struct pci_controller *hose, u_char bus, u_char devfn) |
37 | |||
38 | int mpc83xx_exclude_device(u_char bus, u_char devfn) | ||
39 | { | 37 | { |
40 | if (bus == 0 && PCI_SLOT(devfn) == 0) | 38 | if ((bus == hose->first_busno) && PCI_SLOT(devfn) == 0) |
41 | return PCIBIOS_DEVICE_NOT_FOUND; | 39 | return PCIBIOS_DEVICE_NOT_FOUND; |
42 | if (mpc83xx_pci2_busno) | ||
43 | if (bus == (mpc83xx_pci2_busno) && PCI_SLOT(devfn) == 0) | ||
44 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
45 | return PCIBIOS_SUCCESSFUL; | 40 | return PCIBIOS_SUCCESSFUL; |
46 | } | 41 | } |
47 | 42 | ||
48 | int __init add_bridge(struct device_node *dev) | 43 | int __init mpc83xx_add_bridge(struct device_node *dev) |
49 | { | 44 | { |
50 | int len; | 45 | int len; |
51 | struct pci_controller *hose; | 46 | struct pci_controller *hose; |
@@ -66,11 +61,10 @@ int __init add_bridge(struct device_node *dev) | |||
66 | " bus 0\n", dev->full_name); | 61 | " bus 0\n", dev->full_name); |
67 | } | 62 | } |
68 | 63 | ||
69 | hose = pcibios_alloc_controller(); | 64 | pci_assign_all_buses = 1; |
65 | hose = pcibios_alloc_controller(dev); | ||
70 | if (!hose) | 66 | if (!hose) |
71 | return -ENOMEM; | 67 | return -ENOMEM; |
72 | hose->arch_data = dev; | ||
73 | hose->set_cfg_type = 1; | ||
74 | 68 | ||
75 | hose->first_busno = bus_range ? bus_range[0] : 0; | 69 | hose->first_busno = bus_range ? bus_range[0] : 0; |
76 | hose->last_busno = bus_range ? bus_range[1] : 0xff; | 70 | hose->last_busno = bus_range ? bus_range[1] : 0xff; |
@@ -86,8 +80,6 @@ int __init add_bridge(struct device_node *dev) | |||
86 | if ((rsrc.start & 0xfffff) == 0x8600) { | 80 | if ((rsrc.start & 0xfffff) == 0x8600) { |
87 | setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384); | 81 | setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384); |
88 | primary = 0; | 82 | primary = 0; |
89 | hose->bus_offset = hose->first_busno; | ||
90 | mpc83xx_pci2_busno = hose->first_busno; | ||
91 | } | 83 | } |
92 | 84 | ||
93 | printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%016llx. " | 85 | printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%016llx. " |
diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c new file mode 100644 index 000000000000..e7fdf013cd39 --- /dev/null +++ b/arch/powerpc/platforms/83xx/usb.c | |||
@@ -0,0 +1,181 @@ | |||
1 | /* | ||
2 | * Freescale 83xx USB SOC setup code | ||
3 | * | ||
4 | * Copyright (C) 2007 Freescale Semiconductor, Inc. | ||
5 | * Author: Li Yang | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | |||
13 | |||
14 | #include <linux/stddef.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/errno.h> | ||
17 | |||
18 | #include <asm/io.h> | ||
19 | #include <asm/prom.h> | ||
20 | #include <sysdev/fsl_soc.h> | ||
21 | |||
22 | #include "mpc83xx.h" | ||
23 | |||
24 | |||
25 | #ifdef CONFIG_MPC834x | ||
26 | int mpc834x_usb_cfg(void) | ||
27 | { | ||
28 | unsigned long sccr, sicrl, sicrh; | ||
29 | void __iomem *immap; | ||
30 | struct device_node *np = NULL; | ||
31 | int port0_is_dr = 0, port1_is_dr = 0; | ||
32 | const void *prop, *dr_mode; | ||
33 | |||
34 | immap = ioremap(get_immrbase(), 0x1000); | ||
35 | if (!immap) | ||
36 | return -ENOMEM; | ||
37 | |||
38 | /* Read registers */ | ||
39 | /* Note: DR and MPH must use the same clock setting in SCCR */ | ||
40 | sccr = in_be32(immap + MPC83XX_SCCR_OFFS) & ~MPC83XX_SCCR_USB_MASK; | ||
41 | sicrl = in_be32(immap + MPC83XX_SICRL_OFFS) & ~MPC834X_SICRL_USB_MASK; | ||
42 | sicrh = in_be32(immap + MPC83XX_SICRH_OFFS) & ~MPC834X_SICRH_USB_UTMI; | ||
43 | |||
44 | np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr"); | ||
45 | if (np) { | ||
46 | sccr |= MPC83XX_SCCR_USB_DRCM_11; /* 1:3 */ | ||
47 | |||
48 | prop = of_get_property(np, "phy_type", NULL); | ||
49 | if (prop && (!strcmp(prop, "utmi") || | ||
50 | !strcmp(prop, "utmi_wide"))) { | ||
51 | sicrl |= MPC834X_SICRL_USB0 | MPC834X_SICRL_USB1; | ||
52 | sicrh |= MPC834X_SICRH_USB_UTMI; | ||
53 | port1_is_dr = 1; | ||
54 | } else if (prop && !strcmp(prop, "serial")) { | ||
55 | dr_mode = of_get_property(np, "dr_mode", NULL); | ||
56 | if (dr_mode && !strcmp(dr_mode, "otg")) { | ||
57 | sicrl |= MPC834X_SICRL_USB0 | MPC834X_SICRL_USB1; | ||
58 | port1_is_dr = 1; | ||
59 | } else { | ||
60 | sicrl |= MPC834X_SICRL_USB0; | ||
61 | } | ||
62 | } else if (prop && !strcmp(prop, "ulpi")) { | ||
63 | sicrl |= MPC834X_SICRL_USB0; | ||
64 | } else { | ||
65 | printk(KERN_WARNING "834x USB PHY type not supported\n"); | ||
66 | } | ||
67 | port0_is_dr = 1; | ||
68 | of_node_put(np); | ||
69 | } | ||
70 | np = of_find_compatible_node(NULL, "usb", "fsl-usb2-mph"); | ||
71 | if (np) { | ||
72 | sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */ | ||
73 | |||
74 | prop = of_get_property(np, "port0", NULL); | ||
75 | if (prop) { | ||
76 | if (port0_is_dr) | ||
77 | printk(KERN_WARNING | ||
78 | "834x USB port0 can't be used by both DR and MPH!\n"); | ||
79 | sicrl |= MPC834X_SICRL_USB0; | ||
80 | } | ||
81 | prop = of_get_property(np, "port1", NULL); | ||
82 | if (prop) { | ||
83 | if (port1_is_dr) | ||
84 | printk(KERN_WARNING | ||
85 | "834x USB port1 can't be used by both DR and MPH!\n"); | ||
86 | sicrl |= MPC834X_SICRL_USB1; | ||
87 | } | ||
88 | of_node_put(np); | ||
89 | } | ||
90 | |||
91 | /* Write back */ | ||
92 | out_be32(immap + MPC83XX_SCCR_OFFS, sccr); | ||
93 | out_be32(immap + MPC83XX_SICRL_OFFS, sicrl); | ||
94 | out_be32(immap + MPC83XX_SICRH_OFFS, sicrh); | ||
95 | |||
96 | iounmap(immap); | ||
97 | return 0; | ||
98 | } | ||
99 | #endif /* CONFIG_MPC834x */ | ||
100 | |||
101 | #ifdef CONFIG_PPC_MPC831x | ||
102 | int mpc831x_usb_cfg(void) | ||
103 | { | ||
104 | u32 temp; | ||
105 | void __iomem *immap, *usb_regs; | ||
106 | struct device_node *np = NULL; | ||
107 | const void *prop; | ||
108 | struct resource res; | ||
109 | int ret = 0; | ||
110 | #ifdef CONFIG_USB_OTG | ||
111 | const void *dr_mode; | ||
112 | #endif | ||
113 | |||
114 | np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr"); | ||
115 | if (!np) | ||
116 | return -ENODEV; | ||
117 | prop = of_get_property(np, "phy_type", NULL); | ||
118 | |||
119 | /* Map IMMR space for pin and clock settings */ | ||
120 | immap = ioremap(get_immrbase(), 0x1000); | ||
121 | if (!immap) { | ||
122 | of_node_put(np); | ||
123 | return -ENOMEM; | ||
124 | } | ||
125 | |||
126 | /* Configure clock */ | ||
127 | temp = in_be32(immap + MPC83XX_SCCR_OFFS); | ||
128 | temp &= ~MPC83XX_SCCR_USB_MASK; | ||
129 | temp |= MPC83XX_SCCR_USB_DRCM_11; /* 1:3 */ | ||
130 | out_be32(immap + MPC83XX_SCCR_OFFS, temp); | ||
131 | |||
132 | /* Configure pin mux for ULPI. There is no pin mux for UTMI */ | ||
133 | if (!strcmp(prop, "ulpi")) { | ||
134 | temp = in_be32(immap + MPC83XX_SICRL_OFFS); | ||
135 | temp &= ~MPC831X_SICRL_USB_MASK; | ||
136 | temp |= MPC831X_SICRL_USB_ULPI; | ||
137 | out_be32(immap + MPC83XX_SICRL_OFFS, temp); | ||
138 | |||
139 | temp = in_be32(immap + MPC83XX_SICRH_OFFS); | ||
140 | temp &= ~MPC831X_SICRH_USB_MASK; | ||
141 | temp |= MPC831X_SICRH_USB_ULPI; | ||
142 | out_be32(immap + MPC83XX_SICRH_OFFS, temp); | ||
143 | } | ||
144 | |||
145 | iounmap(immap); | ||
146 | |||
147 | /* Map USB SOC space */ | ||
148 | ret = of_address_to_resource(np, 0, &res); | ||
149 | if (ret) { | ||
150 | of_node_put(np); | ||
151 | return ret; | ||
152 | } | ||
153 | usb_regs = ioremap(res.start, res.end - res.start + 1); | ||
154 | |||
155 | /* Using on-chip PHY */ | ||
156 | if (!strcmp(prop, "utmi_wide") || | ||
157 | !strcmp(prop, "utmi")) { | ||
158 | /* Set UTMI_PHY_EN, REFSEL to 48MHZ */ | ||
159 | out_be32(usb_regs + FSL_USB2_CONTROL_OFFS, | ||
160 | CONTROL_UTMI_PHY_EN | CONTROL_REFSEL_48MHZ); | ||
161 | /* Using external UPLI PHY */ | ||
162 | } else if (!strcmp(prop, "ulpi")) { | ||
163 | /* Set PHY_CLK_SEL to ULPI */ | ||
164 | temp = CONTROL_PHY_CLK_SEL_ULPI; | ||
165 | #ifdef CONFIG_USB_OTG | ||
166 | /* Set OTG_PORT */ | ||
167 | dr_mode = of_get_property(np, "dr_mode", NULL); | ||
168 | if (dr_mode && !strcmp(dr_mode, "otg")) | ||
169 | temp |= CONTROL_OTG_PORT; | ||
170 | #endif /* CONFIG_USB_OTG */ | ||
171 | out_be32(usb_regs + FSL_USB2_CONTROL_OFFS, temp); | ||
172 | } else { | ||
173 | printk(KERN_WARNING "831x USB PHY type not supported\n"); | ||
174 | ret = -EINVAL; | ||
175 | } | ||
176 | |||
177 | iounmap(usb_regs); | ||
178 | of_node_put(np); | ||
179 | return ret; | ||
180 | } | ||
181 | #endif /* CONFIG_PPC_MPC831x */ | ||