/*-1* Interface to the 93C46/56 serial EEPROM that is used to store BIOS2* settings for the aic7xxx based adaptec SCSI controllers. It can3* also be used for 93C26 and 93C06 serial EEPROMS.4*5* SPDX-License-Identifier: BSD-3-Clause6*7* Copyright (c) 1994, 1995, 2000 Justin T. Gibbs.8* All rights reserved.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions, and the following disclaimer,15* without modification.16* 2. Redistributions in binary form must reproduce at minimum a disclaimer17* substantially similar to the "NO WARRANTY" disclaimer below18* ("Disclaimer") and any redistribution must be conditioned upon19* including a substantially similar Disclaimer requirement for further20* binary redistribution.21* 3. Neither the names of the above-listed copyright holders nor the names22* of any contributors may be used to endorse or promote products derived23* from this software without specific prior written permission.24*25* Alternatively, this software may be distributed under the terms of the26* GNU General Public License ("GPL") version 2 as published by the Free27* Software Foundation.28*29* NO WARRANTY30* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS31* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT32* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR33* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT34* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL35* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS36* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)37* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,38* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING39* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE40* POSSIBILITY OF SUCH DAMAGES.41*42* $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $43*/44#ifndef _AIC7XXX_93CX6_H_45#define _AIC7XXX_93CX6_H_4647typedef enum {48C46 = 6,49C56_66 = 850} seeprom_chip_t;5152struct seeprom_descriptor {53struct ahc_softc *sd_ahc;54u_int sd_control_offset;55u_int sd_status_offset;56u_int sd_dataout_offset;57seeprom_chip_t sd_chip;58uint16_t sd_MS;59uint16_t sd_RDY;60uint16_t sd_CS;61uint16_t sd_CK;62uint16_t sd_DO;63uint16_t sd_DI;64};6566/*67* This function will read count 16-bit words from the serial EEPROM and68* return their value in buf. The port address of the aic7xxx serial EEPROM69* control register is passed in as offset. The following parameters are70* also passed in:71*72* CS - Chip select73* CK - Clock74* DO - Data out75* DI - Data in76* RDY - SEEPROM ready77* MS - Memory port mode select78*79* A failed read attempt returns 0, and a successful read returns 1.80*/8182#define SEEPROM_INB(sd) \83ahc_inb(sd->sd_ahc, sd->sd_control_offset)84#define SEEPROM_OUTB(sd, value) \85do { \86ahc_outb(sd->sd_ahc, sd->sd_control_offset, value); \87ahc_flush_device_writes(sd->sd_ahc); \88} while(0)8990#define SEEPROM_STATUS_INB(sd) \91ahc_inb(sd->sd_ahc, sd->sd_status_offset)92#define SEEPROM_DATA_INB(sd) \93ahc_inb(sd->sd_ahc, sd->sd_dataout_offset)9495int ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,96u_int start_addr, u_int count);97int ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,98u_int start_addr, u_int count);99int ahc_verify_cksum(struct seeprom_config *sc);100101#endif /* _AIC7XXX_93CX6_H_ */102103104