Home | History | Annotate | Line # | Download | only in ic
smc93cx6var.h revision 1.6.2.1
      1  1.6.2.1     skrll /*	$NetBSD: smc93cx6var.h,v 1.6.2.1 2005/11/10 14:04:15 skrll Exp $	*/
      2      1.2  explorer 
      3      1.1   mycroft /*
      4      1.1   mycroft  * Interface to the 93C46 serial EEPROM that is used to store BIOS
      5      1.1   mycroft  * settings for the aic7xxx based adaptec SCSI controllers.  It can
      6      1.1   mycroft  * also be used for 93C26 and 93C06 serial EEPROMS.
      7      1.1   mycroft  *
      8      1.1   mycroft  * Copyright (c) 1994, 1995 Justin T. Gibbs.
      9      1.1   mycroft  * All rights reserved.
     10      1.1   mycroft  *
     11      1.1   mycroft  * Redistribution and use in source and binary forms, with or without
     12      1.1   mycroft  * modification, are permitted provided that the following conditions
     13      1.1   mycroft  * are met:
     14      1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     15      1.5      fvdl  *    notice, this list of conditions, and the following disclaimer,
     16      1.5      fvdl  *    without modification.
     17      1.5      fvdl  * 2. The name of the author may not be used to endorse or promote products
     18      1.5      fvdl  *    derived from this software without specific prior written permission.
     19      1.1   mycroft  *
     20      1.5      fvdl  * Alternatively, this software may be distributed under the terms of the
     21      1.5      fvdl  * the GNU Public License ("GPL").
     22      1.5      fvdl  *
     23      1.5      fvdl  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     24      1.5      fvdl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25      1.5      fvdl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26      1.5      fvdl  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     27      1.5      fvdl  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28      1.5      fvdl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29      1.5      fvdl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30      1.5      fvdl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31      1.5      fvdl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32      1.5      fvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33      1.5      fvdl  * SUCH DAMAGE.
     34      1.5      fvdl  *
     35      1.5      fvdl  * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.40 2000/01/07 23:08:17 gibbs Exp $
     36      1.1   mycroft  */
     37      1.1   mycroft 
     38      1.1   mycroft #include <sys/param.h>
     39      1.1   mycroft #if !defined(__NetBSD__)
     40      1.1   mycroft #include <sys/systm.h>
     41      1.1   mycroft #endif
     42      1.1   mycroft 
     43      1.5      fvdl typedef enum {
     44      1.5      fvdl 	C46 = 6,
     45      1.5      fvdl 	C56_66 = 8
     46      1.5      fvdl } seeprom_chip_t;
     47      1.5      fvdl 
     48      1.1   mycroft struct seeprom_descriptor {
     49      1.5      fvdl 	bus_space_tag_t sd_tag;
     50      1.5      fvdl 	bus_space_handle_t sd_bsh;
     51      1.6    dyoung 	bus_size_t sd_regsize;
     52      1.5      fvdl 	bus_size_t sd_control_offset;
     53      1.5      fvdl 	bus_size_t sd_status_offset;
     54      1.5      fvdl 	bus_size_t sd_dataout_offset;
     55      1.5      fvdl 	seeprom_chip_t sd_chip;
     56      1.6    dyoung 	u_int32_t sd_MS;
     57      1.6    dyoung 	u_int32_t sd_RDY;
     58      1.6    dyoung 	u_int32_t sd_CS;
     59      1.6    dyoung 	u_int32_t sd_CK;
     60      1.6    dyoung 	u_int32_t sd_DO;
     61      1.6    dyoung 	u_int32_t sd_DI;
     62      1.1   mycroft };
     63      1.1   mycroft 
     64      1.1   mycroft /*
     65      1.1   mycroft  * This function will read count 16-bit words from the serial EEPROM and
     66      1.1   mycroft  * return their value in buf.  The port address of the aic7xxx serial EEPROM
     67      1.1   mycroft  * control register is passed in as offset.  The following parameters are
     68      1.1   mycroft  * also passed in:
     69      1.1   mycroft  *
     70      1.1   mycroft  *   CS  - Chip select
     71      1.1   mycroft  *   CK  - Clock
     72      1.1   mycroft  *   DO  - Data out
     73      1.1   mycroft  *   DI  - Data in
     74      1.1   mycroft  *   RDY - SEEPROM ready
     75      1.1   mycroft  *   MS  - Memory port mode select
     76      1.1   mycroft  *
     77      1.1   mycroft  *  A failed read attempt returns 0, and a successful read returns 1.
     78      1.1   mycroft  */
     79      1.2  explorer 
     80  1.6.2.1     skrll /* XXX bus barriers */
     81      1.5      fvdl #define SEEPROM_INB(sd) \
     82      1.6    dyoung 	(((sd)->sd_regsize == 4) \
     83      1.6    dyoung 	    ? bus_space_read_4((sd)->sd_tag, (sd)->sd_bsh, \
     84      1.6    dyoung 	          (sd)->sd_control_offset) \
     85      1.6    dyoung 	    : bus_space_read_1((sd)->sd_tag, (sd)->sd_bsh, \
     86      1.6    dyoung 	          (sd)->sd_control_offset))
     87      1.6    dyoung 
     88      1.6    dyoung #define SEEPROM_OUTB(sd, value) do { \
     89      1.6    dyoung 	if ((sd)->sd_regsize == 4) \
     90      1.6    dyoung 		bus_space_write_4((sd)->sd_tag, (sd)->sd_bsh, \
     91      1.6    dyoung 		    (sd)->sd_control_offset, (value)); \
     92      1.6    dyoung 	else \
     93      1.6    dyoung 		bus_space_write_1((sd)->sd_tag, (sd)->sd_bsh, \
     94      1.6    dyoung 		    (sd)->sd_control_offset, (u_int8_t) (value)); \
     95      1.6    dyoung } while (0)
     96      1.6    dyoung 
     97      1.5      fvdl #define SEEPROM_STATUS_INB(sd) \
     98      1.6    dyoung 	(((sd)->sd_regsize == 4) \
     99      1.6    dyoung 	    ? bus_space_read_4((sd)->sd_tag, (sd)->sd_bsh, \
    100      1.6    dyoung 	          (sd)->sd_status_offset) \
    101      1.6    dyoung 	    : bus_space_read_1((sd)->sd_tag, (sd)->sd_bsh, \
    102      1.6    dyoung 	          (sd)->sd_status_offset))
    103      1.6    dyoung 
    104      1.5      fvdl #define SEEPROM_DATA_INB(sd) \
    105      1.6    dyoung 	(((sd)->sd_regsize == 4) \
    106      1.6    dyoung 	    ? bus_space_read_4((sd)->sd_tag, (sd)->sd_bsh, \
    107      1.6    dyoung 	          (sd)->sd_dataout_offset) \
    108      1.6    dyoung 	    : bus_space_read_1((sd)->sd_tag, (sd)->sd_bsh, \
    109      1.6    dyoung 	          (sd)->sd_dataout_offset))
    110      1.2  explorer 
    111  1.6.2.1     skrll int read_seeprom(struct seeprom_descriptor *, u_int16_t *,
    112  1.6.2.1     skrll     bus_size_t, bus_size_t);
    113