103 lines · c
1/*2 * Interface to the 93C46/56 serial EEPROM that is used to store BIOS3 * settings for the aic7xxx based adaptec SCSI controllers. It can4 * also be used for 93C26 and 93C06 serial EEPROMS.5 *6 * Copyright (c) 1994, 1995, 2000 Justin T. Gibbs.7 * All rights reserved.8 *9 * Redistribution and use in source and binary forms, with or without10 * modification, are permitted provided that the following conditions11 * are met:12 * 1. Redistributions of source code must retain the above copyright13 * notice, this list of conditions, and the following disclaimer,14 * without modification.15 * 2. Redistributions in binary form must reproduce at minimum a disclaimer16 * substantially similar to the "NO WARRANTY" disclaimer below17 * ("Disclaimer") and any redistribution must be conditioned upon18 * including a substantially similar Disclaimer requirement for further19 * binary redistribution.20 * 3. Neither the names of the above-listed copyright holders nor the names21 * of any contributors may be used to endorse or promote products derived22 * from this software without specific prior written permission.23 *24 * Alternatively, this software may be distributed under the terms of the25 * GNU General Public License ("GPL") version 2 as published by the Free26 * Software Foundation.27 *28 * NO WARRANTY29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT33 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE39 * POSSIBILITY OF SUCH DAMAGES.40 *41 * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $42 *43 * $FreeBSD$44 */45#ifndef _AIC7XXX_93CX6_H_46#define _AIC7XXX_93CX6_H_47 48typedef enum {49 C46 = 6,50 C56_66 = 851} seeprom_chip_t;52 53struct seeprom_descriptor {54 struct ahc_softc *sd_ahc;55 u_int sd_control_offset;56 u_int sd_status_offset;57 u_int sd_dataout_offset;58 seeprom_chip_t sd_chip;59 uint16_t sd_MS;60 uint16_t sd_RDY;61 uint16_t sd_CS;62 uint16_t sd_CK;63 uint16_t sd_DO;64 uint16_t sd_DI;65};66 67/*68 * This function will read count 16-bit words from the serial EEPROM and69 * return their value in buf. The port address of the aic7xxx serial EEPROM70 * control register is passed in as offset. The following parameters are71 * also passed in:72 *73 * CS - Chip select74 * CK - Clock75 * DO - Data out76 * DI - Data in77 * RDY - SEEPROM ready78 * MS - Memory port mode select79 *80 * A failed read attempt returns 0, and a successful read returns 1.81 */82 83#define SEEPROM_INB(sd) \84 ahc_inb(sd->sd_ahc, sd->sd_control_offset)85#define SEEPROM_OUTB(sd, value) \86do { \87 ahc_outb(sd->sd_ahc, sd->sd_control_offset, value); \88 ahc_flush_device_writes(sd->sd_ahc); \89} while(0)90 91#define SEEPROM_STATUS_INB(sd) \92 ahc_inb(sd->sd_ahc, sd->sd_status_offset)93#define SEEPROM_DATA_INB(sd) \94 ahc_inb(sd->sd_ahc, sd->sd_dataout_offset)95 96int ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,97 u_int start_addr, u_int count);98int ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,99 u_int start_addr, u_int count);100int ahc_verify_cksum(struct seeprom_config *sc);101 102#endif /* _AIC7XXX_93CX6_H_ */103