^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Interface to the 93C46/56 serial EEPROM that is used to store BIOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * settings for the aic7xxx based adaptec SCSI controllers. It can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * also be used for 93C26 and 93C06 serial EEPROMS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 1994, 1995, 2000 Justin T. Gibbs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * notice, this list of conditions, and the following disclaimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * without modification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * 2. Redistributions in binary form must reproduce at minimum a disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * substantially similar to the "NO WARRANTY" disclaimer below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * ("Disclaimer") and any redistribution must be conditioned upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * including a substantially similar Disclaimer requirement for further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * binary redistribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * 3. Neither the names of the above-listed copyright holders nor the names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * of any contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * Alternatively, this software may be distributed under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * GNU General Public License ("GPL") version 2 as published by the Free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * POSSIBILITY OF SUCH DAMAGES.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * $FreeBSD$
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #ifndef _AIC7XXX_93CX6_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define _AIC7XXX_93CX6_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) C46 = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) C56_66 = 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) } seeprom_chip_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct seeprom_descriptor {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct ahc_softc *sd_ahc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u_int sd_control_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u_int sd_status_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u_int sd_dataout_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) seeprom_chip_t sd_chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) uint16_t sd_MS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) uint16_t sd_RDY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) uint16_t sd_CS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) uint16_t sd_CK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) uint16_t sd_DO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) uint16_t sd_DI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * This function will read count 16-bit words from the serial EEPROM and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * return their value in buf. The port address of the aic7xxx serial EEPROM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * control register is passed in as offset. The following parameters are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * also passed in:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * CS - Chip select
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * CK - Clock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * DO - Data out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * DI - Data in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * RDY - SEEPROM ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * MS - Memory port mode select
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * A failed read attempt returns 0, and a successful read returns 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define SEEPROM_INB(sd) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) ahc_inb(sd->sd_ahc, sd->sd_control_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define SEEPROM_OUTB(sd, value) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ahc_outb(sd->sd_ahc, sd->sd_control_offset, value); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ahc_flush_device_writes(sd->sd_ahc); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) } while(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define SEEPROM_STATUS_INB(sd) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ahc_inb(sd->sd_ahc, sd->sd_status_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define SEEPROM_DATA_INB(sd) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) ahc_inb(sd->sd_ahc, sd->sd_dataout_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u_int start_addr, u_int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) int ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) u_int start_addr, u_int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int ahc_verify_cksum(struct seeprom_config *sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #endif /* _AIC7XXX_93CX6_H_ */