corgi.c 8.0 KB

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