[acc25ee] | 1 | /* motorola.h |
---|
| 2 | * |
---|
| 3 | * This include file describe the data structure and the functions implemented |
---|
| 4 | * by rtems to identify motorola boards. |
---|
| 5 | * |
---|
[e79a1947] | 6 | * Copyright (C) 1999 valette@crf.canon.fr |
---|
[acc25ee] | 7 | * |
---|
| 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in found in the file LICENSE in this distribution or at |
---|
[e831de8] | 10 | * http://www.rtems.com/license/LICENSE. |
---|
[acc25ee] | 11 | * |
---|
| 12 | * $Id$ |
---|
| 13 | */ |
---|
| 14 | |
---|
[e79a1947] | 15 | #include <bsp.h> |
---|
[7657233d] | 16 | #include <bsp/motorola.h> |
---|
| 17 | #include <rtems/bspIo.h> |
---|
| 18 | #include <libcpu/io.h> |
---|
| 19 | #include <string.h> |
---|
[acc25ee] | 20 | |
---|
[3a3e0b0e] | 21 | /* |
---|
[e79a1947] | 22 | ** Board-specific table that maps interrupt names to onboard PCI |
---|
| 23 | ** peripherals as well as local PCI busses. This table is used at |
---|
[3a3e0b0e] | 24 | ** bspstart() to configure the interrupt name & pin for all devices that |
---|
| 25 | ** do not have it already specified. If the device is already |
---|
| 26 | ** configured, we leave it alone but sanity check & print a warning if |
---|
| 27 | ** we don't know about the pin/line the card gives us. |
---|
| 28 | ** |
---|
| 29 | ** bus = the bus number of the slot/device in question |
---|
| 30 | ** |
---|
| 31 | ** slot : |
---|
| 32 | ** |
---|
| 33 | ** If slot != -1, it indicates a device on the given bus in that slot |
---|
| 34 | ** is to use one of the listed interrupt names given an interrupt pin. |
---|
| 35 | ** |
---|
| 36 | ** If slot == -1, it means devices on this bus can occupy any slot- |
---|
| 37 | ** and for pci, this means the particular interrupt pin that the |
---|
| 38 | ** device signals is therefore dependent on the particular slot. To |
---|
| 39 | ** work from the slot to the interrupt pin, the swizzle table is used. |
---|
| 40 | ** Once the bus and interrupt pin is known, the correct interrupt name |
---|
| 41 | ** can be pulled from the table. The swizzle table relates the |
---|
| 42 | ** interrupt pin from the device to the particular interrupt |
---|
| 43 | ** controller interrupt pin- so it is quite reasonable for a device on |
---|
| 44 | ** bus 1 signalling interrupt pin 1 to show up at the interrupt |
---|
| 45 | ** controller as pin 4- this is why the int pin field varies for |
---|
| 46 | ** bridged pci busses. |
---|
| 47 | ** |
---|
| 48 | ** |
---|
| 49 | ** opts = bitmap of options that control the configuration of this |
---|
| 50 | ** slot/bus. |
---|
| 51 | ** |
---|
| 52 | ** pin_routes[] = array of pin & vectors that may serve this slot; |
---|
| 53 | ** |
---|
| 54 | ** pin = the pin # which delivers an interrupt on this route, A=1, |
---|
| 55 | ** B=2, C=3, D=4 |
---|
| 56 | ** |
---|
| 57 | ** int_name[4] = an array of up to 4 bsp-specific interrupt name |
---|
| 58 | ** that can be used by this route. Unused entries should be -1. |
---|
| 59 | ** The array is of primary use for slots that can be vectored thru |
---|
| 60 | ** multiple interrupt lines over the interrupt pin supplied by the |
---|
| 61 | ** record. If more than one entry is present, the most preferable |
---|
| 62 | ** should supplied first. |
---|
[6128a4a] | 63 | ** |
---|
[3a3e0b0e] | 64 | */ |
---|
| 65 | |
---|
| 66 | #define NULL_PINMAP {-1,{-1,-1,-1,-1}} |
---|
| 67 | #define NULL_INTMAP {-1,-1,-1,{}} |
---|
| 68 | |
---|
[6128a4a] | 69 | static struct _int_map mcp750_intmap[] = { |
---|
[3a3e0b0e] | 70 | |
---|
| 71 | { 0, 16, 0, {{1, {5, 19,-1,-1}}, /* pmc slot */ |
---|
| 72 | NULL_PINMAP}}, |
---|
| 73 | |
---|
| 74 | { 0, 14, 0, {{1, {10,18,-1,-1}}, /* onboard ethernet */ |
---|
| 75 | NULL_PINMAP}}, |
---|
| 76 | |
---|
| 77 | { 1, -1, 0, {{1, {24,-1,-1,-1}}, |
---|
| 78 | {2, {25,-1,-1,-1}}, |
---|
| 79 | {3, {26,-1,-1,-1}}, |
---|
| 80 | {4, {27,-1,-1,-1}}, |
---|
| 81 | NULL_PINMAP}}, |
---|
| 82 | |
---|
| 83 | NULL_INTMAP }; |
---|
| 84 | |
---|
| 85 | static struct _int_map mtx603_intmap[] = { |
---|
| 86 | |
---|
| 87 | {0, 14, 0, {{1, {10,16,-1,-1}}, /* onboard ethernet */ |
---|
| 88 | NULL_PINMAP}}, |
---|
| 89 | |
---|
| 90 | {0, 12, 0, {{1, {14,18,-1,-1}}, /* onboard scsi */ |
---|
| 91 | NULL_PINMAP}}, |
---|
| 92 | |
---|
| 93 | {0, 16, 0, {{1, {25,-1,-1,-1}}, /* pci/pmc slot 1 */ |
---|
| 94 | {2, {26,-1,-1,-1}}, |
---|
| 95 | {3, {27,-1,-1,-1}}, |
---|
| 96 | {4, {28,-1,-1,-1}}, |
---|
| 97 | NULL_PINMAP}}, |
---|
| 98 | |
---|
| 99 | {0, 17, 0, {{1, {26,-1,-1,-1}}, /* pci/pmc slot 2 */ |
---|
| 100 | {2, {27,-1,-1,-1}}, |
---|
| 101 | {3, {28,-1,-1,-1}}, |
---|
| 102 | {4, {25,-1,-1,-1}}, |
---|
| 103 | NULL_PINMAP}}, |
---|
| 104 | |
---|
| 105 | {0, 18, 0, {{1, {27,-1,-1,-1}}, /* pci slot 3 */ |
---|
| 106 | {2, {28,-1,-1,-1}}, |
---|
| 107 | {3, {25,-1,-1,-1}}, |
---|
| 108 | {4, {26,-1,-1,-1}}, |
---|
| 109 | NULL_PINMAP}}, |
---|
| 110 | |
---|
| 111 | NULL_INTMAP }; |
---|
| 112 | |
---|
[e79a1947] | 113 | static struct _int_map mvme2100_intmap[] = { |
---|
| 114 | {0, 0, 0, {{1, {16,-1,-1,-1}}, /* something shows up in slot 0 and OpenPIC */ |
---|
| 115 | /* 0 is unused. This hushes the init code. */ |
---|
| 116 | NULL_PINMAP}}, |
---|
| 117 | |
---|
| 118 | {0, 13, 0, {{1, {23,24,25,26}}, /* PCI INT[A-D]/Universe Lint[0-3] */ |
---|
| 119 | NULL_PINMAP}}, |
---|
| 120 | |
---|
| 121 | {0, 14, 0, {{1, {17,-1,-1,-1}}, /* onboard ethernet */ |
---|
| 122 | NULL_PINMAP}}, |
---|
| 123 | |
---|
| 124 | NULL_INTMAP }; |
---|
| 125 | |
---|
[3a3e0b0e] | 126 | /* |
---|
| 127 | * This table represents the standard PCI swizzle defined in the |
---|
| 128 | * PCI bus specification. Table taken from Linux 2.4.18, prep_pci.c, |
---|
| 129 | * the values in this table are interrupt_pin values (1 based). |
---|
| 130 | */ |
---|
| 131 | static unsigned char prep_pci_intpins[4][4] = |
---|
| 132 | { |
---|
| 133 | { 1, 2, 3, 4 }, /* Buses 0, 4, 8, ... */ |
---|
| 134 | { 2, 3, 4, 1 }, /* Buses 1, 5, 9, ... */ |
---|
| 135 | { 3, 4, 1, 2 }, /* Buses 2, 6, 10 ... */ |
---|
| 136 | { 4, 1, 2, 3 }, /* Buses 3, 7, 11 ... */ |
---|
| 137 | }; |
---|
| 138 | |
---|
| 139 | static int prep_pci_swizzle(int slot, int pin) |
---|
| 140 | { |
---|
| 141 | return prep_pci_intpins[ slot % 4 ][ pin-1 ]; |
---|
| 142 | } |
---|
| 143 | |
---|
[acc25ee] | 144 | typedef struct { |
---|
| 145 | /* |
---|
| 146 | * 0x100 mask assumes for Raven and Hawk boards |
---|
| 147 | * that the level/edge are set. |
---|
| 148 | * 0x200 if this board has a Hawk chip. |
---|
| 149 | */ |
---|
[3a3e0b0e] | 150 | int cpu_type; |
---|
| 151 | int base_type; |
---|
| 152 | const char *name; |
---|
| 153 | |
---|
| 154 | struct _int_map *intmap; |
---|
| 155 | int (*swizzler)(int, int); |
---|
[acc25ee] | 156 | } mot_info_t; |
---|
| 157 | |
---|
| 158 | static const mot_info_t mot_boards[] = { |
---|
[3a3e0b0e] | 159 | {0x300, 0x00, "MVME 2400", NULL, NULL}, |
---|
| 160 | {0x010, 0x00, "Genesis", NULL, NULL}, |
---|
| 161 | {0x020, 0x00, "Powerstack (Series E)", NULL, NULL}, |
---|
| 162 | {0x040, 0x00, "Blackhawk (Powerstack)", NULL, NULL}, |
---|
| 163 | {0x050, 0x00, "Omaha (PowerStack II Pro3000)", NULL, NULL}, |
---|
| 164 | {0x060, 0x00, "Utah (Powerstack II Pro4000)", NULL, NULL}, |
---|
| 165 | {0x0A0, 0x00, "Powerstack (Series EX)", NULL, NULL}, |
---|
| 166 | {0x1E0, 0xE0, "Mesquite cPCI (MCP750)", mcp750_intmap, prep_pci_swizzle}, |
---|
| 167 | {0x1E0, 0xE1, "Sitka cPCI (MCPN750)", mcp750_intmap, prep_pci_swizzle}, |
---|
| 168 | {0x1E0, 0xE2, "Mesquite cPCI (MCP750) w/ HAC", mcp750_intmap, prep_pci_swizzle}, |
---|
| 169 | {0x1E0, 0xF6, "MTX Plus", NULL, NULL}, |
---|
| 170 | {0x1E0, 0xF7, "MTX w/o Parallel Port", mtx603_intmap, prep_pci_swizzle}, |
---|
| 171 | {0x1E0, 0xF8, "MTX w/ Parallel Port", mtx603_intmap, prep_pci_swizzle}, |
---|
| 172 | {0x1E0, 0xF9, "MVME 2300", NULL, NULL}, |
---|
| 173 | {0x1E0, 0xFA, "MVME 2300SC/2600", NULL, NULL}, |
---|
| 174 | {0x1E0, 0xFB, "MVME 2600 with MVME712M", NULL, NULL}, |
---|
| 175 | {0x1E0, 0xFC, "MVME 2600/2700 with MVME761", NULL, NULL}, |
---|
| 176 | {0x1E0, 0xFD, "MVME 3600 with MVME712M", NULL, NULL}, |
---|
| 177 | {0x1E0, 0xFE, "MVME 3600 with MVME761", NULL, NULL}, |
---|
| 178 | {0x1E0, 0xFF, "MVME 1600-001 or 1600-011", NULL, NULL}, |
---|
[e79a1947] | 179 | {0x000, 0x00, ""}, /* end of probeable values for automatic scan */ |
---|
| 180 | {0x000, 0x00, "MVME 2100", mvme2100_intmap, prep_pci_swizzle}, |
---|
[acc25ee] | 181 | }; |
---|
| 182 | |
---|
| 183 | prep_t currentPrepType; |
---|
[e79a1947] | 184 | motorolaBoard currentBoard; |
---|
| 185 | |
---|
[acc25ee] | 186 | prep_t checkPrepBoardType(RESIDUAL *res) |
---|
| 187 | { |
---|
| 188 | prep_t PREP_type; |
---|
| 189 | /* figure out what kind of prep workstation we are */ |
---|
| 190 | if ( res->ResidualLength != 0 ) { |
---|
| 191 | if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) ) |
---|
| 192 | PREP_type = PREP_IBM; |
---|
| 193 | else if (!strncmp(res->VitalProductData.PrintableModel, |
---|
| 194 | "Radstone",8)){ |
---|
| 195 | PREP_type = PREP_Radstone; |
---|
| 196 | } |
---|
| 197 | else |
---|
| 198 | PREP_type = PREP_Motorola; |
---|
| 199 | } |
---|
| 200 | else /* assume motorola if no residual (netboot?) */ { |
---|
| 201 | PREP_type = PREP_Motorola; |
---|
| 202 | } |
---|
| 203 | currentPrepType = PREP_type; |
---|
| 204 | return PREP_type; |
---|
| 205 | } |
---|
| 206 | |
---|
[e79a1947] | 207 | motorolaBoard getMotorolaBoard() |
---|
[acc25ee] | 208 | { |
---|
[e79a1947] | 209 | /* |
---|
| 210 | * At least the MVME2100 does not have the CPU Type and Base Type Registers, |
---|
| 211 | * so it cannot be probed. |
---|
| 212 | * |
---|
| 213 | * NOTE: Every path must set currentBoard. |
---|
| 214 | */ |
---|
| 215 | #if defined(mvme2100) |
---|
| 216 | currentBoard = (motorolaBoard) MVME_2100; |
---|
| 217 | #else |
---|
[acc25ee] | 218 | unsigned char cpu_type; |
---|
| 219 | unsigned char base_mod; |
---|
| 220 | int entry; |
---|
| 221 | int mot_entry = -1; |
---|
| 222 | |
---|
| 223 | cpu_type = inb(MOTOROLA_CPUTYPE_REG) & 0xF0; |
---|
| 224 | base_mod = inb(MOTOROLA_BASETYPE_REG); |
---|
| 225 | |
---|
| 226 | for (entry = 0; mot_boards[entry].cpu_type != 0; entry++) { |
---|
| 227 | if ((mot_boards[entry].cpu_type & 0xff) != cpu_type) |
---|
| 228 | continue; |
---|
[6128a4a] | 229 | |
---|
[acc25ee] | 230 | if (mot_boards[entry].base_type == 0) { |
---|
| 231 | mot_entry = entry; |
---|
| 232 | break; |
---|
| 233 | } |
---|
[6128a4a] | 234 | |
---|
[acc25ee] | 235 | if (mot_boards[entry].base_type != base_mod) |
---|
| 236 | continue; |
---|
[e79a1947] | 237 | else { |
---|
[acc25ee] | 238 | mot_entry = entry; |
---|
| 239 | break; |
---|
| 240 | } |
---|
| 241 | } |
---|
| 242 | if (mot_entry == -1) { |
---|
[30a1617] | 243 | printk("Unknown motorola board Please update libbsp/powerpc/shared/motorola/motorola.c\n"); |
---|
[acc25ee] | 244 | printk("cpu_type = %x\n", (unsigned) cpu_type); |
---|
| 245 | printk("base_mod = %x\n", (unsigned) base_mod); |
---|
| 246 | currentBoard = MOTOROLA_UNKNOWN; |
---|
| 247 | return currentBoard; |
---|
| 248 | } |
---|
| 249 | currentBoard = (motorolaBoard) mot_entry; |
---|
[e79a1947] | 250 | #endif |
---|
[acc25ee] | 251 | return currentBoard; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | const char* motorolaBoardToString(motorolaBoard board) |
---|
| 255 | { |
---|
| 256 | if (board == MOTOROLA_UNKNOWN) return "Unknown motorola board"; |
---|
| 257 | return (mot_boards[board].name); |
---|
| 258 | } |
---|
| 259 | |
---|
[3a3e0b0e] | 260 | const struct _int_map *motorolaIntMap(motorolaBoard board) |
---|
| 261 | { |
---|
| 262 | if (board == MOTOROLA_UNKNOWN) return NULL; |
---|
[e79a1947] | 263 | /* printk( "IntMap board %d 0x%08x\n", board, mot_boards[board].intmap ); */ |
---|
[3a3e0b0e] | 264 | return mot_boards[board].intmap; |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | const void *motorolaIntSwizzle(motorolaBoard board) |
---|
| 268 | { |
---|
| 269 | if (board == MOTOROLA_UNKNOWN) return NULL; |
---|
| 270 | return (void *)mot_boards[board].swizzler; |
---|
| 271 | } |
---|