Home | History | Annotate | Line # | Download | only in ic
smc93cx6var.h revision 1.2
      1  1.2  explorer /*	$NetBSD: smc93cx6var.h,v 1.2 1996/07/10 22:50:50 explorer 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.1   mycroft  *    notice immediately at the beginning of the file, without modification,
     16  1.1   mycroft  *    this list of conditions, and the following disclaimer.
     17  1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     19  1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     20  1.1   mycroft  * 3. Absolutely no warranty of function or purpose is made by the author
     21  1.1   mycroft  *    Justin T. Gibbs.
     22  1.1   mycroft  * 4. Modifications may be freely made to this file if the above conditions
     23  1.1   mycroft  *    are met.
     24  1.1   mycroft  *
     25  1.2  explorer  * from	Id: 93cx6.h,v 1.3 1996/05/30 07:19:55 gibbs Exp
     26  1.1   mycroft  */
     27  1.1   mycroft 
     28  1.1   mycroft #include <sys/param.h>
     29  1.1   mycroft #if !defined(__NetBSD__)
     30  1.1   mycroft #include <sys/systm.h>
     31  1.1   mycroft #endif
     32  1.1   mycroft 
     33  1.1   mycroft struct seeprom_descriptor {
     34  1.1   mycroft #if defined(__FreeBSD__)
     35  1.1   mycroft 	u_long sd_iobase;
     36  1.1   mycroft #elif defined(__NetBSD__)
     37  1.1   mycroft 	bus_chipset_tag_t sd_bc;
     38  1.1   mycroft 	bus_io_handle_t sd_ioh;
     39  1.1   mycroft 	bus_io_size_t sd_offset;
     40  1.1   mycroft #endif
     41  1.1   mycroft 	u_int16_t sd_MS;
     42  1.1   mycroft 	u_int16_t sd_RDY;
     43  1.1   mycroft 	u_int16_t sd_CS;
     44  1.1   mycroft 	u_int16_t sd_CK;
     45  1.1   mycroft 	u_int16_t sd_DO;
     46  1.1   mycroft 	u_int16_t sd_DI;
     47  1.1   mycroft };
     48  1.1   mycroft 
     49  1.1   mycroft /*
     50  1.1   mycroft  * This function will read count 16-bit words from the serial EEPROM and
     51  1.1   mycroft  * return their value in buf.  The port address of the aic7xxx serial EEPROM
     52  1.1   mycroft  * control register is passed in as offset.  The following parameters are
     53  1.1   mycroft  * also passed in:
     54  1.1   mycroft  *
     55  1.1   mycroft  *   CS  - Chip select
     56  1.1   mycroft  *   CK  - Clock
     57  1.1   mycroft  *   DO  - Data out
     58  1.1   mycroft  *   DI  - Data in
     59  1.1   mycroft  *   RDY - SEEPROM ready
     60  1.1   mycroft  *   MS  - Memory port mode select
     61  1.1   mycroft  *
     62  1.1   mycroft  *  A failed read attempt returns 0, and a successful read returns 1.
     63  1.1   mycroft  */
     64  1.2  explorer 
     65  1.2  explorer #if defined(__FreeBSD__)
     66  1.2  explorer #define	SEEPROM_INB(sd)		inb(sd->sd_iobase)
     67  1.2  explorer #define	SEEPROM_OUTB(sd, value)	outb(sd->sd_iobase, value)
     68  1.2  explorer #elif defined(__NetBSD__)
     69  1.2  explorer #define	SEEPROM_INB(sd) \
     70  1.2  explorer 	bus_io_read_1(sd->sd_bc, sd->sd_ioh, sd->sd_offset)
     71  1.2  explorer #define	SEEPROM_OUTB(sd, value) \
     72  1.2  explorer 	bus_io_write_1(sd->sd_bc, sd->sd_ioh, sd->sd_offset, value)
     73  1.2  explorer #endif
     74  1.2  explorer 
     75  1.1   mycroft #if defined(__FreeBSD__)
     76  1.1   mycroft int read_seeprom __P((struct seeprom_descriptor *sd,
     77  1.1   mycroft     u_int16_t *buf, u_int start_addr, int count));
     78  1.1   mycroft #elif defined(__NetBSD__)
     79  1.1   mycroft int read_seeprom __P((struct seeprom_descriptor *sd,
     80  1.1   mycroft     u_int16_t *buf, bus_io_size_t start_addr, bus_io_size_t count));
     81  1.1   mycroft #endif
     82