cm-x300.c 20 KB

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