vpac270.c 12 KB

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