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