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