Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2000 Deep Blue Solutions Ltd |
| 3 | * Copyright (C) 2002 Shane Nay (shane@minirl.com) |
| 4 | * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/mtd/mtd.h> |
| 19 | #include <linux/mtd/map.h> |
| 20 | #include <linux/mtd/partitions.h> |
| 21 | #include <linux/mtd/physmap.h> |
| 22 | #include <linux/i2c.h> |
| 23 | #include <linux/irq.h> |
| 24 | #include <mach/common.h> |
| 25 | #include <mach/hardware.h> |
| 26 | #include <asm/mach-types.h> |
| 27 | #include <asm/mach/arch.h> |
| 28 | #include <asm/mach/time.h> |
| 29 | #include <asm/mach/map.h> |
| 30 | #include <linux/gpio.h> |
Uwe Kleine-König | e835d88 | 2010-02-16 11:07:49 +0100 | [diff] [blame] | 31 | #include <mach/iomux-mx27.h> |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 32 | #include <mach/mxc_nand.h> |
Alan Carvalho de Assis | 9e3e7af | 2009-11-27 14:09:54 -0200 | [diff] [blame] | 33 | #include <linux/i2c/pca953x.h> |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 34 | #include <mach/imxfb.h> |
| 35 | #include <mach/mmc.h> |
| 36 | |
Uwe Kleine-König | 0e7a29a | 2010-06-16 07:35:31 +0200 | [diff] [blame] | 37 | #include "devices-imx27.h" |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 38 | #include "devices.h" |
| 39 | |
| 40 | static unsigned int mxt_td60_pins[] __initdata = { |
| 41 | /* UART0 */ |
| 42 | PE12_PF_UART1_TXD, |
| 43 | PE13_PF_UART1_RXD, |
| 44 | PE14_PF_UART1_CTS, |
| 45 | PE15_PF_UART1_RTS, |
| 46 | /* UART1 */ |
| 47 | PE3_PF_UART2_CTS, |
| 48 | PE4_PF_UART2_RTS, |
| 49 | PE6_PF_UART2_TXD, |
| 50 | PE7_PF_UART2_RXD, |
| 51 | /* UART2 */ |
| 52 | PE8_PF_UART3_TXD, |
| 53 | PE9_PF_UART3_RXD, |
| 54 | PE10_PF_UART3_CTS, |
| 55 | PE11_PF_UART3_RTS, |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 56 | /* FEC */ |
| 57 | PD0_AIN_FEC_TXD0, |
| 58 | PD1_AIN_FEC_TXD1, |
| 59 | PD2_AIN_FEC_TXD2, |
| 60 | PD3_AIN_FEC_TXD3, |
| 61 | PD4_AOUT_FEC_RX_ER, |
| 62 | PD5_AOUT_FEC_RXD1, |
| 63 | PD6_AOUT_FEC_RXD2, |
| 64 | PD7_AOUT_FEC_RXD3, |
| 65 | PD8_AF_FEC_MDIO, |
| 66 | PD9_AIN_FEC_MDC, |
| 67 | PD10_AOUT_FEC_CRS, |
| 68 | PD11_AOUT_FEC_TX_CLK, |
| 69 | PD12_AOUT_FEC_RXD0, |
| 70 | PD13_AOUT_FEC_RX_DV, |
| 71 | PD14_AOUT_FEC_RX_CLK, |
| 72 | PD15_AOUT_FEC_COL, |
| 73 | PD16_AIN_FEC_TX_ER, |
| 74 | PF23_AIN_FEC_TX_EN, |
| 75 | /* I2C1 */ |
| 76 | PD17_PF_I2C_DATA, |
| 77 | PD18_PF_I2C_CLK, |
| 78 | /* I2C2 */ |
| 79 | PC5_PF_I2C2_SDA, |
| 80 | PC6_PF_I2C2_SCL, |
| 81 | /* FB */ |
| 82 | PA5_PF_LSCLK, |
| 83 | PA6_PF_LD0, |
| 84 | PA7_PF_LD1, |
| 85 | PA8_PF_LD2, |
| 86 | PA9_PF_LD3, |
| 87 | PA10_PF_LD4, |
| 88 | PA11_PF_LD5, |
| 89 | PA12_PF_LD6, |
| 90 | PA13_PF_LD7, |
| 91 | PA14_PF_LD8, |
| 92 | PA15_PF_LD9, |
| 93 | PA16_PF_LD10, |
| 94 | PA17_PF_LD11, |
| 95 | PA18_PF_LD12, |
| 96 | PA19_PF_LD13, |
| 97 | PA20_PF_LD14, |
| 98 | PA21_PF_LD15, |
| 99 | PA22_PF_LD16, |
| 100 | PA23_PF_LD17, |
| 101 | PA25_PF_CLS, |
| 102 | PA27_PF_SPL_SPR, |
| 103 | PA28_PF_HSYNC, |
| 104 | PA29_PF_VSYNC, |
| 105 | PA30_PF_CONTRAST, |
| 106 | PA31_PF_OE_ACD, |
| 107 | /* OWIRE */ |
| 108 | PE16_AF_OWIRE, |
| 109 | /* SDHC1*/ |
| 110 | PE18_PF_SD1_D0, |
| 111 | PE19_PF_SD1_D1, |
| 112 | PE20_PF_SD1_D2, |
| 113 | PE21_PF_SD1_D3, |
| 114 | PE22_PF_SD1_CMD, |
| 115 | PE23_PF_SD1_CLK, |
Alan Carvalho de Assis | 9e3e7af | 2009-11-27 14:09:54 -0200 | [diff] [blame] | 116 | PF8_AF_ATA_IORDY, |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 117 | /* SDHC2*/ |
| 118 | PB4_PF_SD2_D0, |
| 119 | PB5_PF_SD2_D1, |
| 120 | PB6_PF_SD2_D2, |
| 121 | PB7_PF_SD2_D3, |
| 122 | PB8_PF_SD2_CMD, |
| 123 | PB9_PF_SD2_CLK, |
| 124 | }; |
| 125 | |
Uwe Kleine-König | 0e7a29a | 2010-06-16 07:35:31 +0200 | [diff] [blame] | 126 | static const struct mxc_nand_platform_data |
| 127 | mxt_td60_nand_board_info __initconst = { |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 128 | .width = 1, |
| 129 | .hw_ecc = 1, |
| 130 | }; |
| 131 | |
Uwe Kleine-König | c698715 | 2010-06-16 17:25:40 +0200 | [diff] [blame] | 132 | static const struct imxi2c_platform_data mxt_td60_i2c0_data __initconst = { |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 133 | .bitrate = 100000, |
| 134 | }; |
| 135 | |
Alan Carvalho de Assis | 9e3e7af | 2009-11-27 14:09:54 -0200 | [diff] [blame] | 136 | /* PCA9557 */ |
| 137 | static int mxt_td60_pca9557_setup(struct i2c_client *client, |
| 138 | unsigned gpio_base, unsigned ngpio, |
| 139 | void *context) |
| 140 | { |
| 141 | static int mxt_td60_gpio_value[] = { |
| 142 | -1, -1, -1, -1, -1, -1, -1, 1 |
| 143 | }; |
| 144 | int n; |
| 145 | |
| 146 | for (n = 0; n < ARRAY_SIZE(mxt_td60_gpio_value); ++n) { |
| 147 | gpio_request(gpio_base + n, "MXT_TD60 GPIO Exp"); |
| 148 | if (mxt_td60_gpio_value[n] < 0) |
| 149 | gpio_direction_input(gpio_base + n); |
| 150 | else |
| 151 | gpio_direction_output(gpio_base + n, |
| 152 | mxt_td60_gpio_value[n]); |
| 153 | gpio_export(gpio_base + n, 0); |
| 154 | } |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | static struct pca953x_platform_data mxt_td60_pca9557_pdata = { |
| 160 | .gpio_base = 240, /* place PCA9557 after all MX27 gpio pins */ |
| 161 | .invert = 0, /* Do not invert */ |
| 162 | .setup = mxt_td60_pca9557_setup, |
| 163 | }; |
| 164 | |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 165 | static struct i2c_board_info mxt_td60_i2c_devices[] = { |
Alan Carvalho de Assis | 9e3e7af | 2009-11-27 14:09:54 -0200 | [diff] [blame] | 166 | { |
| 167 | I2C_BOARD_INFO("pca9557", 0x18), |
| 168 | .platform_data = &mxt_td60_pca9557_pdata, |
| 169 | }, |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 170 | }; |
| 171 | |
Uwe Kleine-König | c698715 | 2010-06-16 17:25:40 +0200 | [diff] [blame] | 172 | static const struct imxi2c_platform_data mxt_td60_i2c1_data __initconst = { |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 173 | .bitrate = 100000, |
| 174 | }; |
| 175 | |
| 176 | static struct i2c_board_info mxt_td60_i2c2_devices[] = { |
| 177 | }; |
| 178 | |
| 179 | static struct imx_fb_videomode mxt_td60_modes[] = { |
| 180 | { |
| 181 | .mode = { |
| 182 | .name = "Chimei LW700AT9003", |
| 183 | .refresh = 60, |
| 184 | .xres = 800, |
| 185 | .yres = 480, |
| 186 | .pixclock = 30303, |
| 187 | .hsync_len = 64, |
| 188 | .left_margin = 0x67, |
| 189 | .right_margin = 0x68, |
| 190 | .vsync_len = 16, |
| 191 | .upper_margin = 0x0f, |
| 192 | .lower_margin = 0x0f, |
| 193 | }, |
| 194 | .bpp = 16, |
| 195 | .pcr = 0xFA208B83, |
| 196 | }, |
| 197 | }; |
| 198 | |
| 199 | static struct imx_fb_platform_data mxt_td60_fb_data = { |
| 200 | .mode = mxt_td60_modes, |
| 201 | .num_modes = ARRAY_SIZE(mxt_td60_modes), |
| 202 | |
| 203 | /* |
| 204 | * - HSYNC active high |
| 205 | * - VSYNC active high |
| 206 | * - clk notenabled while idle |
| 207 | * - clock inverted |
| 208 | * - data not inverted |
| 209 | * - data enable low active |
| 210 | * - enable sharp mode |
| 211 | */ |
| 212 | .pwmr = 0x00A903FF, |
| 213 | .lscr1 = 0x00120300, |
| 214 | .dmacr = 0x00020010, |
| 215 | }; |
| 216 | |
| 217 | static int mxt_td60_sdhc1_init(struct device *dev, irq_handler_t detect_irq, |
| 218 | void *data) |
| 219 | { |
Alan Carvalho de Assis | 9e3e7af | 2009-11-27 14:09:54 -0200 | [diff] [blame] | 220 | return request_irq(IRQ_GPIOF(8), detect_irq, IRQF_TRIGGER_FALLING, |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 221 | "sdhc1-card-detect", data); |
| 222 | } |
| 223 | |
| 224 | static void mxt_td60_sdhc1_exit(struct device *dev, void *data) |
| 225 | { |
Alan Carvalho de Assis | 9e3e7af | 2009-11-27 14:09:54 -0200 | [diff] [blame] | 226 | free_irq(IRQ_GPIOF(8), data); |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | static struct imxmmc_platform_data sdhc1_pdata = { |
| 230 | .init = mxt_td60_sdhc1_init, |
| 231 | .exit = mxt_td60_sdhc1_exit, |
| 232 | }; |
| 233 | |
| 234 | static struct platform_device *platform_devices[] __initdata = { |
| 235 | &mxc_fec_device, |
| 236 | }; |
| 237 | |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 238 | static const struct imxuart_platform_data uart_pdata __initconst = { |
| 239 | .flags = IMXUART_HAVE_RTSCTS, |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 240 | }; |
| 241 | |
| 242 | static void __init mxt_td60_board_init(void) |
| 243 | { |
| 244 | mxc_gpio_setup_multiple_pins(mxt_td60_pins, ARRAY_SIZE(mxt_td60_pins), |
| 245 | "MXT_TD60"); |
| 246 | |
Uwe Kleine-König | d5dac4a | 2010-06-23 09:36:01 +0200 | [diff] [blame] | 247 | imx27_add_imx_uart0(&uart_pdata); |
| 248 | imx27_add_imx_uart1(&uart_pdata); |
| 249 | imx27_add_imx_uart2(&uart_pdata); |
Uwe Kleine-König | 0e7a29a | 2010-06-16 07:35:31 +0200 | [diff] [blame] | 250 | imx27_add_mxc_nand(&mxt_td60_nand_board_info); |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 251 | |
| 252 | i2c_register_board_info(0, mxt_td60_i2c_devices, |
| 253 | ARRAY_SIZE(mxt_td60_i2c_devices)); |
| 254 | |
| 255 | i2c_register_board_info(1, mxt_td60_i2c2_devices, |
| 256 | ARRAY_SIZE(mxt_td60_i2c2_devices)); |
| 257 | |
Uwe Kleine-König | c698715 | 2010-06-16 17:25:40 +0200 | [diff] [blame] | 258 | imx27_add_i2c_imx0(&mxt_td60_i2c0_data); |
| 259 | imx27_add_i2c_imx1(&mxt_td60_i2c1_data); |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 260 | mxc_register_device(&mxc_fb_device, &mxt_td60_fb_data); |
| 261 | mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata); |
| 262 | |
| 263 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
| 264 | } |
| 265 | |
| 266 | static void __init mxt_td60_timer_init(void) |
| 267 | { |
| 268 | mx27_clocks_init(26000000); |
| 269 | } |
| 270 | |
| 271 | static struct sys_timer mxt_td60_timer = { |
| 272 | .init = mxt_td60_timer_init, |
| 273 | }; |
| 274 | |
| 275 | MACHINE_START(MXT_TD60, "Maxtrack i-MXT TD60") |
| 276 | /* maintainer: Maxtrack Industrial */ |
Uwe Kleine-König | 3f35d1f | 2009-12-09 11:32:11 +0100 | [diff] [blame] | 277 | .phys_io = MX27_AIPI_BASE_ADDR, |
| 278 | .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
Uwe Kleine-König | 3410123 | 2010-01-29 17:36:05 +0100 | [diff] [blame] | 279 | .boot_params = MX27_PHYS_OFFSET + 0x100, |
Alan Carvalho de Assis | 143a179 | 2009-11-25 15:24:50 -0200 | [diff] [blame] | 280 | .map_io = mx27_map_io, |
| 281 | .init_irq = mx27_init_irq, |
| 282 | .init_machine = mxt_td60_board_init, |
| 283 | .timer = &mxt_td60_timer, |
| 284 | MACHINE_END |
| 285 | |