Linux-2.6.12-rc2
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / scsi / sym53c8xx_2 / sym_fw.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 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 2 of the License, or
28 * (at your option) any later version.
29 *
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 */
39
40 #ifndef SYM_FW_H
41 #define SYM_FW_H
42 /*
43 * Macro used to generate interfaces for script A.
44 */
45 #define SYM_GEN_FW_A(s) \
46 SYM_GEN_A(s, start) SYM_GEN_A(s, getjob_begin) \
47 SYM_GEN_A(s, getjob_end) \
48 SYM_GEN_A(s, select) SYM_GEN_A(s, wf_sel_done) \
49 SYM_GEN_A(s, send_ident) \
50 SYM_GEN_A(s, dispatch) SYM_GEN_A(s, init) \
51 SYM_GEN_A(s, clrack) SYM_GEN_A(s, complete_error) \
52 SYM_GEN_A(s, done) SYM_GEN_A(s, done_end) \
53 SYM_GEN_A(s, idle) SYM_GEN_A(s, ungetjob) \
54 SYM_GEN_A(s, reselect) \
55 SYM_GEN_A(s, resel_tag) SYM_GEN_A(s, resel_dsa) \
56 SYM_GEN_A(s, resel_no_tag) \
57 SYM_GEN_A(s, data_in) SYM_GEN_A(s, data_in2) \
58 SYM_GEN_A(s, data_out) SYM_GEN_A(s, data_out2) \
59 SYM_GEN_A(s, pm0_data) SYM_GEN_A(s, pm1_data)
60
61 /*
62 * Macro used to generate interfaces for script B.
63 */
64 #define SYM_GEN_FW_B(s) \
65 SYM_GEN_B(s, no_data) \
66 SYM_GEN_B(s, sel_for_abort) SYM_GEN_B(s, sel_for_abort_1) \
67 SYM_GEN_B(s, msg_bad) SYM_GEN_B(s, msg_weird) \
68 SYM_GEN_B(s, wdtr_resp) SYM_GEN_B(s, send_wdtr) \
69 SYM_GEN_B(s, sdtr_resp) SYM_GEN_B(s, send_sdtr) \
70 SYM_GEN_B(s, ppr_resp) SYM_GEN_B(s, send_ppr) \
71 SYM_GEN_B(s, nego_bad_phase) \
72 SYM_GEN_B(s, ident_break) SYM_GEN_B(s, ident_break_atn) \
73 SYM_GEN_B(s, sdata_in) SYM_GEN_B(s, resel_bad_lun) \
74 SYM_GEN_B(s, bad_i_t_l) SYM_GEN_B(s, bad_i_t_l_q) \
75 SYM_GEN_B(s, wsr_ma_helper)
76
77 /*
78 * Macro used to generate interfaces for script Z.
79 */
80 #define SYM_GEN_FW_Z(s) \
81 SYM_GEN_Z(s, snooptest) SYM_GEN_Z(s, snoopend)
82
83 /*
84 * Generates structure interface that contains
85 * offsets within script A, B and Z.
86 */
87 #define SYM_GEN_A(s, label) s label;
88 #define SYM_GEN_B(s, label) s label;
89 #define SYM_GEN_Z(s, label) s label;
90 struct sym_fwa_ofs {
91 SYM_GEN_FW_A(u_short)
92 };
93 struct sym_fwb_ofs {
94 SYM_GEN_FW_B(u_short)
95 #ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
96 SYM_GEN_B(u_short, data_io)
97 #endif
98 SYM_GEN_B(u_short, start64)
99 SYM_GEN_B(u_short, pm_handle)
100 };
101 struct sym_fwz_ofs {
102 SYM_GEN_FW_Z(u_short)
103 };
104
105 /*
106 * Generates structure interface that contains
107 * bus addresses within script A, B and Z.
108 */
109 struct sym_fwa_ba {
110 SYM_GEN_FW_A(u32)
111 };
112 struct sym_fwb_ba {
113 SYM_GEN_FW_B(u32)
114 #ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
115 SYM_GEN_B(u32, data_io)
116 #endif
117 SYM_GEN_B(u32, start64);
118 SYM_GEN_B(u32, pm_handle);
119 };
120 struct sym_fwz_ba {
121 SYM_GEN_FW_Z(u32)
122 };
123 #undef SYM_GEN_A
124 #undef SYM_GEN_B
125 #undef SYM_GEN_Z
126
127 /*
128 * Let cc know about the name of the controller data structure.
129 * We need this for function prototype declarations just below.
130 */
131 struct sym_hcb;
132
133 /*
134 * Generic structure that defines a firmware.
135 */
136 struct sym_fw {
137 char *name; /* Name we want to print out */
138 u32 *a_base; /* Pointer to script A template */
139 int a_size; /* Size of script A */
140 struct sym_fwa_ofs
141 *a_ofs; /* Useful offsets in script A */
142 u32 *b_base; /* Pointer to script B template */
143 int b_size; /* Size of script B */
144 struct sym_fwb_ofs
145 *b_ofs; /* Useful offsets in script B */
146 u32 *z_base; /* Pointer to script Z template */
147 int z_size; /* Size of script Z */
148 struct sym_fwz_ofs
149 *z_ofs; /* Useful offsets in script Z */
150 /* Setup and patch methods for this firmware */
151 void (*setup)(struct sym_hcb *, struct sym_fw *);
152 void (*patch)(struct sym_hcb *);
153 };
154
155 /*
156 * Macro used to declare a firmware.
157 */
158 #define SYM_FW_ENTRY(fw, name) \
159 { \
160 name, \
161 (u32 *) &fw##a_scr, sizeof(fw##a_scr), &fw##a_ofs, \
162 (u32 *) &fw##b_scr, sizeof(fw##b_scr), &fw##b_ofs, \
163 (u32 *) &fw##z_scr, sizeof(fw##z_scr), &fw##z_ofs, \
164 fw##_setup, fw##_patch \
165 }
166
167 /*
168 * Macros used from the C code to get useful
169 * SCRIPTS bus addresses.
170 */
171 #define SCRIPTA_BA(np, label) (np->fwa_bas.label)
172 #define SCRIPTB_BA(np, label) (np->fwb_bas.label)
173 #define SCRIPTZ_BA(np, label) (np->fwz_bas.label)
174
175 /*
176 * Macros used by scripts definitions.
177 *
178 * HADDR_1 generates a reference to a field of the controller data.
179 * HADDR_2 generates a reference to a field of the controller data
180 * with offset.
181 * RADDR_1 generates a reference to a script processor register.
182 * RADDR_2 generates a reference to a script processor register
183 * with offset.
184 * PADDR_A generates a reference to another part of script A.
185 * PADDR_B generates a reference to another part of script B.
186 *
187 * SYM_GEN_PADDR_A and SYM_GEN_PADDR_B are used to define respectively
188 * the PADDR_A and PADDR_B macros for each firmware by setting argument
189 * `s' to the name of the corresponding structure.
190 *
191 * SCR_DATA_ZERO is used to allocate a DWORD of data in scripts areas.
192 */
193
194 #define RELOC_SOFTC 0x40000000
195 #define RELOC_LABEL_A 0x50000000
196 #define RELOC_REGISTER 0x60000000
197 #define RELOC_LABEL_B 0x80000000
198 #define RELOC_MASK 0xf0000000
199
200 #define HADDR_1(label) (RELOC_SOFTC | offsetof(struct sym_hcb, label))
201 #define HADDR_2(label,ofs) (RELOC_SOFTC | \
202 (offsetof(struct sym_hcb, label)+(ofs)))
203 #define RADDR_1(label) (RELOC_REGISTER | REG(label))
204 #define RADDR_2(label,ofs) (RELOC_REGISTER | ((REG(label))+(ofs)))
205
206 #define SYM_GEN_PADDR_A(s, label) (RELOC_LABEL_A | offsetof(s, label))
207 #define SYM_GEN_PADDR_B(s, label) (RELOC_LABEL_B | offsetof(s, label))
208
209 #define SCR_DATA_ZERO 0xf00ff00f
210
211 #endif /* SYM_FW_H */