poodle.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /*
  2. * linux/arch/arm/mach-pxa/poodle.c
  3. *
  4. * Support for the SHARP Poodle Board.
  5. *
  6. * Based on:
  7. * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
  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. * Change Log
  14. * 12-Dec-2002 Sharp Corporation for Poodle
  15. * John Lenz <lenz@cs.wisc.edu> updates to 2.6
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/fb.h>
  21. #include <linux/pm.h>
  22. #include <linux/delay.h>
  23. #include <asm/hardware.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/irq.h>
  26. #include <asm/setup.h>
  27. #include <asm/system.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/mmc.h>
  33. #include <asm/arch/udc.h>
  34. #include <asm/arch/irda.h>
  35. #include <asm/arch/poodle.h>
  36. #include <asm/arch/pxafb.h>
  37. #include <asm/hardware/scoop.h>
  38. #include <asm/hardware/locomo.h>
  39. #include <asm/mach/sharpsl_param.h>
  40. #include "generic.h"
  41. static struct resource poodle_scoop_resources[] = {
  42. [0] = {
  43. .start = 0x10800000,
  44. .end = 0x10800fff,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. };
  48. static struct scoop_config poodle_scoop_setup = {
  49. .io_dir = POODLE_SCOOP_IO_DIR,
  50. .io_out = POODLE_SCOOP_IO_OUT,
  51. };
  52. struct platform_device poodle_scoop_device = {
  53. .name = "sharp-scoop",
  54. .id = -1,
  55. .dev = {
  56. .platform_data = &poodle_scoop_setup,
  57. },
  58. .num_resources = ARRAY_SIZE(poodle_scoop_resources),
  59. .resource = poodle_scoop_resources,
  60. };
  61. static void poodle_pcmcia_init(void)
  62. {
  63. /* Setup default state of GPIO outputs
  64. before we enable them as outputs. */
  65. GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
  66. GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
  67. GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
  68. GPIO_bit(GPIO53_nPCE_2);
  69. pxa_gpio_mode(GPIO48_nPOE_MD);
  70. pxa_gpio_mode(GPIO49_nPWE_MD);
  71. pxa_gpio_mode(GPIO50_nPIOR_MD);
  72. pxa_gpio_mode(GPIO51_nPIOW_MD);
  73. pxa_gpio_mode(GPIO55_nPREG_MD);
  74. pxa_gpio_mode(GPIO56_nPWAIT_MD);
  75. pxa_gpio_mode(GPIO57_nIOIS16_MD);
  76. pxa_gpio_mode(GPIO52_nPCE_1_MD);
  77. pxa_gpio_mode(GPIO53_nPCE_2_MD);
  78. pxa_gpio_mode(GPIO54_pSKTSEL_MD);
  79. }
  80. static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
  81. {
  82. .dev = &poodle_scoop_device.dev,
  83. .irq = POODLE_IRQ_GPIO_CF_IRQ,
  84. .cd_irq = POODLE_IRQ_GPIO_CF_CD,
  85. .cd_irq_str = "PCMCIA0 CD",
  86. },
  87. };
  88. static struct scoop_pcmcia_config poodle_pcmcia_config = {
  89. .devs = &poodle_pcmcia_scoop[0],
  90. .num_devs = 1,
  91. .pcmcia_init = poodle_pcmcia_init,
  92. };
  93. EXPORT_SYMBOL(poodle_scoop_device);
  94. /* LoCoMo device */
  95. static struct resource locomo_resources[] = {
  96. [0] = {
  97. .start = 0x10000000,
  98. .end = 0x10001fff,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. [1] = {
  102. .start = IRQ_GPIO(10),
  103. .end = IRQ_GPIO(10),
  104. .flags = IORESOURCE_IRQ,
  105. },
  106. };
  107. static struct platform_device locomo_device = {
  108. .name = "locomo",
  109. .id = 0,
  110. .num_resources = ARRAY_SIZE(locomo_resources),
  111. .resource = locomo_resources,
  112. };
  113. /*
  114. * MMC/SD Device
  115. *
  116. * The card detect interrupt isn't debounced so we delay it by 250ms
  117. * to give the card a chance to fully insert/eject.
  118. */
  119. static struct pxamci_platform_data poodle_mci_platform_data;
  120. static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
  121. {
  122. int err;
  123. /* setup GPIO for PXA25x MMC controller */
  124. pxa_gpio_mode(GPIO6_MMCCLK_MD);
  125. pxa_gpio_mode(GPIO8_MMCCS0_MD);
  126. pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
  127. pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN);
  128. pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
  129. pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT);
  130. poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  131. err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
  132. SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
  133. "MMC card detect", data);
  134. if (err) {
  135. printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  136. return -1;
  137. }
  138. return 0;
  139. }
  140. static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
  141. {
  142. struct pxamci_platform_data* p_d = dev->platform_data;
  143. if (( 1 << vdd) & p_d->ocr_mask) {
  144. GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
  145. mdelay(2);
  146. GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
  147. } else {
  148. GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
  149. GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
  150. }
  151. }
  152. static int poodle_mci_get_ro(struct device *dev)
  153. {
  154. return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
  155. }
  156. static void poodle_mci_exit(struct device *dev, void *data)
  157. {
  158. free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
  159. }
  160. static struct pxamci_platform_data poodle_mci_platform_data = {
  161. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  162. .init = poodle_mci_init,
  163. .get_ro = poodle_mci_get_ro,
  164. .setpower = poodle_mci_setpower,
  165. .exit = poodle_mci_exit,
  166. };
  167. /*
  168. * Irda
  169. */
  170. static void poodle_irda_transceiver_mode(struct device *dev, int mode)
  171. {
  172. if (mode & IR_OFF) {
  173. GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
  174. } else {
  175. GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
  176. }
  177. }
  178. static struct pxaficp_platform_data poodle_ficp_platform_data = {
  179. .transceiver_cap = IR_SIRMODE | IR_OFF,
  180. .transceiver_mode = poodle_irda_transceiver_mode,
  181. };
  182. /*
  183. * USB Device Controller
  184. */
  185. static void poodle_udc_command(int cmd)
  186. {
  187. switch(cmd) {
  188. case PXA2XX_UDC_CMD_CONNECT:
  189. GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
  190. break;
  191. case PXA2XX_UDC_CMD_DISCONNECT:
  192. GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
  193. break;
  194. }
  195. }
  196. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  197. /* no connect GPIO; poodle can't tell connection status */
  198. .udc_command = poodle_udc_command,
  199. };
  200. /* PXAFB device */
  201. static struct pxafb_mach_info poodle_fb_info __initdata = {
  202. .pixclock = 144700,
  203. .xres = 320,
  204. .yres = 240,
  205. .bpp = 16,
  206. .hsync_len = 7,
  207. .left_margin = 11,
  208. .right_margin = 30,
  209. .vsync_len = 2,
  210. .upper_margin = 2,
  211. .lower_margin = 0,
  212. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  213. .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
  214. .lccr3 = 0,
  215. .pxafb_backlight_power = NULL,
  216. .pxafb_lcd_power = NULL,
  217. };
  218. static struct platform_device *devices[] __initdata = {
  219. &locomo_device,
  220. &poodle_scoop_device,
  221. };
  222. static void poodle_poweroff(void)
  223. {
  224. RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
  225. arm_machine_restart('h');
  226. }
  227. static void poodle_restart(char mode)
  228. {
  229. RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
  230. arm_machine_restart('h');
  231. }
  232. static void __init poodle_init(void)
  233. {
  234. int ret = 0;
  235. pm_power_off = poodle_poweroff;
  236. arm_pm_restart = poodle_restart;
  237. /* setup sleep mode values */
  238. PWER = 0x00000002;
  239. PFER = 0x00000000;
  240. PRER = 0x00000002;
  241. PGSR0 = 0x00008000;
  242. PGSR1 = 0x003F0202;
  243. PGSR2 = 0x0001C000;
  244. PCFR |= PCFR_OPDE;
  245. /* cpu initialize */
  246. /* Pgsr Register */
  247. PGSR0 = 0x0146dd80;
  248. PGSR1 = 0x03bf0890;
  249. PGSR2 = 0x0001c000;
  250. /* Alternate Register */
  251. GAFR0_L = 0x01001000;
  252. GAFR0_U = 0x591a8010;
  253. GAFR1_L = 0x900a8451;
  254. GAFR1_U = 0xaaa5aaaa;
  255. GAFR2_L = 0x8aaaaaaa;
  256. GAFR2_U = 0x00000002;
  257. /* Direction Register */
  258. GPDR0 = 0xd3f0904c;
  259. GPDR1 = 0xfcffb7d3;
  260. GPDR2 = 0x0001ffff;
  261. /* Output Register */
  262. GPCR0 = 0x00000000;
  263. GPCR1 = 0x00000000;
  264. GPCR2 = 0x00000000;
  265. GPSR0 = 0x00400000;
  266. GPSR1 = 0x00000000;
  267. GPSR2 = 0x00000000;
  268. set_pxa_fb_info(&poodle_fb_info);
  269. pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
  270. pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
  271. pxa_set_udc_info(&udc_info);
  272. pxa_set_mci_info(&poodle_mci_platform_data);
  273. pxa_set_ficp_info(&poodle_ficp_platform_data);
  274. platform_scoop_config = &poodle_pcmcia_config;
  275. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  276. if (ret) {
  277. printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
  278. }
  279. }
  280. static void __init fixup_poodle(struct machine_desc *desc,
  281. struct tag *tags, char **cmdline, struct meminfo *mi)
  282. {
  283. sharpsl_save_param();
  284. mi->nr_banks=1;
  285. mi->bank[0].start = 0xa0000000;
  286. mi->bank[0].node = 0;
  287. mi->bank[0].size = (32*1024*1024);
  288. }
  289. MACHINE_START(POODLE, "SHARP Poodle")
  290. .phys_io = 0x40000000,
  291. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  292. .fixup = fixup_poodle,
  293. .map_io = pxa_map_io,
  294. .init_irq = pxa_init_irq,
  295. .timer = &pxa_timer,
  296. .init_machine = poodle_init,
  297. MACHINE_END