diff options
author | Anoop P A <anoop.pa@gmail.com> | 2011-01-25 03:22:05 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-03-25 13:45:14 -0400 |
commit | 5027070b3ca2eb90adbf40c2d67f792818ae9077 (patch) | |
tree | ad876c171a5bb7cf148b32bbc093ca86db69854d /arch/mips | |
parent | 088f3876fc9234feca0cdfdf710b8fafa87bfce1 (diff) |
MIPS: MSP71xx: Platform support for MSP on-chip USB controller.
Signed-off-by: Anoop P A <anoop.pa@gmail.com>
To: linux-mips@linux-mips.org
To: linux-kernel@vger.kernel.org
Cc: Anoop P A <anoop.pa@gmail.com>
Patchwork: https://patchwork.linux-mips.org/patch/2043/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h | 17 | ||||
-rw-r--r-- | arch/mips/include/asm/pmc-sierra/msp71xx/msp_usb.h | 144 | ||||
-rw-r--r-- | arch/mips/pmc-sierra/Kconfig | 5 | ||||
-rw-r--r-- | arch/mips/pmc-sierra/msp71xx/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/pmc-sierra/msp71xx/msp_usb.c | 239 |
5 files changed, 335 insertions, 72 deletions
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h index 603eb737b4a8..692c1b658b92 100644 --- a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h +++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h | |||
@@ -91,12 +91,10 @@ | |||
91 | /* MAC C device registers */ | 91 | /* MAC C device registers */ |
92 | #define MSP_ADSL2_BASE (MSP_MSB_BASE + 0xA80000) | 92 | #define MSP_ADSL2_BASE (MSP_MSB_BASE + 0xA80000) |
93 | /* ADSL2 device registers */ | 93 | /* ADSL2 device registers */ |
94 | #define MSP_USB_BASE (MSP_MSB_BASE + 0xB40000) | 94 | #define MSP_USB0_BASE (MSP_MSB_BASE + 0xB00000) |
95 | /* USB device registers */ | 95 | /* USB0 device registers */ |
96 | #define MSP_USB_BASE_START (MSP_MSB_BASE + 0xB40100) | 96 | #define MSP_USB1_BASE (MSP_MSB_BASE + 0x300000) |
97 | /* USB device registers */ | 97 | /* USB1 device registers */ |
98 | #define MSP_USB_BASE_END (MSP_MSB_BASE + 0xB401FF) | ||
99 | /* USB device registers */ | ||
100 | #define MSP_CPUIF_BASE (MSP_MSB_BASE + 0xC00000) | 98 | #define MSP_CPUIF_BASE (MSP_MSB_BASE + 0xC00000) |
101 | /* CPU interface registers */ | 99 | /* CPU interface registers */ |
102 | 100 | ||
@@ -319,8 +317,11 @@ | |||
319 | #define CPU_ERR2_REG regptr(MSP_SLP_BASE + 0x184) | 317 | #define CPU_ERR2_REG regptr(MSP_SLP_BASE + 0x184) |
320 | /* CPU/SLP Error status 1 */ | 318 | /* CPU/SLP Error status 1 */ |
321 | 319 | ||
322 | #define EXTENDED_GPIO_REG regptr(MSP_SLP_BASE + 0x188) | 320 | /* Extended GPIO registers */ |
323 | /* Extended GPIO register */ | 321 | #define EXTENDED_GPIO1_REG regptr(MSP_SLP_BASE + 0x188) |
322 | #define EXTENDED_GPIO2_REG regptr(MSP_SLP_BASE + 0x18c) | ||
323 | #define EXTENDED_GPIO_REG EXTENDED_GPIO1_REG | ||
324 | /* Backward-compatibility */ | ||
324 | 325 | ||
325 | /* System Error registers */ | 326 | /* System Error registers */ |
326 | #define SLP_ERR_STS_REG regptr(MSP_SLP_BASE + 0x190) | 327 | #define SLP_ERR_STS_REG regptr(MSP_SLP_BASE + 0x190) |
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_usb.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_usb.h new file mode 100644 index 000000000000..4c9348df9df2 --- /dev/null +++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_usb.h | |||
@@ -0,0 +1,144 @@ | |||
1 | /****************************************************************** | ||
2 | * Copyright (c) 2000-2007 PMC-Sierra INC. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it | ||
5 | * and/or modify it under the terms of the GNU General | ||
6 | * Public License as published by the Free Software | ||
7 | * Foundation; either version 2 of the License, or (at your | ||
8 | * option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be | ||
11 | * useful, but WITHOUT ANY WARRANTY; without even the implied | ||
12 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
13 | * PURPOSE. See the GNU General Public License for more | ||
14 | * details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public | ||
17 | * License along with this program; if not, write to the Free | ||
18 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA | ||
19 | * 02139, USA. | ||
20 | * | ||
21 | * PMC-SIERRA INC. DISCLAIMS ANY LIABILITY OF ANY KIND | ||
22 | * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS | ||
23 | * SOFTWARE. | ||
24 | */ | ||
25 | #ifndef MSP_USB_H_ | ||
26 | #define MSP_USB_H_ | ||
27 | |||
28 | #ifdef CONFIG_MSP_HAS_DUAL_USB | ||
29 | #define NUM_USB_DEVS 2 | ||
30 | #else | ||
31 | #define NUM_USB_DEVS 1 | ||
32 | #endif | ||
33 | |||
34 | /* Register spaces for USB host 0 */ | ||
35 | #define MSP_USB0_MAB_START (MSP_USB0_BASE + 0x0) | ||
36 | #define MSP_USB0_MAB_END (MSP_USB0_BASE + 0x17) | ||
37 | #define MSP_USB0_ID_START (MSP_USB0_BASE + 0x40000) | ||
38 | #define MSP_USB0_ID_END (MSP_USB0_BASE + 0x4008f) | ||
39 | #define MSP_USB0_HS_START (MSP_USB0_BASE + 0x40100) | ||
40 | #define MSP_USB0_HS_END (MSP_USB0_BASE + 0x401FF) | ||
41 | |||
42 | /* Register spaces for USB host 1 */ | ||
43 | #define MSP_USB1_MAB_START (MSP_USB1_BASE + 0x0) | ||
44 | #define MSP_USB1_MAB_END (MSP_USB1_BASE + 0x17) | ||
45 | #define MSP_USB1_ID_START (MSP_USB1_BASE + 0x40000) | ||
46 | #define MSP_USB1_ID_END (MSP_USB1_BASE + 0x4008f) | ||
47 | #define MSP_USB1_HS_START (MSP_USB1_BASE + 0x40100) | ||
48 | #define MSP_USB1_HS_END (MSP_USB1_BASE + 0x401ff) | ||
49 | |||
50 | /* USB Identification registers */ | ||
51 | struct msp_usbid_regs { | ||
52 | u32 id; /* 0x0: Identification register */ | ||
53 | u32 hwgen; /* 0x4: General HW params */ | ||
54 | u32 hwhost; /* 0x8: Host HW params */ | ||
55 | u32 hwdev; /* 0xc: Device HW params */ | ||
56 | u32 hwtxbuf; /* 0x10: Tx buffer HW params */ | ||
57 | u32 hwrxbuf; /* 0x14: Rx buffer HW params */ | ||
58 | u32 reserved[26]; | ||
59 | u32 timer0_load; /* 0x80: General-purpose timer 0 load*/ | ||
60 | u32 timer0_ctrl; /* 0x84: General-purpose timer 0 control */ | ||
61 | u32 timer1_load; /* 0x88: General-purpose timer 1 load*/ | ||
62 | u32 timer1_ctrl; /* 0x8c: General-purpose timer 1 control */ | ||
63 | }; | ||
64 | |||
65 | /* MSBus to AMBA registers */ | ||
66 | struct msp_mab_regs { | ||
67 | u32 isr; /* 0x0: Interrupt status */ | ||
68 | u32 imr; /* 0x4: Interrupt mask */ | ||
69 | u32 thcr0; /* 0x8: Transaction header capture 0 */ | ||
70 | u32 thcr1; /* 0xc: Transaction header capture 1 */ | ||
71 | u32 int_stat; /* 0x10: Interrupt status summary */ | ||
72 | u32 phy_cfg; /* 0x14: USB phy config */ | ||
73 | }; | ||
74 | |||
75 | /* EHCI registers */ | ||
76 | struct msp_usbhs_regs { | ||
77 | u32 hciver; /* 0x0: Version and offset to operational regs */ | ||
78 | u32 hcsparams; /* 0x4: Host control structural parameters */ | ||
79 | u32 hccparams; /* 0x8: Host control capability parameters */ | ||
80 | u32 reserved0[5]; | ||
81 | u32 dciver; /* 0x20: Device interface version */ | ||
82 | u32 dccparams; /* 0x24: Device control capability parameters */ | ||
83 | u32 reserved1[6]; | ||
84 | u32 cmd; /* 0x40: USB command */ | ||
85 | u32 sts; /* 0x44: USB status */ | ||
86 | u32 int_ena; /* 0x48: USB interrupt enable */ | ||
87 | u32 frindex; /* 0x4c: Frame index */ | ||
88 | u32 reserved3; | ||
89 | union { | ||
90 | struct { | ||
91 | u32 flb_addr; /* 0x54: Frame list base address */ | ||
92 | u32 next_async_addr; /* 0x58: next asynchronous addr */ | ||
93 | u32 ttctrl; /* 0x5c: embedded transaction translator | ||
94 | async buffer status */ | ||
95 | u32 burst_size; /* 0x60: Controller burst size */ | ||
96 | u32 tx_fifo_ctrl; /* 0x64: Tx latency FIFO tuning */ | ||
97 | u32 reserved0[4]; | ||
98 | u32 endpt_nak; /* 0x78: Endpoint NAK */ | ||
99 | u32 endpt_nak_ena; /* 0x7c: Endpoint NAK enable */ | ||
100 | u32 cfg_flag; /* 0x80: Config flag */ | ||
101 | u32 port_sc1; /* 0x84: Port status & control 1 */ | ||
102 | u32 reserved1[7]; | ||
103 | u32 otgsc; /* 0xa4: OTG status & control */ | ||
104 | u32 mode; /* 0xa8: USB controller mode */ | ||
105 | } host; | ||
106 | |||
107 | struct { | ||
108 | u32 dev_addr; /* 0x54: Device address */ | ||
109 | u32 endpt_list_addr; /* 0x58: Endpoint list address */ | ||
110 | u32 reserved0[7]; | ||
111 | u32 endpt_nak; /* 0x74 */ | ||
112 | u32 endpt_nak_ctrl; /* 0x78 */ | ||
113 | u32 cfg_flag; /* 0x80 */ | ||
114 | u32 port_sc1; /* 0x84: Port status & control 1 */ | ||
115 | u32 reserved[7]; | ||
116 | u32 otgsc; /* 0xa4: OTG status & control */ | ||
117 | u32 mode; /* 0xa8: USB controller mode */ | ||
118 | u32 endpt_setup_stat; /* 0xac */ | ||
119 | u32 endpt_prime; /* 0xb0 */ | ||
120 | u32 endpt_flush; /* 0xb4 */ | ||
121 | u32 endpt_stat; /* 0xb8 */ | ||
122 | u32 endpt_complete; /* 0xbc */ | ||
123 | u32 endpt_ctrl0; /* 0xc0 */ | ||
124 | u32 endpt_ctrl1; /* 0xc4 */ | ||
125 | u32 endpt_ctrl2; /* 0xc8 */ | ||
126 | u32 endpt_ctrl3; /* 0xcc */ | ||
127 | } device; | ||
128 | } u; | ||
129 | }; | ||
130 | /* | ||
131 | * Container for the more-generic platform_device. | ||
132 | * This exists mainly as a way to map the non-standard register | ||
133 | * spaces and make them accessible to the USB ISR. | ||
134 | */ | ||
135 | struct mspusb_device { | ||
136 | struct msp_mab_regs __iomem *mab_regs; | ||
137 | struct msp_usbid_regs __iomem *usbid_regs; | ||
138 | struct msp_usbhs_regs __iomem *usbhs_regs; | ||
139 | struct platform_device dev; | ||
140 | }; | ||
141 | |||
142 | #define to_mspusb_device(x) container_of((x), struct mspusb_device, dev) | ||
143 | #define TO_HOST_ID(x) ((x) & 0x3) | ||
144 | #endif /*MSP_USB_H_*/ | ||
diff --git a/arch/mips/pmc-sierra/Kconfig b/arch/mips/pmc-sierra/Kconfig index 8d798497c614..c437b8a8ab8c 100644 --- a/arch/mips/pmc-sierra/Kconfig +++ b/arch/mips/pmc-sierra/Kconfig | |||
@@ -23,6 +23,7 @@ config PMC_MSP7120_GW | |||
23 | select SYS_SUPPORTS_MULTITHREADING | 23 | select SYS_SUPPORTS_MULTITHREADING |
24 | select IRQ_MSP_CIC | 24 | select IRQ_MSP_CIC |
25 | select HW_HAS_PCI | 25 | select HW_HAS_PCI |
26 | select MSP_HAS_USB | ||
26 | 27 | ||
27 | config PMC_MSP7120_FPGA | 28 | config PMC_MSP7120_FPGA |
28 | bool "PMC-Sierra MSP7120 FPGA" | 29 | bool "PMC-Sierra MSP7120 FPGA" |
@@ -35,3 +36,7 @@ endchoice | |||
35 | config HYPERTRANSPORT | 36 | config HYPERTRANSPORT |
36 | bool "Hypertransport Support for PMC-Sierra Yosemite" | 37 | bool "Hypertransport Support for PMC-Sierra Yosemite" |
37 | depends on PMC_YOSEMITE | 38 | depends on PMC_YOSEMITE |
39 | |||
40 | config MSP_HAS_USB | ||
41 | boolean | ||
42 | depends on PMC_MSP | ||
diff --git a/arch/mips/pmc-sierra/msp71xx/Makefile b/arch/mips/pmc-sierra/msp71xx/Makefile index a002fa222b25..f26cab349c38 100644 --- a/arch/mips/pmc-sierra/msp71xx/Makefile +++ b/arch/mips/pmc-sierra/msp71xx/Makefile | |||
@@ -9,6 +9,6 @@ obj-$(CONFIG_IRQ_MSP_SLP) += msp_irq_slp.o | |||
9 | obj-$(CONFIG_IRQ_MSP_CIC) += msp_irq_cic.o msp_irq_per.o | 9 | obj-$(CONFIG_IRQ_MSP_CIC) += msp_irq_cic.o msp_irq_per.o |
10 | obj-$(CONFIG_PCI) += msp_pci.o | 10 | obj-$(CONFIG_PCI) += msp_pci.o |
11 | obj-$(CONFIG_MSPETH) += msp_eth.o | 11 | obj-$(CONFIG_MSPETH) += msp_eth.o |
12 | obj-$(CONFIG_USB_MSP71XX) += msp_usb.o | 12 | obj-$(CONFIG_MSP_HAS_USB) += msp_usb.o |
13 | obj-$(CONFIG_MIPS_MT_SMP) += msp_smp.o | 13 | obj-$(CONFIG_MIPS_MT_SMP) += msp_smp.o |
14 | obj-$(CONFIG_MIPS_MT_SMTC) += msp_smtc.o | 14 | obj-$(CONFIG_MIPS_MT_SMTC) += msp_smtc.o |
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_usb.c b/arch/mips/pmc-sierra/msp71xx/msp_usb.c index 0ee01e359dd8..9a1aef89bd4c 100644 --- a/arch/mips/pmc-sierra/msp71xx/msp_usb.c +++ b/arch/mips/pmc-sierra/msp71xx/msp_usb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * The setup file for USB related hardware on PMC-Sierra MSP processors. | 2 | * The setup file for USB related hardware on PMC-Sierra MSP processors. |
3 | * | 3 | * |
4 | * Copyright 2006-2007 PMC-Sierra, Inc. | 4 | * Copyright 2006 PMC-Sierra, Inc. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of the GNU General Public License as published by the | 7 | * under the terms of the GNU General Public License as published by the |
@@ -23,8 +23,8 @@ | |||
23 | * with this program; if not, write to the Free Software Foundation, Inc., | 23 | * with this program; if not, write to the Free Software Foundation, Inc., |
24 | * 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET) | ||
26 | 27 | ||
27 | #include <linux/dma-mapping.h> | ||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
@@ -34,40 +34,56 @@ | |||
34 | #include <msp_regs.h> | 34 | #include <msp_regs.h> |
35 | #include <msp_int.h> | 35 | #include <msp_int.h> |
36 | #include <msp_prom.h> | 36 | #include <msp_prom.h> |
37 | #include <msp_usb.h> | ||
38 | |||
37 | 39 | ||
38 | #if defined(CONFIG_USB_EHCI_HCD) | 40 | #if defined(CONFIG_USB_EHCI_HCD) |
39 | static struct resource msp_usbhost_resources [] = { | 41 | static struct resource msp_usbhost0_resources[] = { |
40 | [0] = { | 42 | [0] = { /* EHCI-HS operational and capabilities registers */ |
41 | .start = MSP_USB_BASE_START, | 43 | .start = MSP_USB0_HS_START, |
42 | .end = MSP_USB_BASE_END, | 44 | .end = MSP_USB0_HS_END, |
43 | .flags = IORESOURCE_MEM, | 45 | .flags = IORESOURCE_MEM, |
44 | }, | 46 | }, |
45 | [1] = { | 47 | [1] = { |
46 | .start = MSP_INT_USB, | 48 | .start = MSP_INT_USB, |
47 | .end = MSP_INT_USB, | 49 | .end = MSP_INT_USB, |
48 | .flags = IORESOURCE_IRQ, | 50 | .flags = IORESOURCE_IRQ, |
51 | }, | ||
52 | [2] = { /* MSBus-to-AMBA bridge register space */ | ||
53 | .start = MSP_USB0_MAB_START, | ||
54 | .end = MSP_USB0_MAB_END, | ||
55 | .flags = IORESOURCE_MEM, | ||
56 | }, | ||
57 | [3] = { /* Identification and general hardware parameters */ | ||
58 | .start = MSP_USB0_ID_START, | ||
59 | .end = MSP_USB0_ID_END, | ||
60 | .flags = IORESOURCE_MEM, | ||
49 | }, | 61 | }, |
50 | }; | 62 | }; |
51 | 63 | ||
52 | static u64 msp_usbhost_dma_mask = DMA_BIT_MASK(32); | 64 | static u64 msp_usbhost0_dma_mask = 0xffffffffUL; |
53 | 65 | ||
54 | static struct platform_device msp_usbhost_device = { | 66 | static struct mspusb_device msp_usbhost0_device = { |
55 | .name = "pmcmsp-ehci", | ||
56 | .id = 0, | ||
57 | .dev = { | 67 | .dev = { |
58 | .dma_mask = &msp_usbhost_dma_mask, | 68 | .name = "pmcmsp-ehci", |
59 | .coherent_dma_mask = DMA_BIT_MASK(32), | 69 | .id = 0, |
70 | .dev = { | ||
71 | .dma_mask = &msp_usbhost0_dma_mask, | ||
72 | .coherent_dma_mask = 0xffffffffUL, | ||
73 | }, | ||
74 | .num_resources = ARRAY_SIZE(msp_usbhost0_resources), | ||
75 | .resource = msp_usbhost0_resources, | ||
60 | }, | 76 | }, |
61 | .num_resources = ARRAY_SIZE(msp_usbhost_resources), | ||
62 | .resource = msp_usbhost_resources, | ||
63 | }; | 77 | }; |
64 | #endif /* CONFIG_USB_EHCI_HCD */ | ||
65 | 78 | ||
66 | #if defined(CONFIG_USB_GADGET) | 79 | /* MSP7140/MSP82XX has two USB2 hosts. */ |
67 | static struct resource msp_usbdev_resources [] = { | 80 | #ifdef CONFIG_MSP_HAS_DUAL_USB |
68 | [0] = { | 81 | static u64 msp_usbhost1_dma_mask = 0xffffffffUL; |
69 | .start = MSP_USB_BASE, | 82 | |
70 | .end = MSP_USB_BASE_END, | 83 | static struct resource msp_usbhost1_resources[] = { |
84 | [0] = { /* EHCI-HS operational and capabilities registers */ | ||
85 | .start = MSP_USB1_HS_START, | ||
86 | .end = MSP_USB1_HS_END, | ||
71 | .flags = IORESOURCE_MEM, | 87 | .flags = IORESOURCE_MEM, |
72 | }, | 88 | }, |
73 | [1] = { | 89 | [1] = { |
@@ -75,76 +91,173 @@ static struct resource msp_usbdev_resources [] = { | |||
75 | .end = MSP_INT_USB, | 91 | .end = MSP_INT_USB, |
76 | .flags = IORESOURCE_IRQ, | 92 | .flags = IORESOURCE_IRQ, |
77 | }, | 93 | }, |
94 | [2] = { /* MSBus-to-AMBA bridge register space */ | ||
95 | .start = MSP_USB1_MAB_START, | ||
96 | .end = MSP_USB1_MAB_END, | ||
97 | .flags = IORESOURCE_MEM, | ||
98 | }, | ||
99 | [3] = { /* Identification and general hardware parameters */ | ||
100 | .start = MSP_USB1_ID_START, | ||
101 | .end = MSP_USB1_ID_END, | ||
102 | .flags = IORESOURCE_MEM, | ||
103 | }, | ||
104 | }; | ||
105 | |||
106 | static struct mspusb_device msp_usbhost1_device = { | ||
107 | .dev = { | ||
108 | .name = "pmcmsp-ehci", | ||
109 | .id = 1, | ||
110 | .dev = { | ||
111 | .dma_mask = &msp_usbhost1_dma_mask, | ||
112 | .coherent_dma_mask = 0xffffffffUL, | ||
113 | }, | ||
114 | .num_resources = ARRAY_SIZE(msp_usbhost1_resources), | ||
115 | .resource = msp_usbhost1_resources, | ||
116 | }, | ||
78 | }; | 117 | }; |
118 | #endif /* CONFIG_MSP_HAS_DUAL_USB */ | ||
119 | #endif /* CONFIG_USB_EHCI_HCD */ | ||
79 | 120 | ||
80 | static u64 msp_usbdev_dma_mask = DMA_BIT_MASK(32); | 121 | #if defined(CONFIG_USB_GADGET) |
122 | static struct resource msp_usbdev0_resources[] = { | ||
123 | [0] = { /* EHCI-HS operational and capabilities registers */ | ||
124 | .start = MSP_USB0_HS_START, | ||
125 | .end = MSP_USB0_HS_END, | ||
126 | .flags = IORESOURCE_MEM, | ||
127 | }, | ||
128 | [1] = { | ||
129 | .start = MSP_INT_USB, | ||
130 | .end = MSP_INT_USB, | ||
131 | .flags = IORESOURCE_IRQ, | ||
132 | }, | ||
133 | [2] = { /* MSBus-to-AMBA bridge register space */ | ||
134 | .start = MSP_USB0_MAB_START, | ||
135 | .end = MSP_USB0_MAB_END, | ||
136 | .flags = IORESOURCE_MEM, | ||
137 | }, | ||
138 | [3] = { /* Identification and general hardware parameters */ | ||
139 | .start = MSP_USB0_ID_START, | ||
140 | .end = MSP_USB0_ID_END, | ||
141 | .flags = IORESOURCE_MEM, | ||
142 | }, | ||
143 | }; | ||
81 | 144 | ||
82 | static struct platform_device msp_usbdev_device = { | 145 | static u64 msp_usbdev_dma_mask = 0xffffffffUL; |
83 | .name = "msp71xx_udc", | 146 | |
84 | .id = 0, | 147 | /* This may need to be converted to a mspusb_device, too. */ |
148 | static struct mspusb_device msp_usbdev0_device = { | ||
85 | .dev = { | 149 | .dev = { |
86 | .dma_mask = &msp_usbdev_dma_mask, | 150 | .name = "msp71xx_udc", |
87 | .coherent_dma_mask = DMA_BIT_MASK(32), | 151 | .id = 0, |
152 | .dev = { | ||
153 | .dma_mask = &msp_usbdev_dma_mask, | ||
154 | .coherent_dma_mask = 0xffffffffUL, | ||
155 | }, | ||
156 | .num_resources = ARRAY_SIZE(msp_usbdev0_resources), | ||
157 | .resource = msp_usbdev0_resources, | ||
88 | }, | 158 | }, |
89 | .num_resources = ARRAY_SIZE(msp_usbdev_resources), | ||
90 | .resource = msp_usbdev_resources, | ||
91 | }; | 159 | }; |
92 | #endif /* CONFIG_USB_GADGET */ | ||
93 | 160 | ||
94 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET) | 161 | #ifdef CONFIG_MSP_HAS_DUAL_USB |
95 | static struct platform_device *msp_devs[1]; | 162 | static struct resource msp_usbdev1_resources[] = { |
96 | #endif | 163 | [0] = { /* EHCI-HS operational and capabilities registers */ |
164 | .start = MSP_USB1_HS_START, | ||
165 | .end = MSP_USB1_HS_END, | ||
166 | .flags = IORESOURCE_MEM, | ||
167 | }, | ||
168 | [1] = { | ||
169 | .start = MSP_INT_USB, | ||
170 | .end = MSP_INT_USB, | ||
171 | .flags = IORESOURCE_IRQ, | ||
172 | }, | ||
173 | [2] = { /* MSBus-to-AMBA bridge register space */ | ||
174 | .start = MSP_USB1_MAB_START, | ||
175 | .end = MSP_USB1_MAB_END, | ||
176 | .flags = IORESOURCE_MEM, | ||
177 | }, | ||
178 | [3] = { /* Identification and general hardware parameters */ | ||
179 | .start = MSP_USB1_ID_START, | ||
180 | .end = MSP_USB1_ID_END, | ||
181 | .flags = IORESOURCE_MEM, | ||
182 | }, | ||
183 | }; | ||
97 | 184 | ||
185 | /* This may need to be converted to a mspusb_device, too. */ | ||
186 | static struct mspusb_device msp_usbdev1_device = { | ||
187 | .dev = { | ||
188 | .name = "msp71xx_udc", | ||
189 | .id = 0, | ||
190 | .dev = { | ||
191 | .dma_mask = &msp_usbdev_dma_mask, | ||
192 | .coherent_dma_mask = 0xffffffffUL, | ||
193 | }, | ||
194 | .num_resources = ARRAY_SIZE(msp_usbdev1_resources), | ||
195 | .resource = msp_usbdev1_resources, | ||
196 | }, | ||
197 | }; | ||
198 | |||
199 | #endif /* CONFIG_MSP_HAS_DUAL_USB */ | ||
200 | #endif /* CONFIG_USB_GADGET */ | ||
98 | 201 | ||
99 | static int __init msp_usb_setup(void) | 202 | static int __init msp_usb_setup(void) |
100 | { | 203 | { |
101 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET) | 204 | char *strp; |
102 | char *strp; | 205 | char envstr[32]; |
103 | char envstr[32]; | 206 | struct platform_device *msp_devs[NUM_USB_DEVS]; |
104 | unsigned int val = 0; | 207 | unsigned int val; |
105 | int result = 0; | ||
106 | 208 | ||
209 | /* construct environment name usbmode */ | ||
210 | /* set usbmode <host/device> as pmon environment var */ | ||
107 | /* | 211 | /* |
108 | * construct environment name usbmode | 212 | * Could this perhaps be integrated into the "features" env var? |
109 | * set usbmode <host/device> as pmon environment var | 213 | * Use the features key "U", and follow with "H" for host-mode, |
214 | * "D" for device-mode. If it works for Ethernet, why not USB... | ||
215 | * -- hammtrev, 2007/03/22 | ||
110 | */ | 216 | */ |
111 | snprintf((char *)&envstr[0], sizeof(envstr), "usbmode"); | 217 | snprintf((char *)&envstr[0], sizeof(envstr), "usbmode"); |
112 | 218 | ||
113 | #if defined(CONFIG_USB_EHCI_HCD) | 219 | /* set default host mode */ |
114 | /* default to host mode */ | ||
115 | val = 1; | 220 | val = 1; |
116 | #endif | ||
117 | 221 | ||
118 | /* get environment string */ | 222 | /* get environment string */ |
119 | strp = prom_getenv((char *)&envstr[0]); | 223 | strp = prom_getenv((char *)&envstr[0]); |
120 | if (strp) { | 224 | if (strp) { |
225 | /* compare string */ | ||
121 | if (!strcmp(strp, "device")) | 226 | if (!strcmp(strp, "device")) |
122 | val = 0; | 227 | val = 0; |
123 | } | 228 | } |
124 | 229 | ||
125 | if (val) { | 230 | if (val) { |
126 | #if defined(CONFIG_USB_EHCI_HCD) | 231 | #if defined(CONFIG_USB_EHCI_HCD) |
127 | /* get host mode device */ | 232 | msp_devs[0] = &msp_usbhost0_device.dev; |
128 | msp_devs[0] = &msp_usbhost_device; | 233 | ppfinit("platform add USB HOST done %s.\n", msp_devs[0]->name); |
129 | ppfinit("platform add USB HOST done %s.\n", | 234 | #ifdef CONFIG_MSP_HAS_DUAL_USB |
130 | msp_devs[0]->name); | 235 | msp_devs[1] = &msp_usbhost1_device.dev; |
131 | 236 | ppfinit("platform add USB HOST done %s.\n", msp_devs[1]->name); | |
132 | result = platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs)); | 237 | #endif |
133 | #endif /* CONFIG_USB_EHCI_HCD */ | 238 | #else |
134 | } | 239 | ppfinit("%s: echi_hcd not supported\n", __FILE__); |
240 | #endif /* CONFIG_USB_EHCI_HCD */ | ||
241 | } else { | ||
135 | #if defined(CONFIG_USB_GADGET) | 242 | #if defined(CONFIG_USB_GADGET) |
136 | else { | ||
137 | /* get device mode structure */ | 243 | /* get device mode structure */ |
138 | msp_devs[0] = &msp_usbdev_device; | 244 | msp_devs[0] = &msp_usbdev0_device.dev; |
139 | ppfinit("platform add USB DEVICE done %s.\n", | 245 | ppfinit("platform add USB DEVICE done %s.\n" |
140 | msp_devs[0]->name); | 246 | , msp_devs[0]->name); |
141 | 247 | #ifdef CONFIG_MSP_HAS_DUAL_USB | |
142 | result = platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs)); | 248 | msp_devs[1] = &msp_usbdev1_device.dev; |
249 | ppfinit("platform add USB DEVICE done %s.\n" | ||
250 | , msp_devs[1]->name); | ||
251 | #endif | ||
252 | #else | ||
253 | ppfinit("%s: usb_gadget not supported\n", __FILE__); | ||
254 | #endif /* CONFIG_USB_GADGET */ | ||
143 | } | 255 | } |
144 | #endif /* CONFIG_USB_GADGET */ | 256 | /* add device */ |
145 | #endif /* CONFIG_USB_EHCI_HCD || CONFIG_USB_GADGET */ | 257 | platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs)); |
146 | 258 | ||
147 | return result; | 259 | return 0; |
148 | } | 260 | } |
149 | 261 | ||
150 | subsys_initcall(msp_usb_setup); | 262 | subsys_initcall(msp_usb_setup); |
263 | #endif /* CONFIG_USB_EHCI_HCD || CONFIG_USB_GADGET */ | ||