poodle.c 10 KB

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