cm-x300.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. /*
  2. * linux/arch/arm/mach-pxa/cm-x300.c
  3. *
  4. * Support for the CompuLab CM-X300 modules
  5. *
  6. * Copyright (C) 2008,2009 CompuLab Ltd.
  7. *
  8. * Mike Rapoport <mike@compulab.co.il>
  9. * Igor Grinberg <grinberg@compulab.co.il>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #define pr_fmt(fmt) "%s: " fmt, __func__
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/init.h>
  20. #include <linux/delay.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/clk.h>
  23. #include <linux/gpio.h>
  24. #include <linux/dm9000.h>
  25. #include <linux/leds.h>
  26. #include <linux/rtc-v3020.h>
  27. #include <linux/pwm_backlight.h>
  28. #include <linux/i2c.h>
  29. #include <linux/i2c/pca953x.h>
  30. #include <linux/i2c/pxa-i2c.h>
  31. #include <linux/mfd/da903x.h>
  32. #include <linux/regulator/machine.h>
  33. #include <linux/power_supply.h>
  34. #include <linux/apm-emulation.h>
  35. #include <linux/spi/spi.h>
  36. #include <linux/spi/spi_gpio.h>
  37. #include <linux/spi/tdo24m.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/setup.h>
  41. #include <mach/pxa300.h>
  42. #include <mach/pxa27x-udc.h>
  43. #include <mach/pxafb.h>
  44. #include <mach/mmc.h>
  45. #include <mach/ohci.h>
  46. #include <plat/pxa3xx_nand.h>
  47. #include <mach/audio.h>
  48. #include <mach/pxa3xx-u2d.h>
  49. #include <asm/mach/map.h>
  50. #include "generic.h"
  51. #include "devices.h"
  52. #define CM_X300_ETH_PHYS 0x08000010
  53. #define GPIO82_MMC_IRQ (82)
  54. #define GPIO85_MMC_WP (85)
  55. #define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ)
  56. #define GPIO95_RTC_CS (95)
  57. #define GPIO96_RTC_WR (96)
  58. #define GPIO97_RTC_RD (97)
  59. #define GPIO98_RTC_IO (98)
  60. #define GPIO_ULPI_PHY_RST (127)
  61. static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
  62. /* LCD */
  63. GPIO54_LCD_LDD_0,
  64. GPIO55_LCD_LDD_1,
  65. GPIO56_LCD_LDD_2,
  66. GPIO57_LCD_LDD_3,
  67. GPIO58_LCD_LDD_4,
  68. GPIO59_LCD_LDD_5,
  69. GPIO60_LCD_LDD_6,
  70. GPIO61_LCD_LDD_7,
  71. GPIO62_LCD_LDD_8,
  72. GPIO63_LCD_LDD_9,
  73. GPIO64_LCD_LDD_10,
  74. GPIO65_LCD_LDD_11,
  75. GPIO66_LCD_LDD_12,
  76. GPIO67_LCD_LDD_13,
  77. GPIO68_LCD_LDD_14,
  78. GPIO69_LCD_LDD_15,
  79. GPIO72_LCD_FCLK,
  80. GPIO73_LCD_LCLK,
  81. GPIO74_LCD_PCLK,
  82. GPIO75_LCD_BIAS,
  83. /* BTUART */
  84. GPIO111_UART2_RTS,
  85. GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
  86. GPIO113_UART2_TXD,
  87. GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
  88. /* STUART */
  89. GPIO109_UART3_TXD,
  90. GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
  91. /* AC97 */
  92. GPIO23_AC97_nACRESET,
  93. GPIO24_AC97_SYSCLK,
  94. GPIO29_AC97_BITCLK,
  95. GPIO25_AC97_SDATA_IN_0,
  96. GPIO27_AC97_SDATA_OUT,
  97. GPIO28_AC97_SYNC,
  98. /* Keypad */
  99. GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  100. GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  101. GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  102. GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  103. GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  104. GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  105. GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  106. GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
  107. GPIO121_KP_MKOUT_0,
  108. GPIO122_KP_MKOUT_1,
  109. GPIO123_KP_MKOUT_2,
  110. GPIO124_KP_MKOUT_3,
  111. GPIO125_KP_MKOUT_4,
  112. GPIO4_2_KP_MKOUT_5,
  113. /* MMC1 */
  114. GPIO3_MMC1_DAT0,
  115. GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  116. GPIO5_MMC1_DAT2,
  117. GPIO6_MMC1_DAT3,
  118. GPIO7_MMC1_CLK,
  119. GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
  120. /* MMC2 */
  121. GPIO9_MMC2_DAT0,
  122. GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  123. GPIO11_MMC2_DAT2,
  124. GPIO12_MMC2_DAT3,
  125. GPIO13_MMC2_CLK,
  126. GPIO14_MMC2_CMD,
  127. /* FFUART */
  128. GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
  129. GPIO31_UART1_TXD,
  130. GPIO32_UART1_CTS,
  131. GPIO37_UART1_RTS,
  132. GPIO33_UART1_DCD,
  133. GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
  134. GPIO35_UART1_RI,
  135. GPIO36_UART1_DTR,
  136. /* GPIOs */
  137. GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
  138. GPIO85_GPIO, /* MMC WP */
  139. GPIO99_GPIO, /* Ethernet IRQ */
  140. /* RTC GPIOs */
  141. GPIO95_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC CS */
  142. GPIO96_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC WR */
  143. GPIO97_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC RD */
  144. GPIO98_GPIO, /* RTC IO */
  145. /* Standard I2C */
  146. GPIO21_I2C_SCL,
  147. GPIO22_I2C_SDA,
  148. /* PWM Backlight */
  149. GPIO19_PWM2_OUT,
  150. };
  151. static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
  152. /* GPIOs */
  153. GPIO79_GPIO, /* LED */
  154. GPIO77_GPIO, /* WiFi reset */
  155. GPIO78_GPIO, /* BT reset */
  156. };
  157. static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
  158. /* GPIOs */
  159. GPIO76_GPIO, /* LED */
  160. GPIO71_GPIO, /* WiFi reset */
  161. GPIO70_GPIO, /* BT reset */
  162. };
  163. static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
  164. /* USB PORT 2 */
  165. ULPI_STP,
  166. ULPI_NXT,
  167. ULPI_DIR,
  168. GPIO30_ULPI_DATA_OUT_0,
  169. GPIO31_ULPI_DATA_OUT_1,
  170. GPIO32_ULPI_DATA_OUT_2,
  171. GPIO33_ULPI_DATA_OUT_3,
  172. GPIO34_ULPI_DATA_OUT_4,
  173. GPIO35_ULPI_DATA_OUT_5,
  174. GPIO36_ULPI_DATA_OUT_6,
  175. GPIO37_ULPI_DATA_OUT_7,
  176. GPIO38_ULPI_CLK,
  177. /* external PHY reset pin */
  178. GPIO127_GPIO,
  179. /* USB PORT 3 */
  180. GPIO77_USB_P3_1,
  181. GPIO78_USB_P3_2,
  182. GPIO79_USB_P3_3,
  183. GPIO80_USB_P3_4,
  184. GPIO81_USB_P3_5,
  185. GPIO82_USB_P3_6,
  186. GPIO0_2_USBH_PEN,
  187. };
  188. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  189. static struct resource dm9000_resources[] = {
  190. [0] = {
  191. .start = CM_X300_ETH_PHYS,
  192. .end = CM_X300_ETH_PHYS + 0x3,
  193. .flags = IORESOURCE_MEM,
  194. },
  195. [1] = {
  196. .start = CM_X300_ETH_PHYS + 0x4,
  197. .end = CM_X300_ETH_PHYS + 0x4 + 500,
  198. .flags = IORESOURCE_MEM,
  199. },
  200. [2] = {
  201. .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
  202. .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
  203. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  204. }
  205. };
  206. static struct dm9000_plat_data cm_x300_dm9000_platdata = {
  207. .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
  208. };
  209. static struct platform_device dm9000_device = {
  210. .name = "dm9000",
  211. .id = 0,
  212. .num_resources = ARRAY_SIZE(dm9000_resources),
  213. .resource = dm9000_resources,
  214. .dev = {
  215. .platform_data = &cm_x300_dm9000_platdata,
  216. }
  217. };
  218. static void __init cm_x300_init_dm9000(void)
  219. {
  220. platform_device_register(&dm9000_device);
  221. }
  222. #else
  223. static inline void cm_x300_init_dm9000(void) {}
  224. #endif
  225. /* LCD */
  226. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  227. static struct pxafb_mode_info cm_x300_lcd_modes[] = {
  228. [0] = {
  229. .pixclock = 38250,
  230. .bpp = 16,
  231. .xres = 480,
  232. .yres = 640,
  233. .hsync_len = 8,
  234. .vsync_len = 2,
  235. .left_margin = 8,
  236. .upper_margin = 2,
  237. .right_margin = 24,
  238. .lower_margin = 4,
  239. .cmap_greyscale = 0,
  240. },
  241. [1] = {
  242. .pixclock = 153800,
  243. .bpp = 16,
  244. .xres = 240,
  245. .yres = 320,
  246. .hsync_len = 8,
  247. .vsync_len = 2,
  248. .left_margin = 8,
  249. .upper_margin = 2,
  250. .right_margin = 88,
  251. .lower_margin = 2,
  252. .cmap_greyscale = 0,
  253. },
  254. };
  255. static struct pxafb_mach_info cm_x300_lcd = {
  256. .modes = cm_x300_lcd_modes,
  257. .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
  258. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  259. };
  260. static void __init cm_x300_init_lcd(void)
  261. {
  262. pxa_set_fb_info(NULL, &cm_x300_lcd);
  263. }
  264. #else
  265. static inline void cm_x300_init_lcd(void) {}
  266. #endif
  267. #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
  268. static struct platform_pwm_backlight_data cm_x300_backlight_data = {
  269. .pwm_id = 2,
  270. .max_brightness = 100,
  271. .dft_brightness = 100,
  272. .pwm_period_ns = 10000,
  273. };
  274. static struct platform_device cm_x300_backlight_device = {
  275. .name = "pwm-backlight",
  276. .dev = {
  277. .parent = &pxa27x_device_pwm0.dev,
  278. .platform_data = &cm_x300_backlight_data,
  279. },
  280. };
  281. static void cm_x300_init_bl(void)
  282. {
  283. platform_device_register(&cm_x300_backlight_device);
  284. }
  285. #else
  286. static inline void cm_x300_init_bl(void) {}
  287. #endif
  288. #if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
  289. #define GPIO_LCD_BASE (144)
  290. #define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
  291. #define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
  292. #define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
  293. #define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
  294. #define LCD_SPI_BUS_NUM (1)
  295. static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
  296. .sck = GPIO_LCD_SCL,
  297. .mosi = GPIO_LCD_DIN,
  298. .miso = GPIO_LCD_DOUT,
  299. .num_chipselect = 1,
  300. };
  301. static struct platform_device cm_x300_spi_gpio = {
  302. .name = "spi_gpio",
  303. .id = LCD_SPI_BUS_NUM,
  304. .dev = {
  305. .platform_data = &cm_x300_spi_gpio_pdata,
  306. },
  307. };
  308. static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
  309. .model = TDO35S,
  310. };
  311. static struct spi_board_info cm_x300_spi_devices[] __initdata = {
  312. {
  313. .modalias = "tdo24m",
  314. .max_speed_hz = 1000000,
  315. .bus_num = LCD_SPI_BUS_NUM,
  316. .chip_select = 0,
  317. .controller_data = (void *) GPIO_LCD_CS,
  318. .platform_data = &cm_x300_tdo24m_pdata,
  319. },
  320. };
  321. static void __init cm_x300_init_spi(void)
  322. {
  323. spi_register_board_info(cm_x300_spi_devices,
  324. ARRAY_SIZE(cm_x300_spi_devices));
  325. platform_device_register(&cm_x300_spi_gpio);
  326. }
  327. #else
  328. static inline void cm_x300_init_spi(void) {}
  329. #endif
  330. #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
  331. static void __init cm_x300_init_ac97(void)
  332. {
  333. pxa_set_ac97_info(NULL);
  334. }
  335. #else
  336. static inline void cm_x300_init_ac97(void) {}
  337. #endif
  338. #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
  339. static struct mtd_partition cm_x300_nand_partitions[] = {
  340. [0] = {
  341. .name = "OBM",
  342. .offset = 0,
  343. .size = SZ_256K,
  344. .mask_flags = MTD_WRITEABLE, /* force read-only */
  345. },
  346. [1] = {
  347. .name = "U-Boot",
  348. .offset = MTDPART_OFS_APPEND,
  349. .size = SZ_256K,
  350. .mask_flags = MTD_WRITEABLE, /* force read-only */
  351. },
  352. [2] = {
  353. .name = "Environment",
  354. .offset = MTDPART_OFS_APPEND,
  355. .size = SZ_256K,
  356. },
  357. [3] = {
  358. .name = "reserved",
  359. .offset = MTDPART_OFS_APPEND,
  360. .size = SZ_256K + SZ_1M,
  361. .mask_flags = MTD_WRITEABLE, /* force read-only */
  362. },
  363. [4] = {
  364. .name = "kernel",
  365. .offset = MTDPART_OFS_APPEND,
  366. .size = SZ_4M,
  367. },
  368. [5] = {
  369. .name = "fs",
  370. .offset = MTDPART_OFS_APPEND,
  371. .size = MTDPART_SIZ_FULL,
  372. },
  373. };
  374. static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
  375. .enable_arbiter = 1,
  376. .keep_config = 1,
  377. .parts = cm_x300_nand_partitions,
  378. .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
  379. };
  380. static void __init cm_x300_init_nand(void)
  381. {
  382. pxa3xx_set_nand_info(&cm_x300_nand_info);
  383. }
  384. #else
  385. static inline void cm_x300_init_nand(void) {}
  386. #endif
  387. #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
  388. static struct pxamci_platform_data cm_x300_mci_platform_data = {
  389. .detect_delay_ms = 200,
  390. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  391. .gpio_card_detect = GPIO82_MMC_IRQ,
  392. .gpio_card_ro = GPIO85_MMC_WP,
  393. .gpio_power = -1,
  394. };
  395. /* The second MMC slot of CM-X300 is hardwired to Libertas card and has
  396. no detection/ro pins */
  397. static int cm_x300_mci2_init(struct device *dev,
  398. irq_handler_t cm_x300_detect_int,
  399. void *data)
  400. {
  401. return 0;
  402. }
  403. static void cm_x300_mci2_exit(struct device *dev, void *data)
  404. {
  405. }
  406. static struct pxamci_platform_data cm_x300_mci2_platform_data = {
  407. .detect_delay_ms = 200,
  408. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  409. .init = cm_x300_mci2_init,
  410. .exit = cm_x300_mci2_exit,
  411. .gpio_card_detect = -1,
  412. .gpio_card_ro = -1,
  413. .gpio_power = -1,
  414. };
  415. static void __init cm_x300_init_mmc(void)
  416. {
  417. pxa_set_mci_info(&cm_x300_mci_platform_data);
  418. pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
  419. }
  420. #else
  421. static inline void cm_x300_init_mmc(void) {}
  422. #endif
  423. #if defined(CONFIG_PXA310_ULPI)
  424. static struct clk *pout_clk;
  425. static int cm_x300_ulpi_phy_reset(void)
  426. {
  427. int err;
  428. /* reset the PHY */
  429. err = gpio_request_one(GPIO_ULPI_PHY_RST, GPIOF_OUT_INIT_LOW,
  430. "ulpi reset");
  431. if (err) {
  432. pr_err("failed to request ULPI reset GPIO: %d\n", err);
  433. return err;
  434. }
  435. msleep(10);
  436. gpio_set_value(GPIO_ULPI_PHY_RST, 1);
  437. msleep(10);
  438. gpio_free(GPIO_ULPI_PHY_RST);
  439. return 0;
  440. }
  441. static inline int cm_x300_u2d_init(struct device *dev)
  442. {
  443. int err = 0;
  444. if (cpu_is_pxa310()) {
  445. /* CLK_POUT is connected to the ULPI PHY */
  446. pout_clk = clk_get(NULL, "CLK_POUT");
  447. if (IS_ERR(pout_clk)) {
  448. err = PTR_ERR(pout_clk);
  449. pr_err("failed to get CLK_POUT: %d\n", err);
  450. return err;
  451. }
  452. clk_enable(pout_clk);
  453. err = cm_x300_ulpi_phy_reset();
  454. if (err) {
  455. clk_disable(pout_clk);
  456. clk_put(pout_clk);
  457. }
  458. }
  459. return err;
  460. }
  461. static void cm_x300_u2d_exit(struct device *dev)
  462. {
  463. if (cpu_is_pxa310()) {
  464. clk_disable(pout_clk);
  465. clk_put(pout_clk);
  466. }
  467. }
  468. static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
  469. .ulpi_mode = ULPI_SER_6PIN,
  470. .init = cm_x300_u2d_init,
  471. .exit = cm_x300_u2d_exit,
  472. };
  473. static void cm_x300_init_u2d(void)
  474. {
  475. pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
  476. }
  477. #else
  478. static inline void cm_x300_init_u2d(void) {}
  479. #endif
  480. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  481. static int cm_x300_ohci_init(struct device *dev)
  482. {
  483. if (cpu_is_pxa300())
  484. UP2OCR = UP2OCR_HXS
  485. | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;
  486. return 0;
  487. }
  488. static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
  489. .port_mode = PMM_PERPORT_MODE,
  490. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
  491. .init = cm_x300_ohci_init,
  492. };
  493. static void __init cm_x300_init_ohci(void)
  494. {
  495. pxa_set_ohci_info(&cm_x300_ohci_platform_data);
  496. }
  497. #else
  498. static inline void cm_x300_init_ohci(void) {}
  499. #endif
  500. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  501. static struct gpio_led cm_x300_leds[] = {
  502. [0] = {
  503. .name = "cm-x300:green",
  504. .default_trigger = "heartbeat",
  505. .active_low = 1,
  506. },
  507. };
  508. static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
  509. .num_leds = ARRAY_SIZE(cm_x300_leds),
  510. .leds = cm_x300_leds,
  511. };
  512. static struct platform_device cm_x300_led_device = {
  513. .name = "leds-gpio",
  514. .id = -1,
  515. .dev = {
  516. .platform_data = &cm_x300_gpio_led_pdata,
  517. },
  518. };
  519. static void __init cm_x300_init_leds(void)
  520. {
  521. if (system_rev < 130)
  522. cm_x300_leds[0].gpio = 79;
  523. else
  524. cm_x300_leds[0].gpio = 76;
  525. platform_device_register(&cm_x300_led_device);
  526. }
  527. #else
  528. static inline void cm_x300_init_leds(void) {}
  529. #endif
  530. #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  531. /* PCA9555 */
  532. static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
  533. .gpio_base = 128,
  534. };
  535. static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
  536. .gpio_base = 144,
  537. };
  538. static struct i2c_board_info cm_x300_gpio_ext_info[] = {
  539. [0] = {
  540. I2C_BOARD_INFO("pca9555", 0x24),
  541. .platform_data = &cm_x300_gpio_ext_pdata_0,
  542. },
  543. [1] = {
  544. I2C_BOARD_INFO("pca9555", 0x25),
  545. .platform_data = &cm_x300_gpio_ext_pdata_1,
  546. },
  547. };
  548. static void __init cm_x300_init_i2c(void)
  549. {
  550. pxa_set_i2c_info(NULL);
  551. i2c_register_board_info(0, cm_x300_gpio_ext_info,
  552. ARRAY_SIZE(cm_x300_gpio_ext_info));
  553. }
  554. #else
  555. static inline void cm_x300_init_i2c(void) {}
  556. #endif
  557. #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
  558. struct v3020_platform_data cm_x300_v3020_pdata = {
  559. .use_gpio = 1,
  560. .gpio_cs = GPIO95_RTC_CS,
  561. .gpio_wr = GPIO96_RTC_WR,
  562. .gpio_rd = GPIO97_RTC_RD,
  563. .gpio_io = GPIO98_RTC_IO,
  564. };
  565. static struct platform_device cm_x300_rtc_device = {
  566. .name = "v3020",
  567. .id = -1,
  568. .dev = {
  569. .platform_data = &cm_x300_v3020_pdata,
  570. }
  571. };
  572. static void __init cm_x300_init_rtc(void)
  573. {
  574. platform_device_register(&cm_x300_rtc_device);
  575. }
  576. #else
  577. static inline void cm_x300_init_rtc(void) {}
  578. #endif
  579. /* Battery */
  580. struct power_supply_info cm_x300_psy_info = {
  581. .name = "battery",
  582. .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
  583. .voltage_max_design = 4200000,
  584. .voltage_min_design = 3000000,
  585. .use_for_apm = 1,
  586. };
  587. static void cm_x300_battery_low(void)
  588. {
  589. #if defined(CONFIG_APM_EMULATION)
  590. apm_queue_event(APM_LOW_BATTERY);
  591. #endif
  592. }
  593. static void cm_x300_battery_critical(void)
  594. {
  595. #if defined(CONFIG_APM_EMULATION)
  596. apm_queue_event(APM_CRITICAL_SUSPEND);
  597. #endif
  598. }
  599. struct da9030_battery_info cm_x300_battery_info = {
  600. .battery_info = &cm_x300_psy_info,
  601. .charge_milliamp = 1000,
  602. .charge_millivolt = 4200,
  603. .vbat_low = 3600,
  604. .vbat_crit = 3400,
  605. .vbat_charge_start = 4100,
  606. .vbat_charge_stop = 4200,
  607. .vbat_charge_restart = 4000,
  608. .vcharge_min = 3200,
  609. .vcharge_max = 5500,
  610. .tbat_low = 197,
  611. .tbat_high = 78,
  612. .tbat_restart = 100,
  613. .batmon_interval = 0,
  614. .battery_low = cm_x300_battery_low,
  615. .battery_critical = cm_x300_battery_critical,
  616. };
  617. static struct regulator_consumer_supply buck2_consumers[] = {
  618. {
  619. .dev = NULL,
  620. .supply = "vcc_core",
  621. },
  622. };
  623. static struct regulator_init_data buck2_data = {
  624. .constraints = {
  625. .min_uV = 1375000,
  626. .max_uV = 1375000,
  627. .state_mem = {
  628. .enabled = 0,
  629. },
  630. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  631. .apply_uV = 1,
  632. },
  633. .num_consumer_supplies = ARRAY_SIZE(buck2_consumers),
  634. .consumer_supplies = buck2_consumers,
  635. };
  636. /* DA9030 */
  637. struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
  638. {
  639. .name = "da903x-battery",
  640. .id = DA9030_ID_BAT,
  641. .platform_data = &cm_x300_battery_info,
  642. },
  643. {
  644. .name = "da903x-regulator",
  645. .id = DA9030_ID_BUCK2,
  646. .platform_data = &buck2_data,
  647. },
  648. };
  649. static struct da903x_platform_data cm_x300_da9030_info = {
  650. .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
  651. .subdevs = cm_x300_da9030_subdevs,
  652. };
  653. static struct i2c_board_info cm_x300_pmic_info = {
  654. I2C_BOARD_INFO("da9030", 0x49),
  655. .irq = IRQ_WAKEUP0,
  656. .platform_data = &cm_x300_da9030_info,
  657. };
  658. static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
  659. .use_pio = 1,
  660. };
  661. static void __init cm_x300_init_da9030(void)
  662. {
  663. pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
  664. i2c_register_board_info(1, &cm_x300_pmic_info, 1);
  665. irq_set_irq_wake(IRQ_WAKEUP0, 1);
  666. }
  667. /* wi2wi gpio setting for system_rev >= 130 */
  668. static struct gpio cm_x300_wi2wi_gpios[] __initdata = {
  669. { 71, GPIOF_OUT_INIT_HIGH, "wlan en" },
  670. { 70, GPIOF_OUT_INIT_HIGH, "bt reset" },
  671. };
  672. static void __init cm_x300_init_wi2wi(void)
  673. {
  674. int bt_reset, wlan_en;
  675. int err;
  676. if (system_rev < 130) {
  677. cm_x300_wi2wi_gpios[0].gpio = 77; /* wlan en */
  678. cm_x300_wi2wi_gpios[1].gpio = 78; /* bt reset */
  679. }
  680. /* Libertas and CSR reset */
  681. err = gpio_request_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
  682. if (err) {
  683. pr_err("failed to request wifi/bt gpios: %d\n", err);
  684. return;
  685. }
  686. udelay(10);
  687. gpio_set_value(bt_reset, 0);
  688. udelay(10);
  689. gpio_set_value(bt_reset, 1);
  690. gpio_free(wlan_en);
  691. gpio_free(bt_reset);
  692. }
  693. /* MFP */
  694. static void __init cm_x300_init_mfp(void)
  695. {
  696. /* board-processor specific GPIO initialization */
  697. pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
  698. if (system_rev < 130)
  699. pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
  700. else
  701. pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
  702. if (cpu_is_pxa310())
  703. pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
  704. }
  705. static void __init cm_x300_init(void)
  706. {
  707. cm_x300_init_mfp();
  708. pxa_set_btuart_info(NULL);
  709. pxa_set_stuart_info(NULL);
  710. if (cpu_is_pxa300())
  711. pxa_set_ffuart_info(NULL);
  712. cm_x300_init_da9030();
  713. cm_x300_init_dm9000();
  714. cm_x300_init_lcd();
  715. cm_x300_init_u2d();
  716. cm_x300_init_ohci();
  717. cm_x300_init_mmc();
  718. cm_x300_init_nand();
  719. cm_x300_init_leds();
  720. cm_x300_init_i2c();
  721. cm_x300_init_spi();
  722. cm_x300_init_rtc();
  723. cm_x300_init_ac97();
  724. cm_x300_init_wi2wi();
  725. cm_x300_init_bl();
  726. }
  727. static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
  728. char **cmdline, struct meminfo *mi)
  729. {
  730. /* Make sure that mi->bank[0].start = PHYS_ADDR */
  731. for (; tags->hdr.size; tags = tag_next(tags))
  732. if (tags->hdr.tag == ATAG_MEM &&
  733. tags->u.mem.start == 0x80000000) {
  734. tags->u.mem.start = 0xa0000000;
  735. break;
  736. }
  737. }
  738. MACHINE_START(CM_X300, "CM-X300 module")
  739. .boot_params = 0xa0000100,
  740. .map_io = pxa3xx_map_io,
  741. .init_irq = pxa3xx_init_irq,
  742. .handle_irq = pxa3xx_handle_irq,
  743. .timer = &pxa_timer,
  744. .init_machine = cm_x300_init,
  745. .fixup = cm_x300_fixup,
  746. MACHINE_END