12 #define __EXTERN_INLINE
15 #undef __EXTERN_INLINE
17 #include <linux/types.h>
18 #include <linux/pci.h>
19 #include <linux/sched.h>
22 #include <asm/ptrace.h>
23 #include <asm/delay.h>
30 #define DEBUG_PRINT_INITIAL_SETTINGS 0
33 #define DEBUG_PRINT_FINAL_SETTINGS 0
46 #define T2_DIRECTMAP_2G 1
49 # define T2_DIRECTMAP_START 0x80000000UL
50 # define T2_DIRECTMAP_LENGTH 0x80000000UL
52 # define T2_DIRECTMAP_START 0x40000000UL
53 # define T2_DIRECTMAP_LENGTH 0x40000000UL
57 #define T2_ISA_SG_START 0x00800000UL
58 #define T2_ISA_SG_LENGTH 0x00800000UL
70 #define DEBUG_CONFIG 0
73 # define DBG(args) printk args
78 static volatile unsigned int t2_mcheck_any_expected;
79 static volatile unsigned int t2_mcheck_last_taken;
140 mk_conf_addr(
struct pci_bus *pbus,
unsigned int device_fn,
int where,
141 unsigned long *
pci_addr,
unsigned char *type1)
146 DBG((
"mk_conf_addr(bus=%d, dfn=0x%x, where=0x%x,"
147 " addr=0x%lx, type1=0x%x)\n",
148 bus, device_fn, where, pci_addr, type1));
151 int device = device_fn >> 3;
156 DBG((
"mk_conf_addr: device (%d)>20, returning -1\n",
162 addr = (0x0800
L << device) | ((device_fn & 7) << 8) | (where);
166 addr = (bus << 16) | (device_fn << 8) | (where);
169 DBG((
"mk_conf_addr: returning pci_addr 0x%lx\n", addr));
180 conf_read(
unsigned long addr,
unsigned char type1)
183 unsigned long t2_cfg = 0;
187 DBG((
"conf_read(addr=0x%lx, type1=%d)\n", addr, type1));
200 t2_mcheck_any_expected |= (1 <<
cpu);
216 t2_mcheck_last_taken |= (1 <<
cpu);
221 t2_mcheck_any_expected = 0;
234 conf_write(
unsigned long addr,
unsigned int value,
unsigned char type1)
236 unsigned int cpu, taken;
237 unsigned long t2_cfg = 0;
252 t2_mcheck_any_expected |= (1 <<
cpu);
268 t2_mcheck_last_taken |= (1 <<
cpu);
272 t2_mcheck_any_expected = 0;
283 t2_read_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
291 if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
294 mask = (size - 1) * 8;
295 shift = (where & 3) * 8;
296 addr = (pci_addr << 5) + mask +
T2_CONF;
297 *value =
conf_read(addr, type1) >> (shift);
302 t2_write_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
int size,
309 if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
312 mask = (size - 1) * 8;
313 addr = (pci_addr << 5) + mask +
T2_CONF;
314 conf_write(addr, value << ((where & 3) * 8), type1);
320 .read = t2_read_config,
321 .write = t2_write_config,
325 t2_direct_map_window1(
unsigned long base,
unsigned long length)
332 temp = (base & 0xfff00000
UL) | ((base + length - 1) >> 20);
334 temp = (length - 1) & 0xfff00000UL;
338 #if DEBUG_PRINT_FINAL_SETTINGS
339 printk(
"%s: setting WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n",
347 unsigned long length)
356 temp = (base & 0xfff00000
UL) | ((base + length - 1) >> 20);
358 temp = (length - 1) & 0xfff00000UL;
365 #if DEBUG_PRINT_FINAL_SETTINGS
366 printk(
"%s: setting WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n",
372 t2_save_configuration(
void)
374 #if DEBUG_PRINT_INITIAL_SETTINGS
381 printk(
"%s: WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n", __func__,
383 printk(
"%s: WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n", __func__,
390 t2_saved_config.window[0].wbase = *(
vulp)T2_WBASE1;
391 t2_saved_config.window[0].wmask = *(
vulp)T2_WMASK1;
393 t2_saved_config.window[1].wbase = *(
vulp)T2_WBASE2;
394 t2_saved_config.window[1].wmask = *(
vulp)T2_WMASK2;
397 t2_saved_config.hae_1 =
srm_hae;
412 for (i = 0; i <
NR_CPUS; i++) {
416 t2_mcheck_any_expected = 0;
417 t2_mcheck_last_taken = 0;
421 if (!(temp & (0x1UL << 26))) {
422 printk(
"t2_init_arch: enabling SG TLB, IOCSR was 0x%lx\n",
429 t2_save_configuration();
442 hose->mem_space = hae_mem;
447 hose->sparse_io_base =
T2_IO - IDENT_ADDR;
448 hose->dense_io_base = 0;
487 *(
vulp)T2_WBASE1 = t2_saved_config.window[0].wbase;
488 *(
vulp)T2_WMASK1 = t2_saved_config.window[0].wmask;
490 *(
vulp)T2_WBASE2 = t2_saved_config.window[1].wbase;
507 unsigned long t2_iocsr;
522 #define SIC_SEIC (1UL << 33)
525 t2_clear_errors(
int cpu)
535 cpu_regs->
cbe |= cpu_regs->
cbe;
559 #ifdef CONFIG_VERBOSE_MCHECK
567 t2_clear_errors(cpu);
582 #ifdef CONFIG_VERBOSE_MCHECK
583 if (alpha_verbose_mcheck > 1) {
584 printk(
"t2_machine_check(cpu%d): any_expected 0x%x -"
585 " (assumed) spurious -"
586 " code 0x%x\n", cpu, t2_mcheck_any_expected,
587 (
unsigned int)mchk_header->
code);
594 if (t2_mcheck_last_taken & (1 << cpu)) {
595 #ifdef CONFIG_VERBOSE_MCHECK
596 if (alpha_verbose_mcheck > 1) {
597 printk(
"t2_machine_check(cpu%d): last_taken 0x%x - "
598 "unexpected mcheck - code 0x%x\n",
599 cpu, t2_mcheck_last_taken,
600 (
unsigned int)mchk_header->
code);
603 t2_mcheck_last_taken = 0;
607 t2_mcheck_last_taken = 0;
612 #ifdef CONFIG_VERBOSE_MCHECK
613 if (alpha_verbose_mcheck > 1) {
614 printk(
"%s t2_mcheck(cpu%d): last_taken 0x%x - "
615 "any_expected 0x%x - code 0x%x\n",
617 t2_mcheck_last_taken, t2_mcheck_any_expected,
618 (
unsigned int)mchk_header->
code);