spitz.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*
  2. * Support for Sharp SL-Cxx00 Series of PDAs
  3. * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
  4. *
  5. * Copyright (c) 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/delay.h>
  18. #include <linux/major.h>
  19. #include <linux/fs.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/mmc/host.h>
  22. #include <asm/setup.h>
  23. #include <asm/memory.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/hardware.h>
  26. #include <asm/irq.h>
  27. #include <asm/io.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/irq.h>
  31. #include <asm/arch/pxa-regs.h>
  32. #include <asm/arch/irq.h>
  33. #include <asm/arch/mmc.h>
  34. #include <asm/arch/udc.h>
  35. #include <asm/arch/ohci.h>
  36. #include <asm/arch/pxafb.h>
  37. #include <asm/arch/akita.h>
  38. #include <asm/arch/spitz.h>
  39. #include <asm/arch/sharpsl.h>
  40. #include <asm/mach/sharpsl_param.h>
  41. #include <asm/hardware/scoop.h>
  42. #include "generic.h"
  43. #include "sharpsl.h"
  44. /*
  45. * Spitz SCOOP Device #1
  46. */
  47. static struct resource spitz_scoop_resources[] = {
  48. [0] = {
  49. .start = 0x10800000,
  50. .end = 0x10800fff,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. };
  54. static struct scoop_config spitz_scoop_setup = {
  55. .io_dir = SPITZ_SCP_IO_DIR,
  56. .io_out = SPITZ_SCP_IO_OUT,
  57. .suspend_clr = SPITZ_SCP_SUS_CLR,
  58. .suspend_set = SPITZ_SCP_SUS_SET,
  59. };
  60. struct platform_device spitzscoop_device = {
  61. .name = "sharp-scoop",
  62. .id = 0,
  63. .dev = {
  64. .platform_data = &spitz_scoop_setup,
  65. },
  66. .num_resources = ARRAY_SIZE(spitz_scoop_resources),
  67. .resource = spitz_scoop_resources,
  68. };
  69. /*
  70. * Spitz SCOOP Device #2
  71. */
  72. static struct resource spitz_scoop2_resources[] = {
  73. [0] = {
  74. .start = 0x08800040,
  75. .end = 0x08800fff,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. };
  79. static struct scoop_config spitz_scoop2_setup = {
  80. .io_dir = SPITZ_SCP2_IO_DIR,
  81. .io_out = SPITZ_SCP2_IO_OUT,
  82. .suspend_clr = SPITZ_SCP2_SUS_CLR,
  83. .suspend_set = SPITZ_SCP2_SUS_SET,
  84. };
  85. struct platform_device spitzscoop2_device = {
  86. .name = "sharp-scoop",
  87. .id = 1,
  88. .dev = {
  89. .platform_data = &spitz_scoop2_setup,
  90. },
  91. .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
  92. .resource = spitz_scoop2_resources,
  93. };
  94. static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
  95. {
  96. .dev = &spitzscoop_device.dev,
  97. .irq = SPITZ_IRQ_GPIO_CF_IRQ,
  98. .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
  99. .cd_irq_str = "PCMCIA0 CD",
  100. },{
  101. .dev = &spitzscoop2_device.dev,
  102. .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
  103. .cd_irq = -1,
  104. },
  105. };
  106. /*
  107. * Spitz SSP Device
  108. *
  109. * Set the parent as the scoop device because a lot of SSP devices
  110. * also use scoop functions and this makes the power up/down order
  111. * work correctly.
  112. */
  113. struct platform_device spitzssp_device = {
  114. .name = "corgi-ssp",
  115. .dev = {
  116. .parent = &spitzscoop_device.dev,
  117. },
  118. .id = -1,
  119. };
  120. struct corgissp_machinfo spitz_ssp_machinfo = {
  121. .port = 2,
  122. .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
  123. .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
  124. .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
  125. .clk_lcdcon = 520,
  126. .clk_ads7846 = 14,
  127. .clk_max1111 = 56,
  128. };
  129. /*
  130. * Spitz Backlight Device
  131. */
  132. static struct corgibl_machinfo spitz_bl_machinfo = {
  133. .max_intensity = 0x2f,
  134. };
  135. static struct platform_device spitzbl_device = {
  136. .name = "corgi-bl",
  137. .dev = {
  138. .platform_data = &spitz_bl_machinfo,
  139. },
  140. .id = -1,
  141. };
  142. /*
  143. * Spitz Keyboard Device
  144. */
  145. static struct platform_device spitzkbd_device = {
  146. .name = "spitz-keyboard",
  147. .id = -1,
  148. };
  149. /*
  150. * Spitz Touch Screen Device
  151. */
  152. static struct resource spitzts_resources[] = {
  153. [0] = {
  154. .start = SPITZ_IRQ_GPIO_TP_INT,
  155. .end = SPITZ_IRQ_GPIO_TP_INT,
  156. .flags = IORESOURCE_IRQ,
  157. },
  158. };
  159. static struct corgits_machinfo spitz_ts_machinfo = {
  160. .get_hsync_len = spitz_get_hsync_len,
  161. .put_hsync = spitz_put_hsync,
  162. .wait_hsync = spitz_wait_hsync,
  163. };
  164. static struct platform_device spitzts_device = {
  165. .name = "corgi-ts",
  166. .dev = {
  167. .parent = &spitzssp_device.dev,
  168. .platform_data = &spitz_ts_machinfo,
  169. },
  170. .id = -1,
  171. .num_resources = ARRAY_SIZE(spitzts_resources),
  172. .resource = spitzts_resources,
  173. };
  174. /*
  175. * MMC/SD Device
  176. *
  177. * The card detect interrupt isn't debounced so we delay it by 250ms
  178. * to give the card a chance to fully insert/eject.
  179. */
  180. static struct pxamci_platform_data spitz_mci_platform_data;
  181. static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(int, void *, struct pt_regs *), void *data)
  182. {
  183. int err;
  184. /* setup GPIO for PXA27x MMC controller */
  185. pxa_gpio_mode(GPIO32_MMCCLK_MD);
  186. pxa_gpio_mode(GPIO112_MMCCMD_MD);
  187. pxa_gpio_mode(GPIO92_MMCDAT0_MD);
  188. pxa_gpio_mode(GPIO109_MMCDAT1_MD);
  189. pxa_gpio_mode(GPIO110_MMCDAT2_MD);
  190. pxa_gpio_mode(GPIO111_MMCDAT3_MD);
  191. pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN);
  192. pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN);
  193. spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  194. err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, SA_INTERRUPT,
  195. "MMC card detect", data);
  196. if (err) {
  197. printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  198. return -1;
  199. }
  200. set_irq_type(SPITZ_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
  201. return 0;
  202. }
  203. /* Power control is shared with one of the CF slots so we have a mess */
  204. static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
  205. {
  206. struct pxamci_platform_data* p_d = dev->platform_data;
  207. unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
  208. if (( 1 << vdd) & p_d->ocr_mask) {
  209. /* printk(KERN_DEBUG "%s: on\n", __FUNCTION__); */
  210. set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
  211. mdelay(2);
  212. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | 0x04);
  213. } else {
  214. /* printk(KERN_DEBUG "%s: off\n", __FUNCTION__); */
  215. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr & ~0x04);
  216. if (!(cpr | 0x02)) {
  217. mdelay(1);
  218. reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
  219. }
  220. }
  221. }
  222. static int spitz_mci_get_ro(struct device *dev)
  223. {
  224. return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP);
  225. }
  226. static void spitz_mci_exit(struct device *dev, void *data)
  227. {
  228. free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
  229. }
  230. static struct pxamci_platform_data spitz_mci_platform_data = {
  231. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  232. .init = spitz_mci_init,
  233. .get_ro = spitz_mci_get_ro,
  234. .setpower = spitz_mci_setpower,
  235. .exit = spitz_mci_exit,
  236. };
  237. /*
  238. * Spitz PXA Framebuffer
  239. */
  240. static struct pxafb_mach_info spitz_pxafb_info __initdata = {
  241. .pixclock = 19231,
  242. .xres = 480,
  243. .yres = 640,
  244. .bpp = 16,
  245. .hsync_len = 40,
  246. .left_margin = 46,
  247. .right_margin = 125,
  248. .vsync_len = 3,
  249. .upper_margin = 1,
  250. .lower_margin = 0,
  251. .sync = 0,
  252. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
  253. .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
  254. .pxafb_lcd_power = spitz_lcd_power,
  255. };
  256. static struct platform_device *devices[] __initdata = {
  257. &spitzscoop_device,
  258. &spitzssp_device,
  259. &spitzkbd_device,
  260. &spitzts_device,
  261. &spitzbl_device,
  262. &spitzbattery_device,
  263. };
  264. static void __init common_init(void)
  265. {
  266. PMCR = 0x00;
  267. /* setup sleep mode values */
  268. PWER = 0x00000002;
  269. PFER = 0x00000000;
  270. PRER = 0x00000002;
  271. PGSR0 = 0x0158C000;
  272. PGSR1 = 0x00FF0080;
  273. PGSR2 = 0x0001C004;
  274. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  275. PCFR |= PCFR_OPDE;
  276. corgi_ssp_set_machinfo(&spitz_ssp_machinfo);
  277. pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN);
  278. platform_add_devices(devices, ARRAY_SIZE(devices));
  279. pxa_set_mci_info(&spitz_mci_platform_data);
  280. pxafb_device.dev.parent = &spitzssp_device.dev;
  281. set_pxa_fb_info(&spitz_pxafb_info);
  282. }
  283. static void __init spitz_init(void)
  284. {
  285. scoop_num = 2;
  286. scoop_devs = &spitz_pcmcia_scoop[0];
  287. spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
  288. common_init();
  289. platform_device_register(&spitzscoop2_device);
  290. }
  291. static void __init fixup_spitz(struct machine_desc *desc,
  292. struct tag *tags, char **cmdline, struct meminfo *mi)
  293. {
  294. sharpsl_save_param();
  295. mi->nr_banks = 1;
  296. mi->bank[0].start = 0xa0000000;
  297. mi->bank[0].node = 0;
  298. mi->bank[0].size = (64*1024*1024);
  299. }
  300. #ifdef CONFIG_MACH_SPITZ
  301. MACHINE_START(SPITZ, "SHARP Spitz")
  302. .phys_ram = 0xa0000000,
  303. .phys_io = 0x40000000,
  304. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  305. .fixup = fixup_spitz,
  306. .map_io = pxa_map_io,
  307. .init_irq = pxa_init_irq,
  308. .init_machine = spitz_init,
  309. .timer = &pxa_timer,
  310. MACHINE_END
  311. #endif
  312. #ifdef CONFIG_MACH_BORZOI
  313. MACHINE_START(BORZOI, "SHARP Borzoi")
  314. .phys_ram = 0xa0000000,
  315. .phys_io = 0x40000000,
  316. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  317. .fixup = fixup_spitz,
  318. .map_io = pxa_map_io,
  319. .init_irq = pxa_init_irq,
  320. .init_machine = spitz_init,
  321. .timer = &pxa_timer,
  322. MACHINE_END
  323. #endif