rte_cb.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * include/asm-v850/rte_cb.c -- Midas lab RTE-CB series of evaluation boards
  3. *
  4. * Copyright (C) 2001,02,03 NEC Electronics Corporation
  5. * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file COPYING in the main directory of this
  9. * archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #include <linux/config.h>
  14. #include <linux/init.h>
  15. #include <linux/irq.h>
  16. #include <linux/fs.h>
  17. #include <linux/module.h>
  18. #include <asm/machdep.h>
  19. #include <asm/v850e_uart.h>
  20. #include "mach.h"
  21. static void led_tick (void);
  22. /* LED access routines. */
  23. extern unsigned read_leds (int pos, char *buf, int len);
  24. extern unsigned write_leds (int pos, const char *buf, int len);
  25. #ifdef CONFIG_RTE_CB_MULTI
  26. extern void multi_init (void);
  27. #endif
  28. void __init rte_cb_early_init (void)
  29. {
  30. v850e_intc_disable_irqs ();
  31. #ifdef CONFIG_RTE_CB_MULTI
  32. multi_init ();
  33. #endif
  34. }
  35. void __init mach_setup (char **cmdline)
  36. {
  37. #ifdef CONFIG_RTE_MB_A_PCI
  38. /* Probe for Mother-A, and print a message if we find it. */
  39. *(volatile unsigned long *)MB_A_SRAM_ADDR = 0xDEADBEEF;
  40. if (*(volatile unsigned long *)MB_A_SRAM_ADDR == 0xDEADBEEF) {
  41. *(volatile unsigned long *)MB_A_SRAM_ADDR = 0x12345678;
  42. if (*(volatile unsigned long *)MB_A_SRAM_ADDR == 0x12345678)
  43. printk (KERN_INFO
  44. " NEC SolutionGear/Midas lab"
  45. " RTE-MOTHER-A motherboard\n");
  46. }
  47. #endif /* CONFIG_RTE_MB_A_PCI */
  48. mach_tick = led_tick;
  49. }
  50. void machine_restart (char *__unused)
  51. {
  52. #ifdef CONFIG_RESET_GUARD
  53. disable_reset_guard ();
  54. #endif
  55. asm ("jmp r0"); /* Jump to the reset vector. */
  56. }
  57. EXPORT_SYMBOL(machine_restart);
  58. /* This says `HALt.' in LEDese. */
  59. static unsigned char halt_leds_msg[] = { 0x76, 0x77, 0x38, 0xF8 };
  60. void machine_halt (void)
  61. {
  62. #ifdef CONFIG_RESET_GUARD
  63. disable_reset_guard ();
  64. #endif
  65. /* Ignore all interrupts. */
  66. local_irq_disable ();
  67. /* Write a little message. */
  68. write_leds (0, halt_leds_msg, sizeof halt_leds_msg);
  69. /* Really halt. */
  70. for (;;)
  71. asm ("halt; nop; nop; nop; nop; nop");
  72. }
  73. EXPORT_SYMBOL(machine_halt);
  74. void machine_power_off (void)
  75. {
  76. machine_halt ();
  77. }
  78. EXPORT_SYMBOL(machine_power_off);
  79. /* Animated LED display for timer tick. */
  80. #define TICK_UPD_FREQ 6
  81. static int tick_frames[][10] = {
  82. { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, -1 },
  83. { 0x63, 0x5c, -1 },
  84. { 0x5c, 0x00, -1 },
  85. { 0x63, 0x00, -1 },
  86. { -1 }
  87. };
  88. static void led_tick ()
  89. {
  90. static unsigned counter = 0;
  91. if (++counter == (HZ / TICK_UPD_FREQ)) {
  92. /* Which frame we're currently displaying for each digit. */
  93. static unsigned frame_nums[LED_NUM_DIGITS] = { 0 };
  94. /* Display image. */
  95. static unsigned char image[LED_NUM_DIGITS] = { 0 };
  96. unsigned char prev_image[LED_NUM_DIGITS];
  97. int write_to_leds = 1; /* true if we should actually display */
  98. int digit;
  99. /* We check to see if the physical LEDs contains what we last
  100. wrote to them; if not, we suppress display (this is so that
  101. users can write to the LEDs, and not have their output
  102. overwritten). As a special case, we start writing again if
  103. all the LEDs are blank, or our display image is all zeros
  104. (indicating that this is the initial update, when the actual
  105. LEDs might contain random data). */
  106. read_leds (0, prev_image, LED_NUM_DIGITS);
  107. for (digit = 0; digit < LED_NUM_DIGITS; digit++)
  108. if (image[digit] != prev_image[digit]
  109. && image[digit] && prev_image[digit])
  110. {
  111. write_to_leds = 0;
  112. break;
  113. }
  114. /* Update display image. */
  115. for (digit = 0;
  116. digit < LED_NUM_DIGITS && tick_frames[digit][0] >= 0;
  117. digit++)
  118. {
  119. int frame = tick_frames[digit][frame_nums[digit]];
  120. if (frame < 0) {
  121. image[digit] = tick_frames[digit][0];
  122. frame_nums[digit] = 1;
  123. } else {
  124. image[digit] = frame;
  125. frame_nums[digit]++;
  126. break;
  127. }
  128. }
  129. if (write_to_leds)
  130. /* Write the display image to the physical LEDs. */
  131. write_leds (0, image, LED_NUM_DIGITS);
  132. counter = 0;
  133. }
  134. }
  135. /* Mother-A interrupts. */
  136. #ifdef CONFIG_RTE_GBUS_INT
  137. #define L GBUS_INT_PRIORITY_LOW
  138. #define M GBUS_INT_PRIORITY_MEDIUM
  139. #define H GBUS_INT_PRIORITY_HIGH
  140. static struct gbus_int_irq_init gbus_irq_inits[] = {
  141. #ifdef CONFIG_RTE_MB_A_PCI
  142. { "MB_A_LAN", IRQ_MB_A_LAN, 1, 1, L },
  143. { "MB_A_PCI1", IRQ_MB_A_PCI1(0), IRQ_MB_A_PCI1_NUM, 1, L },
  144. { "MB_A_PCI2", IRQ_MB_A_PCI2(0), IRQ_MB_A_PCI2_NUM, 1, L },
  145. { "MB_A_EXT", IRQ_MB_A_EXT(0), IRQ_MB_A_EXT_NUM, 1, L },
  146. { "MB_A_USB_OC",IRQ_MB_A_USB_OC(0), IRQ_MB_A_USB_OC_NUM, 1, L },
  147. { "MB_A_PCMCIA_OC",IRQ_MB_A_PCMCIA_OC, 1, 1, L },
  148. #endif
  149. { 0 }
  150. };
  151. #define NUM_GBUS_IRQ_INITS \
  152. ((sizeof gbus_irq_inits / sizeof gbus_irq_inits[0]) - 1)
  153. static struct hw_interrupt_type gbus_hw_itypes[NUM_GBUS_IRQ_INITS];
  154. #endif /* CONFIG_RTE_GBUS_INT */
  155. void __init rte_cb_init_irqs (void)
  156. {
  157. #ifdef CONFIG_RTE_GBUS_INT
  158. gbus_int_init_irqs ();
  159. gbus_int_init_irq_types (gbus_irq_inits, gbus_hw_itypes);
  160. #endif /* CONFIG_RTE_GBUS_INT */
  161. }