board-netstar.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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/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 void __init netstar_init_irq(void)
  51. {
  52. omap_init_irq();
  53. omap_gpio_init();
  54. }
  55. static void __init netstar_init(void)
  56. {
  57. /* green LED */
  58. omap_request_gpio(4);
  59. omap_set_gpio_direction(4, 0);
  60. /* smc91x reset */
  61. omap_request_gpio(7);
  62. omap_set_gpio_direction(7, 0);
  63. omap_set_gpio_dataout(7, 1);
  64. udelay(2); /* wait at least 100ns */
  65. omap_set_gpio_dataout(7, 0);
  66. mdelay(50); /* 50ms until PHY ready */
  67. /* smc91x interrupt pin */
  68. omap_request_gpio(8);
  69. omap_request_gpio(12);
  70. omap_request_gpio(13);
  71. omap_request_gpio(14);
  72. omap_request_gpio(15);
  73. set_irq_type(OMAP_GPIO_IRQ(12), IRQT_FALLING);
  74. set_irq_type(OMAP_GPIO_IRQ(13), IRQT_FALLING);
  75. set_irq_type(OMAP_GPIO_IRQ(14), IRQT_FALLING);
  76. set_irq_type(OMAP_GPIO_IRQ(15), IRQT_FALLING);
  77. platform_add_devices(netstar_devices, ARRAY_SIZE(netstar_devices));
  78. /* Switch on green LED */
  79. omap_set_gpio_dataout(4, 0);
  80. /* Switch off red LED */
  81. omap_writeb(0x00, OMAP_LPG1_PMR); /* Disable clock */
  82. omap_writeb(0x80, OMAP_LPG1_LCR);
  83. }
  84. static int __initdata omap_serial_ports[OMAP_MAX_NR_PORTS] = {1, 1, 1};
  85. static void __init netstar_map_io(void)
  86. {
  87. omap_map_common_io();
  88. omap_serial_init(omap_serial_ports);
  89. }
  90. #define MACHINE_PANICED 1
  91. #define MACHINE_REBOOTING 2
  92. #define MACHINE_REBOOT 4
  93. static unsigned long machine_state;
  94. static int panic_event(struct notifier_block *this, unsigned long event,
  95. void *ptr)
  96. {
  97. if (test_and_set_bit(MACHINE_PANICED, &machine_state))
  98. return NOTIFY_DONE;
  99. /* Switch off green LED */
  100. omap_set_gpio_dataout(4, 1);
  101. /* Flash red LED */
  102. omap_writeb(0x78, OMAP_LPG1_LCR);
  103. omap_writeb(0x01, OMAP_LPG1_PMR); /* Enable clock */
  104. return NOTIFY_DONE;
  105. }
  106. static struct notifier_block panic_block = {
  107. .notifier_call = panic_event,
  108. };
  109. static int __init netstar_late_init(void)
  110. {
  111. /* TODO: Setup front panel switch here */
  112. /* Setup panic notifier */
  113. notifier_chain_register(&panic_notifier_list, &panic_block);
  114. return 0;
  115. }
  116. postcore_initcall(netstar_late_init);
  117. MACHINE_START(NETSTAR, "NetStar OMAP5910")
  118. /* Maintainer: Ladislav Michl <michl@2n.cz> */
  119. .phys_ram = 0x10000000,
  120. .phys_io = 0xfff00000,
  121. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  122. .boot_params = 0x10000100,
  123. .map_io = netstar_map_io,
  124. .init_irq = netstar_init_irq,
  125. .init_machine = netstar_init,
  126. .timer = &omap_timer,
  127. MACHINE_END