cm-x300.c 10 KB

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