Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * armadillo5x0.c |
| 3 | * |
| 4 | * Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> |
| 5 | * updates in http://alberdroid.blogspot.com/ |
| 6 | * |
| 7 | * Based on Atmark Techno, Inc. armadillo 500 BSP 2008 |
| 8 | * Based on mx31ads.c and pcm037.c Great Work! |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 23 | * MA 02110-1301, USA. |
| 24 | */ |
| 25 | |
| 26 | #include <linux/types.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/clk.h> |
| 29 | #include <linux/platform_device.h> |
| 30 | #include <linux/gpio.h> |
| 31 | #include <linux/smsc911x.h> |
| 32 | #include <linux/interrupt.h> |
| 33 | #include <linux/irq.h> |
Alberto Panizzo | c3a9c7f | 2009-06-17 15:05:21 +0200 | [diff] [blame] | 34 | #include <linux/mtd/physmap.h> |
Alberto Panizzo | 0c8bad6 | 2009-06-17 15:06:30 +0200 | [diff] [blame] | 35 | #include <linux/io.h> |
Alberto Panizzo | e33c049 | 2009-10-15 19:24:51 +0200 | [diff] [blame] | 36 | #include <linux/input.h> |
| 37 | #include <linux/gpio_keys.h> |
Alberto Panizzo | 2097abc | 2009-10-15 19:33:24 +0200 | [diff] [blame] | 38 | #include <linux/i2c.h> |
Alberto Panizzo | b3aa111 | 2010-02-26 18:36:32 +0100 | [diff] [blame] | 39 | #include <linux/usb/otg.h> |
| 40 | #include <linux/usb/ulpi.h> |
| 41 | #include <linux/delay.h> |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 42 | |
| 43 | #include <mach/hardware.h> |
| 44 | #include <asm/mach-types.h> |
| 45 | #include <asm/mach/arch.h> |
| 46 | #include <asm/mach/time.h> |
| 47 | #include <asm/memory.h> |
| 48 | #include <asm/mach/map.h> |
| 49 | |
| 50 | #include <mach/common.h> |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 51 | #include <mach/iomux-mx3.h> |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 52 | #include <mach/mmc.h> |
| 53 | #include <mach/ipu.h> |
| 54 | #include <mach/mx3fb.h> |
Alberto Panizzo | b3aa111 | 2010-02-26 18:36:32 +0100 | [diff] [blame] | 55 | #include <mach/mxc_ehci.h> |
| 56 | #include <mach/ulpi.h> |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 57 | |
Uwe Kleine-König | a2ceeef | 2010-06-16 12:23:11 +0200 | [diff] [blame] | 58 | #include "devices-imx31.h" |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 59 | #include "devices.h" |
Alberto Panizzo | 0c8bad6 | 2009-06-17 15:06:30 +0200 | [diff] [blame] | 60 | #include "crm_regs.h" |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 61 | |
| 62 | static int armadillo5x0_pins[] = { |
| 63 | /* UART1 */ |
| 64 | MX31_PIN_CTS1__CTS1, |
| 65 | MX31_PIN_RTS1__RTS1, |
| 66 | MX31_PIN_TXD1__TXD1, |
| 67 | MX31_PIN_RXD1__RXD1, |
| 68 | /* UART2 */ |
| 69 | MX31_PIN_CTS2__CTS2, |
| 70 | MX31_PIN_RTS2__RTS2, |
| 71 | MX31_PIN_TXD2__TXD2, |
| 72 | MX31_PIN_RXD2__RXD2, |
| 73 | /* LAN9118_IRQ */ |
| 74 | IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO), |
| 75 | /* SDHC1 */ |
| 76 | MX31_PIN_SD1_DATA3__SD1_DATA3, |
| 77 | MX31_PIN_SD1_DATA2__SD1_DATA2, |
| 78 | MX31_PIN_SD1_DATA1__SD1_DATA1, |
| 79 | MX31_PIN_SD1_DATA0__SD1_DATA0, |
| 80 | MX31_PIN_SD1_CLK__SD1_CLK, |
| 81 | MX31_PIN_SD1_CMD__SD1_CMD, |
| 82 | /* Framebuffer */ |
| 83 | MX31_PIN_LD0__LD0, |
| 84 | MX31_PIN_LD1__LD1, |
| 85 | MX31_PIN_LD2__LD2, |
| 86 | MX31_PIN_LD3__LD3, |
| 87 | MX31_PIN_LD4__LD4, |
| 88 | MX31_PIN_LD5__LD5, |
| 89 | MX31_PIN_LD6__LD6, |
| 90 | MX31_PIN_LD7__LD7, |
| 91 | MX31_PIN_LD8__LD8, |
| 92 | MX31_PIN_LD9__LD9, |
| 93 | MX31_PIN_LD10__LD10, |
| 94 | MX31_PIN_LD11__LD11, |
| 95 | MX31_PIN_LD12__LD12, |
| 96 | MX31_PIN_LD13__LD13, |
| 97 | MX31_PIN_LD14__LD14, |
| 98 | MX31_PIN_LD15__LD15, |
| 99 | MX31_PIN_LD16__LD16, |
| 100 | MX31_PIN_LD17__LD17, |
| 101 | MX31_PIN_VSYNC3__VSYNC3, |
| 102 | MX31_PIN_HSYNC__HSYNC, |
| 103 | MX31_PIN_FPSHIFT__FPSHIFT, |
| 104 | MX31_PIN_DRDY0__DRDY0, |
| 105 | IOMUX_MODE(MX31_PIN_LCS1, IOMUX_CONFIG_GPIO), /*ADV7125_PSAVE*/ |
Alberto Panizzo | e9a6c5d | 2009-10-15 19:31:07 +0200 | [diff] [blame] | 106 | /* I2C2 */ |
| 107 | MX31_PIN_CSPI2_MOSI__SCL, |
| 108 | MX31_PIN_CSPI2_MISO__SDA, |
Alberto Panizzo | b3aa111 | 2010-02-26 18:36:32 +0100 | [diff] [blame] | 109 | /* OTG */ |
| 110 | MX31_PIN_USBOTG_DATA0__USBOTG_DATA0, |
| 111 | MX31_PIN_USBOTG_DATA1__USBOTG_DATA1, |
| 112 | MX31_PIN_USBOTG_DATA2__USBOTG_DATA2, |
| 113 | MX31_PIN_USBOTG_DATA3__USBOTG_DATA3, |
| 114 | MX31_PIN_USBOTG_DATA4__USBOTG_DATA4, |
| 115 | MX31_PIN_USBOTG_DATA5__USBOTG_DATA5, |
| 116 | MX31_PIN_USBOTG_DATA6__USBOTG_DATA6, |
| 117 | MX31_PIN_USBOTG_DATA7__USBOTG_DATA7, |
| 118 | MX31_PIN_USBOTG_CLK__USBOTG_CLK, |
| 119 | MX31_PIN_USBOTG_DIR__USBOTG_DIR, |
| 120 | MX31_PIN_USBOTG_NXT__USBOTG_NXT, |
| 121 | MX31_PIN_USBOTG_STP__USBOTG_STP, |
| 122 | /* USB host 2 */ |
| 123 | IOMUX_MODE(MX31_PIN_USBH2_CLK, IOMUX_CONFIG_FUNC), |
| 124 | IOMUX_MODE(MX31_PIN_USBH2_DIR, IOMUX_CONFIG_FUNC), |
| 125 | IOMUX_MODE(MX31_PIN_USBH2_NXT, IOMUX_CONFIG_FUNC), |
| 126 | IOMUX_MODE(MX31_PIN_USBH2_STP, IOMUX_CONFIG_FUNC), |
| 127 | IOMUX_MODE(MX31_PIN_USBH2_DATA0, IOMUX_CONFIG_FUNC), |
| 128 | IOMUX_MODE(MX31_PIN_USBH2_DATA1, IOMUX_CONFIG_FUNC), |
| 129 | IOMUX_MODE(MX31_PIN_STXD3, IOMUX_CONFIG_FUNC), |
| 130 | IOMUX_MODE(MX31_PIN_SRXD3, IOMUX_CONFIG_FUNC), |
| 131 | IOMUX_MODE(MX31_PIN_SCK3, IOMUX_CONFIG_FUNC), |
| 132 | IOMUX_MODE(MX31_PIN_SFS3, IOMUX_CONFIG_FUNC), |
| 133 | IOMUX_MODE(MX31_PIN_STXD6, IOMUX_CONFIG_FUNC), |
| 134 | IOMUX_MODE(MX31_PIN_SRXD6, IOMUX_CONFIG_FUNC), |
Alberto Panizzo | 0c8bad6 | 2009-06-17 15:06:30 +0200 | [diff] [blame] | 135 | }; |
Alberto Panizzo | e9a6c5d | 2009-10-15 19:31:07 +0200 | [diff] [blame] | 136 | |
Alberto Panizzo | b3aa111 | 2010-02-26 18:36:32 +0100 | [diff] [blame] | 137 | /* USB */ |
| 138 | #if defined(CONFIG_USB_ULPI) |
| 139 | |
| 140 | #define OTG_RESET IOMUX_TO_GPIO(MX31_PIN_STXD4) |
| 141 | #define USBH2_RESET IOMUX_TO_GPIO(MX31_PIN_SCK6) |
| 142 | #define USBH2_CS IOMUX_TO_GPIO(MX31_PIN_GPIO1_3) |
| 143 | |
| 144 | #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ |
| 145 | PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) |
| 146 | |
| 147 | static int usbotg_init(struct platform_device *pdev) |
| 148 | { |
| 149 | int err; |
| 150 | |
| 151 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG); |
| 152 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG); |
| 153 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG); |
| 154 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG); |
| 155 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG); |
| 156 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG); |
| 157 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG); |
| 158 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG); |
| 159 | mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG); |
| 160 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG); |
| 161 | mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG); |
| 162 | mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG); |
| 163 | |
| 164 | /* Chip already enabled by hardware */ |
| 165 | /* OTG phy reset*/ |
| 166 | err = gpio_request(OTG_RESET, "USB-OTG-RESET"); |
| 167 | if (err) { |
| 168 | pr_err("Failed to request the usb otg reset gpio\n"); |
| 169 | return err; |
| 170 | } |
| 171 | |
| 172 | err = gpio_direction_output(OTG_RESET, 1/*HIGH*/); |
| 173 | if (err) { |
| 174 | pr_err("Failed to reset the usb otg phy\n"); |
| 175 | goto otg_free_reset; |
| 176 | } |
| 177 | |
| 178 | gpio_set_value(OTG_RESET, 0/*LOW*/); |
| 179 | mdelay(5); |
| 180 | gpio_set_value(OTG_RESET, 1/*HIGH*/); |
| 181 | |
| 182 | return 0; |
| 183 | |
| 184 | otg_free_reset: |
| 185 | gpio_free(OTG_RESET); |
| 186 | return err; |
| 187 | } |
| 188 | |
| 189 | static int usbh2_init(struct platform_device *pdev) |
| 190 | { |
| 191 | int err; |
| 192 | |
| 193 | mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG); |
| 194 | mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG); |
| 195 | mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG); |
| 196 | mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG); |
| 197 | mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG); |
| 198 | mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG); |
| 199 | mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG); |
| 200 | mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG); |
| 201 | mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG); |
| 202 | mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG); |
| 203 | mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG); |
| 204 | mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG); |
| 205 | |
| 206 | mxc_iomux_set_gpr(MUX_PGP_UH2, true); |
| 207 | |
| 208 | |
| 209 | /* Enable the chip */ |
| 210 | err = gpio_request(USBH2_CS, "USB-H2-CS"); |
| 211 | if (err) { |
| 212 | pr_err("Failed to request the usb host 2 CS gpio\n"); |
| 213 | return err; |
| 214 | } |
| 215 | |
| 216 | err = gpio_direction_output(USBH2_CS, 0/*Enabled*/); |
| 217 | if (err) { |
| 218 | pr_err("Failed to drive the usb host 2 CS gpio\n"); |
| 219 | goto h2_free_cs; |
| 220 | } |
| 221 | |
| 222 | /* H2 phy reset*/ |
| 223 | err = gpio_request(USBH2_RESET, "USB-H2-RESET"); |
| 224 | if (err) { |
| 225 | pr_err("Failed to request the usb host 2 reset gpio\n"); |
| 226 | goto h2_free_cs; |
| 227 | } |
| 228 | |
| 229 | err = gpio_direction_output(USBH2_RESET, 1/*HIGH*/); |
| 230 | if (err) { |
| 231 | pr_err("Failed to reset the usb host 2 phy\n"); |
| 232 | goto h2_free_reset; |
| 233 | } |
| 234 | |
| 235 | gpio_set_value(USBH2_RESET, 0/*LOW*/); |
| 236 | mdelay(5); |
| 237 | gpio_set_value(USBH2_RESET, 1/*HIGH*/); |
| 238 | |
| 239 | return 0; |
| 240 | |
| 241 | h2_free_reset: |
| 242 | gpio_free(USBH2_RESET); |
| 243 | h2_free_cs: |
| 244 | gpio_free(USBH2_CS); |
| 245 | return err; |
| 246 | } |
| 247 | |
| 248 | static struct mxc_usbh_platform_data usbotg_pdata = { |
| 249 | .init = usbotg_init, |
| 250 | .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT, |
| 251 | .flags = MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_INTERFACE_DIFF_UNI, |
| 252 | }; |
| 253 | |
| 254 | static struct mxc_usbh_platform_data usbh2_pdata = { |
| 255 | .init = usbh2_init, |
| 256 | .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT, |
| 257 | .flags = MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_INTERFACE_DIFF_UNI, |
| 258 | }; |
| 259 | #endif /* CONFIG_USB_ULPI */ |
| 260 | |
Alberto Panizzo | 2097abc | 2009-10-15 19:33:24 +0200 | [diff] [blame] | 261 | /* RTC over I2C*/ |
| 262 | #define ARMADILLO5X0_RTC_GPIO IOMUX_TO_GPIO(MX31_PIN_SRXD4) |
| 263 | |
| 264 | static struct i2c_board_info armadillo5x0_i2c_rtc = { |
| 265 | I2C_BOARD_INFO("s35390a", 0x30), |
| 266 | }; |
| 267 | |
Alberto Panizzo | e33c049 | 2009-10-15 19:24:51 +0200 | [diff] [blame] | 268 | /* GPIO BUTTONS */ |
| 269 | static struct gpio_keys_button armadillo5x0_buttons[] = { |
| 270 | { |
| 271 | .code = KEY_ENTER, /*28*/ |
| 272 | .gpio = IOMUX_TO_GPIO(MX31_PIN_SCLK0), |
| 273 | .active_low = 1, |
| 274 | .desc = "menu", |
| 275 | .wakeup = 1, |
| 276 | }, { |
| 277 | .code = KEY_BACK, /*158*/ |
| 278 | .gpio = IOMUX_TO_GPIO(MX31_PIN_SRST0), |
| 279 | .active_low = 1, |
| 280 | .desc = "back", |
| 281 | .wakeup = 1, |
| 282 | } |
| 283 | }; |
| 284 | |
| 285 | static struct gpio_keys_platform_data armadillo5x0_button_data = { |
| 286 | .buttons = armadillo5x0_buttons, |
| 287 | .nbuttons = ARRAY_SIZE(armadillo5x0_buttons), |
| 288 | }; |
| 289 | |
| 290 | static struct platform_device armadillo5x0_button_device = { |
| 291 | .name = "gpio-keys", |
| 292 | .id = -1, |
| 293 | .num_resources = 0, |
| 294 | .dev = { |
| 295 | .platform_data = &armadillo5x0_button_data, |
| 296 | } |
| 297 | }; |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 298 | |
Alberto Panizzo | 0c8bad6 | 2009-06-17 15:06:30 +0200 | [diff] [blame] | 299 | /* |
| 300 | * NAND Flash |
| 301 | */ |
Uwe Kleine-König | a2ceeef | 2010-06-16 12:23:11 +0200 | [diff] [blame] | 302 | static const struct mxc_nand_platform_data |
| 303 | armadillo5x0_nand_board_info __initconst = { |
Alberto Panizzo | 0c8bad6 | 2009-06-17 15:06:30 +0200 | [diff] [blame] | 304 | .width = 1, |
| 305 | .hw_ecc = 1, |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 306 | }; |
| 307 | |
| 308 | /* |
Alberto Panizzo | c3a9c7f | 2009-06-17 15:05:21 +0200 | [diff] [blame] | 309 | * MTD NOR Flash |
| 310 | */ |
| 311 | static struct mtd_partition armadillo5x0_nor_flash_partitions[] = { |
| 312 | { |
| 313 | .name = "nor.bootloader", |
| 314 | .offset = 0x00000000, |
| 315 | .size = 4*32*1024, |
| 316 | }, { |
| 317 | .name = "nor.kernel", |
| 318 | .offset = MTDPART_OFS_APPEND, |
| 319 | .size = 16*128*1024, |
| 320 | }, { |
| 321 | .name = "nor.userland", |
| 322 | .offset = MTDPART_OFS_APPEND, |
| 323 | .size = 110*128*1024, |
| 324 | }, { |
| 325 | .name = "nor.config", |
| 326 | .offset = MTDPART_OFS_APPEND, |
| 327 | .size = 1*128*1024, |
| 328 | }, |
| 329 | }; |
| 330 | |
| 331 | static struct physmap_flash_data armadillo5x0_nor_flash_pdata = { |
| 332 | .width = 2, |
| 333 | .parts = armadillo5x0_nor_flash_partitions, |
| 334 | .nr_parts = ARRAY_SIZE(armadillo5x0_nor_flash_partitions), |
| 335 | }; |
| 336 | |
| 337 | static struct resource armadillo5x0_nor_flash_resource = { |
| 338 | .flags = IORESOURCE_MEM, |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 339 | .start = MX31_CS0_BASE_ADDR, |
| 340 | .end = MX31_CS0_BASE_ADDR + SZ_64M - 1, |
Alberto Panizzo | c3a9c7f | 2009-06-17 15:05:21 +0200 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | static struct platform_device armadillo5x0_nor_flash = { |
| 344 | .name = "physmap-flash", |
| 345 | .id = -1, |
| 346 | .num_resources = 1, |
| 347 | .resource = &armadillo5x0_nor_flash_resource, |
| 348 | }; |
| 349 | |
| 350 | /* |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 351 | * FB support |
| 352 | */ |
| 353 | static const struct fb_videomode fb_modedb[] = { |
| 354 | { /* 640x480 @ 60 Hz */ |
| 355 | .name = "CRT-VGA", |
| 356 | .refresh = 60, |
| 357 | .xres = 640, |
| 358 | .yres = 480, |
| 359 | .pixclock = 39721, |
| 360 | .left_margin = 35, |
| 361 | .right_margin = 115, |
| 362 | .upper_margin = 43, |
| 363 | .lower_margin = 1, |
| 364 | .hsync_len = 10, |
| 365 | .vsync_len = 1, |
| 366 | .sync = FB_SYNC_OE_ACT_HIGH, |
| 367 | .vmode = FB_VMODE_NONINTERLACED, |
| 368 | .flag = 0, |
| 369 | }, {/* 800x600 @ 56 Hz */ |
| 370 | .name = "CRT-SVGA", |
| 371 | .refresh = 56, |
| 372 | .xres = 800, |
| 373 | .yres = 600, |
| 374 | .pixclock = 30000, |
| 375 | .left_margin = 30, |
| 376 | .right_margin = 108, |
| 377 | .upper_margin = 13, |
| 378 | .lower_margin = 10, |
| 379 | .hsync_len = 10, |
| 380 | .vsync_len = 1, |
| 381 | .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_HOR_HIGH_ACT | |
| 382 | FB_SYNC_VERT_HIGH_ACT, |
| 383 | .vmode = FB_VMODE_NONINTERLACED, |
| 384 | .flag = 0, |
| 385 | }, |
| 386 | }; |
| 387 | |
| 388 | static struct ipu_platform_data mx3_ipu_data = { |
| 389 | .irq_base = MXC_IPU_IRQ_START, |
| 390 | }; |
| 391 | |
| 392 | static struct mx3fb_platform_data mx3fb_pdata = { |
| 393 | .dma_dev = &mx3_ipu.dev, |
| 394 | .name = "CRT-VGA", |
| 395 | .mode = fb_modedb, |
| 396 | .num_modes = ARRAY_SIZE(fb_modedb), |
| 397 | }; |
| 398 | |
| 399 | /* |
| 400 | * SDHC 1 |
| 401 | * MMC support |
| 402 | */ |
| 403 | static int armadillo5x0_sdhc1_get_ro(struct device *dev) |
| 404 | { |
| 405 | return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B)); |
| 406 | } |
| 407 | |
| 408 | static int armadillo5x0_sdhc1_init(struct device *dev, |
| 409 | irq_handler_t detect_irq, void *data) |
| 410 | { |
| 411 | int ret; |
| 412 | int gpio_det, gpio_wp; |
| 413 | |
| 414 | gpio_det = IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK); |
| 415 | gpio_wp = IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B); |
| 416 | |
| 417 | ret = gpio_request(gpio_det, "sdhc-card-detect"); |
| 418 | if (ret) |
| 419 | return ret; |
| 420 | |
| 421 | gpio_direction_input(gpio_det); |
| 422 | |
| 423 | ret = gpio_request(gpio_wp, "sdhc-write-protect"); |
| 424 | if (ret) |
| 425 | goto err_gpio_free; |
| 426 | |
| 427 | gpio_direction_input(gpio_wp); |
| 428 | |
| 429 | /* When supported the trigger type have to be BOTH */ |
| 430 | ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), detect_irq, |
| 431 | IRQF_DISABLED | IRQF_TRIGGER_FALLING, |
| 432 | "sdhc-detect", data); |
| 433 | |
| 434 | if (ret) |
| 435 | goto err_gpio_free_2; |
| 436 | |
| 437 | return 0; |
| 438 | |
| 439 | err_gpio_free_2: |
| 440 | gpio_free(gpio_wp); |
| 441 | |
| 442 | err_gpio_free: |
| 443 | gpio_free(gpio_det); |
| 444 | |
| 445 | return ret; |
| 446 | |
| 447 | } |
| 448 | |
| 449 | static void armadillo5x0_sdhc1_exit(struct device *dev, void *data) |
| 450 | { |
| 451 | free_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), data); |
| 452 | gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)); |
| 453 | gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B)); |
| 454 | } |
| 455 | |
| 456 | static struct imxmmc_platform_data sdhc_pdata = { |
| 457 | .get_ro = armadillo5x0_sdhc1_get_ro, |
| 458 | .init = armadillo5x0_sdhc1_init, |
| 459 | .exit = armadillo5x0_sdhc1_exit, |
| 460 | }; |
| 461 | |
| 462 | /* |
| 463 | * SMSC 9118 |
| 464 | * Network support |
| 465 | */ |
| 466 | static struct resource armadillo5x0_smc911x_resources[] = { |
| 467 | { |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 468 | .start = MX31_CS3_BASE_ADDR, |
| 469 | .end = MX31_CS3_BASE_ADDR + SZ_32M - 1, |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 470 | .flags = IORESOURCE_MEM, |
| 471 | }, { |
| 472 | .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0), |
| 473 | .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0), |
| 474 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 475 | }, |
| 476 | }; |
| 477 | |
| 478 | static struct smsc911x_platform_config smsc911x_info = { |
Alberto Panizzo | 07299ca | 2009-10-15 19:29:05 +0200 | [diff] [blame] | 479 | .flags = SMSC911X_USE_16BIT, |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 480 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 481 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 482 | }; |
| 483 | |
| 484 | static struct platform_device armadillo5x0_smc911x_device = { |
| 485 | .name = "smsc911x", |
| 486 | .id = -1, |
| 487 | .num_resources = ARRAY_SIZE(armadillo5x0_smc911x_resources), |
| 488 | .resource = armadillo5x0_smc911x_resources, |
| 489 | .dev = { |
| 490 | .platform_data = &smsc911x_info, |
| 491 | }, |
| 492 | }; |
| 493 | |
| 494 | /* UART device data */ |
Uwe Kleine-König | 16cf5c4 | 2010-06-23 11:46:16 +0200 | [diff] [blame^] | 495 | static const struct imxuart_platform_data uart_pdata __initconst = { |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 496 | .flags = IMXUART_HAVE_RTSCTS, |
| 497 | }; |
| 498 | |
| 499 | static struct platform_device *devices[] __initdata = { |
| 500 | &armadillo5x0_smc911x_device, |
Alberto Panizzo | e33c049 | 2009-10-15 19:24:51 +0200 | [diff] [blame] | 501 | &armadillo5x0_button_device, |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 502 | }; |
| 503 | |
| 504 | /* |
| 505 | * Perform board specific initializations |
| 506 | */ |
| 507 | static void __init armadillo5x0_init(void) |
| 508 | { |
| 509 | mxc_iomux_setup_multiple_pins(armadillo5x0_pins, |
| 510 | ARRAY_SIZE(armadillo5x0_pins), "armadillo5x0"); |
| 511 | |
| 512 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
Uwe Kleine-König | 4a9b8b0 | 2010-06-16 18:03:05 +0200 | [diff] [blame] | 513 | imx31_add_imx_i2c1(NULL); |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 514 | |
| 515 | /* Register UART */ |
Uwe Kleine-König | 16cf5c4 | 2010-06-23 11:46:16 +0200 | [diff] [blame^] | 516 | imx31_add_imx_uart0(&uart_pdata); |
| 517 | imx31_add_imx_uart1(&uart_pdata); |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 518 | |
| 519 | /* SMSC9118 IRQ pin */ |
| 520 | gpio_direction_input(MX31_PIN_GPIO1_0); |
| 521 | |
| 522 | /* Register SDHC */ |
| 523 | mxc_register_device(&mxcsdhc_device0, &sdhc_pdata); |
| 524 | |
| 525 | /* Register FB */ |
| 526 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); |
| 527 | mxc_register_device(&mx3_fb, &mx3fb_pdata); |
Alberto Panizzo | c3a9c7f | 2009-06-17 15:05:21 +0200 | [diff] [blame] | 528 | |
| 529 | /* Register NOR Flash */ |
| 530 | mxc_register_device(&armadillo5x0_nor_flash, |
| 531 | &armadillo5x0_nor_flash_pdata); |
Alberto Panizzo | 0c8bad6 | 2009-06-17 15:06:30 +0200 | [diff] [blame] | 532 | |
| 533 | /* Register NAND Flash */ |
Uwe Kleine-König | a2ceeef | 2010-06-16 12:23:11 +0200 | [diff] [blame] | 534 | imx31_add_mxc_nand(&armadillo5x0_nand_board_info); |
Alberto Panizzo | 0c8bad6 | 2009-06-17 15:06:30 +0200 | [diff] [blame] | 535 | |
| 536 | /* set NAND page size to 2k if not configured via boot mode pins */ |
| 537 | __raw_writel(__raw_readl(MXC_CCM_RCSR) | (1 << 30), MXC_CCM_RCSR); |
Alberto Panizzo | 2097abc | 2009-10-15 19:33:24 +0200 | [diff] [blame] | 538 | |
| 539 | /* RTC */ |
| 540 | /* Get RTC IRQ and register the chip */ |
| 541 | if (gpio_request(ARMADILLO5X0_RTC_GPIO, "rtc") == 0) { |
| 542 | if (gpio_direction_input(ARMADILLO5X0_RTC_GPIO) == 0) |
| 543 | armadillo5x0_i2c_rtc.irq = gpio_to_irq(ARMADILLO5X0_RTC_GPIO); |
| 544 | else |
| 545 | gpio_free(ARMADILLO5X0_RTC_GPIO); |
| 546 | } |
| 547 | if (armadillo5x0_i2c_rtc.irq == 0) |
| 548 | pr_warning("armadillo5x0_init: failed to get RTC IRQ\n"); |
| 549 | i2c_register_board_info(1, &armadillo5x0_i2c_rtc, 1); |
Alberto Panizzo | b3aa111 | 2010-02-26 18:36:32 +0100 | [diff] [blame] | 550 | |
| 551 | /* USB */ |
| 552 | #if defined(CONFIG_USB_ULPI) |
| 553 | usbotg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, |
| 554 | USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT); |
| 555 | usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, |
| 556 | USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT); |
| 557 | |
| 558 | mxc_register_device(&mxc_otg_host, &usbotg_pdata); |
| 559 | mxc_register_device(&mxc_usbh2, &usbh2_pdata); |
| 560 | #endif |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 561 | } |
| 562 | |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 563 | static void __init armadillo5x0_timer_init(void) |
| 564 | { |
| 565 | mx31_clocks_init(26000000); |
| 566 | } |
| 567 | |
| 568 | static struct sys_timer armadillo5x0_timer = { |
| 569 | .init = armadillo5x0_timer_init, |
| 570 | }; |
| 571 | |
| 572 | MACHINE_START(ARMADILLO5X0, "Armadillo-500") |
| 573 | /* Maintainer: Alberto Panizzo */ |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 574 | .phys_io = MX31_AIPS1_BASE_ADDR, |
Uwe Kleine-König | 321ed16 | 2009-12-10 10:41:26 +0100 | [diff] [blame] | 575 | .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc, |
Uwe Kleine-König | 3410123 | 2010-01-29 17:36:05 +0100 | [diff] [blame] | 576 | .boot_params = MX3x_PHYS_OFFSET + 0x100, |
Alberto Panizzo | 4e0f0881 | 2009-05-25 22:35:38 +0200 | [diff] [blame] | 577 | .map_io = mx31_map_io, |
Sascha Hauer | c5aa0ad | 2009-05-25 17:36:19 +0200 | [diff] [blame] | 578 | .init_irq = mx31_init_irq, |
Alberto Panizzo | 5e9145e | 2009-05-19 10:01:03 +0200 | [diff] [blame] | 579 | .timer = &armadillo5x0_timer, |
| 580 | .init_machine = armadillo5x0_init, |
| 581 | MACHINE_END |