poodle.c 7.8 KB

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