zylonite.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 "generic.h"
  28. #define MAX_SLOTS 3
  29. struct platform_mmc_slot zylonite_mmc_slot[MAX_SLOTS];
  30. int gpio_backlight;
  31. int gpio_eth_irq;
  32. int lcd_id;
  33. int lcd_orientation;
  34. static struct resource smc91x_resources[] = {
  35. [0] = {
  36. .start = ZYLONITE_ETH_PHYS + 0x300,
  37. .end = ZYLONITE_ETH_PHYS + 0xfffff,
  38. .flags = IORESOURCE_MEM,
  39. },
  40. [1] = {
  41. .start = -1, /* for run-time assignment */
  42. .end = -1,
  43. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  44. }
  45. };
  46. static struct platform_device smc91x_device = {
  47. .name = "smc91x",
  48. .id = 0,
  49. .num_resources = ARRAY_SIZE(smc91x_resources),
  50. .resource = smc91x_resources,
  51. };
  52. #if defined(CONFIG_FB_PXA) || (CONFIG_FB_PXA_MODULES)
  53. static void zylonite_backlight_power(int on)
  54. {
  55. gpio_set_value(gpio_backlight, on);
  56. }
  57. static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
  58. .pixclock = 110000,
  59. .xres = 240,
  60. .yres = 320,
  61. .bpp = 16,
  62. .hsync_len = 4,
  63. .left_margin = 6,
  64. .right_margin = 4,
  65. .vsync_len = 2,
  66. .upper_margin = 2,
  67. .lower_margin = 3,
  68. .sync = FB_SYNC_VERT_HIGH_ACT,
  69. };
  70. static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
  71. .pixclock = 50000,
  72. .xres = 640,
  73. .yres = 480,
  74. .bpp = 16,
  75. .hsync_len = 1,
  76. .left_margin = 0x9f,
  77. .right_margin = 1,
  78. .vsync_len = 44,
  79. .upper_margin = 0,
  80. .lower_margin = 0,
  81. .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
  82. };
  83. static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
  84. .num_modes = 1,
  85. .lccr0 = LCCR0_Act,
  86. .lccr3 = LCCR3_PCP,
  87. .pxafb_backlight_power = zylonite_backlight_power,
  88. };
  89. static struct pxafb_mode_info sharp_ls037_modes[] = {
  90. [0] = {
  91. .pixclock = 158000,
  92. .xres = 240,
  93. .yres = 320,
  94. .bpp = 16,
  95. .hsync_len = 4,
  96. .left_margin = 39,
  97. .right_margin = 39,
  98. .vsync_len = 1,
  99. .upper_margin = 2,
  100. .lower_margin = 3,
  101. .sync = 0,
  102. },
  103. [1] = {
  104. .pixclock = 39700,
  105. .xres = 480,
  106. .yres = 640,
  107. .bpp = 16,
  108. .hsync_len = 8,
  109. .left_margin = 81,
  110. .right_margin = 81,
  111. .vsync_len = 1,
  112. .upper_margin = 2,
  113. .lower_margin = 7,
  114. .sync = 0,
  115. },
  116. };
  117. static struct pxafb_mach_info zylonite_sharp_lcd_info = {
  118. .modes = sharp_ls037_modes,
  119. .num_modes = 2,
  120. .lccr0 = LCCR0_Act,
  121. .lccr3 = LCCR3_PCP | LCCR3_HSP | LCCR3_VSP,
  122. .pxafb_backlight_power = zylonite_backlight_power,
  123. };
  124. static void __init zylonite_init_lcd(void)
  125. {
  126. /* backlight GPIO: output, default on */
  127. gpio_direction_output(gpio_backlight, 1);
  128. if (lcd_id & 0x20) {
  129. set_pxa_fb_info(&zylonite_sharp_lcd_info);
  130. return;
  131. }
  132. /* legacy LCD panels, it would be handy here if LCD panel type can
  133. * be decided at run-time
  134. */
  135. if (1)
  136. zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
  137. else
  138. zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
  139. set_pxa_fb_info(&zylonite_toshiba_lcd_info);
  140. }
  141. #else
  142. static inline void zylonite_init_lcd(void) {}
  143. #endif
  144. #if defined(CONFIG_MMC)
  145. static int zylonite_mci_ro(struct device *dev)
  146. {
  147. struct platform_device *pdev = to_platform_device(dev);
  148. return gpio_get_value(zylonite_mmc_slot[pdev->id].gpio_wp);
  149. }
  150. static int zylonite_mci_init(struct device *dev,
  151. irq_handler_t zylonite_detect_int,
  152. void *data)
  153. {
  154. struct platform_device *pdev = to_platform_device(dev);
  155. int err, cd_irq, gpio_cd, gpio_wp;
  156. cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
  157. gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
  158. gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
  159. /*
  160. * setup GPIO for Zylonite MMC controller
  161. */
  162. err = gpio_request(gpio_cd, "mmc card detect");
  163. if (err)
  164. goto err_request_cd;
  165. gpio_direction_input(gpio_cd);
  166. err = gpio_request(gpio_wp, "mmc write protect");
  167. if (err)
  168. goto err_request_wp;
  169. gpio_direction_input(gpio_wp);
  170. err = request_irq(cd_irq, zylonite_detect_int,
  171. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  172. "MMC card detect", data);
  173. if (err) {
  174. printk(KERN_ERR "%s: MMC/SD/SDIO: "
  175. "can't request card detect IRQ\n", __func__);
  176. goto err_request_irq;
  177. }
  178. return 0;
  179. err_request_irq:
  180. gpio_free(gpio_wp);
  181. err_request_wp:
  182. gpio_free(gpio_cd);
  183. err_request_cd:
  184. return err;
  185. }
  186. static void zylonite_mci_exit(struct device *dev, void *data)
  187. {
  188. struct platform_device *pdev = to_platform_device(dev);
  189. int cd_irq, gpio_cd, gpio_wp;
  190. cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
  191. gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
  192. gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
  193. free_irq(cd_irq, data);
  194. gpio_free(gpio_cd);
  195. gpio_free(gpio_wp);
  196. }
  197. static struct pxamci_platform_data zylonite_mci_platform_data = {
  198. .detect_delay = 20,
  199. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  200. .init = zylonite_mci_init,
  201. .exit = zylonite_mci_exit,
  202. .get_ro = zylonite_mci_ro,
  203. };
  204. static struct pxamci_platform_data zylonite_mci2_platform_data = {
  205. .detect_delay = 20,
  206. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  207. };
  208. static void __init zylonite_init_mmc(void)
  209. {
  210. pxa_set_mci_info(&zylonite_mci_platform_data);
  211. pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
  212. if (cpu_is_pxa310())
  213. pxa3xx_set_mci3_info(&zylonite_mci_platform_data);
  214. }
  215. #else
  216. static inline void zylonite_init_mmc(void) {}
  217. #endif
  218. static void __init zylonite_init(void)
  219. {
  220. /* board-processor specific initialization */
  221. zylonite_pxa300_init();
  222. zylonite_pxa320_init();
  223. /*
  224. * Note: We depend that the bootloader set
  225. * the correct value to MSC register for SMC91x.
  226. */
  227. smc91x_resources[1].start = gpio_to_irq(gpio_eth_irq);
  228. smc91x_resources[1].end = gpio_to_irq(gpio_eth_irq);
  229. platform_device_register(&smc91x_device);
  230. zylonite_init_lcd();
  231. zylonite_init_mmc();
  232. }
  233. MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
  234. .phys_io = 0x40000000,
  235. .boot_params = 0xa0000100,
  236. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  237. .map_io = pxa_map_io,
  238. .init_irq = pxa3xx_init_irq,
  239. .timer = &pxa_timer,
  240. .init_machine = zylonite_init,
  241. MACHINE_END