zylonite.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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/audio.h>
  25. #include <asm/arch/gpio.h>
  26. #include <asm/arch/pxafb.h>
  27. #include <asm/arch/zylonite.h>
  28. #include <asm/arch/mmc.h>
  29. #include <asm/arch/pxa27x_keypad.h>
  30. #include <asm/arch/pxa3xx_nand.h>
  31. #include "devices.h"
  32. #include "generic.h"
  33. #define MAX_SLOTS 3
  34. struct platform_mmc_slot zylonite_mmc_slot[MAX_SLOTS];
  35. int gpio_eth_irq;
  36. int gpio_debug_led1;
  37. int gpio_debug_led2;
  38. int wm9713_irq;
  39. int lcd_id;
  40. int lcd_orientation;
  41. static struct resource smc91x_resources[] = {
  42. [0] = {
  43. .start = ZYLONITE_ETH_PHYS + 0x300,
  44. .end = ZYLONITE_ETH_PHYS + 0xfffff,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. [1] = {
  48. .start = -1, /* for run-time assignment */
  49. .end = -1,
  50. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  51. }
  52. };
  53. static struct platform_device smc91x_device = {
  54. .name = "smc91x",
  55. .id = 0,
  56. .num_resources = ARRAY_SIZE(smc91x_resources),
  57. .resource = smc91x_resources,
  58. };
  59. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  60. static struct gpio_led zylonite_debug_leds[] = {
  61. [0] = {
  62. .name = "zylonite:yellow:1",
  63. .default_trigger = "heartbeat",
  64. },
  65. [1] = {
  66. .name = "zylonite:yellow:2",
  67. .default_trigger = "default-on",
  68. },
  69. };
  70. static struct gpio_led_platform_data zylonite_debug_leds_info = {
  71. .leds = zylonite_debug_leds,
  72. .num_leds = ARRAY_SIZE(zylonite_debug_leds),
  73. };
  74. static struct platform_device zylonite_device_leds = {
  75. .name = "leds-gpio",
  76. .id = -1,
  77. .dev = {
  78. .platform_data = &zylonite_debug_leds_info,
  79. }
  80. };
  81. static void __init zylonite_init_leds(void)
  82. {
  83. zylonite_debug_leds[0].gpio = gpio_debug_led1;
  84. zylonite_debug_leds[1].gpio = gpio_debug_led2;
  85. platform_device_register(&zylonite_device_leds);
  86. }
  87. #else
  88. static inline void zylonite_init_leds(void) {}
  89. #endif
  90. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  91. static struct platform_pwm_backlight_data zylonite_backlight_data = {
  92. .pwm_id = 3,
  93. .max_brightness = 100,
  94. .dft_brightness = 100,
  95. .pwm_period_ns = 10000,
  96. };
  97. static struct platform_device zylonite_backlight_device = {
  98. .name = "pwm-backlight",
  99. .dev = {
  100. .parent = &pxa27x_device_pwm1.dev,
  101. .platform_data = &zylonite_backlight_data,
  102. },
  103. };
  104. static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
  105. .pixclock = 110000,
  106. .xres = 240,
  107. .yres = 320,
  108. .bpp = 16,
  109. .hsync_len = 4,
  110. .left_margin = 6,
  111. .right_margin = 4,
  112. .vsync_len = 2,
  113. .upper_margin = 2,
  114. .lower_margin = 3,
  115. .sync = FB_SYNC_VERT_HIGH_ACT,
  116. };
  117. static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
  118. .pixclock = 50000,
  119. .xres = 640,
  120. .yres = 480,
  121. .bpp = 16,
  122. .hsync_len = 1,
  123. .left_margin = 0x9f,
  124. .right_margin = 1,
  125. .vsync_len = 44,
  126. .upper_margin = 0,
  127. .lower_margin = 0,
  128. .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
  129. };
  130. static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
  131. .num_modes = 1,
  132. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  133. };
  134. static struct pxafb_mode_info sharp_ls037_modes[] = {
  135. [0] = {
  136. .pixclock = 158000,
  137. .xres = 240,
  138. .yres = 320,
  139. .bpp = 16,
  140. .hsync_len = 4,
  141. .left_margin = 39,
  142. .right_margin = 39,
  143. .vsync_len = 1,
  144. .upper_margin = 2,
  145. .lower_margin = 3,
  146. .sync = 0,
  147. },
  148. [1] = {
  149. .pixclock = 39700,
  150. .xres = 480,
  151. .yres = 640,
  152. .bpp = 16,
  153. .hsync_len = 8,
  154. .left_margin = 81,
  155. .right_margin = 81,
  156. .vsync_len = 1,
  157. .upper_margin = 2,
  158. .lower_margin = 7,
  159. .sync = 0,
  160. },
  161. };
  162. static struct pxafb_mach_info zylonite_sharp_lcd_info = {
  163. .modes = sharp_ls037_modes,
  164. .num_modes = 2,
  165. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  166. };
  167. static void __init zylonite_init_lcd(void)
  168. {
  169. platform_device_register(&zylonite_backlight_device);
  170. if (lcd_id & 0x20) {
  171. set_pxa_fb_info(&zylonite_sharp_lcd_info);
  172. return;
  173. }
  174. /* legacy LCD panels, it would be handy here if LCD panel type can
  175. * be decided at run-time
  176. */
  177. if (1)
  178. zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
  179. else
  180. zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
  181. set_pxa_fb_info(&zylonite_toshiba_lcd_info);
  182. }
  183. #else
  184. static inline void zylonite_init_lcd(void) {}
  185. #endif
  186. #if defined(CONFIG_MMC)
  187. static int zylonite_mci_ro(struct device *dev)
  188. {
  189. struct platform_device *pdev = to_platform_device(dev);
  190. return gpio_get_value(zylonite_mmc_slot[pdev->id].gpio_wp);
  191. }
  192. static int zylonite_mci_init(struct device *dev,
  193. irq_handler_t zylonite_detect_int,
  194. void *data)
  195. {
  196. struct platform_device *pdev = to_platform_device(dev);
  197. int err, cd_irq, gpio_cd, gpio_wp;
  198. cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
  199. gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
  200. gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
  201. /*
  202. * setup GPIO for Zylonite MMC controller
  203. */
  204. err = gpio_request(gpio_cd, "mmc card detect");
  205. if (err)
  206. goto err_request_cd;
  207. gpio_direction_input(gpio_cd);
  208. err = gpio_request(gpio_wp, "mmc write protect");
  209. if (err)
  210. goto err_request_wp;
  211. gpio_direction_input(gpio_wp);
  212. err = request_irq(cd_irq, zylonite_detect_int,
  213. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  214. "MMC card detect", data);
  215. if (err) {
  216. printk(KERN_ERR "%s: MMC/SD/SDIO: "
  217. "can't request card detect IRQ\n", __func__);
  218. goto err_request_irq;
  219. }
  220. return 0;
  221. err_request_irq:
  222. gpio_free(gpio_wp);
  223. err_request_wp:
  224. gpio_free(gpio_cd);
  225. err_request_cd:
  226. return err;
  227. }
  228. static void zylonite_mci_exit(struct device *dev, void *data)
  229. {
  230. struct platform_device *pdev = to_platform_device(dev);
  231. int cd_irq, gpio_cd, gpio_wp;
  232. cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
  233. gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
  234. gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
  235. free_irq(cd_irq, data);
  236. gpio_free(gpio_cd);
  237. gpio_free(gpio_wp);
  238. }
  239. static struct pxamci_platform_data zylonite_mci_platform_data = {
  240. .detect_delay = 20,
  241. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  242. .init = zylonite_mci_init,
  243. .exit = zylonite_mci_exit,
  244. .get_ro = zylonite_mci_ro,
  245. };
  246. static struct pxamci_platform_data zylonite_mci2_platform_data = {
  247. .detect_delay = 20,
  248. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  249. };
  250. static void __init zylonite_init_mmc(void)
  251. {
  252. pxa_set_mci_info(&zylonite_mci_platform_data);
  253. pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
  254. if (cpu_is_pxa310())
  255. pxa3xx_set_mci3_info(&zylonite_mci_platform_data);
  256. }
  257. #else
  258. static inline void zylonite_init_mmc(void) {}
  259. #endif
  260. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  261. static unsigned int zylonite_matrix_key_map[] = {
  262. /* KEY(row, col, key_code) */
  263. KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D),
  264. KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H),
  265. KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L),
  266. KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P),
  267. KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T),
  268. KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X),
  269. KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z),
  270. KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3),
  271. KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7),
  272. KEY(4, 3, KEY_8), KEY(3, 4, KEY_9),
  273. KEY(4, 5, KEY_SPACE),
  274. KEY(5, 3, KEY_KPASTERISK), /* * */
  275. KEY(5, 4, KEY_KPDOT), /* #" */
  276. KEY(0, 7, KEY_UP),
  277. KEY(1, 7, KEY_DOWN),
  278. KEY(2, 7, KEY_LEFT),
  279. KEY(3, 7, KEY_RIGHT),
  280. KEY(2, 6, KEY_HOME),
  281. KEY(3, 6, KEY_END),
  282. KEY(6, 4, KEY_DELETE),
  283. KEY(6, 6, KEY_BACK),
  284. KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */
  285. KEY(4, 6, KEY_ENTER), /* scroll push */
  286. KEY(5, 7, KEY_ENTER), /* keypad action */
  287. KEY(0, 4, KEY_EMAIL),
  288. KEY(5, 6, KEY_SEND),
  289. KEY(4, 0, KEY_CALENDAR),
  290. KEY(7, 6, KEY_RECORD),
  291. KEY(6, 7, KEY_VOLUMEUP),
  292. KEY(7, 7, KEY_VOLUMEDOWN),
  293. KEY(0, 6, KEY_F22), /* soft1 */
  294. KEY(1, 6, KEY_F23), /* soft2 */
  295. KEY(0, 3, KEY_AUX), /* contact */
  296. };
  297. static struct pxa27x_keypad_platform_data zylonite_keypad_info = {
  298. .matrix_key_rows = 8,
  299. .matrix_key_cols = 8,
  300. .matrix_key_map = zylonite_matrix_key_map,
  301. .matrix_key_map_size = ARRAY_SIZE(zylonite_matrix_key_map),
  302. .enable_rotary0 = 1,
  303. .rotary0_up_key = KEY_UP,
  304. .rotary0_down_key = KEY_DOWN,
  305. .debounce_interval = 30,
  306. };
  307. static void __init zylonite_init_keypad(void)
  308. {
  309. pxa_set_keypad_info(&zylonite_keypad_info);
  310. }
  311. #else
  312. static inline void zylonite_init_keypad(void) {}
  313. #endif
  314. #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
  315. static struct mtd_partition zylonite_nand_partitions[] = {
  316. [0] = {
  317. .name = "Bootloader",
  318. .offset = 0,
  319. .size = 0x060000,
  320. .mask_flags = MTD_WRITEABLE, /* force read-only */
  321. },
  322. [1] = {
  323. .name = "Kernel",
  324. .offset = 0x060000,
  325. .size = 0x200000,
  326. .mask_flags = MTD_WRITEABLE, /* force read-only */
  327. },
  328. [2] = {
  329. .name = "Filesystem",
  330. .offset = 0x0260000,
  331. .size = 0x3000000, /* 48M - rootfs */
  332. },
  333. [3] = {
  334. .name = "MassStorage",
  335. .offset = 0x3260000,
  336. .size = 0x3d40000,
  337. },
  338. [4] = {
  339. .name = "BBT",
  340. .offset = 0x6FA0000,
  341. .size = 0x80000,
  342. .mask_flags = MTD_WRITEABLE, /* force read-only */
  343. },
  344. /* NOTE: we reserve some blocks at the end of the NAND flash for
  345. * bad block management, and the max number of relocation blocks
  346. * differs on different platforms. Please take care with it when
  347. * defining the partition table.
  348. */
  349. };
  350. static struct pxa3xx_nand_platform_data zylonite_nand_info = {
  351. .enable_arbiter = 1,
  352. .parts = zylonite_nand_partitions,
  353. .nr_parts = ARRAY_SIZE(zylonite_nand_partitions),
  354. };
  355. static void __init zylonite_init_nand(void)
  356. {
  357. pxa3xx_set_nand_info(&zylonite_nand_info);
  358. }
  359. #else
  360. static inline void zylonite_init_nand(void) {}
  361. #endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
  362. static void __init zylonite_init(void)
  363. {
  364. /* board-processor specific initialization */
  365. zylonite_pxa300_init();
  366. zylonite_pxa320_init();
  367. /*
  368. * Note: We depend that the bootloader set
  369. * the correct value to MSC register for SMC91x.
  370. */
  371. smc91x_resources[1].start = gpio_to_irq(gpio_eth_irq);
  372. smc91x_resources[1].end = gpio_to_irq(gpio_eth_irq);
  373. platform_device_register(&smc91x_device);
  374. pxa_set_ac97_info(NULL);
  375. zylonite_init_lcd();
  376. zylonite_init_mmc();
  377. zylonite_init_keypad();
  378. zylonite_init_nand();
  379. zylonite_init_leds();
  380. }
  381. MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
  382. .phys_io = 0x40000000,
  383. .boot_params = 0xa0000100,
  384. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  385. .map_io = pxa_map_io,
  386. .init_irq = pxa3xx_init_irq,
  387. .timer = &pxa_timer,
  388. .init_machine = zylonite_init,
  389. MACHINE_END