zylonite.c 8.6 KB

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