collie.c 7.2 KB

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