poodle.c 9.5 KB

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