collie.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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_data/sa11x0-serial.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/mfd/ucb1x00.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/timer.h>
  29. #include <linux/gpio_keys.h>
  30. #include <linux/input.h>
  31. #include <linux/gpio.h>
  32. #include <linux/power/gpio-charger.h>
  33. #include <video/sa1100fb.h>
  34. #include <mach/hardware.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/page.h>
  37. #include <asm/setup.h>
  38. #include <mach/collie.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/flash.h>
  41. #include <asm/mach/map.h>
  42. #include <linux/platform_data/irda-sa11x0.h>
  43. #include <asm/hardware/scoop.h>
  44. #include <asm/mach/sharpsl_param.h>
  45. #include <asm/hardware/locomo.h>
  46. #include <linux/platform_data/mfd-mcp-sa11x0.h>
  47. #include <mach/irqs.h>
  48. #include "generic.h"
  49. static struct resource collie_scoop_resources[] = {
  50. [0] = DEFINE_RES_MEM(0x40800000, SZ_4K),
  51. };
  52. static struct scoop_config collie_scoop_setup = {
  53. .io_dir = COLLIE_SCOOP_IO_DIR,
  54. .io_out = COLLIE_SCOOP_IO_OUT,
  55. .gpio_base = COLLIE_SCOOP_GPIO_BASE,
  56. };
  57. struct platform_device colliescoop_device = {
  58. .name = "sharp-scoop",
  59. .id = -1,
  60. .dev = {
  61. .platform_data = &collie_scoop_setup,
  62. },
  63. .num_resources = ARRAY_SIZE(collie_scoop_resources),
  64. .resource = collie_scoop_resources,
  65. };
  66. static struct scoop_pcmcia_dev collie_pcmcia_scoop[] = {
  67. {
  68. .dev = &colliescoop_device.dev,
  69. .irq = COLLIE_IRQ_GPIO_CF_IRQ,
  70. .cd_irq = COLLIE_IRQ_GPIO_CF_CD,
  71. .cd_irq_str = "PCMCIA0 CD",
  72. },
  73. };
  74. static struct scoop_pcmcia_config collie_pcmcia_config = {
  75. .devs = &collie_pcmcia_scoop[0],
  76. .num_devs = 1,
  77. };
  78. static struct ucb1x00_plat_data collie_ucb1x00_data = {
  79. .gpio_base = COLLIE_TC35143_GPIO_BASE,
  80. };
  81. static struct mcp_plat_data collie_mcp_data = {
  82. .mccr0 = MCCR0_ADM | MCCR0_ExtClk,
  83. .sclk_rate = 9216000,
  84. .codec_pdata = &collie_ucb1x00_data,
  85. };
  86. static int collie_ir_startup(struct device *dev)
  87. {
  88. int rc = gpio_request(COLLIE_GPIO_IR_ON, "IrDA");
  89. if (rc)
  90. return rc;
  91. rc = gpio_direction_output(COLLIE_GPIO_IR_ON, 1);
  92. if (!rc)
  93. return 0;
  94. gpio_free(COLLIE_GPIO_IR_ON);
  95. return rc;
  96. }
  97. static void collie_ir_shutdown(struct device *dev)
  98. {
  99. gpio_free(COLLIE_GPIO_IR_ON);
  100. }
  101. static int collie_ir_set_power(struct device *dev, unsigned int state)
  102. {
  103. gpio_set_value(COLLIE_GPIO_IR_ON, !state);
  104. return 0;
  105. }
  106. static struct irda_platform_data collie_ir_data = {
  107. .startup = collie_ir_startup,
  108. .shutdown = collie_ir_shutdown,
  109. .set_power = collie_ir_set_power,
  110. };
  111. /*
  112. * Collie AC IN
  113. */
  114. static char *collie_ac_supplied_to[] = {
  115. "main-battery",
  116. "backup-battery",
  117. };
  118. static struct gpio_charger_platform_data collie_power_data = {
  119. .name = "charger",
  120. .type = POWER_SUPPLY_TYPE_MAINS,
  121. .gpio = COLLIE_GPIO_AC_IN,
  122. .supplied_to = collie_ac_supplied_to,
  123. .num_supplicants = ARRAY_SIZE(collie_ac_supplied_to),
  124. };
  125. static struct platform_device collie_power_device = {
  126. .name = "gpio-charger",
  127. .id = -1,
  128. .dev.platform_data = &collie_power_data,
  129. };
  130. #ifdef CONFIG_SHARP_LOCOMO
  131. /*
  132. * low-level UART features.
  133. */
  134. struct platform_device collie_locomo_device;
  135. static void collie_uart_set_mctrl(struct uart_port *port, u_int mctrl)
  136. {
  137. if (mctrl & TIOCM_RTS)
  138. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 0);
  139. else
  140. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 1);
  141. if (mctrl & TIOCM_DTR)
  142. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 0);
  143. else
  144. locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 1);
  145. }
  146. static u_int collie_uart_get_mctrl(struct uart_port *port)
  147. {
  148. int ret = TIOCM_CD;
  149. unsigned int r;
  150. r = locomo_gpio_read_output(&collie_locomo_device.dev, LOCOMO_GPIO_CTS & LOCOMO_GPIO_DSR);
  151. if (r == -ENODEV)
  152. return ret;
  153. if (r & LOCOMO_GPIO_CTS)
  154. ret |= TIOCM_CTS;
  155. if (r & LOCOMO_GPIO_DSR)
  156. ret |= TIOCM_DSR;
  157. return ret;
  158. }
  159. static struct sa1100_port_fns collie_port_fns __initdata = {
  160. .set_mctrl = collie_uart_set_mctrl,
  161. .get_mctrl = collie_uart_get_mctrl,
  162. };
  163. static int collie_uart_probe(struct locomo_dev *dev)
  164. {
  165. return 0;
  166. }
  167. static int collie_uart_remove(struct locomo_dev *dev)
  168. {
  169. return 0;
  170. }
  171. static struct locomo_driver collie_uart_driver = {
  172. .drv = {
  173. .name = "collie_uart",
  174. },
  175. .devid = LOCOMO_DEVID_UART,
  176. .probe = collie_uart_probe,
  177. .remove = collie_uart_remove,
  178. };
  179. static int __init collie_uart_init(void)
  180. {
  181. return locomo_driver_register(&collie_uart_driver);
  182. }
  183. device_initcall(collie_uart_init);
  184. #endif
  185. static struct resource locomo_resources[] = {
  186. [0] = DEFINE_RES_MEM(0x40000000, SZ_8K),
  187. [1] = DEFINE_RES_IRQ(IRQ_GPIO25),
  188. };
  189. static struct locomo_platform_data locomo_info = {
  190. .irq_base = IRQ_BOARD_START,
  191. };
  192. struct platform_device collie_locomo_device = {
  193. .name = "locomo",
  194. .id = 0,
  195. .dev = {
  196. .platform_data = &locomo_info,
  197. },
  198. .num_resources = ARRAY_SIZE(locomo_resources),
  199. .resource = locomo_resources,
  200. };
  201. static struct gpio_keys_button collie_gpio_keys[] = {
  202. {
  203. .type = EV_PWR,
  204. .code = KEY_RESERVED,
  205. .gpio = COLLIE_GPIO_ON_KEY,
  206. .desc = "On key",
  207. .wakeup = 1,
  208. .active_low = 1,
  209. },
  210. {
  211. .type = EV_PWR,
  212. .code = KEY_WAKEUP,
  213. .gpio = COLLIE_GPIO_WAKEUP,
  214. .desc = "Sync",
  215. .wakeup = 1,
  216. .active_low = 1,
  217. },
  218. };
  219. static struct gpio_keys_platform_data collie_gpio_keys_data = {
  220. .buttons = collie_gpio_keys,
  221. .nbuttons = ARRAY_SIZE(collie_gpio_keys),
  222. };
  223. static struct platform_device collie_gpio_keys_device = {
  224. .name = "gpio-keys",
  225. .id = -1,
  226. .dev = {
  227. .platform_data = &collie_gpio_keys_data,
  228. },
  229. };
  230. static struct platform_device *devices[] __initdata = {
  231. &collie_locomo_device,
  232. &colliescoop_device,
  233. &collie_power_device,
  234. &collie_gpio_keys_device,
  235. };
  236. static struct mtd_partition collie_partitions[] = {
  237. {
  238. .name = "bootloader",
  239. .offset = 0,
  240. .size = 0x000C0000,
  241. .mask_flags = MTD_WRITEABLE
  242. }, {
  243. .name = "kernel",
  244. .offset = MTDPART_OFS_APPEND,
  245. .size = 0x00100000,
  246. }, {
  247. .name = "rootfs",
  248. .offset = MTDPART_OFS_APPEND,
  249. .size = 0x00e20000,
  250. }, {
  251. .name = "bootblock",
  252. .offset = MTDPART_OFS_APPEND,
  253. .size = 0x00020000,
  254. .mask_flags = MTD_WRITEABLE
  255. }
  256. };
  257. static int collie_flash_init(void)
  258. {
  259. int rc = gpio_request(COLLIE_GPIO_VPEN, "flash Vpp enable");
  260. if (rc)
  261. return rc;
  262. rc = gpio_direction_output(COLLIE_GPIO_VPEN, 1);
  263. if (rc)
  264. gpio_free(COLLIE_GPIO_VPEN);
  265. return rc;
  266. }
  267. static void collie_set_vpp(int vpp)
  268. {
  269. gpio_set_value(COLLIE_GPIO_VPEN, vpp);
  270. }
  271. static void collie_flash_exit(void)
  272. {
  273. gpio_free(COLLIE_GPIO_VPEN);
  274. }
  275. static struct flash_platform_data collie_flash_data = {
  276. .map_name = "cfi_probe",
  277. .init = collie_flash_init,
  278. .set_vpp = collie_set_vpp,
  279. .exit = collie_flash_exit,
  280. .parts = collie_partitions,
  281. .nr_parts = ARRAY_SIZE(collie_partitions),
  282. };
  283. static struct resource collie_flash_resources[] = {
  284. DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M),
  285. };
  286. static struct sa1100fb_mach_info collie_lcd_info = {
  287. .pixclock = 171521, .bpp = 16,
  288. .xres = 320, .yres = 240,
  289. .hsync_len = 5, .vsync_len = 1,
  290. .left_margin = 11, .upper_margin = 2,
  291. .right_margin = 30, .lower_margin = 0,
  292. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  293. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
  294. .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
  295. #ifdef CONFIG_BACKLIGHT_LOCOMO
  296. .lcd_power = locomolcd_power
  297. #endif
  298. };
  299. static void __init collie_init(void)
  300. {
  301. int ret = 0;
  302. /* cpu initialize */
  303. GAFR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SSP_CLK |
  304. GPIO_MCP_CLK | GPIO_32_768kHz;
  305. GPDR = GPIO_LDD8 | GPIO_LDD9 | GPIO_LDD10 | GPIO_LDD11 | GPIO_LDD12 |
  306. GPIO_LDD13 | GPIO_LDD14 | GPIO_LDD15 | GPIO_SSP_TXD |
  307. GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SDLC_SCLK |
  308. _COLLIE_GPIO_UCB1x00_RESET | _COLLIE_GPIO_nMIC_ON |
  309. _COLLIE_GPIO_nREMOCON_ON | GPIO_32_768kHz;
  310. PPDR = PPC_LDD0 | PPC_LDD1 | PPC_LDD2 | PPC_LDD3 | PPC_LDD4 | PPC_LDD5 |
  311. PPC_LDD6 | PPC_LDD7 | PPC_L_PCLK | PPC_L_LCLK | PPC_L_FCLK | PPC_L_BIAS |
  312. PPC_TXD1 | PPC_TXD2 | PPC_TXD3 | PPC_TXD4 | PPC_SCLK | PPC_SFRM;
  313. PWER = 0;
  314. PGSR = _COLLIE_GPIO_nREMOCON_ON;
  315. PSDR = PPC_RXD1 | PPC_RXD2 | PPC_RXD3 | PPC_RXD4;
  316. PCFR = PCFR_OPDE;
  317. GPSR |= _COLLIE_GPIO_UCB1x00_RESET;
  318. sa11x0_ppc_configure_mcp();
  319. platform_scoop_config = &collie_pcmcia_config;
  320. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  321. if (ret) {
  322. printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
  323. }
  324. sa11x0_register_lcd(&collie_lcd_info);
  325. sa11x0_register_mtd(&collie_flash_data, collie_flash_resources,
  326. ARRAY_SIZE(collie_flash_resources));
  327. sa11x0_register_mcp(&collie_mcp_data);
  328. sa11x0_register_irda(&collie_ir_data);
  329. sharpsl_save_param();
  330. }
  331. static struct map_desc collie_io_desc[] __initdata = {
  332. { /* 32M main flash (cs0) */
  333. .virtual = 0xe8000000,
  334. .pfn = __phys_to_pfn(0x00000000),
  335. .length = 0x02000000,
  336. .type = MT_DEVICE
  337. }, { /* 32M boot flash (cs1) */
  338. .virtual = 0xea000000,
  339. .pfn = __phys_to_pfn(0x08000000),
  340. .length = 0x02000000,
  341. .type = MT_DEVICE
  342. }
  343. };
  344. static void __init collie_map_io(void)
  345. {
  346. sa1100_map_io();
  347. iotable_init(collie_io_desc, ARRAY_SIZE(collie_io_desc));
  348. #ifdef CONFIG_SHARP_LOCOMO
  349. sa1100_register_uart_fns(&collie_port_fns);
  350. #endif
  351. sa1100_register_uart(0, 3);
  352. sa1100_register_uart(1, 1);
  353. }
  354. MACHINE_START(COLLIE, "Sharp-Collie")
  355. .map_io = collie_map_io,
  356. .nr_irqs = SA1100_NR_IRQS,
  357. .init_irq = sa1100_init_irq,
  358. .init_time = sa1100_timer_init,
  359. .init_machine = collie_init,
  360. .init_late = sa11x0_init_late,
  361. .restart = sa11x0_restart,
  362. MACHINE_END