vpac270.c 15 KB

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