badge4.c 7.3 KB

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