xref: /freebsd/sys/dev/aic7xxx/aic7xxx_93cx6.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1098ca2bdSWarner Losh /*-
2717d4247SJustin T. Gibbs  * Interface to the 93C46/56 serial EEPROM that is used to store BIOS
33bafc9d4SJustin T. Gibbs  * settings for the aic7xxx based adaptec SCSI controllers.  It can
43bafc9d4SJustin T. Gibbs  * also be used for 93C26 and 93C06 serial EEPROMS.
53bafc9d4SJustin T. Gibbs  *
6*718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
7*718cf2ccSPedro F. Giffuni  *
8717d4247SJustin T. Gibbs  * Copyright (c) 1994, 1995, 2000 Justin T. Gibbs.
93bafc9d4SJustin T. Gibbs  * All rights reserved.
103bafc9d4SJustin T. Gibbs  *
113bafc9d4SJustin T. Gibbs  * Redistribution and use in source and binary forms, with or without
123bafc9d4SJustin T. Gibbs  * modification, are permitted provided that the following conditions
133bafc9d4SJustin T. Gibbs  * are met:
143bafc9d4SJustin T. Gibbs  * 1. Redistributions of source code must retain the above copyright
153bafc9d4SJustin T. Gibbs  *    notice, this list of conditions, and the following disclaimer,
1631fef9fbSJustin T. Gibbs  *    without modification.
178f214efcSJustin T. Gibbs  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
188f214efcSJustin T. Gibbs  *    substantially similar to the "NO WARRANTY" disclaimer below
198f214efcSJustin T. Gibbs  *    ("Disclaimer") and any redistribution must be conditioned upon
208f214efcSJustin T. Gibbs  *    including a substantially similar Disclaimer requirement for further
218f214efcSJustin T. Gibbs  *    binary redistribution.
228f214efcSJustin T. Gibbs  * 3. Neither the names of the above-listed copyright holders nor the names
238f214efcSJustin T. Gibbs  *    of any contributors may be used to endorse or promote products derived
248f214efcSJustin T. Gibbs  *    from this software without specific prior written permission.
253bafc9d4SJustin T. Gibbs  *
2631fef9fbSJustin T. Gibbs  * Alternatively, this software may be distributed under the terms of the
278f214efcSJustin T. Gibbs  * GNU General Public License ("GPL") version 2 as published by the Free
288f214efcSJustin T. Gibbs  * Software Foundation.
293bafc9d4SJustin T. Gibbs  *
308f214efcSJustin T. Gibbs  * NO WARRANTY
318f214efcSJustin T. Gibbs  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
328f214efcSJustin T. Gibbs  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
338f214efcSJustin T. Gibbs  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
348f214efcSJustin T. Gibbs  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
358f214efcSJustin T. Gibbs  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
363bafc9d4SJustin T. Gibbs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
373bafc9d4SJustin T. Gibbs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
388f214efcSJustin T. Gibbs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
398f214efcSJustin T. Gibbs  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
408f214efcSJustin T. Gibbs  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
418f214efcSJustin T. Gibbs  * POSSIBILITY OF SUCH DAMAGES.
423bafc9d4SJustin T. Gibbs  *
436c746b27SJustin T. Gibbs  * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $
443bafc9d4SJustin T. Gibbs  */
45717d4247SJustin T. Gibbs #ifndef _AIC7XXX_93CX6_H_
46717d4247SJustin T. Gibbs #define _AIC7XXX_93CX6_H_
473bafc9d4SJustin T. Gibbs 
483bafc9d4SJustin T. Gibbs typedef enum {
493bafc9d4SJustin T. Gibbs 	C46 = 6,
503bafc9d4SJustin T. Gibbs 	C56_66 = 8
513bafc9d4SJustin T. Gibbs } seeprom_chip_t;
523bafc9d4SJustin T. Gibbs 
533bafc9d4SJustin T. Gibbs struct seeprom_descriptor {
54717d4247SJustin T. Gibbs 	struct ahc_softc *sd_ahc;
55717d4247SJustin T. Gibbs 	u_int sd_control_offset;
56717d4247SJustin T. Gibbs 	u_int sd_status_offset;
57717d4247SJustin T. Gibbs 	u_int sd_dataout_offset;
583bafc9d4SJustin T. Gibbs 	seeprom_chip_t sd_chip;
59aa6dfd9dSJustin T. Gibbs 	uint16_t sd_MS;
60aa6dfd9dSJustin T. Gibbs 	uint16_t sd_RDY;
61aa6dfd9dSJustin T. Gibbs 	uint16_t sd_CS;
62aa6dfd9dSJustin T. Gibbs 	uint16_t sd_CK;
63aa6dfd9dSJustin T. Gibbs 	uint16_t sd_DO;
64aa6dfd9dSJustin T. Gibbs 	uint16_t sd_DI;
653bafc9d4SJustin T. Gibbs };
663bafc9d4SJustin T. Gibbs 
673bafc9d4SJustin T. Gibbs /*
683bafc9d4SJustin T. Gibbs  * This function will read count 16-bit words from the serial EEPROM and
693bafc9d4SJustin T. Gibbs  * return their value in buf.  The port address of the aic7xxx serial EEPROM
703bafc9d4SJustin T. Gibbs  * control register is passed in as offset.  The following parameters are
713bafc9d4SJustin T. Gibbs  * also passed in:
723bafc9d4SJustin T. Gibbs  *
733bafc9d4SJustin T. Gibbs  *   CS  - Chip select
743bafc9d4SJustin T. Gibbs  *   CK  - Clock
753bafc9d4SJustin T. Gibbs  *   DO  - Data out
763bafc9d4SJustin T. Gibbs  *   DI  - Data in
773bafc9d4SJustin T. Gibbs  *   RDY - SEEPROM ready
783bafc9d4SJustin T. Gibbs  *   MS  - Memory port mode select
793bafc9d4SJustin T. Gibbs  *
803bafc9d4SJustin T. Gibbs  *  A failed read attempt returns 0, and a successful read returns 1.
813bafc9d4SJustin T. Gibbs  */
823bafc9d4SJustin T. Gibbs 
833bafc9d4SJustin T. Gibbs #define	SEEPROM_INB(sd) \
84717d4247SJustin T. Gibbs 	ahc_inb(sd->sd_ahc, sd->sd_control_offset)
853bafc9d4SJustin T. Gibbs #define	SEEPROM_OUTB(sd, value)					\
86717d4247SJustin T. Gibbs do {								\
87717d4247SJustin T. Gibbs 	ahc_outb(sd->sd_ahc, sd->sd_control_offset, value);	\
88717d4247SJustin T. Gibbs 	ahc_flush_device_writes(sd->sd_ahc);			\
89717d4247SJustin T. Gibbs } while(0)
90717d4247SJustin T. Gibbs 
913bafc9d4SJustin T. Gibbs #define	SEEPROM_STATUS_INB(sd) \
92717d4247SJustin T. Gibbs 	ahc_inb(sd->sd_ahc, sd->sd_status_offset)
933bafc9d4SJustin T. Gibbs #define	SEEPROM_DATA_INB(sd) \
94717d4247SJustin T. Gibbs 	ahc_inb(sd->sd_ahc, sd->sd_dataout_offset)
953bafc9d4SJustin T. Gibbs 
968f214efcSJustin T. Gibbs int ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
97717d4247SJustin T. Gibbs 		     u_int start_addr, u_int count);
988f214efcSJustin T. Gibbs int ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
998f214efcSJustin T. Gibbs 		      u_int start_addr, u_int count);
1008f214efcSJustin T. Gibbs int ahc_verify_cksum(struct seeprom_config *sc);
1013bafc9d4SJustin T. Gibbs 
102717d4247SJustin T. Gibbs #endif /* _AIC7XXX_93CX6_H_ */
103