vpac270.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /*
  2. * Hardware definitions for Voipac PXA270
  3. *
  4. * Copyright (C) 2010
  5. * Marek Vasut <marek.vasut@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #include <linux/platform_device.h>
  13. #include <linux/delay.h>
  14. #include <linux/irq.h>
  15. #include <linux/gpio_keys.h>
  16. #include <linux/input.h>
  17. #include <linux/gpio.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/usb/gpio_vbus.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/mtd/onenand.h>
  24. #include <linux/dm9000.h>
  25. #include <linux/ucb1400.h>
  26. #include <linux/ata_platform.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <mach/pxa27x.h>
  30. #include <mach/audio.h>
  31. #include <mach/vpac270.h>
  32. #include <mach/mmc.h>
  33. #include <mach/pxafb.h>
  34. #include <mach/ohci.h>
  35. #include <mach/pxa27x-udc.h>
  36. #include <mach/udc.h>
  37. #include <plat/i2c.h>
  38. #include "generic.h"
  39. #include "devices.h"
  40. /******************************************************************************
  41. * Pin configuration
  42. ******************************************************************************/
  43. static unsigned long vpac270_pin_config[] __initdata = {
  44. /* MMC */
  45. GPIO32_MMC_CLK,
  46. GPIO92_MMC_DAT_0,
  47. GPIO109_MMC_DAT_1,
  48. GPIO110_MMC_DAT_2,
  49. GPIO111_MMC_DAT_3,
  50. GPIO112_MMC_CMD,
  51. GPIO53_GPIO, /* SD detect */
  52. GPIO52_GPIO, /* SD r/o switch */
  53. /* GPIO KEYS */
  54. GPIO1_GPIO, /* USER BTN */
  55. /* LEDs */
  56. GPIO15_GPIO, /* orange led */
  57. /* FFUART */
  58. GPIO34_FFUART_RXD,
  59. GPIO39_FFUART_TXD,
  60. GPIO27_FFUART_RTS,
  61. GPIO100_FFUART_CTS,
  62. GPIO33_FFUART_DSR,
  63. GPIO40_FFUART_DTR,
  64. GPIO10_FFUART_DCD,
  65. GPIO38_FFUART_RI,
  66. /* LCD */
  67. GPIO58_LCD_LDD_0,
  68. GPIO59_LCD_LDD_1,
  69. GPIO60_LCD_LDD_2,
  70. GPIO61_LCD_LDD_3,
  71. GPIO62_LCD_LDD_4,
  72. GPIO63_LCD_LDD_5,
  73. GPIO64_LCD_LDD_6,
  74. GPIO65_LCD_LDD_7,
  75. GPIO66_LCD_LDD_8,
  76. GPIO67_LCD_LDD_9,
  77. GPIO68_LCD_LDD_10,
  78. GPIO69_LCD_LDD_11,
  79. GPIO70_LCD_LDD_12,
  80. GPIO71_LCD_LDD_13,
  81. GPIO72_LCD_LDD_14,
  82. GPIO73_LCD_LDD_15,
  83. GPIO86_LCD_LDD_16,
  84. GPIO87_LCD_LDD_17,
  85. GPIO74_LCD_FCLK,
  86. GPIO75_LCD_LCLK,
  87. GPIO76_LCD_PCLK,
  88. GPIO77_LCD_BIAS,
  89. /* PCMCIA */
  90. GPIO48_nPOE,
  91. GPIO49_nPWE,
  92. GPIO50_nPIOR,
  93. GPIO51_nPIOW,
  94. GPIO85_nPCE_1,
  95. GPIO54_nPCE_2,
  96. GPIO55_nPREG,
  97. GPIO57_nIOIS16,
  98. GPIO56_nPWAIT,
  99. GPIO104_PSKTSEL,
  100. GPIO84_GPIO, /* PCMCIA CD */
  101. GPIO35_GPIO, /* PCMCIA RDY */
  102. GPIO107_GPIO, /* PCMCIA PPEN */
  103. GPIO11_GPIO, /* PCMCIA RESET */
  104. GPIO17_GPIO, /* CF CD */
  105. GPIO12_GPIO, /* CF RDY */
  106. GPIO16_GPIO, /* CF RESET */
  107. /* UHC */
  108. GPIO88_USBH1_PWR,
  109. GPIO89_USBH1_PEN,
  110. GPIO119_USBH2_PWR,
  111. GPIO120_USBH2_PEN,
  112. /* UDC */
  113. GPIO41_GPIO,
  114. /* Ethernet */
  115. GPIO114_GPIO, /* IRQ */
  116. /* AC97 */
  117. GPIO28_AC97_BITCLK,
  118. GPIO29_AC97_SDATA_IN_0,
  119. GPIO30_AC97_SDATA_OUT,
  120. GPIO31_AC97_SYNC,
  121. GPIO95_AC97_nRESET,
  122. GPIO98_AC97_SYSCLK,
  123. GPIO113_GPIO, /* TS IRQ */
  124. /* I2C */
  125. GPIO117_I2C_SCL,
  126. GPIO118_I2C_SDA,
  127. /* IDE */
  128. GPIO36_GPIO, /* IDE IRQ */
  129. GPIO80_DREQ_1,
  130. };
  131. /******************************************************************************
  132. * NOR Flash
  133. ******************************************************************************/
  134. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  135. static struct mtd_partition vpac270_nor_partitions[] = {
  136. {
  137. .name = "Flash",
  138. .offset = 0x00000000,
  139. .size = MTDPART_SIZ_FULL,
  140. }
  141. };
  142. static struct physmap_flash_data vpac270_flash_data[] = {
  143. {
  144. .width = 2, /* bankwidth in bytes */
  145. .parts = vpac270_nor_partitions,
  146. .nr_parts = ARRAY_SIZE(vpac270_nor_partitions)
  147. }
  148. };
  149. static struct resource vpac270_flash_resource = {
  150. .start = PXA_CS0_PHYS,
  151. .end = PXA_CS0_PHYS + SZ_64M - 1,
  152. .flags = IORESOURCE_MEM,
  153. };
  154. static struct platform_device vpac270_flash = {
  155. .name = "physmap-flash",
  156. .id = 0,
  157. .resource = &vpac270_flash_resource,
  158. .num_resources = 1,
  159. .dev = {
  160. .platform_data = vpac270_flash_data,
  161. },
  162. };
  163. static void __init vpac270_nor_init(void)
  164. {
  165. platform_device_register(&vpac270_flash);
  166. }
  167. #else
  168. static inline void vpac270_nor_init(void) {}
  169. #endif
  170. /******************************************************************************
  171. * OneNAND Flash
  172. ******************************************************************************/
  173. #if defined(CONFIG_MTD_ONENAND) || defined(CONFIG_MTD_ONENAND_MODULE)
  174. static struct mtd_partition vpac270_onenand_partitions[] = {
  175. {
  176. .name = "Flash",
  177. .offset = 0x00000000,
  178. .size = MTDPART_SIZ_FULL,
  179. }
  180. };
  181. static struct onenand_platform_data vpac270_onenand_info = {
  182. .parts = vpac270_onenand_partitions,
  183. .nr_parts = ARRAY_SIZE(vpac270_onenand_partitions),
  184. };
  185. static struct resource vpac270_onenand_resources[] = {
  186. [0] = {
  187. .start = PXA_CS0_PHYS,
  188. .end = PXA_CS0_PHYS + SZ_1M,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. };
  192. static struct platform_device vpac270_onenand = {
  193. .name = "onenand-flash",
  194. .id = -1,
  195. .resource = vpac270_onenand_resources,
  196. .num_resources = ARRAY_SIZE(vpac270_onenand_resources),
  197. .dev = {
  198. .platform_data = &vpac270_onenand_info,
  199. },
  200. };
  201. static void __init vpac270_onenand_init(void)
  202. {
  203. platform_device_register(&vpac270_onenand);
  204. }
  205. #else
  206. static void __init vpac270_onenand_init(void) {}
  207. #endif
  208. /******************************************************************************
  209. * SD/MMC card controller
  210. ******************************************************************************/
  211. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  212. static struct pxamci_platform_data vpac270_mci_platform_data = {
  213. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  214. .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N,
  215. .gpio_card_ro = GPIO52_VPAC270_SD_READONLY,
  216. .detect_delay_ms = 200,
  217. };
  218. static void __init vpac270_mmc_init(void)
  219. {
  220. pxa_set_mci_info(&vpac270_mci_platform_data);
  221. }
  222. #else
  223. static inline void vpac270_mmc_init(void) {}
  224. #endif
  225. /******************************************************************************
  226. * GPIO keys
  227. ******************************************************************************/
  228. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  229. static struct gpio_keys_button vpac270_pxa_buttons[] = {
  230. {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"},
  231. };
  232. static struct gpio_keys_platform_data vpac270_pxa_keys_data = {
  233. .buttons = vpac270_pxa_buttons,
  234. .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons),
  235. };
  236. static struct platform_device vpac270_pxa_keys = {
  237. .name = "gpio-keys",
  238. .id = -1,
  239. .dev = {
  240. .platform_data = &vpac270_pxa_keys_data,
  241. },
  242. };
  243. static void __init vpac270_keys_init(void)
  244. {
  245. platform_device_register(&vpac270_pxa_keys);
  246. }
  247. #else
  248. static inline void vpac270_keys_init(void) {}
  249. #endif
  250. /******************************************************************************
  251. * LED
  252. ******************************************************************************/
  253. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  254. struct gpio_led vpac270_gpio_leds[] = {
  255. {
  256. .name = "vpac270:orange:user",
  257. .default_trigger = "none",
  258. .gpio = GPIO15_VPAC270_LED_ORANGE,
  259. .active_low = 1,
  260. }
  261. };
  262. static struct gpio_led_platform_data vpac270_gpio_led_info = {
  263. .leds = vpac270_gpio_leds,
  264. .num_leds = ARRAY_SIZE(vpac270_gpio_leds),
  265. };
  266. static struct platform_device vpac270_leds = {
  267. .name = "leds-gpio",
  268. .id = -1,
  269. .dev = {
  270. .platform_data = &vpac270_gpio_led_info,
  271. }
  272. };
  273. static void __init vpac270_leds_init(void)
  274. {
  275. platform_device_register(&vpac270_leds);
  276. }
  277. #else
  278. static inline void vpac270_leds_init(void) {}
  279. #endif
  280. /******************************************************************************
  281. * USB Host
  282. ******************************************************************************/
  283. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  284. static int vpac270_ohci_init(struct device *dev)
  285. {
  286. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  287. return 0;
  288. }
  289. static struct pxaohci_platform_data vpac270_ohci_info = {
  290. .port_mode = PMM_PERPORT_MODE,
  291. .flags = ENABLE_PORT1 | ENABLE_PORT2 |
  292. POWER_CONTROL_LOW | POWER_SENSE_LOW,
  293. .init = vpac270_ohci_init,
  294. };
  295. static void __init vpac270_uhc_init(void)
  296. {
  297. pxa_set_ohci_info(&vpac270_ohci_info);
  298. }
  299. #else
  300. static inline void vpac270_uhc_init(void) {}
  301. #endif
  302. /******************************************************************************
  303. * USB Gadget
  304. ******************************************************************************/
  305. #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
  306. static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = {
  307. .gpio_vbus = GPIO41_VPAC270_UDC_DETECT,
  308. .gpio_pullup = -1,
  309. };
  310. static struct platform_device vpac270_gpio_vbus = {
  311. .name = "gpio-vbus",
  312. .id = -1,
  313. .dev = {
  314. .platform_data = &vpac270_gpio_vbus_info,
  315. },
  316. };
  317. static void vpac270_udc_command(int cmd)
  318. {
  319. if (cmd == PXA2XX_UDC_CMD_CONNECT)
  320. UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
  321. else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  322. UP2OCR = UP2OCR_HXOE;
  323. }
  324. static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = {
  325. .udc_command = vpac270_udc_command,
  326. .gpio_pullup = -1,
  327. };
  328. static void __init vpac270_udc_init(void)
  329. {
  330. pxa_set_udc_info(&vpac270_udc_info);
  331. platform_device_register(&vpac270_gpio_vbus);
  332. }
  333. #else
  334. static inline void vpac270_udc_init(void) {}
  335. #endif
  336. /******************************************************************************
  337. * Ethernet
  338. ******************************************************************************/
  339. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  340. static struct resource vpac270_dm9000_resources[] = {
  341. [0] = {
  342. .start = PXA_CS2_PHYS + 0x300,
  343. .end = PXA_CS2_PHYS + 0x303,
  344. .flags = IORESOURCE_MEM,
  345. },
  346. [1] = {
  347. .start = PXA_CS2_PHYS + 0x304,
  348. .end = PXA_CS2_PHYS + 0x343,
  349. .flags = IORESOURCE_MEM,
  350. },
  351. [2] = {
  352. .start = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ),
  353. .end = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ),
  354. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  355. },
  356. };
  357. static struct dm9000_plat_data vpac270_dm9000_platdata = {
  358. .flags = DM9000_PLATF_32BITONLY,
  359. };
  360. static struct platform_device vpac270_dm9000_device = {
  361. .name = "dm9000",
  362. .id = -1,
  363. .num_resources = ARRAY_SIZE(vpac270_dm9000_resources),
  364. .resource = vpac270_dm9000_resources,
  365. .dev = {
  366. .platform_data = &vpac270_dm9000_platdata,
  367. }
  368. };
  369. static void __init vpac270_eth_init(void)
  370. {
  371. platform_device_register(&vpac270_dm9000_device);
  372. }
  373. #else
  374. static inline void vpac270_eth_init(void) {}
  375. #endif
  376. /******************************************************************************
  377. * Audio and Touchscreen
  378. ******************************************************************************/
  379. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  380. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  381. static pxa2xx_audio_ops_t vpac270_ac97_pdata = {
  382. .reset_gpio = 95,
  383. };
  384. static struct ucb1400_pdata vpac270_ucb1400_pdata = {
  385. .irq = IRQ_GPIO(GPIO113_VPAC270_TS_IRQ),
  386. };
  387. static struct platform_device vpac270_ucb1400_device = {
  388. .name = "ucb1400_core",
  389. .id = -1,
  390. .dev = {
  391. .platform_data = &vpac270_ucb1400_pdata,
  392. },
  393. };
  394. static void __init vpac270_ts_init(void)
  395. {
  396. pxa_set_ac97_info(&vpac270_ac97_pdata);
  397. platform_device_register(&vpac270_ucb1400_device);
  398. }
  399. #else
  400. static inline void vpac270_ts_init(void) {}
  401. #endif
  402. /******************************************************************************
  403. * RTC
  404. ******************************************************************************/
  405. #if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
  406. static struct i2c_board_info __initdata vpac270_i2c_devs[] = {
  407. {
  408. I2C_BOARD_INFO("ds1339", 0x68),
  409. },
  410. };
  411. static void __init vpac270_rtc_init(void)
  412. {
  413. pxa_set_i2c_info(NULL);
  414. i2c_register_board_info(0, ARRAY_AND_SIZE(vpac270_i2c_devs));
  415. }
  416. #else
  417. static inline void vpac270_rtc_init(void) {}
  418. #endif
  419. /******************************************************************************
  420. * Framebuffer
  421. ******************************************************************************/
  422. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  423. static struct pxafb_mode_info vpac270_lcd_modes[] = {
  424. {
  425. .pixclock = 57692,
  426. .xres = 640,
  427. .yres = 480,
  428. .bpp = 32,
  429. .depth = 18,
  430. .left_margin = 144,
  431. .right_margin = 32,
  432. .upper_margin = 13,
  433. .lower_margin = 30,
  434. .hsync_len = 32,
  435. .vsync_len = 2,
  436. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  437. },
  438. };
  439. static struct pxafb_mach_info vpac270_lcd_screen = {
  440. .modes = vpac270_lcd_modes,
  441. .num_modes = ARRAY_SIZE(vpac270_lcd_modes),
  442. .lcd_conn = LCD_COLOR_TFT_18BPP,
  443. };
  444. static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info)
  445. {
  446. gpio_set_value(GPIO81_VPAC270_BKL_ON, on);
  447. }
  448. static void __init vpac270_lcd_init(void)
  449. {
  450. int ret;
  451. ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON");
  452. if (ret) {
  453. pr_err("Requesting BKL-ON GPIO failed!\n");
  454. goto err;
  455. }
  456. ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1);
  457. if (ret) {
  458. pr_err("Setting BKL-ON GPIO direction failed!\n");
  459. goto err2;
  460. }
  461. vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power;
  462. set_pxa_fb_info(&vpac270_lcd_screen);
  463. return;
  464. err2:
  465. gpio_free(GPIO81_VPAC270_BKL_ON);
  466. err:
  467. return;
  468. }
  469. #else
  470. static inline void vpac270_lcd_init(void) {}
  471. #endif
  472. /******************************************************************************
  473. * PATA IDE
  474. ******************************************************************************/
  475. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  476. static struct pata_platform_info vpac270_pata_pdata = {
  477. .ioport_shift = 1,
  478. .irq_flags = IRQF_TRIGGER_RISING,
  479. };
  480. static struct resource vpac270_ide_resources[] = {
  481. [0] = { /* I/O Base address */
  482. .start = PXA_CS3_PHYS + 0x120,
  483. .end = PXA_CS3_PHYS + 0x13f,
  484. .flags = IORESOURCE_MEM
  485. },
  486. [1] = { /* CTL Base address */
  487. .start = PXA_CS3_PHYS + 0x15c,
  488. .end = PXA_CS3_PHYS + 0x15f,
  489. .flags = IORESOURCE_MEM
  490. },
  491. [2] = { /* IDE IRQ pin */
  492. .start = gpio_to_irq(GPIO36_VPAC270_IDE_IRQ),
  493. .end = gpio_to_irq(GPIO36_VPAC270_IDE_IRQ),
  494. .flags = IORESOURCE_IRQ
  495. }
  496. };
  497. static struct platform_device vpac270_ide_device = {
  498. .name = "pata_platform",
  499. .num_resources = ARRAY_SIZE(vpac270_ide_resources),
  500. .resource = vpac270_ide_resources,
  501. .dev = {
  502. .platform_data = &vpac270_pata_pdata,
  503. }
  504. };
  505. static void __init vpac270_ide_init(void)
  506. {
  507. platform_device_register(&vpac270_ide_device);
  508. }
  509. #else
  510. static inline void vpac270_ide_init(void) {}
  511. #endif
  512. /******************************************************************************
  513. * Machine init
  514. ******************************************************************************/
  515. static void __init vpac270_init(void)
  516. {
  517. pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config));
  518. pxa_set_ffuart_info(NULL);
  519. pxa_set_btuart_info(NULL);
  520. pxa_set_stuart_info(NULL);
  521. vpac270_lcd_init();
  522. vpac270_mmc_init();
  523. vpac270_nor_init();
  524. vpac270_onenand_init();
  525. vpac270_leds_init();
  526. vpac270_keys_init();
  527. vpac270_uhc_init();
  528. vpac270_udc_init();
  529. vpac270_eth_init();
  530. vpac270_ts_init();
  531. vpac270_rtc_init();
  532. vpac270_ide_init();
  533. }
  534. MACHINE_START(VPAC270, "Voipac PXA270")
  535. .phys_io = 0x40000000,
  536. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  537. .boot_params = 0xa0000100,
  538. .map_io = pxa_map_io,
  539. .init_irq = pxa27x_init_irq,
  540. .timer = &pxa_timer,
  541. .init_machine = vpac270_init
  542. MACHINE_END