| Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2009 Amit Kucheria <amit.kucheria@canonical.com> | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 3 | * Copyright (C) 2010 Freescale Semiconductor, Inc. | 
| Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 4 | * | 
|  | 5 | * The code contained herein is licensed under the GNU General Public | 
|  | 6 | * License. You may obtain a copy of the GNU General Public License | 
|  | 7 | * Version 2 or later at the following locations: | 
|  | 8 | * | 
|  | 9 | * http://www.opensource.org/licenses/gpl-license.html | 
|  | 10 | * http://www.gnu.org/copyleft/gpl.html | 
|  | 11 | */ | 
|  | 12 |  | 
|  | 13 | #include <linux/platform_device.h> | 
| Dinh Nguyen | c53bdf1 | 2010-04-30 15:48:24 -0500 | [diff] [blame] | 14 | #include <linux/dma-mapping.h> | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 15 | #include <linux/gpio.h> | 
| Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 16 | #include <mach/hardware.h> | 
|  | 17 | #include <mach/imx-uart.h> | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 18 | #include <mach/irqs.h> | 
| Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 19 |  | 
|  | 20 | static struct resource uart0[] = { | 
|  | 21 | { | 
|  | 22 | .start = MX51_UART1_BASE_ADDR, | 
|  | 23 | .end = MX51_UART1_BASE_ADDR + 0xfff, | 
|  | 24 | .flags = IORESOURCE_MEM, | 
|  | 25 | }, { | 
|  | 26 | .start = MX51_MXC_INT_UART1, | 
|  | 27 | .end = MX51_MXC_INT_UART1, | 
|  | 28 | .flags = IORESOURCE_IRQ, | 
|  | 29 | }, | 
|  | 30 | }; | 
|  | 31 |  | 
|  | 32 | struct platform_device mxc_uart_device0 = { | 
|  | 33 | .name = "imx-uart", | 
|  | 34 | .id = 0, | 
|  | 35 | .resource = uart0, | 
|  | 36 | .num_resources = ARRAY_SIZE(uart0), | 
|  | 37 | }; | 
|  | 38 |  | 
|  | 39 | static struct resource uart1[] = { | 
|  | 40 | { | 
|  | 41 | .start = MX51_UART2_BASE_ADDR, | 
|  | 42 | .end = MX51_UART2_BASE_ADDR + 0xfff, | 
|  | 43 | .flags = IORESOURCE_MEM, | 
|  | 44 | }, { | 
|  | 45 | .start = MX51_MXC_INT_UART2, | 
|  | 46 | .end = MX51_MXC_INT_UART2, | 
|  | 47 | .flags = IORESOURCE_IRQ, | 
|  | 48 | }, | 
|  | 49 | }; | 
|  | 50 |  | 
|  | 51 | struct platform_device mxc_uart_device1 = { | 
|  | 52 | .name = "imx-uart", | 
|  | 53 | .id = 1, | 
|  | 54 | .resource = uart1, | 
|  | 55 | .num_resources = ARRAY_SIZE(uart1), | 
|  | 56 | }; | 
|  | 57 |  | 
|  | 58 | static struct resource uart2[] = { | 
|  | 59 | { | 
|  | 60 | .start = MX51_UART3_BASE_ADDR, | 
|  | 61 | .end = MX51_UART3_BASE_ADDR + 0xfff, | 
|  | 62 | .flags = IORESOURCE_MEM, | 
|  | 63 | }, { | 
|  | 64 | .start = MX51_MXC_INT_UART3, | 
|  | 65 | .end = MX51_MXC_INT_UART3, | 
|  | 66 | .flags = IORESOURCE_IRQ, | 
|  | 67 | }, | 
|  | 68 | }; | 
|  | 69 |  | 
|  | 70 | struct platform_device mxc_uart_device2 = { | 
|  | 71 | .name = "imx-uart", | 
|  | 72 | .id = 2, | 
|  | 73 | .resource = uart2, | 
|  | 74 | .num_resources = ARRAY_SIZE(uart2), | 
|  | 75 | }; | 
|  | 76 |  | 
|  | 77 | static struct resource mxc_fec_resources[] = { | 
|  | 78 | { | 
|  | 79 | .start	= MX51_MXC_FEC_BASE_ADDR, | 
|  | 80 | .end	= MX51_MXC_FEC_BASE_ADDR + 0xfff, | 
|  | 81 | .flags	= IORESOURCE_MEM, | 
|  | 82 | }, { | 
|  | 83 | .start	= MX51_MXC_INT_FEC, | 
|  | 84 | .end	= MX51_MXC_INT_FEC, | 
|  | 85 | .flags	= IORESOURCE_IRQ, | 
|  | 86 | }, | 
|  | 87 | }; | 
|  | 88 |  | 
|  | 89 | struct platform_device mxc_fec_device = { | 
|  | 90 | .name = "fec", | 
|  | 91 | .id = 0, | 
|  | 92 | .num_resources = ARRAY_SIZE(mxc_fec_resources), | 
|  | 93 | .resource = mxc_fec_resources, | 
|  | 94 | }; | 
|  | 95 |  | 
| Dinh Nguyen | 71c2e51 | 2010-05-27 10:45:04 -0500 | [diff] [blame] | 96 | static struct resource mxc_i2c0_resources[] = { | 
|  | 97 | { | 
|  | 98 | .start = MX51_I2C1_BASE_ADDR, | 
|  | 99 | .end = MX51_I2C1_BASE_ADDR + SZ_4K - 1, | 
|  | 100 | .flags = IORESOURCE_MEM, | 
|  | 101 | }, { | 
|  | 102 | .start = MX51_MXC_INT_I2C1, | 
|  | 103 | .end = MX51_MXC_INT_I2C1, | 
|  | 104 | .flags = IORESOURCE_IRQ, | 
|  | 105 | }, | 
|  | 106 | }; | 
|  | 107 |  | 
|  | 108 | struct platform_device mxc_i2c_device0 = { | 
|  | 109 | .name = "imx-i2c", | 
|  | 110 | .id = 0, | 
|  | 111 | .num_resources = ARRAY_SIZE(mxc_i2c0_resources), | 
|  | 112 | .resource = mxc_i2c0_resources, | 
|  | 113 | }; | 
|  | 114 |  | 
|  | 115 | static struct resource mxc_i2c1_resources[] = { | 
|  | 116 | { | 
|  | 117 | .start = MX51_I2C2_BASE_ADDR, | 
|  | 118 | .end = MX51_I2C2_BASE_ADDR + SZ_4K - 1, | 
|  | 119 | .flags = IORESOURCE_MEM, | 
|  | 120 | }, { | 
|  | 121 | .start = MX51_MXC_INT_I2C2, | 
|  | 122 | .end = MX51_MXC_INT_I2C2, | 
|  | 123 | .flags = IORESOURCE_IRQ, | 
|  | 124 | }, | 
|  | 125 | }; | 
|  | 126 |  | 
|  | 127 | struct platform_device mxc_i2c_device1 = { | 
|  | 128 | .name = "imx-i2c", | 
|  | 129 | .id = 1, | 
|  | 130 | .num_resources = ARRAY_SIZE(mxc_i2c1_resources), | 
|  | 131 | .resource = mxc_i2c1_resources, | 
|  | 132 | }; | 
|  | 133 |  | 
|  | 134 | static struct resource mxc_hsi2c_resources[] = { | 
|  | 135 | { | 
|  | 136 | .start = MX51_HSI2C_DMA_BASE_ADDR, | 
|  | 137 | .end = MX51_HSI2C_DMA_BASE_ADDR + SZ_16K - 1, | 
|  | 138 | .flags = IORESOURCE_MEM, | 
|  | 139 | }, | 
|  | 140 | { | 
|  | 141 | .start = MX51_MXC_INT_HS_I2C, | 
|  | 142 | .end = MX51_MXC_INT_HS_I2C, | 
|  | 143 | .flags = IORESOURCE_IRQ, | 
|  | 144 | }, | 
|  | 145 | }; | 
|  | 146 |  | 
|  | 147 | struct platform_device mxc_hsi2c_device = { | 
|  | 148 | .name = "imx-i2c", | 
|  | 149 | .id = 2, | 
|  | 150 | .num_resources = ARRAY_SIZE(mxc_hsi2c_resources), | 
|  | 151 | .resource = mxc_hsi2c_resources | 
|  | 152 | }; | 
|  | 153 |  | 
| Dinh Nguyen | c53bdf1 | 2010-04-30 15:48:24 -0500 | [diff] [blame] | 154 | static u64 usb_dma_mask = DMA_BIT_MASK(32); | 
|  | 155 |  | 
|  | 156 | static struct resource usbotg_resources[] = { | 
|  | 157 | { | 
|  | 158 | .start = MX51_OTG_BASE_ADDR, | 
|  | 159 | .end = MX51_OTG_BASE_ADDR + 0x1ff, | 
|  | 160 | .flags = IORESOURCE_MEM, | 
|  | 161 | }, | 
|  | 162 | { | 
|  | 163 | .start = MX51_MXC_INT_USB_OTG, | 
|  | 164 | .flags = IORESOURCE_IRQ, | 
|  | 165 | }, | 
|  | 166 | }; | 
|  | 167 |  | 
| Dinh Nguyen | 2ba5a2c | 2010-05-10 13:45:59 -0500 | [diff] [blame] | 168 | /* OTG gadget device */ | 
|  | 169 | struct platform_device mxc_usbdr_udc_device = { | 
|  | 170 | .name		= "fsl-usb2-udc", | 
|  | 171 | .id		= -1, | 
|  | 172 | .num_resources	= ARRAY_SIZE(usbotg_resources), | 
|  | 173 | .resource	= usbotg_resources, | 
|  | 174 | .dev		= { | 
|  | 175 | .dma_mask		= &usb_dma_mask, | 
|  | 176 | .coherent_dma_mask	= DMA_BIT_MASK(32), | 
|  | 177 | }, | 
|  | 178 | }; | 
|  | 179 |  | 
| Dinh Nguyen | c53bdf1 | 2010-04-30 15:48:24 -0500 | [diff] [blame] | 180 | struct platform_device mxc_usbdr_host_device = { | 
|  | 181 | .name = "mxc-ehci", | 
|  | 182 | .id = 0, | 
|  | 183 | .num_resources = ARRAY_SIZE(usbotg_resources), | 
|  | 184 | .resource = usbotg_resources, | 
|  | 185 | .dev = { | 
|  | 186 | .dma_mask = &usb_dma_mask, | 
|  | 187 | .coherent_dma_mask = DMA_BIT_MASK(32), | 
|  | 188 | }, | 
|  | 189 | }; | 
|  | 190 |  | 
|  | 191 | static struct resource usbh1_resources[] = { | 
|  | 192 | { | 
|  | 193 | .start = MX51_OTG_BASE_ADDR + 0x200, | 
|  | 194 | .end = MX51_OTG_BASE_ADDR + 0x200 + 0x1ff, | 
|  | 195 | .flags = IORESOURCE_MEM, | 
|  | 196 | }, | 
|  | 197 | { | 
|  | 198 | .start = MX51_MXC_INT_USB_H1, | 
|  | 199 | .flags = IORESOURCE_IRQ, | 
|  | 200 | }, | 
|  | 201 | }; | 
|  | 202 |  | 
|  | 203 | struct platform_device mxc_usbh1_device = { | 
|  | 204 | .name = "mxc-ehci", | 
|  | 205 | .id = 1, | 
|  | 206 | .num_resources = ARRAY_SIZE(usbh1_resources), | 
|  | 207 | .resource = usbh1_resources, | 
|  | 208 | .dev = { | 
|  | 209 | .dma_mask = &usb_dma_mask, | 
|  | 210 | .coherent_dma_mask = DMA_BIT_MASK(32), | 
|  | 211 | }, | 
|  | 212 | }; | 
|  | 213 |  | 
| Wolfram Sang | 4a870fc | 2010-05-17 12:33:43 +0200 | [diff] [blame] | 214 | static struct resource mxc_wdt_resources[] = { | 
|  | 215 | { | 
|  | 216 | .start = MX51_WDOG_BASE_ADDR, | 
|  | 217 | .end = MX51_WDOG_BASE_ADDR + SZ_16K - 1, | 
|  | 218 | .flags = IORESOURCE_MEM, | 
|  | 219 | }, | 
|  | 220 | }; | 
|  | 221 |  | 
|  | 222 | struct platform_device mxc_wdt = { | 
|  | 223 | .name = "imx2-wdt", | 
|  | 224 | .id = 0, | 
|  | 225 | .num_resources = ARRAY_SIZE(mxc_wdt_resources), | 
|  | 226 | .resource = mxc_wdt_resources, | 
|  | 227 | }; | 
|  | 228 |  | 
| Jason Wang | a7ebd93 | 2010-07-14 21:24:53 +0800 | [diff] [blame] | 229 | static struct resource mxc_kpp_resources[] = { | 
|  | 230 | { | 
|  | 231 | .start = MX51_MXC_INT_KPP, | 
|  | 232 | .end = MX51_MXC_INT_KPP, | 
|  | 233 | .flags = IORESOURCE_IRQ, | 
|  | 234 | } , { | 
|  | 235 | .start = MX51_KPP_BASE_ADDR, | 
|  | 236 | .end = MX51_KPP_BASE_ADDR + 0x8 - 1, | 
|  | 237 | .flags = IORESOURCE_MEM, | 
|  | 238 | }, | 
|  | 239 | }; | 
|  | 240 |  | 
|  | 241 | struct platform_device mxc_keypad_device = { | 
|  | 242 | .name = "imx-keypad", | 
|  | 243 | .id = 0, | 
|  | 244 | .num_resources = ARRAY_SIZE(mxc_kpp_resources), | 
|  | 245 | .resource = mxc_kpp_resources, | 
|  | 246 | }; | 
|  | 247 |  | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 248 | static struct mxc_gpio_port mxc_gpio_ports[] = { | 
|  | 249 | { | 
|  | 250 | .chip.label = "gpio-0", | 
|  | 251 | .base = MX51_IO_ADDRESS(MX51_GPIO1_BASE_ADDR), | 
|  | 252 | .irq = MX51_MXC_INT_GPIO1_LOW, | 
| Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 253 | .irq_high = MX51_MXC_INT_GPIO1_HIGH, | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 254 | .virtual_irq_start = MXC_GPIO_IRQ_START | 
|  | 255 | }, | 
|  | 256 | { | 
|  | 257 | .chip.label = "gpio-1", | 
|  | 258 | .base = MX51_IO_ADDRESS(MX51_GPIO2_BASE_ADDR), | 
|  | 259 | .irq = MX51_MXC_INT_GPIO2_LOW, | 
| Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 260 | .irq_high = MX51_MXC_INT_GPIO2_HIGH, | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 261 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 1 | 
|  | 262 | }, | 
|  | 263 | { | 
|  | 264 | .chip.label = "gpio-2", | 
|  | 265 | .base = MX51_IO_ADDRESS(MX51_GPIO3_BASE_ADDR), | 
|  | 266 | .irq = MX51_MXC_INT_GPIO3_LOW, | 
| Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 267 | .irq_high = MX51_MXC_INT_GPIO3_HIGH, | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 268 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 2 | 
|  | 269 | }, | 
|  | 270 | { | 
|  | 271 | .chip.label = "gpio-3", | 
|  | 272 | .base = MX51_IO_ADDRESS(MX51_GPIO4_BASE_ADDR), | 
|  | 273 | .irq = MX51_MXC_INT_GPIO4_LOW, | 
| Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 274 | .irq_high = MX51_MXC_INT_GPIO4_HIGH, | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 275 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 3 | 
|  | 276 | }, | 
|  | 277 | }; | 
|  | 278 |  | 
| Uwe Kleine-König | 9a763bf | 2010-06-10 17:11:06 +0200 | [diff] [blame] | 279 | int __init imx51_register_gpios(void) | 
| Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 280 | { | 
| Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 281 | return mxc_gpio_init(mxc_gpio_ports, ARRAY_SIZE(mxc_gpio_ports)); | 
| Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 282 | } |