X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Ftc%2Ftc.c;h=4a51e56f85b6b0a3d362bdd44317c2c484c84319;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=066170aabe2e37c63b983c6efb0b82ec96d52fde;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/tc/tc.c b/drivers/tc/tc.c index 066170aab..4a51e56f8 100644 --- a/drivers/tc/tc.c +++ b/drivers/tc/tc.c @@ -8,46 +8,43 @@ * for more details. * * Copyright (c) Harald Koerfgen, 1998 + * Copyright (c) 2001, 2003, 2005 Maciej W. Rozycki */ -#include #include -#include +#include +#include +#include +#include + #include #include +#include +#include + #include +#include #include #include #include -#include -#include -#include - -#define TC_DEBUG - MODULE_LICENSE("GPL"); slot_info tc_bus[MAX_SLOT]; -static int max_tcslot; +static int num_tcslots; static tcinfo *info; -unsigned long system_base; - -extern void (*dbe_board_handler)(struct pt_regs *regs); -extern unsigned long *(*rex_slot_address)(int); -extern void *(*rex_gettcinfo)(void); - /* * Interface to the world. Read comment in include/asm-mips/tc.h. */ -int search_tc_card(char *name) +int search_tc_card(const char *name) { int slot; slot_info *sip; - for (slot = 0; slot <= max_tcslot; slot++) { + for (slot = 0; slot < num_tcslots; slot++) { sip = &tc_bus[slot]; - if ((sip->flags & FREE) && (strncmp(sip->name, name, strlen(name)) == 0)) { + if ((sip->flags & FREE) && + (strncmp(sip->name, name, strlen(name)) == 0)) { return slot; } } @@ -68,7 +65,8 @@ void claim_tc_card(int slot) void release_tc_card(int slot) { if (tc_bus[slot].flags & FREE) { - printk("release_tc_card: attempting to release a card already free\n"); + printk("release_tc_card: " + "attempting to release a card already free\n"); return; } tc_bus[slot].flags &= ~IN_USE; @@ -93,79 +91,101 @@ unsigned long get_tc_speed(void) /* * Probing for TURBOchannel modules */ -static void __init my_dbe_handler(struct pt_regs *regs) -{ - regs->cp0_epc += 4; -} - -static void __init tc_probe(unsigned long startaddr, unsigned long size, int max_slot) +static void __init tc_probe(unsigned long startaddr, unsigned long size, + int slots) { - int i, slot; + unsigned long slotaddr; + int i, slot, err; long offset; - unsigned char *module; - void (*old_be_handler)(struct pt_regs *regs); - - /* Install our exception handler temporarily */ - - old_be_handler = dbe_board_handler; - dbe_board_handler = my_dbe_handler; - for (slot = 0; slot <= max_slot; slot++) { - module = (char *)(startaddr + slot * size); - offset = -1; - if (module[OLDCARD + TC_PATTERN0] == 0x55 && module[OLDCARD + TC_PATTERN1] == 0x00 - && module[OLDCARD + TC_PATTERN2] == 0xaa && module[OLDCARD + TC_PATTERN3] == 0xff) - offset = OLDCARD; - if (module[TC_PATTERN0] == 0x55 && module[TC_PATTERN1] == 0x00 - && module[TC_PATTERN2] == 0xaa && module[TC_PATTERN3] == 0xff) - offset = 0; - - if (offset != -1) { - tc_bus[slot].base_addr = (unsigned long)module; - for(i = 0; i < 8; i++) { - tc_bus[slot].firmware[i] = module[TC_FIRM_VER + offset + 4 * i]; - tc_bus[slot].vendor[i] = module[TC_VENDOR + offset + 4 * i]; - tc_bus[slot].name[i] = module[TC_MODULE + offset + 4 * i]; + u8 pattern[4]; + volatile u8 *module; + + for (slot = 0; slot < slots; slot++) { + slotaddr = startaddr + slot * size; + module = ioremap_nocache(slotaddr, size); + BUG_ON(!module); + + offset = OLDCARD; + + err = 0; + err |= get_dbe(pattern[0], module + OLDCARD + TC_PATTERN0); + err |= get_dbe(pattern[1], module + OLDCARD + TC_PATTERN1); + err |= get_dbe(pattern[2], module + OLDCARD + TC_PATTERN2); + err |= get_dbe(pattern[3], module + OLDCARD + TC_PATTERN3); + if (err) { + iounmap(module); + continue; + } + + if (pattern[0] != 0x55 || pattern[1] != 0x00 || + pattern[2] != 0xaa || pattern[3] != 0xff) { + offset = NEWCARD; + + err = 0; + err |= get_dbe(pattern[0], module + TC_PATTERN0); + err |= get_dbe(pattern[1], module + TC_PATTERN1); + err |= get_dbe(pattern[2], module + TC_PATTERN2); + err |= get_dbe(pattern[3], module + TC_PATTERN3); + if (err) { + iounmap(module); + continue; } - tc_bus[slot].firmware[8] = 0; - tc_bus[slot].vendor[8] = 0; - tc_bus[slot].name[8] = 0; - /* - * Looks unneccesary, but we may change - * TC? in the future - */ - switch (slot) { - case 0: - tc_bus[slot].interrupt = TC0; - break; - case 1: - tc_bus[slot].interrupt = TC1; - break; - case 2: - tc_bus[slot].interrupt = TC2; - break; - /* - * Yuck! DS5000/200 onboard devices - */ - case 5: - tc_bus[slot].interrupt = SCSI_INT; - break; - case 6: - tc_bus[slot].interrupt = ETHER; - break; - default: - tc_bus[slot].interrupt = -1; - break; - } } - } - dbe_board_handler = old_be_handler; + if (pattern[0] != 0x55 || pattern[1] != 0x00 || + pattern[2] != 0xaa || pattern[3] != 0xff) { + iounmap(module); + continue; + } + + tc_bus[slot].base_addr = slotaddr; + for (i = 0; i < 8; i++) { + tc_bus[slot].firmware[i] = + module[TC_FIRM_VER + offset + 4 * i]; + tc_bus[slot].vendor[i] = + module[TC_VENDOR + offset + 4 * i]; + tc_bus[slot].name[i] = + module[TC_MODULE + offset + 4 * i]; + } + tc_bus[slot].firmware[8] = 0; + tc_bus[slot].vendor[8] = 0; + tc_bus[slot].name[8] = 0; + /* + * Looks unneccesary, but we may change + * TC? in the future + */ + switch (slot) { + case 0: + tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC0]; + break; + case 1: + tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC1]; + break; + case 2: + tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC2]; + break; + /* + * Yuck! DS5000/200 onboard devices + */ + case 5: + tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC5]; + break; + case 6: + tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC6]; + break; + default: + tc_bus[slot].interrupt = -1; + break; + } + + iounmap(module); + } } /* * the main entry */ -void __init tc_init(void) +static int __init tc_init(void) { int tc_clock; int i; @@ -173,7 +193,7 @@ void __init tc_init(void) unsigned long slot_size; if (!TURBOCHANNEL) - return; + return 0; for (i = 0; i < MAX_SLOT; i++) { tc_bus[i].base_addr = 0; @@ -184,56 +204,44 @@ void __init tc_init(void) tc_bus[i].flags = FREE; } - info = (tcinfo *) rex_gettcinfo(); - slot0addr = (unsigned long)KSEG1ADDR(rex_slot_address(0)); + info = rex_gettcinfo(); + slot0addr = CPHYSADDR((long)rex_slot_address(0)); switch (mips_machtype) { case MACH_DS5000_200: - max_tcslot = 6; + num_tcslots = 7; break; case MACH_DS5000_1XX: case MACH_DS5000_2X0: - max_tcslot = 2; + case MACH_DS5900: + num_tcslots = 3; break; case MACH_DS5000_XX: default: - max_tcslot = 1; + num_tcslots = 2; break; } tc_clock = 10000 / info->clk_period; - if (TURBOCHANNEL && info->slot_size && slot0addr) { - printk("TURBOchannel rev. %1d at %2d.%1d MHz ", info->revision, - tc_clock / 10, tc_clock % 10); - printk("(with%s parity)\n", info->parity ? "" : "out"); + if (info->slot_size && slot0addr) { + pr_info("TURBOchannel rev. %d at %d.%d MHz (with%s parity)\n", + info->revision, tc_clock / 10, tc_clock % 10, + info->parity ? "" : "out"); slot_size = info->slot_size << 20; - tc_probe(slot0addr, slot_size, max_tcslot); - - /* - * All TURBOchannel DECstations have the onboard devices - * where the (max_tcslot + 1 or 2 on DS5k/xx) Option Module - * would be. - */ - if(mips_machtype == MACH_DS5000_XX) - i = 2; - else - i = 1; - - system_base = slot0addr + slot_size * (max_tcslot + i); - -#ifdef TC_DEBUG - for (i = 0; i <= max_tcslot; i++) - if (tc_bus[i].base_addr) { - printk(" slot %d: ", i); - printk("%s %s %s\n", tc_bus[i].vendor, - tc_bus[i].name, tc_bus[i].firmware); - } -#endif - ioport_resource.end = KSEG2 - 1; + tc_probe(slot0addr, slot_size, num_tcslots); + + for (i = 0; i < num_tcslots; i++) { + if (!tc_bus[i].base_addr) + continue; + pr_info(" slot %d: %s %s %s\n", i, tc_bus[i].vendor, + tc_bus[i].name, tc_bus[i].firmware); + } } + + return 0; } subsys_initcall(tc_init); @@ -244,4 +252,3 @@ EXPORT_SYMBOL(release_tc_card); EXPORT_SYMBOL(get_tc_base_addr); EXPORT_SYMBOL(get_tc_irq_nr); EXPORT_SYMBOL(get_tc_speed); -