cm-x300.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/gpio.h>
  20. #include <linux/dm9000.h>
  21. #include <linux/leds.h>
  22. #include <linux/rtc-v3020.h>
  23. #include <linux/i2c.h>
  24. #include <linux/i2c/pca953x.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/setup.h>
  28. #include <mach/pxa300.h>
  29. #include <mach/pxafb.h>
  30. #include <mach/mmc.h>
  31. #include <mach/ohci.h>
  32. #include <plat/i2c.h>
  33. #include <mach/pxa3xx_nand.h>
  34. #include <asm/mach/map.h>
  35. #include "generic.h"
  36. #define CM_X300_ETH_PHYS 0x08000010
  37. #define GPIO82_MMC2_IRQ (82)
  38. #define GPIO85_MMC2_WP (85)
  39. #define CM_X300_MMC2_IRQ IRQ_GPIO(GPIO82_MMC2_IRQ)
  40. #define GPIO95_RTC_CS (95)
  41. #define GPIO96_RTC_WR (96)
  42. #define GPIO97_RTC_RD (97)
  43. #define GPIO98_RTC_IO (98)
  44. static mfp_cfg_t cm_x300_mfp_cfg[] __initdata = {
  45. /* LCD */
  46. GPIO54_LCD_LDD_0,
  47. GPIO55_LCD_LDD_1,
  48. GPIO56_LCD_LDD_2,
  49. GPIO57_LCD_LDD_3,
  50. GPIO58_LCD_LDD_4,
  51. GPIO59_LCD_LDD_5,
  52. GPIO60_LCD_LDD_6,
  53. GPIO61_LCD_LDD_7,
  54. GPIO62_LCD_LDD_8,
  55. GPIO63_LCD_LDD_9,
  56. GPIO64_LCD_LDD_10,
  57. GPIO65_LCD_LDD_11,
  58. GPIO66_LCD_LDD_12,
  59. GPIO67_LCD_LDD_13,
  60. GPIO68_LCD_LDD_14,
  61. GPIO69_LCD_LDD_15,
  62. GPIO72_LCD_FCLK,
  63. GPIO73_LCD_LCLK,
  64. GPIO74_LCD_PCLK,
  65. GPIO75_LCD_BIAS,
  66. /* BTUART */
  67. GPIO111_UART2_RTS,
  68. GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
  69. GPIO113_UART2_TXD,
  70. GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
  71. /* STUART */
  72. GPIO109_UART3_TXD,
  73. GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
  74. /* AC97 */
  75. GPIO23_AC97_nACRESET,
  76. GPIO24_AC97_SYSCLK,
  77. GPIO29_AC97_BITCLK,
  78. GPIO25_AC97_SDATA_IN_0,
  79. GPIO27_AC97_SDATA_OUT,
  80. GPIO28_AC97_SYNC,
  81. /* Keypad */
  82. GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  83. GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  84. GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  85. GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  86. GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  87. GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  88. GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  89. GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
  90. GPIO121_KP_MKOUT_0,
  91. GPIO122_KP_MKOUT_1,
  92. GPIO123_KP_MKOUT_2,
  93. GPIO124_KP_MKOUT_3,
  94. GPIO125_KP_MKOUT_4,
  95. GPIO4_2_KP_MKOUT_5,
  96. /* MMC1 */
  97. GPIO3_MMC1_DAT0,
  98. GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  99. GPIO5_MMC1_DAT2,
  100. GPIO6_MMC1_DAT3,
  101. GPIO7_MMC1_CLK,
  102. GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
  103. /* MMC2 */
  104. GPIO9_MMC2_DAT0,
  105. GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  106. GPIO11_MMC2_DAT2,
  107. GPIO12_MMC2_DAT3,
  108. GPIO13_MMC2_CLK,
  109. GPIO14_MMC2_CMD,
  110. /* FFUART */
  111. GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
  112. GPIO31_UART1_TXD,
  113. GPIO32_UART1_CTS,
  114. GPIO37_UART1_RTS,
  115. GPIO33_UART1_DCD,
  116. GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
  117. GPIO35_UART1_RI,
  118. GPIO36_UART1_DTR,
  119. /* GPIOs */
  120. GPIO79_GPIO, /* LED */
  121. GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
  122. GPIO85_GPIO, /* MMC WP */
  123. GPIO99_GPIO, /* Ethernet IRQ */
  124. /* RTC GPIOs */
  125. GPIO95_GPIO, /* RTC CS */
  126. GPIO96_GPIO, /* RTC WR */
  127. GPIO97_GPIO, /* RTC RD */
  128. GPIO98_GPIO, /* RTC IO */
  129. /* Standard I2C */
  130. GPIO21_I2C_SCL,
  131. GPIO22_I2C_SDA,
  132. };
  133. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  134. static struct resource dm9000_resources[] = {
  135. [0] = {
  136. .start = CM_X300_ETH_PHYS,
  137. .end = CM_X300_ETH_PHYS + 0x3,
  138. .flags = IORESOURCE_MEM,
  139. },
  140. [1] = {
  141. .start = CM_X300_ETH_PHYS + 0x4,
  142. .end = CM_X300_ETH_PHYS + 0x4 + 500,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. [2] = {
  146. .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
  147. .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
  148. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  149. }
  150. };
  151. static struct dm9000_plat_data cm_x300_dm9000_platdata = {
  152. .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
  153. };
  154. static struct platform_device dm9000_device = {
  155. .name = "dm9000",
  156. .id = 0,
  157. .num_resources = ARRAY_SIZE(dm9000_resources),
  158. .resource = dm9000_resources,
  159. .dev = {
  160. .platform_data = &cm_x300_dm9000_platdata,
  161. }
  162. };
  163. static void __init cm_x300_init_dm9000(void)
  164. {
  165. platform_device_register(&dm9000_device);
  166. }
  167. #else
  168. static inline void cm_x300_init_dm9000(void) {}
  169. #endif
  170. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  171. static struct pxafb_mode_info cm_x300_lcd_modes[] = {
  172. [0] = {
  173. .pixclock = 38000,
  174. .bpp = 16,
  175. .xres = 480,
  176. .yres = 640,
  177. .hsync_len = 8,
  178. .vsync_len = 2,
  179. .left_margin = 8,
  180. .upper_margin = 0,
  181. .right_margin = 24,
  182. .lower_margin = 4,
  183. .cmap_greyscale = 0,
  184. },
  185. [1] = {
  186. .pixclock = 153800,
  187. .bpp = 16,
  188. .xres = 240,
  189. .yres = 320,
  190. .hsync_len = 8,
  191. .vsync_len = 2,
  192. .left_margin = 8,
  193. .upper_margin = 2,
  194. .right_margin = 88,
  195. .lower_margin = 2,
  196. .cmap_greyscale = 0,
  197. },
  198. };
  199. static struct pxafb_mach_info cm_x300_lcd = {
  200. .modes = cm_x300_lcd_modes,
  201. .num_modes = 2,
  202. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  203. };
  204. static void __init cm_x300_init_lcd(void)
  205. {
  206. set_pxa_fb_info(&cm_x300_lcd);
  207. }
  208. #else
  209. static inline void cm_x300_init_lcd(void) {}
  210. #endif
  211. #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
  212. static struct mtd_partition cm_x300_nand_partitions[] = {
  213. [0] = {
  214. .name = "OBM",
  215. .offset = 0,
  216. .size = SZ_256K,
  217. .mask_flags = MTD_WRITEABLE, /* force read-only */
  218. },
  219. [1] = {
  220. .name = "U-Boot",
  221. .offset = MTDPART_OFS_APPEND,
  222. .size = SZ_256K,
  223. .mask_flags = MTD_WRITEABLE, /* force read-only */
  224. },
  225. [2] = {
  226. .name = "Environment",
  227. .offset = MTDPART_OFS_APPEND,
  228. .size = SZ_256K,
  229. },
  230. [3] = {
  231. .name = "reserved",
  232. .offset = MTDPART_OFS_APPEND,
  233. .size = SZ_256K + SZ_1M,
  234. .mask_flags = MTD_WRITEABLE, /* force read-only */
  235. },
  236. [4] = {
  237. .name = "kernel",
  238. .offset = MTDPART_OFS_APPEND,
  239. .size = SZ_4M,
  240. },
  241. [5] = {
  242. .name = "fs",
  243. .offset = MTDPART_OFS_APPEND,
  244. .size = MTDPART_SIZ_FULL,
  245. },
  246. };
  247. static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
  248. .enable_arbiter = 1,
  249. .keep_config = 1,
  250. .parts = cm_x300_nand_partitions,
  251. .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
  252. };
  253. static void __init cm_x300_init_nand(void)
  254. {
  255. pxa3xx_set_nand_info(&cm_x300_nand_info);
  256. }
  257. #else
  258. static inline void cm_x300_init_nand(void) {}
  259. #endif
  260. #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
  261. /* The first MMC slot of CM-X300 is hardwired to Libertas card and has
  262. no detection/ro pins */
  263. static int cm_x300_mci_init(struct device *dev,
  264. irq_handler_t cm_x300_detect_int,
  265. void *data)
  266. {
  267. return 0;
  268. }
  269. static void cm_x300_mci_exit(struct device *dev, void *data)
  270. {
  271. }
  272. static struct pxamci_platform_data cm_x300_mci_platform_data = {
  273. .detect_delay = 20,
  274. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  275. .init = cm_x300_mci_init,
  276. .exit = cm_x300_mci_exit,
  277. };
  278. static int cm_x300_mci2_ro(struct device *dev)
  279. {
  280. return gpio_get_value(GPIO85_MMC2_WP);
  281. }
  282. static int cm_x300_mci2_init(struct device *dev,
  283. irq_handler_t cm_x300_detect_int,
  284. void *data)
  285. {
  286. int err;
  287. /*
  288. * setup GPIO for CM-X300 MMC controller
  289. */
  290. err = gpio_request(GPIO82_MMC2_IRQ, "mmc card detect");
  291. if (err)
  292. goto err_request_cd;
  293. gpio_direction_input(GPIO82_MMC2_IRQ);
  294. err = gpio_request(GPIO85_MMC2_WP, "mmc write protect");
  295. if (err)
  296. goto err_request_wp;
  297. gpio_direction_input(GPIO85_MMC2_WP);
  298. err = request_irq(CM_X300_MMC2_IRQ, cm_x300_detect_int,
  299. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  300. "MMC card detect", data);
  301. if (err) {
  302. printk(KERN_ERR "%s: MMC/SD/SDIO: "
  303. "can't request card detect IRQ\n", __func__);
  304. goto err_request_irq;
  305. }
  306. return 0;
  307. err_request_irq:
  308. gpio_free(GPIO85_MMC2_WP);
  309. err_request_wp:
  310. gpio_free(GPIO82_MMC2_IRQ);
  311. err_request_cd:
  312. return err;
  313. }
  314. static void cm_x300_mci2_exit(struct device *dev, void *data)
  315. {
  316. free_irq(CM_X300_MMC2_IRQ, data);
  317. gpio_free(GPIO82_MMC2_IRQ);
  318. gpio_free(GPIO85_MMC2_WP);
  319. }
  320. static struct pxamci_platform_data cm_x300_mci2_platform_data = {
  321. .detect_delay = 20,
  322. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  323. .init = cm_x300_mci2_init,
  324. .exit = cm_x300_mci2_exit,
  325. .get_ro = cm_x300_mci2_ro,
  326. };
  327. static void __init cm_x300_init_mmc(void)
  328. {
  329. pxa_set_mci_info(&cm_x300_mci_platform_data);
  330. pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
  331. }
  332. #else
  333. static inline void cm_x300_init_mmc(void) {}
  334. #endif
  335. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  336. static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
  337. .port_mode = PMM_PERPORT_MODE,
  338. .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
  339. };
  340. static void __init cm_x300_init_ohci(void)
  341. {
  342. pxa_set_ohci_info(&cm_x300_ohci_platform_data);
  343. }
  344. #else
  345. static inline void cm_x300_init_ohci(void) {}
  346. #endif
  347. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  348. static struct gpio_led cm_x300_leds[] = {
  349. [0] = {
  350. .name = "cm-x300:green",
  351. .default_trigger = "heartbeat",
  352. .gpio = 79,
  353. .active_low = 1,
  354. },
  355. };
  356. static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
  357. .num_leds = ARRAY_SIZE(cm_x300_leds),
  358. .leds = cm_x300_leds,
  359. };
  360. static struct platform_device cm_x300_led_device = {
  361. .name = "leds-gpio",
  362. .id = -1,
  363. .dev = {
  364. .platform_data = &cm_x300_gpio_led_pdata,
  365. },
  366. };
  367. static void __init cm_x300_init_leds(void)
  368. {
  369. platform_device_register(&cm_x300_led_device);
  370. }
  371. #else
  372. static inline void cm_x300_init_leds(void) {}
  373. #endif
  374. #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  375. /* PCA9555 */
  376. static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
  377. .gpio_base = 128,
  378. };
  379. static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
  380. .gpio_base = 144,
  381. };
  382. static struct i2c_board_info cm_x300_gpio_ext_info[] = {
  383. [0] = {
  384. I2C_BOARD_INFO("pca9555", 0x24),
  385. .platform_data = &cm_x300_gpio_ext_pdata_0,
  386. },
  387. [1] = {
  388. I2C_BOARD_INFO("pca9555", 0x25),
  389. .platform_data = &cm_x300_gpio_ext_pdata_1,
  390. },
  391. };
  392. static void __init cm_x300_init_i2c(void)
  393. {
  394. pxa_set_i2c_info(NULL);
  395. i2c_register_board_info(0, cm_x300_gpio_ext_info,
  396. ARRAY_SIZE(cm_x300_gpio_ext_info));
  397. }
  398. #else
  399. static inline void cm_x300_init_i2c(void) {}
  400. #endif
  401. #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
  402. struct v3020_platform_data cm_x300_v3020_pdata = {
  403. .use_gpio = 1,
  404. .gpio_cs = GPIO95_RTC_CS,
  405. .gpio_wr = GPIO96_RTC_WR,
  406. .gpio_rd = GPIO97_RTC_RD,
  407. .gpio_io = GPIO98_RTC_IO,
  408. };
  409. static struct platform_device cm_x300_rtc_device = {
  410. .name = "v3020",
  411. .id = -1,
  412. .dev = {
  413. .platform_data = &cm_x300_v3020_pdata,
  414. }
  415. };
  416. static void __init cm_x300_init_rtc(void)
  417. {
  418. platform_device_register(&cm_x300_rtc_device);
  419. }
  420. #else
  421. static inline void cm_x300_init_rtc(void) {}
  422. #endif
  423. static void __init cm_x300_init(void)
  424. {
  425. /* board-processor specific GPIO initialization */
  426. pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_mfp_cfg));
  427. cm_x300_init_dm9000();
  428. cm_x300_init_lcd();
  429. cm_x300_init_ohci();
  430. cm_x300_init_mmc();
  431. cm_x300_init_nand();
  432. cm_x300_init_leds();
  433. cm_x300_init_i2c();
  434. cm_x300_init_rtc();
  435. }
  436. static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
  437. char **cmdline, struct meminfo *mi)
  438. {
  439. mi->nr_banks = 2;
  440. mi->bank[0].start = 0xa0000000;
  441. mi->bank[0].node = 0;
  442. mi->bank[0].size = (64*1024*1024);
  443. mi->bank[1].start = 0xc0000000;
  444. mi->bank[1].node = 0;
  445. mi->bank[1].size = (64*1024*1024);
  446. }
  447. MACHINE_START(CM_X300, "CM-X300 module")
  448. .phys_io = 0x40000000,
  449. .boot_params = 0xa0000100,
  450. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  451. .map_io = pxa_map_io,
  452. .init_irq = pxa3xx_init_irq,
  453. .timer = &pxa_timer,
  454. .init_machine = cm_x300_init,
  455. .fixup = cm_x300_fixup,
  456. MACHINE_END