mac80211: share sta->supp_rates
[linux/fpc-iii.git] / arch / mips / pmc-sierra / msp71xx / msp_usb.c
blobf7ca4f58233168ea3a2e9fd84dfa208f2fbaa596
1 /*
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>
34 #include <msp_regs.h>
35 #include <msp_int.h>
36 #include <msp_prom.h>
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,
45 [1] = {
46 .start = MSP_INT_USB,
47 .end = MSP_INT_USB,
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",
56 .id = 0,
57 .dev = {
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 [] = {
68 [0] = {
69 .start = MSP_USB_BASE,
70 .end = MSP_USB_BASE_END,
71 .flags = IORESOURCE_MEM,
73 [1] = {
74 .start = MSP_INT_USB,
75 .end = MSP_INT_USB,
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",
84 .id = 0,
85 .dev = {
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];
96 #endif
99 static int __init msp_usb_setup(void)
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;
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 */
115 val = 1;
116 #endif
118 /* get environment string */
119 strp = prom_getenv((char *)&envstr[0]);
120 if (strp) {
121 if (!strcmp(strp, "device"))
122 val = 0;
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);
132 result = platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs));
133 #endif /* CONFIG_USB_EHCI_HCD */
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);
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 */
147 return result;
150 subsys_initcall(msp_usb_setup);