collie.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /*
  2. * linux/arch/arm/mach-sa1100/collie.c
  3. *
  4. * May be copied or modified under the terms of the GNU General Public
  5. * License. See linux/COPYING for more information.
  6. *
  7. * This file contains all Collie-specific tweaks.
  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. * ChangeLog:
  14. * 2006 Pavel Machek <pavel@ucw.cz>
  15. * 03-06-2004 John Lenz <lenz@cs.wisc.edu>
  16. * 06-04-2002 Chris Larson <kergoth@digitalnemesis.net>
  17. * 04-16-2001 Lineo Japan,Inc. ...
  18. */
  19. #include <linux/init.h>
  20. #include <linux/kernel.h>
  21. #include <linux/tty.h>
  22. #include <linux/delay.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/mtd/mtd.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/timer.h>
  27. #include <linux/gpio.h>
  28. #include <linux/pda_power.h>
  29. #include <mach/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/irq.h>
  32. #include <asm/page.h>
  33. #include <asm/setup.h>
  34. #include <mach/collie.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/flash.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/serial_sa1100.h>
  39. #include <asm/hardware/scoop.h>
  40. #include <asm/mach/sharpsl_param.h>
  41. #include <asm/hardware/locomo.h>
  42. #include <mach/mcp.h>
  43. #include "generic.h"
  44. static struct resource collie_scoop_resources[] = {
  45. [0] = {
  46. .start = 0x40800000,
  47. .end = 0x40800fff,
  48. .flags = IORESOURCE_MEM,
  49. },
  50. };
  51. static struct scoop_config collie_scoop_setup = {
  52. .io_dir = COLLIE_SCOOP_IO_DIR,
  53. .io_out = COLLIE_SCOOP_IO_OUT,
  54. .gpio_base = COLLIE_SCOOP_GPIO_BASE,
  55. };
  56. struct platform_device colliescoop_device = {
  57. .name = "sharp-scoop",
  58. .id = -1,
  59. .dev = {
  60. .platform_data = &collie_scoop_setup,
  61. },
  62. .num_resources = ARRAY_SIZE(collie_scoop_resources),
  63. .resource = collie_scoop_resources,
  64. };
  65. static struct scoop_pcmcia_dev collie_pcmcia_scoop[] = {
  66. {
  67. .dev = &colliescoop_device.dev,
  68. .irq = COLLIE_IRQ_GPIO_CF_IRQ,
  69. .cd_irq = COLLIE_IRQ_GPIO_CF_CD,
  70. .cd_irq_str = "PCMCIA0 CD",
  71. },
  72. };
  73. static struct scoop_pcmcia_config collie_pcmcia_config = {
  74. .devs = &collie_pcmcia_scoop[0],
  75. .num_devs = 1,
  76. };
  77. static struct mcp_plat_data collie_mcp_data = {
  78. .mccr0 = MCCR0_ADM | MCCR0_ExtClk,
  79. .sclk_rate = 9216000,
  80. .gpio_base = COLLIE_TC35143_GPIO_BASE,
  81. };
  82. /*
  83. * Collie AC IN
  84. */
  85. static int collie_power_init(struct device *dev)
  86. {
  87. int ret = gpio_request(COLLIE_GPIO_AC_IN, "ac in");
  88. if (ret)
  89. goto err_gpio_req;
  90. ret = gpio_direction_input(COLLIE_GPIO_AC_IN);
  91. if (ret)
  92. goto err_gpio_in;
  93. return 0;
  94. err_gpio_in:
  95. gpio_free(COLLIE_GPIO_AC_IN);
  96. err_gpio_req:
  97. return ret;
  98. }
  99. static void collie_power_exit(struct device *dev)
  100. {
  101. gpio_free(COLLIE_GPIO_AC_IN);
  102. }
  103. static int collie_power_ac_online(void)
  104. {
  105. return gpio_get_value(COLLIE_GPIO_AC_IN) == 2;
  106. }
  107. static char *collie_ac_supplied_to[] = {
  108. "main-battery",
  109. "backup-battery",
  110. };
  111. static struct pda_power_pdata collie_power_data = {
  112. .init = collie_power_init,
  113. .is_ac_online = collie_power_ac_online,
  114. .exit = collie_power_exit,
  115. .supplied_to = collie_ac_supplied_to,
  116. .num_supplicants = ARRAY_SIZE(collie_ac_supplied_to),
  117. };
  118. static struct resource collie_power_resource[] = {
  119. {
  120. .name = "ac",
  121. .start = gpio_to_irq(COLLIE_GPIO_AC_IN),
  122. .end = gpio_to_irq(COLLIE_GPIO_AC_IN),
  123. .flags = IORESOURCE_IRQ |
  124. IORESOURCE_IRQ_HIGHEDGE |
  125. IORESOURCE_IRQ_LOWEDGE,
  126. },
  127. };
  128. static struct platform_device collie_power_device = {
  129. .name = "pda-power",
  130. .id = -1,
  131. .dev.platform_data = &collie_power_data,
  132. .resource = collie_power_resource,
  133. .num_resources = ARRAY_SIZE(collie_power_resource),
  134. };
  135. #ifdef CONFIG_SHARP_LOCOMO
  136. /*
  137. * low-level UART features.
  138. */
  139. struct platform_device collie_locomo_device;
  140. static void collie_uart_set_mctrl(struct uart_port *port, u_int mctrl)
  141. {
  142. if (mctrl & TIOCM_RTS)
  143. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 0);
  144. else
  145. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 1);
  146. if (mctrl & TIOCM_DTR)
  147. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 0);
  148. else
  149. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 1);
  150. }
  151. static u_int collie_uart_get_mctrl(struct uart_port *port)
  152. {
  153. int ret = TIOCM_CD;
  154. unsigned int r;
  155. r = locomo_gpio_read_output(&collie_locomo_device.dev, LOCOMO_GPIO_CTS & LOCOMO_GPIO_DSR);
  156. if (r == -ENODEV)
  157. return ret;
  158. if (r & LOCOMO_GPIO_CTS)
  159. ret |= TIOCM_CTS;
  160. if (r & LOCOMO_GPIO_DSR)
  161. ret |= TIOCM_DSR;
  162. return ret;
  163. }
  164. static struct sa1100_port_fns collie_port_fns __initdata = {
  165. .set_mctrl = collie_uart_set_mctrl,
  166. .get_mctrl = collie_uart_get_mctrl,
  167. };
  168. static int collie_uart_probe(struct locomo_dev *dev)
  169. {
  170. return 0;
  171. }
  172. static int collie_uart_remove(struct locomo_dev *dev)
  173. {
  174. return 0;
  175. }
  176. static struct locomo_driver collie_uart_driver = {
  177. .drv = {
  178. .name = "collie_uart",
  179. },
  180. .devid = LOCOMO_DEVID_UART,
  181. .probe = collie_uart_probe,
  182. .remove = collie_uart_remove,
  183. };
  184. static int __init collie_uart_init(void)
  185. {
  186. return locomo_driver_register(&collie_uart_driver);
  187. }
  188. device_initcall(collie_uart_init);
  189. #endif
  190. static struct resource locomo_resources[] = {
  191. [0] = {
  192. .start = 0x40000000,
  193. .end = 0x40001fff,
  194. .flags = IORESOURCE_MEM,
  195. },
  196. [1] = {
  197. .start = IRQ_GPIO25,
  198. .end = IRQ_GPIO25,
  199. .flags = IORESOURCE_IRQ,
  200. },
  201. };
  202. static struct locomo_platform_data locomo_info = {
  203. .irq_base = IRQ_BOARD_START,
  204. };
  205. struct platform_device collie_locomo_device = {
  206. .name = "locomo",
  207. .id = 0,
  208. .dev = {
  209. .platform_data = &locomo_info,
  210. },
  211. .num_resources = ARRAY_SIZE(locomo_resources),
  212. .resource = locomo_resources,
  213. };
  214. static struct platform_device *devices[] __initdata = {
  215. &collie_locomo_device,
  216. &colliescoop_device,
  217. &collie_power_device,
  218. };
  219. static struct mtd_partition collie_partitions[] = {
  220. {
  221. .name = "bootloader",
  222. .offset = 0,
  223. .size = 0x000C0000,
  224. .mask_flags = MTD_WRITEABLE
  225. }, {
  226. .name = "kernel",
  227. .offset = MTDPART_OFS_APPEND,
  228. .size = 0x00100000,
  229. }, {
  230. .name = "rootfs",
  231. .offset = MTDPART_OFS_APPEND,
  232. .size = 0x00e20000,
  233. }
  234. };
  235. static int collie_flash_init(void)
  236. {
  237. int rc = gpio_request(COLLIE_GPIO_VPEN, "flash Vpp enable");
  238. if (rc)
  239. return rc;
  240. rc = gpio_direction_output(COLLIE_GPIO_VPEN, 1);
  241. if (rc)
  242. gpio_free(COLLIE_GPIO_VPEN);
  243. return rc;
  244. }
  245. static void collie_set_vpp(int vpp)
  246. {
  247. gpio_set_value(COLLIE_GPIO_VPEN, vpp);
  248. }
  249. static void collie_flash_exit(void)
  250. {
  251. gpio_free(COLLIE_GPIO_VPEN);
  252. }
  253. static struct flash_platform_data collie_flash_data = {
  254. .map_name = "cfi_probe",
  255. .init = collie_flash_init,
  256. .set_vpp = collie_set_vpp,
  257. .exit = collie_flash_exit,
  258. .parts = collie_partitions,
  259. .nr_parts = ARRAY_SIZE(collie_partitions),
  260. };
  261. static struct resource collie_flash_resources[] = {
  262. {
  263. .start = SA1100_CS0_PHYS,
  264. .end = SA1100_CS0_PHYS + SZ_32M - 1,
  265. .flags = IORESOURCE_MEM,
  266. }
  267. };
  268. static void __init collie_init(void)
  269. {
  270. int ret = 0;
  271. /* cpu initialize */
  272. GAFR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SSP_CLK |
  273. GPIO_MCP_CLK | GPIO_32_768kHz;
  274. GPDR = GPIO_LDD8 | GPIO_LDD9 | GPIO_LDD10 | GPIO_LDD11 | GPIO_LDD12 |
  275. GPIO_LDD13 | GPIO_LDD14 | GPIO_LDD15 | GPIO_SSP_TXD |
  276. GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SDLC_SCLK |
  277. _COLLIE_GPIO_UCB1x00_RESET | _COLLIE_GPIO_nMIC_ON |
  278. _COLLIE_GPIO_nREMOCON_ON | GPIO_32_768kHz;
  279. PPDR = PPC_LDD0 | PPC_LDD1 | PPC_LDD2 | PPC_LDD3 | PPC_LDD4 | PPC_LDD5 |
  280. PPC_LDD6 | PPC_LDD7 | PPC_L_PCLK | PPC_L_LCLK | PPC_L_FCLK | PPC_L_BIAS |
  281. PPC_TXD1 | PPC_TXD2 | PPC_TXD3 | PPC_TXD4 | PPC_SCLK | PPC_SFRM;
  282. PWER = _COLLIE_GPIO_AC_IN | _COLLIE_GPIO_CO | _COLLIE_GPIO_ON_KEY |
  283. _COLLIE_GPIO_WAKEUP | _COLLIE_GPIO_nREMOCON_INT | PWER_RTC;
  284. PGSR = _COLLIE_GPIO_nREMOCON_ON;
  285. PSDR = PPC_RXD1 | PPC_RXD2 | PPC_RXD3 | PPC_RXD4;
  286. PCFR = PCFR_OPDE;
  287. GPSR |= _COLLIE_GPIO_UCB1x00_RESET;
  288. platform_scoop_config = &collie_pcmcia_config;
  289. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  290. if (ret) {
  291. printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
  292. }
  293. sa11x0_register_mtd(&collie_flash_data, collie_flash_resources,
  294. ARRAY_SIZE(collie_flash_resources));
  295. sa11x0_register_mcp(&collie_mcp_data);
  296. sharpsl_save_param();
  297. }
  298. static struct map_desc collie_io_desc[] __initdata = {
  299. { /* 32M main flash (cs0) */
  300. .virtual = 0xe8000000,
  301. .pfn = __phys_to_pfn(0x00000000),
  302. .length = 0x02000000,
  303. .type = MT_DEVICE
  304. }, { /* 32M boot flash (cs1) */
  305. .virtual = 0xea000000,
  306. .pfn = __phys_to_pfn(0x08000000),
  307. .length = 0x02000000,
  308. .type = MT_DEVICE
  309. }
  310. };
  311. static void __init collie_map_io(void)
  312. {
  313. sa1100_map_io();
  314. iotable_init(collie_io_desc, ARRAY_SIZE(collie_io_desc));
  315. #ifdef CONFIG_SHARP_LOCOMO
  316. sa1100_register_uart_fns(&collie_port_fns);
  317. #endif
  318. sa1100_register_uart(0, 3);
  319. sa1100_register_uart(1, 1);
  320. }
  321. MACHINE_START(COLLIE, "Sharp-Collie")
  322. .map_io = collie_map_io,
  323. .init_irq = sa1100_init_irq,
  324. .timer = &sa1100_timer,
  325. .init_machine = collie_init,
  326. MACHINE_END