corgi.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 "generic.h"
  38. /*
  39. * Corgi SCOOP Device
  40. */
  41. static struct resource corgi_scoop_resources[] = {
  42. [0] = {
  43. .start = 0x10800000,
  44. .end = 0x10800fff,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. };
  48. static struct scoop_config corgi_scoop_setup = {
  49. .io_dir = CORGI_SCOOP_IO_DIR,
  50. .io_out = CORGI_SCOOP_IO_OUT,
  51. };
  52. static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
  53. {
  54. .dev = &corgiscoop_device.dev,
  55. .irq = CORGI_IRQ_GPIO_CF_IRQ,
  56. .cd_irq = CORGI_IRQ_GPIO_CF_CD,
  57. .cd_irq_str = "PCMCIA0 CD",
  58. },
  59. };
  60. struct platform_device corgiscoop_device = {
  61. .name = "sharp-scoop",
  62. .id = -1,
  63. .dev = {
  64. .platform_data = &corgi_scoop_setup,
  65. },
  66. .num_resources = ARRAY_SIZE(corgi_scoop_resources),
  67. .resource = corgi_scoop_resources,
  68. };
  69. /*
  70. * Corgi SSP Device
  71. *
  72. * Set the parent as the scoop device because a lot of SSP devices
  73. * also use scoop functions and this makes the power up/down order
  74. * work correctly.
  75. */
  76. struct platform_device corgissp_device = {
  77. .name = "corgi-ssp",
  78. .dev = {
  79. .parent = &corgiscoop_device.dev,
  80. },
  81. .id = -1,
  82. };
  83. /*
  84. * Corgi Backlight Device
  85. */
  86. static struct platform_device corgibl_device = {
  87. .name = "corgi-bl",
  88. .dev = {
  89. .parent = &corgifb_device.dev,
  90. },
  91. .id = -1,
  92. };
  93. /*
  94. * Corgi Keyboard Device
  95. */
  96. static struct platform_device corgikbd_device = {
  97. .name = "corgi-keyboard",
  98. .id = -1,
  99. };
  100. /*
  101. * Corgi Touch Screen Device
  102. */
  103. static struct platform_device corgits_device = {
  104. .name = "corgi-ts",
  105. .dev = {
  106. .parent = &corgissp_device.dev,
  107. },
  108. .id = -1,
  109. };
  110. /*
  111. * MMC/SD Device
  112. *
  113. * The card detect interrupt isn't debounced so we delay it by HZ/4
  114. * to give the card a chance to fully insert/eject.
  115. */
  116. static struct mmc_detect {
  117. struct timer_list detect_timer;
  118. void *devid;
  119. } mmc_detect;
  120. static void mmc_detect_callback(unsigned long data)
  121. {
  122. mmc_detect_change(mmc_detect.devid);
  123. }
  124. static irqreturn_t corgi_mmc_detect_int(int irq, void *devid, struct pt_regs *regs)
  125. {
  126. mmc_detect.devid=devid;
  127. mod_timer(&mmc_detect.detect_timer, jiffies + HZ/4);
  128. return IRQ_HANDLED;
  129. }
  130. static int corgi_mci_init(struct device *dev, irqreturn_t (*unused_detect_int)(int, void *, struct pt_regs *), void *data)
  131. {
  132. int err;
  133. /* setup GPIO for PXA25x MMC controller */
  134. pxa_gpio_mode(GPIO6_MMCCLK_MD);
  135. pxa_gpio_mode(GPIO8_MMCCS0_MD);
  136. pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN);
  137. pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT);
  138. init_timer(&mmc_detect.detect_timer);
  139. mmc_detect.detect_timer.function = mmc_detect_callback;
  140. mmc_detect.detect_timer.data = (unsigned long) &mmc_detect;
  141. err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_mmc_detect_int, SA_INTERRUPT,
  142. "MMC card detect", data);
  143. if (err) {
  144. printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  145. return -1;
  146. }
  147. set_irq_type(CORGI_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
  148. return 0;
  149. }
  150. static void corgi_mci_setpower(struct device *dev, unsigned int vdd)
  151. {
  152. struct pxamci_platform_data* p_d = dev->platform_data;
  153. if (( 1 << vdd) & p_d->ocr_mask) {
  154. printk(KERN_DEBUG "%s: on\n", __FUNCTION__);
  155. GPSR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
  156. } else {
  157. printk(KERN_DEBUG "%s: off\n", __FUNCTION__);
  158. GPCR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
  159. }
  160. }
  161. static int corgi_mci_get_ro(struct device *dev)
  162. {
  163. return GPLR(CORGI_GPIO_nSD_WP) & GPIO_bit(CORGI_GPIO_nSD_WP);
  164. }
  165. static void corgi_mci_exit(struct device *dev, void *data)
  166. {
  167. free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
  168. del_timer(&mmc_detect.detect_timer);
  169. }
  170. static struct pxamci_platform_data corgi_mci_platform_data = {
  171. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  172. .init = corgi_mci_init,
  173. .get_ro = corgi_mci_get_ro,
  174. .setpower = corgi_mci_setpower,
  175. .exit = corgi_mci_exit,
  176. };
  177. /*
  178. * USB Device Controller
  179. */
  180. static void corgi_udc_command(int cmd)
  181. {
  182. switch(cmd) {
  183. case PXA2XX_UDC_CMD_CONNECT:
  184. GPSR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
  185. break;
  186. case PXA2XX_UDC_CMD_DISCONNECT:
  187. GPCR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
  188. break;
  189. }
  190. }
  191. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  192. /* no connect GPIO; corgi can't tell connection status */
  193. .udc_command = corgi_udc_command,
  194. };
  195. static struct platform_device *devices[] __initdata = {
  196. &corgiscoop_device,
  197. &corgissp_device,
  198. &corgifb_device,
  199. &corgikbd_device,
  200. &corgibl_device,
  201. &corgits_device,
  202. };
  203. static void __init corgi_init(void)
  204. {
  205. pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT);
  206. pxa_set_udc_info(&udc_info);
  207. pxa_set_mci_info(&corgi_mci_platform_data);
  208. scoop_num = 1;
  209. scoop_devs = &corgi_pcmcia_scoop[0];
  210. platform_add_devices(devices, ARRAY_SIZE(devices));
  211. }
  212. static void __init fixup_corgi(struct machine_desc *desc,
  213. struct tag *tags, char **cmdline, struct meminfo *mi)
  214. {
  215. sharpsl_save_param();
  216. mi->nr_banks=1;
  217. mi->bank[0].start = 0xa0000000;
  218. mi->bank[0].node = 0;
  219. if (machine_is_corgi())
  220. mi->bank[0].size = (32*1024*1024);
  221. else
  222. mi->bank[0].size = (64*1024*1024);
  223. }
  224. static void __init corgi_init_irq(void)
  225. {
  226. pxa_init_irq();
  227. }
  228. static struct map_desc corgi_io_desc[] __initdata = {
  229. /* virtual physical length */
  230. /* { 0xf1000000, 0x08000000, 0x01000000, MT_DEVICE },*/ /* LCDC (readable for Qt driver) */
  231. /* { 0xef700000, 0x10800000, 0x00001000, MT_DEVICE },*/ /* SCOOP */
  232. { 0xef800000, 0x00000000, 0x00800000, MT_DEVICE }, /* Boot Flash */
  233. };
  234. static void __init corgi_map_io(void)
  235. {
  236. pxa_map_io();
  237. iotable_init(corgi_io_desc,ARRAY_SIZE(corgi_io_desc));
  238. /* setup sleep mode values */
  239. PWER = 0x00000002;
  240. PFER = 0x00000000;
  241. PRER = 0x00000002;
  242. PGSR0 = 0x0158C000;
  243. PGSR1 = 0x00FF0080;
  244. PGSR2 = 0x0001C004;
  245. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  246. PCFR |= PCFR_OPDE;
  247. }
  248. #ifdef CONFIG_MACH_CORGI
  249. MACHINE_START(CORGI, "SHARP Corgi")
  250. .phys_ram = 0xa0000000,
  251. .phys_io = 0x40000000,
  252. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  253. .fixup = fixup_corgi,
  254. .map_io = corgi_map_io,
  255. .init_irq = corgi_init_irq,
  256. .init_machine = corgi_init,
  257. .timer = &pxa_timer,
  258. MACHINE_END
  259. #endif
  260. #ifdef CONFIG_MACH_SHEPHERD
  261. MACHINE_START(SHEPHERD, "SHARP Shepherd")
  262. .phys_ram = 0xa0000000,
  263. .phys_io = 0x40000000,
  264. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  265. .fixup = fixup_corgi,
  266. .map_io = corgi_map_io,
  267. .init_irq = corgi_init_irq,
  268. .init_machine = corgi_init,
  269. .timer = &pxa_timer,
  270. MACHINE_END
  271. #endif
  272. #ifdef CONFIG_MACH_HUSKY
  273. MACHINE_START(HUSKY, "SHARP Husky")
  274. .phys_ram = 0xa0000000,
  275. .phys_io = 0x40000000,
  276. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  277. .fixup = fixup_corgi,
  278. .map_io = corgi_map_io,
  279. .init_irq = corgi_init_irq,
  280. .init_machine = corgi_init,
  281. .timer = &pxa_timer,
  282. MACHINE_END
  283. #endif