Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
Magnus Lilja | a2ef456 | 2010-05-14 17:08:29 +0200 | [diff] [blame] | 19 | #include <linux/delay.h> |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 20 | #include <linux/types.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/clk.h> |
| 23 | #include <linux/irq.h> |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 24 | #include <linux/gpio.h> |
Magnus Lilja | 2b0c367 | 2009-05-18 18:46:33 +0200 | [diff] [blame] | 25 | #include <linux/smsc911x.h> |
| 26 | #include <linux/platform_device.h> |
Alberto Panizzo | ae7a3f1 | 2010-03-23 19:51:45 +0100 | [diff] [blame] | 27 | #include <linux/mfd/mc13783.h> |
| 28 | #include <linux/spi/spi.h> |
| 29 | #include <linux/regulator/machine.h> |
Magnus Lilja | a2ef456 | 2010-05-14 17:08:29 +0200 | [diff] [blame] | 30 | #include <linux/fsl_devices.h> |
Alberto Panizzo | 54c1f63 | 2010-05-19 11:34:43 +0200 | [diff] [blame] | 31 | #include <linux/input/matrix_keypad.h> |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 32 | |
| 33 | #include <mach/hardware.h> |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/time.h> |
| 37 | #include <asm/memory.h> |
| 38 | #include <asm/mach/map.h> |
| 39 | #include <mach/common.h> |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 40 | #include <mach/imx-uart.h> |
| 41 | #include <mach/iomux-mx3.h> |
Alberto Panizzo | a1b67b9 | 2010-03-23 19:49:35 +0100 | [diff] [blame] | 42 | #include <mach/mxc_nand.h> |
Alberto Panizzo | a1ac442 | 2010-03-23 19:50:28 +0100 | [diff] [blame] | 43 | #include <mach/spi.h> |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 44 | #include "devices.h" |
| 45 | |
Uwe Kleine-König | b396dc4 | 2010-03-08 16:57:19 +0100 | [diff] [blame^] | 46 | /* Definitions for components on the Debug board */ |
| 47 | |
| 48 | /* Base address of CPLD controller on the Debug board */ |
| 49 | #define DEBUG_BASE_ADDRESS CS5_IO_ADDRESS(MX3x_CS5_BASE_ADDR) |
| 50 | |
| 51 | /* LAN9217 ethernet base address */ |
| 52 | #define LAN9217_BASE_ADDR MX3x_CS5_BASE_ADDR |
| 53 | |
| 54 | /* CPLD config and interrupt base address */ |
| 55 | #define CPLD_ADDR (DEBUG_BASE_ADDRESS + 0x20000) |
| 56 | |
| 57 | /* status, interrupt */ |
| 58 | #define CPLD_INT_STATUS_REG (CPLD_ADDR + 0x10) |
| 59 | #define CPLD_INT_MASK_REG (CPLD_ADDR + 0x38) |
| 60 | #define CPLD_INT_RESET_REG (CPLD_ADDR + 0x20) |
| 61 | /* magic word for debug CPLD */ |
| 62 | #define CPLD_MAGIC_NUMBER1_REG (CPLD_ADDR + 0x40) |
| 63 | #define CPLD_MAGIC_NUMBER2_REG (CPLD_ADDR + 0x48) |
| 64 | /* CPLD code version */ |
| 65 | #define CPLD_CODE_VER_REG (CPLD_ADDR + 0x50) |
| 66 | /* magic word for debug CPLD */ |
| 67 | #define CPLD_MAGIC_NUMBER3_REG (CPLD_ADDR + 0x58) |
| 68 | |
| 69 | /* CPLD IRQ line for external uart, external ethernet etc */ |
| 70 | #define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1) |
| 71 | |
| 72 | #define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START) |
| 73 | #define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) |
| 74 | |
| 75 | #define EXPIO_INT_ENET (MXC_EXP_IO_BASE + 0) |
| 76 | |
| 77 | #define MXC_MAX_EXP_IO_LINES 16 |
| 78 | |
| 79 | /* |
| 80 | * This file contains the board-specific initialization routines. |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 81 | */ |
| 82 | |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 83 | static int mx31_3ds_pins[] = { |
Magnus Lilja | 153fa1d | 2009-05-16 12:43:10 +0200 | [diff] [blame] | 84 | /* UART1 */ |
Valentin Longchamp | 63d97667 | 2009-01-28 15:13:53 +0100 | [diff] [blame] | 85 | MX31_PIN_CTS1__CTS1, |
| 86 | MX31_PIN_RTS1__RTS1, |
| 87 | MX31_PIN_TXD1__TXD1, |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 88 | MX31_PIN_RXD1__RXD1, |
| 89 | IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO), |
Alberto Panizzo | a1ac442 | 2010-03-23 19:50:28 +0100 | [diff] [blame] | 90 | /* SPI 1 */ |
| 91 | MX31_PIN_CSPI2_SCLK__SCLK, |
| 92 | MX31_PIN_CSPI2_MOSI__MOSI, |
| 93 | MX31_PIN_CSPI2_MISO__MISO, |
| 94 | MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, |
| 95 | MX31_PIN_CSPI2_SS0__SS0, |
| 96 | MX31_PIN_CSPI2_SS2__SS2, /*CS for MC13783 */ |
Alberto Panizzo | ae7a3f1 | 2010-03-23 19:51:45 +0100 | [diff] [blame] | 97 | /* MC13783 IRQ */ |
| 98 | IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO), |
Magnus Lilja | a2ef456 | 2010-05-14 17:08:29 +0200 | [diff] [blame] | 99 | /* USB OTG reset */ |
| 100 | IOMUX_MODE(MX31_PIN_USB_PWR, IOMUX_CONFIG_GPIO), |
| 101 | /* USB OTG */ |
| 102 | MX31_PIN_USBOTG_DATA0__USBOTG_DATA0, |
| 103 | MX31_PIN_USBOTG_DATA1__USBOTG_DATA1, |
| 104 | MX31_PIN_USBOTG_DATA2__USBOTG_DATA2, |
| 105 | MX31_PIN_USBOTG_DATA3__USBOTG_DATA3, |
| 106 | MX31_PIN_USBOTG_DATA4__USBOTG_DATA4, |
| 107 | MX31_PIN_USBOTG_DATA5__USBOTG_DATA5, |
| 108 | MX31_PIN_USBOTG_DATA6__USBOTG_DATA6, |
| 109 | MX31_PIN_USBOTG_DATA7__USBOTG_DATA7, |
| 110 | MX31_PIN_USBOTG_CLK__USBOTG_CLK, |
| 111 | MX31_PIN_USBOTG_DIR__USBOTG_DIR, |
| 112 | MX31_PIN_USBOTG_NXT__USBOTG_NXT, |
| 113 | MX31_PIN_USBOTG_STP__USBOTG_STP, |
Alberto Panizzo | 54c1f63 | 2010-05-19 11:34:43 +0200 | [diff] [blame] | 114 | /*Keyboard*/ |
| 115 | MX31_PIN_KEY_ROW0_KEY_ROW0, |
| 116 | MX31_PIN_KEY_ROW1_KEY_ROW1, |
| 117 | MX31_PIN_KEY_ROW2_KEY_ROW2, |
| 118 | MX31_PIN_KEY_COL0_KEY_COL0, |
| 119 | MX31_PIN_KEY_COL1_KEY_COL1, |
| 120 | MX31_PIN_KEY_COL2_KEY_COL2, |
| 121 | MX31_PIN_KEY_COL3_KEY_COL3, |
| 122 | }; |
| 123 | |
| 124 | /* |
| 125 | * Matrix keyboard |
| 126 | */ |
| 127 | |
| 128 | static const uint32_t mx31_3ds_keymap[] = { |
| 129 | KEY(0, 0, KEY_UP), |
| 130 | KEY(0, 1, KEY_DOWN), |
| 131 | KEY(1, 0, KEY_RIGHT), |
| 132 | KEY(1, 1, KEY_LEFT), |
| 133 | KEY(1, 2, KEY_ENTER), |
| 134 | KEY(2, 0, KEY_F6), |
| 135 | KEY(2, 1, KEY_F8), |
| 136 | KEY(2, 2, KEY_F9), |
| 137 | KEY(2, 3, KEY_F10), |
| 138 | }; |
| 139 | |
| 140 | static struct matrix_keymap_data mx31_3ds_keymap_data = { |
| 141 | .keymap = mx31_3ds_keymap, |
| 142 | .keymap_size = ARRAY_SIZE(mx31_3ds_keymap), |
Alberto Panizzo | ae7a3f1 | 2010-03-23 19:51:45 +0100 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | /* Regulators */ |
| 146 | static struct regulator_init_data pwgtx_init = { |
| 147 | .constraints = { |
| 148 | .boot_on = 1, |
| 149 | .always_on = 1, |
| 150 | }, |
| 151 | }; |
| 152 | |
| 153 | static struct mc13783_regulator_init_data mx31_3ds_regulators[] = { |
| 154 | { |
| 155 | .id = MC13783_REGU_PWGT1SPI, /* Power Gate for ARM core. */ |
| 156 | .init_data = &pwgtx_init, |
| 157 | }, { |
| 158 | .id = MC13783_REGU_PWGT2SPI, /* Power Gate for L2 Cache. */ |
| 159 | .init_data = &pwgtx_init, |
| 160 | }, |
| 161 | }; |
| 162 | |
| 163 | /* MC13783 */ |
| 164 | static struct mc13783_platform_data mc13783_pdata __initdata = { |
| 165 | .regulators = mx31_3ds_regulators, |
| 166 | .num_regulators = ARRAY_SIZE(mx31_3ds_regulators), |
| 167 | .flags = MC13783_USE_REGULATOR, |
Alberto Panizzo | a1ac442 | 2010-03-23 19:50:28 +0100 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | /* SPI */ |
| 171 | static int spi1_internal_chipselect[] = { |
| 172 | MXC_SPI_CS(0), |
| 173 | MXC_SPI_CS(2), |
| 174 | }; |
| 175 | |
| 176 | static struct spi_imx_master spi1_pdata = { |
| 177 | .chipselect = spi1_internal_chipselect, |
| 178 | .num_chipselect = ARRAY_SIZE(spi1_internal_chipselect), |
Valentin Longchamp | 63d97667 | 2009-01-28 15:13:53 +0100 | [diff] [blame] | 179 | }; |
| 180 | |
Alberto Panizzo | ae7a3f1 | 2010-03-23 19:51:45 +0100 | [diff] [blame] | 181 | static struct spi_board_info mx31_3ds_spi_devs[] __initdata = { |
| 182 | { |
| 183 | .modalias = "mc13783", |
| 184 | .max_speed_hz = 1000000, |
| 185 | .bus_num = 1, |
| 186 | .chip_select = 1, /* SS2 */ |
| 187 | .platform_data = &mc13783_pdata, |
| 188 | .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3), |
| 189 | .mode = SPI_CS_HIGH, |
| 190 | }, |
| 191 | }; |
| 192 | |
Alberto Panizzo | a1b67b9 | 2010-03-23 19:49:35 +0100 | [diff] [blame] | 193 | /* |
| 194 | * NAND Flash |
| 195 | */ |
| 196 | static struct mxc_nand_platform_data imx31_3ds_nand_flash_pdata = { |
| 197 | .width = 1, |
| 198 | .hw_ecc = 1, |
| 199 | #ifdef MACH_MX31_3DS_MXC_NAND_USE_BBT |
| 200 | .flash_bbt = 1, |
| 201 | #endif |
| 202 | }; |
| 203 | |
Magnus Lilja | a2ef456 | 2010-05-14 17:08:29 +0200 | [diff] [blame] | 204 | /* |
| 205 | * USB OTG |
| 206 | */ |
| 207 | |
| 208 | #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ |
| 209 | PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) |
| 210 | |
| 211 | #define USBOTG_RST_B IOMUX_TO_GPIO(MX31_PIN_USB_PWR) |
| 212 | |
| 213 | static void mx31_3ds_usbotg_init(void) |
| 214 | { |
| 215 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG); |
| 216 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG); |
| 217 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG); |
| 218 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG); |
| 219 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG); |
| 220 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG); |
| 221 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG); |
| 222 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG); |
| 223 | mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG); |
| 224 | mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG); |
| 225 | mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG); |
| 226 | mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG); |
| 227 | |
| 228 | gpio_request(USBOTG_RST_B, "otgusb-reset"); |
| 229 | gpio_direction_output(USBOTG_RST_B, 0); |
| 230 | mdelay(1); |
| 231 | gpio_set_value(USBOTG_RST_B, 1); |
| 232 | } |
| 233 | |
| 234 | static struct fsl_usb2_platform_data usbotg_pdata = { |
| 235 | .operating_mode = FSL_USB2_DR_DEVICE, |
| 236 | .phy_mode = FSL_USB2_PHY_ULPI, |
| 237 | }; |
| 238 | |
Magnus Lilja | 153fa1d | 2009-05-16 12:43:10 +0200 | [diff] [blame] | 239 | static struct imxuart_platform_data uart_pdata = { |
| 240 | .flags = IMXUART_HAVE_RTSCTS, |
| 241 | }; |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 242 | |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 243 | /* |
Magnus Lilja | 2b0c367 | 2009-05-18 18:46:33 +0200 | [diff] [blame] | 244 | * Support for the SMSC9217 on the Debug board. |
| 245 | */ |
| 246 | |
| 247 | static struct smsc911x_platform_config smsc911x_config = { |
| 248 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 249 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 250 | .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY, |
| 251 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 252 | }; |
| 253 | |
| 254 | static struct resource smsc911x_resources[] = { |
| 255 | { |
| 256 | .start = LAN9217_BASE_ADDR, |
| 257 | .end = LAN9217_BASE_ADDR + 0xff, |
| 258 | .flags = IORESOURCE_MEM, |
| 259 | }, { |
| 260 | .start = EXPIO_INT_ENET, |
| 261 | .end = EXPIO_INT_ENET, |
| 262 | .flags = IORESOURCE_IRQ, |
| 263 | }, |
| 264 | }; |
| 265 | |
| 266 | static struct platform_device smsc911x_device = { |
| 267 | .name = "smsc911x", |
| 268 | .id = -1, |
| 269 | .num_resources = ARRAY_SIZE(smsc911x_resources), |
| 270 | .resource = smsc911x_resources, |
| 271 | .dev = { |
| 272 | .platform_data = &smsc911x_config, |
| 273 | }, |
| 274 | }; |
| 275 | |
| 276 | /* |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 277 | * Routines for the CPLD on the debug board. It contains a CPLD handling |
| 278 | * LEDs, switches, interrupts for Ethernet. |
| 279 | */ |
| 280 | |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 281 | static void mx31_3ds_expio_irq_handler(uint32_t irq, struct irq_desc *desc) |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 282 | { |
| 283 | uint32_t imr_val; |
| 284 | uint32_t int_valid; |
| 285 | uint32_t expio_irq; |
| 286 | |
| 287 | imr_val = __raw_readw(CPLD_INT_MASK_REG); |
| 288 | int_valid = __raw_readw(CPLD_INT_STATUS_REG) & ~imr_val; |
| 289 | |
| 290 | expio_irq = MXC_EXP_IO_BASE; |
| 291 | for (; int_valid != 0; int_valid >>= 1, expio_irq++) { |
| 292 | if ((int_valid & 1) == 0) |
| 293 | continue; |
| 294 | generic_handle_irq(expio_irq); |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | /* |
| 299 | * Disable an expio pin's interrupt by setting the bit in the imr. |
| 300 | * @param irq an expio virtual irq number |
| 301 | */ |
| 302 | static void expio_mask_irq(uint32_t irq) |
| 303 | { |
| 304 | uint16_t reg; |
| 305 | uint32_t expio = MXC_IRQ_TO_EXPIO(irq); |
| 306 | |
| 307 | /* mask the interrupt */ |
| 308 | reg = __raw_readw(CPLD_INT_MASK_REG); |
| 309 | reg |= 1 << expio; |
| 310 | __raw_writew(reg, CPLD_INT_MASK_REG); |
| 311 | } |
| 312 | |
| 313 | /* |
| 314 | * Acknowledge an expanded io pin's interrupt by clearing the bit in the isr. |
| 315 | * @param irq an expanded io virtual irq number |
| 316 | */ |
| 317 | static void expio_ack_irq(uint32_t irq) |
| 318 | { |
| 319 | uint32_t expio = MXC_IRQ_TO_EXPIO(irq); |
| 320 | |
| 321 | /* clear the interrupt status */ |
| 322 | __raw_writew(1 << expio, CPLD_INT_RESET_REG); |
| 323 | __raw_writew(0, CPLD_INT_RESET_REG); |
| 324 | /* mask the interrupt */ |
| 325 | expio_mask_irq(irq); |
| 326 | } |
| 327 | |
| 328 | /* |
| 329 | * Enable a expio pin's interrupt by clearing the bit in the imr. |
| 330 | * @param irq a expio virtual irq number |
| 331 | */ |
| 332 | static void expio_unmask_irq(uint32_t irq) |
| 333 | { |
| 334 | uint16_t reg; |
| 335 | uint32_t expio = MXC_IRQ_TO_EXPIO(irq); |
| 336 | |
| 337 | /* unmask the interrupt */ |
| 338 | reg = __raw_readw(CPLD_INT_MASK_REG); |
| 339 | reg &= ~(1 << expio); |
| 340 | __raw_writew(reg, CPLD_INT_MASK_REG); |
| 341 | } |
| 342 | |
| 343 | static struct irq_chip expio_irq_chip = { |
| 344 | .ack = expio_ack_irq, |
| 345 | .mask = expio_mask_irq, |
| 346 | .unmask = expio_unmask_irq, |
| 347 | }; |
| 348 | |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 349 | static int __init mx31_3ds_init_expio(void) |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 350 | { |
| 351 | int i; |
| 352 | int ret; |
| 353 | |
| 354 | /* Check if there's a debug board connected */ |
| 355 | if ((__raw_readw(CPLD_MAGIC_NUMBER1_REG) != 0xAAAA) || |
| 356 | (__raw_readw(CPLD_MAGIC_NUMBER2_REG) != 0x5555) || |
| 357 | (__raw_readw(CPLD_MAGIC_NUMBER3_REG) != 0xCAFE)) { |
| 358 | /* No Debug board found */ |
| 359 | return -ENODEV; |
| 360 | } |
| 361 | |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 362 | pr_info("i.MX31 3DS Debug board detected, rev = 0x%04X\n", |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 363 | __raw_readw(CPLD_CODE_VER_REG)); |
| 364 | |
| 365 | /* |
| 366 | * Configure INT line as GPIO input |
| 367 | */ |
| 368 | ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "sms9217-irq"); |
| 369 | if (ret) |
| 370 | pr_warning("could not get LAN irq gpio\n"); |
| 371 | else |
| 372 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); |
| 373 | |
| 374 | /* Disable the interrupts and clear the status */ |
| 375 | __raw_writew(0, CPLD_INT_MASK_REG); |
| 376 | __raw_writew(0xFFFF, CPLD_INT_RESET_REG); |
| 377 | __raw_writew(0, CPLD_INT_RESET_REG); |
| 378 | __raw_writew(0x1F, CPLD_INT_MASK_REG); |
| 379 | for (i = MXC_EXP_IO_BASE; |
| 380 | i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES); |
| 381 | i++) { |
| 382 | set_irq_chip(i, &expio_irq_chip); |
| 383 | set_irq_handler(i, handle_level_irq); |
| 384 | set_irq_flags(i, IRQF_VALID); |
| 385 | } |
| 386 | set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_LOW); |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 387 | set_irq_chained_handler(EXPIO_PARENT_INT, mx31_3ds_expio_irq_handler); |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | /* |
| 393 | * This structure defines the MX31 memory map. |
| 394 | */ |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 395 | static struct map_desc mx31_3ds_io_desc[] __initdata = { |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 396 | { |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 397 | .virtual = MX31_CS5_BASE_ADDR_VIRT, |
| 398 | .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR), |
| 399 | .length = MX31_CS5_SIZE, |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 400 | .type = MT_DEVICE, |
| 401 | }, |
| 402 | }; |
| 403 | |
| 404 | /* |
| 405 | * Set up static virtual mappings. |
| 406 | */ |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 407 | static void __init mx31_3ds_map_io(void) |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 408 | { |
| 409 | mx31_map_io(); |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 410 | iotable_init(mx31_3ds_io_desc, ARRAY_SIZE(mx31_3ds_io_desc)); |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 411 | } |
| 412 | |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 413 | /*! |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 414 | * Board specific initialization. |
| 415 | */ |
| 416 | static void __init mxc_board_init(void) |
| 417 | { |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 418 | mxc_iomux_setup_multiple_pins(mx31_3ds_pins, ARRAY_SIZE(mx31_3ds_pins), |
| 419 | "mx31_3ds"); |
Magnus Lilja | 153fa1d | 2009-05-16 12:43:10 +0200 | [diff] [blame] | 420 | |
| 421 | mxc_register_device(&mxc_uart_device0, &uart_pdata); |
Alberto Panizzo | a1b67b9 | 2010-03-23 19:49:35 +0100 | [diff] [blame] | 422 | mxc_register_device(&mxc_nand_device, &imx31_3ds_nand_flash_pdata); |
Alberto Panizzo | ae7a3f1 | 2010-03-23 19:51:45 +0100 | [diff] [blame] | 423 | |
Alberto Panizzo | a1ac442 | 2010-03-23 19:50:28 +0100 | [diff] [blame] | 424 | mxc_register_device(&mxc_spi_device1, &spi1_pdata); |
Alberto Panizzo | ae7a3f1 | 2010-03-23 19:51:45 +0100 | [diff] [blame] | 425 | spi_register_board_info(mx31_3ds_spi_devs, |
| 426 | ARRAY_SIZE(mx31_3ds_spi_devs)); |
Magnus Lilja | 135cad3 | 2009-05-17 20:18:08 +0200 | [diff] [blame] | 427 | |
Alberto Panizzo | 54c1f63 | 2010-05-19 11:34:43 +0200 | [diff] [blame] | 428 | mxc_register_device(&imx_kpp_device, &mx31_3ds_keymap_data); |
| 429 | |
Magnus Lilja | a2ef456 | 2010-05-14 17:08:29 +0200 | [diff] [blame] | 430 | mx31_3ds_usbotg_init(); |
| 431 | mxc_register_device(&mxc_otg_udc_device, &usbotg_pdata); |
| 432 | |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 433 | if (!mx31_3ds_init_expio()) |
Magnus Lilja | 2b0c367 | 2009-05-18 18:46:33 +0200 | [diff] [blame] | 434 | platform_device_register(&smsc911x_device); |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 435 | } |
| 436 | |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 437 | static void __init mx31_3ds_timer_init(void) |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 438 | { |
Sascha Hauer | 30c730f | 2009-02-16 14:36:49 +0100 | [diff] [blame] | 439 | mx31_clocks_init(26000000); |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 440 | } |
| 441 | |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 442 | static struct sys_timer mx31_3ds_timer = { |
| 443 | .init = mx31_3ds_timer_init, |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 444 | }; |
| 445 | |
| 446 | /* |
| 447 | * The following uses standard kernel macros defined in arch.h in order to |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 448 | * initialize __mach_desc_MX31_3DS data structure. |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 449 | */ |
| 450 | MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)") |
| 451 | /* Maintainer: Freescale Semiconductor, Inc. */ |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 452 | .phys_io = MX31_AIPS1_BASE_ADDR, |
Uwe Kleine-König | 321ed16 | 2009-12-10 10:41:26 +0100 | [diff] [blame] | 453 | .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc, |
Uwe Kleine-König | 3410123 | 2010-01-29 17:36:05 +0100 | [diff] [blame] | 454 | .boot_params = MX3x_PHYS_OFFSET + 0x100, |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 455 | .map_io = mx31_3ds_map_io, |
Sascha Hauer | c5aa0ad | 2009-05-25 17:36:19 +0200 | [diff] [blame] | 456 | .init_irq = mx31_init_irq, |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 457 | .init_machine = mxc_board_init, |
Alberto Panizzo | 11a332adf | 2010-03-23 19:46:57 +0100 | [diff] [blame] | 458 | .timer = &mx31_3ds_timer, |
Fabio Estevam | 1553a1e | 2008-11-12 15:38:39 +0100 | [diff] [blame] | 459 | MACHINE_END |