corgi.c 9.3 KB

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