badge4.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * linux/arch/arm/mach-sa1100/badge4.c
  3. *
  4. * BadgePAD 4 specific initialization
  5. *
  6. * Tim Connors <connors@hpl.hp.com>
  7. * Christopher Hoover <ch@hpl.hp.com>
  8. *
  9. * Copyright (C) 2002 Hewlett-Packard Company
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. */
  16. #include <linux/module.h>
  17. #include <linux/init.h>
  18. #include <linux/kernel.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/delay.h>
  21. #include <linux/tty.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/errno.h>
  25. #include <mach/hardware.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/setup.h>
  28. #include <mach/irqs.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/flash.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/hardware/sa1111.h>
  33. #include <asm/mach/serial_sa1100.h>
  34. #include <mach/badge4.h>
  35. #include "generic.h"
  36. static struct resource sa1111_resources[] = {
  37. [0] = {
  38. .start = BADGE4_SA1111_BASE,
  39. .end = BADGE4_SA1111_BASE + 0x00001fff,
  40. .flags = IORESOURCE_MEM,
  41. },
  42. [1] = {
  43. .start = BADGE4_IRQ_GPIO_SA1111,
  44. .end = BADGE4_IRQ_GPIO_SA1111,
  45. .flags = IORESOURCE_IRQ,
  46. },
  47. };
  48. static int badge4_sa1111_enable(void *data, unsigned devid)
  49. {
  50. if (devid == SA1111_DEVID_USB)
  51. badge4_set_5V(BADGE4_5V_USB, 1);
  52. return 0;
  53. }
  54. static void badge4_sa1111_disable(void *data, unsigned devid)
  55. {
  56. if (devid == SA1111_DEVID_USB)
  57. badge4_set_5V(BADGE4_5V_USB, 0);
  58. }
  59. static struct sa1111_platform_data sa1111_info = {
  60. .irq_base = IRQ_BOARD_END,
  61. .disable_devs = SA1111_DEVID_PS2_MSE,
  62. .enable = badge4_sa1111_enable,
  63. .disable = badge4_sa1111_disable,
  64. };
  65. static u64 sa1111_dmamask = 0xffffffffUL;
  66. static struct platform_device sa1111_device = {
  67. .name = "sa1111",
  68. .id = 0,
  69. .dev = {
  70. .dma_mask = &sa1111_dmamask,
  71. .coherent_dma_mask = 0xffffffff,
  72. .platform_data = &sa1111_info,
  73. },
  74. .num_resources = ARRAY_SIZE(sa1111_resources),
  75. .resource = sa1111_resources,
  76. };
  77. static struct platform_device *devices[] __initdata = {
  78. &sa1111_device,
  79. };
  80. static int __init badge4_sa1111_init(void)
  81. {
  82. /*
  83. * Ensure that the memory bus request/grant signals are setup,
  84. * and the grant is held in its inactive state
  85. */
  86. sa1110_mb_disable();
  87. /*
  88. * Probe for SA1111.
  89. */
  90. return platform_add_devices(devices, ARRAY_SIZE(devices));
  91. }
  92. /*
  93. * 1 x Intel 28F320C3 Advanced+ Boot Block Flash (32 Mi bit)
  94. * Eight 4 KiW Parameter Bottom Blocks (64 KiB)
  95. * Sixty-three 32 KiW Main Blocks (4032 Ki b)
  96. *
  97. * <or>
  98. *
  99. * 1 x Intel 28F640C3 Advanced+ Boot Block Flash (64 Mi bit)
  100. * Eight 4 KiW Parameter Bottom Blocks (64 KiB)
  101. * One-hundred-twenty-seven 32 KiW Main Blocks (8128 Ki b)
  102. */
  103. static struct mtd_partition badge4_partitions[] = {
  104. {
  105. .name = "BLOB boot loader",
  106. .offset = 0,
  107. .size = 0x0000A000
  108. }, {
  109. .name = "params",
  110. .offset = MTDPART_OFS_APPEND,
  111. .size = 0x00006000
  112. }, {
  113. .name = "root",
  114. .offset = MTDPART_OFS_APPEND,
  115. .size = MTDPART_SIZ_FULL
  116. }
  117. };
  118. static struct flash_platform_data badge4_flash_data = {
  119. .map_name = "cfi_probe",
  120. .parts = badge4_partitions,
  121. .nr_parts = ARRAY_SIZE(badge4_partitions),
  122. };
  123. static struct resource badge4_flash_resource = {
  124. .start = SA1100_CS0_PHYS,
  125. .end = SA1100_CS0_PHYS + SZ_64M - 1,
  126. .flags = IORESOURCE_MEM,
  127. };
  128. static int five_v_on __initdata = 0;
  129. static int __init five_v_on_setup(char *ignore)
  130. {
  131. five_v_on = 1;
  132. return 1;
  133. }
  134. __setup("five_v_on", five_v_on_setup);
  135. static int __init badge4_init(void)
  136. {
  137. int ret;
  138. if (!machine_is_badge4())
  139. return -ENODEV;
  140. /* LCD */
  141. GPCR = (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
  142. BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
  143. BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
  144. BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
  145. BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
  146. BADGE4_GPIO_GPC_VID);
  147. GPDR &= ~BADGE4_GPIO_INT_VID;
  148. GPDR |= (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
  149. BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
  150. BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
  151. BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
  152. BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
  153. BADGE4_GPIO_GPC_VID);
  154. /* SDRAM SPD i2c */
  155. GPCR = (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
  156. GPDR |= (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
  157. /* uart */
  158. GPCR = (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
  159. GPDR |= (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
  160. /* CPLD muxsel0 input for mux/adc chip select */
  161. GPCR = BADGE4_GPIO_MUXSEL0;
  162. GPDR |= BADGE4_GPIO_MUXSEL0;
  163. /* test points: J5, J6 as inputs, J7 outputs */
  164. GPDR &= ~(BADGE4_GPIO_TESTPT_J5 | BADGE4_GPIO_TESTPT_J6);
  165. GPCR = BADGE4_GPIO_TESTPT_J7;
  166. GPDR |= BADGE4_GPIO_TESTPT_J7;
  167. /* 5V supply rail. */
  168. GPCR = BADGE4_GPIO_PCMEN5V; /* initially off */
  169. GPDR |= BADGE4_GPIO_PCMEN5V;
  170. /* CPLD sdram type inputs; set up by blob */
  171. //GPDR |= (BADGE4_GPIO_SDTYP1 | BADGE4_GPIO_SDTYP0);
  172. printk(KERN_DEBUG __FILE__ ": SDRAM CPLD typ1=%d typ0=%d\n",
  173. !!(GPLR & BADGE4_GPIO_SDTYP1),
  174. !!(GPLR & BADGE4_GPIO_SDTYP0));
  175. /* SA1111 reset pin; set up by blob */
  176. //GPSR = BADGE4_GPIO_SA1111_NRST;
  177. //GPDR |= BADGE4_GPIO_SA1111_NRST;
  178. /* power management cruft */
  179. PGSR = 0;
  180. PWER = 0;
  181. PCFR = 0;
  182. PSDR = 0;
  183. PWER |= PWER_GPIO26; /* wake up on an edge from TESTPT_J5 */
  184. PWER |= PWER_RTC; /* wake up if rtc fires */
  185. /* drive sa1111_nrst during sleep */
  186. PGSR |= BADGE4_GPIO_SA1111_NRST;
  187. /* drive CPLD as is during sleep */
  188. PGSR |= (GPLR & (BADGE4_GPIO_SDTYP0|BADGE4_GPIO_SDTYP1));
  189. /* Now bring up the SA-1111. */
  190. ret = badge4_sa1111_init();
  191. if (ret < 0)
  192. printk(KERN_ERR
  193. "%s: SA-1111 initialization failed (%d)\n",
  194. __func__, ret);
  195. /* maybe turn on 5v0 from the start */
  196. badge4_set_5V(BADGE4_5V_INITIALLY, five_v_on);
  197. sa11x0_register_mtd(&badge4_flash_data, &badge4_flash_resource, 1);
  198. return 0;
  199. }
  200. arch_initcall(badge4_init);
  201. static unsigned badge4_5V_bitmap = 0;
  202. void badge4_set_5V(unsigned subsystem, int on)
  203. {
  204. unsigned long flags;
  205. unsigned old_5V_bitmap;
  206. local_irq_save(flags);
  207. old_5V_bitmap = badge4_5V_bitmap;
  208. if (on) {
  209. badge4_5V_bitmap |= subsystem;
  210. } else {
  211. badge4_5V_bitmap &= ~subsystem;
  212. }
  213. /* detect on->off and off->on transitions */
  214. if ((!old_5V_bitmap) && (badge4_5V_bitmap)) {
  215. /* was off, now on */
  216. printk(KERN_INFO "%s: enabling 5V supply rail\n", __func__);
  217. GPSR = BADGE4_GPIO_PCMEN5V;
  218. } else if ((old_5V_bitmap) && (!badge4_5V_bitmap)) {
  219. /* was on, now off */
  220. printk(KERN_INFO "%s: disabling 5V supply rail\n", __func__);
  221. GPCR = BADGE4_GPIO_PCMEN5V;
  222. }
  223. local_irq_restore(flags);
  224. }
  225. EXPORT_SYMBOL(badge4_set_5V);
  226. static struct map_desc badge4_io_desc[] __initdata = {
  227. { /* SRAM bank 1 */
  228. .virtual = 0xf1000000,
  229. .pfn = __phys_to_pfn(0x08000000),
  230. .length = 0x00100000,
  231. .type = MT_DEVICE
  232. }, { /* SRAM bank 2 */
  233. .virtual = 0xf2000000,
  234. .pfn = __phys_to_pfn(0x10000000),
  235. .length = 0x00100000,
  236. .type = MT_DEVICE
  237. }, { /* SA-1111 */
  238. .virtual = 0xf4000000,
  239. .pfn = __phys_to_pfn(0x48000000),
  240. .length = 0x00100000,
  241. .type = MT_DEVICE
  242. }
  243. };
  244. static void
  245. badge4_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  246. {
  247. if (!state) {
  248. Ser1SDCR0 |= SDCR0_UART;
  249. }
  250. }
  251. static struct sa1100_port_fns badge4_port_fns __initdata = {
  252. //.get_mctrl = badge4_get_mctrl,
  253. //.set_mctrl = badge4_set_mctrl,
  254. .pm = badge4_uart_pm,
  255. };
  256. static void __init badge4_map_io(void)
  257. {
  258. sa1100_map_io();
  259. iotable_init(badge4_io_desc, ARRAY_SIZE(badge4_io_desc));
  260. sa1100_register_uart_fns(&badge4_port_fns);
  261. sa1100_register_uart(0, 3);
  262. sa1100_register_uart(1, 1);
  263. }
  264. MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
  265. .atag_offset = 0x100,
  266. .map_io = badge4_map_io,
  267. .init_irq = sa1100_init_irq,
  268. .timer = &sa1100_timer,
  269. #ifdef CONFIG_SA1111
  270. .dma_zone_size = SZ_1M,
  271. #endif
  272. .restart = sa11x0_restart,
  273. MACHINE_END