diff options
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/iha.c | 79 | ||||
-rw-r--r-- | sys/dev/ic/iha.h | 16 |
2 files changed, 41 insertions, 54 deletions
diff --git a/sys/dev/ic/iha.c b/sys/dev/ic/iha.c index 9888fb4ec1e..15203a41c5c 100644 --- a/sys/dev/ic/iha.c +++ b/sys/dev/ic/iha.c @@ -1,8 +1,8 @@ -/* $OpenBSD: iha.c,v 1.7 2001/07/13 03:24:20 krw Exp $ */ +/* $OpenBSD: iha.c,v 1.8 2001/07/13 04:27:09 krw Exp $ */ /* * Initio INI-9xxxU/UW SCSI Device Driver * - * Copyright (c) 2000 Ken Westerback + * Copyright (c) 2000-2001 Ken Westerback * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,14 +91,12 @@ static const u_int8_t iha_rate_tbl[8] = { 62 /* 250ns, 4M */ }; -static struct iha_nvram iha_nvram; - u_int8_t iha_data_over_run __P((struct iha_scsi_req_q *)); void iha_push_sense_request __P((struct iha_softc *, struct iha_scsi_req_q *)); void iha_timeout __P((void *)); int iha_alloc_scbs __P((struct iha_softc *)); -void iha_read_eeprom __P((bus_space_tag_t, bus_space_handle_t)); -int iha_se2_rd_all __P((bus_space_tag_t, bus_space_handle_t)); +void iha_read_eeprom __P((bus_space_tag_t, bus_space_handle_t, + struct iha_nvram *)); void iha_se2_instr __P((bus_space_tag_t, bus_space_handle_t, u_int8_t)); u_int16_t iha_se2_rd __P((bus_space_tag_t, bus_space_handle_t, u_int8_t)); void iha_reset_scsi_bus __P((struct iha_softc *)); @@ -336,23 +334,24 @@ iha_scsi_cmd(xs) } /* - * iha_init_tulip - initialize the inic-950 card and the rest of the - * IHA_SOFTC structure supplied + * iha_init_tulip - initialize the inic-940/950 card and the rest of the + * iha_softc structure supplied */ int iha_init_tulip(sc) struct iha_softc *sc; { struct iha_scsi_req_q *pScb; - bus_space_handle_t ioh; struct iha_nvram_scsi *pScsi; + bus_space_handle_t ioh; + struct iha_nvram iha_nvram; bus_space_tag_t iot; int i, error; iot = sc->sc_iot; ioh = sc->sc_ioh; - iha_read_eeprom(iot, ioh); + iha_read_eeprom(iot, ioh, &iha_nvram); pScsi = &iha_nvram.NVM_Scsi[0]; @@ -367,7 +366,7 @@ iha_init_tulip(sc) sc->sc_link.adapter_buswidth = pScsi->NVM_SCSI_Targets; /* - * fill in the rest of the IHA_SOFTC fields + * fill in the rest of the iha_softc fields */ sc->HCS_Semaph = ~SEMAPH_IN_MAIN; sc->HCS_JSStatus0 = 0; @@ -2595,7 +2594,7 @@ iha_print_info(sc, target) /* - * iha_alloc_scbs - allocate and map the SCB's for the supplied IHA_SOFTC + * iha_alloc_scbs - allocate and map the SCB's for the supplied iha_softc */ int iha_alloc_scbs(sc) @@ -2651,27 +2650,43 @@ iha_alloc_scbs(sc) } /* - * iha_read_eeprom - read Serial EEPROM value & set to defaults - * if required. XXX - Writing does NOT work! + * iha_read_eeprom - read contents of serial EEPROM into iha_nvram pointed at + * by parameter nvram. */ void -iha_read_eeprom(iot, ioh) +iha_read_eeprom(iot, ioh, nvram) bus_space_tag_t iot; bus_space_handle_t ioh; + struct iha_nvram *nvram; { - u_int8_t gctrl; + u_int32_t chksum; + u_int16_t *np; + u_int8_t gctrl, addr; + + const int chksum_addr = offsetof(struct iha_nvram, NVM_CheckSum) / 2; /* Enable EEProm programming */ gctrl = bus_space_read_1(iot, ioh, TUL_GCTRL0) | EEPRG; bus_space_write_1(iot, ioh, TUL_GCTRL0, gctrl); /* Read EEProm */ - if (iha_se2_rd_all(iot, ioh) == 0) - panic("iha: could not read EEPROM\n"); + np = (u_int16_t *)nvram; + for (addr=0, chksum=0; addr < chksum_addr; addr++, np++) { + *np = iha_se2_rd(iot, ioh, addr); + chksum += *np; + } + + chksum &= 0x0000ffff; + nvram->NVM_CheckSum = iha_se2_rd(iot, ioh, chksum_addr); /* Disable EEProm programming */ gctrl = bus_space_read_1(iot, ioh, TUL_GCTRL0) & ~EEPRG; bus_space_write_1(iot, ioh, TUL_GCTRL0, gctrl); + + if ((nvram->NVM_Signature != SIGNATURE) + || + (nvram->NVM_CheckSum != chksum)) + panic("iha: invalid EEPROM, bad signature or checksum\n"); } /* @@ -2714,34 +2729,6 @@ iha_se2_rd(iot, ioh, addr) } /* - * iha_se2_rd_all - Read SCSI H/A config parameters from serial EEPROM - * into iha_nvram variable. - */ -int -iha_se2_rd_all(iot, ioh) - bus_space_tag_t iot; - bus_space_handle_t ioh; -{ - u_int16_t *np; - u_int32_t chksum; - u_int8_t i; - - np = (u_int16_t *)&iha_nvram; - - for (i = 0, chksum = 0; i < 31; i++, np++) { - *np = iha_se2_rd(iot, ioh, i); - chksum += *np; - } - *np = iha_se2_rd(iot, ioh, 31); /* read checksum from eeprom */ - - chksum &= 0x0000ffff; /* calculated checksum is lower 16 bits of sum */ - - return (iha_nvram.NVM_Signature == SIGNATURE) - && - (iha_nvram.NVM_CheckSum == chksum); -} - -/* * iha_se2_instr - write an octet to serial E2PROM one bit at a time */ void diff --git a/sys/dev/ic/iha.h b/sys/dev/ic/iha.h index c43ada91fbd..dcfecb3b2e3 100644 --- a/sys/dev/ic/iha.h +++ b/sys/dev/ic/iha.h @@ -1,8 +1,8 @@ -/* $OpenBSD: iha.h,v 1.5 2001/07/13 03:24:20 krw Exp $ */ +/* $OpenBSD: iha.h,v 1.6 2001/07/13 04:27:09 krw Exp $ */ /* * Initio INI-9xxxU/UW SCSI Device Driver * - * Copyright (c) 2000 Ken Westerback + * Copyright (c) 2000-2001 Ken Westerback * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -64,7 +64,7 @@ struct iha_sg_element { /* * iha_scsi_req_q - SCSI Request structure used by the - * Tulip (aka inic-950). Note that 32 + * Tulip (aka inic-940/950). Note that 32 * bit pointers and ints are assumed! */ @@ -208,7 +208,7 @@ struct iha_nvram_scsi { }; /* - * Tulip (aka ini-950) Serial EEPROM Layout + * Tulip (aka ini-940/950) Serial EEPROM Layout * */ struct iha_nvram { @@ -245,7 +245,7 @@ struct iha_nvram { }; /* - * Tulip (aka inic-950) PCI Configuration Space Initio Specific Registers + * Tulip (aka inic-940/950) PCI Configuration Space Initio Specific Registers * * Offsets 0x00 through 0x3f are the standard PCI Configuration Header * registers. @@ -256,7 +256,7 @@ struct iha_nvram { * Registers 0x50 and 0x52 always read as 0. * * The register offset names and associated bit field names are taken - * from the Init-950 Data Sheet, Version 2.1, March 1997 + * from the Inic-950 Data Sheet, Version 2.1, March 1997 */ #define TUL_GCTRL0 0x54 /* R/W Global Control 0 */ #define EEPRG 0x04 /* Enable EEPROM Programming */ @@ -277,7 +277,7 @@ struct iha_nvram { #define NVRDI 0x01 /* NVRAM Read Data */ /* - * Tulip (aka inic-950) SCSI Registers + * Tulip (aka inic-940/950) SCSI Registers */ #define TUL_STCNT0 0x80 /* R/W 24 bit SCSI Xfer Count */ #define TCNT 0x00ffffff /* SCSI Xfer Transfer Count */ @@ -381,7 +381,7 @@ struct iha_nvram { #define TUL_STEST1 0x93 /* R/W Test1 */ /* - * Tulip (aka inic-950) DMA Registers + * Tulip (aka inic-940/950) DMA Registers */ #define TUL_DXPA 0xC0 /* R/W DMA Xfer Physcl Addr 0-31*/ #define TUL_DXPAE 0xC4 /* R/W DMA Xfer Physcl Addr 32-63*/ |