Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/cm-x300.c |
| 3 | * |
| 4 | * Support for the CompuLab CM-X300 modules |
| 5 | * |
| 6 | * Copyright (C) 2008 CompuLab Ltd. |
| 7 | * |
| 8 | * Mike Rapoport <mike@compulab.co.il> |
| 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 version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/init.h> |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 19 | #include <linux/delay.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 20 | #include <linux/platform_device.h> |
| 21 | |
| 22 | #include <linux/gpio.h> |
| 23 | #include <linux/dm9000.h> |
| 24 | #include <linux/leds.h> |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 25 | #include <linux/rtc-v3020.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 26 | |
| 27 | #include <linux/i2c.h> |
| 28 | #include <linux/i2c/pca953x.h> |
| 29 | |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 30 | #include <linux/spi/spi.h> |
| 31 | #include <linux/spi/spi_gpio.h> |
| 32 | #include <linux/spi/tdo24m.h> |
| 33 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
Mike Rapoport | b5a5c47 | 2009-06-04 10:44:54 +0300 | [diff] [blame] | 36 | #include <asm/setup.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 37 | |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 38 | #include <mach/pxa300.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 39 | #include <mach/pxafb.h> |
| 40 | #include <mach/mmc.h> |
| 41 | #include <mach/ohci.h> |
Eric Miao | f0a8370 | 2009-04-13 15:03:11 +0800 | [diff] [blame] | 42 | #include <plat/i2c.h> |
Haojian Zhuang | 82b95ecb | 2009-09-10 13:55:23 +0800 | [diff] [blame] | 43 | #include <plat/pxa3xx_nand.h> |
Igor Grinberg | 74e74de | 2009-10-14 09:20:20 +0200 | [diff] [blame] | 44 | #include <mach/audio.h> |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 45 | |
| 46 | #include <asm/mach/map.h> |
| 47 | |
| 48 | #include "generic.h" |
| 49 | |
| 50 | #define CM_X300_ETH_PHYS 0x08000010 |
| 51 | |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 52 | #define GPIO82_MMC_IRQ (82) |
| 53 | #define GPIO85_MMC_WP (85) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 54 | |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 55 | #define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 56 | |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 57 | #define GPIO95_RTC_CS (95) |
| 58 | #define GPIO96_RTC_WR (96) |
| 59 | #define GPIO97_RTC_RD (97) |
| 60 | #define GPIO98_RTC_IO (98) |
| 61 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame^] | 62 | static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = { |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 63 | /* LCD */ |
| 64 | GPIO54_LCD_LDD_0, |
| 65 | GPIO55_LCD_LDD_1, |
| 66 | GPIO56_LCD_LDD_2, |
| 67 | GPIO57_LCD_LDD_3, |
| 68 | GPIO58_LCD_LDD_4, |
| 69 | GPIO59_LCD_LDD_5, |
| 70 | GPIO60_LCD_LDD_6, |
| 71 | GPIO61_LCD_LDD_7, |
| 72 | GPIO62_LCD_LDD_8, |
| 73 | GPIO63_LCD_LDD_9, |
| 74 | GPIO64_LCD_LDD_10, |
| 75 | GPIO65_LCD_LDD_11, |
| 76 | GPIO66_LCD_LDD_12, |
| 77 | GPIO67_LCD_LDD_13, |
| 78 | GPIO68_LCD_LDD_14, |
| 79 | GPIO69_LCD_LDD_15, |
| 80 | GPIO72_LCD_FCLK, |
| 81 | GPIO73_LCD_LCLK, |
| 82 | GPIO74_LCD_PCLK, |
| 83 | GPIO75_LCD_BIAS, |
| 84 | |
| 85 | /* BTUART */ |
| 86 | GPIO111_UART2_RTS, |
| 87 | GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL, |
| 88 | GPIO113_UART2_TXD, |
| 89 | GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH, |
| 90 | |
| 91 | /* STUART */ |
| 92 | GPIO109_UART3_TXD, |
| 93 | GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL, |
| 94 | |
| 95 | /* AC97 */ |
| 96 | GPIO23_AC97_nACRESET, |
| 97 | GPIO24_AC97_SYSCLK, |
| 98 | GPIO29_AC97_BITCLK, |
| 99 | GPIO25_AC97_SDATA_IN_0, |
| 100 | GPIO27_AC97_SDATA_OUT, |
| 101 | GPIO28_AC97_SYNC, |
| 102 | |
| 103 | /* Keypad */ |
| 104 | GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH, |
| 105 | GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH, |
| 106 | GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH, |
| 107 | GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH, |
| 108 | GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH, |
| 109 | GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH, |
| 110 | GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH, |
| 111 | GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH, |
| 112 | GPIO121_KP_MKOUT_0, |
| 113 | GPIO122_KP_MKOUT_1, |
| 114 | GPIO123_KP_MKOUT_2, |
| 115 | GPIO124_KP_MKOUT_3, |
| 116 | GPIO125_KP_MKOUT_4, |
| 117 | GPIO4_2_KP_MKOUT_5, |
| 118 | |
| 119 | /* MMC1 */ |
| 120 | GPIO3_MMC1_DAT0, |
| 121 | GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, |
| 122 | GPIO5_MMC1_DAT2, |
| 123 | GPIO6_MMC1_DAT3, |
| 124 | GPIO7_MMC1_CLK, |
| 125 | GPIO8_MMC1_CMD, /* CMD0 for slot 0 */ |
| 126 | |
| 127 | /* MMC2 */ |
| 128 | GPIO9_MMC2_DAT0, |
| 129 | GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, |
| 130 | GPIO11_MMC2_DAT2, |
| 131 | GPIO12_MMC2_DAT3, |
| 132 | GPIO13_MMC2_CLK, |
| 133 | GPIO14_MMC2_CMD, |
| 134 | |
| 135 | /* FFUART */ |
| 136 | GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL, |
| 137 | GPIO31_UART1_TXD, |
| 138 | GPIO32_UART1_CTS, |
| 139 | GPIO37_UART1_RTS, |
| 140 | GPIO33_UART1_DCD, |
| 141 | GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL, |
| 142 | GPIO35_UART1_RI, |
| 143 | GPIO36_UART1_DTR, |
| 144 | |
| 145 | /* GPIOs */ |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 146 | GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */ |
| 147 | GPIO85_GPIO, /* MMC WP */ |
| 148 | GPIO99_GPIO, /* Ethernet IRQ */ |
Eric Miao | 6f584cf | 2008-11-28 16:00:24 +0800 | [diff] [blame] | 149 | |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 150 | /* RTC GPIOs */ |
| 151 | GPIO95_GPIO, /* RTC CS */ |
| 152 | GPIO96_GPIO, /* RTC WR */ |
| 153 | GPIO97_GPIO, /* RTC RD */ |
| 154 | GPIO98_GPIO, /* RTC IO */ |
| 155 | |
Eric Miao | 6f584cf | 2008-11-28 16:00:24 +0800 | [diff] [blame] | 156 | /* Standard I2C */ |
| 157 | GPIO21_I2C_SCL, |
| 158 | GPIO22_I2C_SDA, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 159 | }; |
| 160 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame^] | 161 | static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = { |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 162 | /* GPIOs */ |
| 163 | GPIO79_GPIO, /* LED */ |
| 164 | GPIO77_GPIO, /* WiFi reset */ |
| 165 | GPIO78_GPIO, /* BT reset */ |
| 166 | }; |
| 167 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame^] | 168 | static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = { |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 169 | /* GPIOs */ |
| 170 | GPIO76_GPIO, /* LED */ |
| 171 | GPIO71_GPIO, /* WiFi reset */ |
| 172 | GPIO70_GPIO, /* BT reset */ |
| 173 | }; |
| 174 | |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame^] | 175 | static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = { |
| 176 | /* USB PORT 2 */ |
| 177 | ULPI_STP, |
| 178 | ULPI_NXT, |
| 179 | ULPI_DIR, |
| 180 | GPIO30_ULPI_DATA_OUT_0, |
| 181 | GPIO31_ULPI_DATA_OUT_1, |
| 182 | GPIO32_ULPI_DATA_OUT_2, |
| 183 | GPIO33_ULPI_DATA_OUT_3, |
| 184 | GPIO34_ULPI_DATA_OUT_4, |
| 185 | GPIO35_ULPI_DATA_OUT_5, |
| 186 | GPIO36_ULPI_DATA_OUT_6, |
| 187 | GPIO37_ULPI_DATA_OUT_7, |
| 188 | GPIO38_ULPI_CLK, |
| 189 | /* external PHY reset pin */ |
| 190 | GPIO127_GPIO, |
| 191 | |
| 192 | /* USB PORT 3 */ |
| 193 | GPIO77_USB_P3_1, |
| 194 | GPIO78_USB_P3_2, |
| 195 | GPIO79_USB_P3_3, |
| 196 | GPIO80_USB_P3_4, |
| 197 | GPIO81_USB_P3_5, |
| 198 | GPIO82_USB_P3_6, |
| 199 | GPIO0_2_USBH_PEN, |
| 200 | }; |
| 201 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 202 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) |
| 203 | static struct resource dm9000_resources[] = { |
| 204 | [0] = { |
| 205 | .start = CM_X300_ETH_PHYS, |
| 206 | .end = CM_X300_ETH_PHYS + 0x3, |
| 207 | .flags = IORESOURCE_MEM, |
| 208 | }, |
| 209 | [1] = { |
| 210 | .start = CM_X300_ETH_PHYS + 0x4, |
| 211 | .end = CM_X300_ETH_PHYS + 0x4 + 500, |
| 212 | .flags = IORESOURCE_MEM, |
| 213 | }, |
| 214 | [2] = { |
| 215 | .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)), |
| 216 | .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)), |
| 217 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
| 218 | } |
| 219 | }; |
| 220 | |
| 221 | static struct dm9000_plat_data cm_x300_dm9000_platdata = { |
Mike Rapoport | bff22c9 | 2009-02-23 18:01:12 +0200 | [diff] [blame] | 222 | .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | static struct platform_device dm9000_device = { |
| 226 | .name = "dm9000", |
| 227 | .id = 0, |
| 228 | .num_resources = ARRAY_SIZE(dm9000_resources), |
| 229 | .resource = dm9000_resources, |
| 230 | .dev = { |
| 231 | .platform_data = &cm_x300_dm9000_platdata, |
| 232 | } |
| 233 | |
| 234 | }; |
| 235 | |
| 236 | static void __init cm_x300_init_dm9000(void) |
| 237 | { |
| 238 | platform_device_register(&dm9000_device); |
| 239 | } |
| 240 | #else |
| 241 | static inline void cm_x300_init_dm9000(void) {} |
| 242 | #endif |
| 243 | |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 244 | /* LCD */ |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 245 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 246 | static struct pxafb_mode_info cm_x300_lcd_modes[] = { |
| 247 | [0] = { |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 248 | .pixclock = 38250, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 249 | .bpp = 16, |
| 250 | .xres = 480, |
| 251 | .yres = 640, |
| 252 | .hsync_len = 8, |
| 253 | .vsync_len = 2, |
| 254 | .left_margin = 8, |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 255 | .upper_margin = 2, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 256 | .right_margin = 24, |
| 257 | .lower_margin = 4, |
| 258 | .cmap_greyscale = 0, |
| 259 | }, |
| 260 | [1] = { |
| 261 | .pixclock = 153800, |
| 262 | .bpp = 16, |
| 263 | .xres = 240, |
| 264 | .yres = 320, |
| 265 | .hsync_len = 8, |
| 266 | .vsync_len = 2, |
| 267 | .left_margin = 8, |
| 268 | .upper_margin = 2, |
| 269 | .right_margin = 88, |
| 270 | .lower_margin = 2, |
| 271 | .cmap_greyscale = 0, |
| 272 | }, |
| 273 | }; |
| 274 | |
| 275 | static struct pxafb_mach_info cm_x300_lcd = { |
| 276 | .modes = cm_x300_lcd_modes, |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 277 | .num_modes = ARRAY_SIZE(cm_x300_lcd_modes), |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 278 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
| 279 | }; |
| 280 | |
| 281 | static void __init cm_x300_init_lcd(void) |
| 282 | { |
| 283 | set_pxa_fb_info(&cm_x300_lcd); |
| 284 | } |
| 285 | #else |
| 286 | static inline void cm_x300_init_lcd(void) {} |
| 287 | #endif |
| 288 | |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 289 | #if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE) |
| 290 | #define GPIO_LCD_BASE (144) |
| 291 | #define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */ |
| 292 | #define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */ |
| 293 | #define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */ |
| 294 | #define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */ |
| 295 | #define LCD_SPI_BUS_NUM (1) |
| 296 | |
| 297 | static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = { |
| 298 | .sck = GPIO_LCD_SCL, |
| 299 | .mosi = GPIO_LCD_DIN, |
| 300 | .miso = GPIO_LCD_DOUT, |
| 301 | .num_chipselect = 1, |
| 302 | }; |
| 303 | |
| 304 | static struct platform_device cm_x300_spi_gpio = { |
| 305 | .name = "spi_gpio", |
| 306 | .id = LCD_SPI_BUS_NUM, |
| 307 | .dev = { |
| 308 | .platform_data = &cm_x300_spi_gpio_pdata, |
| 309 | }, |
| 310 | }; |
| 311 | |
| 312 | static struct tdo24m_platform_data cm_x300_tdo24m_pdata = { |
| 313 | .model = TDO35S, |
| 314 | }; |
| 315 | |
| 316 | static struct spi_board_info cm_x300_spi_devices[] __initdata = { |
| 317 | { |
| 318 | .modalias = "tdo24m", |
| 319 | .max_speed_hz = 1000000, |
| 320 | .bus_num = LCD_SPI_BUS_NUM, |
| 321 | .chip_select = 0, |
| 322 | .controller_data = (void *) GPIO_LCD_CS, |
| 323 | .platform_data = &cm_x300_tdo24m_pdata, |
| 324 | }, |
| 325 | }; |
| 326 | |
| 327 | static void __init cm_x300_init_spi(void) |
| 328 | { |
| 329 | spi_register_board_info(cm_x300_spi_devices, |
| 330 | ARRAY_SIZE(cm_x300_spi_devices)); |
| 331 | platform_device_register(&cm_x300_spi_gpio); |
| 332 | } |
| 333 | #else |
| 334 | static inline void cm_x300_init_spi(void) {} |
| 335 | #endif |
| 336 | |
Igor Grinberg | 74e74de | 2009-10-14 09:20:20 +0200 | [diff] [blame] | 337 | #if defined(CONFIG_SND_PXA2XX_LIB_AC97) |
| 338 | static void __init cm_x300_init_ac97(void) |
| 339 | { |
| 340 | pxa_set_ac97_info(NULL); |
| 341 | } |
| 342 | #else |
| 343 | static inline void cm_x300_init_ac97(void) {} |
| 344 | #endif |
| 345 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 346 | #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) |
| 347 | static struct mtd_partition cm_x300_nand_partitions[] = { |
| 348 | [0] = { |
| 349 | .name = "OBM", |
| 350 | .offset = 0, |
| 351 | .size = SZ_256K, |
| 352 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 353 | }, |
| 354 | [1] = { |
| 355 | .name = "U-Boot", |
| 356 | .offset = MTDPART_OFS_APPEND, |
| 357 | .size = SZ_256K, |
| 358 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 359 | }, |
| 360 | [2] = { |
| 361 | .name = "Environment", |
| 362 | .offset = MTDPART_OFS_APPEND, |
| 363 | .size = SZ_256K, |
| 364 | }, |
| 365 | [3] = { |
| 366 | .name = "reserved", |
| 367 | .offset = MTDPART_OFS_APPEND, |
| 368 | .size = SZ_256K + SZ_1M, |
| 369 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 370 | }, |
| 371 | [4] = { |
| 372 | .name = "kernel", |
| 373 | .offset = MTDPART_OFS_APPEND, |
| 374 | .size = SZ_4M, |
| 375 | }, |
| 376 | [5] = { |
| 377 | .name = "fs", |
| 378 | .offset = MTDPART_OFS_APPEND, |
| 379 | .size = MTDPART_SIZ_FULL, |
| 380 | }, |
| 381 | }; |
| 382 | |
| 383 | static struct pxa3xx_nand_platform_data cm_x300_nand_info = { |
| 384 | .enable_arbiter = 1, |
Mike Rapoport | b3992b6 | 2009-06-04 10:44:51 +0300 | [diff] [blame] | 385 | .keep_config = 1, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 386 | .parts = cm_x300_nand_partitions, |
| 387 | .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions), |
| 388 | }; |
| 389 | |
| 390 | static void __init cm_x300_init_nand(void) |
| 391 | { |
| 392 | pxa3xx_set_nand_info(&cm_x300_nand_info); |
| 393 | } |
| 394 | #else |
| 395 | static inline void cm_x300_init_nand(void) {} |
| 396 | #endif |
| 397 | |
| 398 | #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 399 | static struct pxamci_platform_data cm_x300_mci_platform_data = { |
| 400 | .detect_delay = 20, |
| 401 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 402 | .gpio_card_detect = GPIO82_MMC_IRQ, |
| 403 | .gpio_card_ro = GPIO85_MMC_WP, |
| 404 | .gpio_power = -1, |
| 405 | }; |
| 406 | |
| 407 | /* The second MMC slot of CM-X300 is hardwired to Libertas card and has |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 408 | no detection/ro pins */ |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 409 | static int cm_x300_mci2_init(struct device *dev, |
| 410 | irq_handler_t cm_x300_detect_int, |
| 411 | void *data) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 412 | { |
| 413 | return 0; |
| 414 | } |
| 415 | |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 416 | static void cm_x300_mci2_exit(struct device *dev, void *data) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 417 | { |
| 418 | } |
| 419 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 420 | static struct pxamci_platform_data cm_x300_mci2_platform_data = { |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 421 | .detect_delay = 20, |
| 422 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
Mike Rapoport | 0bff2fc | 2009-10-15 10:11:09 +0200 | [diff] [blame] | 423 | .init = cm_x300_mci2_init, |
| 424 | .exit = cm_x300_mci2_exit, |
| 425 | .gpio_card_detect = -1, |
| 426 | .gpio_card_ro = -1, |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 427 | .gpio_power = -1, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 428 | }; |
| 429 | |
| 430 | static void __init cm_x300_init_mmc(void) |
| 431 | { |
| 432 | pxa_set_mci_info(&cm_x300_mci_platform_data); |
| 433 | pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data); |
| 434 | } |
| 435 | #else |
| 436 | static inline void cm_x300_init_mmc(void) {} |
| 437 | #endif |
| 438 | |
| 439 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 440 | static struct pxaohci_platform_data cm_x300_ohci_platform_data = { |
| 441 | .port_mode = PMM_PERPORT_MODE, |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 442 | .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 443 | }; |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 444 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 445 | static void __init cm_x300_init_ohci(void) |
| 446 | { |
| 447 | pxa_set_ohci_info(&cm_x300_ohci_platform_data); |
| 448 | } |
| 449 | #else |
| 450 | static inline void cm_x300_init_ohci(void) {} |
| 451 | #endif |
| 452 | |
| 453 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 454 | static struct gpio_led cm_x300_leds[] = { |
| 455 | [0] = { |
| 456 | .name = "cm-x300:green", |
| 457 | .default_trigger = "heartbeat", |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 458 | .active_low = 1, |
| 459 | }, |
| 460 | }; |
| 461 | |
| 462 | static struct gpio_led_platform_data cm_x300_gpio_led_pdata = { |
| 463 | .num_leds = ARRAY_SIZE(cm_x300_leds), |
| 464 | .leds = cm_x300_leds, |
| 465 | }; |
| 466 | |
| 467 | static struct platform_device cm_x300_led_device = { |
| 468 | .name = "leds-gpio", |
| 469 | .id = -1, |
| 470 | .dev = { |
| 471 | .platform_data = &cm_x300_gpio_led_pdata, |
| 472 | }, |
| 473 | }; |
| 474 | |
| 475 | static void __init cm_x300_init_leds(void) |
| 476 | { |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 477 | if (system_rev < 130) |
| 478 | cm_x300_leds[0].gpio = 79; |
| 479 | else |
| 480 | cm_x300_leds[0].gpio = 76; |
| 481 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 482 | platform_device_register(&cm_x300_led_device); |
| 483 | } |
| 484 | #else |
| 485 | static inline void cm_x300_init_leds(void) {} |
| 486 | #endif |
| 487 | |
| 488 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 489 | /* PCA9555 */ |
| 490 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = { |
| 491 | .gpio_base = 128, |
| 492 | }; |
| 493 | |
| 494 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = { |
| 495 | .gpio_base = 144, |
| 496 | }; |
| 497 | |
| 498 | static struct i2c_board_info cm_x300_gpio_ext_info[] = { |
| 499 | [0] = { |
| 500 | I2C_BOARD_INFO("pca9555", 0x24), |
| 501 | .platform_data = &cm_x300_gpio_ext_pdata_0, |
| 502 | }, |
| 503 | [1] = { |
| 504 | I2C_BOARD_INFO("pca9555", 0x25), |
| 505 | .platform_data = &cm_x300_gpio_ext_pdata_1, |
| 506 | }, |
| 507 | }; |
| 508 | |
| 509 | static void __init cm_x300_init_i2c(void) |
| 510 | { |
| 511 | pxa_set_i2c_info(NULL); |
| 512 | i2c_register_board_info(0, cm_x300_gpio_ext_info, |
| 513 | ARRAY_SIZE(cm_x300_gpio_ext_info)); |
| 514 | } |
| 515 | #else |
| 516 | static inline void cm_x300_init_i2c(void) {} |
| 517 | #endif |
| 518 | |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 519 | #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE) |
| 520 | struct v3020_platform_data cm_x300_v3020_pdata = { |
| 521 | .use_gpio = 1, |
| 522 | .gpio_cs = GPIO95_RTC_CS, |
| 523 | .gpio_wr = GPIO96_RTC_WR, |
| 524 | .gpio_rd = GPIO97_RTC_RD, |
| 525 | .gpio_io = GPIO98_RTC_IO, |
| 526 | }; |
| 527 | |
| 528 | static struct platform_device cm_x300_rtc_device = { |
| 529 | .name = "v3020", |
| 530 | .id = -1, |
| 531 | .dev = { |
| 532 | .platform_data = &cm_x300_v3020_pdata, |
| 533 | } |
| 534 | }; |
| 535 | |
| 536 | static void __init cm_x300_init_rtc(void) |
| 537 | { |
| 538 | platform_device_register(&cm_x300_rtc_device); |
| 539 | } |
| 540 | #else |
| 541 | static inline void cm_x300_init_rtc(void) {} |
| 542 | #endif |
| 543 | |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 544 | static void __init cm_x300_init_wi2wi(void) |
| 545 | { |
| 546 | int bt_reset, wlan_en; |
| 547 | int err; |
| 548 | |
| 549 | if (system_rev < 130) { |
| 550 | wlan_en = 77; |
| 551 | bt_reset = 78; |
| 552 | } else { |
| 553 | wlan_en = 71; |
| 554 | bt_reset = 70; |
| 555 | } |
| 556 | |
| 557 | /* Libertas and CSR reset */ |
| 558 | err = gpio_request(wlan_en, "wlan en"); |
| 559 | if (err) { |
| 560 | pr_err("CM-X300: failed to request wlan en gpio: %d\n", err); |
| 561 | } else { |
| 562 | gpio_direction_output(wlan_en, 1); |
| 563 | gpio_free(wlan_en); |
| 564 | } |
| 565 | |
| 566 | err = gpio_request(bt_reset, "bt reset"); |
| 567 | if (err) { |
| 568 | pr_err("CM-X300: failed to request bt reset gpio: %d\n", err); |
| 569 | } else { |
| 570 | gpio_direction_output(bt_reset, 1); |
| 571 | udelay(10); |
| 572 | gpio_set_value(bt_reset, 0); |
| 573 | udelay(10); |
| 574 | gpio_set_value(bt_reset, 1); |
| 575 | gpio_free(bt_reset); |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | /* MFP */ |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 580 | static void __init cm_x300_init_mfp(void) |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 581 | { |
| 582 | /* board-processor specific GPIO initialization */ |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame^] | 583 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg)); |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 584 | |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 585 | if (system_rev < 130) |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame^] | 586 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg)); |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 587 | else |
Igor Grinberg | def8252 | 2009-10-14 09:20:22 +0200 | [diff] [blame^] | 588 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg)); |
| 589 | |
| 590 | if (cpu_is_pxa310()) |
| 591 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg)); |
Igor Grinberg | 55052ea | 2009-10-14 09:20:18 +0200 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | static void __init cm_x300_init(void) |
| 595 | { |
| 596 | cm_x300_init_mfp(); |
| 597 | |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 598 | pxa_set_ffuart_info(NULL); |
| 599 | pxa_set_btuart_info(NULL); |
| 600 | pxa_set_stuart_info(NULL); |
| 601 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 602 | cm_x300_init_dm9000(); |
| 603 | cm_x300_init_lcd(); |
| 604 | cm_x300_init_ohci(); |
| 605 | cm_x300_init_mmc(); |
| 606 | cm_x300_init_nand(); |
| 607 | cm_x300_init_leds(); |
| 608 | cm_x300_init_i2c(); |
Igor Grinberg | 83e560e | 2009-10-14 09:20:19 +0200 | [diff] [blame] | 609 | cm_x300_init_spi(); |
Mike Rapoport | 1858ced | 2009-06-04 10:44:52 +0300 | [diff] [blame] | 610 | cm_x300_init_rtc(); |
Igor Grinberg | 74e74de | 2009-10-14 09:20:20 +0200 | [diff] [blame] | 611 | cm_x300_init_ac97(); |
Igor Grinberg | b3d01da | 2009-10-14 09:20:21 +0200 | [diff] [blame] | 612 | cm_x300_init_wi2wi(); |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 613 | } |
| 614 | |
Mike Rapoport | b5a5c47 | 2009-06-04 10:44:54 +0300 | [diff] [blame] | 615 | static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags, |
| 616 | char **cmdline, struct meminfo *mi) |
| 617 | { |
| 618 | mi->nr_banks = 2; |
| 619 | mi->bank[0].start = 0xa0000000; |
| 620 | mi->bank[0].node = 0; |
| 621 | mi->bank[0].size = (64*1024*1024); |
| 622 | mi->bank[1].start = 0xc0000000; |
| 623 | mi->bank[1].node = 0; |
| 624 | mi->bank[1].size = (64*1024*1024); |
| 625 | } |
| 626 | |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 627 | MACHINE_START(CM_X300, "CM-X300 module") |
| 628 | .phys_io = 0x40000000, |
| 629 | .boot_params = 0xa0000100, |
| 630 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 631 | .map_io = pxa_map_io, |
| 632 | .init_irq = pxa3xx_init_irq, |
| 633 | .timer = &pxa_timer, |
| 634 | .init_machine = cm_x300_init, |
Mike Rapoport | b5a5c47 | 2009-06-04 10:44:54 +0300 | [diff] [blame] | 635 | .fixup = cm_x300_fixup, |
Mike Rapoport | cf75d8d | 2008-08-26 14:03:44 +0100 | [diff] [blame] | 636 | MACHINE_END |