xref: /onnv-gate/usr/src/uts/common/io/rtw/smc93cx6var.h (revision 10448:fe6b44e693c2)
14689Sql147931 /*
2*10448SMikore.Li@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
34689Sql147931  * Use is subject to license terms.
44689Sql147931  */
54689Sql147931 
64689Sql147931 /*
74689Sql147931  * Interface to the 93C46 serial EEPROM that is used to store BIOS
84689Sql147931  * settings for the aic7xxx based adaptec SCSI controllers.  It can
94689Sql147931  * also be used for 93C26 and 93C06 serial EEPROMS.
104689Sql147931  *
114689Sql147931  * Copyright (c) 1994, 1995 Justin T. Gibbs.
124689Sql147931  * All rights reserved.
134689Sql147931  *
144689Sql147931  * Redistribution and use in source and binary forms, with or without
154689Sql147931  * modification, are permitted provided that the following conditions
164689Sql147931  * are met:
174689Sql147931  * 1. Redistributions of source code must retain the above copyright
184689Sql147931  *    notice, this list of conditions, and the following disclaimer,
194689Sql147931  *    without modification.
204689Sql147931  * 2. The name of the author may not be used to endorse or promote products
214689Sql147931  *    derived from this software without specific prior written permission.
224689Sql147931  *
234689Sql147931  * Alternatively, this software may be distributed under the terms of the
244689Sql147931  * the GNU Public License ("GPL").
254689Sql147931  *
264689Sql147931  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
274689Sql147931  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
284689Sql147931  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
294689Sql147931  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
304689Sql147931  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
314689Sql147931  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
324689Sql147931  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
334689Sql147931  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
344689Sql147931  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
354689Sql147931  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
364689Sql147931  * SUCH DAMAGE.
374689Sql147931  *
384689Sql147931  * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.40 2000/01/07 23:08:17gibbs Exp $
394689Sql147931  */
404689Sql147931 
414689Sql147931 #ifndef _SMC93CX6VAR_H_
424689Sql147931 #define	_SMC93CX6VAR_H_
434689Sql147931 
44*10448SMikore.Li@Sun.COM #ifdef __cplusplus
45*10448SMikore.Li@Sun.COM extern "C" {
46*10448SMikore.Li@Sun.COM #endif
474689Sql147931 
484689Sql147931 #include <sys/param.h>
494689Sql147931 #include <sys/systm.h>
504689Sql147931 
514689Sql147931 typedef enum {
524689Sql147931 	C46 = 6,
534689Sql147931 	C56_66 = 8
544689Sql147931 } seeprom_chip_t;
554689Sql147931 
564689Sql147931 struct seeprom_descriptor {
574689Sql147931 	ddi_acc_handle_t	sd_handle;
584689Sql147931 	caddr_t			sd_base;
594689Sql147931 	size_t sd_regsize;
604689Sql147931 	size_t sd_control_offset;
614689Sql147931 	size_t sd_status_offset;
624689Sql147931 	size_t sd_dataout_offset;
634689Sql147931 	seeprom_chip_t sd_chip;
644689Sql147931 	uint32_t sd_MS;
654689Sql147931 	uint32_t sd_RDY;
664689Sql147931 	uint32_t sd_CS;
674689Sql147931 	uint32_t sd_CK;
684689Sql147931 	uint32_t sd_DO;
694689Sql147931 	uint32_t sd_DI;
704689Sql147931 };
714689Sql147931 
724689Sql147931 /*
734689Sql147931  * This function will read count 16-bit words from the serial EEPROM and
744689Sql147931  * return their value in buf.  The port address of the aic7xxx serial EEPROM
754689Sql147931  * control register is passed in as offset.  The following parameters are
764689Sql147931  * also passed in:
774689Sql147931  *
784689Sql147931  *   CS  - Chip select
794689Sql147931  *   CK  - Clock
804689Sql147931  *   DO  - Data out
814689Sql147931  *   DI  - Data in
824689Sql147931  *   RDY - SEEPROM ready
834689Sql147931  *   MS  - Memory port mode select
844689Sql147931  *
854689Sql147931  *  A failed read attempt returns 0, and a successful read returns 1.
864689Sql147931  */
874689Sql147931 
884689Sql147931 #define	SEEPROM_INB(sd) \
894689Sql147931 	(((sd)->sd_regsize == 4) \
906890Sql147931 	    ? ddi_get32((sd)->sd_handle, \
916890Sql147931 	    (uint32_t *)((uintptr_t)(sd)->sd_base+ \
924689Sql147931 	    (sd)->sd_control_offset)) \
934689Sql147931 	    : ddi_get8((sd)->sd_handle, (uint8_t *)((sd)->sd_base+ \
944689Sql147931 	    (sd)->sd_control_offset)))
954689Sql147931 
964689Sql147931 #define	SEEPROM_OUTB(sd, value) { \
974689Sql147931 	if ((sd)->sd_regsize == 4) \
986890Sql147931 		ddi_put32((sd)->sd_handle, \
996890Sql147931 		    (uint32_t *)((uintptr_t)(sd)->sd_base+ \
1004689Sql147931 		    (sd)->sd_control_offset), (value)); \
1014689Sql147931 	else \
1026890Sql147931 		ddi_put8((sd)->sd_handle, \
1036890Sql147931 		    (uint8_t *)((sd)->sd_base+ \
1044689Sql147931 		    (sd)->sd_control_offset), (uint8_t)(value)); \
1054689Sql147931 }
1064689Sql147931 
1074689Sql147931 #define	SEEPROM_STATUS_INB(sd) \
1084689Sql147931 	(((sd)->sd_regsize == 4) \
1096890Sql147931 	    ? ddi_get32((sd)->sd_handle, \
1106890Sql147931 	    (uint32_t *)((uintptr_t)(sd)->sd_base+ \
1114689Sql147931 	    (sd)->sd_status_offset)) \
1124689Sql147931 	    : ddi_get8((sd)->sd_handle, (uint8_t *)((sd)->sd_base+ \
1134689Sql147931 	    (sd)->sd_status_offset)))
1144689Sql147931 
1154689Sql147931 #define	SEEPROM_DATA_INB(sd) \
1164689Sql147931 	(((sd)->sd_regsize == 4) \
1176890Sql147931 	    ? ddi_get32((sd)->sd_handle, \
1186890Sql147931 	    (uint32_t *)((uintptr_t)(sd)->sd_base+ \
1194689Sql147931 	    (sd)->sd_dataout_offset)) \
1204689Sql147931 	    : ddi_get8((sd)->sd_handle, (uint8_t *)((sd)->sd_base+ \
1214689Sql147931 	    (sd)->sd_dataout_offset)))
1224689Sql147931 
1234689Sql147931 int read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
1244689Sql147931     size_t start_addr, size_t count);
125*10448SMikore.Li@Sun.COM #ifdef __cplusplus
126*10448SMikore.Li@Sun.COM }
127*10448SMikore.Li@Sun.COM #endif
128*10448SMikore.Li@Sun.COM 
1294689Sql147931 #endif	/* _SMC93CX6VAR_H_ */
130