/arch/arm/mach-pxa/corgi.c

https://bitbucket.org/evzijst/gittest · C · 320 lines · 226 code · 49 blank · 45 comment · 5 complexity · 6cb2994dae7ae391ff602b2d5984e32d MD5 · raw file

  1. /*
  2. * Support for Sharp SL-C7xx PDAs
  3. * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky)
  4. *
  5. * Copyright (c) 2004-2005 Richard Purdie
  6. *
  7. * Based on Sharp's 2.4 kernel patches/lubbock.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/device.h>
  17. #include <linux/major.h>
  18. #include <linux/fs.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/mmc/host.h>
  21. #include <asm/setup.h>
  22. #include <asm/memory.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/hardware.h>
  25. #include <asm/irq.h>
  26. #include <asm/io.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <asm/arch/pxa-regs.h>
  31. #include <asm/arch/irq.h>
  32. #include <asm/arch/mmc.h>
  33. #include <asm/arch/udc.h>
  34. #include <asm/arch/corgi.h>
  35. #include <asm/mach/sharpsl_param.h>
  36. #include <asm/hardware/scoop.h>
  37. #include <video/w100fb.h>
  38. #include "generic.h"
  39. /*
  40. * Corgi SCOOP Device
  41. */
  42. static struct resource corgi_scoop_resources[] = {
  43. [0] = {
  44. .start = 0x10800000,
  45. .end = 0x10800fff,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. };
  49. static struct scoop_config corgi_scoop_setup = {
  50. .io_dir = CORGI_SCOOP_IO_DIR,
  51. .io_out = CORGI_SCOOP_IO_OUT,
  52. };
  53. struct platform_device corgiscoop_device = {
  54. .name = "sharp-scoop",
  55. .id = -1,
  56. .dev = {
  57. .platform_data = &corgi_scoop_setup,
  58. },
  59. .num_resources = ARRAY_SIZE(corgi_scoop_resources),
  60. .resource = corgi_scoop_resources,
  61. };
  62. /*
  63. * Corgi SSP Device
  64. *
  65. * Set the parent as the scoop device because a lot of SSP devices
  66. * also use scoop functions and this makes the power up/down order
  67. * work correctly.
  68. */
  69. static struct platform_device corgissp_device = {
  70. .name = "corgi-ssp",
  71. .dev = {
  72. .parent = &corgiscoop_device.dev,
  73. },
  74. .id = -1,
  75. };
  76. /*
  77. * Corgi w100 Frame Buffer Device
  78. */
  79. static struct w100fb_mach_info corgi_fb_info = {
  80. .w100fb_ssp_send = corgi_ssp_lcdtg_send,
  81. .comadj = -1,
  82. .phadadj = -1,
  83. };
  84. static struct resource corgi_fb_resources[] = {
  85. [0] = {
  86. .start = 0x08000000,
  87. .end = 0x08ffffff,
  88. .flags = IORESOURCE_MEM,
  89. },
  90. };
  91. static struct platform_device corgifb_device = {
  92. .name = "w100fb",
  93. .id = -1,
  94. .dev = {
  95. .platform_data = &corgi_fb_info,
  96. .parent = &corgissp_device.dev,
  97. },
  98. .num_resources = ARRAY_SIZE(corgi_fb_resources),
  99. .resource = corgi_fb_resources,
  100. };
  101. /*
  102. * Corgi Backlight Device
  103. */
  104. static struct platform_device corgibl_device = {
  105. .name = "corgi-bl",
  106. .dev = {
  107. .parent = &corgifb_device.dev,
  108. },
  109. .id = -1,
  110. };
  111. /*
  112. * MMC/SD Device
  113. *
  114. * The card detect interrupt isn't debounced so we delay it by HZ/4
  115. * to give the card a chance to fully insert/eject.
  116. */
  117. static struct mmc_detect {
  118. struct timer_list detect_timer;
  119. void *devid;
  120. } mmc_detect;
  121. static void mmc_detect_callback(unsigned long data)
  122. {
  123. mmc_detect_change(mmc_detect.devid);
  124. }
  125. static irqreturn_t corgi_mmc_detect_int(int irq, void *devid, struct pt_regs *regs)
  126. {
  127. mmc_detect.devid=devid;
  128. mod_timer(&mmc_detect.detect_timer, jiffies + HZ/4);
  129. return IRQ_HANDLED;
  130. }
  131. static int corgi_mci_init(struct device *dev, irqreturn_t (*unused_detect_int)(int, void *, struct pt_regs *), void *data)
  132. {
  133. int err;
  134. /* setup GPIO for PXA25x MMC controller */
  135. pxa_gpio_mode(GPIO6_MMCCLK_MD);
  136. pxa_gpio_mode(GPIO8_MMCCS0_MD);
  137. pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN);
  138. pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT);
  139. init_timer(&mmc_detect.detect_timer);
  140. mmc_detect.detect_timer.function = mmc_detect_callback;
  141. mmc_detect.detect_timer.data = (unsigned long) &mmc_detect;
  142. err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_mmc_detect_int, SA_INTERRUPT,
  143. "MMC card detect", data);
  144. if (err) {
  145. printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  146. return -1;
  147. }
  148. set_irq_type(CORGI_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
  149. return 0;
  150. }
  151. static void corgi_mci_setpower(struct device *dev, unsigned int vdd)
  152. {
  153. struct pxamci_platform_data* p_d = dev->platform_data;
  154. if (( 1 << vdd) & p_d->ocr_mask) {
  155. printk(KERN_DEBUG "%s: on\n", __FUNCTION__);
  156. GPSR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
  157. } else {
  158. printk(KERN_DEBUG "%s: off\n", __FUNCTION__);
  159. GPCR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
  160. }
  161. }
  162. static void corgi_mci_exit(struct device *dev, void *data)
  163. {
  164. free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
  165. del_timer(&mmc_detect.detect_timer);
  166. }
  167. static struct pxamci_platform_data corgi_mci_platform_data = {
  168. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  169. .init = corgi_mci_init,
  170. .setpower = corgi_mci_setpower,
  171. .exit = corgi_mci_exit,
  172. };
  173. /*
  174. * USB Device Controller
  175. */
  176. static void corgi_udc_command(int cmd)
  177. {
  178. switch(cmd) {
  179. case PXA2XX_UDC_CMD_CONNECT:
  180. GPSR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
  181. break;
  182. case PXA2XX_UDC_CMD_DISCONNECT:
  183. GPCR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
  184. break;
  185. }
  186. }
  187. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  188. /* no connect GPIO; corgi can't tell connection status */
  189. .udc_command = corgi_udc_command,
  190. };
  191. static struct platform_device *devices[] __initdata = {
  192. &corgiscoop_device,
  193. &corgissp_device,
  194. &corgifb_device,
  195. &corgibl_device,
  196. };
  197. static void __init corgi_init(void)
  198. {
  199. corgi_fb_info.comadj=sharpsl_param.comadj;
  200. corgi_fb_info.phadadj=sharpsl_param.phadadj;
  201. pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT);
  202. pxa_set_udc_info(&udc_info);
  203. pxa_set_mci_info(&corgi_mci_platform_data);
  204. platform_add_devices(devices, ARRAY_SIZE(devices));
  205. }
  206. static void __init fixup_corgi(struct machine_desc *desc,
  207. struct tag *tags, char **cmdline, struct meminfo *mi)
  208. {
  209. sharpsl_save_param();
  210. mi->nr_banks=1;
  211. mi->bank[0].start = 0xa0000000;
  212. mi->bank[0].node = 0;
  213. if (machine_is_corgi())
  214. mi->bank[0].size = (32*1024*1024);
  215. else
  216. mi->bank[0].size = (64*1024*1024);
  217. }
  218. static void __init corgi_init_irq(void)
  219. {
  220. pxa_init_irq();
  221. }
  222. static struct map_desc corgi_io_desc[] __initdata = {
  223. /* virtual physical length */
  224. /* { 0xf1000000, 0x08000000, 0x01000000, MT_DEVICE },*/ /* LCDC (readable for Qt driver) */
  225. /* { 0xef700000, 0x10800000, 0x00001000, MT_DEVICE },*/ /* SCOOP */
  226. { 0xef800000, 0x00000000, 0x00800000, MT_DEVICE }, /* Boot Flash */
  227. };
  228. static void __init corgi_map_io(void)
  229. {
  230. pxa_map_io();
  231. iotable_init(corgi_io_desc,ARRAY_SIZE(corgi_io_desc));
  232. /* setup sleep mode values */
  233. PWER = 0x00000002;
  234. PFER = 0x00000000;
  235. PRER = 0x00000002;
  236. PGSR0 = 0x0158C000;
  237. PGSR1 = 0x00FF0080;
  238. PGSR2 = 0x0001C004;
  239. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  240. PCFR |= PCFR_OPDE;
  241. }
  242. #ifdef CONFIG_MACH_CORGI
  243. MACHINE_START(CORGI, "SHARP Corgi")
  244. BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
  245. FIXUP(fixup_corgi)
  246. MAPIO(corgi_map_io)
  247. INITIRQ(corgi_init_irq)
  248. .init_machine = corgi_init,
  249. .timer = &pxa_timer,
  250. MACHINE_END
  251. #endif
  252. #ifdef CONFIG_MACH_SHEPHERD
  253. MACHINE_START(SHEPHERD, "SHARP Shepherd")
  254. BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
  255. FIXUP(fixup_corgi)
  256. MAPIO(corgi_map_io)
  257. INITIRQ(corgi_init_irq)
  258. .init_machine = corgi_init,
  259. .timer = &pxa_timer,
  260. MACHINE_END
  261. #endif
  262. #ifdef CONFIG_MACH_HUSKY
  263. MACHINE_START(HUSKY, "SHARP Husky")
  264. BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
  265. FIXUP(fixup_corgi)
  266. MAPIO(corgi_map_io)
  267. INITIRQ(corgi_init_irq)
  268. .init_machine = corgi_init,
  269. .timer = &pxa_timer,
  270. MACHINE_END
  271. #endif