ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / scsi / sym53c8xx_2 / sym_nvram.h
1 /*
2  * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family 
3  * of PCI-SCSI IO processors.
4  *
5  * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
6  *
7  * This driver is derived from the Linux sym53c8xx driver.
8  * Copyright (C) 1998-2000  Gerard Roudier
9  *
10  * The sym53c8xx driver is derived from the ncr53c8xx driver that had been 
11  * a port of the FreeBSD ncr driver to Linux-1.2.13.
12  *
13  * The original ncr driver has been written for 386bsd and FreeBSD by
14  *         Wolfgang Stanglmeier        <wolf@cologne.de>
15  *         Stefan Esser                <se@mi.Uni-Koeln.de>
16  * Copyright (C) 1994  Wolfgang Stanglmeier
17  *
18  * Other major contributions:
19  *
20  * NVRAM detection and reading.
21  * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
22  *
23  *-----------------------------------------------------------------------------
24  *
25  * Redistribution and use in source and binary forms, with or without
26  * modification, are permitted provided that the following conditions
27  * are met:
28  * 1. Redistributions of source code must retain the above copyright
29  *    notice, this list of conditions and the following disclaimer.
30  * 2. The name of the author may not be used to endorse or promote products
31  *    derived from this software without specific prior written permission.
32  *
33  * Where this Software is combined with software released under the terms of 
34  * the GNU Public License ("GPL") and the terms of the GPL would require the 
35  * combined work to also be released under the terms of the GPL, the terms
36  * and conditions of this License will apply in addition to those of the
37  * GPL with the exception of any terms or conditions of this License that
38  * conflict with, or are expressly prohibited by, the GPL.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
44  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  */
52
53 #ifndef SYM_NVRAM_H
54 #define SYM_NVRAM_H
55
56 #include "sym_conf.h"
57
58 /*
59  *      Symbios NVRAM data format
60  */
61 #define SYMBIOS_NVRAM_SIZE 368
62 #define SYMBIOS_NVRAM_ADDRESS 0x100
63
64 struct Symbios_nvram {
65 /* Header 6 bytes */
66         u_short type;           /* 0x0000 */
67         u_short byte_count;     /* excluding header/trailer */
68         u_short checksum;
69
70 /* Controller set up 20 bytes */
71         u_char  v_major;        /* 0x00 */
72         u_char  v_minor;        /* 0x30 */
73         u32     boot_crc;
74         u_short flags;
75 #define SYMBIOS_SCAM_ENABLE     (1)
76 #define SYMBIOS_PARITY_ENABLE   (1<<1)
77 #define SYMBIOS_VERBOSE_MSGS    (1<<2)
78 #define SYMBIOS_CHS_MAPPING     (1<<3)
79 #define SYMBIOS_NO_NVRAM        (1<<3)  /* ??? */
80         u_short flags1;
81 #define SYMBIOS_SCAN_HI_LO      (1)
82         u_short term_state;
83 #define SYMBIOS_TERM_CANT_PROGRAM       (0)
84 #define SYMBIOS_TERM_ENABLED            (1)
85 #define SYMBIOS_TERM_DISABLED           (2)
86         u_short rmvbl_flags;
87 #define SYMBIOS_RMVBL_NO_SUPPORT        (0)
88 #define SYMBIOS_RMVBL_BOOT_DEVICE       (1)
89 #define SYMBIOS_RMVBL_MEDIA_INSTALLED   (2)
90         u_char  host_id;
91         u_char  num_hba;        /* 0x04 */
92         u_char  num_devices;    /* 0x10 */
93         u_char  max_scam_devices;       /* 0x04 */
94         u_char  num_valid_scam_devices; /* 0x00 */
95         u_char  flags2;
96 #define SYMBIOS_AVOID_BUS_RESET         (1<<2)
97
98 /* Boot order 14 bytes * 4 */
99         struct Symbios_host{
100                 u_short type;           /* 4:8xx / 0:nok */
101                 u_short device_id;      /* PCI device id */
102                 u_short vendor_id;      /* PCI vendor id */
103                 u_char  bus_nr;         /* PCI bus number */
104                 u_char  device_fn;      /* PCI device/function number << 3*/
105                 u_short word8;
106                 u_short flags;
107 #define SYMBIOS_INIT_SCAN_AT_BOOT       (1)
108                 u_short io_port;        /* PCI io_port address */
109         } host[4];
110
111 /* Targets 8 bytes * 16 */
112         struct Symbios_target {
113                 u_char  flags;
114 #define SYMBIOS_DISCONNECT_ENABLE       (1)
115 #define SYMBIOS_SCAN_AT_BOOT_TIME       (1<<1)
116 #define SYMBIOS_SCAN_LUNS               (1<<2)
117 #define SYMBIOS_QUEUE_TAGS_ENABLED      (1<<3)
118                 u_char  rsvd;
119                 u_char  bus_width;      /* 0x08/0x10 */
120                 u_char  sync_offset;
121                 u_short sync_period;    /* 4*period factor */
122                 u_short timeout;
123         } target[16];
124 /* Scam table 8 bytes * 4 */
125         struct Symbios_scam {
126                 u_short id;
127                 u_short method;
128 #define SYMBIOS_SCAM_DEFAULT_METHOD     (0)
129 #define SYMBIOS_SCAM_DONT_ASSIGN        (1)
130 #define SYMBIOS_SCAM_SET_SPECIFIC_ID    (2)
131 #define SYMBIOS_SCAM_USE_ORDER_GIVEN    (3)
132                 u_short status;
133 #define SYMBIOS_SCAM_UNKNOWN            (0)
134 #define SYMBIOS_SCAM_DEVICE_NOT_FOUND   (1)
135 #define SYMBIOS_SCAM_ID_NOT_SET         (2)
136 #define SYMBIOS_SCAM_ID_VALID           (3)
137                 u_char  target_id;
138                 u_char  rsvd;
139         } scam[4];
140
141         u_char  spare_devices[15*8];
142         u_char  trailer[6];             /* 0xfe 0xfe 0x00 0x00 0x00 0x00 */
143 };
144 typedef struct Symbios_nvram    Symbios_nvram;
145 typedef struct Symbios_host     Symbios_host;
146 typedef struct Symbios_target   Symbios_target;
147 typedef struct Symbios_scam     Symbios_scam;
148
149 /*
150  *      Tekram NvRAM data format.
151  */
152 #define TEKRAM_NVRAM_SIZE 64
153 #define TEKRAM_93C46_NVRAM_ADDRESS 0
154 #define TEKRAM_24C16_NVRAM_ADDRESS 0x40
155
156 struct Tekram_nvram {
157         struct Tekram_target {
158                 u_char  flags;
159 #define TEKRAM_PARITY_CHECK             (1)
160 #define TEKRAM_SYNC_NEGO                (1<<1)
161 #define TEKRAM_DISCONNECT_ENABLE        (1<<2)
162 #define TEKRAM_START_CMD                (1<<3)
163 #define TEKRAM_TAGGED_COMMANDS          (1<<4)
164 #define TEKRAM_WIDE_NEGO                (1<<5)
165                 u_char  sync_index;
166                 u_short word2;
167         } target[16];
168         u_char  host_id;
169         u_char  flags;
170 #define TEKRAM_MORE_THAN_2_DRIVES       (1)
171 #define TEKRAM_DRIVES_SUP_1GB           (1<<1)
172 #define TEKRAM_RESET_ON_POWER_ON        (1<<2)
173 #define TEKRAM_ACTIVE_NEGATION          (1<<3)
174 #define TEKRAM_IMMEDIATE_SEEK           (1<<4)
175 #define TEKRAM_SCAN_LUNS                (1<<5)
176 #define TEKRAM_REMOVABLE_FLAGS          (3<<6)  /* 0: disable; */
177                                                 /* 1: boot device; 2:all */
178         u_char  boot_delay_index;
179         u_char  max_tags_index;
180         u_short flags1;
181 #define TEKRAM_F2_F6_ENABLED            (1)
182         u_short spare[29];
183 };
184 typedef struct Tekram_nvram     Tekram_nvram;
185 typedef struct Tekram_target    Tekram_target;
186
187 /*
188  *  Union of supported NVRAM formats.
189  */
190 struct sym_nvram {
191         int type;
192 #define SYM_SYMBIOS_NVRAM       (1)
193 #define SYM_TEKRAM_NVRAM        (2)
194 #if SYM_CONF_NVRAM_SUPPORT
195         union {
196                 Symbios_nvram Symbios;
197                 Tekram_nvram Tekram;
198         } data;
199 #endif
200 };
201
202 #if SYM_CONF_NVRAM_SUPPORT
203 void sym_nvram_setup_host (struct sym_hcb *np, struct sym_nvram *nvram);
204 void sym_nvram_setup_target (struct sym_hcb *np, int target, struct sym_nvram *nvp);
205 int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp);
206 #else
207 static inline void sym_nvram_setup_host(struct sym_hcb *np, struct sym_nvram *nvram) { }
208 static inline void sym_nvram_setup_target(struct sym_hcb *np, struct sym_nvram *nvram) { }
209 static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp)
210 {
211         nvp->type = 0;
212         return 0;
213 }
214 #endif
215
216 #endif /* SYM_NVRAM_H */