aic7xxx_93cx6.h revision 39220
1/*
2 * Interface to the 93C46 serial EEPROM that is used to store BIOS
3 * settings for the aic7xxx based adaptec SCSI controllers.  It can
4 * also be used for 93C26 and 93C06 serial EEPROMS.
5 *
6 * Copyright (c) 1994, 1995 Justin T. Gibbs.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions, and the following disclaimer,
14 *    without modification, immediately at the beginning of the file.
15 * 2. The name of the author may not be used to endorse or promote products
16 *    derived from this software without specific prior written permission.
17 *
18 * Where this Software is combined with software released under the terms of
19 * the GNU Public License ("GPL") and the terms of the GPL would require the
20 * combined work to also be released under the terms of the GPL, the terms
21 * and conditions of this License will apply in addition to those of the
22 * GPL with the exception of any terms or conditions of this License that
23 * conflict with, or are expressly prohibited by, the GPL.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 *      $Id$
38 */
39
40#include <sys/param.h>
41#if !defined(__NetBSD__)
42#include <sys/systm.h>
43#endif
44
45#ifdef KERNEL
46
47typedef enum {
48	C46 = 6,
49	C56_66 = 8
50} seeprom_chip_t;
51
52struct seeprom_descriptor {
53	bus_space_tag_t sd_tag;
54	bus_space_handle_t sd_bsh;
55	bus_size_t sd_control_offset;
56	bus_size_t sd_status_offset;
57	bus_size_t sd_dataout_offset;
58	seeprom_chip_t sd_chip;
59	u_int16_t sd_MS;
60	u_int16_t sd_RDY;
61	u_int16_t sd_CS;
62	u_int16_t sd_CK;
63	u_int16_t sd_DO;
64	u_int16_t sd_DI;
65};
66
67/*
68 * This function will read count 16-bit words from the serial EEPROM and
69 * return their value in buf.  The port address of the aic7xxx serial EEPROM
70 * control register is passed in as offset.  The following parameters are
71 * also passed in:
72 *
73 *   CS  - Chip select
74 *   CK  - Clock
75 *   DO  - Data out
76 *   DI  - Data in
77 *   RDY - SEEPROM ready
78 *   MS  - Memory port mode select
79 *
80 *  A failed read attempt returns 0, and a successful read returns 1.
81 */
82
83#define	SEEPROM_INB(sd) \
84	bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_control_offset)
85#define	SEEPROM_OUTB(sd, value) \
86	bus_space_write_1(sd->sd_tag, sd->sd_bsh, sd->sd_control_offset, value)
87#define	SEEPROM_STATUS_INB(sd) \
88	bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_status_offset)
89#define	SEEPROM_DATA_INB(sd) \
90	bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_dataout_offset)
91
92int read_seeprom(struct seeprom_descriptor *sd, u_int16_t *buf,
93		 bus_size_t start_addr, bus_size_t count);
94
95#endif /* KERNEL */
96