cm-x300.c 20 KB

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