Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 14 | #include <linux/config.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/irq.h> |
| 17 | #include <linux/fs.h> |
| 18 | #include <linux/module.h> |
| 19 | |
| 20 | #include <asm/machdep.h> |
| 21 | #include <asm/v850e_uart.h> |
| 22 | |
| 23 | #include "mach.h" |
| 24 | |
| 25 | static void led_tick (void); |
| 26 | |
| 27 | /* LED access routines. */ |
| 28 | extern unsigned read_leds (int pos, char *buf, int len); |
| 29 | extern unsigned write_leds (int pos, const char *buf, int len); |
| 30 | |
| 31 | #ifdef CONFIG_RTE_CB_MULTI |
| 32 | extern void multi_init (void); |
| 33 | #endif |
| 34 | |
| 35 | |
| 36 | void __init rte_cb_early_init (void) |
| 37 | { |
| 38 | v850e_intc_disable_irqs (); |
| 39 | |
| 40 | #ifdef CONFIG_RTE_CB_MULTI |
| 41 | multi_init (); |
| 42 | #endif |
| 43 | } |
| 44 | |
| 45 | void __init mach_setup (char **cmdline) |
| 46 | { |
| 47 | #ifdef CONFIG_RTE_MB_A_PCI |
| 48 | /* Probe for Mother-A, and print a message if we find it. */ |
| 49 | *(volatile unsigned long *)MB_A_SRAM_ADDR = 0xDEADBEEF; |
| 50 | if (*(volatile unsigned long *)MB_A_SRAM_ADDR == 0xDEADBEEF) { |
| 51 | *(volatile unsigned long *)MB_A_SRAM_ADDR = 0x12345678; |
| 52 | if (*(volatile unsigned long *)MB_A_SRAM_ADDR == 0x12345678) |
| 53 | printk (KERN_INFO |
| 54 | " NEC SolutionGear/Midas lab" |
| 55 | " RTE-MOTHER-A motherboard\n"); |
| 56 | } |
| 57 | #endif /* CONFIG_RTE_MB_A_PCI */ |
| 58 | |
| 59 | mach_tick = led_tick; |
| 60 | } |
| 61 | |
| 62 | void machine_restart (char *__unused) |
| 63 | { |
| 64 | #ifdef CONFIG_RESET_GUARD |
| 65 | disable_reset_guard (); |
| 66 | #endif |
| 67 | asm ("jmp r0"); /* Jump to the reset vector. */ |
| 68 | } |
| 69 | |
| 70 | EXPORT_SYMBOL(machine_restart); |
| 71 | |
| 72 | /* This says `HALt.' in LEDese. */ |
| 73 | static unsigned char halt_leds_msg[] = { 0x76, 0x77, 0x38, 0xF8 }; |
| 74 | |
| 75 | void machine_halt (void) |
| 76 | { |
| 77 | #ifdef CONFIG_RESET_GUARD |
| 78 | disable_reset_guard (); |
| 79 | #endif |
| 80 | |
| 81 | /* Ignore all interrupts. */ |
| 82 | local_irq_disable (); |
| 83 | |
| 84 | /* Write a little message. */ |
| 85 | write_leds (0, halt_leds_msg, sizeof halt_leds_msg); |
| 86 | |
| 87 | /* Really halt. */ |
| 88 | for (;;) |
| 89 | asm ("halt; nop; nop; nop; nop; nop"); |
| 90 | } |
| 91 | |
| 92 | EXPORT_SYMBOL(machine_halt); |
| 93 | |
| 94 | void machine_power_off (void) |
| 95 | { |
| 96 | machine_halt (); |
| 97 | } |
| 98 | |
| 99 | EXPORT_SYMBOL(machine_power_off); |
| 100 | |
| 101 | |
| 102 | /* Animated LED display for timer tick. */ |
| 103 | |
| 104 | #define TICK_UPD_FREQ 6 |
| 105 | static int tick_frames[][10] = { |
| 106 | { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, -1 }, |
| 107 | { 0x63, 0x5c, -1 }, |
| 108 | { 0x5c, 0x00, -1 }, |
| 109 | { 0x63, 0x00, -1 }, |
| 110 | { -1 } |
| 111 | }; |
| 112 | |
| 113 | static void led_tick () |
| 114 | { |
| 115 | static unsigned counter = 0; |
| 116 | |
| 117 | if (++counter == (HZ / TICK_UPD_FREQ)) { |
| 118 | /* Which frame we're currently displaying for each digit. */ |
| 119 | static unsigned frame_nums[LED_NUM_DIGITS] = { 0 }; |
| 120 | /* Display image. */ |
| 121 | static unsigned char image[LED_NUM_DIGITS] = { 0 }; |
| 122 | unsigned char prev_image[LED_NUM_DIGITS]; |
| 123 | int write_to_leds = 1; /* true if we should actually display */ |
| 124 | int digit; |
| 125 | |
| 126 | /* We check to see if the physical LEDs contains what we last |
| 127 | wrote to them; if not, we suppress display (this is so that |
| 128 | users can write to the LEDs, and not have their output |
| 129 | overwritten). As a special case, we start writing again if |
| 130 | all the LEDs are blank, or our display image is all zeros |
| 131 | (indicating that this is the initial update, when the actual |
| 132 | LEDs might contain random data). */ |
| 133 | read_leds (0, prev_image, LED_NUM_DIGITS); |
| 134 | for (digit = 0; digit < LED_NUM_DIGITS; digit++) |
| 135 | if (image[digit] != prev_image[digit] |
| 136 | && image[digit] && prev_image[digit]) |
| 137 | { |
| 138 | write_to_leds = 0; |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | /* Update display image. */ |
| 143 | for (digit = 0; |
| 144 | digit < LED_NUM_DIGITS && tick_frames[digit][0] >= 0; |
| 145 | digit++) |
| 146 | { |
| 147 | int frame = tick_frames[digit][frame_nums[digit]]; |
| 148 | if (frame < 0) { |
| 149 | image[digit] = tick_frames[digit][0]; |
| 150 | frame_nums[digit] = 1; |
| 151 | } else { |
| 152 | image[digit] = frame; |
| 153 | frame_nums[digit]++; |
| 154 | break; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if (write_to_leds) |
| 159 | /* Write the display image to the physical LEDs. */ |
| 160 | write_leds (0, image, LED_NUM_DIGITS); |
| 161 | |
| 162 | counter = 0; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
| 167 | /* Mother-A interrupts. */ |
| 168 | |
| 169 | #ifdef CONFIG_RTE_GBUS_INT |
| 170 | |
| 171 | #define L GBUS_INT_PRIORITY_LOW |
| 172 | #define M GBUS_INT_PRIORITY_MEDIUM |
| 173 | #define H GBUS_INT_PRIORITY_HIGH |
| 174 | |
| 175 | static struct gbus_int_irq_init gbus_irq_inits[] = { |
| 176 | #ifdef CONFIG_RTE_MB_A_PCI |
| 177 | { "MB_A_LAN", IRQ_MB_A_LAN, 1, 1, L }, |
| 178 | { "MB_A_PCI1", IRQ_MB_A_PCI1(0), IRQ_MB_A_PCI1_NUM, 1, L }, |
| 179 | { "MB_A_PCI2", IRQ_MB_A_PCI2(0), IRQ_MB_A_PCI2_NUM, 1, L }, |
| 180 | { "MB_A_EXT", IRQ_MB_A_EXT(0), IRQ_MB_A_EXT_NUM, 1, L }, |
| 181 | { "MB_A_USB_OC",IRQ_MB_A_USB_OC(0), IRQ_MB_A_USB_OC_NUM, 1, L }, |
| 182 | { "MB_A_PCMCIA_OC",IRQ_MB_A_PCMCIA_OC, 1, 1, L }, |
| 183 | #endif |
| 184 | { 0 } |
| 185 | }; |
| 186 | #define NUM_GBUS_IRQ_INITS \ |
| 187 | ((sizeof gbus_irq_inits / sizeof gbus_irq_inits[0]) - 1) |
| 188 | |
| 189 | static struct hw_interrupt_type gbus_hw_itypes[NUM_GBUS_IRQ_INITS]; |
| 190 | |
| 191 | #endif /* CONFIG_RTE_GBUS_INT */ |
| 192 | |
| 193 | |
| 194 | void __init rte_cb_init_irqs (void) |
| 195 | { |
| 196 | #ifdef CONFIG_RTE_GBUS_INT |
| 197 | gbus_int_init_irqs (); |
| 198 | gbus_int_init_irq_types (gbus_irq_inits, gbus_hw_itypes); |
| 199 | #endif /* CONFIG_RTE_GBUS_INT */ |
| 200 | } |