board-voiceblue.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. * linux/arch/arm/mach-omap1/board-voiceblue.c
  3. *
  4. * Modified from board-generic.c
  5. *
  6. * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz>
  7. *
  8. * Code for OMAP5910 based VoiceBlue board (VoIP to GSM gateway).
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/delay.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/irq.h>
  18. #include <linux/init.h>
  19. #include <linux/kernel.h>
  20. #include <linux/mtd/physmap.h>
  21. #include <linux/notifier.h>
  22. #include <linux/reboot.h>
  23. #include <linux/serial_8250.h>
  24. #include <linux/serial_reg.h>
  25. #include <linux/smc91x.h>
  26. #include <mach/hardware.h>
  27. #include <mach/system.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include <plat/board-voiceblue.h>
  32. #include <plat/common.h>
  33. #include <mach/gpio.h>
  34. #include <plat/flash.h>
  35. #include <plat/mux.h>
  36. #include <plat/tc.h>
  37. #include <plat/usb.h>
  38. static struct plat_serial8250_port voiceblue_ports[] = {
  39. {
  40. .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x40000),
  41. .irq = OMAP_GPIO_IRQ(12),
  42. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  43. .iotype = UPIO_MEM,
  44. .regshift = 1,
  45. .uartclk = 3686400,
  46. },
  47. {
  48. .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x50000),
  49. .irq = OMAP_GPIO_IRQ(13),
  50. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  51. .iotype = UPIO_MEM,
  52. .regshift = 1,
  53. .uartclk = 3686400,
  54. },
  55. {
  56. .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x60000),
  57. .irq = OMAP_GPIO_IRQ(14),
  58. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  59. .iotype = UPIO_MEM,
  60. .regshift = 1,
  61. .uartclk = 3686400,
  62. },
  63. {
  64. .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x70000),
  65. .irq = OMAP_GPIO_IRQ(15),
  66. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  67. .iotype = UPIO_MEM,
  68. .regshift = 1,
  69. .uartclk = 3686400,
  70. },
  71. { },
  72. };
  73. static struct platform_device serial_device = {
  74. .name = "serial8250",
  75. .id = PLAT8250_DEV_PLATFORM1,
  76. .dev = {
  77. .platform_data = voiceblue_ports,
  78. },
  79. };
  80. static int __init ext_uart_init(void)
  81. {
  82. if (!machine_is_voiceblue())
  83. return -ENODEV;
  84. return platform_device_register(&serial_device);
  85. }
  86. arch_initcall(ext_uart_init);
  87. static struct physmap_flash_data voiceblue_flash_data = {
  88. .width = 2,
  89. .set_vpp = omap1_set_vpp,
  90. };
  91. static struct resource voiceblue_flash_resource = {
  92. .start = OMAP_CS0_PHYS,
  93. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  94. .flags = IORESOURCE_MEM,
  95. };
  96. static struct platform_device voiceblue_flash_device = {
  97. .name = "physmap-flash",
  98. .id = 0,
  99. .dev = {
  100. .platform_data = &voiceblue_flash_data,
  101. },
  102. .num_resources = 1,
  103. .resource = &voiceblue_flash_resource,
  104. };
  105. static struct smc91x_platdata voiceblue_smc91x_info = {
  106. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  107. .leda = RPC_LED_100_10,
  108. .ledb = RPC_LED_TX_RX,
  109. };
  110. static struct resource voiceblue_smc91x_resources[] = {
  111. [0] = {
  112. .start = OMAP_CS2_PHYS + 0x300,
  113. .end = OMAP_CS2_PHYS + 0x300 + 16,
  114. .flags = IORESOURCE_MEM,
  115. },
  116. [1] = {
  117. .start = OMAP_GPIO_IRQ(8),
  118. .end = OMAP_GPIO_IRQ(8),
  119. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  120. },
  121. };
  122. static struct platform_device voiceblue_smc91x_device = {
  123. .name = "smc91x",
  124. .id = 0,
  125. .dev = {
  126. .platform_data = &voiceblue_smc91x_info,
  127. },
  128. .num_resources = ARRAY_SIZE(voiceblue_smc91x_resources),
  129. .resource = voiceblue_smc91x_resources,
  130. };
  131. static struct platform_device *voiceblue_devices[] __initdata = {
  132. &voiceblue_flash_device,
  133. &voiceblue_smc91x_device,
  134. };
  135. static struct omap_usb_config voiceblue_usb_config __initdata = {
  136. .hmc_mode = 3,
  137. .register_host = 1,
  138. .register_dev = 1,
  139. .pins[0] = 2,
  140. .pins[1] = 6,
  141. .pins[2] = 6,
  142. };
  143. static struct omap_board_config_kernel voiceblue_config[] = {
  144. };
  145. static void __init voiceblue_init_irq(void)
  146. {
  147. omap1_init_common_hw();
  148. omap_init_irq();
  149. }
  150. static void __init voiceblue_map_io(void)
  151. {
  152. omap1_map_common_io();
  153. }
  154. #define MACHINE_PANICED 1
  155. #define MACHINE_REBOOTING 2
  156. #define MACHINE_REBOOT 4
  157. static unsigned long machine_state;
  158. static int panic_event(struct notifier_block *this, unsigned long event,
  159. void *ptr)
  160. {
  161. if (test_and_set_bit(MACHINE_PANICED, &machine_state))
  162. return NOTIFY_DONE;
  163. /* Flash power LED */
  164. omap_writeb(0x78, OMAP_LPG1_LCR);
  165. omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */
  166. return NOTIFY_DONE;
  167. }
  168. static struct notifier_block panic_block = {
  169. .notifier_call = panic_event,
  170. };
  171. static int __init voiceblue_setup(void)
  172. {
  173. if (!machine_is_voiceblue())
  174. return -ENODEV;
  175. /* Setup panic notifier */
  176. atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
  177. return 0;
  178. }
  179. postcore_initcall(voiceblue_setup);
  180. static int wdt_gpio_state;
  181. void voiceblue_wdt_enable(void)
  182. {
  183. gpio_direction_output(0, 0);
  184. gpio_set_value(0, 1);
  185. gpio_set_value(0, 0);
  186. wdt_gpio_state = 0;
  187. }
  188. void voiceblue_wdt_disable(void)
  189. {
  190. gpio_set_value(0, 0);
  191. gpio_set_value(0, 1);
  192. gpio_set_value(0, 0);
  193. gpio_direction_input(0);
  194. }
  195. void voiceblue_wdt_ping(void)
  196. {
  197. if (test_bit(MACHINE_REBOOT, &machine_state))
  198. return;
  199. wdt_gpio_state = !wdt_gpio_state;
  200. gpio_set_value(0, wdt_gpio_state);
  201. }
  202. static void voiceblue_reset(char mode, const char *cmd)
  203. {
  204. /*
  205. * Workaround for 5912/1611b bug mentioned in sprz209d.pdf p. 28
  206. * "Global Software Reset Affects Traffic Controller Frequency".
  207. */
  208. if (cpu_is_omap5912()) {
  209. omap_writew(omap_readw(DPLL_CTL) & ~(1 << 4), DPLL_CTL);
  210. omap_writew(0x8, ARM_RSTCT1);
  211. }
  212. set_bit(MACHINE_REBOOT, &machine_state);
  213. voiceblue_wdt_enable();
  214. while (1) ;
  215. }
  216. EXPORT_SYMBOL(voiceblue_wdt_enable);
  217. EXPORT_SYMBOL(voiceblue_wdt_disable);
  218. EXPORT_SYMBOL(voiceblue_wdt_ping);
  219. static void __init voiceblue_init(void)
  220. {
  221. /* mux pins for uarts */
  222. omap_cfg_reg(UART1_TX);
  223. omap_cfg_reg(UART1_RTS);
  224. omap_cfg_reg(UART2_TX);
  225. omap_cfg_reg(UART2_RTS);
  226. omap_cfg_reg(UART3_TX);
  227. omap_cfg_reg(UART3_RX);
  228. /* Watchdog */
  229. gpio_request(0, "Watchdog");
  230. /* smc91x reset */
  231. gpio_request(7, "SMC91x reset");
  232. gpio_direction_output(7, 1);
  233. udelay(2); /* wait at least 100ns */
  234. gpio_set_value(7, 0);
  235. mdelay(50); /* 50ms until PHY ready */
  236. /* smc91x interrupt pin */
  237. gpio_request(8, "SMC91x irq");
  238. /* 16C554 reset*/
  239. gpio_request(6, "16C554 reset");
  240. gpio_direction_output(6, 0);
  241. /* 16C554 interrupt pins */
  242. gpio_request(12, "16C554 irq");
  243. gpio_request(13, "16C554 irq");
  244. gpio_request(14, "16C554 irq");
  245. gpio_request(15, "16C554 irq");
  246. irq_set_irq_type(gpio_to_irq(12), IRQ_TYPE_EDGE_RISING);
  247. irq_set_irq_type(gpio_to_irq(13), IRQ_TYPE_EDGE_RISING);
  248. irq_set_irq_type(gpio_to_irq(14), IRQ_TYPE_EDGE_RISING);
  249. irq_set_irq_type(gpio_to_irq(15), IRQ_TYPE_EDGE_RISING);
  250. platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices));
  251. omap_board_config = voiceblue_config;
  252. omap_board_config_size = ARRAY_SIZE(voiceblue_config);
  253. omap_serial_init();
  254. omap1_usb_init(&voiceblue_usb_config);
  255. omap_register_i2c_bus(1, 100, NULL, 0);
  256. /* There is a good chance board is going up, so enable power LED
  257. * (it is connected through invertor) */
  258. omap_writeb(0x00, OMAP_LPG1_LCR);
  259. omap_writeb(0x00, OMAP_LPG1_PMR); /* Disable clock */
  260. arch_reset = voiceblue_reset;
  261. }
  262. MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910")
  263. /* Maintainer: Ladislav Michl <michl@2n.cz> */
  264. .boot_params = 0x10000100,
  265. .map_io = voiceblue_map_io,
  266. .reserve = omap_reserve,
  267. .init_irq = voiceblue_init_irq,
  268. .init_machine = voiceblue_init,
  269. .timer = &omap_timer,
  270. MACHINE_END