162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Interface to the 93C46/56 serial EEPROM that is used to store BIOS
362306a36Sopenharmony_ci * settings for the aic7xxx based adaptec SCSI controllers.  It can
462306a36Sopenharmony_ci * also be used for 93C26 and 93C06 serial EEPROMS.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (c) 1994, 1995, 2000 Justin T. Gibbs.
762306a36Sopenharmony_ci * All rights reserved.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
1062306a36Sopenharmony_ci * modification, are permitted provided that the following conditions
1162306a36Sopenharmony_ci * are met:
1262306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
1362306a36Sopenharmony_ci *    notice, this list of conditions, and the following disclaimer,
1462306a36Sopenharmony_ci *    without modification.
1562306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1662306a36Sopenharmony_ci *    substantially similar to the "NO WARRANTY" disclaimer below
1762306a36Sopenharmony_ci *    ("Disclaimer") and any redistribution must be conditioned upon
1862306a36Sopenharmony_ci *    including a substantially similar Disclaimer requirement for further
1962306a36Sopenharmony_ci *    binary redistribution.
2062306a36Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names
2162306a36Sopenharmony_ci *    of any contributors may be used to endorse or promote products derived
2262306a36Sopenharmony_ci *    from this software without specific prior written permission.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
2562306a36Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free
2662306a36Sopenharmony_ci * Software Foundation.
2762306a36Sopenharmony_ci *
2862306a36Sopenharmony_ci * NO WARRANTY
2962306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3062306a36Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3162306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3262306a36Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3362306a36Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3462306a36Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3562306a36Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3662306a36Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3762306a36Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
3862306a36Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3962306a36Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES.
4062306a36Sopenharmony_ci *
4162306a36Sopenharmony_ci * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $
4262306a36Sopenharmony_ci *
4362306a36Sopenharmony_ci * $FreeBSD$
4462306a36Sopenharmony_ci */
4562306a36Sopenharmony_ci#ifndef _AIC7XXX_93CX6_H_
4662306a36Sopenharmony_ci#define _AIC7XXX_93CX6_H_
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_citypedef enum {
4962306a36Sopenharmony_ci	C46 = 6,
5062306a36Sopenharmony_ci	C56_66 = 8
5162306a36Sopenharmony_ci} seeprom_chip_t;
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_cistruct seeprom_descriptor {
5462306a36Sopenharmony_ci	struct ahc_softc *sd_ahc;
5562306a36Sopenharmony_ci	u_int sd_control_offset;
5662306a36Sopenharmony_ci	u_int sd_status_offset;
5762306a36Sopenharmony_ci	u_int sd_dataout_offset;
5862306a36Sopenharmony_ci	seeprom_chip_t sd_chip;
5962306a36Sopenharmony_ci	uint16_t sd_MS;
6062306a36Sopenharmony_ci	uint16_t sd_RDY;
6162306a36Sopenharmony_ci	uint16_t sd_CS;
6262306a36Sopenharmony_ci	uint16_t sd_CK;
6362306a36Sopenharmony_ci	uint16_t sd_DO;
6462306a36Sopenharmony_ci	uint16_t sd_DI;
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/*
6862306a36Sopenharmony_ci * This function will read count 16-bit words from the serial EEPROM and
6962306a36Sopenharmony_ci * return their value in buf.  The port address of the aic7xxx serial EEPROM
7062306a36Sopenharmony_ci * control register is passed in as offset.  The following parameters are
7162306a36Sopenharmony_ci * also passed in:
7262306a36Sopenharmony_ci *
7362306a36Sopenharmony_ci *   CS  - Chip select
7462306a36Sopenharmony_ci *   CK  - Clock
7562306a36Sopenharmony_ci *   DO  - Data out
7662306a36Sopenharmony_ci *   DI  - Data in
7762306a36Sopenharmony_ci *   RDY - SEEPROM ready
7862306a36Sopenharmony_ci *   MS  - Memory port mode select
7962306a36Sopenharmony_ci *
8062306a36Sopenharmony_ci *  A failed read attempt returns 0, and a successful read returns 1.
8162306a36Sopenharmony_ci */
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#define	SEEPROM_INB(sd) \
8462306a36Sopenharmony_ci	ahc_inb(sd->sd_ahc, sd->sd_control_offset)
8562306a36Sopenharmony_ci#define	SEEPROM_OUTB(sd, value)					\
8662306a36Sopenharmony_cido {								\
8762306a36Sopenharmony_ci	ahc_outb(sd->sd_ahc, sd->sd_control_offset, value);	\
8862306a36Sopenharmony_ci	ahc_flush_device_writes(sd->sd_ahc);			\
8962306a36Sopenharmony_ci} while(0)
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define	SEEPROM_STATUS_INB(sd) \
9262306a36Sopenharmony_ci	ahc_inb(sd->sd_ahc, sd->sd_status_offset)
9362306a36Sopenharmony_ci#define	SEEPROM_DATA_INB(sd) \
9462306a36Sopenharmony_ci	ahc_inb(sd->sd_ahc, sd->sd_dataout_offset)
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ciint ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
9762306a36Sopenharmony_ci		     u_int start_addr, u_int count);
9862306a36Sopenharmony_ciint ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
9962306a36Sopenharmony_ci		      u_int start_addr, u_int count);
10062306a36Sopenharmony_ciint ahc_verify_cksum(struct seeprom_config *sc);
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#endif /* _AIC7XXX_93CX6_H_ */
103