Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 1 | /* |
| 2 | * The setup file for USB related hardware on PMC-Sierra MSP processors. |
| 3 | * |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 4 | * Copyright 2006 PMC-Sierra, Inc. |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 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 | */ |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 26 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET) |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 27 | |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 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> |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 37 | #include <msp_usb.h> |
| 38 | |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 39 | |
| 40 | #if defined(CONFIG_USB_EHCI_HCD) |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 41 | static struct resource msp_usbhost0_resources[] = { |
| 42 | [0] = { /* EHCI-HS operational and capabilities registers */ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 43 | .start = MSP_USB0_HS_START, |
| 44 | .end = MSP_USB0_HS_END, |
| 45 | .flags = IORESOURCE_MEM, |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 46 | }, |
| 47 | [1] = { |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 48 | .start = MSP_INT_USB, |
| 49 | .end = MSP_INT_USB, |
| 50 | .flags = IORESOURCE_IRQ, |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 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, |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 61 | }, |
| 62 | }; |
| 63 | |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 64 | static u64 msp_usbhost0_dma_mask = 0xffffffffUL; |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 65 | |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 66 | static struct mspusb_device msp_usbhost0_device = { |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 67 | .dev = { |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 68 | .name = "pmcmsp-ehci", |
| 69 | .id = 0, |
| 70 | .dev = { |
| 71 | .dma_mask = &msp_usbhost0_dma_mask, |
| 72 | .coherent_dma_mask = 0xffffffffUL, |
| 73 | }, |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 74 | .num_resources = ARRAY_SIZE(msp_usbhost0_resources), |
| 75 | .resource = msp_usbhost0_resources, |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 76 | }, |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 77 | }; |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 78 | #endif /* CONFIG_USB_EHCI_HCD */ |
| 79 | |
| 80 | #if defined(CONFIG_USB_GADGET) |
| 81 | static struct resource msp_usbdev0_resources[] = { |
| 82 | [0] = { /* EHCI-HS operational and capabilities registers */ |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 83 | .start = MSP_USB0_HS_START, |
| 84 | .end = MSP_USB0_HS_END, |
| 85 | .flags = IORESOURCE_MEM, |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 86 | }, |
| 87 | [1] = { |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 88 | .start = MSP_INT_USB, |
| 89 | .end = MSP_INT_USB, |
| 90 | .flags = IORESOURCE_IRQ, |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 91 | }, |
| 92 | [2] = { /* MSBus-to-AMBA bridge register space */ |
| 93 | .start = MSP_USB0_MAB_START, |
| 94 | .end = MSP_USB0_MAB_END, |
| 95 | .flags = IORESOURCE_MEM, |
| 96 | }, |
| 97 | [3] = { /* Identification and general hardware parameters */ |
| 98 | .start = MSP_USB0_ID_START, |
| 99 | .end = MSP_USB0_ID_END, |
| 100 | .flags = IORESOURCE_MEM, |
| 101 | }, |
| 102 | }; |
| 103 | |
| 104 | static u64 msp_usbdev_dma_mask = 0xffffffffUL; |
| 105 | |
| 106 | /* This may need to be converted to a mspusb_device, too. */ |
| 107 | static struct mspusb_device msp_usbdev0_device = { |
| 108 | .dev = { |
| 109 | .name = "msp71xx_udc", |
| 110 | .id = 0, |
| 111 | .dev = { |
| 112 | .dma_mask = &msp_usbdev_dma_mask, |
| 113 | .coherent_dma_mask = 0xffffffffUL, |
| 114 | }, |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 115 | .num_resources = ARRAY_SIZE(msp_usbdev0_resources), |
| 116 | .resource = msp_usbdev0_resources, |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 117 | }, |
| 118 | }; |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 119 | #endif /* CONFIG_USB_GADGET */ |
| 120 | |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 121 | static int __init msp_usb_setup(void) |
| 122 | { |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 123 | char *strp; |
| 124 | char envstr[32]; |
| 125 | struct platform_device *msp_devs[NUM_USB_DEVS]; |
| 126 | unsigned int val; |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 127 | |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 128 | /* construct environment name usbmode */ |
| 129 | /* set usbmode <host/device> as pmon environment var */ |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 130 | /* |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 131 | * Could this perhaps be integrated into the "features" env var? |
| 132 | * Use the features key "U", and follow with "H" for host-mode, |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 133 | * "D" for device-mode. If it works for Ethernet, why not USB... |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 134 | * -- hammtrev, 2007/03/22 |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 135 | */ |
| 136 | snprintf((char *)&envstr[0], sizeof(envstr), "usbmode"); |
| 137 | |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 138 | /* set default host mode */ |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 139 | val = 1; |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 140 | |
| 141 | /* get environment string */ |
| 142 | strp = prom_getenv((char *)&envstr[0]); |
| 143 | if (strp) { |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 144 | /* compare string */ |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 145 | if (!strcmp(strp, "device")) |
| 146 | val = 0; |
| 147 | } |
| 148 | |
| 149 | if (val) { |
| 150 | #if defined(CONFIG_USB_EHCI_HCD) |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 151 | msp_devs[0] = &msp_usbhost0_device.dev; |
| 152 | ppfinit("platform add USB HOST done %s.\n", msp_devs[0]->name); |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 153 | #else |
| 154 | ppfinit("%s: echi_hcd not supported\n", __FILE__); |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 155 | #endif /* CONFIG_USB_EHCI_HCD */ |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 156 | } else { |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 157 | #if defined(CONFIG_USB_GADGET) |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 158 | /* get device mode structure */ |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 159 | msp_devs[0] = &msp_usbdev0_device.dev; |
| 160 | ppfinit("platform add USB DEVICE done %s.\n" |
| 161 | , msp_devs[0]->name); |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 162 | #else |
| 163 | ppfinit("%s: usb_gadget not supported\n", __FILE__); |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 164 | #endif /* CONFIG_USB_GADGET */ |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 165 | } |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 166 | /* add device */ |
| 167 | platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs)); |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 168 | |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 169 | return 0; |
Marc St-Jean | 35832e2 | 2007-06-14 15:54:47 -0600 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | subsys_initcall(msp_usb_setup); |
Anoop P A | 5027070 | 2011-01-25 13:52:05 +0530 | [diff] [blame] | 173 | #endif /* CONFIG_USB_EHCI_HCD || CONFIG_USB_GADGET */ |