board-voiceblue.c 6.8 KB

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