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