corgi.c 8.6 KB

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