corgi.c 8.7 KB

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