collie.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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@suse.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 <mach/hardware.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/irq.h>
  31. #include <asm/setup.h>
  32. #include <mach/collie.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/flash.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/serial_sa1100.h>
  37. #include <asm/hardware/scoop.h>
  38. #include <asm/mach/sharpsl_param.h>
  39. #include <asm/hardware/locomo.h>
  40. #include <mach/mcp.h>
  41. #include "generic.h"
  42. static struct resource collie_scoop_resources[] = {
  43. [0] = {
  44. .start = 0x40800000,
  45. .end = 0x40800fff,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. };
  49. static struct scoop_config collie_scoop_setup = {
  50. .io_dir = COLLIE_SCOOP_IO_DIR,
  51. .io_out = COLLIE_SCOOP_IO_OUT,
  52. .gpio_base = COLLIE_SCOOP_GPIO_BASE,
  53. };
  54. struct platform_device colliescoop_device = {
  55. .name = "sharp-scoop",
  56. .id = -1,
  57. .dev = {
  58. .platform_data = &collie_scoop_setup,
  59. },
  60. .num_resources = ARRAY_SIZE(collie_scoop_resources),
  61. .resource = collie_scoop_resources,
  62. };
  63. static struct scoop_pcmcia_dev collie_pcmcia_scoop[] = {
  64. {
  65. .dev = &colliescoop_device.dev,
  66. .irq = COLLIE_IRQ_GPIO_CF_IRQ,
  67. .cd_irq = COLLIE_IRQ_GPIO_CF_CD,
  68. .cd_irq_str = "PCMCIA0 CD",
  69. },
  70. };
  71. static struct scoop_pcmcia_config collie_pcmcia_config = {
  72. .devs = &collie_pcmcia_scoop[0],
  73. .num_devs = 1,
  74. };
  75. static struct mcp_plat_data collie_mcp_data = {
  76. .mccr0 = MCCR0_ADM | MCCR0_ExtClk,
  77. .sclk_rate = 9216000,
  78. .gpio_base = COLLIE_TC35143_GPIO_BASE,
  79. };
  80. #ifdef CONFIG_SHARP_LOCOMO
  81. /*
  82. * low-level UART features.
  83. */
  84. struct platform_device collie_locomo_device;
  85. static void collie_uart_set_mctrl(struct uart_port *port, u_int mctrl)
  86. {
  87. if (mctrl & TIOCM_RTS)
  88. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 0);
  89. else
  90. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 1);
  91. if (mctrl & TIOCM_DTR)
  92. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 0);
  93. else
  94. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 1);
  95. }
  96. static u_int collie_uart_get_mctrl(struct uart_port *port)
  97. {
  98. int ret = TIOCM_CD;
  99. unsigned int r;
  100. r = locomo_gpio_read_output(&collie_locomo_device.dev, LOCOMO_GPIO_CTS & LOCOMO_GPIO_DSR);
  101. if (r == -ENODEV)
  102. return ret;
  103. if (r & LOCOMO_GPIO_CTS)
  104. ret |= TIOCM_CTS;
  105. if (r & LOCOMO_GPIO_DSR)
  106. ret |= TIOCM_DSR;
  107. return ret;
  108. }
  109. static struct sa1100_port_fns collie_port_fns __initdata = {
  110. .set_mctrl = collie_uart_set_mctrl,
  111. .get_mctrl = collie_uart_get_mctrl,
  112. };
  113. static int collie_uart_probe(struct locomo_dev *dev)
  114. {
  115. return 0;
  116. }
  117. static int collie_uart_remove(struct locomo_dev *dev)
  118. {
  119. return 0;
  120. }
  121. static struct locomo_driver collie_uart_driver = {
  122. .drv = {
  123. .name = "collie_uart",
  124. },
  125. .devid = LOCOMO_DEVID_UART,
  126. .probe = collie_uart_probe,
  127. .remove = collie_uart_remove,
  128. };
  129. static int __init collie_uart_init(void)
  130. {
  131. return locomo_driver_register(&collie_uart_driver);
  132. }
  133. device_initcall(collie_uart_init);
  134. #endif
  135. static struct resource locomo_resources[] = {
  136. [0] = {
  137. .start = 0x40000000,
  138. .end = 0x40001fff,
  139. .flags = IORESOURCE_MEM,
  140. },
  141. [1] = {
  142. .start = IRQ_GPIO25,
  143. .end = IRQ_GPIO25,
  144. .flags = IORESOURCE_IRQ,
  145. },
  146. };
  147. struct platform_device collie_locomo_device = {
  148. .name = "locomo",
  149. .id = 0,
  150. .num_resources = ARRAY_SIZE(locomo_resources),
  151. .resource = locomo_resources,
  152. };
  153. static struct platform_device *devices[] __initdata = {
  154. &collie_locomo_device,
  155. &colliescoop_device,
  156. };
  157. static struct mtd_partition collie_partitions[] = {
  158. {
  159. .name = "bootloader",
  160. .offset = 0,
  161. .size = 0x000C0000,
  162. .mask_flags = MTD_WRITEABLE
  163. }, {
  164. .name = "kernel",
  165. .offset = MTDPART_OFS_APPEND,
  166. .size = 0x00100000,
  167. }, {
  168. .name = "rootfs",
  169. .offset = MTDPART_OFS_APPEND,
  170. .size = 0x00e20000,
  171. }
  172. };
  173. static int collie_flash_init(void)
  174. {
  175. int rc = gpio_request(COLLIE_GPIO_VPEN, "flash Vpp enable");
  176. if (rc)
  177. return rc;
  178. rc = gpio_direction_output(COLLIE_GPIO_VPEN, 1);
  179. if (rc)
  180. gpio_free(COLLIE_GPIO_VPEN);
  181. return rc;
  182. }
  183. static void collie_set_vpp(int vpp)
  184. {
  185. gpio_set_value(COLLIE_GPIO_VPEN, vpp);
  186. }
  187. static void collie_flash_exit(void)
  188. {
  189. gpio_free(COLLIE_GPIO_VPEN);
  190. }
  191. static struct flash_platform_data collie_flash_data = {
  192. .map_name = "cfi_probe",
  193. .init = collie_flash_init,
  194. .set_vpp = collie_set_vpp,
  195. .exit = collie_flash_exit,
  196. .parts = collie_partitions,
  197. .nr_parts = ARRAY_SIZE(collie_partitions),
  198. };
  199. static struct resource collie_flash_resources[] = {
  200. {
  201. .start = SA1100_CS0_PHYS,
  202. .end = SA1100_CS0_PHYS + SZ_32M - 1,
  203. .flags = IORESOURCE_MEM,
  204. }
  205. };
  206. static void __init collie_init(void)
  207. {
  208. int ret = 0;
  209. /* cpu initialize */
  210. GAFR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SSP_CLK |
  211. GPIO_MCP_CLK | GPIO_32_768kHz;
  212. GPDR = GPIO_LDD8 | GPIO_LDD9 | GPIO_LDD10 | GPIO_LDD11 | GPIO_LDD12 |
  213. GPIO_LDD13 | GPIO_LDD14 | GPIO_LDD15 | GPIO_SSP_TXD |
  214. GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SDLC_SCLK |
  215. _COLLIE_GPIO_UCB1x00_RESET | _COLLIE_GPIO_nMIC_ON |
  216. _COLLIE_GPIO_nREMOCON_ON | GPIO_32_768kHz;
  217. PPDR = PPC_LDD0 | PPC_LDD1 | PPC_LDD2 | PPC_LDD3 | PPC_LDD4 | PPC_LDD5 |
  218. PPC_LDD6 | PPC_LDD7 | PPC_L_PCLK | PPC_L_LCLK | PPC_L_FCLK | PPC_L_BIAS |
  219. PPC_TXD1 | PPC_TXD2 | PPC_TXD3 | PPC_TXD4 | PPC_SCLK | PPC_SFRM;
  220. PWER = _COLLIE_GPIO_AC_IN | _COLLIE_GPIO_CO | _COLLIE_GPIO_ON_KEY |
  221. _COLLIE_GPIO_WAKEUP | _COLLIE_GPIO_nREMOCON_INT | PWER_RTC;
  222. PGSR = _COLLIE_GPIO_nREMOCON_ON;
  223. PSDR = PPC_RXD1 | PPC_RXD2 | PPC_RXD3 | PPC_RXD4;
  224. PCFR = PCFR_OPDE;
  225. GPSR |= _COLLIE_GPIO_UCB1x00_RESET;
  226. platform_scoop_config = &collie_pcmcia_config;
  227. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  228. if (ret) {
  229. printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
  230. }
  231. sa11x0_set_flash_data(&collie_flash_data, collie_flash_resources,
  232. ARRAY_SIZE(collie_flash_resources));
  233. sa11x0_set_mcp_data(&collie_mcp_data);
  234. sharpsl_save_param();
  235. }
  236. static struct map_desc collie_io_desc[] __initdata = {
  237. { /* 32M main flash (cs0) */
  238. .virtual = 0xe8000000,
  239. .pfn = __phys_to_pfn(0x00000000),
  240. .length = 0x02000000,
  241. .type = MT_DEVICE
  242. }, { /* 32M boot flash (cs1) */
  243. .virtual = 0xea000000,
  244. .pfn = __phys_to_pfn(0x08000000),
  245. .length = 0x02000000,
  246. .type = MT_DEVICE
  247. }
  248. };
  249. static void __init collie_map_io(void)
  250. {
  251. sa1100_map_io();
  252. iotable_init(collie_io_desc, ARRAY_SIZE(collie_io_desc));
  253. #ifdef CONFIG_SHARP_LOCOMO
  254. sa1100_register_uart_fns(&collie_port_fns);
  255. #endif
  256. sa1100_register_uart(0, 3);
  257. sa1100_register_uart(1, 1);
  258. }
  259. MACHINE_START(COLLIE, "Sharp-Collie")
  260. .phys_io = 0x80000000,
  261. .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
  262. .map_io = collie_map_io,
  263. .init_irq = sa1100_init_irq,
  264. .timer = &sa1100_timer,
  265. .init_machine = collie_init,
  266. MACHINE_END