poodle.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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 struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
  60. {
  61. .dev = &poodle_scoop_device.dev,
  62. .irq = POODLE_IRQ_GPIO_CF_IRQ,
  63. .cd_irq = POODLE_IRQ_GPIO_CF_CD,
  64. .cd_irq_str = "PCMCIA0 CD",
  65. },
  66. };
  67. /* LoCoMo device */
  68. static struct resource locomo_resources[] = {
  69. [0] = {
  70. .start = 0x10000000,
  71. .end = 0x10001fff,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. [1] = {
  75. .start = IRQ_GPIO(10),
  76. .end = IRQ_GPIO(10),
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. };
  80. static struct platform_device locomo_device = {
  81. .name = "locomo",
  82. .id = 0,
  83. .num_resources = ARRAY_SIZE(locomo_resources),
  84. .resource = locomo_resources,
  85. };
  86. /*
  87. * MMC/SD Device
  88. *
  89. * The card detect interrupt isn't debounced so we delay it by 250ms
  90. * to give the card a chance to fully insert/eject.
  91. */
  92. static struct pxamci_platform_data poodle_mci_platform_data;
  93. static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
  94. {
  95. int err;
  96. /* setup GPIO for PXA25x MMC controller */
  97. pxa_gpio_mode(GPIO6_MMCCLK_MD);
  98. pxa_gpio_mode(GPIO8_MMCCS0_MD);
  99. pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
  100. pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
  101. poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  102. err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int, SA_INTERRUPT,
  103. "MMC card detect", data);
  104. if (err) {
  105. printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
  106. return -1;
  107. }
  108. set_irq_type(POODLE_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
  109. return 0;
  110. }
  111. static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
  112. {
  113. struct pxamci_platform_data* p_d = dev->platform_data;
  114. if (( 1 << vdd) & p_d->ocr_mask)
  115. GPSR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
  116. else
  117. GPCR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
  118. }
  119. static void poodle_mci_exit(struct device *dev, void *data)
  120. {
  121. free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
  122. }
  123. static struct pxamci_platform_data poodle_mci_platform_data = {
  124. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  125. .init = poodle_mci_init,
  126. .setpower = poodle_mci_setpower,
  127. .exit = poodle_mci_exit,
  128. };
  129. /*
  130. * Irda
  131. */
  132. static void poodle_irda_transceiver_mode(struct device *dev, int mode)
  133. {
  134. if (mode & IR_OFF) {
  135. GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
  136. } else {
  137. GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
  138. }
  139. }
  140. static struct pxaficp_platform_data poodle_ficp_platform_data = {
  141. .transceiver_cap = IR_SIRMODE | IR_OFF,
  142. .transceiver_mode = poodle_irda_transceiver_mode,
  143. };
  144. /*
  145. * USB Device Controller
  146. */
  147. static void poodle_udc_command(int cmd)
  148. {
  149. switch(cmd) {
  150. case PXA2XX_UDC_CMD_CONNECT:
  151. GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
  152. break;
  153. case PXA2XX_UDC_CMD_DISCONNECT:
  154. GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
  155. break;
  156. }
  157. }
  158. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  159. /* no connect GPIO; poodle can't tell connection status */
  160. .udc_command = poodle_udc_command,
  161. };
  162. /* PXAFB device */
  163. static struct pxafb_mach_info poodle_fb_info __initdata = {
  164. .pixclock = 144700,
  165. .xres = 320,
  166. .yres = 240,
  167. .bpp = 16,
  168. .hsync_len = 7,
  169. .left_margin = 11,
  170. .right_margin = 30,
  171. .vsync_len = 2,
  172. .upper_margin = 2,
  173. .lower_margin = 0,
  174. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  175. .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
  176. .lccr3 = 0,
  177. .pxafb_backlight_power = NULL,
  178. .pxafb_lcd_power = NULL,
  179. };
  180. static struct platform_device *devices[] __initdata = {
  181. &locomo_device,
  182. &poodle_scoop_device,
  183. };
  184. static void __init poodle_init(void)
  185. {
  186. int ret = 0;
  187. /* setup sleep mode values */
  188. PWER = 0x00000002;
  189. PFER = 0x00000000;
  190. PRER = 0x00000002;
  191. PGSR0 = 0x00008000;
  192. PGSR1 = 0x003F0202;
  193. PGSR2 = 0x0001C000;
  194. PCFR |= PCFR_OPDE;
  195. /* cpu initialize */
  196. /* Pgsr Register */
  197. PGSR0 = 0x0146dd80;
  198. PGSR1 = 0x03bf0890;
  199. PGSR2 = 0x0001c000;
  200. /* Alternate Register */
  201. GAFR0_L = 0x01001000;
  202. GAFR0_U = 0x591a8010;
  203. GAFR1_L = 0x900a8451;
  204. GAFR1_U = 0xaaa5aaaa;
  205. GAFR2_L = 0x8aaaaaaa;
  206. GAFR2_U = 0x00000002;
  207. /* Direction Register */
  208. GPDR0 = 0xd3f0904c;
  209. GPDR1 = 0xfcffb7d3;
  210. GPDR2 = 0x0001ffff;
  211. /* Output Register */
  212. GPCR0 = 0x00000000;
  213. GPCR1 = 0x00000000;
  214. GPCR2 = 0x00000000;
  215. GPSR0 = 0x00400000;
  216. GPSR1 = 0x00000000;
  217. GPSR2 = 0x00000000;
  218. set_pxa_fb_info(&poodle_fb_info);
  219. pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
  220. pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
  221. pxa_set_udc_info(&udc_info);
  222. pxa_set_mci_info(&poodle_mci_platform_data);
  223. pxa_set_ficp_info(&poodle_ficp_platform_data);
  224. scoop_num = 1;
  225. scoop_devs = &poodle_pcmcia_scoop[0];
  226. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  227. if (ret) {
  228. printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
  229. }
  230. }
  231. static void __init fixup_poodle(struct machine_desc *desc,
  232. struct tag *tags, char **cmdline, struct meminfo *mi)
  233. {
  234. sharpsl_save_param();
  235. }
  236. MACHINE_START(POODLE, "SHARP Poodle")
  237. .phys_ram = 0xa0000000,
  238. .phys_io = 0x40000000,
  239. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  240. .fixup = fixup_poodle,
  241. .map_io = pxa_map_io,
  242. .init_irq = pxa_init_irq,
  243. .timer = &pxa_timer,
  244. .init_machine = poodle_init,
  245. MACHINE_END