spitz.c 8.7 KB

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