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