poodle.c 7.4 KB

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