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