corgi.c 7.4 KB

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