zylonite.c 12 KB

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