]>
Commit | Line | Data |
---|---|---|
35832e26 MSJ |
1 | /* |
2 | * The setup file for USB related hardware on PMC-Sierra MSP processors. | |
3 | * | |
4 | * Copyright 2006-2007 PMC-Sierra, Inc. | |
5 | * | |
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 | |
8 | * Free Software Foundation; either version 2 of the License, or (at your | |
9 | * option) any later version. | |
10 | * | |
11 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
12 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
13 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | |
14 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
15 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
16 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |
17 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
18 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
19 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
20 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License along | |
23 | * with this program; if not, write to the Free Software Foundation, Inc., | |
24 | * 675 Mass Ave, Cambridge, MA 02139, USA. | |
25 | */ | |
26 | ||
27 | #include <linux/dma-mapping.h> | |
28 | #include <linux/init.h> | |
29 | #include <linux/ioport.h> | |
30 | #include <linux/platform_device.h> | |
31 | ||
32 | #include <asm/mipsregs.h> | |
33 | ||
34 | #include <msp_regs.h> | |
35 | #include <msp_int.h> | |
36 | #include <msp_prom.h> | |
37 | ||
38 | #if defined(CONFIG_USB_EHCI_HCD) | |
39 | static struct resource msp_usbhost_resources [] = { | |
40 | [0] = { | |
41 | .start = MSP_USB_BASE_START, | |
42 | .end = MSP_USB_BASE_END, | |
43 | .flags = IORESOURCE_MEM, | |
44 | }, | |
45 | [1] = { | |
46 | .start = MSP_INT_USB, | |
47 | .end = MSP_INT_USB, | |
48 | .flags = IORESOURCE_IRQ, | |
49 | }, | |
50 | }; | |
51 | ||
284901a9 | 52 | static u64 msp_usbhost_dma_mask = DMA_BIT_MASK(32); |
35832e26 MSJ |
53 | |
54 | static struct platform_device msp_usbhost_device = { | |
55 | .name = "pmcmsp-ehci", | |
56 | .id = 0, | |
57 | .dev = { | |
58 | .dma_mask = &msp_usbhost_dma_mask, | |
284901a9 | 59 | .coherent_dma_mask = DMA_BIT_MASK(32), |
35832e26 | 60 | }, |
49a89efb | 61 | .num_resources = ARRAY_SIZE(msp_usbhost_resources), |
35832e26 MSJ |
62 | .resource = msp_usbhost_resources, |
63 | }; | |
64 | #endif /* CONFIG_USB_EHCI_HCD */ | |
65 | ||
66 | #if defined(CONFIG_USB_GADGET) | |
67 | static struct resource msp_usbdev_resources [] = { | |
68 | [0] = { | |
69 | .start = MSP_USB_BASE, | |
70 | .end = MSP_USB_BASE_END, | |
71 | .flags = IORESOURCE_MEM, | |
72 | }, | |
73 | [1] = { | |
74 | .start = MSP_INT_USB, | |
75 | .end = MSP_INT_USB, | |
76 | .flags = IORESOURCE_IRQ, | |
77 | }, | |
78 | }; | |
79 | ||
284901a9 | 80 | static u64 msp_usbdev_dma_mask = DMA_BIT_MASK(32); |
35832e26 MSJ |
81 | |
82 | static struct platform_device msp_usbdev_device = { | |
83 | .name = "msp71xx_udc", | |
84 | .id = 0, | |
85 | .dev = { | |
86 | .dma_mask = &msp_usbdev_dma_mask, | |
284901a9 | 87 | .coherent_dma_mask = DMA_BIT_MASK(32), |
35832e26 | 88 | }, |
49a89efb | 89 | .num_resources = ARRAY_SIZE(msp_usbdev_resources), |
35832e26 MSJ |
90 | .resource = msp_usbdev_resources, |
91 | }; | |
92 | #endif /* CONFIG_USB_GADGET */ | |
93 | ||
94 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET) | |
95 | static struct platform_device *msp_devs[1]; | |
96 | #endif | |
97 | ||
98 | ||
99 | static int __init msp_usb_setup(void) | |
100 | { | |
101 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET) | |
102 | char *strp; | |
103 | char envstr[32]; | |
104 | unsigned int val = 0; | |
105 | int result = 0; | |
106 | ||
107 | /* | |
108 | * construct environment name usbmode | |
109 | * set usbmode <host/device> as pmon environment var | |
110 | */ | |
111 | snprintf((char *)&envstr[0], sizeof(envstr), "usbmode"); | |
112 | ||
113 | #if defined(CONFIG_USB_EHCI_HCD) | |
114 | /* default to host mode */ | |
115 | val = 1; | |
116 | #endif | |
117 | ||
118 | /* get environment string */ | |
119 | strp = prom_getenv((char *)&envstr[0]); | |
120 | if (strp) { | |
121 | if (!strcmp(strp, "device")) | |
122 | val = 0; | |
123 | } | |
124 | ||
125 | if (val) { | |
126 | #if defined(CONFIG_USB_EHCI_HCD) | |
127 | /* get host mode device */ | |
128 | msp_devs[0] = &msp_usbhost_device; | |
129 | ppfinit("platform add USB HOST done %s.\n", | |
130 | msp_devs[0]->name); | |
131 | ||
49a89efb | 132 | result = platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs)); |
35832e26 MSJ |
133 | #endif /* CONFIG_USB_EHCI_HCD */ |
134 | } | |
135 | #if defined(CONFIG_USB_GADGET) | |
136 | else { | |
137 | /* get device mode structure */ | |
138 | msp_devs[0] = &msp_usbdev_device; | |
139 | ppfinit("platform add USB DEVICE done %s.\n", | |
140 | msp_devs[0]->name); | |
141 | ||
49a89efb | 142 | result = platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs)); |
35832e26 MSJ |
143 | } |
144 | #endif /* CONFIG_USB_GADGET */ | |
145 | #endif /* CONFIG_USB_EHCI_HCD || CONFIG_USB_GADGET */ | |
146 | ||
147 | return result; | |
148 | } | |
149 | ||
150 | subsys_initcall(msp_usb_setup); |