badge4.c 7.1 KB

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