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 | |
Dinh Nguyen | 71c2e51 | 2010-05-27 10:45:04 -0500 | [diff] [blame] | 20 | static struct resource mxc_hsi2c_resources[] = { |
| 21 | { |
| 22 | .start = MX51_HSI2C_DMA_BASE_ADDR, |
| 23 | .end = MX51_HSI2C_DMA_BASE_ADDR + SZ_16K - 1, |
| 24 | .flags = IORESOURCE_MEM, |
| 25 | }, |
| 26 | { |
| 27 | .start = MX51_MXC_INT_HS_I2C, |
| 28 | .end = MX51_MXC_INT_HS_I2C, |
| 29 | .flags = IORESOURCE_IRQ, |
| 30 | }, |
| 31 | }; |
| 32 | |
| 33 | struct platform_device mxc_hsi2c_device = { |
| 34 | .name = "imx-i2c", |
| 35 | .id = 2, |
| 36 | .num_resources = ARRAY_SIZE(mxc_hsi2c_resources), |
| 37 | .resource = mxc_hsi2c_resources |
| 38 | }; |
| 39 | |
Dinh Nguyen | c53bdf1 | 2010-04-30 15:48:24 -0500 | [diff] [blame] | 40 | static u64 usb_dma_mask = DMA_BIT_MASK(32); |
| 41 | |
| 42 | static struct resource usbotg_resources[] = { |
| 43 | { |
| 44 | .start = MX51_OTG_BASE_ADDR, |
| 45 | .end = MX51_OTG_BASE_ADDR + 0x1ff, |
| 46 | .flags = IORESOURCE_MEM, |
| 47 | }, |
| 48 | { |
| 49 | .start = MX51_MXC_INT_USB_OTG, |
| 50 | .flags = IORESOURCE_IRQ, |
| 51 | }, |
| 52 | }; |
| 53 | |
Dinh Nguyen | 2ba5a2c | 2010-05-10 13:45:59 -0500 | [diff] [blame] | 54 | /* OTG gadget device */ |
| 55 | struct platform_device mxc_usbdr_udc_device = { |
| 56 | .name = "fsl-usb2-udc", |
| 57 | .id = -1, |
| 58 | .num_resources = ARRAY_SIZE(usbotg_resources), |
| 59 | .resource = usbotg_resources, |
| 60 | .dev = { |
| 61 | .dma_mask = &usb_dma_mask, |
| 62 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 63 | }, |
| 64 | }; |
| 65 | |
Dinh Nguyen | c53bdf1 | 2010-04-30 15:48:24 -0500 | [diff] [blame] | 66 | struct platform_device mxc_usbdr_host_device = { |
| 67 | .name = "mxc-ehci", |
| 68 | .id = 0, |
| 69 | .num_resources = ARRAY_SIZE(usbotg_resources), |
| 70 | .resource = usbotg_resources, |
| 71 | .dev = { |
| 72 | .dma_mask = &usb_dma_mask, |
| 73 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | static struct resource usbh1_resources[] = { |
| 78 | { |
| 79 | .start = MX51_OTG_BASE_ADDR + 0x200, |
| 80 | .end = MX51_OTG_BASE_ADDR + 0x200 + 0x1ff, |
| 81 | .flags = IORESOURCE_MEM, |
| 82 | }, |
| 83 | { |
| 84 | .start = MX51_MXC_INT_USB_H1, |
| 85 | .flags = IORESOURCE_IRQ, |
| 86 | }, |
| 87 | }; |
| 88 | |
| 89 | struct platform_device mxc_usbh1_device = { |
| 90 | .name = "mxc-ehci", |
| 91 | .id = 1, |
| 92 | .num_resources = ARRAY_SIZE(usbh1_resources), |
| 93 | .resource = usbh1_resources, |
| 94 | .dev = { |
| 95 | .dma_mask = &usb_dma_mask, |
| 96 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 97 | }, |
| 98 | }; |
| 99 | |
Arnaud Patard (Rtp) | 8305ed7 | 2010-12-20 16:48:57 +0100 | [diff] [blame] | 100 | static struct resource usbh2_resources[] = { |
| 101 | { |
| 102 | .start = MX51_OTG_BASE_ADDR + 0x400, |
| 103 | .end = MX51_OTG_BASE_ADDR + 0x400 + 0x1ff, |
| 104 | .flags = IORESOURCE_MEM, |
| 105 | }, |
| 106 | { |
| 107 | .start = MX51_MXC_INT_USB_H2, |
| 108 | .flags = IORESOURCE_IRQ, |
| 109 | }, |
| 110 | }; |
| 111 | |
| 112 | struct platform_device mxc_usbh2_device = { |
| 113 | .name = "mxc-ehci", |
| 114 | .id = 2, |
| 115 | .num_resources = ARRAY_SIZE(usbh2_resources), |
| 116 | .resource = usbh2_resources, |
| 117 | .dev = { |
| 118 | .dma_mask = &usb_dma_mask, |
| 119 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 120 | }, |
| 121 | }; |
| 122 | |
Jason Wang | a7ebd93 | 2010-07-14 21:24:53 +0800 | [diff] [blame] | 123 | static struct resource mxc_kpp_resources[] = { |
| 124 | { |
| 125 | .start = MX51_MXC_INT_KPP, |
| 126 | .end = MX51_MXC_INT_KPP, |
| 127 | .flags = IORESOURCE_IRQ, |
| 128 | } , { |
| 129 | .start = MX51_KPP_BASE_ADDR, |
| 130 | .end = MX51_KPP_BASE_ADDR + 0x8 - 1, |
| 131 | .flags = IORESOURCE_MEM, |
| 132 | }, |
| 133 | }; |
| 134 | |
| 135 | struct platform_device mxc_keypad_device = { |
| 136 | .name = "imx-keypad", |
| 137 | .id = 0, |
| 138 | .num_resources = ARRAY_SIZE(mxc_kpp_resources), |
| 139 | .resource = mxc_kpp_resources, |
| 140 | }; |
| 141 | |
Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 142 | static struct mxc_gpio_port mxc_gpio_ports[] = { |
| 143 | { |
| 144 | .chip.label = "gpio-0", |
| 145 | .base = MX51_IO_ADDRESS(MX51_GPIO1_BASE_ADDR), |
| 146 | .irq = MX51_MXC_INT_GPIO1_LOW, |
Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 147 | .irq_high = MX51_MXC_INT_GPIO1_HIGH, |
Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 148 | .virtual_irq_start = MXC_GPIO_IRQ_START |
| 149 | }, |
| 150 | { |
| 151 | .chip.label = "gpio-1", |
| 152 | .base = MX51_IO_ADDRESS(MX51_GPIO2_BASE_ADDR), |
| 153 | .irq = MX51_MXC_INT_GPIO2_LOW, |
Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 154 | .irq_high = MX51_MXC_INT_GPIO2_HIGH, |
Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 155 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 1 |
| 156 | }, |
| 157 | { |
| 158 | .chip.label = "gpio-2", |
| 159 | .base = MX51_IO_ADDRESS(MX51_GPIO3_BASE_ADDR), |
| 160 | .irq = MX51_MXC_INT_GPIO3_LOW, |
Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 161 | .irq_high = MX51_MXC_INT_GPIO3_HIGH, |
Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 162 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 2 |
| 163 | }, |
| 164 | { |
| 165 | .chip.label = "gpio-3", |
| 166 | .base = MX51_IO_ADDRESS(MX51_GPIO4_BASE_ADDR), |
| 167 | .irq = MX51_MXC_INT_GPIO4_LOW, |
Eric Bénard | aa87214 | 2010-07-21 14:46:11 +0200 | [diff] [blame] | 168 | .irq_high = MX51_MXC_INT_GPIO4_HIGH, |
Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 169 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 3 |
| 170 | }, |
Dinh Nguyen | c0abefd | 2010-11-15 11:29:59 -0600 | [diff] [blame] | 171 | { |
| 172 | .chip.label = "gpio-4", |
| 173 | .base = MX53_IO_ADDRESS(MX53_GPIO5_BASE_ADDR), |
| 174 | .irq = MX53_INT_GPIO5_LOW, |
| 175 | .irq_high = MX53_INT_GPIO5_HIGH, |
| 176 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 4 |
| 177 | }, |
| 178 | { |
| 179 | .chip.label = "gpio-5", |
| 180 | .base = MX53_IO_ADDRESS(MX53_GPIO6_BASE_ADDR), |
| 181 | .irq = MX53_INT_GPIO6_LOW, |
| 182 | .irq_high = MX53_INT_GPIO6_HIGH, |
| 183 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 5 |
| 184 | }, |
| 185 | { |
| 186 | .chip.label = "gpio-6", |
| 187 | .base = MX53_IO_ADDRESS(MX53_GPIO7_BASE_ADDR), |
| 188 | .irq = MX53_INT_GPIO7_LOW, |
| 189 | .irq_high = MX53_INT_GPIO7_HIGH, |
| 190 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32 * 6 |
| 191 | }, |
Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 192 | }; |
| 193 | |
Uwe Kleine-König | 9a763bf | 2010-06-10 17:11:06 +0200 | [diff] [blame] | 194 | int __init imx51_register_gpios(void) |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 195 | { |
Dinh Nguyen | c0abefd | 2010-11-15 11:29:59 -0600 | [diff] [blame] | 196 | return mxc_gpio_init(mxc_gpio_ports, 4); |
| 197 | } |
| 198 | |
| 199 | int __init imx53_register_gpios(void) |
| 200 | { |
Dinh Nguyen | e24798e | 2010-04-22 16:28:42 +0300 | [diff] [blame] | 201 | return mxc_gpio_init(mxc_gpio_ports, ARRAY_SIZE(mxc_gpio_ports)); |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 202 | } |
Dinh Nguyen | c0abefd | 2010-11-15 11:29:59 -0600 | [diff] [blame] | 203 | |