initial commit with v2.6.9
[linux-2.6.9-moxart.git] / drivers / scsi / sym53c8xx_2 / sym_fw.h
blob59333f42bb16762726391c7f0bb9f6c2beee8495
1 /*
2 * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
3 * of PCI-SCSI IO processors.
5 * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
7 * This driver is derived from the Linux sym53c8xx driver.
8 * Copyright (C) 1998-2000 Gerard Roudier
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.
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
18 * Other major contributions:
20 * NVRAM detection and reading.
21 * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
23 *-----------------------------------------------------------------------------
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.
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.
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.
53 #ifndef SYM_FW_H
54 #define SYM_FW_H
56 * Macro used to generate interfaces for script A.
58 #define SYM_GEN_FW_A(s) \
59 SYM_GEN_A(s, start) SYM_GEN_A(s, getjob_begin) \
60 SYM_GEN_A(s, getjob_end) \
61 SYM_GEN_A(s, select) SYM_GEN_A(s, wf_sel_done) \
62 SYM_GEN_A(s, send_ident) \
63 SYM_GEN_A(s, dispatch) SYM_GEN_A(s, init) \
64 SYM_GEN_A(s, clrack) SYM_GEN_A(s, complete_error) \
65 SYM_GEN_A(s, done) SYM_GEN_A(s, done_end) \
66 SYM_GEN_A(s, idle) SYM_GEN_A(s, ungetjob) \
67 SYM_GEN_A(s, reselect) \
68 SYM_GEN_A(s, resel_tag) SYM_GEN_A(s, resel_dsa) \
69 SYM_GEN_A(s, resel_no_tag) \
70 SYM_GEN_A(s, data_in) SYM_GEN_A(s, data_in2) \
71 SYM_GEN_A(s, data_out) SYM_GEN_A(s, data_out2) \
72 SYM_GEN_A(s, pm0_data) SYM_GEN_A(s, pm1_data)
75 * Macro used to generate interfaces for script B.
77 #define SYM_GEN_FW_B(s) \
78 SYM_GEN_B(s, no_data) \
79 SYM_GEN_B(s, sel_for_abort) SYM_GEN_B(s, sel_for_abort_1) \
80 SYM_GEN_B(s, msg_bad) SYM_GEN_B(s, msg_weird) \
81 SYM_GEN_B(s, wdtr_resp) SYM_GEN_B(s, send_wdtr) \
82 SYM_GEN_B(s, sdtr_resp) SYM_GEN_B(s, send_sdtr) \
83 SYM_GEN_B(s, ppr_resp) SYM_GEN_B(s, send_ppr) \
84 SYM_GEN_B(s, nego_bad_phase) \
85 SYM_GEN_B(s, ident_break) SYM_GEN_B(s, ident_break_atn) \
86 SYM_GEN_B(s, sdata_in) SYM_GEN_B(s, resel_bad_lun) \
87 SYM_GEN_B(s, bad_i_t_l) SYM_GEN_B(s, bad_i_t_l_q) \
88 SYM_GEN_B(s, wsr_ma_helper)
91 * Macro used to generate interfaces for script Z.
93 #define SYM_GEN_FW_Z(s) \
94 SYM_GEN_Z(s, snooptest) SYM_GEN_Z(s, snoopend)
97 * Generates structure interface that contains
98 * offsets within script A, B and Z.
100 #define SYM_GEN_A(s, label) s label;
101 #define SYM_GEN_B(s, label) s label;
102 #define SYM_GEN_Z(s, label) s label;
103 struct sym_fwa_ofs {
104 SYM_GEN_FW_A(u_short)
106 struct sym_fwb_ofs {
107 SYM_GEN_FW_B(u_short)
108 #ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
109 SYM_GEN_B(u_short, data_io)
110 #endif
111 SYM_GEN_B(u_short, start64)
112 SYM_GEN_B(u_short, pm_handle)
114 struct sym_fwz_ofs {
115 SYM_GEN_FW_Z(u_short)
119 * Generates structure interface that contains
120 * bus addresses within script A, B and Z.
122 struct sym_fwa_ba {
123 SYM_GEN_FW_A(u32)
125 struct sym_fwb_ba {
126 SYM_GEN_FW_B(u32)
127 #ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
128 SYM_GEN_B(u32, data_io)
129 #endif
130 SYM_GEN_B(u32, start64);
131 SYM_GEN_B(u32, pm_handle);
133 struct sym_fwz_ba {
134 SYM_GEN_FW_Z(u32)
136 #undef SYM_GEN_A
137 #undef SYM_GEN_B
138 #undef SYM_GEN_Z
141 * Let cc know about the name of the controller data structure.
142 * We need this for function prototype declarations just below.
144 struct sym_hcb;
147 * Generic structure that defines a firmware.
149 struct sym_fw {
150 char *name; /* Name we want to print out */
151 u32 *a_base; /* Pointer to script A template */
152 int a_size; /* Size of script A */
153 struct sym_fwa_ofs
154 *a_ofs; /* Useful offsets in script A */
155 u32 *b_base; /* Pointer to script B template */
156 int b_size; /* Size of script B */
157 struct sym_fwb_ofs
158 *b_ofs; /* Useful offsets in script B */
159 u32 *z_base; /* Pointer to script Z template */
160 int z_size; /* Size of script Z */
161 struct sym_fwz_ofs
162 *z_ofs; /* Useful offsets in script Z */
163 /* Setup and patch methods for this firmware */
164 void (*setup)(struct sym_hcb *, struct sym_fw *);
165 void (*patch)(struct sym_hcb *);
169 * Macro used to declare a firmware.
171 #define SYM_FW_ENTRY(fw, name) \
173 name, \
174 (u32 *) &fw##a_scr, sizeof(fw##a_scr), &fw##a_ofs, \
175 (u32 *) &fw##b_scr, sizeof(fw##b_scr), &fw##b_ofs, \
176 (u32 *) &fw##z_scr, sizeof(fw##z_scr), &fw##z_ofs, \
177 fw##_setup, fw##_patch \
181 * Macros used from the C code to get useful
182 * SCRIPTS bus addresses.
184 #define SCRIPTA_BA(np, label) (np->fwa_bas.label)
185 #define SCRIPTB_BA(np, label) (np->fwb_bas.label)
186 #define SCRIPTZ_BA(np, label) (np->fwz_bas.label)
189 * Macros used by scripts definitions.
191 * HADDR_1 generates a reference to a field of the controller data.
192 * HADDR_2 generates a reference to a field of the controller data
193 * with offset.
194 * RADDR_1 generates a reference to a script processor register.
195 * RADDR_2 generates a reference to a script processor register
196 * with offset.
197 * PADDR_A generates a reference to another part of script A.
198 * PADDR_B generates a reference to another part of script B.
200 * SYM_GEN_PADDR_A and SYM_GEN_PADDR_B are used to define respectively
201 * the PADDR_A and PADDR_B macros for each firmware by setting argument
202 * `s' to the name of the corresponding structure.
204 * SCR_DATA_ZERO is used to allocate a DWORD of data in scripts areas.
207 #define RELOC_SOFTC 0x40000000
208 #define RELOC_LABEL_A 0x50000000
209 #define RELOC_REGISTER 0x60000000
210 #define RELOC_LABEL_B 0x80000000
211 #define RELOC_MASK 0xf0000000
213 #define HADDR_1(label) (RELOC_SOFTC | offsetof(struct sym_hcb, label))
214 #define HADDR_2(label,ofs) (RELOC_SOFTC | \
215 (offsetof(struct sym_hcb, label)+(ofs)))
216 #define RADDR_1(label) (RELOC_REGISTER | REG(label))
217 #define RADDR_2(label,ofs) (RELOC_REGISTER | ((REG(label))+(ofs)))
219 #define SYM_GEN_PADDR_A(s, label) (RELOC_LABEL_A | offsetof(s, label))
220 #define SYM_GEN_PADDR_B(s, label) (RELOC_LABEL_B | offsetof(s, label))
222 #define SCR_DATA_ZERO 0xf00ff00f
224 #endif /* SYM_FW_H */