zylonite.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /*
  2. * linux/arch/arm/mach-pxa/zylonite.c
  3. *
  4. * Support for the PXA3xx Development Platform (aka Zylonite)
  5. *
  6. * Copyright (C) 2006 Marvell International Ltd.
  7. *
  8. * 2007-09-04: eric miao <eric.miao@marvell.com>
  9. * rewrite to align with latest kernel
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/module.h>
  16. #include <linux/kernel.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/hardware.h>
  23. #include <asm/arch/gpio.h>
  24. #include <asm/arch/pxafb.h>
  25. #include <asm/arch/zylonite.h>
  26. #include <asm/arch/mmc.h>
  27. #include <asm/arch/pxa27x_keypad.h>
  28. #include "generic.h"
  29. #define MAX_SLOTS 3
  30. struct platform_mmc_slot zylonite_mmc_slot[MAX_SLOTS];
  31. int gpio_backlight;
  32. int gpio_eth_irq;
  33. int wm9713_irq;
  34. int lcd_id;
  35. int lcd_orientation;
  36. static struct resource smc91x_resources[] = {
  37. [0] = {
  38. .start = ZYLONITE_ETH_PHYS + 0x300,
  39. .end = ZYLONITE_ETH_PHYS + 0xfffff,
  40. .flags = IORESOURCE_MEM,
  41. },
  42. [1] = {
  43. .start = -1, /* for run-time assignment */
  44. .end = -1,
  45. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  46. }
  47. };
  48. static struct platform_device smc91x_device = {
  49. .name = "smc91x",
  50. .id = 0,
  51. .num_resources = ARRAY_SIZE(smc91x_resources),
  52. .resource = smc91x_resources,
  53. };
  54. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  55. static void zylonite_backlight_power(int on)
  56. {
  57. gpio_set_value(gpio_backlight, on);
  58. }
  59. static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
  60. .pixclock = 110000,
  61. .xres = 240,
  62. .yres = 320,
  63. .bpp = 16,
  64. .hsync_len = 4,
  65. .left_margin = 6,
  66. .right_margin = 4,
  67. .vsync_len = 2,
  68. .upper_margin = 2,
  69. .lower_margin = 3,
  70. .sync = FB_SYNC_VERT_HIGH_ACT,
  71. };
  72. static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
  73. .pixclock = 50000,
  74. .xres = 640,
  75. .yres = 480,
  76. .bpp = 16,
  77. .hsync_len = 1,
  78. .left_margin = 0x9f,
  79. .right_margin = 1,
  80. .vsync_len = 44,
  81. .upper_margin = 0,
  82. .lower_margin = 0,
  83. .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
  84. };
  85. static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
  86. .num_modes = 1,
  87. .lccr0 = LCCR0_Act,
  88. .lccr3 = LCCR3_PCP,
  89. .pxafb_backlight_power = zylonite_backlight_power,
  90. };
  91. static struct pxafb_mode_info sharp_ls037_modes[] = {
  92. [0] = {
  93. .pixclock = 158000,
  94. .xres = 240,
  95. .yres = 320,
  96. .bpp = 16,
  97. .hsync_len = 4,
  98. .left_margin = 39,
  99. .right_margin = 39,
  100. .vsync_len = 1,
  101. .upper_margin = 2,
  102. .lower_margin = 3,
  103. .sync = 0,
  104. },
  105. [1] = {
  106. .pixclock = 39700,
  107. .xres = 480,
  108. .yres = 640,
  109. .bpp = 16,
  110. .hsync_len = 8,
  111. .left_margin = 81,
  112. .right_margin = 81,
  113. .vsync_len = 1,
  114. .upper_margin = 2,
  115. .lower_margin = 7,
  116. .sync = 0,
  117. },
  118. };
  119. static struct pxafb_mach_info zylonite_sharp_lcd_info = {
  120. .modes = sharp_ls037_modes,
  121. .num_modes = 2,
  122. .lccr0 = LCCR0_Act,
  123. .lccr3 = LCCR3_PCP | LCCR3_HSP | LCCR3_VSP,
  124. .pxafb_backlight_power = zylonite_backlight_power,
  125. };
  126. static void __init zylonite_init_lcd(void)
  127. {
  128. /* backlight GPIO: output, default on */
  129. gpio_direction_output(gpio_backlight, 1);
  130. if (lcd_id & 0x20) {
  131. set_pxa_fb_info(&zylonite_sharp_lcd_info);
  132. return;
  133. }
  134. /* legacy LCD panels, it would be handy here if LCD panel type can
  135. * be decided at run-time
  136. */
  137. if (1)
  138. zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
  139. else
  140. zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
  141. set_pxa_fb_info(&zylonite_toshiba_lcd_info);
  142. }
  143. #else
  144. static inline void zylonite_init_lcd(void) {}
  145. #endif
  146. #if defined(CONFIG_MMC)
  147. static int zylonite_mci_ro(struct device *dev)
  148. {
  149. struct platform_device *pdev = to_platform_device(dev);
  150. return gpio_get_value(zylonite_mmc_slot[pdev->id].gpio_wp);
  151. }
  152. static int zylonite_mci_init(struct device *dev,
  153. irq_handler_t zylonite_detect_int,
  154. void *data)
  155. {
  156. struct platform_device *pdev = to_platform_device(dev);
  157. int err, cd_irq, gpio_cd, gpio_wp;
  158. cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
  159. gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
  160. gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
  161. /*
  162. * setup GPIO for Zylonite MMC controller
  163. */
  164. err = gpio_request(gpio_cd, "mmc card detect");
  165. if (err)
  166. goto err_request_cd;
  167. gpio_direction_input(gpio_cd);
  168. err = gpio_request(gpio_wp, "mmc write protect");
  169. if (err)
  170. goto err_request_wp;
  171. gpio_direction_input(gpio_wp);
  172. err = request_irq(cd_irq, zylonite_detect_int,
  173. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  174. "MMC card detect", data);
  175. if (err) {
  176. printk(KERN_ERR "%s: MMC/SD/SDIO: "
  177. "can't request card detect IRQ\n", __func__);
  178. goto err_request_irq;
  179. }
  180. return 0;
  181. err_request_irq:
  182. gpio_free(gpio_wp);
  183. err_request_wp:
  184. gpio_free(gpio_cd);
  185. err_request_cd:
  186. return err;
  187. }
  188. static void zylonite_mci_exit(struct device *dev, void *data)
  189. {
  190. struct platform_device *pdev = to_platform_device(dev);
  191. int cd_irq, gpio_cd, gpio_wp;
  192. cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
  193. gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
  194. gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
  195. free_irq(cd_irq, data);
  196. gpio_free(gpio_cd);
  197. gpio_free(gpio_wp);
  198. }
  199. static struct pxamci_platform_data zylonite_mci_platform_data = {
  200. .detect_delay = 20,
  201. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  202. .init = zylonite_mci_init,
  203. .exit = zylonite_mci_exit,
  204. .get_ro = zylonite_mci_ro,
  205. };
  206. static struct pxamci_platform_data zylonite_mci2_platform_data = {
  207. .detect_delay = 20,
  208. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  209. };
  210. static void __init zylonite_init_mmc(void)
  211. {
  212. pxa_set_mci_info(&zylonite_mci_platform_data);
  213. pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
  214. if (cpu_is_pxa310())
  215. pxa3xx_set_mci3_info(&zylonite_mci_platform_data);
  216. }
  217. #else
  218. static inline void zylonite_init_mmc(void) {}
  219. #endif
  220. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULES)
  221. static unsigned int zylonite_matrix_key_map[] = {
  222. /* KEY(row, col, key_code) */
  223. KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D),
  224. KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H),
  225. KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L),
  226. KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P),
  227. KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T),
  228. KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X),
  229. KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z),
  230. KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3),
  231. KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7),
  232. KEY(4, 3, KEY_8), KEY(3, 4, KEY_9),
  233. KEY(4, 5, KEY_SPACE),
  234. KEY(5, 3, KEY_KPASTERISK), /* * */
  235. KEY(5, 4, KEY_KPDOT), /* #" */
  236. KEY(0, 7, KEY_UP),
  237. KEY(1, 7, KEY_DOWN),
  238. KEY(2, 7, KEY_LEFT),
  239. KEY(3, 7, KEY_RIGHT),
  240. KEY(2, 6, KEY_HOME),
  241. KEY(3, 6, KEY_END),
  242. KEY(6, 4, KEY_DELETE),
  243. KEY(6, 6, KEY_BACK),
  244. KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */
  245. KEY(4, 6, KEY_ENTER), /* scroll push */
  246. KEY(5, 7, KEY_ENTER), /* keypad action */
  247. KEY(0, 4, KEY_EMAIL),
  248. KEY(5, 6, KEY_SEND),
  249. KEY(4, 0, KEY_CALENDAR),
  250. KEY(7, 6, KEY_RECORD),
  251. KEY(6, 7, KEY_VOLUMEUP),
  252. KEY(7, 7, KEY_VOLUMEDOWN),
  253. KEY(0, 6, KEY_F22), /* soft1 */
  254. KEY(1, 6, KEY_F23), /* soft2 */
  255. KEY(0, 3, KEY_AUX), /* contact */
  256. };
  257. static struct pxa27x_keypad_platform_data zylonite_keypad_info = {
  258. .matrix_key_rows = 8,
  259. .matrix_key_cols = 8,
  260. .matrix_key_map = zylonite_matrix_key_map,
  261. .matrix_key_map_size = ARRAY_SIZE(zylonite_matrix_key_map),
  262. .enable_rotary0 = 1,
  263. .rotary0_up_key = KEY_UP,
  264. .rotary0_down_key = KEY_DOWN,
  265. .debounce_interval = 30,
  266. };
  267. static void __init zylonite_init_keypad(void)
  268. {
  269. pxa_set_keypad_info(&zylonite_keypad_info);
  270. }
  271. #else
  272. static inline void zylonite_init_keypad(void) {}
  273. #endif
  274. static void __init zylonite_init(void)
  275. {
  276. /* board-processor specific initialization */
  277. zylonite_pxa300_init();
  278. zylonite_pxa320_init();
  279. /*
  280. * Note: We depend that the bootloader set
  281. * the correct value to MSC register for SMC91x.
  282. */
  283. smc91x_resources[1].start = gpio_to_irq(gpio_eth_irq);
  284. smc91x_resources[1].end = gpio_to_irq(gpio_eth_irq);
  285. platform_device_register(&smc91x_device);
  286. zylonite_init_lcd();
  287. zylonite_init_mmc();
  288. zylonite_init_keypad();
  289. }
  290. MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
  291. .phys_io = 0x40000000,
  292. .boot_params = 0xa0000100,
  293. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  294. .map_io = pxa_map_io,
  295. .init_irq = pxa3xx_init_irq,
  296. .timer = &pxa_timer,
  297. .init_machine = zylonite_init,
  298. MACHINE_END