2 * The setup file for USB related hardware on PMC-Sierra MSP processors.
4 * Copyright 2006-2007 PMC-Sierra, Inc.
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.
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.
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.
27 #include <linux/dma-mapping.h>
28 #include <linux/init.h>
29 #include <linux/ioport.h>
30 #include <linux/platform_device.h>
32 #include <asm/mipsregs.h>
38 #if defined(CONFIG_USB_EHCI_HCD)
39 static struct resource msp_usbhost_resources [] = {
41 .start = MSP_USB_BASE_START,
42 .end = MSP_USB_BASE_END,
43 .flags = IORESOURCE_MEM,
48 .flags = IORESOURCE_IRQ,
52 static u64 msp_usbhost_dma_mask = DMA_32BIT_MASK;
54 static struct platform_device msp_usbhost_device = {
55 .name = "pmcmsp-ehci",
58 .dma_mask = &msp_usbhost_dma_mask,
59 .coherent_dma_mask = DMA_32BIT_MASK,
61 .num_resources = ARRAY_SIZE (msp_usbhost_resources),
62 .resource = msp_usbhost_resources,
64 #endif /* CONFIG_USB_EHCI_HCD */
66 #if defined(CONFIG_USB_GADGET)
67 static struct resource msp_usbdev_resources [] = {
69 .start = MSP_USB_BASE,
70 .end = MSP_USB_BASE_END,
71 .flags = IORESOURCE_MEM,
76 .flags = IORESOURCE_IRQ,
80 static u64 msp_usbdev_dma_mask = DMA_32BIT_MASK;
82 static struct platform_device msp_usbdev_device = {
83 .name = "msp71xx_udc",
86 .dma_mask = &msp_usbdev_dma_mask,
87 .coherent_dma_mask = DMA_32BIT_MASK,
89 .num_resources = ARRAY_SIZE (msp_usbdev_resources),
90 .resource = msp_usbdev_resources,
92 #endif /* CONFIG_USB_GADGET */
94 #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET)
95 static struct platform_device *msp_devs[1];
99 static int __init msp_usb_setup(void)
101 #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET)
104 unsigned int val = 0;
108 * construct environment name usbmode
109 * set usbmode <host/device> as pmon environment var
111 snprintf((char *)&envstr[0], sizeof(envstr), "usbmode");
113 #if defined(CONFIG_USB_EHCI_HCD)
114 /* default to host mode */
118 /* get environment string */
119 strp = prom_getenv((char *)&envstr[0]);
121 if (!strcmp(strp, "device"))
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",
132 result = platform_add_devices(msp_devs, ARRAY_SIZE (msp_devs));
133 #endif /* CONFIG_USB_EHCI_HCD */
135 #if defined(CONFIG_USB_GADGET)
137 /* get device mode structure */
138 msp_devs[0] = &msp_usbdev_device;
139 ppfinit("platform add USB DEVICE done %s.\n",
142 result = platform_add_devices(msp_devs, ARRAY_SIZE (msp_devs));
144 #endif /* CONFIG_USB_GADGET */
145 #endif /* CONFIG_USB_EHCI_HCD || CONFIG_USB_GADGET */
150 subsys_initcall(msp_usb_setup);