vpac270.c 12 KB

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