board-voiceblue.c 6.6 KB

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