1139749Simp/*- 265942Sgibbs * Interface to the 93C46/56 serial EEPROM that is used to store BIOS 339220Sgibbs * settings for the aic7xxx based adaptec SCSI controllers. It can 439220Sgibbs * also be used for 93C26 and 93C06 serial EEPROMS. 539220Sgibbs * 665942Sgibbs * Copyright (c) 1994, 1995, 2000 Justin T. Gibbs. 739220Sgibbs * All rights reserved. 839220Sgibbs * 939220Sgibbs * Redistribution and use in source and binary forms, with or without 1039220Sgibbs * modification, are permitted provided that the following conditions 1139220Sgibbs * are met: 1239220Sgibbs * 1. Redistributions of source code must retain the above copyright 1339220Sgibbs * notice, this list of conditions, and the following disclaimer, 1456980Sgibbs * without modification. 1595378Sgibbs * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1695378Sgibbs * substantially similar to the "NO WARRANTY" disclaimer below 1795378Sgibbs * ("Disclaimer") and any redistribution must be conditioned upon 1895378Sgibbs * including a substantially similar Disclaimer requirement for further 1995378Sgibbs * binary redistribution. 2095378Sgibbs * 3. Neither the names of the above-listed copyright holders nor the names 2195378Sgibbs * of any contributors may be used to endorse or promote products derived 2295378Sgibbs * from this software without specific prior written permission. 2339220Sgibbs * 2456980Sgibbs * Alternatively, this software may be distributed under the terms of the 2595378Sgibbs * GNU General Public License ("GPL") version 2 as published by the Free 2695378Sgibbs * Software Foundation. 2739220Sgibbs * 2895378Sgibbs * NO WARRANTY 2995378Sgibbs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3095378Sgibbs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3195378Sgibbs * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3295378Sgibbs * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3395378Sgibbs * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3439220Sgibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3539220Sgibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3695378Sgibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3795378Sgibbs * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 3895378Sgibbs * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3995378Sgibbs * POSSIBILITY OF SUCH DAMAGES. 4039220Sgibbs * 41102677Sgibbs * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $ 4265942Sgibbs * 4350477Speter * $FreeBSD$ 4439220Sgibbs */ 4565942Sgibbs#ifndef _AIC7XXX_93CX6_H_ 4665942Sgibbs#define _AIC7XXX_93CX6_H_ 4739220Sgibbs 4839220Sgibbstypedef enum { 4939220Sgibbs C46 = 6, 5039220Sgibbs C56_66 = 8 5139220Sgibbs} seeprom_chip_t; 5239220Sgibbs 5339220Sgibbsstruct seeprom_descriptor { 5465942Sgibbs struct ahc_softc *sd_ahc; 5565942Sgibbs u_int sd_control_offset; 5665942Sgibbs u_int sd_status_offset; 5765942Sgibbs u_int sd_dataout_offset; 5839220Sgibbs seeprom_chip_t sd_chip; 5963457Sgibbs uint16_t sd_MS; 6063457Sgibbs uint16_t sd_RDY; 6163457Sgibbs uint16_t sd_CS; 6263457Sgibbs uint16_t sd_CK; 6363457Sgibbs uint16_t sd_DO; 6463457Sgibbs uint16_t sd_DI; 6539220Sgibbs}; 6639220Sgibbs 6739220Sgibbs/* 6839220Sgibbs * This function will read count 16-bit words from the serial EEPROM and 6939220Sgibbs * return their value in buf. The port address of the aic7xxx serial EEPROM 7039220Sgibbs * control register is passed in as offset. The following parameters are 7139220Sgibbs * also passed in: 7239220Sgibbs * 7339220Sgibbs * CS - Chip select 7439220Sgibbs * CK - Clock 7539220Sgibbs * DO - Data out 7639220Sgibbs * DI - Data in 7739220Sgibbs * RDY - SEEPROM ready 7839220Sgibbs * MS - Memory port mode select 7939220Sgibbs * 8039220Sgibbs * A failed read attempt returns 0, and a successful read returns 1. 8139220Sgibbs */ 8239220Sgibbs 8339220Sgibbs#define SEEPROM_INB(sd) \ 8465942Sgibbs ahc_inb(sd->sd_ahc, sd->sd_control_offset) 8565942Sgibbs#define SEEPROM_OUTB(sd, value) \ 8665942Sgibbsdo { \ 8765942Sgibbs ahc_outb(sd->sd_ahc, sd->sd_control_offset, value); \ 8865942Sgibbs ahc_flush_device_writes(sd->sd_ahc); \ 8965942Sgibbs} while(0) 9065942Sgibbs 9139220Sgibbs#define SEEPROM_STATUS_INB(sd) \ 9265942Sgibbs ahc_inb(sd->sd_ahc, sd->sd_status_offset) 9339220Sgibbs#define SEEPROM_DATA_INB(sd) \ 9465942Sgibbs ahc_inb(sd->sd_ahc, sd->sd_dataout_offset) 9539220Sgibbs 9695378Sgibbsint ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, 9795378Sgibbs u_int start_addr, u_int count); 9895378Sgibbsint ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, 9995378Sgibbs u_int start_addr, u_int count); 10095378Sgibbsint ahc_verify_cksum(struct seeprom_config *sc); 10139220Sgibbs 10265942Sgibbs#endif /* _AIC7XXX_93CX6_H_ */ 103