vpac270.c 14 KB

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