board-voiceblue.c 7.1 KB

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