cm-x300.c 17 KB

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