vpac270.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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/mtd/mtd.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <linux/mtd/physmap.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <mach/pxa27x.h>
  25. #include <mach/vpac270.h>
  26. #include <mach/mmc.h>
  27. #include <mach/pxafb.h>
  28. #include "generic.h"
  29. #include "devices.h"
  30. /******************************************************************************
  31. * Pin configuration
  32. ******************************************************************************/
  33. static unsigned long vpac270_pin_config[] __initdata = {
  34. /* MMC */
  35. GPIO32_MMC_CLK,
  36. GPIO92_MMC_DAT_0,
  37. GPIO109_MMC_DAT_1,
  38. GPIO110_MMC_DAT_2,
  39. GPIO111_MMC_DAT_3,
  40. GPIO112_MMC_CMD,
  41. GPIO53_GPIO, /* SD detect */
  42. GPIO52_GPIO, /* SD r/o switch */
  43. /* GPIO KEYS */
  44. GPIO1_GPIO, /* USER BTN */
  45. /* LEDs */
  46. GPIO15_GPIO, /* orange led */
  47. /* FFUART */
  48. GPIO34_FFUART_RXD,
  49. GPIO39_FFUART_TXD,
  50. GPIO27_FFUART_RTS,
  51. GPIO100_FFUART_CTS,
  52. GPIO33_FFUART_DSR,
  53. GPIO40_FFUART_DTR,
  54. GPIO10_FFUART_DCD,
  55. GPIO38_FFUART_RI,
  56. /* LCD */
  57. GPIO58_LCD_LDD_0,
  58. GPIO59_LCD_LDD_1,
  59. GPIO60_LCD_LDD_2,
  60. GPIO61_LCD_LDD_3,
  61. GPIO62_LCD_LDD_4,
  62. GPIO63_LCD_LDD_5,
  63. GPIO64_LCD_LDD_6,
  64. GPIO65_LCD_LDD_7,
  65. GPIO66_LCD_LDD_8,
  66. GPIO67_LCD_LDD_9,
  67. GPIO68_LCD_LDD_10,
  68. GPIO69_LCD_LDD_11,
  69. GPIO70_LCD_LDD_12,
  70. GPIO71_LCD_LDD_13,
  71. GPIO72_LCD_LDD_14,
  72. GPIO73_LCD_LDD_15,
  73. GPIO86_LCD_LDD_16,
  74. GPIO87_LCD_LDD_17,
  75. GPIO74_LCD_FCLK,
  76. GPIO75_LCD_LCLK,
  77. GPIO76_LCD_PCLK,
  78. GPIO77_LCD_BIAS,
  79. };
  80. /******************************************************************************
  81. * NOR Flash
  82. ******************************************************************************/
  83. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  84. static struct mtd_partition vpac270_partitions[] = {
  85. {
  86. .name = "Flash",
  87. .offset = 0x00000000,
  88. .size = MTDPART_SIZ_FULL,
  89. }
  90. };
  91. static struct physmap_flash_data vpac270_flash_data[] = {
  92. {
  93. .width = 2, /* bankwidth in bytes */
  94. .parts = vpac270_partitions,
  95. .nr_parts = ARRAY_SIZE(vpac270_partitions)
  96. }
  97. };
  98. static struct resource vpac270_flash_resource = {
  99. .start = PXA_CS0_PHYS,
  100. .end = PXA_CS0_PHYS + SZ_64M - 1,
  101. .flags = IORESOURCE_MEM,
  102. };
  103. static struct platform_device vpac270_flash = {
  104. .name = "physmap-flash",
  105. .id = 0,
  106. .resource = &vpac270_flash_resource,
  107. .num_resources = 1,
  108. .dev = {
  109. .platform_data = vpac270_flash_data,
  110. },
  111. };
  112. static void __init vpac270_nor_init(void)
  113. {
  114. platform_device_register(&vpac270_flash);
  115. }
  116. #else
  117. static inline void vpac270_nor_init(void) {}
  118. #endif
  119. /******************************************************************************
  120. * SD/MMC card controller
  121. ******************************************************************************/
  122. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  123. static struct pxamci_platform_data vpac270_mci_platform_data = {
  124. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  125. .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N,
  126. .gpio_card_ro = GPIO52_VPAC270_SD_READONLY,
  127. .detect_delay = 20,
  128. };
  129. static void __init vpac270_mmc_init(void)
  130. {
  131. pxa_set_mci_info(&vpac270_mci_platform_data);
  132. }
  133. #else
  134. static inline void vpac270_mmc_init(void) {}
  135. #endif
  136. /******************************************************************************
  137. * GPIO keys
  138. ******************************************************************************/
  139. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  140. static struct gpio_keys_button vpac270_pxa_buttons[] = {
  141. {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"},
  142. };
  143. static struct gpio_keys_platform_data vpac270_pxa_keys_data = {
  144. .buttons = vpac270_pxa_buttons,
  145. .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons),
  146. };
  147. static struct platform_device vpac270_pxa_keys = {
  148. .name = "gpio-keys",
  149. .id = -1,
  150. .dev = {
  151. .platform_data = &vpac270_pxa_keys_data,
  152. },
  153. };
  154. static void __init vpac270_keys_init(void)
  155. {
  156. platform_device_register(&vpac270_pxa_keys);
  157. }
  158. #else
  159. static inline void vpac270_keys_init(void) {}
  160. #endif
  161. /******************************************************************************
  162. * LED
  163. ******************************************************************************/
  164. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  165. struct gpio_led vpac270_gpio_leds[] = {
  166. {
  167. .name = "vpac270:orange:user",
  168. .default_trigger = "none",
  169. .gpio = GPIO15_VPAC270_LED_ORANGE,
  170. .active_low = 1,
  171. }
  172. };
  173. static struct gpio_led_platform_data vpac270_gpio_led_info = {
  174. .leds = vpac270_gpio_leds,
  175. .num_leds = ARRAY_SIZE(vpac270_gpio_leds),
  176. };
  177. static struct platform_device vpac270_leds = {
  178. .name = "leds-gpio",
  179. .id = -1,
  180. .dev = {
  181. .platform_data = &vpac270_gpio_led_info,
  182. }
  183. };
  184. static void __init vpac270_leds_init(void)
  185. {
  186. platform_device_register(&vpac270_leds);
  187. }
  188. #else
  189. static inline void vpac270_leds_init(void) {}
  190. #endif
  191. /******************************************************************************
  192. * Framebuffer
  193. ******************************************************************************/
  194. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  195. static struct pxafb_mode_info vpac270_lcd_modes[] = {
  196. {
  197. .pixclock = 57692,
  198. .xres = 640,
  199. .yres = 480,
  200. .bpp = 32,
  201. .depth = 18,
  202. .left_margin = 144,
  203. .right_margin = 32,
  204. .upper_margin = 13,
  205. .lower_margin = 30,
  206. .hsync_len = 32,
  207. .vsync_len = 2,
  208. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  209. },
  210. };
  211. static struct pxafb_mach_info vpac270_lcd_screen = {
  212. .modes = vpac270_lcd_modes,
  213. .num_modes = ARRAY_SIZE(vpac270_lcd_modes),
  214. .lcd_conn = LCD_COLOR_TFT_18BPP,
  215. };
  216. static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info)
  217. {
  218. gpio_set_value(GPIO81_VPAC270_BKL_ON, on);
  219. }
  220. static void __init vpac270_lcd_init(void)
  221. {
  222. int ret;
  223. ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON");
  224. if (ret) {
  225. pr_err("Requesting BKL-ON GPIO failed!\n");
  226. goto err;
  227. }
  228. ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1);
  229. if (ret) {
  230. pr_err("Setting BKL-ON GPIO direction failed!\n");
  231. goto err2;
  232. }
  233. vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power;
  234. set_pxa_fb_info(&vpac270_lcd_screen);
  235. return;
  236. err2:
  237. gpio_free(GPIO81_VPAC270_BKL_ON);
  238. err:
  239. return;
  240. }
  241. #else
  242. static inline void vpac270_lcd_init(void) {}
  243. #endif
  244. /******************************************************************************
  245. * Machine init
  246. ******************************************************************************/
  247. static void __init vpac270_init(void)
  248. {
  249. pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config));
  250. pxa_set_ffuart_info(NULL);
  251. pxa_set_btuart_info(NULL);
  252. pxa_set_stuart_info(NULL);
  253. vpac270_lcd_init();
  254. vpac270_mmc_init();
  255. vpac270_nor_init();
  256. vpac270_leds_init();
  257. vpac270_keys_init();
  258. }
  259. MACHINE_START(VPAC270, "Voipac PXA270")
  260. .phys_io = 0x40000000,
  261. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  262. .boot_params = 0xa0000100,
  263. .map_io = pxa_map_io,
  264. .init_irq = pxa27x_init_irq,
  265. .timer = &pxa_timer,
  266. .init_machine = vpac270_init
  267. MACHINE_END