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