board-netstar.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Modified from board-generic.c
  3. *
  4. * Copyright (C) 2004 2N Telekomunikace, Ladislav Michl <michl@2n.cz>
  5. *
  6. * Code for Netstar OMAP board.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/delay.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/init.h>
  16. #include <linux/kernel.h>
  17. #include <linux/notifier.h>
  18. #include <linux/reboot.h>
  19. #include <asm/hardware.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/arch/gpio.h>
  24. #include <asm/arch/mux.h>
  25. #include <asm/arch/usb.h>
  26. #include <asm/arch/common.h>
  27. extern void __init omap_init_time(void);
  28. extern int omap_gpio_init(void);
  29. static struct resource netstar_smc91x_resources[] = {
  30. [0] = {
  31. .start = OMAP_CS1_PHYS + 0x300,
  32. .end = OMAP_CS1_PHYS + 0x300 + 16,
  33. .flags = IORESOURCE_MEM,
  34. },
  35. [1] = {
  36. .start = OMAP_GPIO_IRQ(8),
  37. .end = OMAP_GPIO_IRQ(8),
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. static struct platform_device netstar_smc91x_device = {
  42. .name = "smc91x",
  43. .id = 0,
  44. .num_resources = ARRAY_SIZE(netstar_smc91x_resources),
  45. .resource = netstar_smc91x_resources,
  46. };
  47. static struct platform_device *netstar_devices[] __initdata = {
  48. &netstar_smc91x_device,
  49. };
  50. static struct omap_uart_config netstar_uart_config __initdata = {
  51. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  52. };
  53. static struct omap_board_config_kernel netstar_config[] = {
  54. { OMAP_TAG_UART, &netstar_uart_config },
  55. };
  56. static void __init netstar_init_irq(void)
  57. {
  58. omap_init_irq();
  59. omap_gpio_init();
  60. }
  61. static void __init netstar_init(void)
  62. {
  63. /* green LED */
  64. omap_request_gpio(4);
  65. omap_set_gpio_direction(4, 0);
  66. /* smc91x reset */
  67. omap_request_gpio(7);
  68. omap_set_gpio_direction(7, 0);
  69. omap_set_gpio_dataout(7, 1);
  70. udelay(2); /* wait at least 100ns */
  71. omap_set_gpio_dataout(7, 0);
  72. mdelay(50); /* 50ms until PHY ready */
  73. /* smc91x interrupt pin */
  74. omap_request_gpio(8);
  75. omap_request_gpio(12);
  76. omap_request_gpio(13);
  77. omap_request_gpio(14);
  78. omap_request_gpio(15);
  79. set_irq_type(OMAP_GPIO_IRQ(12), IRQT_FALLING);
  80. set_irq_type(OMAP_GPIO_IRQ(13), IRQT_FALLING);
  81. set_irq_type(OMAP_GPIO_IRQ(14), IRQT_FALLING);
  82. set_irq_type(OMAP_GPIO_IRQ(15), IRQT_FALLING);
  83. platform_add_devices(netstar_devices, ARRAY_SIZE(netstar_devices));
  84. /* Switch on green LED */
  85. omap_set_gpio_dataout(4, 0);
  86. /* Switch off red LED */
  87. omap_writeb(0x00, OMAP_LPG1_PMR); /* Disable clock */
  88. omap_writeb(0x80, OMAP_LPG1_LCR);
  89. omap_board_config = netstar_config;
  90. omap_board_config_size = ARRAY_SIZE(netstar_config);
  91. omap_serial_init();
  92. }
  93. static void __init netstar_map_io(void)
  94. {
  95. omap_map_common_io();
  96. }
  97. #define MACHINE_PANICED 1
  98. #define MACHINE_REBOOTING 2
  99. #define MACHINE_REBOOT 4
  100. static unsigned long machine_state;
  101. static int panic_event(struct notifier_block *this, unsigned long event,
  102. void *ptr)
  103. {
  104. if (test_and_set_bit(MACHINE_PANICED, &machine_state))
  105. return NOTIFY_DONE;
  106. /* Switch off green LED */
  107. omap_set_gpio_dataout(4, 1);
  108. /* Flash red LED */
  109. omap_writeb(0x78, OMAP_LPG1_LCR);
  110. omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */
  111. return NOTIFY_DONE;
  112. }
  113. static struct notifier_block panic_block = {
  114. .notifier_call = panic_event,
  115. };
  116. static int __init netstar_late_init(void)
  117. {
  118. /* TODO: Setup front panel switch here */
  119. /* Setup panic notifier */
  120. notifier_chain_register(&panic_notifier_list, &panic_block);
  121. return 0;
  122. }
  123. postcore_initcall(netstar_late_init);
  124. MACHINE_START(NETSTAR, "NetStar OMAP5910")
  125. /* Maintainer: Ladislav Michl <michl@2n.cz> */
  126. .phys_io = 0xfff00000,
  127. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  128. .boot_params = 0x10000100,
  129. .map_io = netstar_map_io,
  130. .init_irq = netstar_init_irq,
  131. .init_machine = netstar_init,
  132. .timer = &omap_timer,
  133. MACHINE_END