badge4.c 7.4 KB

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