blob: ab9108293d0f4be49a64f08ca40677e8f839ce01 [file] [log] [blame]
Matthew Wilcox01fbfe02007-09-09 08:56:40 -06001#define DRV_NAME "advansys"
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -04002#define ASC_VERSION "3.4" /* AdvanSys Driver Version */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4/*
5 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
6 *
7 * Copyright (c) 1995-2000 Advanced System Products, Inc.
8 * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -04009 * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * All Rights Reserved.
11 *
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040012 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */
17
18/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
20 * changed its name to ConnectCom Solutions, Inc.
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040021 * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 */
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/string.h>
26#include <linux/kernel.h>
27#include <linux/types.h>
28#include <linux/ioport.h>
29#include <linux/interrupt.h>
30#include <linux/delay.h>
31#include <linux/slab.h>
32#include <linux/mm.h>
33#include <linux/proc_fs.h>
34#include <linux/init.h>
35#include <linux/blkdev.h>
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060036#include <linux/isa.h>
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060037#include <linux/eisa.h>
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040038#include <linux/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/spinlock.h>
40#include <linux/dma-mapping.h>
41
42#include <asm/io.h>
43#include <asm/system.h>
44#include <asm/dma.h>
45
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040046#include <scsi/scsi_cmnd.h>
47#include <scsi/scsi_device.h>
48#include <scsi/scsi_tcq.h>
49#include <scsi/scsi.h>
50#include <scsi/scsi_host.h>
51
Matthew Wilcox4bd6d7f2007-07-30 08:41:03 -060052/* FIXME:
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
Matthew Wilcox4bd6d7f2007-07-30 08:41:03 -060054 * 1. Although all of the necessary command mapping places have the
55 * appropriate dma_map.. APIs, the driver still processes its internal
56 * queue using bus_to_virt() and virt_to_bus() which are illegal under
57 * the API. The entire queue processing structure will need to be
58 * altered to fix this.
59 * 2. Need to add memory mapping workaround. Test the memory mapping.
60 * If it doesn't work revert to I/O port access. Can a test be done
61 * safely?
62 * 3. Handle an interrupt not working. Keep an interrupt counter in
63 * the interrupt handler. In the timeout function if the interrupt
64 * has not occurred then print a message and run in polled mode.
65 * 4. Need to add support for target mode commands, cf. CAM XPT.
66 * 5. check DMA mapping functions for failure
Matthew Wilcox349d2c42007-09-09 08:56:34 -060067 * 6. Use scsi_transport_spi
68 * 7. advansys_info is not safe against multiple simultaneous callers
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040069 * 8. Add module_param to override ISA/VLB ioport array
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 */
71#warning this driver is still not properly converted to the DMA API
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073/* Enable driver /proc statistics. */
74#define ADVANSYS_STATS
75
76/* Enable driver tracing. */
Matthew Wilcoxb352f922007-10-02 21:55:33 -040077#undef ADVANSYS_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Linus Torvalds1da177e2005-04-16 15:20:36 -070079/*
80 * Portable Data Types
81 *
82 * Any instance where a 32-bit long or pointer type is assumed
83 * for precision or HW defined structures, the following define
84 * types must be used. In Linux the char, short, and int types
85 * are all consistent at 8, 16, and 32 bits respectively. Pointers
86 * and long types are 64 bits on Alpha and UltraSPARC.
87 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -040088#define ASC_PADDR __u32 /* Physical/Bus address data type. */
89#define ASC_VADDR __u32 /* Virtual address data type. */
90#define ASC_DCNT __u32 /* Unsigned Data count type. */
91#define ASC_SDCNT __s32 /* Signed Data count type. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93/*
94 * These macros are used to convert a virtual address to a
95 * 32-bit value. This currently can be used on Linux Alpha
96 * which uses 64-bit virtual address but a 32-bit bus address.
97 * This is likely to break in the future, but doing this now
98 * will give us time to change the HW and FW to handle 64-bit
99 * addresses.
100 */
101#define ASC_VADDR_TO_U32 virt_to_bus
102#define ASC_U32_TO_VADDR bus_to_virt
103
104typedef unsigned char uchar;
105
106#ifndef TRUE
107#define TRUE (1)
108#endif
109#ifndef FALSE
110#define FALSE (0)
111#endif
112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113#define ERR (-1)
114#define UW_ERR (uint)(0xFFFF)
115#define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Dave Jones2672ea82006-08-02 17:11:49 -0400117#define PCI_VENDOR_ID_ASP 0x10cd
118#define PCI_DEVICE_ID_ASP_1200A 0x1100
119#define PCI_DEVICE_ID_ASP_ABP940 0x1200
120#define PCI_DEVICE_ID_ASP_ABP940U 0x1300
121#define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
122#define PCI_DEVICE_ID_38C0800_REV1 0x2500
123#define PCI_DEVICE_ID_38C1600_REV1 0x2700
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125/*
126 * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
127 * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
128 * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
129 * SRB structure.
130 */
131#define CC_VERY_LONG_SG_LIST 0
132#define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
133
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400134#define PortAddr unsigned short /* port address size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#define inp(port) inb(port)
136#define outp(port, byte) outb((byte), (port))
137
138#define inpw(port) inw(port)
139#define outpw(port, word) outw((word), (port))
140
141#define ASC_MAX_SG_QUEUE 7
142#define ASC_MAX_SG_LIST 255
143
144#define ASC_CS_TYPE unsigned short
145
146#define ASC_IS_ISA (0x0001)
147#define ASC_IS_ISAPNP (0x0081)
148#define ASC_IS_EISA (0x0002)
149#define ASC_IS_PCI (0x0004)
150#define ASC_IS_PCI_ULTRA (0x0104)
151#define ASC_IS_PCMCIA (0x0008)
152#define ASC_IS_MCA (0x0020)
153#define ASC_IS_VL (0x0040)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#define ASC_IS_WIDESCSI_16 (0x0100)
155#define ASC_IS_WIDESCSI_32 (0x0200)
156#define ASC_IS_BIG_ENDIAN (0x8000)
Matthew Wilcox95c9f162007-09-09 08:56:39 -0600157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#define ASC_CHIP_MIN_VER_VL (0x01)
159#define ASC_CHIP_MAX_VER_VL (0x07)
160#define ASC_CHIP_MIN_VER_PCI (0x09)
161#define ASC_CHIP_MAX_VER_PCI (0x0F)
162#define ASC_CHIP_VER_PCI_BIT (0x08)
163#define ASC_CHIP_MIN_VER_ISA (0x11)
164#define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
165#define ASC_CHIP_MAX_VER_ISA (0x27)
166#define ASC_CHIP_VER_ISA_BIT (0x30)
167#define ASC_CHIP_VER_ISAPNP_BIT (0x20)
168#define ASC_CHIP_VER_ASYN_BUG (0x21)
169#define ASC_CHIP_VER_PCI 0x08
170#define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
171#define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
172#define ASC_CHIP_MIN_VER_EISA (0x41)
173#define ASC_CHIP_MAX_VER_EISA (0x47)
174#define ASC_CHIP_VER_EISA_BIT (0x40)
175#define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176#define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177#define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178#define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
180#define ASC_SCSI_ID_BITS 3
181#define ASC_SCSI_TIX_TYPE uchar
182#define ASC_ALL_DEVICE_BIT_SET 0xFF
183#define ASC_SCSI_BIT_ID_TYPE uchar
184#define ASC_MAX_TID 7
185#define ASC_MAX_LUN 7
186#define ASC_SCSI_WIDTH_BIT_SET 0xFF
187#define ASC_MAX_SENSE_LEN 32
188#define ASC_MIN_SENSE_LEN 14
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189#define ASC_SCSI_RESET_HOLD_TIME_US 60
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191/*
Matthew Wilcoxf05ec592007-09-09 08:56:36 -0600192 * Narrow boards only support 12-byte commands, while wide boards
193 * extend to 16-byte commands.
194 */
195#define ASC_MAX_CDB_LEN 12
196#define ADV_MAX_CDB_LEN 16
197
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198#define MS_SDTR_LEN 0x03
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199#define MS_WDTR_LEN 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201#define ASC_SG_LIST_PER_Q 7
202#define QS_FREE 0x00
203#define QS_READY 0x01
204#define QS_DISC1 0x02
205#define QS_DISC2 0x04
206#define QS_BUSY 0x08
207#define QS_ABORTED 0x40
208#define QS_DONE 0x80
209#define QC_NO_CALLBACK 0x01
210#define QC_SG_SWAP_QUEUE 0x02
211#define QC_SG_HEAD 0x04
212#define QC_DATA_IN 0x08
213#define QC_DATA_OUT 0x10
214#define QC_URGENT 0x20
215#define QC_MSG_OUT 0x40
216#define QC_REQ_SENSE 0x80
217#define QCSG_SG_XFER_LIST 0x02
218#define QCSG_SG_XFER_MORE 0x04
219#define QCSG_SG_XFER_END 0x08
220#define QD_IN_PROGRESS 0x00
221#define QD_NO_ERROR 0x01
222#define QD_ABORTED_BY_HOST 0x02
223#define QD_WITH_ERROR 0x04
224#define QD_INVALID_REQUEST 0x80
225#define QD_INVALID_HOST_NUM 0x81
226#define QD_INVALID_DEVICE 0x82
227#define QD_ERR_INTERNAL 0xFF
228#define QHSTA_NO_ERROR 0x00
229#define QHSTA_M_SEL_TIMEOUT 0x11
230#define QHSTA_M_DATA_OVER_RUN 0x12
231#define QHSTA_M_DATA_UNDER_RUN 0x12
232#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
233#define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
234#define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
235#define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
236#define QHSTA_D_HOST_ABORT_FAILED 0x23
237#define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
238#define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
239#define QHSTA_D_ASPI_NO_BUF_POOL 0x26
240#define QHSTA_M_WTM_TIMEOUT 0x41
241#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
242#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
243#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
244#define QHSTA_M_TARGET_STATUS_BUSY 0x45
245#define QHSTA_M_BAD_TAG_CODE 0x46
246#define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
247#define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
248#define QHSTA_D_LRAM_CMP_ERROR 0x81
249#define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
250#define ASC_FLAG_SCSIQ_REQ 0x01
251#define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
252#define ASC_FLAG_BIOS_ASYNC_IO 0x04
253#define ASC_FLAG_SRB_LINEAR_ADDR 0x08
254#define ASC_FLAG_WIN16 0x10
255#define ASC_FLAG_WIN32 0x20
256#define ASC_FLAG_ISA_OVER_16MB 0x40
257#define ASC_FLAG_DOS_VM_CALLBACK 0x80
258#define ASC_TAG_FLAG_EXTRA_BYTES 0x10
259#define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
260#define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
261#define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
262#define ASC_SCSIQ_CPY_BEG 4
263#define ASC_SCSIQ_SGHD_CPY_BEG 2
264#define ASC_SCSIQ_B_FWD 0
265#define ASC_SCSIQ_B_BWD 1
266#define ASC_SCSIQ_B_STATUS 2
267#define ASC_SCSIQ_B_QNO 3
268#define ASC_SCSIQ_B_CNTL 4
269#define ASC_SCSIQ_B_SG_QUEUE_CNT 5
270#define ASC_SCSIQ_D_DATA_ADDR 8
271#define ASC_SCSIQ_D_DATA_CNT 12
272#define ASC_SCSIQ_B_SENSE_LEN 20
273#define ASC_SCSIQ_DONE_INFO_BEG 22
274#define ASC_SCSIQ_D_SRBPTR 22
275#define ASC_SCSIQ_B_TARGET_IX 26
276#define ASC_SCSIQ_B_CDB_LEN 28
277#define ASC_SCSIQ_B_TAG_CODE 29
278#define ASC_SCSIQ_W_VM_ID 30
279#define ASC_SCSIQ_DONE_STATUS 32
280#define ASC_SCSIQ_HOST_STATUS 33
281#define ASC_SCSIQ_SCSI_STATUS 34
282#define ASC_SCSIQ_CDB_BEG 36
283#define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
284#define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
285#define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
286#define ASC_SCSIQ_B_SG_WK_QP 49
287#define ASC_SCSIQ_B_SG_WK_IX 50
288#define ASC_SCSIQ_W_ALT_DC1 52
289#define ASC_SCSIQ_B_LIST_CNT 6
290#define ASC_SCSIQ_B_CUR_LIST_CNT 7
291#define ASC_SGQ_B_SG_CNTL 4
292#define ASC_SGQ_B_SG_HEAD_QP 5
293#define ASC_SGQ_B_SG_LIST_CNT 6
294#define ASC_SGQ_B_SG_CUR_LIST_CNT 7
295#define ASC_SGQ_LIST_BEG 8
296#define ASC_DEF_SCSI1_QNG 4
297#define ASC_MAX_SCSI1_QNG 4
298#define ASC_DEF_SCSI2_QNG 16
299#define ASC_MAX_SCSI2_QNG 32
300#define ASC_TAG_CODE_MASK 0x23
301#define ASC_STOP_REQ_RISC_STOP 0x01
302#define ASC_STOP_ACK_RISC_STOP 0x03
303#define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
304#define ASC_STOP_CLEAN_UP_DISC_Q 0x20
305#define ASC_STOP_HOST_REQ_RISC_HALT 0x40
306#define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
307#define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
308#define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
309#define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
310#define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
311#define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
312#define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
313
314typedef struct asc_scsiq_1 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400315 uchar status;
316 uchar q_no;
317 uchar cntl;
318 uchar sg_queue_cnt;
319 uchar target_id;
320 uchar target_lun;
321 ASC_PADDR data_addr;
322 ASC_DCNT data_cnt;
323 ASC_PADDR sense_addr;
324 uchar sense_len;
325 uchar extra_bytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326} ASC_SCSIQ_1;
327
328typedef struct asc_scsiq_2 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400329 ASC_VADDR srb_ptr;
330 uchar target_ix;
331 uchar flag;
332 uchar cdb_len;
333 uchar tag_code;
334 ushort vm_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335} ASC_SCSIQ_2;
336
337typedef struct asc_scsiq_3 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400338 uchar done_stat;
339 uchar host_stat;
340 uchar scsi_stat;
341 uchar scsi_msg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342} ASC_SCSIQ_3;
343
344typedef struct asc_scsiq_4 {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400345 uchar cdb[ASC_MAX_CDB_LEN];
346 uchar y_first_sg_list_qp;
347 uchar y_working_sg_qp;
348 uchar y_working_sg_ix;
349 uchar y_res;
350 ushort x_req_count;
351 ushort x_reconnect_rtn;
352 ASC_PADDR x_saved_data_addr;
353 ASC_DCNT x_saved_data_cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354} ASC_SCSIQ_4;
355
356typedef struct asc_q_done_info {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400357 ASC_SCSIQ_2 d2;
358 ASC_SCSIQ_3 d3;
359 uchar q_status;
360 uchar q_no;
361 uchar cntl;
362 uchar sense_len;
363 uchar extra_bytes;
364 uchar res;
365 ASC_DCNT remain_bytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366} ASC_QDONE_INFO;
367
368typedef struct asc_sg_list {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400369 ASC_PADDR addr;
370 ASC_DCNT bytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371} ASC_SG_LIST;
372
373typedef struct asc_sg_head {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400374 ushort entry_cnt;
375 ushort queue_cnt;
376 ushort entry_to_copy;
377 ushort res;
Matthew Wilcox05848b62007-10-02 21:55:25 -0400378 ASC_SG_LIST sg_list[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379} ASC_SG_HEAD;
380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381typedef struct asc_scsi_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400382 ASC_SCSIQ_1 q1;
383 ASC_SCSIQ_2 q2;
384 uchar *cdbptr;
385 ASC_SG_HEAD *sg_head;
386 ushort remain_sg_entry_cnt;
387 ushort next_sg_index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388} ASC_SCSI_Q;
389
390typedef struct asc_scsi_req_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400391 ASC_SCSIQ_1 r1;
392 ASC_SCSIQ_2 r2;
393 uchar *cdbptr;
394 ASC_SG_HEAD *sg_head;
395 uchar *sense_ptr;
396 ASC_SCSIQ_3 r3;
397 uchar cdb[ASC_MAX_CDB_LEN];
398 uchar sense[ASC_MIN_SENSE_LEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399} ASC_SCSI_REQ_Q;
400
401typedef struct asc_scsi_bios_req_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400402 ASC_SCSIQ_1 r1;
403 ASC_SCSIQ_2 r2;
404 uchar *cdbptr;
405 ASC_SG_HEAD *sg_head;
406 uchar *sense_ptr;
407 ASC_SCSIQ_3 r3;
408 uchar cdb[ASC_MAX_CDB_LEN];
409 uchar sense[ASC_MIN_SENSE_LEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410} ASC_SCSI_BIOS_REQ_Q;
411
412typedef struct asc_risc_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400413 uchar fwd;
414 uchar bwd;
415 ASC_SCSIQ_1 i1;
416 ASC_SCSIQ_2 i2;
417 ASC_SCSIQ_3 i3;
418 ASC_SCSIQ_4 i4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419} ASC_RISC_Q;
420
421typedef struct asc_sg_list_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400422 uchar seq_no;
423 uchar q_no;
424 uchar cntl;
425 uchar sg_head_qp;
426 uchar sg_list_cnt;
427 uchar sg_cur_list_cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428} ASC_SG_LIST_Q;
429
430typedef struct asc_risc_sg_list_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400431 uchar fwd;
432 uchar bwd;
433 ASC_SG_LIST_Q sg;
434 ASC_SG_LIST sg_list[7];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435} ASC_RISC_SG_LIST_Q;
436
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437#define ASCQ_ERR_Q_STATUS 0x0D
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438#define ASCQ_ERR_CUR_QNG 0x17
439#define ASCQ_ERR_SG_Q_LINKS 0x18
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440#define ASCQ_ERR_ISR_RE_ENTRY 0x1A
441#define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
442#define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
444/*
445 * Warning code values are set in ASC_DVC_VAR 'warn_code'.
446 */
447#define ASC_WARN_NO_ERROR 0x0000
448#define ASC_WARN_IO_PORT_ROTATE 0x0001
449#define ASC_WARN_EEPROM_CHKSUM 0x0002
450#define ASC_WARN_IRQ_MODIFIED 0x0004
451#define ASC_WARN_AUTO_CONFIG 0x0008
452#define ASC_WARN_CMD_QNG_CONFLICT 0x0010
453#define ASC_WARN_EEPROM_RECOVER 0x0020
454#define ASC_WARN_CFG_MSW_RECOVER 0x0040
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456/*
Matthew Wilcox720349a2007-10-02 21:55:30 -0400457 * Error code values are set in {ASC/ADV}_DVC_VAR 'err_code'.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 */
Matthew Wilcox720349a2007-10-02 21:55:30 -0400459#define ASC_IERR_NO_CARRIER 0x0001 /* No more carrier memory */
460#define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
461#define ASC_IERR_SET_PC_ADDR 0x0004
462#define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
463#define ASC_IERR_ILLEGAL_CONNECTION 0x0010 /* Illegal cable connection */
464#define ASC_IERR_SINGLE_END_DEVICE 0x0020 /* SE device on DIFF bus */
465#define ASC_IERR_REVERSED_CABLE 0x0040 /* Narrow flat cable reversed */
466#define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
467#define ASC_IERR_HVD_DEVICE 0x0100 /* HVD device on LVD port */
468#define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
469#define ASC_IERR_NO_BUS_TYPE 0x0400
470#define ASC_IERR_BIST_PRE_TEST 0x0800 /* BIST pre-test error */
471#define ASC_IERR_BIST_RAM_TEST 0x1000 /* BIST RAM test error */
472#define ASC_IERR_BAD_CHIPTYPE 0x2000 /* Invalid chip_type setting */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474#define ASC_DEF_MAX_TOTAL_QNG (0xF0)
475#define ASC_MIN_TAG_Q_PER_DVC (0x04)
Matthew Wilcox95c9f162007-09-09 08:56:39 -0600476#define ASC_MIN_FREE_Q (0x02)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477#define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
478#define ASC_MAX_TOTAL_QNG 240
479#define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
480#define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
481#define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
482#define ASC_MAX_INRAM_TAG_QNG 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483#define ASC_IOADR_GAP 0x10
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484#define ASC_SYN_MAX_OFFSET 0x0F
485#define ASC_DEF_SDTR_OFFSET 0x0F
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486#define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -0400487#define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
488
489/* The narrow chip only supports a limited selection of transfer rates.
490 * These are encoded in the range 0..7 or 0..15 depending whether the chip
491 * is Ultra-capable or not. These tables let us convert from one to the other.
492 */
493static const unsigned char asc_syn_xfer_period[8] = {
494 25, 30, 35, 40, 50, 60, 70, 85
495};
496
497static const unsigned char asc_syn_ultra_xfer_period[16] = {
498 12, 19, 25, 32, 38, 44, 50, 57, 63, 69, 75, 82, 88, 94, 100, 107
499};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
501typedef struct ext_msg {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400502 uchar msg_type;
503 uchar msg_len;
504 uchar msg_req;
505 union {
506 struct {
507 uchar sdtr_xfer_period;
508 uchar sdtr_req_ack_offset;
509 } sdtr;
510 struct {
511 uchar wdtr_width;
512 } wdtr;
513 struct {
514 uchar mdp_b3;
515 uchar mdp_b2;
516 uchar mdp_b1;
517 uchar mdp_b0;
518 } mdp;
519 } u_ext_msg;
520 uchar res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521} EXT_MSG;
522
523#define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
524#define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
525#define wdtr_width u_ext_msg.wdtr.wdtr_width
526#define mdp_b3 u_ext_msg.mdp_b3
527#define mdp_b2 u_ext_msg.mdp_b2
528#define mdp_b1 u_ext_msg.mdp_b1
529#define mdp_b0 u_ext_msg.mdp_b0
530
531typedef struct asc_dvc_cfg {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400532 ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
533 ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
534 ASC_SCSI_BIT_ID_TYPE disc_enable;
535 ASC_SCSI_BIT_ID_TYPE sdtr_enable;
536 uchar chip_scsi_id;
537 uchar isa_dma_speed;
538 uchar isa_dma_channel;
539 uchar chip_version;
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400540 ushort mcode_date;
541 ushort mcode_version;
542 uchar max_tag_qng[ASC_MAX_TID + 1];
543 uchar *overrun_buf;
544 uchar sdtr_period_offset[ASC_MAX_TID + 1];
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400545 uchar adapter_info[6];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546} ASC_DVC_CFG;
547
548#define ASC_DEF_DVC_CNTL 0xFFFF
549#define ASC_DEF_CHIP_SCSI_ID 7
550#define ASC_DEF_ISA_DMA_SPEED 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551#define ASC_INIT_STATE_BEG_GET_CFG 0x0001
552#define ASC_INIT_STATE_END_GET_CFG 0x0002
553#define ASC_INIT_STATE_BEG_SET_CFG 0x0004
554#define ASC_INIT_STATE_END_SET_CFG 0x0008
555#define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
556#define ASC_INIT_STATE_END_LOAD_MC 0x0020
557#define ASC_INIT_STATE_BEG_INQUIRY 0x0040
558#define ASC_INIT_STATE_END_INQUIRY 0x0080
559#define ASC_INIT_RESET_SCSI_DONE 0x0100
560#define ASC_INIT_STATE_WITHOUT_EEP 0x8000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561#define ASC_BUG_FIX_IF_NOT_DWB 0x0001
562#define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563#define ASC_MIN_TAGGED_CMD 7
564#define ASC_MAX_SCSI_RESET_WAIT 30
565
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400566struct asc_dvc_var; /* Forward Declaration. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568typedef struct asc_dvc_var {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400569 PortAddr iop_base;
570 ushort err_code;
571 ushort dvc_cntl;
572 ushort bug_fix_cntl;
573 ushort bus_type;
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400574 ASC_SCSI_BIT_ID_TYPE init_sdtr;
575 ASC_SCSI_BIT_ID_TYPE sdtr_done;
576 ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
577 ASC_SCSI_BIT_ID_TYPE unit_not_ready;
578 ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
579 ASC_SCSI_BIT_ID_TYPE start_motor;
580 uchar scsi_reset_wait;
581 uchar chip_no;
582 char is_in_int;
583 uchar max_total_qng;
584 uchar cur_total_qng;
585 uchar in_critical_cnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400586 uchar last_q_shortage;
587 ushort init_state;
588 uchar cur_dvc_qng[ASC_MAX_TID + 1];
589 uchar max_dvc_qng[ASC_MAX_TID + 1];
590 ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
591 ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -0400592 const uchar *sdtr_period_tbl;
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400593 ASC_DVC_CFG *cfg;
594 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
595 char redo_scam;
596 ushort res2;
597 uchar dos_int13_table[ASC_MAX_TID + 1];
598 ASC_DCNT max_dma_count;
599 ASC_SCSI_BIT_ID_TYPE no_scam;
600 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -0400601 uchar min_sdtr_index;
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400602 uchar max_sdtr_index;
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400603 struct asc_board *drv_ptr;
604 ASC_DCNT uc_break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605} ASC_DVC_VAR;
606
607typedef struct asc_dvc_inq_info {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400608 uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609} ASC_DVC_INQ_INFO;
610
611typedef struct asc_cap_info {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400612 ASC_DCNT lba;
613 ASC_DCNT blk_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614} ASC_CAP_INFO;
615
616typedef struct asc_cap_info_array {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400617 ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618} ASC_CAP_INFO_ARRAY;
619
620#define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
621#define ASC_MCNTL_NULL_TARGET (ushort)0x0002
622#define ASC_CNTL_INITIATOR (ushort)0x0001
623#define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
624#define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
625#define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
626#define ASC_CNTL_NO_SCAM (ushort)0x0010
627#define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
628#define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
629#define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
630#define ASC_CNTL_RESET_SCSI (ushort)0x0200
631#define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
632#define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
633#define ASC_CNTL_SCSI_PARITY (ushort)0x1000
634#define ASC_CNTL_BURST_MODE (ushort)0x2000
635#define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
636#define ASC_EEP_DVC_CFG_BEG_VL 2
637#define ASC_EEP_MAX_DVC_ADDR_VL 15
638#define ASC_EEP_DVC_CFG_BEG 32
639#define ASC_EEP_MAX_DVC_ADDR 45
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640#define ASC_EEP_MAX_RETRY 20
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641
642/*
643 * These macros keep the chip SCSI id and ISA DMA speed
644 * bitfields in board order. C bitfields aren't portable
645 * between big and little-endian platforms so they are
646 * not used.
647 */
648
649#define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
650#define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
651#define ASC_EEP_SET_CHIP_ID(cfg, sid) \
652 ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
653#define ASC_EEP_SET_DMA_SPD(cfg, spd) \
654 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
655
656typedef struct asceep_config {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400657 ushort cfg_lsw;
658 ushort cfg_msw;
659 uchar init_sdtr;
660 uchar disc_enable;
661 uchar use_cmd_qng;
662 uchar start_motor;
663 uchar max_total_qng;
664 uchar max_tag_qng;
665 uchar bios_scan;
666 uchar power_up_wait;
667 uchar no_scam;
668 uchar id_speed; /* low order 4 bits is chip scsi id */
669 /* high order 4 bits is isa dma speed */
670 uchar dos_int13_table[ASC_MAX_TID + 1];
671 uchar adapter_info[6];
672 ushort cntl;
673 ushort chksum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674} ASCEEP_CONFIG;
675
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676#define ASC_EEP_CMD_READ 0x80
677#define ASC_EEP_CMD_WRITE 0x40
678#define ASC_EEP_CMD_WRITE_ABLE 0x30
679#define ASC_EEP_CMD_WRITE_DISABLE 0x00
680#define ASC_OVERRUN_BSIZE 0x00000048UL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681#define ASCV_MSGOUT_BEG 0x0000
682#define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
683#define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
684#define ASCV_BREAK_SAVED_CODE (ushort)0x0006
685#define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
686#define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
687#define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
688#define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
689#define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
690#define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
691#define ASCV_BREAK_ADDR (ushort)0x0028
692#define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
693#define ASCV_BREAK_CONTROL (ushort)0x002C
694#define ASCV_BREAK_HIT_COUNT (ushort)0x002E
695
696#define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
697#define ASCV_MCODE_CHKSUM_W (ushort)0x0032
698#define ASCV_MCODE_SIZE_W (ushort)0x0034
699#define ASCV_STOP_CODE_B (ushort)0x0036
700#define ASCV_DVC_ERR_CODE_B (ushort)0x0037
701#define ASCV_OVERRUN_PADDR_D (ushort)0x0038
702#define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
703#define ASCV_HALTCODE_W (ushort)0x0040
704#define ASCV_CHKSUM_W (ushort)0x0042
705#define ASCV_MC_DATE_W (ushort)0x0044
706#define ASCV_MC_VER_W (ushort)0x0046
707#define ASCV_NEXTRDY_B (ushort)0x0048
708#define ASCV_DONENEXT_B (ushort)0x0049
709#define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
710#define ASCV_SCSIBUSY_B (ushort)0x004B
711#define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
712#define ASCV_CURCDB_B (ushort)0x004D
713#define ASCV_RCLUN_B (ushort)0x004E
714#define ASCV_BUSY_QHEAD_B (ushort)0x004F
715#define ASCV_DISC1_QHEAD_B (ushort)0x0050
716#define ASCV_DISC_ENABLE_B (ushort)0x0052
717#define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
718#define ASCV_HOSTSCSI_ID_B (ushort)0x0055
719#define ASCV_MCODE_CNTL_B (ushort)0x0056
720#define ASCV_NULL_TARGET_B (ushort)0x0057
721#define ASCV_FREE_Q_HEAD_W (ushort)0x0058
722#define ASCV_DONE_Q_TAIL_W (ushort)0x005A
723#define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
724#define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
725#define ASCV_HOST_FLAG_B (ushort)0x005D
726#define ASCV_TOTAL_READY_Q_B (ushort)0x0064
727#define ASCV_VER_SERIAL_B (ushort)0x0065
728#define ASCV_HALTCODE_SAVED_W (ushort)0x0066
729#define ASCV_WTM_FLAG_B (ushort)0x0068
730#define ASCV_RISC_FLAG_B (ushort)0x006A
731#define ASCV_REQ_SG_LIST_QP (ushort)0x006B
732#define ASC_HOST_FLAG_IN_ISR 0x01
733#define ASC_HOST_FLAG_ACK_INT 0x02
734#define ASC_RISC_FLAG_GEN_INT 0x01
735#define ASC_RISC_FLAG_REQ_SG_LIST 0x02
736#define IOP_CTRL (0x0F)
737#define IOP_STATUS (0x0E)
738#define IOP_INT_ACK IOP_STATUS
739#define IOP_REG_IFC (0x0D)
740#define IOP_SYN_OFFSET (0x0B)
741#define IOP_EXTRA_CONTROL (0x0D)
742#define IOP_REG_PC (0x0C)
743#define IOP_RAM_ADDR (0x0A)
744#define IOP_RAM_DATA (0x08)
745#define IOP_EEP_DATA (0x06)
746#define IOP_EEP_CMD (0x07)
747#define IOP_VERSION (0x03)
748#define IOP_CONFIG_HIGH (0x04)
749#define IOP_CONFIG_LOW (0x02)
750#define IOP_SIG_BYTE (0x01)
751#define IOP_SIG_WORD (0x00)
752#define IOP_REG_DC1 (0x0E)
753#define IOP_REG_DC0 (0x0C)
754#define IOP_REG_SB (0x0B)
755#define IOP_REG_DA1 (0x0A)
756#define IOP_REG_DA0 (0x08)
757#define IOP_REG_SC (0x09)
758#define IOP_DMA_SPEED (0x07)
759#define IOP_REG_FLAG (0x07)
760#define IOP_FIFO_H (0x06)
761#define IOP_FIFO_L (0x04)
762#define IOP_REG_ID (0x05)
763#define IOP_REG_QP (0x03)
764#define IOP_REG_IH (0x02)
765#define IOP_REG_IX (0x01)
766#define IOP_REG_AX (0x00)
767#define IFC_REG_LOCK (0x00)
768#define IFC_REG_UNLOCK (0x09)
769#define IFC_WR_EN_FILTER (0x10)
770#define IFC_RD_NO_EEPROM (0x10)
771#define IFC_SLEW_RATE (0x20)
772#define IFC_ACT_NEG (0x40)
773#define IFC_INP_FILTER (0x80)
774#define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
775#define SC_SEL (uchar)(0x80)
776#define SC_BSY (uchar)(0x40)
777#define SC_ACK (uchar)(0x20)
778#define SC_REQ (uchar)(0x10)
779#define SC_ATN (uchar)(0x08)
780#define SC_IO (uchar)(0x04)
781#define SC_CD (uchar)(0x02)
782#define SC_MSG (uchar)(0x01)
783#define SEC_SCSI_CTL (uchar)(0x80)
784#define SEC_ACTIVE_NEGATE (uchar)(0x40)
785#define SEC_SLEW_RATE (uchar)(0x20)
786#define SEC_ENABLE_FILTER (uchar)(0x10)
787#define ASC_HALT_EXTMSG_IN (ushort)0x8000
788#define ASC_HALT_CHK_CONDITION (ushort)0x8100
789#define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
790#define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
791#define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
792#define ASC_HALT_SDTR_REJECTED (ushort)0x4000
793#define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
794#define ASC_MAX_QNO 0xF8
795#define ASC_DATA_SEC_BEG (ushort)0x0080
796#define ASC_DATA_SEC_END (ushort)0x0080
797#define ASC_CODE_SEC_BEG (ushort)0x0080
798#define ASC_CODE_SEC_END (ushort)0x0080
799#define ASC_QADR_BEG (0x4000)
800#define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
801#define ASC_QADR_END (ushort)0x7FFF
802#define ASC_QLAST_ADR (ushort)0x7FC0
803#define ASC_QBLK_SIZE 0x40
804#define ASC_BIOS_DATA_QBEG 0xF8
805#define ASC_MIN_ACTIVE_QNO 0x01
806#define ASC_QLINK_END 0xFF
807#define ASC_EEPROM_WORDS 0x10
808#define ASC_MAX_MGS_LEN 0x10
809#define ASC_BIOS_ADDR_DEF 0xDC00
810#define ASC_BIOS_SIZE 0x3800
811#define ASC_BIOS_RAM_OFF 0x3800
812#define ASC_BIOS_RAM_SIZE 0x800
813#define ASC_BIOS_MIN_ADDR 0xC000
814#define ASC_BIOS_MAX_ADDR 0xEC00
815#define ASC_BIOS_BANK_SIZE 0x0400
816#define ASC_MCODE_START_ADDR 0x0080
817#define ASC_CFG0_HOST_INT_ON 0x0020
818#define ASC_CFG0_BIOS_ON 0x0040
819#define ASC_CFG0_VERA_BURST_ON 0x0080
820#define ASC_CFG0_SCSI_PARITY_ON 0x0800
821#define ASC_CFG1_SCSI_TARGET_ON 0x0080
822#define ASC_CFG1_LRAM_8BITS_ON 0x0800
823#define ASC_CFG_MSW_CLR_MASK 0x3080
824#define CSW_TEST1 (ASC_CS_TYPE)0x8000
825#define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
826#define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
827#define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
828#define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
829#define CSW_TEST2 (ASC_CS_TYPE)0x0400
830#define CSW_TEST3 (ASC_CS_TYPE)0x0200
831#define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
832#define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
833#define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
834#define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
835#define CSW_HALTED (ASC_CS_TYPE)0x0010
836#define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
837#define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
838#define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
839#define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
840#define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
841#define CIW_INT_ACK (ASC_CS_TYPE)0x0100
842#define CIW_TEST1 (ASC_CS_TYPE)0x0200
843#define CIW_TEST2 (ASC_CS_TYPE)0x0400
844#define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
845#define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
846#define CC_CHIP_RESET (uchar)0x80
847#define CC_SCSI_RESET (uchar)0x40
848#define CC_HALT (uchar)0x20
849#define CC_SINGLE_STEP (uchar)0x10
850#define CC_DMA_ABLE (uchar)0x08
851#define CC_TEST (uchar)0x04
852#define CC_BANK_ONE (uchar)0x02
853#define CC_DIAG (uchar)0x01
854#define ASC_1000_ID0W 0x04C1
855#define ASC_1000_ID0W_FIX 0x00C1
856#define ASC_1000_ID1B 0x25
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857#define ASC_EISA_REV_IOP_MASK (0x0C83)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858#define ASC_EISA_CFG_IOP_MASK (0x0C86)
859#define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860#define INS_HALTINT (ushort)0x6281
861#define INS_HALT (ushort)0x6280
862#define INS_SINT (ushort)0x6200
863#define INS_RFLAG_WTM (ushort)0x7380
864#define ASC_MC_SAVE_CODE_WSIZE 0x500
865#define ASC_MC_SAVE_DATA_WSIZE 0x40
866
867typedef struct asc_mc_saved {
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400868 ushort data[ASC_MC_SAVE_DATA_WSIZE];
869 ushort code[ASC_MC_SAVE_CODE_WSIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870} ASC_MC_SAVED;
871
872#define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
873#define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
874#define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
875#define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
876#define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
877#define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
878#define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
879#define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
880#define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
881#define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
Matthew Wilcox51219352007-10-02 21:55:22 -0400882#define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
883#define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
884#define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
885#define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886#define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
887#define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
888#define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
889#define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
890#define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
891#define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
892#define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
893#define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
894#define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
895#define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
896#define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
897#define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
898#define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
899#define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
900#define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
901#define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
902#define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
903#define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
904#define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
905#define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
906#define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
907#define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
908#define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
909#define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
910#define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
911#define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
912#define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
913#define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
914#define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
915#define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
916#define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
917#define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
918#define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
919#define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
920#define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
921#define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
922#define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
923#define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
924#define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
925#define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
926#define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
927#define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
928#define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
929#define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
930#define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
931#define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
932#define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
933#define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
934#define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
935#define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
936#define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
937#define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
938#define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
939
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940/*
941 * Portable Data Types
942 *
943 * Any instance where a 32-bit long or pointer type is assumed
944 * for precision or HW defined structures, the following define
945 * types must be used. In Linux the char, short, and int types
946 * are all consistent at 8, 16, and 32 bits respectively. Pointers
947 * and long types are 64 bits on Alpha and UltraSPARC.
948 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400949#define ADV_PADDR __u32 /* Physical address data type. */
950#define ADV_VADDR __u32 /* Virtual address data type. */
951#define ADV_DCNT __u32 /* Unsigned Data count type. */
952#define ADV_SDCNT __s32 /* Signed Data count type. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953
954/*
955 * These macros are used to convert a virtual address to a
956 * 32-bit value. This currently can be used on Linux Alpha
957 * which uses 64-bit virtual address but a 32-bit bus address.
958 * This is likely to break in the future, but doing this now
959 * will give us time to change the HW and FW to handle 64-bit
960 * addresses.
961 */
962#define ADV_VADDR_TO_U32 virt_to_bus
963#define ADV_U32_TO_VADDR bus_to_virt
964
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400965#define AdvPortAddr void __iomem * /* Virtual memory address size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966
967/*
968 * Define Adv Library required memory access macros.
969 */
970#define ADV_MEM_READB(addr) readb(addr)
971#define ADV_MEM_READW(addr) readw(addr)
972#define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
973#define ADV_MEM_WRITEW(addr, word) writew(word, addr)
974#define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
975
976#define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
977
978/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 * Define total number of simultaneous maximum element scatter-gather
980 * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
981 * maximum number of outstanding commands per wide host adapter. Each
982 * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
983 * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
984 * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
985 * structures or 255 scatter-gather elements.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 */
987#define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
988
989/*
Matthew Wilcox98d41c22007-10-02 21:55:37 -0400990 * Define maximum number of scatter-gather elements per request.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 */
992#define ADV_MAX_SG_LIST 255
Matthew Wilcox98d41c22007-10-02 21:55:37 -0400993#define NO_OF_SG_PER_BLOCK 15
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995#define ADV_EEP_DVC_CFG_BEGIN (0x00)
996#define ADV_EEP_DVC_CFG_END (0x15)
Matthew Wilcox27c868c2007-07-26 10:56:23 -0400997#define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998#define ADV_EEP_MAX_WORD_ADDR (0x1E)
999
1000#define ADV_EEP_DELAY_MS 100
1001
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001002#define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
1003#define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004/*
1005 * For the ASC3550 Bit 13 is Termination Polarity control bit.
1006 * For later ICs Bit 13 controls whether the CIS (Card Information
1007 * Service Section) is loaded from EEPROM.
1008 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001009#define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
1010#define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011/*
1012 * ASC38C1600 Bit 11
1013 *
1014 * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
1015 * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
1016 * Function 0 will specify INT B.
1017 *
1018 * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
1019 * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
1020 * Function 1 will specify INT A.
1021 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001022#define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001024typedef struct adveep_3550_config {
1025 /* Word Offset, Description */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001027 ushort cfg_lsw; /* 00 power up initialization */
1028 /* bit 13 set - Term Polarity Control */
1029 /* bit 14 set - BIOS Enable */
1030 /* bit 15 set - Big Endian Mode */
1031 ushort cfg_msw; /* 01 unused */
1032 ushort disc_enable; /* 02 disconnect enable */
1033 ushort wdtr_able; /* 03 Wide DTR able */
1034 ushort sdtr_able; /* 04 Synchronous DTR able */
1035 ushort start_motor; /* 05 send start up motor */
1036 ushort tagqng_able; /* 06 tag queuing able */
1037 ushort bios_scan; /* 07 BIOS device control */
1038 ushort scam_tolerant; /* 08 no scam */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001040 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1041 uchar bios_boot_delay; /* power up wait */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001043 uchar scsi_reset_delay; /* 10 reset delay */
1044 uchar bios_id_lun; /* first boot device scsi id & lun */
1045 /* high nibble is lun */
1046 /* low nibble is scsi id */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001048 uchar termination; /* 11 0 - automatic */
1049 /* 1 - low off / high off */
1050 /* 2 - low off / high on */
1051 /* 3 - low on / high on */
1052 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001054 uchar reserved1; /* reserved byte (not used) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001056 ushort bios_ctrl; /* 12 BIOS control bits */
1057 /* bit 0 BIOS don't act as initiator. */
1058 /* bit 1 BIOS > 1 GB support */
1059 /* bit 2 BIOS > 2 Disk Support */
1060 /* bit 3 BIOS don't support removables */
1061 /* bit 4 BIOS support bootable CD */
1062 /* bit 5 BIOS scan enabled */
1063 /* bit 6 BIOS support multiple LUNs */
1064 /* bit 7 BIOS display of message */
1065 /* bit 8 SCAM disabled */
1066 /* bit 9 Reset SCSI bus during init. */
1067 /* bit 10 */
1068 /* bit 11 No verbose initialization. */
1069 /* bit 12 SCSI parity enabled */
1070 /* bit 13 */
1071 /* bit 14 */
1072 /* bit 15 */
1073 ushort ultra_able; /* 13 ULTRA speed able */
1074 ushort reserved2; /* 14 reserved */
1075 uchar max_host_qng; /* 15 maximum host queuing */
1076 uchar max_dvc_qng; /* maximum per device queuing */
1077 ushort dvc_cntl; /* 16 control bit for driver */
1078 ushort bug_fix; /* 17 control bit for bug fix */
1079 ushort serial_number_word1; /* 18 Board serial number word 1 */
1080 ushort serial_number_word2; /* 19 Board serial number word 2 */
1081 ushort serial_number_word3; /* 20 Board serial number word 3 */
1082 ushort check_sum; /* 21 EEP check sum */
1083 uchar oem_name[16]; /* 22 OEM name */
1084 ushort dvc_err_code; /* 30 last device driver error code */
1085 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1086 ushort adv_err_addr; /* 32 last uc error address */
1087 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1088 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1089 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1090 ushort num_of_err; /* 36 number of error */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091} ADVEEP_3550_CONFIG;
1092
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001093typedef struct adveep_38C0800_config {
1094 /* Word Offset, Description */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001096 ushort cfg_lsw; /* 00 power up initialization */
1097 /* bit 13 set - Load CIS */
1098 /* bit 14 set - BIOS Enable */
1099 /* bit 15 set - Big Endian Mode */
1100 ushort cfg_msw; /* 01 unused */
1101 ushort disc_enable; /* 02 disconnect enable */
1102 ushort wdtr_able; /* 03 Wide DTR able */
1103 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1104 ushort start_motor; /* 05 send start up motor */
1105 ushort tagqng_able; /* 06 tag queuing able */
1106 ushort bios_scan; /* 07 BIOS device control */
1107 ushort scam_tolerant; /* 08 no scam */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001109 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1110 uchar bios_boot_delay; /* power up wait */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001112 uchar scsi_reset_delay; /* 10 reset delay */
1113 uchar bios_id_lun; /* first boot device scsi id & lun */
1114 /* high nibble is lun */
1115 /* low nibble is scsi id */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001117 uchar termination_se; /* 11 0 - automatic */
1118 /* 1 - low off / high off */
1119 /* 2 - low off / high on */
1120 /* 3 - low on / high on */
1121 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001123 uchar termination_lvd; /* 11 0 - automatic */
1124 /* 1 - low off / high off */
1125 /* 2 - low off / high on */
1126 /* 3 - low on / high on */
1127 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001129 ushort bios_ctrl; /* 12 BIOS control bits */
1130 /* bit 0 BIOS don't act as initiator. */
1131 /* bit 1 BIOS > 1 GB support */
1132 /* bit 2 BIOS > 2 Disk Support */
1133 /* bit 3 BIOS don't support removables */
1134 /* bit 4 BIOS support bootable CD */
1135 /* bit 5 BIOS scan enabled */
1136 /* bit 6 BIOS support multiple LUNs */
1137 /* bit 7 BIOS display of message */
1138 /* bit 8 SCAM disabled */
1139 /* bit 9 Reset SCSI bus during init. */
1140 /* bit 10 */
1141 /* bit 11 No verbose initialization. */
1142 /* bit 12 SCSI parity enabled */
1143 /* bit 13 */
1144 /* bit 14 */
1145 /* bit 15 */
1146 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1147 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1148 uchar max_host_qng; /* 15 maximum host queueing */
1149 uchar max_dvc_qng; /* maximum per device queuing */
1150 ushort dvc_cntl; /* 16 control bit for driver */
1151 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1152 ushort serial_number_word1; /* 18 Board serial number word 1 */
1153 ushort serial_number_word2; /* 19 Board serial number word 2 */
1154 ushort serial_number_word3; /* 20 Board serial number word 3 */
1155 ushort check_sum; /* 21 EEP check sum */
1156 uchar oem_name[16]; /* 22 OEM name */
1157 ushort dvc_err_code; /* 30 last device driver error code */
1158 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1159 ushort adv_err_addr; /* 32 last uc error address */
1160 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1161 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1162 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1163 ushort reserved36; /* 36 reserved */
1164 ushort reserved37; /* 37 reserved */
1165 ushort reserved38; /* 38 reserved */
1166 ushort reserved39; /* 39 reserved */
1167 ushort reserved40; /* 40 reserved */
1168 ushort reserved41; /* 41 reserved */
1169 ushort reserved42; /* 42 reserved */
1170 ushort reserved43; /* 43 reserved */
1171 ushort reserved44; /* 44 reserved */
1172 ushort reserved45; /* 45 reserved */
1173 ushort reserved46; /* 46 reserved */
1174 ushort reserved47; /* 47 reserved */
1175 ushort reserved48; /* 48 reserved */
1176 ushort reserved49; /* 49 reserved */
1177 ushort reserved50; /* 50 reserved */
1178 ushort reserved51; /* 51 reserved */
1179 ushort reserved52; /* 52 reserved */
1180 ushort reserved53; /* 53 reserved */
1181 ushort reserved54; /* 54 reserved */
1182 ushort reserved55; /* 55 reserved */
1183 ushort cisptr_lsw; /* 56 CIS PTR LSW */
1184 ushort cisprt_msw; /* 57 CIS PTR MSW */
1185 ushort subsysvid; /* 58 SubSystem Vendor ID */
1186 ushort subsysid; /* 59 SubSystem ID */
1187 ushort reserved60; /* 60 reserved */
1188 ushort reserved61; /* 61 reserved */
1189 ushort reserved62; /* 62 reserved */
1190 ushort reserved63; /* 63 reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191} ADVEEP_38C0800_CONFIG;
1192
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001193typedef struct adveep_38C1600_config {
1194 /* Word Offset, Description */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001196 ushort cfg_lsw; /* 00 power up initialization */
1197 /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
1198 /* clear - Func. 0 INTA, Func. 1 INTB */
1199 /* bit 13 set - Load CIS */
1200 /* bit 14 set - BIOS Enable */
1201 /* bit 15 set - Big Endian Mode */
1202 ushort cfg_msw; /* 01 unused */
1203 ushort disc_enable; /* 02 disconnect enable */
1204 ushort wdtr_able; /* 03 Wide DTR able */
1205 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1206 ushort start_motor; /* 05 send start up motor */
1207 ushort tagqng_able; /* 06 tag queuing able */
1208 ushort bios_scan; /* 07 BIOS device control */
1209 ushort scam_tolerant; /* 08 no scam */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001211 uchar adapter_scsi_id; /* 09 Host Adapter ID */
1212 uchar bios_boot_delay; /* power up wait */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001214 uchar scsi_reset_delay; /* 10 reset delay */
1215 uchar bios_id_lun; /* first boot device scsi id & lun */
1216 /* high nibble is lun */
1217 /* low nibble is scsi id */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001219 uchar termination_se; /* 11 0 - automatic */
1220 /* 1 - low off / high off */
1221 /* 2 - low off / high on */
1222 /* 3 - low on / high on */
1223 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001225 uchar termination_lvd; /* 11 0 - automatic */
1226 /* 1 - low off / high off */
1227 /* 2 - low off / high on */
1228 /* 3 - low on / high on */
1229 /* There is no low on / high off */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001231 ushort bios_ctrl; /* 12 BIOS control bits */
1232 /* bit 0 BIOS don't act as initiator. */
1233 /* bit 1 BIOS > 1 GB support */
1234 /* bit 2 BIOS > 2 Disk Support */
1235 /* bit 3 BIOS don't support removables */
1236 /* bit 4 BIOS support bootable CD */
1237 /* bit 5 BIOS scan enabled */
1238 /* bit 6 BIOS support multiple LUNs */
1239 /* bit 7 BIOS display of message */
1240 /* bit 8 SCAM disabled */
1241 /* bit 9 Reset SCSI bus during init. */
1242 /* bit 10 Basic Integrity Checking disabled */
1243 /* bit 11 No verbose initialization. */
1244 /* bit 12 SCSI parity enabled */
1245 /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
1246 /* bit 14 */
1247 /* bit 15 */
1248 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1249 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1250 uchar max_host_qng; /* 15 maximum host queueing */
1251 uchar max_dvc_qng; /* maximum per device queuing */
1252 ushort dvc_cntl; /* 16 control bit for driver */
1253 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1254 ushort serial_number_word1; /* 18 Board serial number word 1 */
1255 ushort serial_number_word2; /* 19 Board serial number word 2 */
1256 ushort serial_number_word3; /* 20 Board serial number word 3 */
1257 ushort check_sum; /* 21 EEP check sum */
1258 uchar oem_name[16]; /* 22 OEM name */
1259 ushort dvc_err_code; /* 30 last device driver error code */
1260 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
1261 ushort adv_err_addr; /* 32 last uc error address */
1262 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
1263 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
1264 ushort saved_adv_err_addr; /* 35 saved last uc error address */
1265 ushort reserved36; /* 36 reserved */
1266 ushort reserved37; /* 37 reserved */
1267 ushort reserved38; /* 38 reserved */
1268 ushort reserved39; /* 39 reserved */
1269 ushort reserved40; /* 40 reserved */
1270 ushort reserved41; /* 41 reserved */
1271 ushort reserved42; /* 42 reserved */
1272 ushort reserved43; /* 43 reserved */
1273 ushort reserved44; /* 44 reserved */
1274 ushort reserved45; /* 45 reserved */
1275 ushort reserved46; /* 46 reserved */
1276 ushort reserved47; /* 47 reserved */
1277 ushort reserved48; /* 48 reserved */
1278 ushort reserved49; /* 49 reserved */
1279 ushort reserved50; /* 50 reserved */
1280 ushort reserved51; /* 51 reserved */
1281 ushort reserved52; /* 52 reserved */
1282 ushort reserved53; /* 53 reserved */
1283 ushort reserved54; /* 54 reserved */
1284 ushort reserved55; /* 55 reserved */
1285 ushort cisptr_lsw; /* 56 CIS PTR LSW */
1286 ushort cisprt_msw; /* 57 CIS PTR MSW */
1287 ushort subsysvid; /* 58 SubSystem Vendor ID */
1288 ushort subsysid; /* 59 SubSystem ID */
1289 ushort reserved60; /* 60 reserved */
1290 ushort reserved61; /* 61 reserved */
1291 ushort reserved62; /* 62 reserved */
1292 ushort reserved63; /* 63 reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293} ADVEEP_38C1600_CONFIG;
1294
1295/*
1296 * EEPROM Commands
1297 */
1298#define ASC_EEP_CMD_DONE 0x0200
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299
1300/* bios_ctrl */
1301#define BIOS_CTRL_BIOS 0x0001
1302#define BIOS_CTRL_EXTENDED_XLAT 0x0002
1303#define BIOS_CTRL_GT_2_DISK 0x0004
1304#define BIOS_CTRL_BIOS_REMOVABLE 0x0008
1305#define BIOS_CTRL_BOOTABLE_CD 0x0010
1306#define BIOS_CTRL_MULTIPLE_LUN 0x0040
1307#define BIOS_CTRL_DISPLAY_MSG 0x0080
1308#define BIOS_CTRL_NO_SCAM 0x0100
1309#define BIOS_CTRL_RESET_SCSI_BUS 0x0200
1310#define BIOS_CTRL_INIT_VERBOSE 0x0800
1311#define BIOS_CTRL_SCSI_PARITY 0x1000
1312#define BIOS_CTRL_AIPP_DIS 0x2000
1313
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001314#define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001316#define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317
1318/*
1319 * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
1320 * a special 16K Adv Library and Microcode version. After the issue is
1321 * resolved, should restore 32K support.
1322 *
1323 * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
1324 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001325#define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326
1327/*
1328 * Byte I/O register address from base of 'iop_base'.
1329 */
1330#define IOPB_INTR_STATUS_REG 0x00
1331#define IOPB_CHIP_ID_1 0x01
1332#define IOPB_INTR_ENABLES 0x02
1333#define IOPB_CHIP_TYPE_REV 0x03
1334#define IOPB_RES_ADDR_4 0x04
1335#define IOPB_RES_ADDR_5 0x05
1336#define IOPB_RAM_DATA 0x06
1337#define IOPB_RES_ADDR_7 0x07
1338#define IOPB_FLAG_REG 0x08
1339#define IOPB_RES_ADDR_9 0x09
1340#define IOPB_RISC_CSR 0x0A
1341#define IOPB_RES_ADDR_B 0x0B
1342#define IOPB_RES_ADDR_C 0x0C
1343#define IOPB_RES_ADDR_D 0x0D
1344#define IOPB_SOFT_OVER_WR 0x0E
1345#define IOPB_RES_ADDR_F 0x0F
1346#define IOPB_MEM_CFG 0x10
1347#define IOPB_RES_ADDR_11 0x11
1348#define IOPB_GPIO_DATA 0x12
1349#define IOPB_RES_ADDR_13 0x13
1350#define IOPB_FLASH_PAGE 0x14
1351#define IOPB_RES_ADDR_15 0x15
1352#define IOPB_GPIO_CNTL 0x16
1353#define IOPB_RES_ADDR_17 0x17
1354#define IOPB_FLASH_DATA 0x18
1355#define IOPB_RES_ADDR_19 0x19
1356#define IOPB_RES_ADDR_1A 0x1A
1357#define IOPB_RES_ADDR_1B 0x1B
1358#define IOPB_RES_ADDR_1C 0x1C
1359#define IOPB_RES_ADDR_1D 0x1D
1360#define IOPB_RES_ADDR_1E 0x1E
1361#define IOPB_RES_ADDR_1F 0x1F
1362#define IOPB_DMA_CFG0 0x20
1363#define IOPB_DMA_CFG1 0x21
1364#define IOPB_TICKLE 0x22
1365#define IOPB_DMA_REG_WR 0x23
1366#define IOPB_SDMA_STATUS 0x24
1367#define IOPB_SCSI_BYTE_CNT 0x25
1368#define IOPB_HOST_BYTE_CNT 0x26
1369#define IOPB_BYTE_LEFT_TO_XFER 0x27
1370#define IOPB_BYTE_TO_XFER_0 0x28
1371#define IOPB_BYTE_TO_XFER_1 0x29
1372#define IOPB_BYTE_TO_XFER_2 0x2A
1373#define IOPB_BYTE_TO_XFER_3 0x2B
1374#define IOPB_ACC_GRP 0x2C
1375#define IOPB_RES_ADDR_2D 0x2D
1376#define IOPB_DEV_ID 0x2E
1377#define IOPB_RES_ADDR_2F 0x2F
1378#define IOPB_SCSI_DATA 0x30
1379#define IOPB_RES_ADDR_31 0x31
1380#define IOPB_RES_ADDR_32 0x32
1381#define IOPB_SCSI_DATA_HSHK 0x33
1382#define IOPB_SCSI_CTRL 0x34
1383#define IOPB_RES_ADDR_35 0x35
1384#define IOPB_RES_ADDR_36 0x36
1385#define IOPB_RES_ADDR_37 0x37
1386#define IOPB_RAM_BIST 0x38
1387#define IOPB_PLL_TEST 0x39
1388#define IOPB_PCI_INT_CFG 0x3A
1389#define IOPB_RES_ADDR_3B 0x3B
1390#define IOPB_RFIFO_CNT 0x3C
1391#define IOPB_RES_ADDR_3D 0x3D
1392#define IOPB_RES_ADDR_3E 0x3E
1393#define IOPB_RES_ADDR_3F 0x3F
1394
1395/*
1396 * Word I/O register address from base of 'iop_base'.
1397 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001398#define IOPW_CHIP_ID_0 0x00 /* CID0 */
1399#define IOPW_CTRL_REG 0x02 /* CC */
1400#define IOPW_RAM_ADDR 0x04 /* LA */
1401#define IOPW_RAM_DATA 0x06 /* LD */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402#define IOPW_RES_ADDR_08 0x08
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001403#define IOPW_RISC_CSR 0x0A /* CSR */
1404#define IOPW_SCSI_CFG0 0x0C /* CFG0 */
1405#define IOPW_SCSI_CFG1 0x0E /* CFG1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406#define IOPW_RES_ADDR_10 0x10
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001407#define IOPW_SEL_MASK 0x12 /* SM */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408#define IOPW_RES_ADDR_14 0x14
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001409#define IOPW_FLASH_ADDR 0x16 /* FA */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410#define IOPW_RES_ADDR_18 0x18
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001411#define IOPW_EE_CMD 0x1A /* EC */
1412#define IOPW_EE_DATA 0x1C /* ED */
1413#define IOPW_SFIFO_CNT 0x1E /* SFC */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414#define IOPW_RES_ADDR_20 0x20
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001415#define IOPW_Q_BASE 0x22 /* QB */
1416#define IOPW_QP 0x24 /* QP */
1417#define IOPW_IX 0x26 /* IX */
1418#define IOPW_SP 0x28 /* SP */
1419#define IOPW_PC 0x2A /* PC */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420#define IOPW_RES_ADDR_2C 0x2C
1421#define IOPW_RES_ADDR_2E 0x2E
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001422#define IOPW_SCSI_DATA 0x30 /* SD */
1423#define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
1424#define IOPW_SCSI_CTRL 0x34 /* SC */
1425#define IOPW_HSHK_CFG 0x36 /* HCFG */
1426#define IOPW_SXFR_STATUS 0x36 /* SXS */
1427#define IOPW_SXFR_CNTL 0x38 /* SXL */
1428#define IOPW_SXFR_CNTH 0x3A /* SXH */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429#define IOPW_RES_ADDR_3C 0x3C
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001430#define IOPW_RFIFO_DATA 0x3E /* RFD */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431
1432/*
1433 * Doubleword I/O register address from base of 'iop_base'.
1434 */
1435#define IOPDW_RES_ADDR_0 0x00
1436#define IOPDW_RAM_DATA 0x04
1437#define IOPDW_RES_ADDR_8 0x08
1438#define IOPDW_RES_ADDR_C 0x0C
1439#define IOPDW_RES_ADDR_10 0x10
1440#define IOPDW_COMMA 0x14
1441#define IOPDW_COMMB 0x18
1442#define IOPDW_RES_ADDR_1C 0x1C
1443#define IOPDW_SDMA_ADDR0 0x20
1444#define IOPDW_SDMA_ADDR1 0x24
1445#define IOPDW_SDMA_COUNT 0x28
1446#define IOPDW_SDMA_ERROR 0x2C
1447#define IOPDW_RDMA_ADDR0 0x30
1448#define IOPDW_RDMA_ADDR1 0x34
1449#define IOPDW_RDMA_COUNT 0x38
1450#define IOPDW_RDMA_ERROR 0x3C
1451
1452#define ADV_CHIP_ID_BYTE 0x25
1453#define ADV_CHIP_ID_WORD 0x04C1
1454
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455#define ADV_INTR_ENABLE_HOST_INTR 0x01
1456#define ADV_INTR_ENABLE_SEL_INTR 0x02
1457#define ADV_INTR_ENABLE_DPR_INTR 0x04
1458#define ADV_INTR_ENABLE_RTA_INTR 0x08
1459#define ADV_INTR_ENABLE_RMA_INTR 0x10
1460#define ADV_INTR_ENABLE_RST_INTR 0x20
1461#define ADV_INTR_ENABLE_DPE_INTR 0x40
1462#define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
1463
1464#define ADV_INTR_STATUS_INTRA 0x01
1465#define ADV_INTR_STATUS_INTRB 0x02
1466#define ADV_INTR_STATUS_INTRC 0x04
1467
1468#define ADV_RISC_CSR_STOP (0x0000)
1469#define ADV_RISC_TEST_COND (0x2000)
1470#define ADV_RISC_CSR_RUN (0x4000)
1471#define ADV_RISC_CSR_SINGLE_STEP (0x8000)
1472
1473#define ADV_CTRL_REG_HOST_INTR 0x0100
1474#define ADV_CTRL_REG_SEL_INTR 0x0200
1475#define ADV_CTRL_REG_DPR_INTR 0x0400
1476#define ADV_CTRL_REG_RTA_INTR 0x0800
1477#define ADV_CTRL_REG_RMA_INTR 0x1000
1478#define ADV_CTRL_REG_RES_BIT14 0x2000
1479#define ADV_CTRL_REG_DPE_INTR 0x4000
1480#define ADV_CTRL_REG_POWER_DONE 0x8000
1481#define ADV_CTRL_REG_ANY_INTR 0xFF00
1482
1483#define ADV_CTRL_REG_CMD_RESET 0x00C6
1484#define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
1485#define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
1486#define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
1487#define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
1488
1489#define ADV_TICKLE_NOP 0x00
1490#define ADV_TICKLE_A 0x01
1491#define ADV_TICKLE_B 0x02
1492#define ADV_TICKLE_C 0x03
1493
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494#define AdvIsIntPending(port) \
1495 (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
1496
1497/*
1498 * SCSI_CFG0 Register bit definitions
1499 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001500#define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
1501#define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
1502#define EVEN_PARITY 0x1000 /* Select Even Parity */
1503#define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
1504#define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
1505#define PRIM_MODE 0x0100 /* Primitive SCSI mode */
1506#define SCAM_EN 0x0080 /* Enable SCAM selection */
1507#define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
1508#define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
1509#define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
1510#define OUR_ID 0x000F /* SCSI ID */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511
1512/*
1513 * SCSI_CFG1 Register bit definitions
1514 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001515#define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
1516#define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
1517#define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
1518#define FILTER_SEL 0x0C00 /* Filter Period Selection */
1519#define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
1520#define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
1521#define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
1522#define ACTIVE_DBL 0x0200 /* Disable Active Negation */
1523#define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
1524#define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
1525#define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
1526#define TERM_CTL 0x0030 /* External SCSI Termination Bits */
1527#define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
1528#define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
1529#define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530
1531/*
1532 * Addendum for ASC-38C0800 Chip
1533 *
1534 * The ASC-38C1600 Chip uses the same definitions except that the
1535 * bus mode override bits [12:10] have been moved to byte register
1536 * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
1537 * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
1538 * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
1539 * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
1540 * and [1:0]. Bits [14], [7:6], [3:2] are unused.
1541 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001542#define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
1543#define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
1544#define HVD 0x1000 /* HVD Device Detect */
1545#define LVD 0x0800 /* LVD Device Detect */
1546#define SE 0x0400 /* SE Device Detect */
1547#define TERM_LVD 0x00C0 /* LVD Termination Bits */
1548#define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
1549#define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
1550#define TERM_SE 0x0030 /* SE Termination Bits */
1551#define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
1552#define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
1553#define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
1554#define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
1555#define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
1556#define C_DET_SE 0x0003 /* SE Cable Detect Bits */
1557#define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
1558#define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559
1560#define CABLE_ILLEGAL_A 0x7
1561 /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
1562
1563#define CABLE_ILLEGAL_B 0xB
1564 /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
1565
1566/*
1567 * MEM_CFG Register bit definitions
1568 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001569#define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
1570#define FAST_EE_CLK 0x20 /* Diagnostic Bit */
1571#define RAM_SZ 0x1C /* Specify size of RAM to RISC */
1572#define RAM_SZ_2KB 0x00 /* 2 KB */
1573#define RAM_SZ_4KB 0x04 /* 4 KB */
1574#define RAM_SZ_8KB 0x08 /* 8 KB */
1575#define RAM_SZ_16KB 0x0C /* 16 KB */
1576#define RAM_SZ_32KB 0x10 /* 32 KB */
1577#define RAM_SZ_64KB 0x14 /* 64 KB */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578
1579/*
1580 * DMA_CFG0 Register bit definitions
1581 *
1582 * This register is only accessible to the host.
1583 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001584#define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
1585#define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
1586#define FIFO_THRESH_16B 0x00 /* 16 bytes */
1587#define FIFO_THRESH_32B 0x20 /* 32 bytes */
1588#define FIFO_THRESH_48B 0x30 /* 48 bytes */
1589#define FIFO_THRESH_64B 0x40 /* 64 bytes */
1590#define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
1591#define FIFO_THRESH_96B 0x60 /* 96 bytes */
1592#define FIFO_THRESH_112B 0x70 /* 112 bytes */
1593#define START_CTL 0x0C /* DMA start conditions */
1594#define START_CTL_TH 0x00 /* Wait threshold level (default) */
1595#define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
1596#define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
1597#define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
1598#define READ_CMD 0x03 /* Memory Read Method */
1599#define READ_CMD_MR 0x00 /* Memory Read */
1600#define READ_CMD_MRL 0x02 /* Memory Read Long */
1601#define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602
1603/*
1604 * ASC-38C0800 RAM BIST Register bit definitions
1605 */
1606#define RAM_TEST_MODE 0x80
1607#define PRE_TEST_MODE 0x40
1608#define NORMAL_MODE 0x00
1609#define RAM_TEST_DONE 0x10
1610#define RAM_TEST_STATUS 0x0F
1611#define RAM_TEST_HOST_ERROR 0x08
1612#define RAM_TEST_INTRAM_ERROR 0x04
1613#define RAM_TEST_RISC_ERROR 0x02
1614#define RAM_TEST_SCSI_ERROR 0x01
1615#define RAM_TEST_SUCCESS 0x00
1616#define PRE_TEST_VALUE 0x05
1617#define NORMAL_VALUE 0x00
1618
1619/*
1620 * ASC38C1600 Definitions
1621 *
1622 * IOPB_PCI_INT_CFG Bit Field Definitions
1623 */
1624
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001625#define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626
1627/*
1628 * Bit 1 can be set to change the interrupt for the Function to operate in
1629 * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
1630 * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
1631 * mode, otherwise the operating mode is undefined.
1632 */
1633#define TOTEMPOLE 0x02
1634
1635/*
1636 * Bit 0 can be used to change the Int Pin for the Function. The value is
1637 * 0 by default for both Functions with Function 0 using INT A and Function
1638 * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
1639 * INT A is used.
1640 *
1641 * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
1642 * value specified in the PCI Configuration Space.
1643 */
1644#define INTAB 0x01
1645
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646/*
1647 * Adv Library Status Definitions
1648 */
1649#define ADV_TRUE 1
1650#define ADV_FALSE 0
Linus Torvalds1da177e2005-04-16 15:20:36 -07001651#define ADV_SUCCESS 1
1652#define ADV_BUSY 0
1653#define ADV_ERROR (-1)
1654
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655/*
1656 * ADV_DVC_VAR 'warn_code' values
1657 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001658#define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
1659#define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
1660#define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001661#define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001663#define ADV_MAX_TID 15 /* max. target identifier */
1664#define ADV_MAX_LUN 7 /* max. logical unit number */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665
1666/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667 * Fixed locations of microcode operating variables.
1668 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001669#define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
1670#define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
1671#define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
1672#define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
1673#define ASC_MC_VERSION_NUM 0x003A /* microcode number */
1674#define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
1675#define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
1676#define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
1677#define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
1678#define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
1679#define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
1680#define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
1681#define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682#define ASC_MC_CHIP_TYPE 0x009A
1683#define ASC_MC_INTRB_CODE 0x009B
1684#define ASC_MC_WDTR_ABLE 0x009C
1685#define ASC_MC_SDTR_ABLE 0x009E
1686#define ASC_MC_TAGQNG_ABLE 0x00A0
1687#define ASC_MC_DISC_ENABLE 0x00A2
1688#define ASC_MC_IDLE_CMD_STATUS 0x00A4
1689#define ASC_MC_IDLE_CMD 0x00A6
1690#define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
1691#define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
1692#define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
1693#define ASC_MC_DEFAULT_MEM_CFG 0x00B0
1694#define ASC_MC_DEFAULT_SEL_MASK 0x00B2
1695#define ASC_MC_SDTR_DONE 0x00B6
1696#define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
1697#define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
1698#define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001699#define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700#define ASC_MC_WDTR_DONE 0x0124
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001701#define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702#define ASC_MC_ICQ 0x0160
1703#define ASC_MC_IRQ 0x0164
1704#define ASC_MC_PPR_ABLE 0x017A
1705
1706/*
1707 * BIOS LRAM variable absolute offsets.
1708 */
1709#define BIOS_CODESEG 0x54
1710#define BIOS_CODELEN 0x56
1711#define BIOS_SIGNATURE 0x58
1712#define BIOS_VERSION 0x5A
1713
1714/*
1715 * Microcode Control Flags
1716 *
1717 * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
1718 * and handled by the microcode.
1719 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001720#define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
1721#define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722
1723/*
1724 * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
1725 */
1726#define HSHK_CFG_WIDE_XFR 0x8000
1727#define HSHK_CFG_RATE 0x0F00
1728#define HSHK_CFG_OFFSET 0x001F
1729
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001730#define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
1731#define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
1732#define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
1733#define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001735#define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
1736#define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
1737#define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
1738#define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
1739#define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001741#define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
1742#define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
1743#define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
1744#define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
1745#define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746/*
1747 * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
1748 * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
1749 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001750#define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
1751#define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752
1753/*
1754 * All fields here are accessed by the board microcode and need to be
1755 * little-endian.
1756 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001757typedef struct adv_carr_t {
1758 ADV_VADDR carr_va; /* Carrier Virtual Address */
1759 ADV_PADDR carr_pa; /* Carrier Physical Address */
1760 ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
1761 /*
1762 * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
1763 *
1764 * next_vpa [3:1] Reserved Bits
1765 * next_vpa [0] Done Flag set in Response Queue.
1766 */
1767 ADV_VADDR next_vpa;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768} ADV_CARR_T;
1769
1770/*
1771 * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
1772 */
1773#define ASC_NEXT_VPA_MASK 0xFFFFFFF0
1774
1775#define ASC_RQ_DONE 0x00000001
1776#define ASC_RQ_GOOD 0x00000002
1777#define ASC_CQ_STOPPER 0x00000000
1778
1779#define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
1780
1781#define ADV_CARRIER_NUM_PAGE_CROSSING \
Matthew Wilcoxfd625f42007-10-02 21:55:38 -04001782 (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783
1784#define ADV_CARRIER_BUFSIZE \
1785 ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
1786
1787/*
1788 * ASC_SCSI_REQ_Q 'a_flag' definitions
1789 *
1790 * The Adv Library should limit use to the lower nibble (4 bits) of
1791 * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
1792 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001793#define ADV_POLL_REQUEST 0x01 /* poll for request completion */
1794#define ADV_SCSIQ_DONE 0x02 /* request done */
1795#define ADV_DONT_RETRY 0x08 /* don't do retry */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001797#define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
1798#define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
1799#define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800
1801/*
1802 * Adapter temporary configuration structure
1803 *
1804 * This structure can be discarded after initialization. Don't add
1805 * fields here needed after initialization.
1806 *
1807 * Field naming convention:
1808 *
1809 * *_enable indicates the field enables or disables a feature. The
1810 * value of the field is never reset.
1811 */
1812typedef struct adv_dvc_cfg {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001813 ushort disc_enable; /* enable disconnection */
1814 uchar chip_version; /* chip version */
1815 uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001816 ushort control_flag; /* Microcode Control Flag */
1817 ushort mcode_date; /* Microcode date */
1818 ushort mcode_version; /* Microcode version */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001819 ushort serial1; /* EEPROM serial number word 1 */
1820 ushort serial2; /* EEPROM serial number word 2 */
1821 ushort serial3; /* EEPROM serial number word 3 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822} ADV_DVC_CFG;
1823
1824struct adv_dvc_var;
1825struct adv_scsi_req_q;
1826
Linus Torvalds1da177e2005-04-16 15:20:36 -07001827typedef struct asc_sg_block {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001828 uchar reserved1;
1829 uchar reserved2;
1830 uchar reserved3;
1831 uchar sg_cnt; /* Valid entries in block. */
1832 ADV_PADDR sg_ptr; /* Pointer to next sg block. */
1833 struct {
1834 ADV_PADDR sg_addr; /* SG element address. */
1835 ADV_DCNT sg_count; /* SG element count. */
1836 } sg_list[NO_OF_SG_PER_BLOCK];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001837} ADV_SG_BLOCK;
1838
1839/*
1840 * ADV_SCSI_REQ_Q - microcode request structure
1841 *
1842 * All fields in this structure up to byte 60 are used by the microcode.
1843 * The microcode makes assumptions about the size and ordering of fields
1844 * in this structure. Do not change the structure definition here without
1845 * coordinating the change with the microcode.
1846 *
1847 * All fields accessed by microcode must be maintained in little_endian
1848 * order.
1849 */
1850typedef struct adv_scsi_req_q {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001851 uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
1852 uchar target_cmd;
1853 uchar target_id; /* Device target identifier. */
1854 uchar target_lun; /* Device target logical unit number. */
1855 ADV_PADDR data_addr; /* Data buffer physical address. */
1856 ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
1857 ADV_PADDR sense_addr;
1858 ADV_PADDR carr_pa;
1859 uchar mflag;
1860 uchar sense_len;
1861 uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
1862 uchar scsi_cntl;
1863 uchar done_status; /* Completion status. */
1864 uchar scsi_status; /* SCSI status byte. */
1865 uchar host_status; /* Ucode host status. */
1866 uchar sg_working_ix;
1867 uchar cdb[12]; /* SCSI CDB bytes 0-11. */
1868 ADV_PADDR sg_real_addr; /* SG list physical address. */
1869 ADV_PADDR scsiq_rptr;
1870 uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
1871 ADV_VADDR scsiq_ptr;
1872 ADV_VADDR carr_va;
1873 /*
1874 * End of microcode structure - 60 bytes. The rest of the structure
1875 * is used by the Adv Library and ignored by the microcode.
1876 */
1877 ADV_VADDR srb_ptr;
1878 ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
1879 char *vdata_addr; /* Data buffer virtual address. */
1880 uchar a_flag;
1881 uchar pad[2]; /* Pad out to a word boundary. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882} ADV_SCSI_REQ_Q;
1883
1884/*
Matthew Wilcox98d41c22007-10-02 21:55:37 -04001885 * The following two structures are used to process Wide Board requests.
1886 *
1887 * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
1888 * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
1889 * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
1890 * Mid-Level SCSI request structure.
1891 *
1892 * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
1893 * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
1894 * up to 255 scatter-gather elements may be used per request or
1895 * ADV_SCSI_REQ_Q.
1896 *
1897 * Both structures must be 32 byte aligned.
1898 */
1899typedef struct adv_sgblk {
1900 ADV_SG_BLOCK sg_block; /* Sgblock structure. */
1901 uchar align[32]; /* Sgblock structure padding. */
1902 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
1903} adv_sgblk_t;
1904
1905typedef struct adv_req {
1906 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
1907 uchar align[32]; /* Request structure padding. */
1908 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
1909 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
1910 struct adv_req *next_reqp; /* Next Request Structure. */
1911} adv_req_t;
1912
1913/*
1914 * Adapter operation variable structure.
1915 *
1916 * One structure is required per host adapter.
1917 *
1918 * Field naming convention:
1919 *
1920 * *_able indicates both whether a feature should be enabled or disabled
1921 * and whether a device isi capable of the feature. At initialization
1922 * this field may be set, but later if a device is found to be incapable
1923 * of the feature, the field is cleared.
1924 */
1925typedef struct adv_dvc_var {
1926 AdvPortAddr iop_base; /* I/O port address */
1927 ushort err_code; /* fatal error code */
1928 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
1929 ushort wdtr_able; /* try WDTR for a device */
1930 ushort sdtr_able; /* try SDTR for a device */
1931 ushort ultra_able; /* try SDTR Ultra speed for a device */
1932 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
1933 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
1934 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
1935 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
1936 ushort tagqng_able; /* try tagged queuing with a device */
1937 ushort ppr_able; /* PPR message capable per TID bitmask. */
1938 uchar max_dvc_qng; /* maximum number of tagged commands per device */
1939 ushort start_motor; /* start motor command allowed */
1940 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
1941 uchar chip_no; /* should be assigned by caller */
1942 uchar max_host_qng; /* maximum number of Q'ed command allowed */
1943 ushort no_scam; /* scam_tolerant of EEPROM */
1944 struct asc_board *drv_ptr; /* driver pointer to private structure */
1945 uchar chip_scsi_id; /* chip SCSI target ID */
1946 uchar chip_type;
1947 uchar bist_err_code;
1948 ADV_CARR_T *carrier_buf;
1949 ADV_CARR_T *carr_freelist; /* Carrier free list. */
1950 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
1951 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
1952 ushort carr_pending_cnt; /* Count of pending carriers. */
1953 struct adv_req *orig_reqp; /* adv_req_t memory block. */
1954 /*
1955 * Note: The following fields will not be used after initialization. The
1956 * driver may discard the buffer after initialization is done.
1957 */
1958 ADV_DVC_CFG *cfg; /* temporary configuration structure */
1959} ADV_DVC_VAR;
1960
1961/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962 * Microcode idle loop commands
1963 */
1964#define IDLE_CMD_COMPLETED 0
1965#define IDLE_CMD_STOP_CHIP 0x0001
1966#define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
1967#define IDLE_CMD_SEND_INT 0x0004
1968#define IDLE_CMD_ABORT 0x0008
1969#define IDLE_CMD_DEVICE_RESET 0x0010
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001970#define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
1971#define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972#define IDLE_CMD_SCSIREQ 0x0080
1973
1974#define IDLE_CMD_STATUS_SUCCESS 0x0001
1975#define IDLE_CMD_STATUS_FAILURE 0x0002
1976
1977/*
1978 * AdvSendIdleCmd() flag definitions.
1979 */
1980#define ADV_NOWAIT 0x01
1981
1982/*
1983 * Wait loop time out values.
1984 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001985#define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
1986#define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001987#define SCSI_MAX_RETRY 10 /* retry count */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001989#define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
1990#define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
1991#define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
1992#define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993
Matthew Wilcox27c868c2007-07-26 10:56:23 -04001994#define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001995
Linus Torvalds1da177e2005-04-16 15:20:36 -07001996/* Read byte from a register. */
1997#define AdvReadByteRegister(iop_base, reg_off) \
1998 (ADV_MEM_READB((iop_base) + (reg_off)))
1999
2000/* Write byte to a register. */
2001#define AdvWriteByteRegister(iop_base, reg_off, byte) \
2002 (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
2003
2004/* Read word (2 bytes) from a register. */
2005#define AdvReadWordRegister(iop_base, reg_off) \
2006 (ADV_MEM_READW((iop_base) + (reg_off)))
2007
2008/* Write word (2 bytes) to a register. */
2009#define AdvWriteWordRegister(iop_base, reg_off, word) \
2010 (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
2011
2012/* Write dword (4 bytes) to a register. */
2013#define AdvWriteDWordRegister(iop_base, reg_off, dword) \
2014 (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
2015
2016/* Read byte from LRAM. */
2017#define AdvReadByteLram(iop_base, addr, byte) \
2018do { \
2019 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2020 (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
2021} while (0)
2022
2023/* Write byte to LRAM. */
2024#define AdvWriteByteLram(iop_base, addr, byte) \
2025 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2026 ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
2027
2028/* Read word (2 bytes) from LRAM. */
2029#define AdvReadWordLram(iop_base, addr, word) \
2030do { \
2031 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2032 (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
2033} while (0)
2034
2035/* Write word (2 bytes) to LRAM. */
2036#define AdvWriteWordLram(iop_base, addr, word) \
2037 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2038 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2039
2040/* Write little-endian double word (4 bytes) to LRAM */
2041/* Because of unspecified C language ordering don't use auto-increment. */
2042#define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
2043 ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2044 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2045 cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
2046 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
2047 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2048 cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
2049
2050/* Read word (2 bytes) from LRAM assuming that the address is already set. */
2051#define AdvReadWordAutoIncLram(iop_base) \
2052 (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
2053
2054/* Write word (2 bytes) to LRAM assuming that the address is already set. */
2055#define AdvWriteWordAutoIncLram(iop_base, word) \
2056 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2057
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058/*
2059 * Define macro to check for Condor signature.
2060 *
2061 * Evaluate to ADV_TRUE if a Condor chip is found the specified port
2062 * address 'iop_base'. Otherwise evalue to ADV_FALSE.
2063 */
2064#define AdvFindSignature(iop_base) \
2065 (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
2066 ADV_CHIP_ID_BYTE) && \
2067 (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
2068 ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
2069
2070/*
2071 * Define macro to Return the version number of the chip at 'iop_base'.
2072 *
2073 * The second parameter 'bus_type' is currently unused.
2074 */
2075#define AdvGetChipVersion(iop_base, bus_type) \
2076 AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
2077
2078/*
2079 * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
2080 * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
2081 *
2082 * If the request has not yet been sent to the device it will simply be
2083 * aborted from RISC memory. If the request is disconnected it will be
2084 * aborted on reselection by sending an Abort Message to the target ID.
2085 *
2086 * Return value:
2087 * ADV_TRUE(1) - Queue was successfully aborted.
2088 * ADV_FALSE(0) - Queue was not found on the active queue list.
2089 */
2090#define AdvAbortQueue(asc_dvc, scsiq) \
2091 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
2092 (ADV_DCNT) (scsiq))
2093
2094/*
2095 * Send a Bus Device Reset Message to the specified target ID.
2096 *
2097 * All outstanding commands will be purged if sending the
2098 * Bus Device Reset Message is successful.
2099 *
2100 * Return Value:
2101 * ADV_TRUE(1) - All requests on the target are purged.
2102 * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
2103 * are not purged.
2104 */
2105#define AdvResetDevice(asc_dvc, target_id) \
2106 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
2107 (ADV_DCNT) (target_id))
2108
2109/*
2110 * SCSI Wide Type definition.
2111 */
2112#define ADV_SCSI_BIT_ID_TYPE ushort
2113
2114/*
2115 * AdvInitScsiTarget() 'cntl_flag' options.
2116 */
2117#define ADV_SCAN_LUN 0x01
2118#define ADV_CAPINFO_NOLUN 0x02
2119
2120/*
2121 * Convert target id to target id bit mask.
2122 */
2123#define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
2124
2125/*
2126 * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
2127 */
2128
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002129#define QD_NO_STATUS 0x00 /* Request not completed yet. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130#define QD_NO_ERROR 0x01
2131#define QD_ABORTED_BY_HOST 0x02
2132#define QD_WITH_ERROR 0x04
2133
2134#define QHSTA_NO_ERROR 0x00
2135#define QHSTA_M_SEL_TIMEOUT 0x11
2136#define QHSTA_M_DATA_OVER_RUN 0x12
2137#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
2138#define QHSTA_M_QUEUE_ABORTED 0x15
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002139#define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
2140#define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
2141#define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
2142#define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
2143#define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
2144#define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
2145#define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146/* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002147#define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
2148#define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
2149#define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
2150#define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
2151#define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
2152#define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
2153#define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
2154#define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155#define QHSTA_M_WTM_TIMEOUT 0x41
2156#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
2157#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
2158#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002159#define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
2160#define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
2161#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002162
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163/* Return the address that is aligned at the next doubleword >= to 'addr'. */
2164#define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
2165#define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
2166#define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
2167
2168/*
2169 * Total contiguous memory needed for driver SG blocks.
2170 *
2171 * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
2172 * number of scatter-gather elements the driver supports in a
2173 * single request.
2174 */
2175
2176#define ADV_SG_LIST_MAX_BYTE_SIZE \
2177 (sizeof(ADV_SG_BLOCK) * \
2178 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
2179
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002180/* struct asc_board flags */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002181#define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182
2183#define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002185#define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002187#define ASC_INFO_SIZE 128 /* advansys_info() line size */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188
2189#ifdef CONFIG_PROC_FS
2190/* /proc/scsi/advansys/[0...] related definitions */
2191#define ASC_PRTBUF_SIZE 2048
2192#define ASC_PRTLINE_SIZE 160
2193
2194#define ASC_PRT_NEXT() \
2195 if (cp) { \
2196 totlen += len; \
2197 leftlen -= len; \
2198 if (leftlen == 0) { \
2199 return totlen; \
2200 } \
2201 cp += len; \
2202 }
2203#endif /* CONFIG_PROC_FS */
2204
2205/* Asc Library return codes */
2206#define ASC_TRUE 1
2207#define ASC_FALSE 0
2208#define ASC_NOERROR 1
2209#define ASC_BUSY 0
2210#define ASC_ERROR (-1)
2211
2212/* struct scsi_cmnd function return codes */
2213#define STATUS_BYTE(byte) (byte)
2214#define MSG_BYTE(byte) ((byte) << 8)
2215#define HOST_BYTE(byte) ((byte) << 16)
2216#define DRIVER_BYTE(byte) ((byte) << 24)
2217
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002218#define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002219#ifndef ADVANSYS_STATS
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002220#define ASC_STATS_ADD(shost, counter, count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221#else /* ADVANSYS_STATS */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002222#define ASC_STATS_ADD(shost, counter, count) \
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002223 (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224#endif /* ADVANSYS_STATS */
2225
2226#define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
2227
2228/* If the result wraps when calculating tenths, return 0. */
2229#define ASC_TENTHS(num, den) \
2230 (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
2231 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
2232
2233/*
2234 * Display a message to the console.
2235 */
2236#define ASC_PRINT(s) \
2237 { \
2238 printk("advansys: "); \
2239 printk(s); \
2240 }
2241
2242#define ASC_PRINT1(s, a1) \
2243 { \
2244 printk("advansys: "); \
2245 printk((s), (a1)); \
2246 }
2247
2248#define ASC_PRINT2(s, a1, a2) \
2249 { \
2250 printk("advansys: "); \
2251 printk((s), (a1), (a2)); \
2252 }
2253
2254#define ASC_PRINT3(s, a1, a2, a3) \
2255 { \
2256 printk("advansys: "); \
2257 printk((s), (a1), (a2), (a3)); \
2258 }
2259
2260#define ASC_PRINT4(s, a1, a2, a3, a4) \
2261 { \
2262 printk("advansys: "); \
2263 printk((s), (a1), (a2), (a3), (a4)); \
2264 }
2265
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266#ifndef ADVANSYS_DEBUG
2267
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002268#define ASC_DBG(lvl, s...)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269#define ASC_DBG_PRT_SCSI_HOST(lvl, s)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
2271#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2272#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
2273#define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2274#define ASC_DBG_PRT_HEX(lvl, name, start, length)
2275#define ASC_DBG_PRT_CDB(lvl, cdb, len)
2276#define ASC_DBG_PRT_SENSE(lvl, sense, len)
2277#define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
2278
2279#else /* ADVANSYS_DEBUG */
2280
2281/*
2282 * Debugging Message Levels:
2283 * 0: Errors Only
2284 * 1: High-Level Tracing
2285 * 2-N: Verbose Tracing
2286 */
2287
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002288#define ASC_DBG(lvl, format, arg...) { \
2289 if (asc_dbglvl >= (lvl)) \
2290 printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \
2291 __FUNCTION__ , ## arg); \
2292}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002293
2294#define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
2295 { \
2296 if (asc_dbglvl >= (lvl)) { \
2297 asc_prt_scsi_host(s); \
2298 } \
2299 }
2300
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301#define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
2302 { \
2303 if (asc_dbglvl >= (lvl)) { \
2304 asc_prt_asc_scsi_q(scsiqp); \
2305 } \
2306 }
2307
2308#define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
2309 { \
2310 if (asc_dbglvl >= (lvl)) { \
2311 asc_prt_asc_qdone_info(qdone); \
2312 } \
2313 }
2314
2315#define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
2316 { \
2317 if (asc_dbglvl >= (lvl)) { \
2318 asc_prt_adv_scsi_req_q(scsiqp); \
2319 } \
2320 }
2321
2322#define ASC_DBG_PRT_HEX(lvl, name, start, length) \
2323 { \
2324 if (asc_dbglvl >= (lvl)) { \
2325 asc_prt_hex((name), (start), (length)); \
2326 } \
2327 }
2328
2329#define ASC_DBG_PRT_CDB(lvl, cdb, len) \
2330 ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
2331
2332#define ASC_DBG_PRT_SENSE(lvl, sense, len) \
2333 ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
2334
2335#define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
2336 ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
2337#endif /* ADVANSYS_DEBUG */
2338
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339#ifdef ADVANSYS_STATS
2340
2341/* Per board statistics structure */
2342struct asc_stats {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002343 /* Driver Entrypoint Statistics */
2344 ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
2345 ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
2346 ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
2347 ADV_DCNT interrupt; /* # advansys_interrupt() calls */
2348 ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
2349 ADV_DCNT done; /* # calls to request's scsi_done function */
2350 ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
2351 ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
2352 ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
2353 /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
2354 ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
2355 ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
2356 ADV_DCNT exe_error; /* # ASC_ERROR returns. */
2357 ADV_DCNT exe_unknown; /* # unknown returns. */
2358 /* Data Transfer Statistics */
2359 ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
2360 ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
2361 ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
2362 ADV_DCNT sg_elem; /* # scatter-gather elements */
2363 ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364};
2365#endif /* ADVANSYS_STATS */
2366
2367/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002368 * Structure allocated for each board.
2369 *
Matthew Wilcox8dfb5372007-07-30 09:08:34 -06002370 * This structure is allocated by scsi_host_alloc() at the end
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371 * of the 'Scsi_Host' structure starting at the 'hostdata'
2372 * field. It is guaranteed to be allocated from DMA-able memory.
2373 */
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002374struct asc_board {
Matthew Wilcox394dbf32007-07-26 11:56:40 -04002375 struct device *dev;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002376 uint flags; /* Board flags */
Matthew Wilcoxd361db42007-10-02 21:55:29 -04002377 unsigned int irq;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002378 union {
2379 ASC_DVC_VAR asc_dvc_var; /* Narrow board */
2380 ADV_DVC_VAR adv_dvc_var; /* Wide board */
2381 } dvc_var;
2382 union {
2383 ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
2384 ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
2385 } dvc_cfg;
2386 ushort asc_n_io_port; /* Number I/O ports. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002387 ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002388 ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
2389 ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
2390 ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
2391 union {
2392 ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
2393 ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
2394 ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
2395 ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
2396 } eep_config;
2397 ulong last_reset; /* Saved last reset time */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002398 /* /proc/scsi/advansys/[0...] */
2399 char *prtbuf; /* /proc print buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400#ifdef ADVANSYS_STATS
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002401 struct asc_stats asc_stats; /* Board statistics */
2402#endif /* ADVANSYS_STATS */
2403 /*
2404 * The following fields are used only for Narrow Boards.
2405 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002406 uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
2407 /*
2408 * The following fields are used only for Wide Boards.
2409 */
2410 void __iomem *ioremap_addr; /* I/O Memory remap address. */
2411 ushort ioport; /* I/O Port address. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002412 adv_req_t *adv_reqp; /* Request structures. */
2413 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
2414 ushort bios_signature; /* BIOS Signature. */
2415 ushort bios_version; /* BIOS Version. */
2416 ushort bios_codeseg; /* BIOS Code Segment. */
2417 ushort bios_codelen; /* BIOS Code Segment Length. */
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002418};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419
Matthew Wilcox13ac2d92007-07-30 08:10:23 -06002420#define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
2421 dvc_var.adv_dvc_var)
2422#define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
2423
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424/* Overrun buffer used by all narrow boards. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002425static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427#ifdef ADVANSYS_DEBUG
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002428static int asc_dbglvl = 3;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430/*
Matthew Wilcox51219352007-10-02 21:55:22 -04002431 * asc_prt_asc_dvc_var()
2432 */
2433static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
2434{
2435 printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
2436
2437 printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
2438 "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
2439
2440 printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
2441 (unsigned)h->init_sdtr);
2442
2443 printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
2444 "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
2445 (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
2446 (unsigned)h->chip_no);
2447
2448 printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
2449 "%u,\n", (unsigned)h->queue_full_or_busy,
2450 (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
2451
2452 printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
2453 "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
2454 (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
2455 (unsigned)h->in_critical_cnt);
2456
2457 printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
2458 "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
2459 (unsigned)h->init_state, (unsigned)h->no_scam,
2460 (unsigned)h->pci_fix_asyn_xfer);
2461
Matthew Wilcoxd361db42007-10-02 21:55:29 -04002462 printk(" cfg 0x%lx\n", (ulong)h->cfg);
Matthew Wilcox51219352007-10-02 21:55:22 -04002463}
2464
2465/*
2466 * asc_prt_asc_dvc_cfg()
2467 */
2468static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
2469{
2470 printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
2471
2472 printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
2473 h->can_tagged_qng, h->cmd_qng_enabled);
2474 printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
2475 h->disc_enable, h->sdtr_enable);
2476
Matthew Wilcoxb08fc562007-10-02 21:55:32 -04002477 printk(" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, "
2478 "chip_version %d,\n", h->chip_scsi_id, h->isa_dma_speed,
2479 h->isa_dma_channel, h->chip_version);
Matthew Wilcox51219352007-10-02 21:55:22 -04002480
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002481 printk(" mcode_date 0x%x, mcode_version %d, overrun_buf 0x%p\n",
Matthew Wilcoxb08fc562007-10-02 21:55:32 -04002482 h->mcode_date, h->mcode_version, h->overrun_buf);
Matthew Wilcox51219352007-10-02 21:55:22 -04002483}
2484
2485/*
Matthew Wilcox51219352007-10-02 21:55:22 -04002486 * asc_prt_adv_dvc_var()
2487 *
2488 * Display an ADV_DVC_VAR structure.
2489 */
2490static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
2491{
2492 printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
2493
2494 printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
2495 (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
2496
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002497 printk(" sdtr_able 0x%x, wdtr_able 0x%x\n",
2498 (unsigned)h->sdtr_able, (unsigned)h->wdtr_able);
Matthew Wilcox51219352007-10-02 21:55:22 -04002499
Matthew Wilcoxd361db42007-10-02 21:55:29 -04002500 printk(" start_motor 0x%x, scsi_reset_wait 0x%x\n",
2501 (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
Matthew Wilcox51219352007-10-02 21:55:22 -04002502
2503 printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
2504 (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
2505 (ulong)h->carr_freelist);
2506
2507 printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
2508 (ulong)h->icq_sp, (ulong)h->irq_sp);
2509
2510 printk(" no_scam 0x%x, tagqng_able 0x%x\n",
2511 (unsigned)h->no_scam, (unsigned)h->tagqng_able);
2512
2513 printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
2514 (unsigned)h->chip_scsi_id, (ulong)h->cfg);
2515}
2516
2517/*
2518 * asc_prt_adv_dvc_cfg()
2519 *
2520 * Display an ADV_DVC_CFG structure.
2521 */
2522static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
2523{
2524 printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
2525
2526 printk(" disc_enable 0x%x, termination 0x%x\n",
2527 h->disc_enable, h->termination);
2528
2529 printk(" chip_version 0x%x, mcode_date 0x%x\n",
2530 h->chip_version, h->mcode_date);
2531
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002532 printk(" mcode_version 0x%x, control_flag 0x%x\n",
2533 h->mcode_version, h->control_flag);
Matthew Wilcox51219352007-10-02 21:55:22 -04002534}
2535
2536/*
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002537 * asc_prt_scsi_host()
Matthew Wilcox51219352007-10-02 21:55:22 -04002538 */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002539static void asc_prt_scsi_host(struct Scsi_Host *s)
Matthew Wilcox51219352007-10-02 21:55:22 -04002540{
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002541 struct asc_board *boardp = shost_priv(s);
Matthew Wilcox51219352007-10-02 21:55:22 -04002542
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002543 printk("Scsi_Host at addr 0x%p, device %s\n", s, boardp->dev->bus_id);
2544 printk(" host_busy %u, host_no %d, last_reset %d,\n",
2545 s->host_busy, s->host_no, (unsigned)s->last_reset);
Matthew Wilcox51219352007-10-02 21:55:22 -04002546
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002547 printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
2548 (ulong)s->base, (ulong)s->io_port, boardp->irq);
Matthew Wilcox51219352007-10-02 21:55:22 -04002549
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002550 printk(" dma_channel %d, this_id %d, can_queue %d,\n",
2551 s->dma_channel, s->this_id, s->can_queue);
Matthew Wilcox51219352007-10-02 21:55:22 -04002552
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002553 printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
2554 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
Matthew Wilcox51219352007-10-02 21:55:22 -04002555
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002556 if (ASC_NARROW_BOARD(boardp)) {
2557 asc_prt_asc_dvc_var(&boardp->dvc_var.asc_dvc_var);
2558 asc_prt_asc_dvc_cfg(&boardp->dvc_cfg.asc_dvc_cfg);
2559 } else {
2560 asc_prt_adv_dvc_var(&boardp->dvc_var.adv_dvc_var);
2561 asc_prt_adv_dvc_cfg(&boardp->dvc_cfg.adv_dvc_cfg);
Matthew Wilcox51219352007-10-02 21:55:22 -04002562 }
2563}
2564
2565/*
2566 * asc_prt_hex()
2567 *
2568 * Print hexadecimal output in 4 byte groupings 32 bytes
2569 * or 8 double-words per line.
2570 */
2571static void asc_prt_hex(char *f, uchar *s, int l)
2572{
2573 int i;
2574 int j;
2575 int k;
2576 int m;
2577
2578 printk("%s: (%d bytes)\n", f, l);
2579
2580 for (i = 0; i < l; i += 32) {
2581
2582 /* Display a maximum of 8 double-words per line. */
2583 if ((k = (l - i) / 4) >= 8) {
2584 k = 8;
2585 m = 0;
2586 } else {
2587 m = (l - i) % 4;
2588 }
2589
2590 for (j = 0; j < k; j++) {
2591 printk(" %2.2X%2.2X%2.2X%2.2X",
2592 (unsigned)s[i + (j * 4)],
2593 (unsigned)s[i + (j * 4) + 1],
2594 (unsigned)s[i + (j * 4) + 2],
2595 (unsigned)s[i + (j * 4) + 3]);
2596 }
2597
2598 switch (m) {
2599 case 0:
2600 default:
2601 break;
2602 case 1:
2603 printk(" %2.2X", (unsigned)s[i + (j * 4)]);
2604 break;
2605 case 2:
2606 printk(" %2.2X%2.2X",
2607 (unsigned)s[i + (j * 4)],
2608 (unsigned)s[i + (j * 4) + 1]);
2609 break;
2610 case 3:
2611 printk(" %2.2X%2.2X%2.2X",
2612 (unsigned)s[i + (j * 4) + 1],
2613 (unsigned)s[i + (j * 4) + 2],
2614 (unsigned)s[i + (j * 4) + 3]);
2615 break;
2616 }
2617
2618 printk("\n");
2619 }
2620}
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002621
2622/*
2623 * asc_prt_asc_scsi_q()
2624 */
2625static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
2626{
2627 ASC_SG_HEAD *sgp;
2628 int i;
2629
2630 printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
2631
2632 printk
2633 (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
2634 q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
2635 q->q2.tag_code);
2636
2637 printk
2638 (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2639 (ulong)le32_to_cpu(q->q1.data_addr),
2640 (ulong)le32_to_cpu(q->q1.data_cnt),
2641 (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
2642
2643 printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
2644 (ulong)q->cdbptr, q->q2.cdb_len,
2645 (ulong)q->sg_head, q->q1.sg_queue_cnt);
2646
2647 if (q->sg_head) {
2648 sgp = q->sg_head;
2649 printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
2650 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
2651 sgp->queue_cnt);
2652 for (i = 0; i < sgp->entry_cnt; i++) {
2653 printk(" [%u]: addr 0x%lx, bytes %lu\n",
2654 i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
2655 (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
2656 }
2657
2658 }
2659}
2660
2661/*
2662 * asc_prt_asc_qdone_info()
2663 */
2664static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
2665{
2666 printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
2667 printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
2668 (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
2669 q->d2.tag_code);
2670 printk
2671 (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
2672 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
2673}
2674
2675/*
2676 * asc_prt_adv_sgblock()
2677 *
2678 * Display an ADV_SG_BLOCK structure.
2679 */
2680static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
2681{
2682 int i;
2683
2684 printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
2685 (ulong)b, sgblockno);
2686 printk(" sg_cnt %u, sg_ptr 0x%lx\n",
2687 b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
2688 BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
2689 if (b->sg_ptr != 0)
2690 BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
2691 for (i = 0; i < b->sg_cnt; i++) {
2692 printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
2693 i, (ulong)b->sg_list[i].sg_addr,
2694 (ulong)b->sg_list[i].sg_count);
2695 }
2696}
2697
2698/*
2699 * asc_prt_adv_scsi_req_q()
2700 *
2701 * Display an ADV_SCSI_REQ_Q structure.
2702 */
2703static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
2704{
2705 int sg_blk_cnt;
2706 struct asc_sg_block *sg_ptr;
2707
2708 printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
2709
2710 printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
2711 q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
2712
2713 printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
2714 q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
2715
2716 printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2717 (ulong)le32_to_cpu(q->data_cnt),
2718 (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
2719
2720 printk
2721 (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
2722 q->cdb_len, q->done_status, q->host_status, q->scsi_status);
2723
2724 printk(" sg_working_ix 0x%x, target_cmd %u\n",
2725 q->sg_working_ix, q->target_cmd);
2726
2727 printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
2728 (ulong)le32_to_cpu(q->scsiq_rptr),
2729 (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
2730
2731 /* Display the request's ADV_SG_BLOCK structures. */
2732 if (q->sg_list_ptr != NULL) {
2733 sg_blk_cnt = 0;
2734 while (1) {
2735 /*
2736 * 'sg_ptr' is a physical address. Convert it to a virtual
2737 * address by indexing 'sg_blk_cnt' into the virtual address
2738 * array 'sg_list_ptr'.
2739 *
2740 * XXX - Assumes all SG physical blocks are virtually contiguous.
2741 */
2742 sg_ptr =
2743 &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
2744 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
2745 if (sg_ptr->sg_ptr == 0) {
2746 break;
2747 }
2748 sg_blk_cnt++;
2749 }
2750 }
2751}
Matthew Wilcox51219352007-10-02 21:55:22 -04002752#endif /* ADVANSYS_DEBUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002753
2754/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 * advansys_info()
2756 *
2757 * Return suitable for printing on the console with the argument
2758 * adapter's configuration information.
2759 *
2760 * Note: The information line should not exceed ASC_INFO_SIZE bytes,
2761 * otherwise the static 'info' array will be overrun.
2762 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002763static const char *advansys_info(struct Scsi_Host *shost)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002764{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002765 static char info[ASC_INFO_SIZE];
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002766 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002767 ASC_DVC_VAR *asc_dvc_varp;
2768 ADV_DVC_VAR *adv_dvc_varp;
2769 char *busname;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002770 char *widename = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002771
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002772 if (ASC_NARROW_BOARD(boardp)) {
2773 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002774 ASC_DBG(1, "begin\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002775 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
2776 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
2777 ASC_IS_ISAPNP) {
2778 busname = "ISA PnP";
2779 } else {
2780 busname = "ISA";
2781 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002782 sprintf(info,
2783 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
2784 ASC_VERSION, busname,
2785 (ulong)shost->io_port,
Matthew Wilcox4a2d31c2007-07-26 11:55:34 -04002786 (ulong)shost->io_port + ASC_IOADR_GAP - 1,
Matthew Wilcoxd361db42007-10-02 21:55:29 -04002787 boardp->irq, shost->dma_channel);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002788 } else {
2789 if (asc_dvc_varp->bus_type & ASC_IS_VL) {
2790 busname = "VL";
2791 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
2792 busname = "EISA";
2793 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
2794 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
2795 == ASC_IS_PCI_ULTRA) {
2796 busname = "PCI Ultra";
2797 } else {
2798 busname = "PCI";
2799 }
2800 } else {
2801 busname = "?";
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -04002802 shost_printk(KERN_ERR, shost, "unknown bus "
2803 "type %d\n", asc_dvc_varp->bus_type);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002804 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002805 sprintf(info,
2806 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
Matthew Wilcoxecec1942007-07-30 08:08:22 -06002807 ASC_VERSION, busname, (ulong)shost->io_port,
Matthew Wilcox4a2d31c2007-07-26 11:55:34 -04002808 (ulong)shost->io_port + ASC_IOADR_GAP - 1,
Matthew Wilcoxd361db42007-10-02 21:55:29 -04002809 boardp->irq);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002810 }
2811 } else {
2812 /*
2813 * Wide Adapter Information
2814 *
2815 * Memory-mapped I/O is used instead of I/O space to access
2816 * the adapter, but display the I/O Port range. The Memory
2817 * I/O address is displayed through the driver /proc file.
2818 */
2819 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
2820 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002821 widename = "Ultra-Wide";
2822 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002823 widename = "Ultra2-Wide";
2824 } else {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002825 widename = "Ultra3-Wide";
2826 }
2827 sprintf(info,
2828 "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
2829 ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
Matthew Wilcoxd361db42007-10-02 21:55:29 -04002830 (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, boardp->irq);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002831 }
Matthew Wilcoxb009bef2007-09-09 08:56:38 -06002832 BUG_ON(strlen(info) >= ASC_INFO_SIZE);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04002833 ASC_DBG(1, "end\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002834 return info;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835}
2836
Matthew Wilcox51219352007-10-02 21:55:22 -04002837#ifdef CONFIG_PROC_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -07002838/*
Matthew Wilcox51219352007-10-02 21:55:22 -04002839 * asc_prt_line()
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 *
Matthew Wilcox51219352007-10-02 21:55:22 -04002841 * If 'cp' is NULL print to the console, otherwise print to a buffer.
2842 *
2843 * Return 0 if printing to the console, otherwise return the number of
2844 * bytes written to the buffer.
2845 *
2846 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
2847 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002848 */
Matthew Wilcox51219352007-10-02 21:55:22 -04002849static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850{
Matthew Wilcox51219352007-10-02 21:55:22 -04002851 va_list args;
2852 int ret;
2853 char s[ASC_PRTLINE_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854
Matthew Wilcox51219352007-10-02 21:55:22 -04002855 va_start(args, fmt);
2856 ret = vsprintf(s, fmt, args);
2857 BUG_ON(ret >= ASC_PRTLINE_SIZE);
2858 if (buf == NULL) {
2859 (void)printk(s);
2860 ret = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002861 } else {
Matthew Wilcox51219352007-10-02 21:55:22 -04002862 ret = min(buflen, ret);
2863 memcpy(buf, s, ret);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002864 }
Matthew Wilcox51219352007-10-02 21:55:22 -04002865 va_end(args);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002866 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867}
2868
2869/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002870 * asc_prt_board_devices()
2871 *
2872 * Print driver information for devices attached to the board.
2873 *
2874 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
2875 * cf. asc_prt_line().
2876 *
2877 * Return the number of characters copied into 'cp'. No more than
2878 * 'cplen' characters will be copied to 'cp'.
2879 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002880static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002881{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002882 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002883 int leftlen;
2884 int totlen;
2885 int len;
2886 int chip_scsi_id;
2887 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002888
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002889 leftlen = cplen;
2890 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002891
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002892 len = asc_prt_line(cp, leftlen,
2893 "\nDevice Information for AdvanSys SCSI Host %d:\n",
2894 shost->host_no);
2895 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002897 if (ASC_NARROW_BOARD(boardp)) {
2898 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
2899 } else {
2900 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
2901 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002902
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002903 len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
2904 ASC_PRT_NEXT();
2905 for (i = 0; i <= ADV_MAX_TID; i++) {
2906 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
2907 len = asc_prt_line(cp, leftlen, " %X,", i);
2908 ASC_PRT_NEXT();
2909 }
2910 }
2911 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
2912 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002913
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002914 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002915}
2916
2917/*
2918 * Display Wide Board BIOS Information.
2919 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002920static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002921{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04002922 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002923 int leftlen;
2924 int totlen;
2925 int len;
2926 ushort major, minor, letter;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002927
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002928 leftlen = cplen;
2929 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002931 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
2932 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002933
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002934 /*
2935 * If the BIOS saved a valid signature, then fill in
2936 * the BIOS code segment base address.
2937 */
2938 if (boardp->bios_signature != 0x55AA) {
2939 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
2940 ASC_PRT_NEXT();
2941 len = asc_prt_line(cp, leftlen,
2942 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
2943 ASC_PRT_NEXT();
2944 len = asc_prt_line(cp, leftlen,
2945 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
2946 ASC_PRT_NEXT();
2947 } else {
2948 major = (boardp->bios_version >> 12) & 0xF;
2949 minor = (boardp->bios_version >> 8) & 0xF;
2950 letter = (boardp->bios_version & 0xFF);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002951
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002952 len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
2953 major, minor,
2954 letter >= 26 ? '?' : letter + 'A');
2955 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07002956
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002957 /*
2958 * Current available ROM BIOS release is 3.1I for UW
2959 * and 3.2I for U2W. This code doesn't differentiate
2960 * UW and U2W boards.
2961 */
2962 if (major < 3 || (major <= 3 && minor < 1) ||
2963 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
2964 len = asc_prt_line(cp, leftlen,
2965 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
2966 ASC_PRT_NEXT();
2967 len = asc_prt_line(cp, leftlen,
2968 "ftp://ftp.connectcom.net/pub\n");
2969 ASC_PRT_NEXT();
2970 }
2971 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002973 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002974}
2975
2976/*
2977 * Add serial number to information bar if signature AAh
2978 * is found in at bit 15-9 (7 bits) of word 1.
2979 *
2980 * Serial Number consists fo 12 alpha-numeric digits.
2981 *
2982 * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
2983 * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
2984 * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
2985 * 5 - Product revision (A-J) Word0: " "
2986 *
2987 * Signature Word1: 15-9 (7 bits)
2988 * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
2989 * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
2990 *
2991 * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
2992 *
2993 * Note 1: Only production cards will have a serial number.
2994 *
2995 * Note 2: Signature is most significant 7 bits (0xFE).
2996 *
2997 * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
2998 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04002999static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003000{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003001 ushort w, num;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003002
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003003 if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
3004 return ASC_FALSE;
3005 } else {
3006 /*
3007 * First word - 6 digits.
3008 */
3009 w = serialnum[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -07003010
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003011 /* Product type - 1st digit. */
3012 if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
3013 /* Product type is P=Prototype */
3014 *cp += 0x8;
3015 }
3016 cp++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003018 /* Manufacturing location - 2nd digit. */
3019 *cp++ = 'A' + ((w & 0x1C00) >> 10);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003021 /* Product ID - 3rd, 4th digits. */
3022 num = w & 0x3FF;
3023 *cp++ = '0' + (num / 100);
3024 num %= 100;
3025 *cp++ = '0' + (num / 10);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003026
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003027 /* Product revision - 5th digit. */
3028 *cp++ = 'A' + (num % 10);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003029
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003030 /*
3031 * Second word
3032 */
3033 w = serialnum[1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07003034
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003035 /*
3036 * Year - 6th digit.
3037 *
3038 * If bit 15 of third word is set, then the
3039 * last digit of the year is greater than 7.
3040 */
3041 if (serialnum[2] & 0x8000) {
3042 *cp++ = '8' + ((w & 0x1C0) >> 6);
3043 } else {
3044 *cp++ = '0' + ((w & 0x1C0) >> 6);
3045 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003046
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003047 /* Week of year - 7th, 8th digits. */
3048 num = w & 0x003F;
3049 *cp++ = '0' + num / 10;
3050 num %= 10;
3051 *cp++ = '0' + num;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003052
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003053 /*
3054 * Third word
3055 */
3056 w = serialnum[2] & 0x7FFF;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003057
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003058 /* Serial number - 9th digit. */
3059 *cp++ = 'A' + (w / 1000);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003060
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003061 /* 10th, 11th, 12th digits. */
3062 num = w % 1000;
3063 *cp++ = '0' + num / 100;
3064 num %= 100;
3065 *cp++ = '0' + num / 10;
3066 num %= 10;
3067 *cp++ = '0' + num;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003069 *cp = '\0'; /* Null Terminate the string. */
3070 return ASC_TRUE;
3071 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003072}
3073
3074/*
3075 * asc_prt_asc_board_eeprom()
3076 *
3077 * Print board EEPROM configuration.
3078 *
3079 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3080 * cf. asc_prt_line().
3081 *
3082 * Return the number of characters copied into 'cp'. No more than
3083 * 'cplen' characters will be copied to 'cp'.
3084 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003085static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003086{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04003087 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003088 ASC_DVC_VAR *asc_dvc_varp;
3089 int leftlen;
3090 int totlen;
3091 int len;
3092 ASCEEP_CONFIG *ep;
3093 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003094#ifdef CONFIG_ISA
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003095 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
Linus Torvalds1da177e2005-04-16 15:20:36 -07003096#endif /* CONFIG_ISA */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003097 uchar serialstr[13];
Linus Torvalds1da177e2005-04-16 15:20:36 -07003098
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003099 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
3100 ep = &boardp->eep_config.asc_eep;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003101
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003102 leftlen = cplen;
3103 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003105 len = asc_prt_line(cp, leftlen,
3106 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3107 shost->host_no);
3108 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003109
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003110 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
3111 == ASC_TRUE) {
3112 len =
3113 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
3114 serialstr);
3115 ASC_PRT_NEXT();
3116 } else {
3117 if (ep->adapter_info[5] == 0xBB) {
3118 len = asc_prt_line(cp, leftlen,
3119 " Default Settings Used for EEPROM-less Adapter.\n");
3120 ASC_PRT_NEXT();
3121 } else {
3122 len = asc_prt_line(cp, leftlen,
3123 " Serial Number Signature Not Present.\n");
3124 ASC_PRT_NEXT();
3125 }
3126 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003127
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003128 len = asc_prt_line(cp, leftlen,
3129 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3130 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
3131 ep->max_tag_qng);
3132 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003133
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003134 len = asc_prt_line(cp, leftlen,
3135 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
3136 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003137
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003138 len = asc_prt_line(cp, leftlen, " Target ID: ");
3139 ASC_PRT_NEXT();
3140 for (i = 0; i <= ASC_MAX_TID; i++) {
3141 len = asc_prt_line(cp, leftlen, " %d", i);
3142 ASC_PRT_NEXT();
3143 }
3144 len = asc_prt_line(cp, leftlen, "\n");
3145 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003146
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003147 len = asc_prt_line(cp, leftlen, " Disconnects: ");
3148 ASC_PRT_NEXT();
3149 for (i = 0; i <= ASC_MAX_TID; i++) {
3150 len = asc_prt_line(cp, leftlen, " %c",
3151 (ep->
3152 disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3153 'N');
3154 ASC_PRT_NEXT();
3155 }
3156 len = asc_prt_line(cp, leftlen, "\n");
3157 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003158
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003159 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3160 ASC_PRT_NEXT();
3161 for (i = 0; i <= ASC_MAX_TID; i++) {
3162 len = asc_prt_line(cp, leftlen, " %c",
3163 (ep->
3164 use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3165 'N');
3166 ASC_PRT_NEXT();
3167 }
3168 len = asc_prt_line(cp, leftlen, "\n");
3169 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003170
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003171 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3172 ASC_PRT_NEXT();
3173 for (i = 0; i <= ASC_MAX_TID; i++) {
3174 len = asc_prt_line(cp, leftlen, " %c",
3175 (ep->
3176 start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3177 'N');
3178 ASC_PRT_NEXT();
3179 }
3180 len = asc_prt_line(cp, leftlen, "\n");
3181 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003182
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003183 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3184 ASC_PRT_NEXT();
3185 for (i = 0; i <= ASC_MAX_TID; i++) {
3186 len = asc_prt_line(cp, leftlen, " %c",
3187 (ep->
3188 init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3189 'N');
3190 ASC_PRT_NEXT();
3191 }
3192 len = asc_prt_line(cp, leftlen, "\n");
3193 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003194
3195#ifdef CONFIG_ISA
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003196 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
3197 len = asc_prt_line(cp, leftlen,
3198 " Host ISA DMA speed: %d MB/S\n",
3199 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
3200 ASC_PRT_NEXT();
3201 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003202#endif /* CONFIG_ISA */
3203
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003204 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205}
3206
3207/*
3208 * asc_prt_adv_board_eeprom()
3209 *
3210 * Print board EEPROM configuration.
3211 *
3212 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3213 * cf. asc_prt_line().
3214 *
3215 * Return the number of characters copied into 'cp'. No more than
3216 * 'cplen' characters will be copied to 'cp'.
3217 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003218static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003219{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04003220 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003221 ADV_DVC_VAR *adv_dvc_varp;
3222 int leftlen;
3223 int totlen;
3224 int len;
3225 int i;
3226 char *termstr;
3227 uchar serialstr[13];
3228 ADVEEP_3550_CONFIG *ep_3550 = NULL;
3229 ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
3230 ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
3231 ushort word;
3232 ushort *wordp;
3233 ushort sdtr_speed = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003234
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003235 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
3236 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3237 ep_3550 = &boardp->eep_config.adv_3550_eep;
3238 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3239 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
3240 } else {
3241 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
3242 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003243
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003244 leftlen = cplen;
3245 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003246
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003247 len = asc_prt_line(cp, leftlen,
3248 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3249 shost->host_no);
3250 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003251
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003252 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3253 wordp = &ep_3550->serial_number_word1;
3254 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3255 wordp = &ep_38C0800->serial_number_word1;
3256 } else {
3257 wordp = &ep_38C1600->serial_number_word1;
3258 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003260 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
3261 len =
3262 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
3263 serialstr);
3264 ASC_PRT_NEXT();
3265 } else {
3266 len = asc_prt_line(cp, leftlen,
3267 " Serial Number Signature Not Present.\n");
3268 ASC_PRT_NEXT();
3269 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003270
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003271 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3272 len = asc_prt_line(cp, leftlen,
3273 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3274 ep_3550->adapter_scsi_id,
3275 ep_3550->max_host_qng, ep_3550->max_dvc_qng);
3276 ASC_PRT_NEXT();
3277 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3278 len = asc_prt_line(cp, leftlen,
3279 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3280 ep_38C0800->adapter_scsi_id,
3281 ep_38C0800->max_host_qng,
3282 ep_38C0800->max_dvc_qng);
3283 ASC_PRT_NEXT();
3284 } else {
3285 len = asc_prt_line(cp, leftlen,
3286 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3287 ep_38C1600->adapter_scsi_id,
3288 ep_38C1600->max_host_qng,
3289 ep_38C1600->max_dvc_qng);
3290 ASC_PRT_NEXT();
3291 }
3292 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3293 word = ep_3550->termination;
3294 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3295 word = ep_38C0800->termination_lvd;
3296 } else {
3297 word = ep_38C1600->termination_lvd;
3298 }
3299 switch (word) {
3300 case 1:
3301 termstr = "Low Off/High Off";
3302 break;
3303 case 2:
3304 termstr = "Low Off/High On";
3305 break;
3306 case 3:
3307 termstr = "Low On/High On";
3308 break;
3309 default:
3310 case 0:
3311 termstr = "Automatic";
3312 break;
3313 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003315 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3316 len = asc_prt_line(cp, leftlen,
3317 " termination: %u (%s), bios_ctrl: 0x%x\n",
3318 ep_3550->termination, termstr,
3319 ep_3550->bios_ctrl);
3320 ASC_PRT_NEXT();
3321 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3322 len = asc_prt_line(cp, leftlen,
3323 " termination: %u (%s), bios_ctrl: 0x%x\n",
3324 ep_38C0800->termination_lvd, termstr,
3325 ep_38C0800->bios_ctrl);
3326 ASC_PRT_NEXT();
3327 } else {
3328 len = asc_prt_line(cp, leftlen,
3329 " termination: %u (%s), bios_ctrl: 0x%x\n",
3330 ep_38C1600->termination_lvd, termstr,
3331 ep_38C1600->bios_ctrl);
3332 ASC_PRT_NEXT();
3333 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003335 len = asc_prt_line(cp, leftlen, " Target ID: ");
3336 ASC_PRT_NEXT();
3337 for (i = 0; i <= ADV_MAX_TID; i++) {
3338 len = asc_prt_line(cp, leftlen, " %X", i);
3339 ASC_PRT_NEXT();
3340 }
3341 len = asc_prt_line(cp, leftlen, "\n");
3342 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003343
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003344 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3345 word = ep_3550->disc_enable;
3346 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3347 word = ep_38C0800->disc_enable;
3348 } else {
3349 word = ep_38C1600->disc_enable;
3350 }
3351 len = asc_prt_line(cp, leftlen, " Disconnects: ");
3352 ASC_PRT_NEXT();
3353 for (i = 0; i <= ADV_MAX_TID; i++) {
3354 len = asc_prt_line(cp, leftlen, " %c",
3355 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3356 ASC_PRT_NEXT();
3357 }
3358 len = asc_prt_line(cp, leftlen, "\n");
3359 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003360
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003361 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3362 word = ep_3550->tagqng_able;
3363 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3364 word = ep_38C0800->tagqng_able;
3365 } else {
3366 word = ep_38C1600->tagqng_able;
3367 }
3368 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3369 ASC_PRT_NEXT();
3370 for (i = 0; i <= ADV_MAX_TID; i++) {
3371 len = asc_prt_line(cp, leftlen, " %c",
3372 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3373 ASC_PRT_NEXT();
3374 }
3375 len = asc_prt_line(cp, leftlen, "\n");
3376 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003377
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003378 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3379 word = ep_3550->start_motor;
3380 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3381 word = ep_38C0800->start_motor;
3382 } else {
3383 word = ep_38C1600->start_motor;
3384 }
3385 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3386 ASC_PRT_NEXT();
3387 for (i = 0; i <= ADV_MAX_TID; i++) {
3388 len = asc_prt_line(cp, leftlen, " %c",
3389 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3390 ASC_PRT_NEXT();
3391 }
3392 len = asc_prt_line(cp, leftlen, "\n");
3393 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003395 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3396 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3397 ASC_PRT_NEXT();
3398 for (i = 0; i <= ADV_MAX_TID; i++) {
3399 len = asc_prt_line(cp, leftlen, " %c",
3400 (ep_3550->
3401 sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
3402 'Y' : 'N');
3403 ASC_PRT_NEXT();
3404 }
3405 len = asc_prt_line(cp, leftlen, "\n");
3406 ASC_PRT_NEXT();
3407 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003408
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003409 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3410 len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
3411 ASC_PRT_NEXT();
3412 for (i = 0; i <= ADV_MAX_TID; i++) {
3413 len = asc_prt_line(cp, leftlen, " %c",
3414 (ep_3550->
3415 ultra_able & ADV_TID_TO_TIDMASK(i))
3416 ? 'Y' : 'N');
3417 ASC_PRT_NEXT();
3418 }
3419 len = asc_prt_line(cp, leftlen, "\n");
3420 ASC_PRT_NEXT();
3421 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003422
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003423 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3424 word = ep_3550->wdtr_able;
3425 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
3426 word = ep_38C0800->wdtr_able;
3427 } else {
3428 word = ep_38C1600->wdtr_able;
3429 }
3430 len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
3431 ASC_PRT_NEXT();
3432 for (i = 0; i <= ADV_MAX_TID; i++) {
3433 len = asc_prt_line(cp, leftlen, " %c",
3434 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3435 ASC_PRT_NEXT();
3436 }
3437 len = asc_prt_line(cp, leftlen, "\n");
3438 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003439
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003440 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
3441 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
3442 len = asc_prt_line(cp, leftlen,
3443 " Synchronous Transfer Speed (Mhz):\n ");
3444 ASC_PRT_NEXT();
3445 for (i = 0; i <= ADV_MAX_TID; i++) {
3446 char *speed_str;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003447
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003448 if (i == 0) {
3449 sdtr_speed = adv_dvc_varp->sdtr_speed1;
3450 } else if (i == 4) {
3451 sdtr_speed = adv_dvc_varp->sdtr_speed2;
3452 } else if (i == 8) {
3453 sdtr_speed = adv_dvc_varp->sdtr_speed3;
3454 } else if (i == 12) {
3455 sdtr_speed = adv_dvc_varp->sdtr_speed4;
3456 }
3457 switch (sdtr_speed & ADV_MAX_TID) {
3458 case 0:
3459 speed_str = "Off";
3460 break;
3461 case 1:
3462 speed_str = " 5";
3463 break;
3464 case 2:
3465 speed_str = " 10";
3466 break;
3467 case 3:
3468 speed_str = " 20";
3469 break;
3470 case 4:
3471 speed_str = " 40";
3472 break;
3473 case 5:
3474 speed_str = " 80";
3475 break;
3476 default:
3477 speed_str = "Unk";
3478 break;
3479 }
3480 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
3481 ASC_PRT_NEXT();
3482 if (i == 7) {
3483 len = asc_prt_line(cp, leftlen, "\n ");
3484 ASC_PRT_NEXT();
3485 }
3486 sdtr_speed >>= 4;
3487 }
3488 len = asc_prt_line(cp, leftlen, "\n");
3489 ASC_PRT_NEXT();
3490 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003491
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003492 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003493}
3494
3495/*
3496 * asc_prt_driver_conf()
3497 *
3498 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3499 * cf. asc_prt_line().
3500 *
3501 * Return the number of characters copied into 'cp'. No more than
3502 * 'cplen' characters will be copied to 'cp'.
3503 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003504static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04003506 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003507 int leftlen;
3508 int totlen;
3509 int len;
3510 int chip_scsi_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003511
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003512 leftlen = cplen;
3513 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003515 len = asc_prt_line(cp, leftlen,
3516 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
3517 shost->host_no);
3518 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003519
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003520 len = asc_prt_line(cp, leftlen,
3521 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
3522 shost->host_busy, shost->last_reset, shost->max_id,
3523 shost->max_lun, shost->max_channel);
3524 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003525
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003526 len = asc_prt_line(cp, leftlen,
3527 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
3528 shost->unique_id, shost->can_queue, shost->this_id,
3529 shost->sg_tablesize, shost->cmd_per_lun);
3530 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003531
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003532 len = asc_prt_line(cp, leftlen,
3533 " unchecked_isa_dma %d, use_clustering %d\n",
3534 shost->unchecked_isa_dma, shost->use_clustering);
3535 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003536
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003537 len = asc_prt_line(cp, leftlen,
3538 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
3539 boardp->flags, boardp->last_reset, jiffies,
3540 boardp->asc_n_io_port);
3541 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003542
Matthew Wilcox4a2d31c2007-07-26 11:55:34 -04003543 len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003544 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003545
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003546 if (ASC_NARROW_BOARD(boardp)) {
3547 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
3548 } else {
3549 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
3550 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003551
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003552 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003553}
3554
3555/*
3556 * asc_prt_asc_board_info()
3557 *
3558 * Print dynamic board configuration information.
3559 *
3560 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3561 * cf. asc_prt_line().
3562 *
3563 * Return the number of characters copied into 'cp'. No more than
3564 * 'cplen' characters will be copied to 'cp'.
3565 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003566static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003567{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04003568 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003569 int chip_scsi_id;
3570 int leftlen;
3571 int totlen;
3572 int len;
3573 ASC_DVC_VAR *v;
3574 ASC_DVC_CFG *c;
3575 int i;
3576 int renegotiate = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003577
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003578 v = &boardp->dvc_var.asc_dvc_var;
3579 c = &boardp->dvc_cfg.asc_dvc_cfg;
3580 chip_scsi_id = c->chip_scsi_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003581
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003582 leftlen = cplen;
3583 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003584
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003585 len = asc_prt_line(cp, leftlen,
3586 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3587 shost->host_no);
3588 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003589
Matthew Wilcoxb08fc562007-10-02 21:55:32 -04003590 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
3591 "mcode_version 0x%x, err_code %u\n",
3592 c->chip_version, c->mcode_date, c->mcode_version,
3593 v->err_code);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003594 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003595
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003596 /* Current number of commands waiting for the host. */
3597 len = asc_prt_line(cp, leftlen,
3598 " Total Command Pending: %d\n", v->cur_total_qng);
3599 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003600
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003601 len = asc_prt_line(cp, leftlen, " Command Queuing:");
3602 ASC_PRT_NEXT();
3603 for (i = 0; i <= ASC_MAX_TID; i++) {
3604 if ((chip_scsi_id == i) ||
3605 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3606 continue;
3607 }
3608 len = asc_prt_line(cp, leftlen, " %X:%c",
3609 i,
3610 (v->
3611 use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
3612 'Y' : 'N');
3613 ASC_PRT_NEXT();
3614 }
3615 len = asc_prt_line(cp, leftlen, "\n");
3616 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003617
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003618 /* Current number of commands waiting for a device. */
3619 len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
3620 ASC_PRT_NEXT();
3621 for (i = 0; i <= ASC_MAX_TID; i++) {
3622 if ((chip_scsi_id == i) ||
3623 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3624 continue;
3625 }
3626 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
3627 ASC_PRT_NEXT();
3628 }
3629 len = asc_prt_line(cp, leftlen, "\n");
3630 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003631
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003632 /* Current limit on number of commands that can be sent to a device. */
3633 len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
3634 ASC_PRT_NEXT();
3635 for (i = 0; i <= ASC_MAX_TID; i++) {
3636 if ((chip_scsi_id == i) ||
3637 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3638 continue;
3639 }
3640 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
3641 ASC_PRT_NEXT();
3642 }
3643 len = asc_prt_line(cp, leftlen, "\n");
3644 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003645
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003646 /* Indicate whether the device has returned queue full status. */
3647 len = asc_prt_line(cp, leftlen, " Command Queue Full:");
3648 ASC_PRT_NEXT();
3649 for (i = 0; i <= ASC_MAX_TID; i++) {
3650 if ((chip_scsi_id == i) ||
3651 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3652 continue;
3653 }
3654 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
3655 len = asc_prt_line(cp, leftlen, " %X:Y-%d",
3656 i, boardp->queue_full_cnt[i]);
3657 } else {
3658 len = asc_prt_line(cp, leftlen, " %X:N", i);
3659 }
3660 ASC_PRT_NEXT();
3661 }
3662 len = asc_prt_line(cp, leftlen, "\n");
3663 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003665 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3666 ASC_PRT_NEXT();
3667 for (i = 0; i <= ASC_MAX_TID; i++) {
3668 if ((chip_scsi_id == i) ||
3669 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3670 continue;
3671 }
3672 len = asc_prt_line(cp, leftlen, " %X:%c",
3673 i,
3674 (v->
3675 sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3676 'N');
3677 ASC_PRT_NEXT();
3678 }
3679 len = asc_prt_line(cp, leftlen, "\n");
3680 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003681
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003682 for (i = 0; i <= ASC_MAX_TID; i++) {
3683 uchar syn_period_ix;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003685 if ((chip_scsi_id == i) ||
3686 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
3687 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
3688 continue;
3689 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003690
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003691 len = asc_prt_line(cp, leftlen, " %X:", i);
3692 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003693
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003694 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
3695 len = asc_prt_line(cp, leftlen, " Asynchronous");
3696 ASC_PRT_NEXT();
3697 } else {
3698 syn_period_ix =
3699 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
3700 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003701
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003702 len = asc_prt_line(cp, leftlen,
3703 " Transfer Period Factor: %d (%d.%d Mhz),",
3704 v->sdtr_period_tbl[syn_period_ix],
3705 250 /
3706 v->sdtr_period_tbl[syn_period_ix],
3707 ASC_TENTHS(250,
3708 v->
3709 sdtr_period_tbl
3710 [syn_period_ix]));
3711 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003713 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
3714 boardp->
3715 sdtr_data[i] & ASC_SYN_MAX_OFFSET);
3716 ASC_PRT_NEXT();
3717 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003718
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003719 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3720 len = asc_prt_line(cp, leftlen, "*\n");
3721 renegotiate = 1;
3722 } else {
3723 len = asc_prt_line(cp, leftlen, "\n");
3724 }
3725 ASC_PRT_NEXT();
3726 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003727
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003728 if (renegotiate) {
3729 len = asc_prt_line(cp, leftlen,
3730 " * = Re-negotiation pending before next command.\n");
3731 ASC_PRT_NEXT();
3732 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003733
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003734 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003735}
3736
3737/*
3738 * asc_prt_adv_board_info()
3739 *
3740 * Print dynamic board configuration information.
3741 *
3742 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3743 * cf. asc_prt_line().
3744 *
3745 * Return the number of characters copied into 'cp'. No more than
3746 * 'cplen' characters will be copied to 'cp'.
3747 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003748static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003749{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04003750 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003751 int leftlen;
3752 int totlen;
3753 int len;
3754 int i;
3755 ADV_DVC_VAR *v;
3756 ADV_DVC_CFG *c;
3757 AdvPortAddr iop_base;
3758 ushort chip_scsi_id;
3759 ushort lramword;
3760 uchar lrambyte;
3761 ushort tagqng_able;
3762 ushort sdtr_able, wdtr_able;
3763 ushort wdtr_done, sdtr_done;
3764 ushort period = 0;
3765 int renegotiate = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003766
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003767 v = &boardp->dvc_var.adv_dvc_var;
3768 c = &boardp->dvc_cfg.adv_dvc_cfg;
3769 iop_base = v->iop_base;
3770 chip_scsi_id = v->chip_scsi_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003771
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003772 leftlen = cplen;
3773 totlen = len = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003774
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003775 len = asc_prt_line(cp, leftlen,
3776 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3777 shost->host_no);
3778 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003779
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003780 len = asc_prt_line(cp, leftlen,
3781 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
3782 v->iop_base,
3783 AdvReadWordRegister(iop_base,
3784 IOPW_SCSI_CFG1) & CABLE_DETECT,
3785 v->err_code);
3786 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003787
Matthew Wilcoxb08fc562007-10-02 21:55:32 -04003788 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
3789 "mcode_version 0x%x\n", c->chip_version,
3790 c->mcode_date, c->mcode_version);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003791 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003793 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
3794 len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
3795 ASC_PRT_NEXT();
3796 for (i = 0; i <= ADV_MAX_TID; i++) {
3797 if ((chip_scsi_id == i) ||
3798 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3799 continue;
3800 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003801
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003802 len = asc_prt_line(cp, leftlen, " %X:%c",
3803 i,
3804 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3805 'N');
3806 ASC_PRT_NEXT();
3807 }
3808 len = asc_prt_line(cp, leftlen, "\n");
3809 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003810
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003811 len = asc_prt_line(cp, leftlen, " Queue Limit:");
3812 ASC_PRT_NEXT();
3813 for (i = 0; i <= ADV_MAX_TID; i++) {
3814 if ((chip_scsi_id == i) ||
3815 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3816 continue;
3817 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003818
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003819 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
3820 lrambyte);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003821
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003822 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
3823 ASC_PRT_NEXT();
3824 }
3825 len = asc_prt_line(cp, leftlen, "\n");
3826 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003827
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003828 len = asc_prt_line(cp, leftlen, " Command Pending:");
3829 ASC_PRT_NEXT();
3830 for (i = 0; i <= ADV_MAX_TID; i++) {
3831 if ((chip_scsi_id == i) ||
3832 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3833 continue;
3834 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003835
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003836 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
3837 lrambyte);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003838
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003839 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
3840 ASC_PRT_NEXT();
3841 }
3842 len = asc_prt_line(cp, leftlen, "\n");
3843 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003844
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003845 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
3846 len = asc_prt_line(cp, leftlen, " Wide Enabled:");
3847 ASC_PRT_NEXT();
3848 for (i = 0; i <= ADV_MAX_TID; i++) {
3849 if ((chip_scsi_id == i) ||
3850 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3851 continue;
3852 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003853
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003854 len = asc_prt_line(cp, leftlen, " %X:%c",
3855 i,
3856 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3857 'N');
3858 ASC_PRT_NEXT();
3859 }
3860 len = asc_prt_line(cp, leftlen, "\n");
3861 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003862
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003863 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
3864 len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
3865 ASC_PRT_NEXT();
3866 for (i = 0; i <= ADV_MAX_TID; i++) {
3867 if ((chip_scsi_id == i) ||
3868 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3869 continue;
3870 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003871
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003872 AdvReadWordLram(iop_base,
3873 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
3874 lramword);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003875
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003876 len = asc_prt_line(cp, leftlen, " %X:%d",
3877 i, (lramword & 0x8000) ? 16 : 8);
3878 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003879
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003880 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
3881 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3882 len = asc_prt_line(cp, leftlen, "*");
3883 ASC_PRT_NEXT();
3884 renegotiate = 1;
3885 }
3886 }
3887 len = asc_prt_line(cp, leftlen, "\n");
3888 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003889
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003890 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
3891 len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
3892 ASC_PRT_NEXT();
3893 for (i = 0; i <= ADV_MAX_TID; i++) {
3894 if ((chip_scsi_id == i) ||
3895 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3896 continue;
3897 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003898
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003899 len = asc_prt_line(cp, leftlen, " %X:%c",
3900 i,
3901 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3902 'N');
3903 ASC_PRT_NEXT();
3904 }
3905 len = asc_prt_line(cp, leftlen, "\n");
3906 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003908 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
3909 for (i = 0; i <= ADV_MAX_TID; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003910
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003911 AdvReadWordLram(iop_base,
3912 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
3913 lramword);
3914 lramword &= ~0x8000;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003915
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003916 if ((chip_scsi_id == i) ||
3917 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
3918 ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
3919 continue;
3920 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003921
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003922 len = asc_prt_line(cp, leftlen, " %X:", i);
3923 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003924
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003925 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
3926 len = asc_prt_line(cp, leftlen, " Asynchronous");
3927 ASC_PRT_NEXT();
3928 } else {
3929 len =
3930 asc_prt_line(cp, leftlen,
3931 " Transfer Period Factor: ");
3932 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07003933
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003934 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
3935 len =
3936 asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
3937 ASC_PRT_NEXT();
3938 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
3939 len =
3940 asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
3941 ASC_PRT_NEXT();
3942 } else { /* 20 Mhz or below. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003943
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003944 period = (((lramword >> 8) * 25) + 50) / 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003945
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003946 if (period == 0) { /* Should never happen. */
3947 len =
3948 asc_prt_line(cp, leftlen,
3949 "%d (? Mhz), ");
3950 ASC_PRT_NEXT();
3951 } else {
3952 len = asc_prt_line(cp, leftlen,
3953 "%d (%d.%d Mhz),",
3954 period, 250 / period,
3955 ASC_TENTHS(250,
3956 period));
3957 ASC_PRT_NEXT();
3958 }
3959 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003960
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003961 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
3962 lramword & 0x1F);
3963 ASC_PRT_NEXT();
3964 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003966 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3967 len = asc_prt_line(cp, leftlen, "*\n");
3968 renegotiate = 1;
3969 } else {
3970 len = asc_prt_line(cp, leftlen, "\n");
3971 }
3972 ASC_PRT_NEXT();
3973 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003974
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003975 if (renegotiate) {
3976 len = asc_prt_line(cp, leftlen,
3977 " * = Re-negotiation pending before next command.\n");
3978 ASC_PRT_NEXT();
3979 }
3980
3981 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003982}
3983
3984/*
3985 * asc_proc_copy()
3986 *
3987 * Copy proc information to a read buffer taking into account the current
3988 * read offset in the file and the remaining space in the read buffer.
3989 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003990static int
Linus Torvalds1da177e2005-04-16 15:20:36 -07003991asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003992 char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003993{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003994 int cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995
Matthew Wilcoxb352f922007-10-02 21:55:33 -04003996 ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n",
Matthew Wilcox27c868c2007-07-26 10:56:23 -04003997 (unsigned)offset, (unsigned)advoffset, cplen);
3998 if (offset <= advoffset) {
3999 /* Read offset below current offset, copy everything. */
4000 cnt = min(cplen, leftlen);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004001 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004002 (ulong)curbuf, (ulong)cp, cnt);
4003 memcpy(curbuf, cp, cnt);
4004 } else if (offset < advoffset + cplen) {
4005 /* Read offset within current range, partial copy. */
4006 cnt = (advoffset + cplen) - offset;
4007 cp = (cp + cplen) - cnt;
4008 cnt = min(cnt, leftlen);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004009 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004010 (ulong)curbuf, (ulong)cp, cnt);
4011 memcpy(curbuf, cp, cnt);
4012 }
4013 return cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004014}
4015
Linus Torvalds1da177e2005-04-16 15:20:36 -07004016#ifdef ADVANSYS_STATS
Linus Torvalds1da177e2005-04-16 15:20:36 -07004017/*
4018 * asc_prt_board_stats()
4019 *
4020 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
4021 * cf. asc_prt_line().
4022 *
4023 * Return the number of characters copied into 'cp'. No more than
4024 * 'cplen' characters will be copied to 'cp'.
4025 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004026static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004027{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04004028 struct asc_board *boardp = shost_priv(shost);
4029 struct asc_stats *s = &boardp->asc_stats;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004030
Matthew Wilcoxd2411492007-10-02 21:55:31 -04004031 int leftlen = cplen;
4032 int len, totlen = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004033
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004034 len = asc_prt_line(cp, leftlen,
4035 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
4036 shost->host_no);
4037 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004038
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004039 len = asc_prt_line(cp, leftlen,
4040 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
4041 s->queuecommand, s->reset, s->biosparam,
4042 s->interrupt);
4043 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004044
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004045 len = asc_prt_line(cp, leftlen,
4046 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
4047 s->callback, s->done, s->build_error,
4048 s->adv_build_noreq, s->adv_build_nosg);
4049 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004050
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004051 len = asc_prt_line(cp, leftlen,
4052 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
4053 s->exe_noerror, s->exe_busy, s->exe_error,
4054 s->exe_unknown);
4055 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004056
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004057 /*
4058 * Display data transfer statistics.
4059 */
4060 if (s->cont_cnt > 0) {
4061 len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
4062 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004063
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004064 len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
4065 s->cont_xfer / 2,
4066 ASC_TENTHS(s->cont_xfer, 2));
4067 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004068
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004069 /* Contiguous transfer average size */
4070 len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
4071 (s->cont_xfer / 2) / s->cont_cnt,
4072 ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
4073 ASC_PRT_NEXT();
4074 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004075
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004076 if (s->sg_cnt > 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004077
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004078 len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
4079 s->sg_cnt, s->sg_elem);
4080 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004081
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004082 len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
4083 s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
4084 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004085
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004086 /* Scatter gather transfer statistics */
4087 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
4088 s->sg_elem / s->sg_cnt,
4089 ASC_TENTHS(s->sg_elem, s->sg_cnt));
4090 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004091
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004092 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
4093 (s->sg_xfer / 2) / s->sg_elem,
4094 ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
4095 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004096
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004097 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
4098 (s->sg_xfer / 2) / s->sg_cnt,
4099 ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
4100 ASC_PRT_NEXT();
4101 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004102
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004103 /*
4104 * Display request queuing statistics.
4105 */
4106 len = asc_prt_line(cp, leftlen,
4107 " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
4108 HZ);
4109 ASC_PRT_NEXT();
Linus Torvalds1da177e2005-04-16 15:20:36 -07004110
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004111 return totlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004112}
Linus Torvalds1da177e2005-04-16 15:20:36 -07004113#endif /* ADVANSYS_STATS */
4114
Linus Torvalds1da177e2005-04-16 15:20:36 -07004115/*
Matthew Wilcox51219352007-10-02 21:55:22 -04004116 * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
4117 *
4118 * *buffer: I/O buffer
4119 * **start: if inout == FALSE pointer into buffer where user read should start
4120 * offset: current offset into a /proc/scsi/advansys/[0...] file
4121 * length: length of buffer
4122 * hostno: Scsi_Host host_no
4123 * inout: TRUE - user is writing; FALSE - user is reading
4124 *
4125 * Return the number of bytes read from or written to a
4126 * /proc/scsi/advansys/[0...] file.
4127 *
4128 * Note: This function uses the per board buffer 'prtbuf' which is
4129 * allocated when the board is initialized in advansys_detect(). The
4130 * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
4131 * used to write to the buffer. The way asc_proc_copy() is written
4132 * if 'prtbuf' is too small it will not be overwritten. Instead the
4133 * user just won't get all the available statistics.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004134 */
Matthew Wilcox51219352007-10-02 21:55:22 -04004135static int
4136advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
4137 off_t offset, int length, int inout)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04004139 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox51219352007-10-02 21:55:22 -04004140 char *cp;
4141 int cplen;
4142 int cnt;
4143 int totcnt;
4144 int leftlen;
4145 char *curbuf;
4146 off_t advoffset;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004147
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004148 ASC_DBG(1, "begin\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07004149
Matthew Wilcox51219352007-10-02 21:55:22 -04004150 /*
4151 * User write not supported.
4152 */
Matthew Wilcoxd2411492007-10-02 21:55:31 -04004153 if (inout == TRUE)
4154 return -ENOSYS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004155
Matthew Wilcox51219352007-10-02 21:55:22 -04004156 /*
4157 * User read of /proc/scsi/advansys/[0...] file.
4158 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004159
Matthew Wilcox51219352007-10-02 21:55:22 -04004160 /* Copy read data starting at the beginning of the buffer. */
4161 *start = buffer;
4162 curbuf = buffer;
4163 advoffset = 0;
4164 totcnt = 0;
4165 leftlen = length;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004166
Matthew Wilcox51219352007-10-02 21:55:22 -04004167 /*
4168 * Get board configuration information.
4169 *
4170 * advansys_info() returns the board string from its own static buffer.
4171 */
4172 cp = (char *)advansys_info(shost);
4173 strcat(cp, "\n");
4174 cplen = strlen(cp);
4175 /* Copy board information. */
4176 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4177 totcnt += cnt;
4178 leftlen -= cnt;
4179 if (leftlen == 0) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004180 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004181 return totcnt;
4182 }
4183 advoffset += cplen;
4184 curbuf += cnt;
4185
4186 /*
4187 * Display Wide Board BIOS Information.
4188 */
Matthew Wilcox9a256fa2007-10-02 21:55:28 -04004189 if (!ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox51219352007-10-02 21:55:22 -04004190 cp = boardp->prtbuf;
4191 cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
4192 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4193 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4194 cplen);
4195 totcnt += cnt;
4196 leftlen -= cnt;
4197 if (leftlen == 0) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004198 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004199 return totcnt;
4200 }
4201 advoffset += cplen;
4202 curbuf += cnt;
4203 }
4204
4205 /*
4206 * Display driver information for each device attached to the board.
4207 */
4208 cp = boardp->prtbuf;
4209 cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
4210 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4211 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4212 totcnt += cnt;
4213 leftlen -= cnt;
4214 if (leftlen == 0) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004215 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004216 return totcnt;
4217 }
4218 advoffset += cplen;
4219 curbuf += cnt;
4220
4221 /*
4222 * Display EEPROM configuration for the board.
4223 */
4224 cp = boardp->prtbuf;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004225 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox51219352007-10-02 21:55:22 -04004226 cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004227 } else {
Matthew Wilcox51219352007-10-02 21:55:22 -04004228 cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004229 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004230 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4231 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4232 totcnt += cnt;
4233 leftlen -= cnt;
4234 if (leftlen == 0) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004235 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004236 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004237 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004238 advoffset += cplen;
4239 curbuf += cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004240
Matthew Wilcox51219352007-10-02 21:55:22 -04004241 /*
4242 * Display driver configuration and information for the board.
4243 */
4244 cp = boardp->prtbuf;
4245 cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
4246 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4247 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4248 totcnt += cnt;
4249 leftlen -= cnt;
4250 if (leftlen == 0) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004251 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004252 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004253 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004254 advoffset += cplen;
4255 curbuf += cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004256
Matthew Wilcox51219352007-10-02 21:55:22 -04004257#ifdef ADVANSYS_STATS
4258 /*
4259 * Display driver statistics for the board.
4260 */
4261 cp = boardp->prtbuf;
4262 cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
4263 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4264 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4265 totcnt += cnt;
4266 leftlen -= cnt;
4267 if (leftlen == 0) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004268 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004269 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004270 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004271 advoffset += cplen;
4272 curbuf += cnt;
4273#endif /* ADVANSYS_STATS */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004274
Matthew Wilcox51219352007-10-02 21:55:22 -04004275 /*
4276 * Display Asc Library dynamic configuration information
4277 * for the board.
4278 */
4279 cp = boardp->prtbuf;
4280 if (ASC_NARROW_BOARD(boardp)) {
4281 cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
4282 } else {
4283 cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004284 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004285 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4286 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4287 totcnt += cnt;
4288 leftlen -= cnt;
4289 if (leftlen == 0) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004290 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004291 return totcnt;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004292 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004293 advoffset += cplen;
4294 curbuf += cnt;
4295
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004296 ASC_DBG(1, "totcnt %d\n", totcnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04004297
4298 return totcnt;
4299}
4300#endif /* CONFIG_PROC_FS */
4301
4302static void asc_scsi_done(struct scsi_cmnd *scp)
4303{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04004304 struct asc_board *boardp = shost_priv(scp->device->host);
Matthew Wilcox51219352007-10-02 21:55:22 -04004305
4306 if (scp->use_sg)
4307 dma_unmap_sg(boardp->dev,
4308 (struct scatterlist *)scp->request_buffer,
4309 scp->use_sg, scp->sc_data_direction);
4310 else if (scp->request_bufflen)
4311 dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
4312 scp->request_bufflen, scp->sc_data_direction);
4313
4314 ASC_STATS(scp->device->host, done);
4315
4316 scp->scsi_done(scp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004317}
4318
Matthew Wilcox51219352007-10-02 21:55:22 -04004319static void AscSetBank(PortAddr iop_base, uchar bank)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004320{
Matthew Wilcox51219352007-10-02 21:55:22 -04004321 uchar val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004322
Matthew Wilcox51219352007-10-02 21:55:22 -04004323 val = AscGetChipControl(iop_base) &
4324 (~
4325 (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
4326 CC_CHIP_RESET));
4327 if (bank == 1) {
4328 val |= CC_BANK_ONE;
4329 } else if (bank == 2) {
4330 val |= CC_DIAG | CC_BANK_ONE;
4331 } else {
4332 val &= ~CC_BANK_ONE;
4333 }
4334 AscSetChipControl(iop_base, val);
Matthew Wilcox51219352007-10-02 21:55:22 -04004335}
4336
4337static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
4338{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004339 AscSetBank(iop_base, 1);
Matthew Wilcox51219352007-10-02 21:55:22 -04004340 AscWriteChipIH(iop_base, ins_code);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004341 AscSetBank(iop_base, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004342}
4343
Matthew Wilcox51219352007-10-02 21:55:22 -04004344static int AscStartChip(PortAddr iop_base)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004345{
Matthew Wilcox51219352007-10-02 21:55:22 -04004346 AscSetChipControl(iop_base, 0);
4347 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
4348 return (0);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004349 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004350 return (1);
4351}
4352
4353static int AscStopChip(PortAddr iop_base)
4354{
4355 uchar cc_val;
4356
4357 cc_val =
4358 AscGetChipControl(iop_base) &
4359 (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
4360 AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
4361 AscSetChipIH(iop_base, INS_HALT);
4362 AscSetChipIH(iop_base, INS_RFLAG_WTM);
4363 if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
4364 return (0);
4365 }
4366 return (1);
4367}
4368
4369static int AscIsChipHalted(PortAddr iop_base)
4370{
4371 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
4372 if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
4373 return (1);
4374 }
4375 }
4376 return (0);
4377}
4378
4379static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
4380{
4381 PortAddr iop_base;
4382 int i = 10;
4383
4384 iop_base = asc_dvc->iop_base;
4385 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
4386 && (i-- > 0)) {
4387 mdelay(100);
4388 }
4389 AscStopChip(iop_base);
4390 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
4391 udelay(60);
4392 AscSetChipIH(iop_base, INS_RFLAG_WTM);
4393 AscSetChipIH(iop_base, INS_HALT);
4394 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
4395 AscSetChipControl(iop_base, CC_HALT);
4396 mdelay(200);
4397 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
4398 AscSetChipStatus(iop_base, 0);
4399 return (AscIsChipHalted(iop_base));
4400}
4401
4402static int AscFindSignature(PortAddr iop_base)
4403{
4404 ushort sig_word;
4405
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004406 ASC_DBG(1, "AscGetChipSignatureByte(0x%x) 0x%x\n",
Matthew Wilcox51219352007-10-02 21:55:22 -04004407 iop_base, AscGetChipSignatureByte(iop_base));
4408 if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004409 ASC_DBG(1, "AscGetChipSignatureWord(0x%x) 0x%x\n",
Matthew Wilcox51219352007-10-02 21:55:22 -04004410 iop_base, AscGetChipSignatureWord(iop_base));
4411 sig_word = AscGetChipSignatureWord(iop_base);
4412 if ((sig_word == (ushort)ASC_1000_ID0W) ||
4413 (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
4414 return (1);
4415 }
4416 }
4417 return (0);
4418}
4419
4420static void AscEnableInterrupt(PortAddr iop_base)
4421{
4422 ushort cfg;
4423
4424 cfg = AscGetChipCfgLsw(iop_base);
4425 AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
Matthew Wilcox51219352007-10-02 21:55:22 -04004426}
4427
4428static void AscDisableInterrupt(PortAddr iop_base)
4429{
4430 ushort cfg;
4431
4432 cfg = AscGetChipCfgLsw(iop_base);
4433 AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
Matthew Wilcox51219352007-10-02 21:55:22 -04004434}
4435
4436static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
4437{
4438 unsigned char byte_data;
4439 unsigned short word_data;
4440
4441 if (isodd_word(addr)) {
4442 AscSetChipLramAddr(iop_base, addr - 1);
4443 word_data = AscGetChipLramData(iop_base);
4444 byte_data = (word_data >> 8) & 0xFF;
4445 } else {
4446 AscSetChipLramAddr(iop_base, addr);
4447 word_data = AscGetChipLramData(iop_base);
4448 byte_data = word_data & 0xFF;
4449 }
4450 return byte_data;
4451}
4452
4453static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
4454{
4455 ushort word_data;
4456
4457 AscSetChipLramAddr(iop_base, addr);
4458 word_data = AscGetChipLramData(iop_base);
4459 return (word_data);
4460}
4461
4462#if CC_VERY_LONG_SG_LIST
4463static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
4464{
4465 ushort val_low, val_high;
4466 ASC_DCNT dword_data;
4467
4468 AscSetChipLramAddr(iop_base, addr);
4469 val_low = AscGetChipLramData(iop_base);
4470 val_high = AscGetChipLramData(iop_base);
4471 dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
4472 return (dword_data);
4473}
4474#endif /* CC_VERY_LONG_SG_LIST */
4475
4476static void
4477AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
4478{
4479 int i;
4480
4481 AscSetChipLramAddr(iop_base, s_addr);
4482 for (i = 0; i < words; i++) {
4483 AscSetChipLramData(iop_base, set_wval);
4484 }
4485}
4486
4487static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
4488{
4489 AscSetChipLramAddr(iop_base, addr);
4490 AscSetChipLramData(iop_base, word_val);
Matthew Wilcox51219352007-10-02 21:55:22 -04004491}
4492
4493static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
4494{
4495 ushort word_data;
4496
4497 if (isodd_word(addr)) {
4498 addr--;
4499 word_data = AscReadLramWord(iop_base, addr);
4500 word_data &= 0x00FF;
4501 word_data |= (((ushort)byte_val << 8) & 0xFF00);
4502 } else {
4503 word_data = AscReadLramWord(iop_base, addr);
4504 word_data &= 0xFF00;
4505 word_data |= ((ushort)byte_val & 0x00FF);
4506 }
4507 AscWriteLramWord(iop_base, addr, word_data);
Matthew Wilcox51219352007-10-02 21:55:22 -04004508}
4509
4510/*
4511 * Copy 2 bytes to LRAM.
4512 *
4513 * The source data is assumed to be in little-endian order in memory
4514 * and is maintained in little-endian order when written to LRAM.
4515 */
4516static void
4517AscMemWordCopyPtrToLram(PortAddr iop_base,
4518 ushort s_addr, uchar *s_buffer, int words)
4519{
4520 int i;
4521
4522 AscSetChipLramAddr(iop_base, s_addr);
4523 for (i = 0; i < 2 * words; i += 2) {
4524 /*
4525 * On a little-endian system the second argument below
4526 * produces a little-endian ushort which is written to
4527 * LRAM in little-endian order. On a big-endian system
4528 * the second argument produces a big-endian ushort which
4529 * is "transparently" byte-swapped by outpw() and written
4530 * in little-endian order to LRAM.
4531 */
4532 outpw(iop_base + IOP_RAM_DATA,
4533 ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
4534 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004535}
4536
4537/*
4538 * Copy 4 bytes to LRAM.
4539 *
4540 * The source data is assumed to be in little-endian order in memory
4541 * and is maintained in little-endian order when writen to LRAM.
4542 */
4543static void
4544AscMemDWordCopyPtrToLram(PortAddr iop_base,
4545 ushort s_addr, uchar *s_buffer, int dwords)
4546{
4547 int i;
4548
4549 AscSetChipLramAddr(iop_base, s_addr);
4550 for (i = 0; i < 4 * dwords; i += 4) {
4551 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
4552 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
4553 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004554}
4555
4556/*
4557 * Copy 2 bytes from LRAM.
4558 *
4559 * The source data is assumed to be in little-endian order in LRAM
4560 * and is maintained in little-endian order when written to memory.
4561 */
4562static void
4563AscMemWordCopyPtrFromLram(PortAddr iop_base,
4564 ushort s_addr, uchar *d_buffer, int words)
4565{
4566 int i;
4567 ushort word;
4568
4569 AscSetChipLramAddr(iop_base, s_addr);
4570 for (i = 0; i < 2 * words; i += 2) {
4571 word = inpw(iop_base + IOP_RAM_DATA);
4572 d_buffer[i] = word & 0xff;
4573 d_buffer[i + 1] = (word >> 8) & 0xff;
4574 }
Matthew Wilcox51219352007-10-02 21:55:22 -04004575}
4576
4577static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
4578{
4579 ASC_DCNT sum;
4580 int i;
4581
4582 sum = 0L;
4583 for (i = 0; i < words; i++, s_addr += 2) {
4584 sum += AscReadLramWord(iop_base, s_addr);
4585 }
4586 return (sum);
4587}
4588
4589static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
4590{
4591 uchar i;
4592 ushort s_addr;
4593 PortAddr iop_base;
4594 ushort warn_code;
4595
4596 iop_base = asc_dvc->iop_base;
4597 warn_code = 0;
4598 AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
4599 (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
4600 64) >> 1));
4601 i = ASC_MIN_ACTIVE_QNO;
4602 s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
4603 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4604 (uchar)(i + 1));
4605 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4606 (uchar)(asc_dvc->max_total_qng));
4607 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4608 (uchar)i);
4609 i++;
4610 s_addr += ASC_QBLK_SIZE;
4611 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
4612 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4613 (uchar)(i + 1));
4614 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4615 (uchar)(i - 1));
4616 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4617 (uchar)i);
4618 }
4619 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
4620 (uchar)ASC_QLINK_END);
4621 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
4622 (uchar)(asc_dvc->max_total_qng - 1));
4623 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
4624 (uchar)asc_dvc->max_total_qng);
4625 i++;
4626 s_addr += ASC_QBLK_SIZE;
4627 for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
4628 i++, s_addr += ASC_QBLK_SIZE) {
4629 AscWriteLramByte(iop_base,
4630 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
4631 AscWriteLramByte(iop_base,
4632 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
4633 AscWriteLramByte(iop_base,
4634 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
4635 }
4636 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004637}
4638
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004639static ASC_DCNT
4640AscLoadMicroCode(PortAddr iop_base,
4641 ushort s_addr, uchar *mcode_buf, ushort mcode_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004642{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004643 ASC_DCNT chksum;
4644 ushort mcode_word_size;
4645 ushort mcode_chksum;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004646
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004647 /* Write the microcode buffer starting at LRAM address 0. */
4648 mcode_word_size = (ushort)(mcode_size >> 1);
4649 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
4650 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004651
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004652 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004653 ASC_DBG(1, "chksum 0x%lx\n", (ulong)chksum);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004654 mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
4655 (ushort)ASC_CODE_SEC_BEG,
4656 (ushort)((mcode_size -
4657 s_addr - (ushort)
4658 ASC_CODE_SEC_BEG) /
4659 2));
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004660 ASC_DBG(1, "mcode_chksum 0x%lx\n", (ulong)mcode_chksum);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004661 AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
4662 AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04004663 return chksum;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004664}
4665
Linus Torvalds1da177e2005-04-16 15:20:36 -07004666/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004667static uchar _asc_mcode_buf[] = {
4668 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004669 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004670 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004671 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004672 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4673 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
4674 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4675 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004676 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004677 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
4678 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
4679 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004680 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004681 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
4682 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
4683 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004684 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004685 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
4686 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
4687 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004688 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004689 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
4690 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
4691 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004692 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004693 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
4694 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
4695 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004696 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004697 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
4698 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
4699 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004700 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004701 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
4702 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
4703 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004704 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004705 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
4706 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
4707 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004708 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004709 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
4710 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
4711 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004712 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004713 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
4714 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
4715 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004716 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004717 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
4718 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
4719 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004720 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004721 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
4722 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
4723 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004724 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004725 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
4726 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
4727 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004728 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004729 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
4730 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
4731 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004732 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004733 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
4734 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
4735 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004736 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004737 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
4738 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
4739 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004740 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004741 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
4742 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
4743 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004744 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004745 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
4746 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
4747 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004748 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004749 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
4750 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
4751 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004752 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004753 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
4754 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
4755 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004756 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004757 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
4758 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
4759 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004760 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004761 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
4762 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
4763 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004764 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004765 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
4766 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
4767 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004768 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004769 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
4770 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
4771 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004772 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004773 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
4774 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
4775 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004776 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004777 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
4778 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
4779 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004780 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004781 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
4782 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
4783 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004784 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004785 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
4786 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
4787 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004788 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004789 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
4790 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
4791 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004792 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004793 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
4794 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
4795 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004796 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004797 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
4798 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
4799 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004800 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004801 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
4802 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
4803 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004804 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004805 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
4806 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
4807 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004808 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004809 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
4810 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
4811 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004812 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004813 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
4814 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
4815 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004816 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004817 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
4818 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
4819 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004820 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004821 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
4822 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
4823 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004824 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004825 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
4826 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
4827 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004828 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004829 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
4830 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
4831 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004832 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004833 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
4834 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
4835 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004836 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004837 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
4838 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
4839 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004840 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004841 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
4842 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
4843 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004844 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004845 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
4846 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
4847 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004848 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004849 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
4850 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
4851 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004852 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004853 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
4854 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
4855 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004856 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004857 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
4858 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
4859 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004860};
4861
Matthew Wilcox51219352007-10-02 21:55:22 -04004862static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004863static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004864
Linus Torvalds1da177e2005-04-16 15:20:36 -07004865/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004866static unsigned char _adv_asc3550_buf[] = {
4867 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004868 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
4869 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
4870 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004871 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004872 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
4873 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
4874 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004875 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004876 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
4877 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
4878 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004879 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004880 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
4881 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
4882 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004883 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004884 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
4885 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
4886 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004887 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004888 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
4889 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
4890 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004891 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004892 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
4893 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
4894 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004895 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004896 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
4897 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
4898 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004899 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004900 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
4901 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
4902 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004903 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004904 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
4905 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
4906 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004907 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004908 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
4909 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
4910 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004911 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004912 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
4913 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
4914 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004915 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004916 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
4917 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
4918 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004919 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004920 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
4921 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
4922 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004923 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004924 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
4925 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
4926 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004927 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004928 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
4929 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
4930 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004931 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004932 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
4933 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
4934 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004935 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004936 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
4937 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
4938 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004939 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004940 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
4941 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
4942 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004943 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004944 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
4945 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
4946 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004947 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004948 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
4949 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
4950 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004951 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004952 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
4953 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
4954 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004955 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004956 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
4957 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
4958 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004959 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004960 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
4961 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
4962 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004963 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004964 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
4965 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
4966 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004967 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004968 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
4969 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
4970 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004971 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004972 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
4973 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
4974 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004975 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004976 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
4977 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
4978 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004979 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004980 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
4981 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
4982 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004983 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004984 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
4985 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
4986 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004987 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004988 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
4989 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
4990 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004991 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004992 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
4993 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
4994 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004995 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06004996 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
4997 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
4998 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04004999 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005000 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
5001 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
5002 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005003 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005004 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
5005 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
5006 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005007 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005008 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
5009 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
5010 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005011 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005012 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
5013 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
5014 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005015 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005016 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
5017 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
5018 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005019 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005020 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
5021 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
5022 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005023 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005024 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
5025 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
5026 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005027 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005028 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
5029 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
5030 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005031 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005032 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
5033 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
5034 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005035 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005036 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
5037 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
5038 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005039 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005040 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
5041 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
5042 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005043 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005044 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
5045 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
5046 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005047 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005048 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
5049 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
5050 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005051 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005052 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
5053 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
5054 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005055 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005056 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
5057 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
5058 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005059 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005060 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
5061 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
5062 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005063 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005064 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
5065 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
5066 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005067 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005068 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
5069 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
5070 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005071 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005072 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
5073 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
5074 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005075 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005076 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
5077 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
5078 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005079 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005080 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
5081 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
5082 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005083 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005084 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
5085 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
5086 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005087 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005088 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
5089 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
5090 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005091 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005092 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
5093 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
5094 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005095 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005096 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
5097 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
5098 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005099 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005100 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
5101 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
5102 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005103 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005104 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
5105 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
5106 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005107 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005108 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
5109 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
5110 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005111 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005112 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
5113 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
5114 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005115 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005116 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
5117 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
5118 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005119 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005120 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
5121 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
5122 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005123 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005124 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
5125 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
5126 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005127 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005128 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
5129 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
5130 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005131 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005132 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
5133 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
5134 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005135 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005136 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
5137 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
5138 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005139 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005140 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
5141 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
5142 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005143 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005144 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
5145 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
5146 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005147 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005148 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
5149 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
5150 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005151 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005152 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
5153 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
5154 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005155 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005156 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
5157 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
5158 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005159 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005160 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
5161 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
5162 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005163 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005164 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
5165 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
5166 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005167 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005168 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
5169 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
5170 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005171 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005172 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
5173 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
5174 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005175 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005176 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
5177 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
5178 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005179 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005180 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
5181 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
5182 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005183 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005184 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
5185 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
5186 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005187 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005188 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
5189 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
5190 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005191 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005192 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
5193 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
5194 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005195 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005196 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
5197 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
5198 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005199 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005200 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
5201 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
5202 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005203 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005204 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
5205 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
5206 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005207 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005208 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
5209 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
5210 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005211 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005212 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
5213 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
5214 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005215 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005216 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
5217 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
5218 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005219 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005220 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
5221 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
5222 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005223 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005224 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
5225 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
5226 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005227 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005228 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
5229 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
5230 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005231 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005232 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
5233 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
5234 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005235 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005236 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
5237 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
5238 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005239 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005240 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
5241 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
5242 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005243 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005244 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
5245 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
5246 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005247 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005248 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
5249 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
5250 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005251 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005252 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
5253 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
5254 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005255 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005256 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
5257 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
5258 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005259 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005260 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
5261 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
5262 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005263 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005264 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
5265 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
5266 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005267 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005268 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
5269 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
5270 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005271 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005272 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
5273 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
5274 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005275 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005276 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
5277 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
5278 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005279 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005280 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
5281 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
5282 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005283 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005284 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
5285 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07005286};
5287
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005288static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
5289static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005290
5291/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005292static unsigned char _adv_asc38C0800_buf[] = {
5293 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005294 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
5295 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
5296 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005297 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005298 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
5299 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
5300 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005301 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005302 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
5303 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
5304 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005305 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005306 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
5307 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
5308 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005309 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005310 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
5311 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
5312 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005313 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005314 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
5315 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
5316 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005317 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005318 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
5319 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
5320 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005321 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005322 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
5323 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
5324 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005325 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005326 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
5327 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
5328 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005329 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005330 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
5331 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
5332 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005333 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005334 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
5335 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
5336 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005337 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005338 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
5339 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
5340 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005341 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005342 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
5343 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
5344 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005345 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005346 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
5347 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
5348 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005349 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005350 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
5351 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
5352 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005353 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005354 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
5355 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
5356 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005357 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005358 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
5359 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
5360 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005361 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005362 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
5363 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
5364 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005365 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005366 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
5367 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
5368 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005369 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005370 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
5371 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
5372 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005373 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005374 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
5375 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
5376 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005377 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005378 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
5379 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
5380 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005381 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005382 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
5383 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
5384 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005385 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005386 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
5387 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
5388 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005389 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005390 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
5391 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
5392 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005393 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005394 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
5395 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
5396 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005397 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005398 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
5399 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
5400 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005401 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005402 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
5403 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
5404 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005405 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005406 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
5407 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
5408 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005409 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005410 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
5411 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
5412 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005413 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005414 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
5415 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
5416 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005417 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005418 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
5419 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
5420 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005421 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005422 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
5423 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
5424 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005425 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005426 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
5427 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
5428 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005429 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005430 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
5431 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
5432 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005433 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005434 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
5435 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
5436 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005437 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005438 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
5439 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
5440 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005441 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005442 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
5443 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
5444 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005445 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005446 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
5447 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
5448 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005449 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005450 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
5451 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
5452 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005453 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005454 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
5455 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
5456 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005457 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005458 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
5459 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
5460 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005461 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005462 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
5463 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
5464 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005465 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005466 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
5467 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
5468 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005469 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005470 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
5471 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
5472 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005473 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005474 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
5475 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
5476 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005477 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005478 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
5479 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
5480 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005481 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005482 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
5483 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
5484 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005485 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005486 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
5487 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
5488 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005489 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005490 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
5491 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
5492 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005493 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005494 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
5495 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
5496 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005497 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005498 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
5499 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
5500 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005501 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005502 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
5503 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
5504 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005505 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005506 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
5507 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
5508 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005509 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005510 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
5511 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
5512 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005513 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005514 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
5515 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
5516 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005517 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005518 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
5519 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
5520 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005521 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005522 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
5523 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
5524 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005525 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005526 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
5527 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
5528 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005529 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005530 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
5531 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
5532 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005533 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005534 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
5535 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
5536 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005537 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005538 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
5539 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
5540 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005541 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005542 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
5543 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
5544 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005545 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005546 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
5547 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
5548 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005549 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005550 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
5551 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
5552 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005553 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005554 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
5555 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
5556 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005557 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005558 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
5559 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
5560 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005561 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005562 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
5563 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
5564 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005565 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005566 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
5567 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
5568 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005569 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005570 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
5571 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
5572 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005573 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005574 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
5575 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
5576 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005577 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005578 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
5579 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
5580 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005581 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005582 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
5583 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
5584 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005585 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005586 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
5587 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
5588 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005589 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005590 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
5591 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
5592 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005593 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005594 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
5595 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
5596 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005597 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005598 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
5599 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
5600 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005601 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005602 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
5603 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
5604 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005605 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005606 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
5607 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
5608 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005609 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005610 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
5611 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
5612 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005613 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005614 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
5615 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
5616 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005617 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005618 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
5619 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
5620 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005621 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005622 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
5623 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
5624 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005625 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005626 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
5627 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
5628 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005629 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005630 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
5631 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
5632 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005633 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005634 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
5635 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
5636 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005637 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005638 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
5639 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
5640 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005641 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005642 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
5643 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
5644 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005645 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005646 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
5647 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
5648 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005649 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005650 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
5651 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
5652 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005653 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005654 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
5655 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
5656 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005657 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005658 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
5659 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
5660 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005661 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005662 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
5663 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
5664 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005665 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005666 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
5667 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
5668 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005669 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005670 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
5671 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
5672 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005673 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005674 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
5675 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
5676 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005677 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005678 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
5679 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
5680 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005681 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005682 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
5683 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
5684 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005685 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005686 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
5687 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
5688 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005689 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005690 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
5691 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
5692 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005693 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005694 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
5695 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
5696 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005697 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005698 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
5699 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
5700 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005701 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005702 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
5703 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
5704 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005705 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005706 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
5707 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
5708 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005709 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005710 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
5711 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
5712 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005713 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005714 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
5715 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
5716 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005717 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005718 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
5719 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
5720 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005721 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005722 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
5723 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
5724 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005725 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005726 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
5727 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
5728 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005729 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005730 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
5731 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
5732 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005733 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005734 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
5735 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
5736 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005737 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07005738};
5739
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005740static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
5741static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005742
5743/* Microcode buffer is kept after initialization for error recovery. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005744static unsigned char _adv_asc38C1600_buf[] = {
5745 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005746 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
5747 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
5748 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005749 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005750 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
5751 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
5752 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005753 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005754 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
5755 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
5756 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005757 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005758 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
5759 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
5760 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005761 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005762 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
5763 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
5764 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005765 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005766 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
5767 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
5768 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005769 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005770 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
5771 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
5772 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005773 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005774 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
5775 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
5776 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005777 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005778 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
5779 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
5780 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005781 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005782 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
5783 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
5784 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005785 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005786 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
5787 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
5788 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005789 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005790 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
5791 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
5792 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005793 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005794 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
5795 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
5796 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005797 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005798 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
5799 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
5800 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005801 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005802 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
5803 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
5804 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005805 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005806 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
5807 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
5808 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005809 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005810 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
5811 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
5812 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005813 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005814 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
5815 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
5816 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005817 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005818 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
5819 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
5820 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005821 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005822 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
5823 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
5824 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005825 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005826 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
5827 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
5828 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005829 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005830 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
5831 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
5832 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005833 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005834 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
5835 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
5836 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005837 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005838 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
5839 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
5840 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005841 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005842 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
5843 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
5844 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005845 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005846 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
5847 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
5848 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005849 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005850 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
5851 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
5852 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005853 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005854 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
5855 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
5856 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005857 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005858 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
5859 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
5860 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005861 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005862 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
5863 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
5864 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005865 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005866 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
5867 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
5868 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005869 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005870 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
5871 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
5872 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005873 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005874 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
5875 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
5876 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005877 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005878 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
5879 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
5880 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005881 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005882 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
5883 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
5884 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005885 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005886 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
5887 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
5888 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005889 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005890 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
5891 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
5892 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005893 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005894 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
5895 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
5896 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005897 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005898 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
5899 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
5900 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005901 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005902 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
5903 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
5904 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005905 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005906 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
5907 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
5908 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005909 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005910 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
5911 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
5912 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005913 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005914 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
5915 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
5916 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005917 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005918 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
5919 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
5920 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005921 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005922 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
5923 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
5924 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005925 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005926 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
5927 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
5928 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005929 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005930 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
5931 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
5932 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005933 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005934 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
5935 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
5936 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005937 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005938 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
5939 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
5940 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005941 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005942 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
5943 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
5944 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005945 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005946 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
5947 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
5948 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005949 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005950 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
5951 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
5952 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005953 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005954 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
5955 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
5956 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005957 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005958 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
5959 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
5960 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005961 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005962 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
5963 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
5964 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005965 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005966 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
5967 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
5968 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005969 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005970 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
5971 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
5972 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005973 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005974 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
5975 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
5976 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005977 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005978 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
5979 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
5980 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005981 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005982 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
5983 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
5984 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005985 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005986 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
5987 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
5988 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005989 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005990 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
5991 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
5992 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005993 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005994 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
5995 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
5996 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04005997 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06005998 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
5999 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
6000 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006001 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006002 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
6003 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
6004 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006005 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006006 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
6007 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
6008 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006009 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006010 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
6011 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
6012 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006013 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006014 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
6015 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
6016 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006017 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006018 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
6019 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
6020 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006021 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006022 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
6023 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
6024 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006025 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006026 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
6027 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
6028 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006029 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006030 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
6031 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
6032 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006033 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006034 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
6035 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
6036 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006037 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006038 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
6039 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
6040 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006041 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006042 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
6043 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
6044 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006045 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006046 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
6047 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
6048 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006049 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006050 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
6051 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
6052 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006053 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006054 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
6055 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
6056 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006057 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006058 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
6059 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
6060 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006061 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006062 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
6063 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
6064 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006065 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006066 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
6067 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
6068 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006069 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006070 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
6071 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
6072 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006073 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006074 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
6075 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
6076 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006077 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006078 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
6079 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
6080 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006081 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006082 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
6083 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
6084 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006085 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006086 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
6087 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
6088 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006089 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006090 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
6091 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
6092 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006093 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006094 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
6095 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
6096 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006097 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006098 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
6099 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
6100 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006101 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006102 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
6103 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
6104 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006105 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006106 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
6107 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
6108 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006109 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006110 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
6111 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
6112 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006113 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006114 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
6115 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
6116 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006117 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006118 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
6119 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
6120 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006121 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006122 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
6123 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
6124 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006125 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006126 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
6127 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
6128 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006129 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006130 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
6131 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
6132 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006133 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006134 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
6135 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
6136 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006137 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006138 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
6139 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
6140 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006141 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006142 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
6143 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
6144 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006145 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006146 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
6147 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
6148 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006149 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006150 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
6151 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
6152 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006153 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006154 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
6155 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
6156 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006157 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006158 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
6159 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
6160 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006161 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006162 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
6163 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
6164 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006165 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006166 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
6167 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
6168 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006169 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006170 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
6171 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
6172 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006173 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006174 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
6175 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
6176 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006177 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006178 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
6179 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
6180 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006181 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006182 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
6183 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
6184 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006185 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006186 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
6187 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
6188 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006189 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006190 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
6191 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
6192 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006193 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006194 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
6195 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
6196 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006197 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006198 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
6199 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
6200 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006201 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006202 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
6203 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
6204 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006205 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006206 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
6207 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
6208 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006209 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006210 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
6211 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
6212 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006213 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006214 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
6215 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
6216 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006217 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006218 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
6219 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
6220 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006221 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006222 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
6223 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
6224 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006225 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006226 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
6227 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
6228 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006229 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006230 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
6231 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
6232 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006233 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006234 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
6235 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
6236 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006237 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006238 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
6239 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
6240 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006241 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006242 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
6243 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
6244 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006245 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006246 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
6247 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
6248 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006249 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006250 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
6251 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
6252 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006253 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006254 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
6255 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
6256 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006257 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006258 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
6259 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
6260 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006261 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006262 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
6263 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
6264 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006265 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006266 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
6267 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
6268 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006269 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
Matthew Wilcox629d6882007-09-09 08:56:29 -06006270 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
6271 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
6272 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07006273};
6274
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006275static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
6276static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006277
Matthew Wilcox51219352007-10-02 21:55:22 -04006278static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07006279{
Matthew Wilcox51219352007-10-02 21:55:22 -04006280 PortAddr iop_base;
6281 int i;
6282 ushort lram_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006283
Matthew Wilcox51219352007-10-02 21:55:22 -04006284 iop_base = asc_dvc->iop_base;
6285 AscPutRiscVarFreeQHead(iop_base, 1);
6286 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
6287 AscPutVarFreeQHead(iop_base, 1);
6288 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
6289 AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
6290 (uchar)((int)asc_dvc->max_total_qng + 1));
6291 AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
6292 (uchar)((int)asc_dvc->max_total_qng + 2));
6293 AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
6294 asc_dvc->max_total_qng);
6295 AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
6296 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
6297 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
6298 AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
6299 AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
6300 AscPutQDoneInProgress(iop_base, 0);
6301 lram_addr = ASC_QADR_BEG;
6302 for (i = 0; i < 32; i++, lram_addr += 2) {
6303 AscWriteLramWord(iop_base, lram_addr, 0);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006304 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006305}
6306
Matthew Wilcox51219352007-10-02 21:55:22 -04006307static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006308{
Matthew Wilcox51219352007-10-02 21:55:22 -04006309 int i;
6310 ushort warn_code;
6311 PortAddr iop_base;
6312 ASC_PADDR phy_addr;
6313 ASC_DCNT phy_size;
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006314
Matthew Wilcox51219352007-10-02 21:55:22 -04006315 iop_base = asc_dvc->iop_base;
6316 warn_code = 0;
6317 for (i = 0; i <= ASC_MAX_TID; i++) {
6318 AscPutMCodeInitSDTRAtID(iop_base, i,
6319 asc_dvc->cfg->sdtr_period_offset[i]);
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006320 }
6321
Matthew Wilcox51219352007-10-02 21:55:22 -04006322 AscInitQLinkVar(asc_dvc);
6323 AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
6324 asc_dvc->cfg->disc_enable);
6325 AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
6326 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006327
Matthew Wilcox51219352007-10-02 21:55:22 -04006328 /* Align overrun buffer on an 8 byte boundary. */
6329 phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
6330 phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
6331 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
6332 (uchar *)&phy_addr, 1);
6333 phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
6334 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
6335 (uchar *)&phy_size, 1);
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006336
Matthew Wilcox51219352007-10-02 21:55:22 -04006337 asc_dvc->cfg->mcode_date =
6338 AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
6339 asc_dvc->cfg->mcode_version =
6340 AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006341
Matthew Wilcox51219352007-10-02 21:55:22 -04006342 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
6343 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
6344 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
6345 return warn_code;
6346 }
6347 if (AscStartChip(iop_base) != 1) {
6348 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
6349 return warn_code;
6350 }
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006351
Matthew Wilcox51219352007-10-02 21:55:22 -04006352 return warn_code;
6353}
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006354
Matthew Wilcox51219352007-10-02 21:55:22 -04006355static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
6356{
6357 ushort warn_code;
6358 PortAddr iop_base;
6359
6360 iop_base = asc_dvc->iop_base;
6361 warn_code = 0;
6362 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
6363 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
6364 AscResetChipAndScsiBus(asc_dvc);
6365 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
6366 }
6367 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
6368 if (asc_dvc->err_code != 0)
6369 return UW_ERR;
6370 if (!AscFindSignature(asc_dvc->iop_base)) {
6371 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
6372 return warn_code;
6373 }
6374 AscDisableInterrupt(iop_base);
6375 warn_code |= AscInitLram(asc_dvc);
6376 if (asc_dvc->err_code != 0)
6377 return UW_ERR;
Matthew Wilcoxb352f922007-10-02 21:55:33 -04006378 ASC_DBG(1, "_asc_mcode_chksum 0x%lx\n", (ulong)_asc_mcode_chksum);
Matthew Wilcox51219352007-10-02 21:55:22 -04006379 if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
6380 _asc_mcode_size) != _asc_mcode_chksum) {
6381 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
6382 return warn_code;
6383 }
6384 warn_code |= AscInitMicroCodeVar(asc_dvc);
6385 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
6386 AscEnableInterrupt(iop_base);
6387 return warn_code;
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006388}
6389
Linus Torvalds1da177e2005-04-16 15:20:36 -07006390/*
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006391 * Load the Microcode
6392 *
6393 * Write the microcode image to RISC memory starting at address 0.
6394 *
6395 * The microcode is stored compressed in the following format:
6396 *
6397 * 254 word (508 byte) table indexed by byte code followed
6398 * by the following byte codes:
6399 *
6400 * 1-Byte Code:
6401 * 00: Emit word 0 in table.
6402 * 01: Emit word 1 in table.
6403 * .
6404 * FD: Emit word 253 in table.
6405 *
6406 * Multi-Byte Code:
6407 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
6408 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
6409 *
6410 * Returns 0 or an error if the checksum doesn't match
6411 */
6412static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
6413 int memsize, int chksum)
6414{
6415 int i, j, end, len = 0;
6416 ADV_DCNT sum;
6417
6418 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
6419
6420 for (i = 253 * 2; i < size; i++) {
6421 if (buf[i] == 0xff) {
6422 unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
6423 for (j = 0; j < buf[i + 1]; j++) {
6424 AdvWriteWordAutoIncLram(iop_base, word);
6425 len += 2;
6426 }
6427 i += 3;
6428 } else if (buf[i] == 0xfe) {
6429 unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
6430 AdvWriteWordAutoIncLram(iop_base, word);
6431 i += 2;
6432 len += 2;
6433 } else {
6434 unsigned char off = buf[i] * 2;
6435 unsigned short word = (buf[off + 1] << 8) | buf[off];
6436 AdvWriteWordAutoIncLram(iop_base, word);
6437 len += 2;
6438 }
6439 }
6440
6441 end = len;
6442
6443 while (len < memsize) {
6444 AdvWriteWordAutoIncLram(iop_base, 0);
6445 len += 2;
6446 }
6447
6448 /* Verify the microcode checksum. */
6449 sum = 0;
6450 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
6451
6452 for (len = 0; len < end; len += 2) {
6453 sum += AdvReadWordAutoIncLram(iop_base);
6454 }
6455
6456 if (sum != chksum)
6457 return ASC_IERR_MCODE_CHKSUM;
6458
6459 return 0;
6460}
6461
Matthew Wilcox51219352007-10-02 21:55:22 -04006462static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
6463{
6464 ADV_CARR_T *carrp;
6465 ADV_SDCNT buf_size;
6466 ADV_PADDR carr_paddr;
6467
Matthew Wilcox51219352007-10-02 21:55:22 -04006468 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
6469 asc_dvc->carr_freelist = NULL;
6470 if (carrp == asc_dvc->carrier_buf) {
6471 buf_size = ADV_CARRIER_BUFSIZE;
6472 } else {
6473 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
6474 }
6475
6476 do {
6477 /* Get physical address of the carrier 'carrp'. */
Matthew Wilcoxfd625f42007-10-02 21:55:38 -04006478 carr_paddr = cpu_to_le32(virt_to_bus(carrp));
Matthew Wilcox51219352007-10-02 21:55:22 -04006479
6480 buf_size -= sizeof(ADV_CARR_T);
6481
Matthew Wilcox51219352007-10-02 21:55:22 -04006482 carrp->carr_pa = carr_paddr;
6483 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
6484
6485 /*
6486 * Insert the carrier at the beginning of the freelist.
6487 */
6488 carrp->next_vpa =
6489 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
6490 asc_dvc->carr_freelist = carrp;
6491
6492 carrp++;
6493 } while (buf_size > 0);
6494}
6495
6496/*
6497 * Send an idle command to the chip and wait for completion.
6498 *
6499 * Command completion is polled for once per microsecond.
6500 *
6501 * The function can be called from anywhere including an interrupt handler.
6502 * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
6503 * functions to prevent reentrancy.
6504 *
6505 * Return Values:
6506 * ADV_TRUE - command completed successfully
6507 * ADV_FALSE - command failed
6508 * ADV_ERROR - command timed out
6509 */
6510static int
6511AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
6512 ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
6513{
6514 int result;
6515 ADV_DCNT i, j;
6516 AdvPortAddr iop_base;
6517
6518 iop_base = asc_dvc->iop_base;
6519
6520 /*
6521 * Clear the idle command status which is set by the microcode
6522 * to a non-zero value to indicate when the command is completed.
6523 * The non-zero result is one of the IDLE_CMD_STATUS_* values
6524 */
6525 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
6526
6527 /*
6528 * Write the idle command value after the idle command parameter
6529 * has been written to avoid a race condition. If the order is not
6530 * followed, the microcode may process the idle command before the
6531 * parameters have been written to LRAM.
6532 */
6533 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
6534 cpu_to_le32(idle_cmd_parameter));
6535 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
6536
6537 /*
6538 * Tickle the RISC to tell it to process the idle command.
6539 */
6540 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
6541 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
6542 /*
6543 * Clear the tickle value. In the ASC-3550 the RISC flag
6544 * command 'clr_tickle_b' does not work unless the host
6545 * value is cleared.
6546 */
6547 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
6548 }
6549
6550 /* Wait for up to 100 millisecond for the idle command to timeout. */
6551 for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
6552 /* Poll once each microsecond for command completion. */
6553 for (j = 0; j < SCSI_US_PER_MSEC; j++) {
6554 AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
6555 result);
6556 if (result != 0)
6557 return result;
6558 udelay(1);
6559 }
6560 }
6561
6562 BUG(); /* The idle command should never timeout. */
6563 return ADV_ERROR;
6564}
6565
6566/*
6567 * Reset SCSI Bus and purge all outstanding requests.
6568 *
6569 * Return Value:
6570 * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
6571 * ADV_FALSE(0) - Microcode command failed.
6572 * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
6573 * may be hung which requires driver recovery.
6574 */
6575static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
6576{
6577 int status;
6578
6579 /*
6580 * Send the SCSI Bus Reset idle start idle command which asserts
6581 * the SCSI Bus Reset signal.
6582 */
6583 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
6584 if (status != ADV_TRUE) {
6585 return status;
6586 }
6587
6588 /*
6589 * Delay for the specified SCSI Bus Reset hold time.
6590 *
6591 * The hold time delay is done on the host because the RISC has no
6592 * microsecond accurate timer.
6593 */
6594 udelay(ASC_SCSI_RESET_HOLD_TIME_US);
6595
6596 /*
6597 * Send the SCSI Bus Reset end idle command which de-asserts
6598 * the SCSI Bus Reset signal and purges any pending requests.
6599 */
6600 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
6601 if (status != ADV_TRUE) {
6602 return status;
6603 }
6604
6605 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
6606
6607 return status;
6608}
6609
6610/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07006611 * Initialize the ASC-3550.
6612 *
6613 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
6614 *
6615 * For a non-fatal error return a warning code. If there are no warnings
6616 * then 0 is returned.
6617 *
6618 * Needed after initialization for error recovery.
6619 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006620static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07006621{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006622 AdvPortAddr iop_base;
6623 ushort warn_code;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006624 int begin_addr;
6625 int end_addr;
6626 ushort code_sum;
6627 int word;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006628 int i;
6629 ushort scsi_cfg1;
6630 uchar tid;
6631 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
6632 ushort wdtr_able = 0, sdtr_able, tagqng_able;
6633 uchar max_cmd[ADV_MAX_TID + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07006634
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006635 /* If there is already an error, don't continue. */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006636 if (asc_dvc->err_code != 0)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006637 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006638
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006639 /*
6640 * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
6641 */
6642 if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006643 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006644 return ADV_ERROR;
6645 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006646
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006647 warn_code = 0;
6648 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006649
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006650 /*
6651 * Save the RISC memory BIOS region before writing the microcode.
6652 * The BIOS may already be loaded and using its RISC LRAM region
6653 * so its region must be saved and restored.
6654 *
6655 * Note: This code makes the assumption, which is currently true,
6656 * that a chip reset does not clear RISC LRAM.
6657 */
6658 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
6659 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
6660 bios_mem[i]);
6661 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006662
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006663 /*
6664 * Save current per TID negotiated values.
6665 */
6666 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
6667 ushort bios_version, major, minor;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006668
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006669 bios_version =
6670 bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
6671 major = (bios_version >> 12) & 0xF;
6672 minor = (bios_version >> 8) & 0xF;
6673 if (major < 3 || (major == 3 && minor == 1)) {
6674 /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
6675 AdvReadWordLram(iop_base, 0x120, wdtr_able);
6676 } else {
6677 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
6678 }
6679 }
6680 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
6681 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
6682 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
6683 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
6684 max_cmd[tid]);
6685 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006686
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06006687 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
6688 _adv_asc3550_size, ADV_3550_MEMSIZE,
6689 _adv_asc3550_chksum);
6690 if (asc_dvc->err_code)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006691 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006692
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006693 /*
6694 * Restore the RISC memory BIOS region.
6695 */
6696 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
6697 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
6698 bios_mem[i]);
6699 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006700
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006701 /*
6702 * Calculate and write the microcode code checksum to the microcode
6703 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
6704 */
6705 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
6706 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
6707 code_sum = 0;
6708 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
6709 for (word = begin_addr; word < end_addr; word += 2) {
6710 code_sum += AdvReadWordAutoIncLram(iop_base);
6711 }
6712 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006713
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006714 /*
6715 * Read and save microcode version and date.
6716 */
6717 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
6718 asc_dvc->cfg->mcode_date);
6719 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
6720 asc_dvc->cfg->mcode_version);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006721
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006722 /*
6723 * Set the chip type to indicate the ASC3550.
6724 */
6725 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006726
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006727 /*
6728 * If the PCI Configuration Command Register "Parity Error Response
6729 * Control" Bit was clear (0), then set the microcode variable
6730 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
6731 * to ignore DMA parity errors.
6732 */
6733 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
6734 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
6735 word |= CONTROL_FLAG_IGNORE_PERR;
6736 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
6737 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006738
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006739 /*
6740 * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
6741 * threshold of 128 bytes. This register is only accessible to the host.
6742 */
6743 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
6744 START_CTL_EMFU | READ_CMD_MRM);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006745
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006746 /*
6747 * Microcode operating variables for WDTR, SDTR, and command tag
Matthew Wilcox47d853c2007-07-26 11:41:33 -04006748 * queuing will be set in slave_configure() based on what a
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006749 * device reports it is capable of in Inquiry byte 7.
6750 *
6751 * If SCSI Bus Resets have been disabled, then directly set
6752 * SDTR and WDTR from the EEPROM configuration. This will allow
6753 * the BIOS and warm boot to work without a SCSI bus hang on
6754 * the Inquiry caused by host and target mismatched DTR values.
6755 * Without the SCSI Bus Reset, before an Inquiry a device can't
6756 * be assumed to be in Asynchronous, Narrow mode.
6757 */
6758 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
6759 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
6760 asc_dvc->wdtr_able);
6761 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
6762 asc_dvc->sdtr_able);
6763 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006764
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006765 /*
6766 * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
6767 * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
6768 * bitmask. These values determine the maximum SDTR speed negotiated
6769 * with a device.
6770 *
6771 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
6772 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
6773 * without determining here whether the device supports SDTR.
6774 *
6775 * 4-bit speed SDTR speed name
6776 * =========== ===============
6777 * 0000b (0x0) SDTR disabled
6778 * 0001b (0x1) 5 Mhz
6779 * 0010b (0x2) 10 Mhz
6780 * 0011b (0x3) 20 Mhz (Ultra)
6781 * 0100b (0x4) 40 Mhz (LVD/Ultra2)
6782 * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
6783 * 0110b (0x6) Undefined
6784 * .
6785 * 1111b (0xF) Undefined
6786 */
6787 word = 0;
6788 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
6789 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
6790 /* Set Ultra speed for TID 'tid'. */
6791 word |= (0x3 << (4 * (tid % 4)));
6792 } else {
6793 /* Set Fast speed for TID 'tid'. */
6794 word |= (0x2 << (4 * (tid % 4)));
6795 }
6796 if (tid == 3) { /* Check if done with sdtr_speed1. */
6797 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
6798 word = 0;
6799 } else if (tid == 7) { /* Check if done with sdtr_speed2. */
6800 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
6801 word = 0;
6802 } else if (tid == 11) { /* Check if done with sdtr_speed3. */
6803 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
6804 word = 0;
6805 } else if (tid == 15) { /* Check if done with sdtr_speed4. */
6806 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
6807 /* End of loop. */
6808 }
6809 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006810
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006811 /*
6812 * Set microcode operating variable for the disconnect per TID bitmask.
6813 */
6814 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
6815 asc_dvc->cfg->disc_enable);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006816
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006817 /*
6818 * Set SCSI_CFG0 Microcode Default Value.
6819 *
6820 * The microcode will set the SCSI_CFG0 register using this value
6821 * after it is started below.
6822 */
6823 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
6824 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
6825 asc_dvc->chip_scsi_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006826
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006827 /*
6828 * Determine SCSI_CFG1 Microcode Default Value.
6829 *
6830 * The microcode will set the SCSI_CFG1 register using this value
6831 * after it is started below.
6832 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006833
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006834 /* Read current SCSI_CFG1 Register value. */
6835 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006836
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006837 /*
6838 * If all three connectors are in use, return an error.
6839 */
6840 if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
6841 (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
6842 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
6843 return ADV_ERROR;
6844 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006845
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006846 /*
6847 * If the internal narrow cable is reversed all of the SCSI_CTRL
6848 * register signals will be set. Check for and return an error if
6849 * this condition is found.
6850 */
6851 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
6852 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
6853 return ADV_ERROR;
6854 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006855
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006856 /*
6857 * If this is a differential board and a single-ended device
6858 * is attached to one of the connectors, return an error.
6859 */
6860 if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
6861 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
6862 return ADV_ERROR;
6863 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006864
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006865 /*
6866 * If automatic termination control is enabled, then set the
6867 * termination value based on a table listed in a_condor.h.
6868 *
6869 * If manual termination was specified with an EEPROM setting
6870 * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
6871 * is ready to be 'ored' into SCSI_CFG1.
6872 */
6873 if (asc_dvc->cfg->termination == 0) {
6874 /*
6875 * The software always controls termination by setting TERM_CTL_SEL.
6876 * If TERM_CTL_SEL were set to 0, the hardware would set termination.
6877 */
6878 asc_dvc->cfg->termination |= TERM_CTL_SEL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006879
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006880 switch (scsi_cfg1 & CABLE_DETECT) {
6881 /* TERM_CTL_H: on, TERM_CTL_L: on */
6882 case 0x3:
6883 case 0x7:
6884 case 0xB:
6885 case 0xD:
6886 case 0xE:
6887 case 0xF:
6888 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
6889 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006890
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006891 /* TERM_CTL_H: on, TERM_CTL_L: off */
6892 case 0x1:
6893 case 0x5:
6894 case 0x9:
6895 case 0xA:
6896 case 0xC:
6897 asc_dvc->cfg->termination |= TERM_CTL_H;
6898 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006899
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006900 /* TERM_CTL_H: off, TERM_CTL_L: off */
6901 case 0x2:
6902 case 0x6:
6903 break;
6904 }
6905 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006906
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006907 /*
6908 * Clear any set TERM_CTL_H and TERM_CTL_L bits.
6909 */
6910 scsi_cfg1 &= ~TERM_CTL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006911
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006912 /*
6913 * Invert the TERM_CTL_H and TERM_CTL_L bits and then
6914 * set 'scsi_cfg1'. The TERM_POL bit does not need to be
6915 * referenced, because the hardware internally inverts
6916 * the Termination High and Low bits if TERM_POL is set.
6917 */
6918 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
Linus Torvalds1da177e2005-04-16 15:20:36 -07006919
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006920 /*
6921 * Set SCSI_CFG1 Microcode Default Value
6922 *
6923 * Set filter value and possibly modified termination control
6924 * bits in the Microcode SCSI_CFG1 Register Value.
6925 *
6926 * The microcode will set the SCSI_CFG1 register using this value
6927 * after it is started below.
6928 */
6929 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
6930 FLTR_DISABLE | scsi_cfg1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006931
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006932 /*
6933 * Set MEM_CFG Microcode Default Value
6934 *
6935 * The microcode will set the MEM_CFG register using this value
6936 * after it is started below.
6937 *
6938 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
6939 * are defined.
6940 *
6941 * ASC-3550 has 8KB internal memory.
6942 */
6943 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
6944 BIOS_EN | RAM_SZ_8KB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006945
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006946 /*
6947 * Set SEL_MASK Microcode Default Value
6948 *
6949 * The microcode will set the SEL_MASK register using this value
6950 * after it is started below.
6951 */
6952 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
6953 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -07006954
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06006955 AdvBuildCarrierFreelist(asc_dvc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006956
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006957 /*
6958 * Set-up the Host->RISC Initiator Command Queue (ICQ).
6959 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006960
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006961 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
6962 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
6963 return ADV_ERROR;
6964 }
6965 asc_dvc->carr_freelist = (ADV_CARR_T *)
6966 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07006967
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006968 /*
6969 * The first command issued will be placed in the stopper carrier.
6970 */
6971 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006972
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006973 /*
6974 * Set RISC ICQ physical address start value.
6975 */
6976 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006977
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006978 /*
6979 * Set-up the RISC->Host Initiator Response Queue (IRQ).
6980 */
6981 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
6982 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
6983 return ADV_ERROR;
6984 }
6985 asc_dvc->carr_freelist = (ADV_CARR_T *)
6986 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07006987
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006988 /*
6989 * The first command completed by the RISC will be placed in
6990 * the stopper.
6991 *
6992 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
6993 * completed the RISC will set the ASC_RQ_STOPPER bit.
6994 */
6995 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006996
Matthew Wilcox27c868c2007-07-26 10:56:23 -04006997 /*
6998 * Set RISC IRQ physical address start value.
6999 */
7000 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7001 asc_dvc->carr_pending_cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007002
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007003 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7004 (ADV_INTR_ENABLE_HOST_INTR |
7005 ADV_INTR_ENABLE_GLOBAL_INTR));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007006
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007007 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7008 AdvWriteWordRegister(iop_base, IOPW_PC, word);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007009
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007010 /* finally, finally, gentlemen, start your engine */
7011 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007012
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007013 /*
7014 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7015 * Resets should be performed. The RISC has to be running
7016 * to issue a SCSI Bus Reset.
7017 */
7018 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7019 /*
7020 * If the BIOS Signature is present in memory, restore the
7021 * BIOS Handshake Configuration Table and do not perform
7022 * a SCSI Bus Reset.
7023 */
7024 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7025 0x55AA) {
7026 /*
7027 * Restore per TID negotiated values.
7028 */
7029 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7030 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7031 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
7032 tagqng_able);
7033 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7034 AdvWriteByteLram(iop_base,
7035 ASC_MC_NUMBER_OF_MAX_CMD + tid,
7036 max_cmd[tid]);
7037 }
7038 } else {
7039 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
7040 warn_code = ASC_WARN_BUSRESET_ERROR;
7041 }
7042 }
7043 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007044
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007045 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007046}
7047
7048/*
7049 * Initialize the ASC-38C0800.
7050 *
7051 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
7052 *
7053 * For a non-fatal error return a warning code. If there are no warnings
7054 * then 0 is returned.
7055 *
7056 * Needed after initialization for error recovery.
7057 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007058static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007059{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007060 AdvPortAddr iop_base;
7061 ushort warn_code;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007062 int begin_addr;
7063 int end_addr;
7064 ushort code_sum;
7065 int word;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007066 int i;
7067 ushort scsi_cfg1;
7068 uchar byte;
7069 uchar tid;
7070 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
7071 ushort wdtr_able, sdtr_able, tagqng_able;
7072 uchar max_cmd[ADV_MAX_TID + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07007073
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007074 /* If there is already an error, don't continue. */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007075 if (asc_dvc->err_code != 0)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007076 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007077
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007078 /*
7079 * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
7080 */
7081 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
7082 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
7083 return ADV_ERROR;
7084 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007085
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007086 warn_code = 0;
7087 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007088
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007089 /*
7090 * Save the RISC memory BIOS region before writing the microcode.
7091 * The BIOS may already be loaded and using its RISC LRAM region
7092 * so its region must be saved and restored.
7093 *
7094 * Note: This code makes the assumption, which is currently true,
7095 * that a chip reset does not clear RISC LRAM.
7096 */
7097 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7098 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7099 bios_mem[i]);
7100 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007101
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007102 /*
7103 * Save current per TID negotiated values.
7104 */
7105 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7106 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7107 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
7108 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7109 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
7110 max_cmd[tid]);
7111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007112
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007113 /*
7114 * RAM BIST (RAM Built-In Self Test)
7115 *
7116 * Address : I/O base + offset 0x38h register (byte).
7117 * Function: Bit 7-6(RW) : RAM mode
7118 * Normal Mode : 0x00
7119 * Pre-test Mode : 0x40
7120 * RAM Test Mode : 0x80
7121 * Bit 5 : unused
7122 * Bit 4(RO) : Done bit
7123 * Bit 3-0(RO) : Status
7124 * Host Error : 0x08
7125 * Int_RAM Error : 0x04
7126 * RISC Error : 0x02
7127 * SCSI Error : 0x01
7128 * No Error : 0x00
7129 *
7130 * Note: RAM BIST code should be put right here, before loading the
7131 * microcode and after saving the RISC memory BIOS region.
7132 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007133
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007134 /*
7135 * LRAM Pre-test
7136 *
7137 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
7138 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
7139 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
7140 * to NORMAL_MODE, return an error too.
7141 */
7142 for (i = 0; i < 2; i++) {
7143 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
Matthew Wilcoxb009bef2007-09-09 08:56:38 -06007144 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007145 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7146 if ((byte & RAM_TEST_DONE) == 0
7147 || (byte & 0x0F) != PRE_TEST_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007148 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007149 return ADV_ERROR;
7150 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007151
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007152 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Matthew Wilcoxb009bef2007-09-09 08:56:38 -06007153 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007154 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
7155 != NORMAL_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007156 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007157 return ADV_ERROR;
7158 }
7159 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007160
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007161 /*
7162 * LRAM Test - It takes about 1.5 ms to run through the test.
7163 *
7164 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
7165 * If Done bit not set or Status not 0, save register byte, set the
7166 * err_code, and return an error.
7167 */
7168 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
Matthew Wilcoxb009bef2007-09-09 08:56:38 -06007169 mdelay(10); /* Wait for 10ms before checking status. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007170
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007171 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7172 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
7173 /* Get here if Done bit not set or Status not 0. */
7174 asc_dvc->bist_err_code = byte; /* for BIOS display message */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007175 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007176 return ADV_ERROR;
7177 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007178
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007179 /* We need to reset back to normal mode after LRAM test passes. */
7180 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007182 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
7183 _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
7184 _adv_asc38C0800_chksum);
7185 if (asc_dvc->err_code)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007186 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007187
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007188 /*
7189 * Restore the RISC memory BIOS region.
7190 */
7191 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7192 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7193 bios_mem[i]);
7194 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007195
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007196 /*
7197 * Calculate and write the microcode code checksum to the microcode
7198 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
7199 */
7200 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
7201 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
7202 code_sum = 0;
7203 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
7204 for (word = begin_addr; word < end_addr; word += 2) {
7205 code_sum += AdvReadWordAutoIncLram(iop_base);
7206 }
7207 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007208
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007209 /*
7210 * Read microcode version and date.
7211 */
7212 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
7213 asc_dvc->cfg->mcode_date);
7214 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
7215 asc_dvc->cfg->mcode_version);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007216
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007217 /*
7218 * Set the chip type to indicate the ASC38C0800.
7219 */
7220 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007221
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007222 /*
7223 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
7224 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
7225 * cable detection and then we are able to read C_DET[3:0].
7226 *
7227 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
7228 * Microcode Default Value' section below.
7229 */
7230 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7231 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
7232 scsi_cfg1 | DIS_TERM_DRV);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007233
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007234 /*
7235 * If the PCI Configuration Command Register "Parity Error Response
7236 * Control" Bit was clear (0), then set the microcode variable
7237 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
7238 * to ignore DMA parity errors.
7239 */
7240 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
7241 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7242 word |= CONTROL_FLAG_IGNORE_PERR;
7243 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7244 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007245
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007246 /*
7247 * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
7248 * bits for the default FIFO threshold.
7249 *
7250 * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
7251 *
7252 * For DMA Errata #4 set the BC_THRESH_ENB bit.
7253 */
7254 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
7255 BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
7256 READ_CMD_MRM);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007257
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007258 /*
7259 * Microcode operating variables for WDTR, SDTR, and command tag
Matthew Wilcox47d853c2007-07-26 11:41:33 -04007260 * queuing will be set in slave_configure() based on what a
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007261 * device reports it is capable of in Inquiry byte 7.
7262 *
7263 * If SCSI Bus Resets have been disabled, then directly set
7264 * SDTR and WDTR from the EEPROM configuration. This will allow
7265 * the BIOS and warm boot to work without a SCSI bus hang on
7266 * the Inquiry caused by host and target mismatched DTR values.
7267 * Without the SCSI Bus Reset, before an Inquiry a device can't
7268 * be assumed to be in Asynchronous, Narrow mode.
7269 */
7270 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
7271 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
7272 asc_dvc->wdtr_able);
7273 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
7274 asc_dvc->sdtr_able);
7275 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007276
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007277 /*
7278 * Set microcode operating variables for DISC and SDTR_SPEED1,
7279 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
7280 * configuration values.
7281 *
7282 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
7283 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
7284 * without determining here whether the device supports SDTR.
7285 */
7286 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
7287 asc_dvc->cfg->disc_enable);
7288 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
7289 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
7290 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
7291 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007292
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007293 /*
7294 * Set SCSI_CFG0 Microcode Default Value.
7295 *
7296 * The microcode will set the SCSI_CFG0 register using this value
7297 * after it is started below.
7298 */
7299 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
7300 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
7301 asc_dvc->chip_scsi_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007302
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007303 /*
7304 * Determine SCSI_CFG1 Microcode Default Value.
7305 *
7306 * The microcode will set the SCSI_CFG1 register using this value
7307 * after it is started below.
7308 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007309
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007310 /* Read current SCSI_CFG1 Register value. */
7311 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007312
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007313 /*
7314 * If the internal narrow cable is reversed all of the SCSI_CTRL
7315 * register signals will be set. Check for and return an error if
7316 * this condition is found.
7317 */
7318 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
7319 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
7320 return ADV_ERROR;
7321 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007322
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007323 /*
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007324 * All kind of combinations of devices attached to one of four
7325 * connectors are acceptable except HVD device attached. For example,
7326 * LVD device can be attached to SE connector while SE device attached
7327 * to LVD connector. If LVD device attached to SE connector, it only
7328 * runs up to Ultra speed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007329 *
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007330 * If an HVD device is attached to one of LVD connectors, return an
7331 * error. However, there is no way to detect HVD device attached to
7332 * SE connectors.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007333 */
7334 if (scsi_cfg1 & HVD) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007335 asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007336 return ADV_ERROR;
7337 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007338
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007339 /*
7340 * If either SE or LVD automatic termination control is enabled, then
7341 * set the termination value based on a table listed in a_condor.h.
7342 *
7343 * If manual termination was specified with an EEPROM setting then
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007344 * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
7345 * to be 'ored' into SCSI_CFG1.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007346 */
7347 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
7348 /* SE automatic termination control is enabled. */
7349 switch (scsi_cfg1 & C_DET_SE) {
7350 /* TERM_SE_HI: on, TERM_SE_LO: on */
7351 case 0x1:
7352 case 0x2:
7353 case 0x3:
7354 asc_dvc->cfg->termination |= TERM_SE;
7355 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007356
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007357 /* TERM_SE_HI: on, TERM_SE_LO: off */
7358 case 0x0:
7359 asc_dvc->cfg->termination |= TERM_SE_HI;
7360 break;
7361 }
7362 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007363
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007364 if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
7365 /* LVD automatic termination control is enabled. */
7366 switch (scsi_cfg1 & C_DET_LVD) {
7367 /* TERM_LVD_HI: on, TERM_LVD_LO: on */
7368 case 0x4:
7369 case 0x8:
7370 case 0xC:
7371 asc_dvc->cfg->termination |= TERM_LVD;
7372 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007373
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007374 /* TERM_LVD_HI: off, TERM_LVD_LO: off */
7375 case 0x0:
7376 break;
7377 }
7378 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007379
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007380 /*
7381 * Clear any set TERM_SE and TERM_LVD bits.
7382 */
7383 scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007384
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007385 /*
7386 * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
7387 */
7388 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007389
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007390 /*
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007391 * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
7392 * bits and set possibly modified termination control bits in the
7393 * Microcode SCSI_CFG1 Register Value.
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007394 */
7395 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007396
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007397 /*
7398 * Set SCSI_CFG1 Microcode Default Value
7399 *
7400 * Set possibly modified termination control and reset DIS_TERM_DRV
7401 * bits in the Microcode SCSI_CFG1 Register Value.
7402 *
7403 * The microcode will set the SCSI_CFG1 register using this value
7404 * after it is started below.
7405 */
7406 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007407
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007408 /*
7409 * Set MEM_CFG Microcode Default Value
7410 *
7411 * The microcode will set the MEM_CFG register using this value
7412 * after it is started below.
7413 *
7414 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
7415 * are defined.
7416 *
7417 * ASC-38C0800 has 16KB internal memory.
7418 */
7419 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7420 BIOS_EN | RAM_SZ_16KB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007421
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007422 /*
7423 * Set SEL_MASK Microcode Default Value
7424 *
7425 * The microcode will set the SEL_MASK register using this value
7426 * after it is started below.
7427 */
7428 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
7429 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007430
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06007431 AdvBuildCarrierFreelist(asc_dvc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007432
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007433 /*
7434 * Set-up the Host->RISC Initiator Command Queue (ICQ).
7435 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007436
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007437 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
7438 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7439 return ADV_ERROR;
7440 }
7441 asc_dvc->carr_freelist = (ADV_CARR_T *)
7442 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007443
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007444 /*
7445 * The first command issued will be placed in the stopper carrier.
7446 */
7447 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007448
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007449 /*
7450 * Set RISC ICQ physical address start value.
7451 * carr_pa is LE, must be native before write
7452 */
7453 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007454
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007455 /*
7456 * Set-up the RISC->Host Initiator Response Queue (IRQ).
7457 */
7458 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
7459 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7460 return ADV_ERROR;
7461 }
7462 asc_dvc->carr_freelist = (ADV_CARR_T *)
7463 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007464
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007465 /*
7466 * The first command completed by the RISC will be placed in
7467 * the stopper.
7468 *
7469 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
7470 * completed the RISC will set the ASC_RQ_STOPPER bit.
7471 */
7472 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007473
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007474 /*
7475 * Set RISC IRQ physical address start value.
7476 *
7477 * carr_pa is LE, must be native before write *
7478 */
7479 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7480 asc_dvc->carr_pending_cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007481
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007482 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7483 (ADV_INTR_ENABLE_HOST_INTR |
7484 ADV_INTR_ENABLE_GLOBAL_INTR));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007485
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007486 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7487 AdvWriteWordRegister(iop_base, IOPW_PC, word);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007488
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007489 /* finally, finally, gentlemen, start your engine */
7490 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007491
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007492 /*
7493 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7494 * Resets should be performed. The RISC has to be running
7495 * to issue a SCSI Bus Reset.
7496 */
7497 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7498 /*
7499 * If the BIOS Signature is present in memory, restore the
7500 * BIOS Handshake Configuration Table and do not perform
7501 * a SCSI Bus Reset.
7502 */
7503 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7504 0x55AA) {
7505 /*
7506 * Restore per TID negotiated values.
7507 */
7508 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7509 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7510 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
7511 tagqng_able);
7512 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
7513 AdvWriteByteLram(iop_base,
7514 ASC_MC_NUMBER_OF_MAX_CMD + tid,
7515 max_cmd[tid]);
7516 }
7517 } else {
7518 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
7519 warn_code = ASC_WARN_BUSRESET_ERROR;
7520 }
7521 }
7522 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007523
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007524 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007525}
7526
7527/*
7528 * Initialize the ASC-38C1600.
7529 *
7530 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
7531 *
7532 * For a non-fatal error return a warning code. If there are no warnings
7533 * then 0 is returned.
7534 *
7535 * Needed after initialization for error recovery.
7536 */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007537static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007538{
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007539 AdvPortAddr iop_base;
7540 ushort warn_code;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007541 int begin_addr;
7542 int end_addr;
7543 ushort code_sum;
7544 long word;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007545 int i;
7546 ushort scsi_cfg1;
7547 uchar byte;
7548 uchar tid;
7549 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
7550 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
7551 uchar max_cmd[ASC_MAX_TID + 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -07007552
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007553 /* If there is already an error, don't continue. */
7554 if (asc_dvc->err_code != 0) {
7555 return ADV_ERROR;
7556 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007557
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007558 /*
7559 * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
7560 */
7561 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
7562 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
7563 return ADV_ERROR;
7564 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007565
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007566 warn_code = 0;
7567 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007568
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007569 /*
7570 * Save the RISC memory BIOS region before writing the microcode.
7571 * The BIOS may already be loaded and using its RISC LRAM region
7572 * so its region must be saved and restored.
7573 *
7574 * Note: This code makes the assumption, which is currently true,
7575 * that a chip reset does not clear RISC LRAM.
7576 */
7577 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7578 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7579 bios_mem[i]);
7580 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007581
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007582 /*
7583 * Save current per TID negotiated values.
7584 */
7585 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7586 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7587 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
7588 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
7589 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
7590 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
7591 max_cmd[tid]);
7592 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007593
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007594 /*
7595 * RAM BIST (Built-In Self Test)
7596 *
7597 * Address : I/O base + offset 0x38h register (byte).
7598 * Function: Bit 7-6(RW) : RAM mode
7599 * Normal Mode : 0x00
7600 * Pre-test Mode : 0x40
7601 * RAM Test Mode : 0x80
7602 * Bit 5 : unused
7603 * Bit 4(RO) : Done bit
7604 * Bit 3-0(RO) : Status
7605 * Host Error : 0x08
7606 * Int_RAM Error : 0x04
7607 * RISC Error : 0x02
7608 * SCSI Error : 0x01
7609 * No Error : 0x00
7610 *
7611 * Note: RAM BIST code should be put right here, before loading the
7612 * microcode and after saving the RISC memory BIOS region.
7613 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007614
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007615 /*
7616 * LRAM Pre-test
7617 *
7618 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
7619 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
7620 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
7621 * to NORMAL_MODE, return an error too.
7622 */
7623 for (i = 0; i < 2; i++) {
7624 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
Matthew Wilcoxb009bef2007-09-09 08:56:38 -06007625 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007626 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7627 if ((byte & RAM_TEST_DONE) == 0
7628 || (byte & 0x0F) != PRE_TEST_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007629 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007630 return ADV_ERROR;
7631 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007632
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007633 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Matthew Wilcoxb009bef2007-09-09 08:56:38 -06007634 mdelay(10); /* Wait for 10ms before reading back. */
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007635 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
7636 != NORMAL_VALUE) {
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007637 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007638 return ADV_ERROR;
7639 }
7640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007641
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007642 /*
7643 * LRAM Test - It takes about 1.5 ms to run through the test.
7644 *
7645 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
7646 * If Done bit not set or Status not 0, save register byte, set the
7647 * err_code, and return an error.
7648 */
7649 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
Matthew Wilcoxb009bef2007-09-09 08:56:38 -06007650 mdelay(10); /* Wait for 10ms before checking status. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007651
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007652 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
7653 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
7654 /* Get here if Done bit not set or Status not 0. */
7655 asc_dvc->bist_err_code = byte; /* for BIOS display message */
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007656 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007657 return ADV_ERROR;
7658 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007659
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007660 /* We need to reset back to normal mode after LRAM test passes. */
7661 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007662
Matthew Wilcoxb9d96612007-09-09 08:56:28 -06007663 asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
7664 _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
7665 _adv_asc38C1600_chksum);
7666 if (asc_dvc->err_code)
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007667 return ADV_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007668
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007669 /*
7670 * Restore the RISC memory BIOS region.
7671 */
7672 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
7673 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
7674 bios_mem[i]);
7675 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007676
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007677 /*
7678 * Calculate and write the microcode code checksum to the microcode
7679 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
7680 */
7681 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
7682 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
7683 code_sum = 0;
7684 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
7685 for (word = begin_addr; word < end_addr; word += 2) {
7686 code_sum += AdvReadWordAutoIncLram(iop_base);
7687 }
7688 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007689
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007690 /*
7691 * Read microcode version and date.
7692 */
7693 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
7694 asc_dvc->cfg->mcode_date);
7695 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
7696 asc_dvc->cfg->mcode_version);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007697
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007698 /*
7699 * Set the chip type to indicate the ASC38C1600.
7700 */
7701 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007702
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007703 /*
7704 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
7705 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
7706 * cable detection and then we are able to read C_DET[3:0].
7707 *
7708 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
7709 * Microcode Default Value' section below.
7710 */
7711 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
7712 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
7713 scsi_cfg1 | DIS_TERM_DRV);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007714
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007715 /*
7716 * If the PCI Configuration Command Register "Parity Error Response
7717 * Control" Bit was clear (0), then set the microcode variable
7718 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
7719 * to ignore DMA parity errors.
7720 */
7721 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
7722 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7723 word |= CONTROL_FLAG_IGNORE_PERR;
7724 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7725 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007726
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007727 /*
7728 * If the BIOS control flag AIPP (Asynchronous Information
7729 * Phase Protection) disable bit is not set, then set the firmware
7730 * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
7731 * AIPP checking and encoding.
7732 */
7733 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
7734 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7735 word |= CONTROL_FLAG_ENABLE_AIPP;
7736 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
7737 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007738
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007739 /*
7740 * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
7741 * and START_CTL_TH [3:2].
7742 */
7743 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
7744 FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007745
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007746 /*
7747 * Microcode operating variables for WDTR, SDTR, and command tag
Matthew Wilcox47d853c2007-07-26 11:41:33 -04007748 * queuing will be set in slave_configure() based on what a
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007749 * device reports it is capable of in Inquiry byte 7.
7750 *
7751 * If SCSI Bus Resets have been disabled, then directly set
7752 * SDTR and WDTR from the EEPROM configuration. This will allow
7753 * the BIOS and warm boot to work without a SCSI bus hang on
7754 * the Inquiry caused by host and target mismatched DTR values.
7755 * Without the SCSI Bus Reset, before an Inquiry a device can't
7756 * be assumed to be in Asynchronous, Narrow mode.
7757 */
7758 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
7759 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
7760 asc_dvc->wdtr_able);
7761 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
7762 asc_dvc->sdtr_able);
7763 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007764
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007765 /*
7766 * Set microcode operating variables for DISC and SDTR_SPEED1,
7767 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
7768 * configuration values.
7769 *
7770 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
7771 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
7772 * without determining here whether the device supports SDTR.
7773 */
7774 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
7775 asc_dvc->cfg->disc_enable);
7776 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
7777 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
7778 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
7779 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007780
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007781 /*
7782 * Set SCSI_CFG0 Microcode Default Value.
7783 *
7784 * The microcode will set the SCSI_CFG0 register using this value
7785 * after it is started below.
7786 */
7787 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
7788 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
7789 asc_dvc->chip_scsi_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007790
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007791 /*
7792 * Calculate SCSI_CFG1 Microcode Default Value.
7793 *
7794 * The microcode will set the SCSI_CFG1 register using this value
7795 * after it is started below.
7796 *
7797 * Each ASC-38C1600 function has only two cable detect bits.
7798 * The bus mode override bits are in IOPB_SOFT_OVER_WR.
7799 */
7800 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007801
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007802 /*
7803 * If the cable is reversed all of the SCSI_CTRL register signals
7804 * will be set. Check for and return an error if this condition is
7805 * found.
7806 */
7807 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
7808 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
7809 return ADV_ERROR;
7810 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007811
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007812 /*
7813 * Each ASC-38C1600 function has two connectors. Only an HVD device
7814 * can not be connected to either connector. An LVD device or SE device
7815 * may be connected to either connecor. If an SE device is connected,
7816 * then at most Ultra speed (20 Mhz) can be used on both connectors.
7817 *
7818 * If an HVD device is attached, return an error.
7819 */
7820 if (scsi_cfg1 & HVD) {
7821 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
7822 return ADV_ERROR;
7823 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007824
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007825 /*
7826 * Each function in the ASC-38C1600 uses only the SE cable detect and
7827 * termination because there are two connectors for each function. Each
7828 * function may use either LVD or SE mode. Corresponding the SE automatic
7829 * termination control EEPROM bits are used for each function. Each
7830 * function has its own EEPROM. If SE automatic control is enabled for
7831 * the function, then set the termination value based on a table listed
7832 * in a_condor.h.
7833 *
7834 * If manual termination is specified in the EEPROM for the function,
7835 * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
7836 * ready to be 'ored' into SCSI_CFG1.
7837 */
7838 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
Matthew Wilcox13ac2d92007-07-30 08:10:23 -06007839 struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007840 /* SE automatic termination control is enabled. */
7841 switch (scsi_cfg1 & C_DET_SE) {
7842 /* TERM_SE_HI: on, TERM_SE_LO: on */
7843 case 0x1:
7844 case 0x2:
7845 case 0x3:
7846 asc_dvc->cfg->termination |= TERM_SE;
7847 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007848
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007849 case 0x0:
Matthew Wilcox13ac2d92007-07-30 08:10:23 -06007850 if (PCI_FUNC(pdev->devfn) == 0) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007851 /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
7852 } else {
7853 /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
7854 asc_dvc->cfg->termination |= TERM_SE_HI;
7855 }
7856 break;
7857 }
7858 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007859
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007860 /*
7861 * Clear any set TERM_SE bits.
7862 */
7863 scsi_cfg1 &= ~TERM_SE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007864
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007865 /*
7866 * Invert the TERM_SE bits and then set 'scsi_cfg1'.
7867 */
7868 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007869
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007870 /*
7871 * Clear Big Endian and Terminator Polarity bits and set possibly
7872 * modified termination control bits in the Microcode SCSI_CFG1
7873 * Register Value.
7874 *
7875 * Big Endian bit is not used even on big endian machines.
7876 */
7877 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007878
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007879 /*
7880 * Set SCSI_CFG1 Microcode Default Value
7881 *
7882 * Set possibly modified termination control bits in the Microcode
7883 * SCSI_CFG1 Register Value.
7884 *
7885 * The microcode will set the SCSI_CFG1 register using this value
7886 * after it is started below.
7887 */
7888 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007889
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007890 /*
7891 * Set MEM_CFG Microcode Default Value
7892 *
7893 * The microcode will set the MEM_CFG register using this value
7894 * after it is started below.
7895 *
7896 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
7897 * are defined.
7898 *
7899 * ASC-38C1600 has 32KB internal memory.
7900 *
7901 * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
7902 * out a special 16K Adv Library and Microcode version. After the issue
7903 * resolved, we should turn back to the 32K support. Both a_condor.h and
7904 * mcode.sas files also need to be updated.
7905 *
7906 * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7907 * BIOS_EN | RAM_SZ_32KB);
7908 */
7909 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
7910 BIOS_EN | RAM_SZ_16KB);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007911
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007912 /*
7913 * Set SEL_MASK Microcode Default Value
7914 *
7915 * The microcode will set the SEL_MASK register using this value
7916 * after it is started below.
7917 */
7918 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
7919 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007920
Matthew Wilcoxa9f4a592007-09-09 08:56:27 -06007921 AdvBuildCarrierFreelist(asc_dvc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007922
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007923 /*
7924 * Set-up the Host->RISC Initiator Command Queue (ICQ).
7925 */
7926 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
7927 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7928 return ADV_ERROR;
7929 }
7930 asc_dvc->carr_freelist = (ADV_CARR_T *)
7931 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007932
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007933 /*
7934 * The first command issued will be placed in the stopper carrier.
7935 */
7936 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007937
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007938 /*
7939 * Set RISC ICQ physical address start value. Initialize the
7940 * COMMA register to the same value otherwise the RISC will
7941 * prematurely detect a command is available.
7942 */
7943 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
7944 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
7945 le32_to_cpu(asc_dvc->icq_sp->carr_pa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007946
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007947 /*
7948 * Set-up the RISC->Host Initiator Response Queue (IRQ).
7949 */
7950 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
7951 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
7952 return ADV_ERROR;
7953 }
7954 asc_dvc->carr_freelist = (ADV_CARR_T *)
7955 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
Linus Torvalds1da177e2005-04-16 15:20:36 -07007956
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007957 /*
7958 * The first command completed by the RISC will be placed in
7959 * the stopper.
7960 *
7961 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
7962 * completed the RISC will set the ASC_RQ_STOPPER bit.
7963 */
7964 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007965
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007966 /*
7967 * Set RISC IRQ physical address start value.
7968 */
7969 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
7970 asc_dvc->carr_pending_cnt = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007971
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007972 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
7973 (ADV_INTR_ENABLE_HOST_INTR |
7974 ADV_INTR_ENABLE_GLOBAL_INTR));
7975 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
7976 AdvWriteWordRegister(iop_base, IOPW_PC, word);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007977
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007978 /* finally, finally, gentlemen, start your engine */
7979 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007980
Matthew Wilcox27c868c2007-07-26 10:56:23 -04007981 /*
7982 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
7983 * Resets should be performed. The RISC has to be running
7984 * to issue a SCSI Bus Reset.
7985 */
7986 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
7987 /*
7988 * If the BIOS Signature is present in memory, restore the
7989 * per TID microcode operating variables.
7990 */
7991 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
7992 0x55AA) {
7993 /*
7994 * Restore per TID negotiated values.
7995 */
7996 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
7997 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
7998 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
7999 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
8000 tagqng_able);
8001 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
8002 AdvWriteByteLram(iop_base,
8003 ASC_MC_NUMBER_OF_MAX_CMD + tid,
8004 max_cmd[tid]);
8005 }
8006 } else {
8007 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
8008 warn_code = ASC_WARN_BUSRESET_ERROR;
8009 }
8010 }
8011 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07008012
Matthew Wilcox27c868c2007-07-26 10:56:23 -04008013 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07008014}
8015
8016/*
Matthew Wilcox51219352007-10-02 21:55:22 -04008017 * Reset chip and SCSI Bus.
8018 *
8019 * Return Value:
8020 * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
8021 * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
8022 */
8023static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
8024{
8025 int status;
8026 ushort wdtr_able, sdtr_able, tagqng_able;
8027 ushort ppr_able = 0;
8028 uchar tid, max_cmd[ADV_MAX_TID + 1];
8029 AdvPortAddr iop_base;
8030 ushort bios_sig;
8031
8032 iop_base = asc_dvc->iop_base;
8033
8034 /*
8035 * Save current per TID negotiated values.
8036 */
8037 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8038 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8039 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8040 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
8041 }
8042 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8043 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
8044 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
8045 max_cmd[tid]);
8046 }
8047
8048 /*
8049 * Force the AdvInitAsc3550/38C0800Driver() function to
8050 * perform a SCSI Bus Reset by clearing the BIOS signature word.
8051 * The initialization functions assumes a SCSI Bus Reset is not
8052 * needed if the BIOS signature word is present.
8053 */
8054 AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
8055 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
8056
8057 /*
8058 * Stop chip and reset it.
8059 */
8060 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
8061 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
8062 mdelay(100);
8063 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
8064 ADV_CTRL_REG_CMD_WR_IO_REG);
8065
8066 /*
8067 * Reset Adv Library error code, if any, and try
8068 * re-initializing the chip.
8069 */
8070 asc_dvc->err_code = 0;
8071 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8072 status = AdvInitAsc38C1600Driver(asc_dvc);
8073 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
8074 status = AdvInitAsc38C0800Driver(asc_dvc);
8075 } else {
8076 status = AdvInitAsc3550Driver(asc_dvc);
8077 }
8078
8079 /* Translate initialization return value to status value. */
8080 if (status == 0) {
8081 status = ADV_TRUE;
8082 } else {
8083 status = ADV_FALSE;
8084 }
8085
8086 /*
8087 * Restore the BIOS signature word.
8088 */
8089 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
8090
8091 /*
8092 * Restore per TID negotiated values.
8093 */
8094 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8095 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8096 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
8097 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
8098 }
8099 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8100 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
8101 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
8102 max_cmd[tid]);
8103 }
8104
8105 return status;
8106}
8107
8108/*
8109 * adv_async_callback() - Adv Library asynchronous event callback function.
8110 */
8111static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
8112{
8113 switch (code) {
8114 case ADV_ASYNC_SCSI_BUS_RESET_DET:
8115 /*
8116 * The firmware detected a SCSI Bus reset.
8117 */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008118 ASC_DBG(0, "ADV_ASYNC_SCSI_BUS_RESET_DET\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008119 break;
8120
8121 case ADV_ASYNC_RDMA_FAILURE:
8122 /*
8123 * Handle RDMA failure by resetting the SCSI Bus and
8124 * possibly the chip if it is unresponsive. Log the error
8125 * with a unique code.
8126 */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008127 ASC_DBG(0, "ADV_ASYNC_RDMA_FAILURE\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008128 AdvResetChipAndSB(adv_dvc_varp);
8129 break;
8130
8131 case ADV_HOST_SCSI_BUS_RESET:
8132 /*
8133 * Host generated SCSI bus reset occurred.
8134 */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008135 ASC_DBG(0, "ADV_HOST_SCSI_BUS_RESET\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008136 break;
8137
8138 default:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008139 ASC_DBG(0, "unknown code 0x%x\n", code);
Matthew Wilcox51219352007-10-02 21:55:22 -04008140 break;
8141 }
8142}
8143
8144/*
8145 * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
8146 *
8147 * Callback function for the Wide SCSI Adv Library.
8148 */
8149static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
8150{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04008151 struct asc_board *boardp;
Matthew Wilcox51219352007-10-02 21:55:22 -04008152 adv_req_t *reqp;
8153 adv_sgblk_t *sgblkp;
8154 struct scsi_cmnd *scp;
8155 struct Scsi_Host *shost;
8156 ADV_DCNT resid_cnt;
8157
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008158 ASC_DBG(1, "adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
Matthew Wilcox51219352007-10-02 21:55:22 -04008159 (ulong)adv_dvc_varp, (ulong)scsiqp);
8160 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
8161
8162 /*
8163 * Get the adv_req_t structure for the command that has been
8164 * completed. The adv_req_t structure actually contains the
8165 * completed ADV_SCSI_REQ_Q structure.
8166 */
8167 reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008168 ASC_DBG(1, "reqp 0x%lx\n", (ulong)reqp);
Matthew Wilcox51219352007-10-02 21:55:22 -04008169 if (reqp == NULL) {
8170 ASC_PRINT("adv_isr_callback: reqp is NULL\n");
8171 return;
8172 }
8173
8174 /*
8175 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
8176 * command that has been completed.
8177 *
8178 * Note: The adv_req_t request structure and adv_sgblk_t structure,
8179 * if any, are dropped, because a board structure pointer can not be
8180 * determined.
8181 */
8182 scp = reqp->cmndp;
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008183 ASC_DBG(1, "scp 0x%p\n", scp);
Matthew Wilcox51219352007-10-02 21:55:22 -04008184 if (scp == NULL) {
8185 ASC_PRINT
8186 ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
8187 return;
8188 }
8189 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
8190
8191 shost = scp->device->host;
8192 ASC_STATS(shost, callback);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008193 ASC_DBG(1, "shost 0x%p\n", shost);
Matthew Wilcox51219352007-10-02 21:55:22 -04008194
Matthew Wilcoxd2411492007-10-02 21:55:31 -04008195 boardp = shost_priv(shost);
Matthew Wilcox51219352007-10-02 21:55:22 -04008196 BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
8197
8198 /*
8199 * 'done_status' contains the command's ending status.
8200 */
8201 switch (scsiqp->done_status) {
8202 case QD_NO_ERROR:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008203 ASC_DBG(2, "QD_NO_ERROR\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008204 scp->result = 0;
8205
8206 /*
8207 * Check for an underrun condition.
8208 *
8209 * If there was no error and an underrun condition, then
8210 * then return the number of underrun bytes.
8211 */
8212 resid_cnt = le32_to_cpu(scsiqp->data_cnt);
8213 if (scp->request_bufflen != 0 && resid_cnt != 0 &&
8214 resid_cnt <= scp->request_bufflen) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008215 ASC_DBG(1, "underrun condition %lu bytes\n",
Matthew Wilcox51219352007-10-02 21:55:22 -04008216 (ulong)resid_cnt);
8217 scp->resid = resid_cnt;
8218 }
8219 break;
8220
8221 case QD_WITH_ERROR:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008222 ASC_DBG(2, "QD_WITH_ERROR\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008223 switch (scsiqp->host_status) {
8224 case QHSTA_NO_ERROR:
8225 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008226 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008227 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
8228 sizeof(scp->sense_buffer));
8229 /*
8230 * Note: The 'status_byte()' macro used by
8231 * target drivers defined in scsi.h shifts the
8232 * status byte returned by host drivers right
8233 * by 1 bit. This is why target drivers also
8234 * use right shifted status byte definitions.
8235 * For instance target drivers use
8236 * CHECK_CONDITION, defined to 0x1, instead of
8237 * the SCSI defined check condition value of
8238 * 0x2. Host drivers are supposed to return
8239 * the status byte as it is defined by SCSI.
8240 */
8241 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
8242 STATUS_BYTE(scsiqp->scsi_status);
8243 } else {
8244 scp->result = STATUS_BYTE(scsiqp->scsi_status);
8245 }
8246 break;
8247
8248 default:
8249 /* Some other QHSTA error occurred. */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008250 ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status);
Matthew Wilcox51219352007-10-02 21:55:22 -04008251 scp->result = HOST_BYTE(DID_BAD_TARGET);
8252 break;
8253 }
8254 break;
8255
8256 case QD_ABORTED_BY_HOST:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008257 ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008258 scp->result =
8259 HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
8260 break;
8261
8262 default:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008263 ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
Matthew Wilcox51219352007-10-02 21:55:22 -04008264 scp->result =
8265 HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
8266 break;
8267 }
8268
8269 /*
8270 * If the 'init_tidmask' bit isn't already set for the target and the
8271 * current request finished normally, then set the bit for the target
8272 * to indicate that a device is present.
8273 */
8274 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
8275 scsiqp->done_status == QD_NO_ERROR &&
8276 scsiqp->host_status == QHSTA_NO_ERROR) {
8277 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
8278 }
8279
8280 asc_scsi_done(scp);
8281
8282 /*
8283 * Free all 'adv_sgblk_t' structures allocated for the request.
8284 */
8285 while ((sgblkp = reqp->sgblkp) != NULL) {
8286 /* Remove 'sgblkp' from the request list. */
8287 reqp->sgblkp = sgblkp->next_sgblkp;
8288
8289 /* Add 'sgblkp' to the board free list. */
8290 sgblkp->next_sgblkp = boardp->adv_sgblkp;
8291 boardp->adv_sgblkp = sgblkp;
8292 }
8293
8294 /*
8295 * Free the adv_req_t structure used with the command by adding
8296 * it back to the board free list.
8297 */
8298 reqp->next_reqp = boardp->adv_reqp;
8299 boardp->adv_reqp = reqp;
8300
Matthew Wilcoxb352f922007-10-02 21:55:33 -04008301 ASC_DBG(1, "done\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04008302}
8303
8304/*
8305 * Adv Library Interrupt Service Routine
8306 *
8307 * This function is called by a driver's interrupt service routine.
8308 * The function disables and re-enables interrupts.
8309 *
8310 * When a microcode idle command is completed, the ADV_DVC_VAR
8311 * 'idle_cmd_done' field is set to ADV_TRUE.
8312 *
8313 * Note: AdvISR() can be called when interrupts are disabled or even
8314 * when there is no hardware interrupt condition present. It will
8315 * always check for completed idle commands and microcode requests.
8316 * This is an important feature that shouldn't be changed because it
8317 * allows commands to be completed from polling mode loops.
8318 *
8319 * Return:
8320 * ADV_TRUE(1) - interrupt was pending
8321 * ADV_FALSE(0) - no interrupt was pending
8322 */
8323static int AdvISR(ADV_DVC_VAR *asc_dvc)
8324{
8325 AdvPortAddr iop_base;
8326 uchar int_stat;
8327 ushort target_bit;
8328 ADV_CARR_T *free_carrp;
8329 ADV_VADDR irq_next_vpa;
8330 ADV_SCSI_REQ_Q *scsiq;
8331
8332 iop_base = asc_dvc->iop_base;
8333
8334 /* Reading the register clears the interrupt. */
8335 int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
8336
8337 if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
8338 ADV_INTR_STATUS_INTRC)) == 0) {
8339 return ADV_FALSE;
8340 }
8341
8342 /*
8343 * Notify the driver of an asynchronous microcode condition by
8344 * calling the adv_async_callback function. The function
8345 * is passed the microcode ASC_MC_INTRB_CODE byte value.
8346 */
8347 if (int_stat & ADV_INTR_STATUS_INTRB) {
8348 uchar intrb_code;
8349
8350 AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
8351
8352 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
8353 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
8354 if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
8355 asc_dvc->carr_pending_cnt != 0) {
8356 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
8357 ADV_TICKLE_A);
8358 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
8359 AdvWriteByteRegister(iop_base,
8360 IOPB_TICKLE,
8361 ADV_TICKLE_NOP);
8362 }
8363 }
8364 }
8365
8366 adv_async_callback(asc_dvc, intrb_code);
8367 }
8368
8369 /*
8370 * Check if the IRQ stopper carrier contains a completed request.
8371 */
8372 while (((irq_next_vpa =
8373 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
8374 /*
8375 * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
8376 * The RISC will have set 'areq_vpa' to a virtual address.
8377 *
8378 * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
8379 * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
8380 * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
8381 * in AdvExeScsiQueue().
8382 */
8383 scsiq = (ADV_SCSI_REQ_Q *)
8384 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
8385
8386 /*
8387 * Request finished with good status and the queue was not
8388 * DMAed to host memory by the firmware. Set all status fields
8389 * to indicate good status.
8390 */
8391 if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
8392 scsiq->done_status = QD_NO_ERROR;
8393 scsiq->host_status = scsiq->scsi_status = 0;
8394 scsiq->data_cnt = 0L;
8395 }
8396
8397 /*
8398 * Advance the stopper pointer to the next carrier
8399 * ignoring the lower four bits. Free the previous
8400 * stopper carrier.
8401 */
8402 free_carrp = asc_dvc->irq_sp;
8403 asc_dvc->irq_sp = (ADV_CARR_T *)
8404 ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
8405
8406 free_carrp->next_vpa =
8407 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
8408 asc_dvc->carr_freelist = free_carrp;
8409 asc_dvc->carr_pending_cnt--;
8410
8411 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
8412
8413 /*
8414 * Clear request microcode control flag.
8415 */
8416 scsiq->cntl = 0;
8417
8418 /*
8419 * Notify the driver of the completed request by passing
8420 * the ADV_SCSI_REQ_Q pointer to its callback function.
8421 */
8422 scsiq->a_flag |= ADV_SCSIQ_DONE;
8423 adv_isr_callback(asc_dvc, scsiq);
8424 /*
8425 * Note: After the driver callback function is called, 'scsiq'
8426 * can no longer be referenced.
8427 *
8428 * Fall through and continue processing other completed
8429 * requests...
8430 */
8431 }
8432 return ADV_TRUE;
8433}
8434
8435static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
8436{
8437 if (asc_dvc->err_code == 0) {
8438 asc_dvc->err_code = err_code;
8439 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
8440 err_code);
8441 }
8442 return err_code;
8443}
8444
8445static void AscAckInterrupt(PortAddr iop_base)
8446{
8447 uchar host_flag;
8448 uchar risc_flag;
8449 ushort loop;
8450
8451 loop = 0;
8452 do {
8453 risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
8454 if (loop++ > 0x7FFF) {
8455 break;
8456 }
8457 } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
8458 host_flag =
8459 AscReadLramByte(iop_base,
8460 ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
8461 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
8462 (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
8463 AscSetChipStatus(iop_base, CIW_INT_ACK);
8464 loop = 0;
8465 while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
8466 AscSetChipStatus(iop_base, CIW_INT_ACK);
8467 if (loop++ > 3) {
8468 break;
8469 }
8470 }
8471 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
Matthew Wilcox51219352007-10-02 21:55:22 -04008472}
8473
8474static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
8475{
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -04008476 const uchar *period_table;
Matthew Wilcox51219352007-10-02 21:55:22 -04008477 int max_index;
8478 int min_index;
8479 int i;
8480
8481 period_table = asc_dvc->sdtr_period_tbl;
8482 max_index = (int)asc_dvc->max_sdtr_index;
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -04008483 min_index = (int)asc_dvc->min_sdtr_index;
Matthew Wilcox51219352007-10-02 21:55:22 -04008484 if ((syn_time <= period_table[max_index])) {
8485 for (i = min_index; i < (max_index - 1); i++) {
8486 if (syn_time <= period_table[i]) {
8487 return (uchar)i;
8488 }
8489 }
8490 return (uchar)max_index;
8491 } else {
8492 return (uchar)(max_index + 1);
8493 }
8494}
8495
8496static uchar
8497AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
8498{
8499 EXT_MSG sdtr_buf;
8500 uchar sdtr_period_index;
8501 PortAddr iop_base;
8502
8503 iop_base = asc_dvc->iop_base;
8504 sdtr_buf.msg_type = EXTENDED_MESSAGE;
8505 sdtr_buf.msg_len = MS_SDTR_LEN;
8506 sdtr_buf.msg_req = EXTENDED_SDTR;
8507 sdtr_buf.xfer_period = sdtr_period;
8508 sdtr_offset &= ASC_SYN_MAX_OFFSET;
8509 sdtr_buf.req_ack_offset = sdtr_offset;
8510 sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
8511 if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
8512 AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
8513 (uchar *)&sdtr_buf,
8514 sizeof(EXT_MSG) >> 1);
8515 return ((sdtr_period_index << 4) | sdtr_offset);
8516 } else {
8517 sdtr_buf.req_ack_offset = 0;
8518 AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
8519 (uchar *)&sdtr_buf,
8520 sizeof(EXT_MSG) >> 1);
8521 return 0;
8522 }
8523}
8524
8525static uchar
8526AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
8527{
8528 uchar byte;
8529 uchar sdtr_period_ix;
8530
8531 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -04008532 if (sdtr_period_ix > asc_dvc->max_sdtr_index)
Matthew Wilcox51219352007-10-02 21:55:22 -04008533 return 0xFF;
Matthew Wilcox51219352007-10-02 21:55:22 -04008534 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
8535 return byte;
8536}
8537
8538static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
8539{
8540 ASC_SCSI_BIT_ID_TYPE org_id;
8541 int i;
8542 int sta = TRUE;
8543
8544 AscSetBank(iop_base, 1);
8545 org_id = AscReadChipDvcID(iop_base);
8546 for (i = 0; i <= ASC_MAX_TID; i++) {
8547 if (org_id == (0x01 << i))
8548 break;
8549 }
8550 org_id = (ASC_SCSI_BIT_ID_TYPE) i;
8551 AscWriteChipDvcID(iop_base, id);
8552 if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
8553 AscSetBank(iop_base, 0);
8554 AscSetChipSyn(iop_base, sdtr_data);
8555 if (AscGetChipSyn(iop_base) != sdtr_data) {
8556 sta = FALSE;
8557 }
8558 } else {
8559 sta = FALSE;
8560 }
8561 AscSetBank(iop_base, 1);
8562 AscWriteChipDvcID(iop_base, org_id);
8563 AscSetBank(iop_base, 0);
8564 return (sta);
8565}
8566
8567static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
8568{
8569 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
8570 AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
8571}
8572
8573static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
8574{
8575 EXT_MSG ext_msg;
8576 EXT_MSG out_msg;
8577 ushort halt_q_addr;
8578 int sdtr_accept;
8579 ushort int_halt_code;
8580 ASC_SCSI_BIT_ID_TYPE scsi_busy;
8581 ASC_SCSI_BIT_ID_TYPE target_id;
8582 PortAddr iop_base;
8583 uchar tag_code;
8584 uchar q_status;
8585 uchar halt_qp;
8586 uchar sdtr_data;
8587 uchar target_ix;
8588 uchar q_cntl, tid_no;
8589 uchar cur_dvc_qng;
8590 uchar asyn_sdtr;
8591 uchar scsi_status;
Matthew Wilcoxd2411492007-10-02 21:55:31 -04008592 struct asc_board *boardp;
Matthew Wilcox51219352007-10-02 21:55:22 -04008593
8594 BUG_ON(!asc_dvc->drv_ptr);
8595 boardp = asc_dvc->drv_ptr;
8596
8597 iop_base = asc_dvc->iop_base;
8598 int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
8599
8600 halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
8601 halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
8602 target_ix = AscReadLramByte(iop_base,
8603 (ushort)(halt_q_addr +
8604 (ushort)ASC_SCSIQ_B_TARGET_IX));
8605 q_cntl = AscReadLramByte(iop_base,
8606 (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
8607 tid_no = ASC_TIX_TO_TID(target_ix);
8608 target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
8609 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8610 asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
8611 } else {
8612 asyn_sdtr = 0;
8613 }
8614 if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
8615 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8616 AscSetChipSDTR(iop_base, 0, tid_no);
8617 boardp->sdtr_data[tid_no] = 0;
8618 }
8619 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8620 return (0);
8621 } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
8622 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
8623 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8624 boardp->sdtr_data[tid_no] = asyn_sdtr;
8625 }
8626 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8627 return (0);
8628 } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
8629 AscMemWordCopyPtrFromLram(iop_base,
8630 ASCV_MSGIN_BEG,
8631 (uchar *)&ext_msg,
8632 sizeof(EXT_MSG) >> 1);
8633
8634 if (ext_msg.msg_type == EXTENDED_MESSAGE &&
8635 ext_msg.msg_req == EXTENDED_SDTR &&
8636 ext_msg.msg_len == MS_SDTR_LEN) {
8637 sdtr_accept = TRUE;
8638 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
8639
8640 sdtr_accept = FALSE;
8641 ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
8642 }
8643 if ((ext_msg.xfer_period <
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -04008644 asc_dvc->sdtr_period_tbl[asc_dvc->min_sdtr_index])
Matthew Wilcox51219352007-10-02 21:55:22 -04008645 || (ext_msg.xfer_period >
8646 asc_dvc->sdtr_period_tbl[asc_dvc->
8647 max_sdtr_index])) {
8648 sdtr_accept = FALSE;
8649 ext_msg.xfer_period =
8650 asc_dvc->sdtr_period_tbl[asc_dvc->
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -04008651 min_sdtr_index];
Matthew Wilcox51219352007-10-02 21:55:22 -04008652 }
8653 if (sdtr_accept) {
8654 sdtr_data =
8655 AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
8656 ext_msg.req_ack_offset);
8657 if ((sdtr_data == 0xFF)) {
8658
8659 q_cntl |= QC_MSG_OUT;
8660 asc_dvc->init_sdtr &= ~target_id;
8661 asc_dvc->sdtr_done &= ~target_id;
8662 AscSetChipSDTR(iop_base, asyn_sdtr,
8663 tid_no);
8664 boardp->sdtr_data[tid_no] = asyn_sdtr;
8665 }
8666 }
8667 if (ext_msg.req_ack_offset == 0) {
8668
8669 q_cntl &= ~QC_MSG_OUT;
8670 asc_dvc->init_sdtr &= ~target_id;
8671 asc_dvc->sdtr_done &= ~target_id;
8672 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8673 } else {
8674 if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
Matthew Wilcox51219352007-10-02 21:55:22 -04008675 q_cntl &= ~QC_MSG_OUT;
8676 asc_dvc->sdtr_done |= target_id;
8677 asc_dvc->init_sdtr |= target_id;
8678 asc_dvc->pci_fix_asyn_xfer &=
8679 ~target_id;
8680 sdtr_data =
8681 AscCalSDTRData(asc_dvc,
8682 ext_msg.xfer_period,
8683 ext_msg.
8684 req_ack_offset);
8685 AscSetChipSDTR(iop_base, sdtr_data,
8686 tid_no);
8687 boardp->sdtr_data[tid_no] = sdtr_data;
8688 } else {
Matthew Wilcox51219352007-10-02 21:55:22 -04008689 q_cntl |= QC_MSG_OUT;
8690 AscMsgOutSDTR(asc_dvc,
8691 ext_msg.xfer_period,
8692 ext_msg.req_ack_offset);
8693 asc_dvc->pci_fix_asyn_xfer &=
8694 ~target_id;
8695 sdtr_data =
8696 AscCalSDTRData(asc_dvc,
8697 ext_msg.xfer_period,
8698 ext_msg.
8699 req_ack_offset);
8700 AscSetChipSDTR(iop_base, sdtr_data,
8701 tid_no);
8702 boardp->sdtr_data[tid_no] = sdtr_data;
8703 asc_dvc->sdtr_done |= target_id;
8704 asc_dvc->init_sdtr |= target_id;
8705 }
8706 }
8707
8708 AscWriteLramByte(iop_base,
8709 (ushort)(halt_q_addr +
8710 (ushort)ASC_SCSIQ_B_CNTL),
8711 q_cntl);
8712 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8713 return (0);
8714 } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
8715 ext_msg.msg_req == EXTENDED_WDTR &&
8716 ext_msg.msg_len == MS_WDTR_LEN) {
8717
8718 ext_msg.wdtr_width = 0;
8719 AscMemWordCopyPtrToLram(iop_base,
8720 ASCV_MSGOUT_BEG,
8721 (uchar *)&ext_msg,
8722 sizeof(EXT_MSG) >> 1);
8723 q_cntl |= QC_MSG_OUT;
8724 AscWriteLramByte(iop_base,
8725 (ushort)(halt_q_addr +
8726 (ushort)ASC_SCSIQ_B_CNTL),
8727 q_cntl);
8728 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8729 return (0);
8730 } else {
8731
8732 ext_msg.msg_type = MESSAGE_REJECT;
8733 AscMemWordCopyPtrToLram(iop_base,
8734 ASCV_MSGOUT_BEG,
8735 (uchar *)&ext_msg,
8736 sizeof(EXT_MSG) >> 1);
8737 q_cntl |= QC_MSG_OUT;
8738 AscWriteLramByte(iop_base,
8739 (ushort)(halt_q_addr +
8740 (ushort)ASC_SCSIQ_B_CNTL),
8741 q_cntl);
8742 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8743 return (0);
8744 }
8745 } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
8746
8747 q_cntl |= QC_REQ_SENSE;
8748
8749 if ((asc_dvc->init_sdtr & target_id) != 0) {
8750
8751 asc_dvc->sdtr_done &= ~target_id;
8752
8753 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
8754 q_cntl |= QC_MSG_OUT;
8755 AscMsgOutSDTR(asc_dvc,
8756 asc_dvc->
8757 sdtr_period_tbl[(sdtr_data >> 4) &
8758 (uchar)(asc_dvc->
8759 max_sdtr_index -
8760 1)],
8761 (uchar)(sdtr_data & (uchar)
8762 ASC_SYN_MAX_OFFSET));
8763 }
8764
8765 AscWriteLramByte(iop_base,
8766 (ushort)(halt_q_addr +
8767 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
8768
8769 tag_code = AscReadLramByte(iop_base,
8770 (ushort)(halt_q_addr + (ushort)
8771 ASC_SCSIQ_B_TAG_CODE));
8772 tag_code &= 0xDC;
8773 if ((asc_dvc->pci_fix_asyn_xfer & target_id)
8774 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
8775 ) {
8776
8777 tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
8778 | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
8779
8780 }
8781 AscWriteLramByte(iop_base,
8782 (ushort)(halt_q_addr +
8783 (ushort)ASC_SCSIQ_B_TAG_CODE),
8784 tag_code);
8785
8786 q_status = AscReadLramByte(iop_base,
8787 (ushort)(halt_q_addr + (ushort)
8788 ASC_SCSIQ_B_STATUS));
8789 q_status |= (QS_READY | QS_BUSY);
8790 AscWriteLramByte(iop_base,
8791 (ushort)(halt_q_addr +
8792 (ushort)ASC_SCSIQ_B_STATUS),
8793 q_status);
8794
8795 scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
8796 scsi_busy &= ~target_id;
8797 AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
8798
8799 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8800 return (0);
8801 } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
8802
8803 AscMemWordCopyPtrFromLram(iop_base,
8804 ASCV_MSGOUT_BEG,
8805 (uchar *)&out_msg,
8806 sizeof(EXT_MSG) >> 1);
8807
8808 if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
8809 (out_msg.msg_len == MS_SDTR_LEN) &&
8810 (out_msg.msg_req == EXTENDED_SDTR)) {
8811
8812 asc_dvc->init_sdtr &= ~target_id;
8813 asc_dvc->sdtr_done &= ~target_id;
8814 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
8815 boardp->sdtr_data[tid_no] = asyn_sdtr;
8816 }
8817 q_cntl &= ~QC_MSG_OUT;
8818 AscWriteLramByte(iop_base,
8819 (ushort)(halt_q_addr +
8820 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
8821 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8822 return (0);
8823 } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
8824
8825 scsi_status = AscReadLramByte(iop_base,
8826 (ushort)((ushort)halt_q_addr +
8827 (ushort)
8828 ASC_SCSIQ_SCSI_STATUS));
8829 cur_dvc_qng =
8830 AscReadLramByte(iop_base,
8831 (ushort)((ushort)ASC_QADR_BEG +
8832 (ushort)target_ix));
8833 if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
8834
8835 scsi_busy = AscReadLramByte(iop_base,
8836 (ushort)ASCV_SCSIBUSY_B);
8837 scsi_busy |= target_id;
8838 AscWriteLramByte(iop_base,
8839 (ushort)ASCV_SCSIBUSY_B, scsi_busy);
8840 asc_dvc->queue_full_or_busy |= target_id;
8841
8842 if (scsi_status == SAM_STAT_TASK_SET_FULL) {
8843 if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
8844 cur_dvc_qng -= 1;
8845 asc_dvc->max_dvc_qng[tid_no] =
8846 cur_dvc_qng;
8847
8848 AscWriteLramByte(iop_base,
8849 (ushort)((ushort)
8850 ASCV_MAX_DVC_QNG_BEG
8851 + (ushort)
8852 tid_no),
8853 cur_dvc_qng);
8854
8855 /*
8856 * Set the device queue depth to the
8857 * number of active requests when the
8858 * QUEUE FULL condition was encountered.
8859 */
8860 boardp->queue_full |= target_id;
8861 boardp->queue_full_cnt[tid_no] =
8862 cur_dvc_qng;
8863 }
8864 }
8865 }
8866 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8867 return (0);
8868 }
8869#if CC_VERY_LONG_SG_LIST
8870 else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
8871 uchar q_no;
8872 ushort q_addr;
8873 uchar sg_wk_q_no;
8874 uchar first_sg_wk_q_no;
8875 ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
8876 ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
8877 ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
8878 ushort sg_list_dwords;
8879 ushort sg_entry_cnt;
8880 uchar next_qp;
8881 int i;
8882
8883 q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
8884 if (q_no == ASC_QLINK_END)
8885 return 0;
8886
8887 q_addr = ASC_QNO_TO_QADDR(q_no);
8888
8889 /*
8890 * Convert the request's SRB pointer to a host ASC_SCSI_REQ
8891 * structure pointer using a macro provided by the driver.
8892 * The ASC_SCSI_REQ pointer provides a pointer to the
8893 * host ASC_SG_HEAD structure.
8894 */
8895 /* Read request's SRB pointer. */
8896 scsiq = (ASC_SCSI_Q *)
8897 ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
8898 (ushort)
8899 (q_addr +
8900 ASC_SCSIQ_D_SRBPTR))));
8901
8902 /*
8903 * Get request's first and working SG queue.
8904 */
8905 sg_wk_q_no = AscReadLramByte(iop_base,
8906 (ushort)(q_addr +
8907 ASC_SCSIQ_B_SG_WK_QP));
8908
8909 first_sg_wk_q_no = AscReadLramByte(iop_base,
8910 (ushort)(q_addr +
8911 ASC_SCSIQ_B_FIRST_SG_WK_QP));
8912
8913 /*
8914 * Reset request's working SG queue back to the
8915 * first SG queue.
8916 */
8917 AscWriteLramByte(iop_base,
8918 (ushort)(q_addr +
8919 (ushort)ASC_SCSIQ_B_SG_WK_QP),
8920 first_sg_wk_q_no);
8921
8922 sg_head = scsiq->sg_head;
8923
8924 /*
8925 * Set sg_entry_cnt to the number of SG elements
8926 * that will be completed on this interrupt.
8927 *
8928 * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
8929 * SG elements. The data_cnt and data_addr fields which
8930 * add 1 to the SG element capacity are not used when
8931 * restarting SG handling after a halt.
8932 */
8933 if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
8934 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
8935
8936 /*
8937 * Keep track of remaining number of SG elements that
8938 * will need to be handled on the next interrupt.
8939 */
8940 scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
8941 } else {
8942 sg_entry_cnt = scsiq->remain_sg_entry_cnt;
8943 scsiq->remain_sg_entry_cnt = 0;
8944 }
8945
8946 /*
8947 * Copy SG elements into the list of allocated SG queues.
8948 *
8949 * Last index completed is saved in scsiq->next_sg_index.
8950 */
8951 next_qp = first_sg_wk_q_no;
8952 q_addr = ASC_QNO_TO_QADDR(next_qp);
8953 scsi_sg_q.sg_head_qp = q_no;
8954 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
8955 for (i = 0; i < sg_head->queue_cnt; i++) {
8956 scsi_sg_q.seq_no = i + 1;
8957 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
8958 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
8959 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
8960 /*
8961 * After very first SG queue RISC FW uses next
8962 * SG queue first element then checks sg_list_cnt
8963 * against zero and then decrements, so set
8964 * sg_list_cnt 1 less than number of SG elements
8965 * in each SG queue.
8966 */
8967 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
8968 scsi_sg_q.sg_cur_list_cnt =
8969 ASC_SG_LIST_PER_Q - 1;
8970 } else {
8971 /*
8972 * This is the last SG queue in the list of
8973 * allocated SG queues. If there are more
8974 * SG elements than will fit in the allocated
8975 * queues, then set the QCSG_SG_XFER_MORE flag.
8976 */
8977 if (scsiq->remain_sg_entry_cnt != 0) {
8978 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
8979 } else {
8980 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
8981 }
8982 /* equals sg_entry_cnt * 2 */
8983 sg_list_dwords = sg_entry_cnt << 1;
8984 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
8985 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
8986 sg_entry_cnt = 0;
8987 }
8988
8989 scsi_sg_q.q_no = next_qp;
8990 AscMemWordCopyPtrToLram(iop_base,
8991 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
8992 (uchar *)&scsi_sg_q,
8993 sizeof(ASC_SG_LIST_Q) >> 1);
8994
8995 AscMemDWordCopyPtrToLram(iop_base,
8996 q_addr + ASC_SGQ_LIST_BEG,
8997 (uchar *)&sg_head->
8998 sg_list[scsiq->next_sg_index],
8999 sg_list_dwords);
9000
9001 scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
9002
9003 /*
9004 * If the just completed SG queue contained the
9005 * last SG element, then no more SG queues need
9006 * to be written.
9007 */
9008 if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
9009 break;
9010 }
9011
9012 next_qp = AscReadLramByte(iop_base,
9013 (ushort)(q_addr +
9014 ASC_SCSIQ_B_FWD));
9015 q_addr = ASC_QNO_TO_QADDR(next_qp);
9016 }
9017
9018 /*
9019 * Clear the halt condition so the RISC will be restarted
9020 * after the return.
9021 */
9022 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9023 return (0);
9024 }
9025#endif /* CC_VERY_LONG_SG_LIST */
9026 return (0);
9027}
9028
9029/*
9030 * void
9031 * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
9032 *
9033 * Calling/Exit State:
9034 * none
9035 *
9036 * Description:
9037 * Input an ASC_QDONE_INFO structure from the chip
9038 */
9039static void
9040DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
9041{
9042 int i;
9043 ushort word;
9044
9045 AscSetChipLramAddr(iop_base, s_addr);
9046 for (i = 0; i < 2 * words; i += 2) {
9047 if (i == 10) {
9048 continue;
9049 }
9050 word = inpw(iop_base + IOP_RAM_DATA);
9051 inbuf[i] = word & 0xff;
9052 inbuf[i + 1] = (word >> 8) & 0xff;
9053 }
9054 ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
9055}
9056
9057static uchar
9058_AscCopyLramScsiDoneQ(PortAddr iop_base,
9059 ushort q_addr,
9060 ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
9061{
9062 ushort _val;
9063 uchar sg_queue_cnt;
9064
9065 DvcGetQinfo(iop_base,
9066 q_addr + ASC_SCSIQ_DONE_INFO_BEG,
9067 (uchar *)scsiq,
9068 (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
9069
9070 _val = AscReadLramWord(iop_base,
9071 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
9072 scsiq->q_status = (uchar)_val;
9073 scsiq->q_no = (uchar)(_val >> 8);
9074 _val = AscReadLramWord(iop_base,
9075 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
9076 scsiq->cntl = (uchar)_val;
9077 sg_queue_cnt = (uchar)(_val >> 8);
9078 _val = AscReadLramWord(iop_base,
9079 (ushort)(q_addr +
9080 (ushort)ASC_SCSIQ_B_SENSE_LEN));
9081 scsiq->sense_len = (uchar)_val;
9082 scsiq->extra_bytes = (uchar)(_val >> 8);
9083
9084 /*
9085 * Read high word of remain bytes from alternate location.
9086 */
9087 scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
9088 (ushort)(q_addr +
9089 (ushort)
9090 ASC_SCSIQ_W_ALT_DC1)))
9091 << 16);
9092 /*
9093 * Read low word of remain bytes from original location.
9094 */
9095 scsiq->remain_bytes += AscReadLramWord(iop_base,
9096 (ushort)(q_addr + (ushort)
9097 ASC_SCSIQ_DW_REMAIN_XFER_CNT));
9098
9099 scsiq->remain_bytes &= max_dma_count;
9100 return sg_queue_cnt;
9101}
9102
9103/*
9104 * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
9105 *
9106 * Interrupt callback function for the Narrow SCSI Asc Library.
9107 */
9108static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
9109{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04009110 struct asc_board *boardp;
Matthew Wilcox51219352007-10-02 21:55:22 -04009111 struct scsi_cmnd *scp;
9112 struct Scsi_Host *shost;
9113
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009114 ASC_DBG(1, "asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
Matthew Wilcox51219352007-10-02 21:55:22 -04009115 ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
9116
9117 /*
9118 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
9119 * command that has been completed.
9120 */
9121 scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009122 ASC_DBG(1, "scp 0x%p\n", scp);
Matthew Wilcox51219352007-10-02 21:55:22 -04009123
9124 if (scp == NULL) {
9125 ASC_PRINT("asc_isr_callback: scp is NULL\n");
9126 return;
9127 }
9128 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
9129
9130 shost = scp->device->host;
9131 ASC_STATS(shost, callback);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009132 ASC_DBG(1, "shost 0x%p\n", shost);
Matthew Wilcox51219352007-10-02 21:55:22 -04009133
Matthew Wilcoxd2411492007-10-02 21:55:31 -04009134 boardp = shost_priv(shost);
Matthew Wilcox51219352007-10-02 21:55:22 -04009135 BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
9136
9137 /*
9138 * 'qdonep' contains the command's ending status.
9139 */
9140 switch (qdonep->d3.done_stat) {
9141 case QD_NO_ERROR:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009142 ASC_DBG(2, "QD_NO_ERROR\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009143 scp->result = 0;
9144
9145 /*
9146 * Check for an underrun condition.
9147 *
9148 * If there was no error and an underrun condition, then
9149 * return the number of underrun bytes.
9150 */
9151 if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
9152 qdonep->remain_bytes <= scp->request_bufflen) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009153 ASC_DBG(1, "underrun condition %u bytes\n",
Matthew Wilcox51219352007-10-02 21:55:22 -04009154 (unsigned)qdonep->remain_bytes);
9155 scp->resid = qdonep->remain_bytes;
9156 }
9157 break;
9158
9159 case QD_WITH_ERROR:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009160 ASC_DBG(2, "QD_WITH_ERROR\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009161 switch (qdonep->d3.host_stat) {
9162 case QHSTA_NO_ERROR:
9163 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009164 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009165 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
9166 sizeof(scp->sense_buffer));
9167 /*
9168 * Note: The 'status_byte()' macro used by
9169 * target drivers defined in scsi.h shifts the
9170 * status byte returned by host drivers right
9171 * by 1 bit. This is why target drivers also
9172 * use right shifted status byte definitions.
9173 * For instance target drivers use
9174 * CHECK_CONDITION, defined to 0x1, instead of
9175 * the SCSI defined check condition value of
9176 * 0x2. Host drivers are supposed to return
9177 * the status byte as it is defined by SCSI.
9178 */
9179 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
9180 STATUS_BYTE(qdonep->d3.scsi_stat);
9181 } else {
9182 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
9183 }
9184 break;
9185
9186 default:
9187 /* QHSTA error occurred */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009188 ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat);
Matthew Wilcox51219352007-10-02 21:55:22 -04009189 scp->result = HOST_BYTE(DID_BAD_TARGET);
9190 break;
9191 }
9192 break;
9193
9194 case QD_ABORTED_BY_HOST:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009195 ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009196 scp->result =
9197 HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
9198 scsi_msg) |
9199 STATUS_BYTE(qdonep->d3.scsi_stat);
9200 break;
9201
9202 default:
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009203 ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat);
Matthew Wilcox51219352007-10-02 21:55:22 -04009204 scp->result =
9205 HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
9206 scsi_msg) |
9207 STATUS_BYTE(qdonep->d3.scsi_stat);
9208 break;
9209 }
9210
9211 /*
9212 * If the 'init_tidmask' bit isn't already set for the target and the
9213 * current request finished normally, then set the bit for the target
9214 * to indicate that a device is present.
9215 */
9216 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
9217 qdonep->d3.done_stat == QD_NO_ERROR &&
9218 qdonep->d3.host_stat == QHSTA_NO_ERROR) {
9219 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
9220 }
9221
9222 asc_scsi_done(scp);
Matthew Wilcox51219352007-10-02 21:55:22 -04009223}
9224
9225static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
9226{
9227 uchar next_qp;
9228 uchar n_q_used;
9229 uchar sg_list_qp;
9230 uchar sg_queue_cnt;
9231 uchar q_cnt;
9232 uchar done_q_tail;
9233 uchar tid_no;
9234 ASC_SCSI_BIT_ID_TYPE scsi_busy;
9235 ASC_SCSI_BIT_ID_TYPE target_id;
9236 PortAddr iop_base;
9237 ushort q_addr;
9238 ushort sg_q_addr;
9239 uchar cur_target_qng;
9240 ASC_QDONE_INFO scsiq_buf;
9241 ASC_QDONE_INFO *scsiq;
9242 int false_overrun;
9243
9244 iop_base = asc_dvc->iop_base;
9245 n_q_used = 1;
9246 scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
9247 done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
9248 q_addr = ASC_QNO_TO_QADDR(done_q_tail);
9249 next_qp = AscReadLramByte(iop_base,
9250 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
9251 if (next_qp != ASC_QLINK_END) {
9252 AscPutVarDoneQTail(iop_base, next_qp);
9253 q_addr = ASC_QNO_TO_QADDR(next_qp);
9254 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
9255 asc_dvc->max_dma_count);
9256 AscWriteLramByte(iop_base,
9257 (ushort)(q_addr +
9258 (ushort)ASC_SCSIQ_B_STATUS),
9259 (uchar)(scsiq->
9260 q_status & (uchar)~(QS_READY |
9261 QS_ABORTED)));
9262 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
9263 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
9264 if ((scsiq->cntl & QC_SG_HEAD) != 0) {
9265 sg_q_addr = q_addr;
9266 sg_list_qp = next_qp;
9267 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
9268 sg_list_qp = AscReadLramByte(iop_base,
9269 (ushort)(sg_q_addr
9270 + (ushort)
9271 ASC_SCSIQ_B_FWD));
9272 sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
9273 if (sg_list_qp == ASC_QLINK_END) {
9274 AscSetLibErrorCode(asc_dvc,
9275 ASCQ_ERR_SG_Q_LINKS);
9276 scsiq->d3.done_stat = QD_WITH_ERROR;
9277 scsiq->d3.host_stat =
9278 QHSTA_D_QDONE_SG_LIST_CORRUPTED;
9279 goto FATAL_ERR_QDONE;
9280 }
9281 AscWriteLramByte(iop_base,
9282 (ushort)(sg_q_addr + (ushort)
9283 ASC_SCSIQ_B_STATUS),
9284 QS_FREE);
9285 }
9286 n_q_used = sg_queue_cnt + 1;
9287 AscPutVarDoneQTail(iop_base, sg_list_qp);
9288 }
9289 if (asc_dvc->queue_full_or_busy & target_id) {
9290 cur_target_qng = AscReadLramByte(iop_base,
9291 (ushort)((ushort)
9292 ASC_QADR_BEG
9293 + (ushort)
9294 scsiq->d2.
9295 target_ix));
9296 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
9297 scsi_busy = AscReadLramByte(iop_base, (ushort)
9298 ASCV_SCSIBUSY_B);
9299 scsi_busy &= ~target_id;
9300 AscWriteLramByte(iop_base,
9301 (ushort)ASCV_SCSIBUSY_B,
9302 scsi_busy);
9303 asc_dvc->queue_full_or_busy &= ~target_id;
9304 }
9305 }
9306 if (asc_dvc->cur_total_qng >= n_q_used) {
9307 asc_dvc->cur_total_qng -= n_q_used;
9308 if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
9309 asc_dvc->cur_dvc_qng[tid_no]--;
9310 }
9311 } else {
9312 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
9313 scsiq->d3.done_stat = QD_WITH_ERROR;
9314 goto FATAL_ERR_QDONE;
9315 }
9316 if ((scsiq->d2.srb_ptr == 0UL) ||
9317 ((scsiq->q_status & QS_ABORTED) != 0)) {
9318 return (0x11);
9319 } else if (scsiq->q_status == QS_DONE) {
9320 false_overrun = FALSE;
9321 if (scsiq->extra_bytes != 0) {
9322 scsiq->remain_bytes +=
9323 (ADV_DCNT)scsiq->extra_bytes;
9324 }
9325 if (scsiq->d3.done_stat == QD_WITH_ERROR) {
9326 if (scsiq->d3.host_stat ==
9327 QHSTA_M_DATA_OVER_RUN) {
9328 if ((scsiq->
9329 cntl & (QC_DATA_IN | QC_DATA_OUT))
9330 == 0) {
9331 scsiq->d3.done_stat =
9332 QD_NO_ERROR;
9333 scsiq->d3.host_stat =
9334 QHSTA_NO_ERROR;
9335 } else if (false_overrun) {
9336 scsiq->d3.done_stat =
9337 QD_NO_ERROR;
9338 scsiq->d3.host_stat =
9339 QHSTA_NO_ERROR;
9340 }
9341 } else if (scsiq->d3.host_stat ==
9342 QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
9343 AscStopChip(iop_base);
9344 AscSetChipControl(iop_base,
9345 (uchar)(CC_SCSI_RESET
9346 | CC_HALT));
9347 udelay(60);
9348 AscSetChipControl(iop_base, CC_HALT);
9349 AscSetChipStatus(iop_base,
9350 CIW_CLR_SCSI_RESET_INT);
9351 AscSetChipStatus(iop_base, 0);
9352 AscSetChipControl(iop_base, 0);
9353 }
9354 }
9355 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9356 asc_isr_callback(asc_dvc, scsiq);
9357 } else {
9358 if ((AscReadLramByte(iop_base,
9359 (ushort)(q_addr + (ushort)
9360 ASC_SCSIQ_CDB_BEG))
9361 == START_STOP)) {
9362 asc_dvc->unit_not_ready &= ~target_id;
9363 if (scsiq->d3.done_stat != QD_NO_ERROR) {
9364 asc_dvc->start_motor &=
9365 ~target_id;
9366 }
9367 }
9368 }
9369 return (1);
9370 } else {
9371 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
9372 FATAL_ERR_QDONE:
9373 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9374 asc_isr_callback(asc_dvc, scsiq);
9375 }
9376 return (0x80);
9377 }
9378 }
9379 return (0);
9380}
9381
9382static int AscISR(ASC_DVC_VAR *asc_dvc)
9383{
9384 ASC_CS_TYPE chipstat;
9385 PortAddr iop_base;
9386 ushort saved_ram_addr;
9387 uchar ctrl_reg;
9388 uchar saved_ctrl_reg;
9389 int int_pending;
9390 int status;
9391 uchar host_flag;
9392
9393 iop_base = asc_dvc->iop_base;
9394 int_pending = FALSE;
9395
9396 if (AscIsIntPending(iop_base) == 0)
9397 return int_pending;
9398
9399 if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
9400 return ERR;
9401 }
9402 if (asc_dvc->in_critical_cnt != 0) {
9403 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
9404 return ERR;
9405 }
9406 if (asc_dvc->is_in_int) {
9407 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
9408 return ERR;
9409 }
9410 asc_dvc->is_in_int = TRUE;
9411 ctrl_reg = AscGetChipControl(iop_base);
9412 saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
9413 CC_SINGLE_STEP | CC_DIAG | CC_TEST));
9414 chipstat = AscGetChipStatus(iop_base);
9415 if (chipstat & CSW_SCSI_RESET_LATCH) {
9416 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
9417 int i = 10;
9418 int_pending = TRUE;
9419 asc_dvc->sdtr_done = 0;
9420 saved_ctrl_reg &= (uchar)(~CC_HALT);
9421 while ((AscGetChipStatus(iop_base) &
9422 CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
9423 mdelay(100);
9424 }
9425 AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
9426 AscSetChipControl(iop_base, CC_HALT);
9427 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
9428 AscSetChipStatus(iop_base, 0);
9429 chipstat = AscGetChipStatus(iop_base);
9430 }
9431 }
9432 saved_ram_addr = AscGetChipLramAddr(iop_base);
9433 host_flag = AscReadLramByte(iop_base,
9434 ASCV_HOST_FLAG_B) &
9435 (uchar)(~ASC_HOST_FLAG_IN_ISR);
9436 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
9437 (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
9438 if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
9439 AscAckInterrupt(iop_base);
9440 int_pending = TRUE;
9441 if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
9442 if (AscIsrChipHalted(asc_dvc) == ERR) {
9443 goto ISR_REPORT_QDONE_FATAL_ERROR;
9444 } else {
9445 saved_ctrl_reg &= (uchar)(~CC_HALT);
9446 }
9447 } else {
9448 ISR_REPORT_QDONE_FATAL_ERROR:
9449 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
9450 while (((status =
9451 AscIsrQDone(asc_dvc)) & 0x01) != 0) {
9452 }
9453 } else {
9454 do {
9455 if ((status =
9456 AscIsrQDone(asc_dvc)) == 1) {
9457 break;
9458 }
9459 } while (status == 0x11);
9460 }
9461 if ((status & 0x80) != 0)
9462 int_pending = ERR;
9463 }
9464 }
9465 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
9466 AscSetChipLramAddr(iop_base, saved_ram_addr);
9467 AscSetChipControl(iop_base, saved_ctrl_reg);
9468 asc_dvc->is_in_int = FALSE;
9469 return int_pending;
9470}
9471
9472/*
9473 * advansys_reset()
9474 *
9475 * Reset the bus associated with the command 'scp'.
9476 *
9477 * This function runs its own thread. Interrupts must be blocked but
9478 * sleeping is allowed and no locking other than for host structures is
9479 * required. Returns SUCCESS or FAILED.
9480 */
9481static int advansys_reset(struct scsi_cmnd *scp)
9482{
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009483 struct Scsi_Host *shost = scp->device->host;
Matthew Wilcoxd2411492007-10-02 21:55:31 -04009484 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009485 unsigned long flags;
Matthew Wilcox51219352007-10-02 21:55:22 -04009486 int status;
9487 int ret = SUCCESS;
9488
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009489 ASC_DBG(1, "0x%p\n", scp);
Matthew Wilcox51219352007-10-02 21:55:22 -04009490
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009491 ASC_STATS(shost, reset);
Matthew Wilcox51219352007-10-02 21:55:22 -04009492
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009493 scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009494
9495 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009496 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
Matthew Wilcox51219352007-10-02 21:55:22 -04009497
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009498 /* Reset the chip and SCSI bus. */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009499 ASC_DBG(1, "before AscInitAsc1000Driver()\n");
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009500 status = AscInitAsc1000Driver(asc_dvc);
Matthew Wilcox51219352007-10-02 21:55:22 -04009501
9502 /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009503 if (asc_dvc->err_code) {
9504 scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
9505 "0x%x\n", asc_dvc->err_code);
Matthew Wilcox51219352007-10-02 21:55:22 -04009506 ret = FAILED;
9507 } else if (status) {
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009508 scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
9509 "0x%x\n", status);
Matthew Wilcox51219352007-10-02 21:55:22 -04009510 } else {
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009511 scmd_printk(KERN_INFO, scp, "SCSI bus reset "
9512 "successful\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009513 }
9514
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009515 ASC_DBG(1, "after AscInitAsc1000Driver()\n");
Matthew Wilcoxf092d222007-10-02 21:55:34 -04009516 spin_lock_irqsave(shost->host_lock, flags);
Matthew Wilcox51219352007-10-02 21:55:22 -04009517 } else {
9518 /*
Matthew Wilcox51219352007-10-02 21:55:22 -04009519 * If the suggest reset bus flags are set, then reset the bus.
9520 * Otherwise only reset the device.
9521 */
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009522 ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
Matthew Wilcox51219352007-10-02 21:55:22 -04009523
9524 /*
9525 * Reset the target's SCSI bus.
9526 */
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009527 ASC_DBG(1, "before AdvResetChipAndSB()\n");
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009528 switch (AdvResetChipAndSB(adv_dvc)) {
Matthew Wilcox51219352007-10-02 21:55:22 -04009529 case ASC_TRUE:
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009530 scmd_printk(KERN_INFO, scp, "SCSI bus reset "
9531 "successful\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009532 break;
9533 case ASC_FALSE:
9534 default:
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009535 scmd_printk(KERN_INFO, scp, "SCSI bus reset error\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009536 ret = FAILED;
9537 break;
9538 }
Matthew Wilcoxf092d222007-10-02 21:55:34 -04009539 spin_lock_irqsave(shost->host_lock, flags);
Matthew Wilcox52fa0772007-10-02 21:55:26 -04009540 AdvISR(adv_dvc);
Matthew Wilcox51219352007-10-02 21:55:22 -04009541 }
Matthew Wilcox51219352007-10-02 21:55:22 -04009542
9543 /* Save the time of the most recently completed reset. */
9544 boardp->last_reset = jiffies;
Matthew Wilcoxf092d222007-10-02 21:55:34 -04009545 spin_unlock_irqrestore(shost->host_lock, flags);
Matthew Wilcox51219352007-10-02 21:55:22 -04009546
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009547 ASC_DBG(1, "ret %d\n", ret);
Matthew Wilcox51219352007-10-02 21:55:22 -04009548
9549 return ret;
9550}
9551
9552/*
9553 * advansys_biosparam()
9554 *
9555 * Translate disk drive geometry if the "BIOS greater than 1 GB"
9556 * support is enabled for a drive.
9557 *
9558 * ip (information pointer) is an int array with the following definition:
9559 * ip[0]: heads
9560 * ip[1]: sectors
9561 * ip[2]: cylinders
9562 */
9563static int
9564advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
9565 sector_t capacity, int ip[])
9566{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04009567 struct asc_board *boardp = shost_priv(sdev->host);
Matthew Wilcox51219352007-10-02 21:55:22 -04009568
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009569 ASC_DBG(1, "begin\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009570 ASC_STATS(sdev->host, biosparam);
Matthew Wilcox51219352007-10-02 21:55:22 -04009571 if (ASC_NARROW_BOARD(boardp)) {
9572 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
9573 ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
9574 ip[0] = 255;
9575 ip[1] = 63;
9576 } else {
9577 ip[0] = 64;
9578 ip[1] = 32;
9579 }
9580 } else {
9581 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
9582 BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
9583 ip[0] = 255;
9584 ip[1] = 63;
9585 } else {
9586 ip[0] = 64;
9587 ip[1] = 32;
9588 }
9589 }
9590 ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009591 ASC_DBG(1, "end\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009592 return 0;
9593}
9594
9595/*
9596 * First-level interrupt handler.
9597 *
9598 * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
9599 */
9600static irqreturn_t advansys_interrupt(int irq, void *dev_id)
9601{
Matthew Wilcox51219352007-10-02 21:55:22 -04009602 struct Scsi_Host *shost = dev_id;
Matthew Wilcoxd2411492007-10-02 21:55:31 -04009603 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox51219352007-10-02 21:55:22 -04009604 irqreturn_t result = IRQ_NONE;
9605
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009606 ASC_DBG(2, "boardp 0x%p\n", boardp);
Matthew Wilcoxf092d222007-10-02 21:55:34 -04009607 spin_lock(shost->host_lock);
Matthew Wilcox51219352007-10-02 21:55:22 -04009608 if (ASC_NARROW_BOARD(boardp)) {
9609 if (AscIsIntPending(shost->io_port)) {
9610 result = IRQ_HANDLED;
9611 ASC_STATS(shost, interrupt);
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009612 ASC_DBG(1, "before AscISR()\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009613 AscISR(&boardp->dvc_var.asc_dvc_var);
9614 }
9615 } else {
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009616 ASC_DBG(1, "before AdvISR()\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009617 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
9618 result = IRQ_HANDLED;
9619 ASC_STATS(shost, interrupt);
9620 }
9621 }
Matthew Wilcoxf092d222007-10-02 21:55:34 -04009622 spin_unlock(shost->host_lock);
Matthew Wilcox51219352007-10-02 21:55:22 -04009623
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009624 ASC_DBG(1, "end\n");
Matthew Wilcox51219352007-10-02 21:55:22 -04009625 return result;
9626}
9627
9628static int AscHostReqRiscHalt(PortAddr iop_base)
9629{
9630 int count = 0;
9631 int sta = 0;
9632 uchar saved_stop_code;
9633
9634 if (AscIsChipHalted(iop_base))
9635 return (1);
9636 saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
9637 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
9638 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
9639 do {
9640 if (AscIsChipHalted(iop_base)) {
9641 sta = 1;
9642 break;
9643 }
9644 mdelay(100);
9645 } while (count++ < 20);
9646 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
9647 return (sta);
9648}
9649
9650static int
9651AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
9652{
9653 int sta = FALSE;
9654
9655 if (AscHostReqRiscHalt(iop_base)) {
9656 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
9657 AscStartChip(iop_base);
9658 }
9659 return sta;
9660}
9661
9662static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
9663{
9664 char type = sdev->type;
9665 ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
9666
9667 if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
9668 return;
9669 if (asc_dvc->init_sdtr & tid_bits)
9670 return;
9671
9672 if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
9673 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
9674
9675 asc_dvc->pci_fix_asyn_xfer |= tid_bits;
9676 if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
9677 (type == TYPE_ROM) || (type == TYPE_TAPE))
9678 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
9679
9680 if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
9681 AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
9682 ASYN_SDTR_DATA_FIX_PCI_REV_AB);
9683}
9684
9685static void
9686advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
9687{
9688 ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
9689 ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
9690
9691 if (sdev->lun == 0) {
9692 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
9693 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
9694 asc_dvc->init_sdtr |= tid_bit;
9695 } else {
9696 asc_dvc->init_sdtr &= ~tid_bit;
9697 }
9698
9699 if (orig_init_sdtr != asc_dvc->init_sdtr)
9700 AscAsyncFix(asc_dvc, sdev);
9701 }
9702
9703 if (sdev->tagged_supported) {
9704 if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
9705 if (sdev->lun == 0) {
9706 asc_dvc->cfg->can_tagged_qng |= tid_bit;
9707 asc_dvc->use_tagged_qng |= tid_bit;
9708 }
9709 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
9710 asc_dvc->max_dvc_qng[sdev->id]);
9711 }
9712 } else {
9713 if (sdev->lun == 0) {
9714 asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
9715 asc_dvc->use_tagged_qng &= ~tid_bit;
9716 }
9717 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
9718 }
9719
9720 if ((sdev->lun == 0) &&
9721 (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
9722 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
9723 asc_dvc->cfg->disc_enable);
9724 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
9725 asc_dvc->use_tagged_qng);
9726 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
9727 asc_dvc->cfg->can_tagged_qng);
9728
9729 asc_dvc->max_dvc_qng[sdev->id] =
9730 asc_dvc->cfg->max_tag_qng[sdev->id];
9731 AscWriteLramByte(asc_dvc->iop_base,
9732 (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
9733 asc_dvc->max_dvc_qng[sdev->id]);
9734 }
9735}
9736
9737/*
9738 * Wide Transfers
9739 *
9740 * If the EEPROM enabled WDTR for the device and the device supports wide
9741 * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
9742 * write the new value to the microcode.
9743 */
9744static void
9745advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
9746{
9747 unsigned short cfg_word;
9748 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
9749 if ((cfg_word & tidmask) != 0)
9750 return;
9751
9752 cfg_word |= tidmask;
9753 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
9754
9755 /*
9756 * Clear the microcode SDTR and WDTR negotiation done indicators for
9757 * the target to cause it to negotiate with the new setting set above.
9758 * WDTR when accepted causes the target to enter asynchronous mode, so
9759 * SDTR must be negotiated.
9760 */
9761 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9762 cfg_word &= ~tidmask;
9763 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9764 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
9765 cfg_word &= ~tidmask;
9766 AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
9767}
9768
9769/*
9770 * Synchronous Transfers
9771 *
9772 * If the EEPROM enabled SDTR for the device and the device
9773 * supports synchronous transfers, then turn on the device's
9774 * 'sdtr_able' bit. Write the new value to the microcode.
9775 */
9776static void
9777advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
9778{
9779 unsigned short cfg_word;
9780 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
9781 if ((cfg_word & tidmask) != 0)
9782 return;
9783
9784 cfg_word |= tidmask;
9785 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
9786
9787 /*
9788 * Clear the microcode "SDTR negotiation" done indicator for the
9789 * target to cause it to negotiate with the new setting set above.
9790 */
9791 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9792 cfg_word &= ~tidmask;
9793 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
9794}
9795
9796/*
9797 * PPR (Parallel Protocol Request) Capable
9798 *
9799 * If the device supports DT mode, then it must be PPR capable.
9800 * The PPR message will be used in place of the SDTR and WDTR
9801 * messages to negotiate synchronous speed and offset, transfer
9802 * width, and protocol options.
9803 */
9804static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
9805 AdvPortAddr iop_base, unsigned short tidmask)
9806{
9807 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
9808 adv_dvc->ppr_able |= tidmask;
9809 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
9810}
9811
9812static void
9813advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
9814{
9815 AdvPortAddr iop_base = adv_dvc->iop_base;
9816 unsigned short tidmask = 1 << sdev->id;
9817
9818 if (sdev->lun == 0) {
9819 /*
9820 * Handle WDTR, SDTR, and Tag Queuing. If the feature
9821 * is enabled in the EEPROM and the device supports the
9822 * feature, then enable it in the microcode.
9823 */
9824
9825 if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
9826 advansys_wide_enable_wdtr(iop_base, tidmask);
9827 if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
9828 advansys_wide_enable_sdtr(iop_base, tidmask);
9829 if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
9830 advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
9831
9832 /*
9833 * Tag Queuing is disabled for the BIOS which runs in polled
9834 * mode and would see no benefit from Tag Queuing. Also by
9835 * disabling Tag Queuing in the BIOS devices with Tag Queuing
9836 * bugs will at least work with the BIOS.
9837 */
9838 if ((adv_dvc->tagqng_able & tidmask) &&
9839 sdev->tagged_supported) {
9840 unsigned short cfg_word;
9841 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
9842 cfg_word |= tidmask;
9843 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
9844 cfg_word);
9845 AdvWriteByteLram(iop_base,
9846 ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
9847 adv_dvc->max_dvc_qng);
9848 }
9849 }
9850
9851 if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
9852 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
9853 adv_dvc->max_dvc_qng);
9854 } else {
9855 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
9856 }
9857}
9858
9859/*
9860 * Set the number of commands to queue per device for the
9861 * specified host adapter.
9862 */
9863static int advansys_slave_configure(struct scsi_device *sdev)
9864{
Matthew Wilcoxd2411492007-10-02 21:55:31 -04009865 struct asc_board *boardp = shost_priv(sdev->host);
Matthew Wilcox51219352007-10-02 21:55:22 -04009866
Matthew Wilcox51219352007-10-02 21:55:22 -04009867 if (ASC_NARROW_BOARD(boardp))
9868 advansys_narrow_slave_configure(sdev,
9869 &boardp->dvc_var.asc_dvc_var);
9870 else
9871 advansys_wide_slave_configure(sdev,
9872 &boardp->dvc_var.adv_dvc_var);
9873
9874 return 0;
9875}
9876
Matthew Wilcoxd2411492007-10-02 21:55:31 -04009877static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
Matthew Wilcox05848b62007-10-02 21:55:25 -04009878 struct asc_scsi_q *asc_scsi_q)
Matthew Wilcox51219352007-10-02 21:55:22 -04009879{
Matthew Wilcox05848b62007-10-02 21:55:25 -04009880 memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
Matthew Wilcox51219352007-10-02 21:55:22 -04009881
9882 /*
9883 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
9884 */
Matthew Wilcox05848b62007-10-02 21:55:25 -04009885 asc_scsi_q->q2.srb_ptr = ASC_VADDR_TO_U32(scp);
Matthew Wilcox51219352007-10-02 21:55:22 -04009886
9887 /*
9888 * Build the ASC_SCSI_Q request.
9889 */
Matthew Wilcox05848b62007-10-02 21:55:25 -04009890 asc_scsi_q->cdbptr = &scp->cmnd[0];
9891 asc_scsi_q->q2.cdb_len = scp->cmd_len;
9892 asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
9893 asc_scsi_q->q1.target_lun = scp->device->lun;
9894 asc_scsi_q->q2.target_ix =
Matthew Wilcox51219352007-10-02 21:55:22 -04009895 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
Matthew Wilcox05848b62007-10-02 21:55:25 -04009896 asc_scsi_q->q1.sense_addr =
Matthew Wilcox51219352007-10-02 21:55:22 -04009897 cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
Matthew Wilcox05848b62007-10-02 21:55:25 -04009898 asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
Matthew Wilcox51219352007-10-02 21:55:22 -04009899
9900 /*
9901 * If there are any outstanding requests for the current target,
9902 * then every 255th request send an ORDERED request. This heuristic
9903 * tries to retain the benefit of request sorting while preventing
9904 * request starvation. 255 is the max number of tags or pending commands
9905 * a device may have outstanding.
9906 *
9907 * The request count is incremented below for every successfully
9908 * started request.
9909 *
9910 */
9911 if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
9912 (boardp->reqcnt[scp->device->id] % 255) == 0) {
Matthew Wilcox05848b62007-10-02 21:55:25 -04009913 asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
Matthew Wilcox51219352007-10-02 21:55:22 -04009914 } else {
Matthew Wilcox05848b62007-10-02 21:55:25 -04009915 asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
Matthew Wilcox51219352007-10-02 21:55:22 -04009916 }
9917
9918 /*
9919 * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
9920 * buffer command.
9921 */
9922 if (scp->use_sg == 0) {
9923 /*
9924 * CDB request of single contiguous buffer.
9925 */
9926 ASC_STATS(scp->device->host, cont_cnt);
9927 scp->SCp.dma_handle = scp->request_bufflen ?
9928 dma_map_single(boardp->dev, scp->request_buffer,
9929 scp->request_bufflen,
9930 scp->sc_data_direction) : 0;
Matthew Wilcox05848b62007-10-02 21:55:25 -04009931 asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
9932 asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
Matthew Wilcox51219352007-10-02 21:55:22 -04009933 ASC_STATS_ADD(scp->device->host, cont_xfer,
9934 ASC_CEILING(scp->request_bufflen, 512));
Matthew Wilcox05848b62007-10-02 21:55:25 -04009935 asc_scsi_q->q1.sg_queue_cnt = 0;
9936 asc_scsi_q->sg_head = NULL;
Matthew Wilcox51219352007-10-02 21:55:22 -04009937 } else {
9938 /*
9939 * CDB scatter-gather request list.
9940 */
9941 int sgcnt;
9942 int use_sg;
9943 struct scatterlist *slp;
Matthew Wilcox05848b62007-10-02 21:55:25 -04009944 struct asc_sg_head *asc_sg_head;
Matthew Wilcox51219352007-10-02 21:55:22 -04009945
9946 slp = (struct scatterlist *)scp->request_buffer;
9947 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
9948 scp->sc_data_direction);
9949
9950 if (use_sg > scp->device->host->sg_tablesize) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -04009951 scmd_printk(KERN_ERR, scp, "use_sg %d > "
9952 "sg_tablesize %d\n", use_sg,
9953 scp->device->host->sg_tablesize);
Matthew Wilcox51219352007-10-02 21:55:22 -04009954 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
9955 scp->sc_data_direction);
9956 scp->result = HOST_BYTE(DID_ERROR);
9957 return ASC_ERROR;
9958 }
9959
9960 ASC_STATS(scp->device->host, sg_cnt);
9961
Matthew Wilcox05848b62007-10-02 21:55:25 -04009962 asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
9963 use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
9964 if (!asc_sg_head) {
9965 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
9966 scp->sc_data_direction);
9967 scp->result = HOST_BYTE(DID_SOFT_ERROR);
9968 return ASC_ERROR;
9969 }
Matthew Wilcox51219352007-10-02 21:55:22 -04009970
Matthew Wilcox05848b62007-10-02 21:55:25 -04009971 asc_scsi_q->q1.cntl |= QC_SG_HEAD;
9972 asc_scsi_q->sg_head = asc_sg_head;
9973 asc_scsi_q->q1.data_cnt = 0;
9974 asc_scsi_q->q1.data_addr = 0;
Matthew Wilcox51219352007-10-02 21:55:22 -04009975 /* This is a byte value, otherwise it would need to be swapped. */
Matthew Wilcox05848b62007-10-02 21:55:25 -04009976 asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
Matthew Wilcox51219352007-10-02 21:55:22 -04009977 ASC_STATS_ADD(scp->device->host, sg_elem,
Matthew Wilcox05848b62007-10-02 21:55:25 -04009978 asc_sg_head->entry_cnt);
Matthew Wilcox51219352007-10-02 21:55:22 -04009979
9980 /*
9981 * Convert scatter-gather list into ASC_SG_HEAD list.
9982 */
9983 for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
Matthew Wilcox05848b62007-10-02 21:55:25 -04009984 asc_sg_head->sg_list[sgcnt].addr =
Matthew Wilcox51219352007-10-02 21:55:22 -04009985 cpu_to_le32(sg_dma_address(slp));
Matthew Wilcox05848b62007-10-02 21:55:25 -04009986 asc_sg_head->sg_list[sgcnt].bytes =
Matthew Wilcox51219352007-10-02 21:55:22 -04009987 cpu_to_le32(sg_dma_len(slp));
9988 ASC_STATS_ADD(scp->device->host, sg_xfer,
9989 ASC_CEILING(sg_dma_len(slp), 512));
9990 }
9991 }
9992
Matthew Wilcoxb352f922007-10-02 21:55:33 -04009993 ASC_DBG_PRT_ASC_SCSI_Q(2, asc_scsi_q);
Matthew Wilcox51219352007-10-02 21:55:22 -04009994 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
9995
9996 return ASC_NOERROR;
9997}
9998
9999/*
10000 * Build scatter-gather list for Adv Library (Wide Board).
10001 *
10002 * Additional ADV_SG_BLOCK structures will need to be allocated
10003 * if the total number of scatter-gather elements exceeds
10004 * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
10005 * assumed to be physically contiguous.
10006 *
10007 * Return:
10008 * ADV_SUCCESS(1) - SG List successfully created
10009 * ADV_ERROR(-1) - SG List creation failed
10010 */
10011static int
Matthew Wilcoxd2411492007-10-02 21:55:31 -040010012adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
Matthew Wilcox51219352007-10-02 21:55:22 -040010013 int use_sg)
10014{
10015 adv_sgblk_t *sgblkp;
10016 ADV_SCSI_REQ_Q *scsiqp;
10017 struct scatterlist *slp;
10018 int sg_elem_cnt;
10019 ADV_SG_BLOCK *sg_block, *prev_sg_block;
10020 ADV_PADDR sg_block_paddr;
10021 int i;
10022
10023 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
10024 slp = (struct scatterlist *)scp->request_buffer;
10025 sg_elem_cnt = use_sg;
10026 prev_sg_block = NULL;
10027 reqp->sgblkp = NULL;
10028
10029 for (;;) {
10030 /*
10031 * Allocate a 'adv_sgblk_t' structure from the board free
10032 * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
10033 * (15) scatter-gather elements.
10034 */
10035 if ((sgblkp = boardp->adv_sgblkp) == NULL) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040010036 ASC_DBG(1, "no free adv_sgblk_t\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040010037 ASC_STATS(scp->device->host, adv_build_nosg);
10038
10039 /*
10040 * Allocation failed. Free 'adv_sgblk_t' structures
10041 * already allocated for the request.
10042 */
10043 while ((sgblkp = reqp->sgblkp) != NULL) {
10044 /* Remove 'sgblkp' from the request list. */
10045 reqp->sgblkp = sgblkp->next_sgblkp;
10046
10047 /* Add 'sgblkp' to the board free list. */
10048 sgblkp->next_sgblkp = boardp->adv_sgblkp;
10049 boardp->adv_sgblkp = sgblkp;
10050 }
10051 return ASC_BUSY;
10052 }
10053
10054 /* Complete 'adv_sgblk_t' board allocation. */
10055 boardp->adv_sgblkp = sgblkp->next_sgblkp;
10056 sgblkp->next_sgblkp = NULL;
10057
10058 /*
10059 * Get 8 byte aligned virtual and physical addresses
10060 * for the allocated ADV_SG_BLOCK structure.
10061 */
10062 sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
10063 sg_block_paddr = virt_to_bus(sg_block);
10064
10065 /*
10066 * Check if this is the first 'adv_sgblk_t' for the
10067 * request.
10068 */
10069 if (reqp->sgblkp == NULL) {
10070 /* Request's first scatter-gather block. */
10071 reqp->sgblkp = sgblkp;
10072
10073 /*
10074 * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
10075 * address pointers.
10076 */
10077 scsiqp->sg_list_ptr = sg_block;
10078 scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
10079 } else {
10080 /* Request's second or later scatter-gather block. */
10081 sgblkp->next_sgblkp = reqp->sgblkp;
10082 reqp->sgblkp = sgblkp;
10083
10084 /*
10085 * Point the previous ADV_SG_BLOCK structure to
10086 * the newly allocated ADV_SG_BLOCK structure.
10087 */
10088 prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
10089 }
10090
10091 for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
10092 sg_block->sg_list[i].sg_addr =
10093 cpu_to_le32(sg_dma_address(slp));
10094 sg_block->sg_list[i].sg_count =
10095 cpu_to_le32(sg_dma_len(slp));
10096 ASC_STATS_ADD(scp->device->host, sg_xfer,
10097 ASC_CEILING(sg_dma_len(slp), 512));
10098
10099 if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
10100 sg_block->sg_cnt = i + 1;
10101 sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
10102 return ADV_SUCCESS;
10103 }
10104 slp++;
10105 }
10106 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
10107 prev_sg_block = sg_block;
10108 }
10109}
10110
10111/*
10112 * Build a request structure for the Adv Library (Wide Board).
10113 *
10114 * If an adv_req_t can not be allocated to issue the request,
10115 * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
10116 *
10117 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
10118 * microcode for DMA addresses or math operations are byte swapped
10119 * to little-endian order.
10120 */
10121static int
Matthew Wilcoxd2411492007-10-02 21:55:31 -040010122adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
Matthew Wilcox51219352007-10-02 21:55:22 -040010123 ADV_SCSI_REQ_Q **adv_scsiqpp)
10124{
10125 adv_req_t *reqp;
10126 ADV_SCSI_REQ_Q *scsiqp;
10127 int i;
10128 int ret;
10129
10130 /*
10131 * Allocate an adv_req_t structure from the board to execute
10132 * the command.
10133 */
10134 if (boardp->adv_reqp == NULL) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040010135 ASC_DBG(1, "no free adv_req_t\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040010136 ASC_STATS(scp->device->host, adv_build_noreq);
10137 return ASC_BUSY;
10138 } else {
10139 reqp = boardp->adv_reqp;
10140 boardp->adv_reqp = reqp->next_reqp;
10141 reqp->next_reqp = NULL;
10142 }
10143
10144 /*
10145 * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
10146 */
10147 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
10148
10149 /*
10150 * Initialize the structure.
10151 */
10152 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
10153
10154 /*
10155 * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
10156 */
10157 scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
10158
10159 /*
10160 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
10161 */
10162 reqp->cmndp = scp;
10163
10164 /*
10165 * Build the ADV_SCSI_REQ_Q request.
10166 */
10167
10168 /* Set CDB length and copy it to the request structure. */
10169 scsiqp->cdb_len = scp->cmd_len;
10170 /* Copy first 12 CDB bytes to cdb[]. */
10171 for (i = 0; i < scp->cmd_len && i < 12; i++) {
10172 scsiqp->cdb[i] = scp->cmnd[i];
10173 }
10174 /* Copy last 4 CDB bytes, if present, to cdb16[]. */
10175 for (; i < scp->cmd_len; i++) {
10176 scsiqp->cdb16[i - 12] = scp->cmnd[i];
10177 }
10178
10179 scsiqp->target_id = scp->device->id;
10180 scsiqp->target_lun = scp->device->lun;
10181
10182 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
10183 scsiqp->sense_len = sizeof(scp->sense_buffer);
10184
10185 /*
10186 * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
10187 * buffer command.
10188 */
10189
10190 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
10191 scsiqp->vdata_addr = scp->request_buffer;
10192 scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
10193
10194 if (scp->use_sg == 0) {
10195 /*
10196 * CDB request of single contiguous buffer.
10197 */
10198 reqp->sgblkp = NULL;
10199 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
10200 if (scp->request_bufflen) {
10201 scsiqp->vdata_addr = scp->request_buffer;
10202 scp->SCp.dma_handle =
10203 dma_map_single(boardp->dev, scp->request_buffer,
10204 scp->request_bufflen,
10205 scp->sc_data_direction);
10206 } else {
10207 scsiqp->vdata_addr = NULL;
10208 scp->SCp.dma_handle = 0;
10209 }
10210 scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
10211 scsiqp->sg_list_ptr = NULL;
10212 scsiqp->sg_real_addr = 0;
10213 ASC_STATS(scp->device->host, cont_cnt);
10214 ASC_STATS_ADD(scp->device->host, cont_xfer,
10215 ASC_CEILING(scp->request_bufflen, 512));
10216 } else {
10217 /*
10218 * CDB scatter-gather request list.
10219 */
10220 struct scatterlist *slp;
10221 int use_sg;
10222
10223 slp = (struct scatterlist *)scp->request_buffer;
10224 use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
10225 scp->sc_data_direction);
10226
10227 if (use_sg > ADV_MAX_SG_LIST) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040010228 scmd_printk(KERN_ERR, scp, "use_sg %d > "
10229 "ADV_MAX_SG_LIST %d\n", use_sg,
Matthew Wilcox51219352007-10-02 21:55:22 -040010230 scp->device->host->sg_tablesize);
10231 dma_unmap_sg(boardp->dev, slp, scp->use_sg,
10232 scp->sc_data_direction);
10233 scp->result = HOST_BYTE(DID_ERROR);
10234
10235 /*
10236 * Free the 'adv_req_t' structure by adding it back
10237 * to the board free list.
10238 */
10239 reqp->next_reqp = boardp->adv_reqp;
10240 boardp->adv_reqp = reqp;
10241
10242 return ASC_ERROR;
10243 }
10244
10245 ret = adv_get_sglist(boardp, reqp, scp, use_sg);
10246 if (ret != ADV_SUCCESS) {
10247 /*
10248 * Free the adv_req_t structure by adding it back to
10249 * the board free list.
10250 */
10251 reqp->next_reqp = boardp->adv_reqp;
10252 boardp->adv_reqp = reqp;
10253
10254 return ret;
10255 }
10256
10257 ASC_STATS(scp->device->host, sg_cnt);
10258 ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
10259 }
10260
10261 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
10262 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
10263
10264 *adv_scsiqpp = scsiqp;
10265
10266 return ASC_NOERROR;
10267}
10268
10269static int AscSgListToQueue(int sg_list)
10270{
10271 int n_sg_list_qs;
10272
10273 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
10274 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
10275 n_sg_list_qs++;
10276 return n_sg_list_qs + 1;
10277}
10278
10279static uint
10280AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
10281{
10282 uint cur_used_qs;
10283 uint cur_free_qs;
10284 ASC_SCSI_BIT_ID_TYPE target_id;
10285 uchar tid_no;
10286
10287 target_id = ASC_TIX_TO_TARGET_ID(target_ix);
10288 tid_no = ASC_TIX_TO_TID(target_ix);
10289 if ((asc_dvc->unit_not_ready & target_id) ||
10290 (asc_dvc->queue_full_or_busy & target_id)) {
10291 return 0;
10292 }
10293 if (n_qs == 1) {
10294 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10295 (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
10296 } else {
10297 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10298 (uint) ASC_MIN_FREE_Q;
10299 }
10300 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
10301 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
10302 if (asc_dvc->cur_dvc_qng[tid_no] >=
10303 asc_dvc->max_dvc_qng[tid_no]) {
10304 return 0;
10305 }
10306 return cur_free_qs;
10307 }
10308 if (n_qs > 1) {
10309 if ((n_qs > asc_dvc->last_q_shortage)
10310 && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
10311 asc_dvc->last_q_shortage = n_qs;
10312 }
10313 }
10314 return 0;
10315}
10316
10317static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
10318{
10319 ushort q_addr;
10320 uchar next_qp;
10321 uchar q_status;
10322
10323 q_addr = ASC_QNO_TO_QADDR(free_q_head);
10324 q_status = (uchar)AscReadLramByte(iop_base,
10325 (ushort)(q_addr +
10326 ASC_SCSIQ_B_STATUS));
10327 next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
10328 if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
10329 return next_qp;
10330 return ASC_QLINK_END;
10331}
10332
10333static uchar
10334AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
10335{
10336 uchar i;
10337
10338 for (i = 0; i < n_free_q; i++) {
10339 free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
10340 if (free_q_head == ASC_QLINK_END)
10341 break;
10342 }
10343 return free_q_head;
10344}
10345
10346/*
10347 * void
10348 * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
10349 *
10350 * Calling/Exit State:
10351 * none
10352 *
10353 * Description:
10354 * Output an ASC_SCSI_Q structure to the chip
10355 */
10356static void
10357DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
10358{
10359 int i;
10360
10361 ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
10362 AscSetChipLramAddr(iop_base, s_addr);
10363 for (i = 0; i < 2 * words; i += 2) {
10364 if (i == 4 || i == 20) {
10365 continue;
10366 }
10367 outpw(iop_base + IOP_RAM_DATA,
10368 ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
10369 }
10370}
10371
10372static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
10373{
10374 ushort q_addr;
10375 uchar tid_no;
10376 uchar sdtr_data;
10377 uchar syn_period_ix;
10378 uchar syn_offset;
10379 PortAddr iop_base;
10380
10381 iop_base = asc_dvc->iop_base;
10382 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
10383 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
10384 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
10385 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10386 syn_period_ix =
10387 (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
10388 syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
10389 AscMsgOutSDTR(asc_dvc,
10390 asc_dvc->sdtr_period_tbl[syn_period_ix],
10391 syn_offset);
10392 scsiq->q1.cntl |= QC_MSG_OUT;
10393 }
10394 q_addr = ASC_QNO_TO_QADDR(q_no);
10395 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
10396 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
10397 }
10398 scsiq->q1.status = QS_FREE;
10399 AscMemWordCopyPtrToLram(iop_base,
10400 q_addr + ASC_SCSIQ_CDB_BEG,
10401 (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
10402
10403 DvcPutScsiQ(iop_base,
10404 q_addr + ASC_SCSIQ_CPY_BEG,
10405 (uchar *)&scsiq->q1.cntl,
10406 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
10407 AscWriteLramWord(iop_base,
10408 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
10409 (ushort)(((ushort)scsiq->q1.
10410 q_no << 8) | (ushort)QS_READY));
10411 return 1;
10412}
10413
10414static int
10415AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
10416{
10417 int sta;
10418 int i;
10419 ASC_SG_HEAD *sg_head;
10420 ASC_SG_LIST_Q scsi_sg_q;
10421 ASC_DCNT saved_data_addr;
10422 ASC_DCNT saved_data_cnt;
10423 PortAddr iop_base;
10424 ushort sg_list_dwords;
10425 ushort sg_index;
10426 ushort sg_entry_cnt;
10427 ushort q_addr;
10428 uchar next_qp;
10429
10430 iop_base = asc_dvc->iop_base;
10431 sg_head = scsiq->sg_head;
10432 saved_data_addr = scsiq->q1.data_addr;
10433 saved_data_cnt = scsiq->q1.data_cnt;
10434 scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
10435 scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
10436#if CC_VERY_LONG_SG_LIST
10437 /*
10438 * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
10439 * then not all SG elements will fit in the allocated queues.
10440 * The rest of the SG elements will be copied when the RISC
10441 * completes the SG elements that fit and halts.
10442 */
10443 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
10444 /*
10445 * Set sg_entry_cnt to be the number of SG elements that
10446 * will fit in the allocated SG queues. It is minus 1, because
10447 * the first SG element is handled above. ASC_MAX_SG_LIST is
10448 * already inflated by 1 to account for this. For example it
10449 * may be 50 which is 1 + 7 queues * 7 SG elements.
10450 */
10451 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
10452
10453 /*
10454 * Keep track of remaining number of SG elements that will
10455 * need to be handled from a_isr.c.
10456 */
10457 scsiq->remain_sg_entry_cnt =
10458 sg_head->entry_cnt - ASC_MAX_SG_LIST;
10459 } else {
10460#endif /* CC_VERY_LONG_SG_LIST */
10461 /*
10462 * Set sg_entry_cnt to be the number of SG elements that
10463 * will fit in the allocated SG queues. It is minus 1, because
10464 * the first SG element is handled above.
10465 */
10466 sg_entry_cnt = sg_head->entry_cnt - 1;
10467#if CC_VERY_LONG_SG_LIST
10468 }
10469#endif /* CC_VERY_LONG_SG_LIST */
10470 if (sg_entry_cnt != 0) {
10471 scsiq->q1.cntl |= QC_SG_HEAD;
10472 q_addr = ASC_QNO_TO_QADDR(q_no);
10473 sg_index = 1;
10474 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
10475 scsi_sg_q.sg_head_qp = q_no;
10476 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
10477 for (i = 0; i < sg_head->queue_cnt; i++) {
10478 scsi_sg_q.seq_no = i + 1;
10479 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
10480 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
10481 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
10482 if (i == 0) {
10483 scsi_sg_q.sg_list_cnt =
10484 ASC_SG_LIST_PER_Q;
10485 scsi_sg_q.sg_cur_list_cnt =
10486 ASC_SG_LIST_PER_Q;
10487 } else {
10488 scsi_sg_q.sg_list_cnt =
10489 ASC_SG_LIST_PER_Q - 1;
10490 scsi_sg_q.sg_cur_list_cnt =
10491 ASC_SG_LIST_PER_Q - 1;
10492 }
10493 } else {
10494#if CC_VERY_LONG_SG_LIST
10495 /*
10496 * This is the last SG queue in the list of
10497 * allocated SG queues. If there are more
10498 * SG elements than will fit in the allocated
10499 * queues, then set the QCSG_SG_XFER_MORE flag.
10500 */
10501 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
10502 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
10503 } else {
10504#endif /* CC_VERY_LONG_SG_LIST */
10505 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
10506#if CC_VERY_LONG_SG_LIST
10507 }
10508#endif /* CC_VERY_LONG_SG_LIST */
10509 sg_list_dwords = sg_entry_cnt << 1;
10510 if (i == 0) {
10511 scsi_sg_q.sg_list_cnt = sg_entry_cnt;
10512 scsi_sg_q.sg_cur_list_cnt =
10513 sg_entry_cnt;
10514 } else {
10515 scsi_sg_q.sg_list_cnt =
10516 sg_entry_cnt - 1;
10517 scsi_sg_q.sg_cur_list_cnt =
10518 sg_entry_cnt - 1;
10519 }
10520 sg_entry_cnt = 0;
10521 }
10522 next_qp = AscReadLramByte(iop_base,
10523 (ushort)(q_addr +
10524 ASC_SCSIQ_B_FWD));
10525 scsi_sg_q.q_no = next_qp;
10526 q_addr = ASC_QNO_TO_QADDR(next_qp);
10527 AscMemWordCopyPtrToLram(iop_base,
10528 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
10529 (uchar *)&scsi_sg_q,
10530 sizeof(ASC_SG_LIST_Q) >> 1);
10531 AscMemDWordCopyPtrToLram(iop_base,
10532 q_addr + ASC_SGQ_LIST_BEG,
10533 (uchar *)&sg_head->
10534 sg_list[sg_index],
10535 sg_list_dwords);
10536 sg_index += ASC_SG_LIST_PER_Q;
10537 scsiq->next_sg_index = sg_index;
10538 }
10539 } else {
10540 scsiq->q1.cntl &= ~QC_SG_HEAD;
10541 }
10542 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
10543 scsiq->q1.data_addr = saved_data_addr;
10544 scsiq->q1.data_cnt = saved_data_cnt;
10545 return (sta);
10546}
10547
10548static int
10549AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
10550{
10551 PortAddr iop_base;
10552 uchar free_q_head;
10553 uchar next_qp;
10554 uchar tid_no;
10555 uchar target_ix;
10556 int sta;
10557
10558 iop_base = asc_dvc->iop_base;
10559 target_ix = scsiq->q2.target_ix;
10560 tid_no = ASC_TIX_TO_TID(target_ix);
10561 sta = 0;
10562 free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
10563 if (n_q_required > 1) {
10564 next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
10565 (uchar)n_q_required);
10566 if (next_qp != ASC_QLINK_END) {
10567 asc_dvc->last_q_shortage = 0;
10568 scsiq->sg_head->queue_cnt = n_q_required - 1;
10569 scsiq->q1.q_no = free_q_head;
10570 sta = AscPutReadySgListQueue(asc_dvc, scsiq,
10571 free_q_head);
10572 }
10573 } else if (n_q_required == 1) {
10574 next_qp = AscAllocFreeQueue(iop_base, free_q_head);
10575 if (next_qp != ASC_QLINK_END) {
10576 scsiq->q1.q_no = free_q_head;
10577 sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
10578 }
10579 }
10580 if (sta == 1) {
10581 AscPutVarFreeQHead(iop_base, next_qp);
10582 asc_dvc->cur_total_qng += n_q_required;
10583 asc_dvc->cur_dvc_qng[tid_no]++;
10584 }
10585 return sta;
10586}
10587
10588#define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
10589static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
10590 INQUIRY,
10591 REQUEST_SENSE,
10592 READ_CAPACITY,
10593 READ_TOC,
10594 MODE_SELECT,
10595 MODE_SENSE,
10596 MODE_SELECT_10,
10597 MODE_SENSE_10,
10598 0xFF,
10599 0xFF,
10600 0xFF,
10601 0xFF,
10602 0xFF,
10603 0xFF,
10604 0xFF,
10605 0xFF
10606};
10607
10608static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
10609{
10610 PortAddr iop_base;
10611 int sta;
10612 int n_q_required;
10613 int disable_syn_offset_one_fix;
10614 int i;
10615 ASC_PADDR addr;
10616 ushort sg_entry_cnt = 0;
10617 ushort sg_entry_cnt_minus_one = 0;
10618 uchar target_ix;
10619 uchar tid_no;
10620 uchar sdtr_data;
10621 uchar extra_bytes;
10622 uchar scsi_cmd;
10623 uchar disable_cmd;
10624 ASC_SG_HEAD *sg_head;
10625 ASC_DCNT data_cnt;
10626
10627 iop_base = asc_dvc->iop_base;
10628 sg_head = scsiq->sg_head;
10629 if (asc_dvc->err_code != 0)
10630 return (ERR);
10631 scsiq->q1.q_no = 0;
10632 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
10633 scsiq->q1.extra_bytes = 0;
10634 }
10635 sta = 0;
10636 target_ix = scsiq->q2.target_ix;
10637 tid_no = ASC_TIX_TO_TID(target_ix);
10638 n_q_required = 1;
10639 if (scsiq->cdbptr[0] == REQUEST_SENSE) {
10640 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
10641 asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
10642 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10643 AscMsgOutSDTR(asc_dvc,
10644 asc_dvc->
10645 sdtr_period_tbl[(sdtr_data >> 4) &
10646 (uchar)(asc_dvc->
10647 max_sdtr_index -
10648 1)],
10649 (uchar)(sdtr_data & (uchar)
10650 ASC_SYN_MAX_OFFSET));
10651 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
10652 }
10653 }
10654 if (asc_dvc->in_critical_cnt != 0) {
10655 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
10656 return (ERR);
10657 }
10658 asc_dvc->in_critical_cnt++;
10659 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
10660 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
10661 asc_dvc->in_critical_cnt--;
10662 return (ERR);
10663 }
10664#if !CC_VERY_LONG_SG_LIST
10665 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
10666 asc_dvc->in_critical_cnt--;
10667 return (ERR);
10668 }
10669#endif /* !CC_VERY_LONG_SG_LIST */
10670 if (sg_entry_cnt == 1) {
10671 scsiq->q1.data_addr =
10672 (ADV_PADDR)sg_head->sg_list[0].addr;
10673 scsiq->q1.data_cnt =
10674 (ADV_DCNT)sg_head->sg_list[0].bytes;
10675 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
10676 }
10677 sg_entry_cnt_minus_one = sg_entry_cnt - 1;
10678 }
10679 scsi_cmd = scsiq->cdbptr[0];
10680 disable_syn_offset_one_fix = FALSE;
10681 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
10682 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
10683 if (scsiq->q1.cntl & QC_SG_HEAD) {
10684 data_cnt = 0;
10685 for (i = 0; i < sg_entry_cnt; i++) {
10686 data_cnt +=
10687 (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
10688 bytes);
10689 }
10690 } else {
10691 data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
10692 }
10693 if (data_cnt != 0UL) {
10694 if (data_cnt < 512UL) {
10695 disable_syn_offset_one_fix = TRUE;
10696 } else {
10697 for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
10698 i++) {
10699 disable_cmd =
10700 _syn_offset_one_disable_cmd[i];
10701 if (disable_cmd == 0xFF) {
10702 break;
10703 }
10704 if (scsi_cmd == disable_cmd) {
10705 disable_syn_offset_one_fix =
10706 TRUE;
10707 break;
10708 }
10709 }
10710 }
10711 }
10712 }
10713 if (disable_syn_offset_one_fix) {
10714 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
10715 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
10716 ASC_TAG_FLAG_DISABLE_DISCONNECT);
10717 } else {
10718 scsiq->q2.tag_code &= 0x27;
10719 }
10720 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
10721 if (asc_dvc->bug_fix_cntl) {
10722 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
10723 if ((scsi_cmd == READ_6) ||
10724 (scsi_cmd == READ_10)) {
10725 addr =
10726 (ADV_PADDR)le32_to_cpu(sg_head->
10727 sg_list
10728 [sg_entry_cnt_minus_one].
10729 addr) +
10730 (ADV_DCNT)le32_to_cpu(sg_head->
10731 sg_list
10732 [sg_entry_cnt_minus_one].
10733 bytes);
10734 extra_bytes =
10735 (uchar)((ushort)addr & 0x0003);
10736 if ((extra_bytes != 0)
10737 &&
10738 ((scsiq->q2.
10739 tag_code &
10740 ASC_TAG_FLAG_EXTRA_BYTES)
10741 == 0)) {
10742 scsiq->q2.tag_code |=
10743 ASC_TAG_FLAG_EXTRA_BYTES;
10744 scsiq->q1.extra_bytes =
10745 extra_bytes;
10746 data_cnt =
10747 le32_to_cpu(sg_head->
10748 sg_list
10749 [sg_entry_cnt_minus_one].
10750 bytes);
10751 data_cnt -=
10752 (ASC_DCNT) extra_bytes;
10753 sg_head->
10754 sg_list
10755 [sg_entry_cnt_minus_one].
10756 bytes =
10757 cpu_to_le32(data_cnt);
10758 }
10759 }
10760 }
10761 }
10762 sg_head->entry_to_copy = sg_head->entry_cnt;
10763#if CC_VERY_LONG_SG_LIST
10764 /*
10765 * Set the sg_entry_cnt to the maximum possible. The rest of
10766 * the SG elements will be copied when the RISC completes the
10767 * SG elements that fit and halts.
10768 */
10769 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
10770 sg_entry_cnt = ASC_MAX_SG_LIST;
10771 }
10772#endif /* CC_VERY_LONG_SG_LIST */
10773 n_q_required = AscSgListToQueue(sg_entry_cnt);
10774 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
10775 (uint) n_q_required)
10776 || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
10777 if ((sta =
10778 AscSendScsiQueue(asc_dvc, scsiq,
10779 n_q_required)) == 1) {
10780 asc_dvc->in_critical_cnt--;
10781 return (sta);
10782 }
10783 }
10784 } else {
10785 if (asc_dvc->bug_fix_cntl) {
10786 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
10787 if ((scsi_cmd == READ_6) ||
10788 (scsi_cmd == READ_10)) {
10789 addr =
10790 le32_to_cpu(scsiq->q1.data_addr) +
10791 le32_to_cpu(scsiq->q1.data_cnt);
10792 extra_bytes =
10793 (uchar)((ushort)addr & 0x0003);
10794 if ((extra_bytes != 0)
10795 &&
10796 ((scsiq->q2.
10797 tag_code &
10798 ASC_TAG_FLAG_EXTRA_BYTES)
10799 == 0)) {
10800 data_cnt =
10801 le32_to_cpu(scsiq->q1.
10802 data_cnt);
10803 if (((ushort)data_cnt & 0x01FF)
10804 == 0) {
10805 scsiq->q2.tag_code |=
10806 ASC_TAG_FLAG_EXTRA_BYTES;
10807 data_cnt -= (ASC_DCNT)
10808 extra_bytes;
10809 scsiq->q1.data_cnt =
10810 cpu_to_le32
10811 (data_cnt);
10812 scsiq->q1.extra_bytes =
10813 extra_bytes;
10814 }
10815 }
10816 }
10817 }
10818 }
10819 n_q_required = 1;
10820 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
10821 ((scsiq->q1.cntl & QC_URGENT) != 0)) {
10822 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
10823 n_q_required)) == 1) {
10824 asc_dvc->in_critical_cnt--;
10825 return (sta);
10826 }
10827 }
10828 }
10829 asc_dvc->in_critical_cnt--;
10830 return (sta);
10831}
10832
10833/*
10834 * AdvExeScsiQueue() - Send a request to the RISC microcode program.
10835 *
10836 * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
10837 * add the carrier to the ICQ (Initiator Command Queue), and tickle the
10838 * RISC to notify it a new command is ready to be executed.
10839 *
10840 * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
10841 * set to SCSI_MAX_RETRY.
10842 *
10843 * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
10844 * for DMA addresses or math operations are byte swapped to little-endian
10845 * order.
10846 *
10847 * Return:
10848 * ADV_SUCCESS(1) - The request was successfully queued.
10849 * ADV_BUSY(0) - Resource unavailable; Retry again after pending
10850 * request completes.
10851 * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
10852 * host IC error.
10853 */
10854static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
10855{
10856 AdvPortAddr iop_base;
Matthew Wilcox51219352007-10-02 21:55:22 -040010857 ADV_PADDR req_paddr;
10858 ADV_CARR_T *new_carrp;
10859
10860 /*
10861 * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
10862 */
10863 if (scsiq->target_id > ADV_MAX_TID) {
10864 scsiq->host_status = QHSTA_M_INVALID_DEVICE;
10865 scsiq->done_status = QD_WITH_ERROR;
10866 return ADV_ERROR;
10867 }
10868
10869 iop_base = asc_dvc->iop_base;
10870
10871 /*
10872 * Allocate a carrier ensuring at least one carrier always
10873 * remains on the freelist and initialize fields.
10874 */
10875 if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
10876 return ADV_BUSY;
10877 }
10878 asc_dvc->carr_freelist = (ADV_CARR_T *)
10879 ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
10880 asc_dvc->carr_pending_cnt++;
10881
10882 /*
10883 * Set the carrier to be a stopper by setting 'next_vpa'
10884 * to the stopper value. The current stopper will be changed
10885 * below to point to the new stopper.
10886 */
10887 new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
10888
10889 /*
10890 * Clear the ADV_SCSI_REQ_Q done flag.
10891 */
10892 scsiq->a_flag &= ~ADV_SCSIQ_DONE;
10893
Matthew Wilcoxfd625f42007-10-02 21:55:38 -040010894 req_paddr = virt_to_bus(scsiq);
Matthew Wilcox51219352007-10-02 21:55:22 -040010895 BUG_ON(req_paddr & 31);
Matthew Wilcox51219352007-10-02 21:55:22 -040010896 /* Wait for assertion before making little-endian */
10897 req_paddr = cpu_to_le32(req_paddr);
10898
10899 /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
10900 scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
10901 scsiq->scsiq_rptr = req_paddr;
10902
10903 scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
10904 /*
10905 * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
10906 * order during initialization.
10907 */
10908 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
10909
10910 /*
10911 * Use the current stopper to send the ADV_SCSI_REQ_Q command to
10912 * the microcode. The newly allocated stopper will become the new
10913 * stopper.
10914 */
10915 asc_dvc->icq_sp->areq_vpa = req_paddr;
10916
10917 /*
10918 * Set the 'next_vpa' pointer for the old stopper to be the
10919 * physical address of the new stopper. The RISC can only
10920 * follow physical addresses.
10921 */
10922 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
10923
10924 /*
10925 * Set the host adapter stopper pointer to point to the new carrier.
10926 */
10927 asc_dvc->icq_sp = new_carrp;
10928
10929 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
10930 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
10931 /*
10932 * Tickle the RISC to tell it to read its Command Queue Head pointer.
10933 */
10934 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
10935 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
10936 /*
10937 * Clear the tickle value. In the ASC-3550 the RISC flag
10938 * command 'clr_tickle_a' does not work unless the host
10939 * value is cleared.
10940 */
10941 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
10942 ADV_TICKLE_NOP);
10943 }
10944 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
10945 /*
10946 * Notify the RISC a carrier is ready by writing the physical
10947 * address of the new carrier stopper to the COMMA register.
10948 */
10949 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
10950 le32_to_cpu(new_carrp->carr_pa));
10951 }
10952
10953 return ADV_SUCCESS;
10954}
10955
10956/*
10957 * Execute a single 'Scsi_Cmnd'.
10958 *
10959 * The function 'done' is called when the request has been completed.
10960 *
10961 * Scsi_Cmnd:
10962 *
10963 * host - board controlling device
10964 * device - device to send command
10965 * target - target of device
10966 * lun - lun of device
10967 * cmd_len - length of SCSI CDB
10968 * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
10969 * use_sg - if non-zero indicates scatter-gather request with use_sg elements
10970 *
10971 * if (use_sg == 0) {
10972 * request_buffer - buffer address for request
10973 * request_bufflen - length of request buffer
10974 * } else {
10975 * request_buffer - pointer to scatterlist structure
10976 * }
10977 *
10978 * sense_buffer - sense command buffer
10979 *
10980 * result (4 bytes of an int):
10981 * Byte Meaning
10982 * 0 SCSI Status Byte Code
10983 * 1 SCSI One Byte Message Code
10984 * 2 Host Error Code
10985 * 3 Mid-Level Error Code
10986 *
10987 * host driver fields:
10988 * SCp - Scsi_Pointer used for command processing status
10989 * scsi_done - used to save caller's done function
10990 * host_scribble - used for pointer to another struct scsi_cmnd
10991 *
10992 * If this function returns ASC_NOERROR the request will be completed
10993 * from the interrupt handler.
10994 *
10995 * If this function returns ASC_ERROR the host error code has been set,
10996 * and the called must call asc_scsi_done.
10997 *
10998 * If ASC_BUSY is returned the request will be returned to the midlayer
10999 * and re-tried later.
11000 */
11001static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
11002{
Matthew Wilcox41d24932007-10-02 21:55:24 -040011003 int ret, err_code;
Matthew Wilcoxd2411492007-10-02 21:55:31 -040011004 struct asc_board *boardp = shost_priv(scp->device->host);
Matthew Wilcox51219352007-10-02 21:55:22 -040011005
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011006 ASC_DBG(1, "scp 0x%p\n", scp);
Matthew Wilcox51219352007-10-02 21:55:22 -040011007
11008 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox41d24932007-10-02 21:55:24 -040011009 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
Matthew Wilcox05848b62007-10-02 21:55:25 -040011010 struct asc_scsi_q asc_scsi_q;
Matthew Wilcox51219352007-10-02 21:55:22 -040011011
Matthew Wilcox41d24932007-10-02 21:55:24 -040011012 /* asc_build_req() can not return ASC_BUSY. */
Matthew Wilcox05848b62007-10-02 21:55:25 -040011013 ret = asc_build_req(boardp, scp, &asc_scsi_q);
11014 if (ret == ASC_ERROR) {
Matthew Wilcox51219352007-10-02 21:55:22 -040011015 ASC_STATS(scp->device->host, build_error);
11016 return ASC_ERROR;
11017 }
11018
Matthew Wilcox41d24932007-10-02 21:55:24 -040011019 ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
Matthew Wilcox05848b62007-10-02 21:55:25 -040011020 kfree(asc_scsi_q.sg_head);
Matthew Wilcox41d24932007-10-02 21:55:24 -040011021 err_code = asc_dvc->err_code;
Matthew Wilcox51219352007-10-02 21:55:22 -040011022 } else {
Matthew Wilcox41d24932007-10-02 21:55:24 -040011023 ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
11024 ADV_SCSI_REQ_Q *adv_scsiqp;
Matthew Wilcox51219352007-10-02 21:55:22 -040011025
Matthew Wilcox51219352007-10-02 21:55:22 -040011026 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
11027 case ASC_NOERROR:
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011028 ASC_DBG(3, "adv_build_req ASC_NOERROR\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011029 break;
11030 case ASC_BUSY:
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011031 ASC_DBG(1, "adv_build_req ASC_BUSY\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011032 /*
11033 * The asc_stats fields 'adv_build_noreq' and
11034 * 'adv_build_nosg' count wide board busy conditions.
11035 * They are updated in adv_build_req and
11036 * adv_get_sglist, respectively.
11037 */
11038 return ASC_BUSY;
11039 case ASC_ERROR:
11040 default:
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011041 ASC_DBG(1, "adv_build_req ASC_ERROR\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011042 ASC_STATS(scp->device->host, build_error);
11043 return ASC_ERROR;
11044 }
11045
Matthew Wilcox41d24932007-10-02 21:55:24 -040011046 ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
11047 err_code = adv_dvc->err_code;
11048 }
11049
11050 switch (ret) {
11051 case ASC_NOERROR:
11052 ASC_STATS(scp->device->host, exe_noerror);
11053 /*
11054 * Increment monotonically increasing per device
11055 * successful request counter. Wrapping doesn't matter.
11056 */
11057 boardp->reqcnt[scp->device->id]++;
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011058 ASC_DBG(1, "ExeScsiQueue() ASC_NOERROR\n");
Matthew Wilcox41d24932007-10-02 21:55:24 -040011059 break;
11060 case ASC_BUSY:
11061 ASC_STATS(scp->device->host, exe_busy);
11062 break;
11063 case ASC_ERROR:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011064 scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, "
11065 "err_code 0x%x\n", err_code);
Matthew Wilcox41d24932007-10-02 21:55:24 -040011066 ASC_STATS(scp->device->host, exe_error);
11067 scp->result = HOST_BYTE(DID_ERROR);
11068 break;
11069 default:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011070 scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, "
11071 "err_code 0x%x\n", err_code);
Matthew Wilcox41d24932007-10-02 21:55:24 -040011072 ASC_STATS(scp->device->host, exe_unknown);
11073 scp->result = HOST_BYTE(DID_ERROR);
11074 break;
Matthew Wilcox51219352007-10-02 21:55:22 -040011075 }
11076
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011077 ASC_DBG(1, "end\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011078 return ret;
11079}
11080
11081/*
11082 * advansys_queuecommand() - interrupt-driven I/O entrypoint.
11083 *
11084 * This function always returns 0. Command return status is saved
11085 * in the 'scp' result field.
11086 */
11087static int
11088advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
11089{
11090 struct Scsi_Host *shost = scp->device->host;
Matthew Wilcox51219352007-10-02 21:55:22 -040011091 int asc_res, result = 0;
11092
11093 ASC_STATS(shost, queuecommand);
11094 scp->scsi_done = done;
11095
Matthew Wilcox51219352007-10-02 21:55:22 -040011096 asc_res = asc_execute_scsi_cmnd(scp);
Matthew Wilcox51219352007-10-02 21:55:22 -040011097
11098 switch (asc_res) {
11099 case ASC_NOERROR:
11100 break;
11101 case ASC_BUSY:
11102 result = SCSI_MLQUEUE_HOST_BUSY;
11103 break;
11104 case ASC_ERROR:
11105 default:
11106 asc_scsi_done(scp);
11107 break;
11108 }
11109
11110 return result;
11111}
11112
11113static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
11114{
11115 PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
11116 (PortAddr) (ASC_EISA_CFG_IOP_MASK);
11117 return inpw(eisa_cfg_iop);
11118}
11119
11120/*
11121 * Return the BIOS address of the adapter at the specified
11122 * I/O port and with the specified bus type.
11123 */
11124static unsigned short __devinit
11125AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
11126{
11127 unsigned short cfg_lsw;
11128 unsigned short bios_addr;
11129
11130 /*
11131 * The PCI BIOS is re-located by the motherboard BIOS. Because
11132 * of this the driver can not determine where a PCI BIOS is
11133 * loaded and executes.
11134 */
11135 if (bus_type & ASC_IS_PCI)
11136 return 0;
11137
11138 if ((bus_type & ASC_IS_EISA) != 0) {
11139 cfg_lsw = AscGetEisaChipCfg(iop_base);
11140 cfg_lsw &= 0x000F;
11141 bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
11142 return bios_addr;
11143 }
11144
11145 cfg_lsw = AscGetChipCfgLsw(iop_base);
11146
11147 /*
11148 * ISA PnP uses the top bit as the 32K BIOS flag
11149 */
11150 if (bus_type == ASC_IS_ISAPNP)
11151 cfg_lsw &= 0x7FFF;
11152 bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
11153 return bios_addr;
11154}
11155
11156static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
11157{
11158 ushort cfg_lsw;
11159
11160 if (AscGetChipScsiID(iop_base) == new_host_id) {
11161 return (new_host_id);
11162 }
11163 cfg_lsw = AscGetChipCfgLsw(iop_base);
11164 cfg_lsw &= 0xF8FF;
11165 cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
11166 AscSetChipCfgLsw(iop_base, cfg_lsw);
11167 return (AscGetChipScsiID(iop_base));
11168}
11169
11170static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
11171{
11172 unsigned char sc;
11173
11174 AscSetBank(iop_base, 1);
11175 sc = inp(iop_base + IOP_REG_SC);
11176 AscSetBank(iop_base, 0);
11177 return sc;
11178}
11179
11180static unsigned char __devinit
11181AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
11182{
11183 if (bus_type & ASC_IS_EISA) {
11184 PortAddr eisa_iop;
11185 unsigned char revision;
11186 eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
11187 (PortAddr) ASC_EISA_REV_IOP_MASK;
11188 revision = inp(eisa_iop);
11189 return ASC_CHIP_MIN_VER_EISA - 1 + revision;
11190 }
11191 return AscGetChipVerNo(iop_base);
11192}
11193
Matthew Wilcox51219352007-10-02 21:55:22 -040011194#ifdef CONFIG_ISA
11195static void __devinit AscEnableIsaDma(uchar dma_channel)
11196{
11197 if (dma_channel < 4) {
11198 outp(0x000B, (ushort)(0xC0 | dma_channel));
11199 outp(0x000A, dma_channel);
11200 } else if (dma_channel < 8) {
11201 outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
11202 outp(0x00D4, (ushort)(dma_channel - 4));
11203 }
Matthew Wilcox51219352007-10-02 21:55:22 -040011204}
11205#endif /* CONFIG_ISA */
11206
11207static int AscStopQueueExe(PortAddr iop_base)
11208{
11209 int count = 0;
11210
11211 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
11212 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
11213 ASC_STOP_REQ_RISC_STOP);
11214 do {
11215 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
11216 ASC_STOP_ACK_RISC_STOP) {
11217 return (1);
11218 }
11219 mdelay(100);
11220 } while (count++ < 20);
11221 }
11222 return (0);
11223}
11224
11225static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
11226{
11227 if (bus_type & ASC_IS_ISA)
11228 return ASC_MAX_ISA_DMA_COUNT;
11229 else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
11230 return ASC_MAX_VL_DMA_COUNT;
11231 return ASC_MAX_PCI_DMA_COUNT;
11232}
11233
11234#ifdef CONFIG_ISA
11235static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
11236{
11237 ushort channel;
11238
11239 channel = AscGetChipCfgLsw(iop_base) & 0x0003;
11240 if (channel == 0x03)
11241 return (0);
11242 else if (channel == 0x00)
11243 return (7);
11244 return (channel + 4);
11245}
11246
11247static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
11248{
11249 ushort cfg_lsw;
11250 uchar value;
11251
11252 if ((dma_channel >= 5) && (dma_channel <= 7)) {
11253 if (dma_channel == 7)
11254 value = 0x00;
11255 else
11256 value = dma_channel - 4;
11257 cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
11258 cfg_lsw |= value;
11259 AscSetChipCfgLsw(iop_base, cfg_lsw);
11260 return (AscGetIsaDmaChannel(iop_base));
11261 }
11262 return 0;
11263}
11264
11265static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
11266{
11267 uchar speed_value;
11268
11269 AscSetBank(iop_base, 1);
11270 speed_value = AscReadChipDmaSpeed(iop_base);
11271 speed_value &= 0x07;
11272 AscSetBank(iop_base, 0);
11273 return speed_value;
11274}
11275
11276static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
11277{
11278 speed_value &= 0x07;
11279 AscSetBank(iop_base, 1);
11280 AscWriteChipDmaSpeed(iop_base, speed_value);
11281 AscSetBank(iop_base, 0);
11282 return AscGetIsaDmaSpeed(iop_base);
11283}
11284#endif /* CONFIG_ISA */
11285
11286static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
11287{
11288 int i;
11289 PortAddr iop_base;
11290 ushort warn_code;
11291 uchar chip_version;
11292
11293 iop_base = asc_dvc->iop_base;
11294 warn_code = 0;
11295 asc_dvc->err_code = 0;
11296 if ((asc_dvc->bus_type &
11297 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
11298 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
11299 }
11300 AscSetChipControl(iop_base, CC_HALT);
11301 AscSetChipStatus(iop_base, 0);
11302 asc_dvc->bug_fix_cntl = 0;
11303 asc_dvc->pci_fix_asyn_xfer = 0;
11304 asc_dvc->pci_fix_asyn_xfer_always = 0;
11305 /* asc_dvc->init_state initalized in AscInitGetConfig(). */
11306 asc_dvc->sdtr_done = 0;
11307 asc_dvc->cur_total_qng = 0;
11308 asc_dvc->is_in_int = 0;
11309 asc_dvc->in_critical_cnt = 0;
11310 asc_dvc->last_q_shortage = 0;
11311 asc_dvc->use_tagged_qng = 0;
11312 asc_dvc->no_scam = 0;
11313 asc_dvc->unit_not_ready = 0;
11314 asc_dvc->queue_full_or_busy = 0;
11315 asc_dvc->redo_scam = 0;
11316 asc_dvc->res2 = 0;
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -040011317 asc_dvc->min_sdtr_index = 0;
Matthew Wilcox51219352007-10-02 21:55:22 -040011318 asc_dvc->cfg->can_tagged_qng = 0;
11319 asc_dvc->cfg->cmd_qng_enabled = 0;
11320 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
11321 asc_dvc->init_sdtr = 0;
11322 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
11323 asc_dvc->scsi_reset_wait = 3;
11324 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
11325 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
11326 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
11327 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
11328 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
Matthew Wilcox51219352007-10-02 21:55:22 -040011329 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
11330 asc_dvc->cfg->chip_version = chip_version;
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -040011331 asc_dvc->sdtr_period_tbl = asc_syn_xfer_period;
Matthew Wilcox51219352007-10-02 21:55:22 -040011332 asc_dvc->max_sdtr_index = 7;
11333 if ((asc_dvc->bus_type & ASC_IS_PCI) &&
11334 (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
11335 asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -040011336 asc_dvc->sdtr_period_tbl = asc_syn_ultra_xfer_period;
Matthew Wilcox51219352007-10-02 21:55:22 -040011337 asc_dvc->max_sdtr_index = 15;
11338 if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
11339 AscSetExtraControl(iop_base,
11340 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
11341 } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
11342 AscSetExtraControl(iop_base,
11343 (SEC_ACTIVE_NEGATE |
11344 SEC_ENABLE_FILTER));
11345 }
11346 }
11347 if (asc_dvc->bus_type == ASC_IS_PCI) {
11348 AscSetExtraControl(iop_base,
11349 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
11350 }
11351
11352 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
11353#ifdef CONFIG_ISA
11354 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
11355 if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
11356 AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
11357 asc_dvc->bus_type = ASC_IS_ISAPNP;
11358 }
11359 asc_dvc->cfg->isa_dma_channel =
11360 (uchar)AscGetIsaDmaChannel(iop_base);
11361 }
11362#endif /* CONFIG_ISA */
11363 for (i = 0; i <= ASC_MAX_TID; i++) {
11364 asc_dvc->cur_dvc_qng[i] = 0;
11365 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
11366 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
11367 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
11368 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
11369 }
11370 return warn_code;
11371}
11372
11373static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
11374{
11375 int retry;
11376
11377 for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
11378 unsigned char read_back;
11379 AscSetChipEEPCmd(iop_base, cmd_reg);
11380 mdelay(1);
11381 read_back = AscGetChipEEPCmd(iop_base);
11382 if (read_back == cmd_reg)
11383 return 1;
11384 }
11385 return 0;
11386}
11387
11388static void __devinit AscWaitEEPRead(void)
11389{
11390 mdelay(1);
11391}
11392
11393static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
11394{
11395 ushort read_wval;
11396 uchar cmd_reg;
11397
11398 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
11399 AscWaitEEPRead();
11400 cmd_reg = addr | ASC_EEP_CMD_READ;
11401 AscWriteEEPCmdReg(iop_base, cmd_reg);
11402 AscWaitEEPRead();
11403 read_wval = AscGetChipEEPData(iop_base);
11404 AscWaitEEPRead();
11405 return read_wval;
11406}
11407
11408static ushort __devinit
11409AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
11410{
11411 ushort wval;
11412 ushort sum;
11413 ushort *wbuf;
11414 int cfg_beg;
11415 int cfg_end;
11416 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
11417 int s_addr;
11418
11419 wbuf = (ushort *)cfg_buf;
11420 sum = 0;
11421 /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
11422 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
11423 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
11424 sum += *wbuf;
11425 }
11426 if (bus_type & ASC_IS_VL) {
11427 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
11428 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
11429 } else {
11430 cfg_beg = ASC_EEP_DVC_CFG_BEG;
11431 cfg_end = ASC_EEP_MAX_DVC_ADDR;
11432 }
11433 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
11434 wval = AscReadEEPWord(iop_base, (uchar)s_addr);
11435 if (s_addr <= uchar_end_in_config) {
11436 /*
11437 * Swap all char fields - must unswap bytes already swapped
11438 * by AscReadEEPWord().
11439 */
11440 *wbuf = le16_to_cpu(wval);
11441 } else {
11442 /* Don't swap word field at the end - cntl field. */
11443 *wbuf = wval;
11444 }
11445 sum += wval; /* Checksum treats all EEPROM data as words. */
11446 }
11447 /*
11448 * Read the checksum word which will be compared against 'sum'
11449 * by the caller. Word field already swapped.
11450 */
11451 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
11452 return sum;
11453}
11454
11455static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
11456{
11457 PortAddr iop_base;
11458 ushort q_addr;
11459 ushort saved_word;
11460 int sta;
11461
11462 iop_base = asc_dvc->iop_base;
11463 sta = 0;
11464 q_addr = ASC_QNO_TO_QADDR(241);
11465 saved_word = AscReadLramWord(iop_base, q_addr);
11466 AscSetChipLramAddr(iop_base, q_addr);
11467 AscSetChipLramData(iop_base, 0x55AA);
11468 mdelay(10);
11469 AscSetChipLramAddr(iop_base, q_addr);
11470 if (AscGetChipLramData(iop_base) == 0x55AA) {
11471 sta = 1;
11472 AscWriteLramWord(iop_base, q_addr, saved_word);
11473 }
11474 return (sta);
11475}
11476
11477static void __devinit AscWaitEEPWrite(void)
11478{
11479 mdelay(20);
Matthew Wilcox51219352007-10-02 21:55:22 -040011480}
11481
11482static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
11483{
11484 ushort read_back;
11485 int retry;
11486
11487 retry = 0;
11488 while (TRUE) {
11489 AscSetChipEEPData(iop_base, data_reg);
11490 mdelay(1);
11491 read_back = AscGetChipEEPData(iop_base);
11492 if (read_back == data_reg) {
11493 return (1);
11494 }
11495 if (retry++ > ASC_EEP_MAX_RETRY) {
11496 return (0);
11497 }
11498 }
11499}
11500
11501static ushort __devinit
11502AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
11503{
11504 ushort read_wval;
11505
11506 read_wval = AscReadEEPWord(iop_base, addr);
11507 if (read_wval != word_val) {
11508 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
11509 AscWaitEEPRead();
11510 AscWriteEEPDataReg(iop_base, word_val);
11511 AscWaitEEPRead();
11512 AscWriteEEPCmdReg(iop_base,
11513 (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
11514 AscWaitEEPWrite();
11515 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
11516 AscWaitEEPRead();
11517 return (AscReadEEPWord(iop_base, addr));
11518 }
11519 return (read_wval);
11520}
11521
11522static int __devinit
11523AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
11524{
11525 int n_error;
11526 ushort *wbuf;
11527 ushort word;
11528 ushort sum;
11529 int s_addr;
11530 int cfg_beg;
11531 int cfg_end;
11532 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
11533
11534 wbuf = (ushort *)cfg_buf;
11535 n_error = 0;
11536 sum = 0;
11537 /* Write two config words; AscWriteEEPWord() will swap bytes. */
11538 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
11539 sum += *wbuf;
11540 if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
11541 n_error++;
11542 }
11543 }
11544 if (bus_type & ASC_IS_VL) {
11545 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
11546 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
11547 } else {
11548 cfg_beg = ASC_EEP_DVC_CFG_BEG;
11549 cfg_end = ASC_EEP_MAX_DVC_ADDR;
11550 }
11551 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
11552 if (s_addr <= uchar_end_in_config) {
11553 /*
11554 * This is a char field. Swap char fields before they are
11555 * swapped again by AscWriteEEPWord().
11556 */
11557 word = cpu_to_le16(*wbuf);
11558 if (word !=
11559 AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
11560 n_error++;
11561 }
11562 } else {
11563 /* Don't swap word field at the end - cntl field. */
11564 if (*wbuf !=
11565 AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
11566 n_error++;
11567 }
11568 }
11569 sum += *wbuf; /* Checksum calculated from word values. */
11570 }
11571 /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
11572 *wbuf = sum;
11573 if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
11574 n_error++;
11575 }
11576
11577 /* Read EEPROM back again. */
11578 wbuf = (ushort *)cfg_buf;
11579 /*
11580 * Read two config words; Byte-swapping done by AscReadEEPWord().
11581 */
11582 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
11583 if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
11584 n_error++;
11585 }
11586 }
11587 if (bus_type & ASC_IS_VL) {
11588 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
11589 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
11590 } else {
11591 cfg_beg = ASC_EEP_DVC_CFG_BEG;
11592 cfg_end = ASC_EEP_MAX_DVC_ADDR;
11593 }
11594 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
11595 if (s_addr <= uchar_end_in_config) {
11596 /*
11597 * Swap all char fields. Must unswap bytes already swapped
11598 * by AscReadEEPWord().
11599 */
11600 word =
11601 le16_to_cpu(AscReadEEPWord
11602 (iop_base, (uchar)s_addr));
11603 } else {
11604 /* Don't swap word field at the end - cntl field. */
11605 word = AscReadEEPWord(iop_base, (uchar)s_addr);
11606 }
11607 if (*wbuf != word) {
11608 n_error++;
11609 }
11610 }
11611 /* Read checksum; Byte swapping not needed. */
11612 if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
11613 n_error++;
11614 }
11615 return n_error;
11616}
11617
11618static int __devinit
11619AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
11620{
11621 int retry;
11622 int n_error;
11623
11624 retry = 0;
11625 while (TRUE) {
11626 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
11627 bus_type)) == 0) {
11628 break;
11629 }
11630 if (++retry > ASC_EEP_MAX_RETRY) {
11631 break;
11632 }
11633 }
11634 return n_error;
11635}
11636
11637static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
11638{
11639 ASCEEP_CONFIG eep_config_buf;
11640 ASCEEP_CONFIG *eep_config;
11641 PortAddr iop_base;
11642 ushort chksum;
11643 ushort warn_code;
11644 ushort cfg_msw, cfg_lsw;
11645 int i;
11646 int write_eep = 0;
11647
11648 iop_base = asc_dvc->iop_base;
11649 warn_code = 0;
11650 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
11651 AscStopQueueExe(iop_base);
11652 if ((AscStopChip(iop_base) == FALSE) ||
11653 (AscGetChipScsiCtrl(iop_base) != 0)) {
11654 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
11655 AscResetChipAndScsiBus(asc_dvc);
11656 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
11657 }
11658 if (AscIsChipHalted(iop_base) == FALSE) {
11659 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
11660 return (warn_code);
11661 }
11662 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
11663 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
11664 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
11665 return (warn_code);
11666 }
11667 eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
11668 cfg_msw = AscGetChipCfgMsw(iop_base);
11669 cfg_lsw = AscGetChipCfgLsw(iop_base);
11670 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
11671 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
11672 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
11673 AscSetChipCfgMsw(iop_base, cfg_msw);
11674 }
11675 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011676 ASC_DBG(1, "chksum 0x%x\n", chksum);
Matthew Wilcox51219352007-10-02 21:55:22 -040011677 if (chksum == 0) {
11678 chksum = 0xaa55;
11679 }
11680 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
11681 warn_code |= ASC_WARN_AUTO_CONFIG;
11682 if (asc_dvc->cfg->chip_version == 3) {
11683 if (eep_config->cfg_lsw != cfg_lsw) {
11684 warn_code |= ASC_WARN_EEPROM_RECOVER;
11685 eep_config->cfg_lsw =
11686 AscGetChipCfgLsw(iop_base);
11687 }
11688 if (eep_config->cfg_msw != cfg_msw) {
11689 warn_code |= ASC_WARN_EEPROM_RECOVER;
11690 eep_config->cfg_msw =
11691 AscGetChipCfgMsw(iop_base);
11692 }
11693 }
11694 }
11695 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
11696 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011697 ASC_DBG(1, "eep_config->chksum 0x%x\n", eep_config->chksum);
Matthew Wilcox51219352007-10-02 21:55:22 -040011698 if (chksum != eep_config->chksum) {
11699 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
11700 ASC_CHIP_VER_PCI_ULTRA_3050) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040011701 ASC_DBG(1, "chksum error ignored; EEPROM-less board\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011702 eep_config->init_sdtr = 0xFF;
11703 eep_config->disc_enable = 0xFF;
11704 eep_config->start_motor = 0xFF;
11705 eep_config->use_cmd_qng = 0;
11706 eep_config->max_total_qng = 0xF0;
11707 eep_config->max_tag_qng = 0x20;
11708 eep_config->cntl = 0xBFFF;
11709 ASC_EEP_SET_CHIP_ID(eep_config, 7);
11710 eep_config->no_scam = 0;
11711 eep_config->adapter_info[0] = 0;
11712 eep_config->adapter_info[1] = 0;
11713 eep_config->adapter_info[2] = 0;
11714 eep_config->adapter_info[3] = 0;
11715 eep_config->adapter_info[4] = 0;
11716 /* Indicate EEPROM-less board. */
11717 eep_config->adapter_info[5] = 0xBB;
11718 } else {
11719 ASC_PRINT
11720 ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
11721 write_eep = 1;
11722 warn_code |= ASC_WARN_EEPROM_CHKSUM;
11723 }
11724 }
11725 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
11726 asc_dvc->cfg->disc_enable = eep_config->disc_enable;
11727 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
11728 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
11729 asc_dvc->start_motor = eep_config->start_motor;
11730 asc_dvc->dvc_cntl = eep_config->cntl;
11731 asc_dvc->no_scam = eep_config->no_scam;
11732 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
11733 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
11734 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
11735 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
11736 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
11737 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
11738 if (!AscTestExternalLram(asc_dvc)) {
11739 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
11740 ASC_IS_PCI_ULTRA)) {
11741 eep_config->max_total_qng =
11742 ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
11743 eep_config->max_tag_qng =
11744 ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
11745 } else {
11746 eep_config->cfg_msw |= 0x0800;
11747 cfg_msw |= 0x0800;
11748 AscSetChipCfgMsw(iop_base, cfg_msw);
11749 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
11750 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
11751 }
11752 } else {
11753 }
11754 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
11755 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
11756 }
11757 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
11758 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
11759 }
11760 if (eep_config->max_tag_qng > eep_config->max_total_qng) {
11761 eep_config->max_tag_qng = eep_config->max_total_qng;
11762 }
11763 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
11764 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
11765 }
11766 asc_dvc->max_total_qng = eep_config->max_total_qng;
11767 if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
11768 eep_config->use_cmd_qng) {
11769 eep_config->disc_enable = eep_config->use_cmd_qng;
11770 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
11771 }
Matthew Wilcox51219352007-10-02 21:55:22 -040011772 ASC_EEP_SET_CHIP_ID(eep_config,
11773 ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
11774 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
11775 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
11776 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -040011777 asc_dvc->min_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
Matthew Wilcox51219352007-10-02 21:55:22 -040011778 }
11779
11780 for (i = 0; i <= ASC_MAX_TID; i++) {
11781 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
11782 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
11783 asc_dvc->cfg->sdtr_period_offset[i] =
11784 (uchar)(ASC_DEF_SDTR_OFFSET |
Matthew Wilcoxafbb68c2007-10-02 21:55:36 -040011785 (asc_dvc->min_sdtr_index << 4));
Matthew Wilcox51219352007-10-02 21:55:22 -040011786 }
11787 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
11788 if (write_eep) {
11789 if ((i = AscSetEEPConfig(iop_base, eep_config,
11790 asc_dvc->bus_type)) != 0) {
11791 ASC_PRINT1
11792 ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
11793 i);
11794 } else {
11795 ASC_PRINT
11796 ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
11797 }
11798 }
11799 return (warn_code);
11800}
11801
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011802static int __devinit AscInitGetConfig(struct Scsi_Host *shost)
Matthew Wilcox51219352007-10-02 21:55:22 -040011803{
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011804 struct asc_board *board = shost_priv(shost);
11805 ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
Matthew Wilcox51219352007-10-02 21:55:22 -040011806 unsigned short warn_code = 0;
11807
11808 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
11809 if (asc_dvc->err_code != 0)
11810 return asc_dvc->err_code;
11811
11812 if (AscFindSignature(asc_dvc->iop_base)) {
11813 warn_code |= AscInitAscDvcVar(asc_dvc);
11814 warn_code |= AscInitFromEEP(asc_dvc);
11815 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
11816 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
11817 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
11818 } else {
11819 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
11820 }
11821
11822 switch (warn_code) {
11823 case 0: /* No error */
11824 break;
11825 case ASC_WARN_IO_PORT_ROTATE:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011826 shost_printk(KERN_WARNING, shost, "I/O port address "
11827 "modified\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011828 break;
11829 case ASC_WARN_AUTO_CONFIG:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011830 shost_printk(KERN_WARNING, shost, "I/O port increment switch "
11831 "enabled\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011832 break;
11833 case ASC_WARN_EEPROM_CHKSUM:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011834 shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011835 break;
11836 case ASC_WARN_IRQ_MODIFIED:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011837 shost_printk(KERN_WARNING, shost, "IRQ modified\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011838 break;
11839 case ASC_WARN_CMD_QNG_CONFLICT:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011840 shost_printk(KERN_WARNING, shost, "tag queuing enabled w/o "
11841 "disconnects\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011842 break;
11843 default:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011844 shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
11845 warn_code);
Matthew Wilcox51219352007-10-02 21:55:22 -040011846 break;
11847 }
11848
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011849 if (asc_dvc->err_code != 0)
11850 shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
11851 "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
Matthew Wilcox51219352007-10-02 21:55:22 -040011852
11853 return asc_dvc->err_code;
11854}
11855
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011856static int __devinit AscInitSetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
Matthew Wilcox51219352007-10-02 21:55:22 -040011857{
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011858 struct asc_board *board = shost_priv(shost);
11859 ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
Matthew Wilcox51219352007-10-02 21:55:22 -040011860 PortAddr iop_base = asc_dvc->iop_base;
11861 unsigned short cfg_msw;
11862 unsigned short warn_code = 0;
11863
11864 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
11865 if (asc_dvc->err_code != 0)
11866 return asc_dvc->err_code;
11867 if (!AscFindSignature(asc_dvc->iop_base)) {
11868 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
11869 return asc_dvc->err_code;
11870 }
11871
11872 cfg_msw = AscGetChipCfgMsw(iop_base);
11873 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
11874 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
11875 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
11876 AscSetChipCfgMsw(iop_base, cfg_msw);
11877 }
11878 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
11879 asc_dvc->cfg->cmd_qng_enabled) {
11880 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
11881 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
11882 }
11883 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
11884 warn_code |= ASC_WARN_AUTO_CONFIG;
11885 }
Matthew Wilcox51219352007-10-02 21:55:22 -040011886#ifdef CONFIG_PCI
11887 if (asc_dvc->bus_type & ASC_IS_PCI) {
11888 cfg_msw &= 0xFFC0;
11889 AscSetChipCfgMsw(iop_base, cfg_msw);
11890 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
11891 } else {
11892 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
11893 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
11894 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
11895 asc_dvc->bug_fix_cntl |=
11896 ASC_BUG_FIX_ASYN_USE_SYN;
11897 }
11898 }
11899 } else
11900#endif /* CONFIG_PCI */
11901 if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
11902 if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
11903 == ASC_CHIP_VER_ASYN_BUG) {
11904 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
11905 }
11906 }
11907 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
11908 asc_dvc->cfg->chip_scsi_id) {
11909 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
11910 }
11911#ifdef CONFIG_ISA
11912 if (asc_dvc->bus_type & ASC_IS_ISA) {
11913 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
11914 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
11915 }
11916#endif /* CONFIG_ISA */
11917
11918 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
11919
11920 switch (warn_code) {
11921 case 0: /* No error. */
11922 break;
11923 case ASC_WARN_IO_PORT_ROTATE:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011924 shost_printk(KERN_WARNING, shost, "I/O port address "
11925 "modified\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011926 break;
11927 case ASC_WARN_AUTO_CONFIG:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011928 shost_printk(KERN_WARNING, shost, "I/O port increment switch "
11929 "enabled\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011930 break;
11931 case ASC_WARN_EEPROM_CHKSUM:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011932 shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011933 break;
11934 case ASC_WARN_IRQ_MODIFIED:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011935 shost_printk(KERN_WARNING, shost, "IRQ modified\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011936 break;
11937 case ASC_WARN_CMD_QNG_CONFLICT:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011938 shost_printk(KERN_WARNING, shost, "tag queuing w/o "
11939 "disconnects\n");
Matthew Wilcox51219352007-10-02 21:55:22 -040011940 break;
11941 default:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011942 shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
11943 warn_code);
Matthew Wilcox51219352007-10-02 21:55:22 -040011944 break;
11945 }
11946
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040011947 if (asc_dvc->err_code != 0)
11948 shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
11949 "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
Matthew Wilcox51219352007-10-02 21:55:22 -040011950
11951 return asc_dvc->err_code;
11952}
11953
11954/*
11955 * EEPROM Configuration.
11956 *
11957 * All drivers should use this structure to set the default EEPROM
11958 * configuration. The BIOS now uses this structure when it is built.
11959 * Additional structure information can be found in a_condor.h where
11960 * the structure is defined.
11961 *
11962 * The *_Field_IsChar structs are needed to correct for endianness.
11963 * These values are read from the board 16 bits at a time directly
11964 * into the structs. Because some fields are char, the values will be
11965 * in the wrong order. The *_Field_IsChar tells when to flip the
11966 * bytes. Data read and written to PCI memory is automatically swapped
11967 * on big-endian platforms so char fields read as words are actually being
11968 * unswapped on big-endian platforms.
11969 */
11970static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
11971 ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
11972 0x0000, /* cfg_msw */
11973 0xFFFF, /* disc_enable */
11974 0xFFFF, /* wdtr_able */
11975 0xFFFF, /* sdtr_able */
11976 0xFFFF, /* start_motor */
11977 0xFFFF, /* tagqng_able */
11978 0xFFFF, /* bios_scan */
11979 0, /* scam_tolerant */
11980 7, /* adapter_scsi_id */
11981 0, /* bios_boot_delay */
11982 3, /* scsi_reset_delay */
11983 0, /* bios_id_lun */
11984 0, /* termination */
11985 0, /* reserved1 */
11986 0xFFE7, /* bios_ctrl */
11987 0xFFFF, /* ultra_able */
11988 0, /* reserved2 */
11989 ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
11990 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
11991 0, /* dvc_cntl */
11992 0, /* bug_fix */
11993 0, /* serial_number_word1 */
11994 0, /* serial_number_word2 */
11995 0, /* serial_number_word3 */
11996 0, /* check_sum */
11997 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
11998 , /* oem_name[16] */
11999 0, /* dvc_err_code */
12000 0, /* adv_err_code */
12001 0, /* adv_err_addr */
12002 0, /* saved_dvc_err_code */
12003 0, /* saved_adv_err_code */
12004 0, /* saved_adv_err_addr */
12005 0 /* num_of_err */
12006};
12007
12008static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
12009 0, /* cfg_lsw */
12010 0, /* cfg_msw */
12011 0, /* -disc_enable */
12012 0, /* wdtr_able */
12013 0, /* sdtr_able */
12014 0, /* start_motor */
12015 0, /* tagqng_able */
12016 0, /* bios_scan */
12017 0, /* scam_tolerant */
12018 1, /* adapter_scsi_id */
12019 1, /* bios_boot_delay */
12020 1, /* scsi_reset_delay */
12021 1, /* bios_id_lun */
12022 1, /* termination */
12023 1, /* reserved1 */
12024 0, /* bios_ctrl */
12025 0, /* ultra_able */
12026 0, /* reserved2 */
12027 1, /* max_host_qng */
12028 1, /* max_dvc_qng */
12029 0, /* dvc_cntl */
12030 0, /* bug_fix */
12031 0, /* serial_number_word1 */
12032 0, /* serial_number_word2 */
12033 0, /* serial_number_word3 */
12034 0, /* check_sum */
12035 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12036 , /* oem_name[16] */
12037 0, /* dvc_err_code */
12038 0, /* adv_err_code */
12039 0, /* adv_err_addr */
12040 0, /* saved_dvc_err_code */
12041 0, /* saved_adv_err_code */
12042 0, /* saved_adv_err_addr */
12043 0 /* num_of_err */
12044};
12045
12046static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
12047 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
12048 0x0000, /* 01 cfg_msw */
12049 0xFFFF, /* 02 disc_enable */
12050 0xFFFF, /* 03 wdtr_able */
12051 0x4444, /* 04 sdtr_speed1 */
12052 0xFFFF, /* 05 start_motor */
12053 0xFFFF, /* 06 tagqng_able */
12054 0xFFFF, /* 07 bios_scan */
12055 0, /* 08 scam_tolerant */
12056 7, /* 09 adapter_scsi_id */
12057 0, /* bios_boot_delay */
12058 3, /* 10 scsi_reset_delay */
12059 0, /* bios_id_lun */
12060 0, /* 11 termination_se */
12061 0, /* termination_lvd */
12062 0xFFE7, /* 12 bios_ctrl */
12063 0x4444, /* 13 sdtr_speed2 */
12064 0x4444, /* 14 sdtr_speed3 */
12065 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
12066 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
12067 0, /* 16 dvc_cntl */
12068 0x4444, /* 17 sdtr_speed4 */
12069 0, /* 18 serial_number_word1 */
12070 0, /* 19 serial_number_word2 */
12071 0, /* 20 serial_number_word3 */
12072 0, /* 21 check_sum */
12073 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
12074 , /* 22-29 oem_name[16] */
12075 0, /* 30 dvc_err_code */
12076 0, /* 31 adv_err_code */
12077 0, /* 32 adv_err_addr */
12078 0, /* 33 saved_dvc_err_code */
12079 0, /* 34 saved_adv_err_code */
12080 0, /* 35 saved_adv_err_addr */
12081 0, /* 36 reserved */
12082 0, /* 37 reserved */
12083 0, /* 38 reserved */
12084 0, /* 39 reserved */
12085 0, /* 40 reserved */
12086 0, /* 41 reserved */
12087 0, /* 42 reserved */
12088 0, /* 43 reserved */
12089 0, /* 44 reserved */
12090 0, /* 45 reserved */
12091 0, /* 46 reserved */
12092 0, /* 47 reserved */
12093 0, /* 48 reserved */
12094 0, /* 49 reserved */
12095 0, /* 50 reserved */
12096 0, /* 51 reserved */
12097 0, /* 52 reserved */
12098 0, /* 53 reserved */
12099 0, /* 54 reserved */
12100 0, /* 55 reserved */
12101 0, /* 56 cisptr_lsw */
12102 0, /* 57 cisprt_msw */
12103 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
12104 PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
12105 0, /* 60 reserved */
12106 0, /* 61 reserved */
12107 0, /* 62 reserved */
12108 0 /* 63 reserved */
12109};
12110
12111static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
12112 0, /* 00 cfg_lsw */
12113 0, /* 01 cfg_msw */
12114 0, /* 02 disc_enable */
12115 0, /* 03 wdtr_able */
12116 0, /* 04 sdtr_speed1 */
12117 0, /* 05 start_motor */
12118 0, /* 06 tagqng_able */
12119 0, /* 07 bios_scan */
12120 0, /* 08 scam_tolerant */
12121 1, /* 09 adapter_scsi_id */
12122 1, /* bios_boot_delay */
12123 1, /* 10 scsi_reset_delay */
12124 1, /* bios_id_lun */
12125 1, /* 11 termination_se */
12126 1, /* termination_lvd */
12127 0, /* 12 bios_ctrl */
12128 0, /* 13 sdtr_speed2 */
12129 0, /* 14 sdtr_speed3 */
12130 1, /* 15 max_host_qng */
12131 1, /* max_dvc_qng */
12132 0, /* 16 dvc_cntl */
12133 0, /* 17 sdtr_speed4 */
12134 0, /* 18 serial_number_word1 */
12135 0, /* 19 serial_number_word2 */
12136 0, /* 20 serial_number_word3 */
12137 0, /* 21 check_sum */
12138 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12139 , /* 22-29 oem_name[16] */
12140 0, /* 30 dvc_err_code */
12141 0, /* 31 adv_err_code */
12142 0, /* 32 adv_err_addr */
12143 0, /* 33 saved_dvc_err_code */
12144 0, /* 34 saved_adv_err_code */
12145 0, /* 35 saved_adv_err_addr */
12146 0, /* 36 reserved */
12147 0, /* 37 reserved */
12148 0, /* 38 reserved */
12149 0, /* 39 reserved */
12150 0, /* 40 reserved */
12151 0, /* 41 reserved */
12152 0, /* 42 reserved */
12153 0, /* 43 reserved */
12154 0, /* 44 reserved */
12155 0, /* 45 reserved */
12156 0, /* 46 reserved */
12157 0, /* 47 reserved */
12158 0, /* 48 reserved */
12159 0, /* 49 reserved */
12160 0, /* 50 reserved */
12161 0, /* 51 reserved */
12162 0, /* 52 reserved */
12163 0, /* 53 reserved */
12164 0, /* 54 reserved */
12165 0, /* 55 reserved */
12166 0, /* 56 cisptr_lsw */
12167 0, /* 57 cisprt_msw */
12168 0, /* 58 subsysvid */
12169 0, /* 59 subsysid */
12170 0, /* 60 reserved */
12171 0, /* 61 reserved */
12172 0, /* 62 reserved */
12173 0 /* 63 reserved */
12174};
12175
12176static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
12177 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
12178 0x0000, /* 01 cfg_msw */
12179 0xFFFF, /* 02 disc_enable */
12180 0xFFFF, /* 03 wdtr_able */
12181 0x5555, /* 04 sdtr_speed1 */
12182 0xFFFF, /* 05 start_motor */
12183 0xFFFF, /* 06 tagqng_able */
12184 0xFFFF, /* 07 bios_scan */
12185 0, /* 08 scam_tolerant */
12186 7, /* 09 adapter_scsi_id */
12187 0, /* bios_boot_delay */
12188 3, /* 10 scsi_reset_delay */
12189 0, /* bios_id_lun */
12190 0, /* 11 termination_se */
12191 0, /* termination_lvd */
12192 0xFFE7, /* 12 bios_ctrl */
12193 0x5555, /* 13 sdtr_speed2 */
12194 0x5555, /* 14 sdtr_speed3 */
12195 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
12196 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
12197 0, /* 16 dvc_cntl */
12198 0x5555, /* 17 sdtr_speed4 */
12199 0, /* 18 serial_number_word1 */
12200 0, /* 19 serial_number_word2 */
12201 0, /* 20 serial_number_word3 */
12202 0, /* 21 check_sum */
12203 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
12204 , /* 22-29 oem_name[16] */
12205 0, /* 30 dvc_err_code */
12206 0, /* 31 adv_err_code */
12207 0, /* 32 adv_err_addr */
12208 0, /* 33 saved_dvc_err_code */
12209 0, /* 34 saved_adv_err_code */
12210 0, /* 35 saved_adv_err_addr */
12211 0, /* 36 reserved */
12212 0, /* 37 reserved */
12213 0, /* 38 reserved */
12214 0, /* 39 reserved */
12215 0, /* 40 reserved */
12216 0, /* 41 reserved */
12217 0, /* 42 reserved */
12218 0, /* 43 reserved */
12219 0, /* 44 reserved */
12220 0, /* 45 reserved */
12221 0, /* 46 reserved */
12222 0, /* 47 reserved */
12223 0, /* 48 reserved */
12224 0, /* 49 reserved */
12225 0, /* 50 reserved */
12226 0, /* 51 reserved */
12227 0, /* 52 reserved */
12228 0, /* 53 reserved */
12229 0, /* 54 reserved */
12230 0, /* 55 reserved */
12231 0, /* 56 cisptr_lsw */
12232 0, /* 57 cisprt_msw */
12233 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
12234 PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
12235 0, /* 60 reserved */
12236 0, /* 61 reserved */
12237 0, /* 62 reserved */
12238 0 /* 63 reserved */
12239};
12240
12241static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
12242 0, /* 00 cfg_lsw */
12243 0, /* 01 cfg_msw */
12244 0, /* 02 disc_enable */
12245 0, /* 03 wdtr_able */
12246 0, /* 04 sdtr_speed1 */
12247 0, /* 05 start_motor */
12248 0, /* 06 tagqng_able */
12249 0, /* 07 bios_scan */
12250 0, /* 08 scam_tolerant */
12251 1, /* 09 adapter_scsi_id */
12252 1, /* bios_boot_delay */
12253 1, /* 10 scsi_reset_delay */
12254 1, /* bios_id_lun */
12255 1, /* 11 termination_se */
12256 1, /* termination_lvd */
12257 0, /* 12 bios_ctrl */
12258 0, /* 13 sdtr_speed2 */
12259 0, /* 14 sdtr_speed3 */
12260 1, /* 15 max_host_qng */
12261 1, /* max_dvc_qng */
12262 0, /* 16 dvc_cntl */
12263 0, /* 17 sdtr_speed4 */
12264 0, /* 18 serial_number_word1 */
12265 0, /* 19 serial_number_word2 */
12266 0, /* 20 serial_number_word3 */
12267 0, /* 21 check_sum */
12268 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
12269 , /* 22-29 oem_name[16] */
12270 0, /* 30 dvc_err_code */
12271 0, /* 31 adv_err_code */
12272 0, /* 32 adv_err_addr */
12273 0, /* 33 saved_dvc_err_code */
12274 0, /* 34 saved_adv_err_code */
12275 0, /* 35 saved_adv_err_addr */
12276 0, /* 36 reserved */
12277 0, /* 37 reserved */
12278 0, /* 38 reserved */
12279 0, /* 39 reserved */
12280 0, /* 40 reserved */
12281 0, /* 41 reserved */
12282 0, /* 42 reserved */
12283 0, /* 43 reserved */
12284 0, /* 44 reserved */
12285 0, /* 45 reserved */
12286 0, /* 46 reserved */
12287 0, /* 47 reserved */
12288 0, /* 48 reserved */
12289 0, /* 49 reserved */
12290 0, /* 50 reserved */
12291 0, /* 51 reserved */
12292 0, /* 52 reserved */
12293 0, /* 53 reserved */
12294 0, /* 54 reserved */
12295 0, /* 55 reserved */
12296 0, /* 56 cisptr_lsw */
12297 0, /* 57 cisprt_msw */
12298 0, /* 58 subsysvid */
12299 0, /* 59 subsysid */
12300 0, /* 60 reserved */
12301 0, /* 61 reserved */
12302 0, /* 62 reserved */
12303 0 /* 63 reserved */
12304};
12305
12306#ifdef CONFIG_PCI
12307/*
12308 * Wait for EEPROM command to complete
12309 */
12310static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
12311{
12312 int eep_delay_ms;
12313
12314 for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
12315 if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
12316 ASC_EEP_CMD_DONE) {
12317 break;
12318 }
12319 mdelay(1);
12320 }
12321 if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
12322 0)
12323 BUG();
12324}
12325
12326/*
12327 * Read the EEPROM from specified location
12328 */
12329static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
12330{
12331 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12332 ASC_EEP_CMD_READ | eep_word_addr);
12333 AdvWaitEEPCmd(iop_base);
12334 return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
12335}
12336
12337/*
12338 * Write the EEPROM from 'cfg_buf'.
12339 */
12340void __devinit
12341AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
12342{
12343 ushort *wbuf;
12344 ushort addr, chksum;
12345 ushort *charfields;
12346
12347 wbuf = (ushort *)cfg_buf;
12348 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
12349 chksum = 0;
12350
12351 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12352 AdvWaitEEPCmd(iop_base);
12353
12354 /*
12355 * Write EEPROM from word 0 to word 20.
12356 */
12357 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12358 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12359 ushort word;
12360
12361 if (*charfields++) {
12362 word = cpu_to_le16(*wbuf);
12363 } else {
12364 word = *wbuf;
12365 }
12366 chksum += *wbuf; /* Checksum is calculated from word values. */
12367 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12368 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12369 ASC_EEP_CMD_WRITE | addr);
12370 AdvWaitEEPCmd(iop_base);
12371 mdelay(ADV_EEP_DELAY_MS);
12372 }
12373
12374 /*
12375 * Write EEPROM checksum at word 21.
12376 */
12377 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12378 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12379 AdvWaitEEPCmd(iop_base);
12380 wbuf++;
12381 charfields++;
12382
12383 /*
12384 * Write EEPROM OEM name at words 22 to 29.
12385 */
12386 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12387 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12388 ushort word;
12389
12390 if (*charfields++) {
12391 word = cpu_to_le16(*wbuf);
12392 } else {
12393 word = *wbuf;
12394 }
12395 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12396 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12397 ASC_EEP_CMD_WRITE | addr);
12398 AdvWaitEEPCmd(iop_base);
12399 }
12400 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
12401 AdvWaitEEPCmd(iop_base);
12402}
12403
12404/*
12405 * Write the EEPROM from 'cfg_buf'.
12406 */
12407void __devinit
12408AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
12409{
12410 ushort *wbuf;
12411 ushort *charfields;
12412 ushort addr, chksum;
12413
12414 wbuf = (ushort *)cfg_buf;
12415 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
12416 chksum = 0;
12417
12418 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12419 AdvWaitEEPCmd(iop_base);
12420
12421 /*
12422 * Write EEPROM from word 0 to word 20.
12423 */
12424 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12425 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12426 ushort word;
12427
12428 if (*charfields++) {
12429 word = cpu_to_le16(*wbuf);
12430 } else {
12431 word = *wbuf;
12432 }
12433 chksum += *wbuf; /* Checksum is calculated from word values. */
12434 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12435 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12436 ASC_EEP_CMD_WRITE | addr);
12437 AdvWaitEEPCmd(iop_base);
12438 mdelay(ADV_EEP_DELAY_MS);
12439 }
12440
12441 /*
12442 * Write EEPROM checksum at word 21.
12443 */
12444 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12445 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12446 AdvWaitEEPCmd(iop_base);
12447 wbuf++;
12448 charfields++;
12449
12450 /*
12451 * Write EEPROM OEM name at words 22 to 29.
12452 */
12453 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12454 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12455 ushort word;
12456
12457 if (*charfields++) {
12458 word = cpu_to_le16(*wbuf);
12459 } else {
12460 word = *wbuf;
12461 }
12462 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12463 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12464 ASC_EEP_CMD_WRITE | addr);
12465 AdvWaitEEPCmd(iop_base);
12466 }
12467 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
12468 AdvWaitEEPCmd(iop_base);
12469}
12470
12471/*
12472 * Write the EEPROM from 'cfg_buf'.
12473 */
12474void __devinit
12475AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
12476{
12477 ushort *wbuf;
12478 ushort *charfields;
12479 ushort addr, chksum;
12480
12481 wbuf = (ushort *)cfg_buf;
12482 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
12483 chksum = 0;
12484
12485 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
12486 AdvWaitEEPCmd(iop_base);
12487
12488 /*
12489 * Write EEPROM from word 0 to word 20.
12490 */
12491 for (addr = ADV_EEP_DVC_CFG_BEGIN;
12492 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
12493 ushort word;
12494
12495 if (*charfields++) {
12496 word = cpu_to_le16(*wbuf);
12497 } else {
12498 word = *wbuf;
12499 }
12500 chksum += *wbuf; /* Checksum is calculated from word values. */
12501 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12502 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12503 ASC_EEP_CMD_WRITE | addr);
12504 AdvWaitEEPCmd(iop_base);
12505 mdelay(ADV_EEP_DELAY_MS);
12506 }
12507
12508 /*
12509 * Write EEPROM checksum at word 21.
12510 */
12511 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
12512 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
12513 AdvWaitEEPCmd(iop_base);
12514 wbuf++;
12515 charfields++;
12516
12517 /*
12518 * Write EEPROM OEM name at words 22 to 29.
12519 */
12520 for (addr = ADV_EEP_DVC_CTL_BEGIN;
12521 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
12522 ushort word;
12523
12524 if (*charfields++) {
12525 word = cpu_to_le16(*wbuf);
12526 } else {
12527 word = *wbuf;
12528 }
12529 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
12530 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
12531 ASC_EEP_CMD_WRITE | addr);
12532 AdvWaitEEPCmd(iop_base);
12533 }
12534 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
12535 AdvWaitEEPCmd(iop_base);
12536}
12537
12538/*
12539 * Read EEPROM configuration into the specified buffer.
12540 *
12541 * Return a checksum based on the EEPROM configuration read.
12542 */
12543static ushort __devinit
12544AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
12545{
12546 ushort wval, chksum;
12547 ushort *wbuf;
12548 int eep_addr;
12549 ushort *charfields;
12550
12551 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
12552 wbuf = (ushort *)cfg_buf;
12553 chksum = 0;
12554
12555 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
12556 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
12557 wval = AdvReadEEPWord(iop_base, eep_addr);
12558 chksum += wval; /* Checksum is calculated from word values. */
12559 if (*charfields++) {
12560 *wbuf = le16_to_cpu(wval);
12561 } else {
12562 *wbuf = wval;
12563 }
12564 }
12565 /* Read checksum word. */
12566 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12567 wbuf++;
12568 charfields++;
12569
12570 /* Read rest of EEPROM not covered by the checksum. */
12571 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
12572 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
12573 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12574 if (*charfields++) {
12575 *wbuf = le16_to_cpu(*wbuf);
12576 }
12577 }
12578 return chksum;
12579}
12580
12581/*
12582 * Read EEPROM configuration into the specified buffer.
12583 *
12584 * Return a checksum based on the EEPROM configuration read.
12585 */
12586static ushort __devinit
12587AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
12588{
12589 ushort wval, chksum;
12590 ushort *wbuf;
12591 int eep_addr;
12592 ushort *charfields;
12593
12594 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
12595 wbuf = (ushort *)cfg_buf;
12596 chksum = 0;
12597
12598 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
12599 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
12600 wval = AdvReadEEPWord(iop_base, eep_addr);
12601 chksum += wval; /* Checksum is calculated from word values. */
12602 if (*charfields++) {
12603 *wbuf = le16_to_cpu(wval);
12604 } else {
12605 *wbuf = wval;
12606 }
12607 }
12608 /* Read checksum word. */
12609 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12610 wbuf++;
12611 charfields++;
12612
12613 /* Read rest of EEPROM not covered by the checksum. */
12614 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
12615 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
12616 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12617 if (*charfields++) {
12618 *wbuf = le16_to_cpu(*wbuf);
12619 }
12620 }
12621 return chksum;
12622}
12623
12624/*
12625 * Read EEPROM configuration into the specified buffer.
12626 *
12627 * Return a checksum based on the EEPROM configuration read.
12628 */
12629static ushort __devinit
12630AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
12631{
12632 ushort wval, chksum;
12633 ushort *wbuf;
12634 int eep_addr;
12635 ushort *charfields;
12636
12637 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
12638 wbuf = (ushort *)cfg_buf;
12639 chksum = 0;
12640
12641 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
12642 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
12643 wval = AdvReadEEPWord(iop_base, eep_addr);
12644 chksum += wval; /* Checksum is calculated from word values. */
12645 if (*charfields++) {
12646 *wbuf = le16_to_cpu(wval);
12647 } else {
12648 *wbuf = wval;
12649 }
12650 }
12651 /* Read checksum word. */
12652 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12653 wbuf++;
12654 charfields++;
12655
12656 /* Read rest of EEPROM not covered by the checksum. */
12657 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
12658 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
12659 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
12660 if (*charfields++) {
12661 *wbuf = le16_to_cpu(*wbuf);
12662 }
12663 }
12664 return chksum;
12665}
12666
12667/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070012668 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
12669 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
12670 * all of this is done.
12671 *
12672 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
12673 *
12674 * For a non-fatal error return a warning code. If there are no warnings
12675 * then 0 is returned.
12676 *
12677 * Note: Chip is stopped on entry.
12678 */
Matthew Wilcox78e77d82007-07-29 21:46:15 -060012679static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012680{
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012681 AdvPortAddr iop_base;
12682 ushort warn_code;
12683 ADVEEP_3550_CONFIG eep_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012684
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012685 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012686
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012687 warn_code = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012688
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012689 /*
12690 * Read the board's EEPROM configuration.
12691 *
12692 * Set default values if a bad checksum is found.
12693 */
12694 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
12695 warn_code |= ASC_WARN_EEPROM_CHKSUM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012696
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012697 /*
12698 * Set EEPROM default values.
12699 */
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040012700 memcpy(&eep_config, &Default_3550_EEPROM_Config,
12701 sizeof(ADVEEP_3550_CONFIG));
Linus Torvalds1da177e2005-04-16 15:20:36 -070012702
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012703 /*
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040012704 * Assume the 6 byte board serial number that was read from
12705 * EEPROM is correct even if the EEPROM checksum failed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012706 */
12707 eep_config.serial_number_word3 =
12708 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070012709
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012710 eep_config.serial_number_word2 =
12711 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -070012712
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012713 eep_config.serial_number_word1 =
12714 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -070012715
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012716 AdvSet3550EEPConfig(iop_base, &eep_config);
12717 }
12718 /*
12719 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
12720 * EEPROM configuration that was read.
12721 *
12722 * This is the mapping of EEPROM fields to Adv Library fields.
12723 */
12724 asc_dvc->wdtr_able = eep_config.wdtr_able;
12725 asc_dvc->sdtr_able = eep_config.sdtr_able;
12726 asc_dvc->ultra_able = eep_config.ultra_able;
12727 asc_dvc->tagqng_able = eep_config.tagqng_able;
12728 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
12729 asc_dvc->max_host_qng = eep_config.max_host_qng;
12730 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
12731 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
12732 asc_dvc->start_motor = eep_config.start_motor;
12733 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
12734 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
12735 asc_dvc->no_scam = eep_config.scam_tolerant;
12736 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
12737 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
12738 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012739
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012740 /*
12741 * Set the host maximum queuing (max. 253, min. 16) and the per device
12742 * maximum queuing (max. 63, min. 4).
12743 */
12744 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
12745 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12746 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
12747 /* If the value is zero, assume it is uninitialized. */
12748 if (eep_config.max_host_qng == 0) {
12749 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12750 } else {
12751 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
12752 }
12753 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012754
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012755 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
12756 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12757 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
12758 /* If the value is zero, assume it is uninitialized. */
12759 if (eep_config.max_dvc_qng == 0) {
12760 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12761 } else {
12762 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
12763 }
12764 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012765
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012766 /*
12767 * If 'max_dvc_qng' is greater than 'max_host_qng', then
12768 * set 'max_dvc_qng' to 'max_host_qng'.
12769 */
12770 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
12771 eep_config.max_dvc_qng = eep_config.max_host_qng;
12772 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012773
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012774 /*
12775 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
12776 * values based on possibly adjusted EEPROM values.
12777 */
12778 asc_dvc->max_host_qng = eep_config.max_host_qng;
12779 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012780
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012781 /*
12782 * If the EEPROM 'termination' field is set to automatic (0), then set
12783 * the ADV_DVC_CFG 'termination' field to automatic also.
12784 *
12785 * If the termination is specified with a non-zero 'termination'
12786 * value check that a legal value is set and set the ADV_DVC_CFG
12787 * 'termination' field appropriately.
12788 */
12789 if (eep_config.termination == 0) {
12790 asc_dvc->cfg->termination = 0; /* auto termination */
12791 } else {
12792 /* Enable manual control with low off / high off. */
12793 if (eep_config.termination == 1) {
12794 asc_dvc->cfg->termination = TERM_CTL_SEL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012795
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012796 /* Enable manual control with low off / high on. */
12797 } else if (eep_config.termination == 2) {
12798 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012799
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012800 /* Enable manual control with low on / high on. */
12801 } else if (eep_config.termination == 3) {
12802 asc_dvc->cfg->termination =
12803 TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
12804 } else {
12805 /*
12806 * The EEPROM 'termination' field contains a bad value. Use
12807 * automatic termination instead.
12808 */
12809 asc_dvc->cfg->termination = 0;
12810 warn_code |= ASC_WARN_EEPROM_TERMINATION;
12811 }
12812 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012813
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012814 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012815}
12816
12817/*
12818 * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
12819 * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
12820 * all of this is done.
12821 *
12822 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
12823 *
12824 * For a non-fatal error return a warning code. If there are no warnings
12825 * then 0 is returned.
12826 *
12827 * Note: Chip is stopped on entry.
12828 */
Matthew Wilcox78e77d82007-07-29 21:46:15 -060012829static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012830{
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012831 AdvPortAddr iop_base;
12832 ushort warn_code;
12833 ADVEEP_38C0800_CONFIG eep_config;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012834 uchar tid, termination;
12835 ushort sdtr_speed = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012836
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012837 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012838
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012839 warn_code = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012840
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012841 /*
12842 * Read the board's EEPROM configuration.
12843 *
12844 * Set default values if a bad checksum is found.
12845 */
12846 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
12847 eep_config.check_sum) {
12848 warn_code |= ASC_WARN_EEPROM_CHKSUM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012849
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012850 /*
12851 * Set EEPROM default values.
12852 */
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040012853 memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
12854 sizeof(ADVEEP_38C0800_CONFIG));
Linus Torvalds1da177e2005-04-16 15:20:36 -070012855
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012856 /*
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040012857 * Assume the 6 byte board serial number that was read from
12858 * EEPROM is correct even if the EEPROM checksum failed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012859 */
12860 eep_config.serial_number_word3 =
12861 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070012862
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012863 eep_config.serial_number_word2 =
12864 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -070012865
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012866 eep_config.serial_number_word1 =
12867 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -070012868
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012869 AdvSet38C0800EEPConfig(iop_base, &eep_config);
12870 }
12871 /*
12872 * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
12873 * EEPROM configuration that was read.
12874 *
12875 * This is the mapping of EEPROM fields to Adv Library fields.
12876 */
12877 asc_dvc->wdtr_able = eep_config.wdtr_able;
12878 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
12879 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
12880 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
12881 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
12882 asc_dvc->tagqng_able = eep_config.tagqng_able;
12883 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
12884 asc_dvc->max_host_qng = eep_config.max_host_qng;
12885 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
12886 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
12887 asc_dvc->start_motor = eep_config.start_motor;
12888 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
12889 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
12890 asc_dvc->no_scam = eep_config.scam_tolerant;
12891 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
12892 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
12893 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012894
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012895 /*
12896 * For every Target ID if any of its 'sdtr_speed[1234]' bits
12897 * are set, then set an 'sdtr_able' bit for it.
12898 */
12899 asc_dvc->sdtr_able = 0;
12900 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
12901 if (tid == 0) {
12902 sdtr_speed = asc_dvc->sdtr_speed1;
12903 } else if (tid == 4) {
12904 sdtr_speed = asc_dvc->sdtr_speed2;
12905 } else if (tid == 8) {
12906 sdtr_speed = asc_dvc->sdtr_speed3;
12907 } else if (tid == 12) {
12908 sdtr_speed = asc_dvc->sdtr_speed4;
12909 }
12910 if (sdtr_speed & ADV_MAX_TID) {
12911 asc_dvc->sdtr_able |= (1 << tid);
12912 }
12913 sdtr_speed >>= 4;
12914 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012915
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012916 /*
12917 * Set the host maximum queuing (max. 253, min. 16) and the per device
12918 * maximum queuing (max. 63, min. 4).
12919 */
12920 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
12921 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12922 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
12923 /* If the value is zero, assume it is uninitialized. */
12924 if (eep_config.max_host_qng == 0) {
12925 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
12926 } else {
12927 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
12928 }
12929 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012930
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012931 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
12932 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12933 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
12934 /* If the value is zero, assume it is uninitialized. */
12935 if (eep_config.max_dvc_qng == 0) {
12936 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
12937 } else {
12938 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
12939 }
12940 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012941
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012942 /*
12943 * If 'max_dvc_qng' is greater than 'max_host_qng', then
12944 * set 'max_dvc_qng' to 'max_host_qng'.
12945 */
12946 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
12947 eep_config.max_dvc_qng = eep_config.max_host_qng;
12948 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012949
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012950 /*
12951 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
12952 * values based on possibly adjusted EEPROM values.
12953 */
12954 asc_dvc->max_host_qng = eep_config.max_host_qng;
12955 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012956
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012957 /*
12958 * If the EEPROM 'termination' field is set to automatic (0), then set
12959 * the ADV_DVC_CFG 'termination' field to automatic also.
12960 *
12961 * If the termination is specified with a non-zero 'termination'
12962 * value check that a legal value is set and set the ADV_DVC_CFG
12963 * 'termination' field appropriately.
12964 */
12965 if (eep_config.termination_se == 0) {
12966 termination = 0; /* auto termination for SE */
12967 } else {
12968 /* Enable manual control with low off / high off. */
12969 if (eep_config.termination_se == 1) {
12970 termination = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012971
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012972 /* Enable manual control with low off / high on. */
12973 } else if (eep_config.termination_se == 2) {
12974 termination = TERM_SE_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012975
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012976 /* Enable manual control with low on / high on. */
12977 } else if (eep_config.termination_se == 3) {
12978 termination = TERM_SE;
12979 } else {
12980 /*
12981 * The EEPROM 'termination_se' field contains a bad value.
12982 * Use automatic termination instead.
12983 */
12984 termination = 0;
12985 warn_code |= ASC_WARN_EEPROM_TERMINATION;
12986 }
12987 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070012988
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012989 if (eep_config.termination_lvd == 0) {
12990 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
12991 } else {
12992 /* Enable manual control with low off / high off. */
12993 if (eep_config.termination_lvd == 1) {
12994 asc_dvc->cfg->termination = termination;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012995
Matthew Wilcox27c868c2007-07-26 10:56:23 -040012996 /* Enable manual control with low off / high on. */
12997 } else if (eep_config.termination_lvd == 2) {
12998 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012999
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013000 /* Enable manual control with low on / high on. */
13001 } else if (eep_config.termination_lvd == 3) {
13002 asc_dvc->cfg->termination = termination | TERM_LVD;
13003 } else {
13004 /*
13005 * The EEPROM 'termination_lvd' field contains a bad value.
13006 * Use automatic termination instead.
13007 */
13008 asc_dvc->cfg->termination = termination;
13009 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13010 }
13011 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013012
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013013 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013014}
13015
13016/*
13017 * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
13018 * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
13019 * all of this is done.
13020 *
13021 * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
13022 *
13023 * For a non-fatal error return a warning code. If there are no warnings
13024 * then 0 is returned.
13025 *
13026 * Note: Chip is stopped on entry.
13027 */
Matthew Wilcox78e77d82007-07-29 21:46:15 -060013028static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013029{
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013030 AdvPortAddr iop_base;
13031 ushort warn_code;
13032 ADVEEP_38C1600_CONFIG eep_config;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013033 uchar tid, termination;
13034 ushort sdtr_speed = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013035
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013036 iop_base = asc_dvc->iop_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013037
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013038 warn_code = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013039
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013040 /*
13041 * Read the board's EEPROM configuration.
13042 *
13043 * Set default values if a bad checksum is found.
13044 */
13045 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
13046 eep_config.check_sum) {
Matthew Wilcox13ac2d92007-07-30 08:10:23 -060013047 struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013048 warn_code |= ASC_WARN_EEPROM_CHKSUM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013049
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013050 /*
13051 * Set EEPROM default values.
13052 */
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013053 memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
13054 sizeof(ADVEEP_38C1600_CONFIG));
Linus Torvalds1da177e2005-04-16 15:20:36 -070013055
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013056 if (PCI_FUNC(pdev->devfn) != 0) {
13057 u8 ints;
13058 /*
13059 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
13060 * and old Mac system booting problem. The Expansion
13061 * ROM must be disabled in Function 1 for these systems
13062 */
13063 eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
13064 /*
13065 * Clear the INTAB (bit 11) if the GPIO 0 input
13066 * indicates the Function 1 interrupt line is wired
13067 * to INTB.
13068 *
13069 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
13070 * 1 - Function 1 interrupt line wired to INT A.
13071 * 0 - Function 1 interrupt line wired to INT B.
13072 *
13073 * Note: Function 0 is always wired to INTA.
13074 * Put all 5 GPIO bits in input mode and then read
13075 * their input values.
13076 */
13077 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
13078 ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
13079 if ((ints & 0x01) == 0)
13080 eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013081 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013082
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013083 /*
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013084 * Assume the 6 byte board serial number that was read from
13085 * EEPROM is correct even if the EEPROM checksum failed.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013086 */
13087 eep_config.serial_number_word3 =
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013088 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013089 eep_config.serial_number_word2 =
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013090 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013091 eep_config.serial_number_word1 =
Matthew Wilcoxd68f4322007-07-26 11:58:12 -040013092 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013093
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013094 AdvSet38C1600EEPConfig(iop_base, &eep_config);
13095 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013096
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013097 /*
13098 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
13099 * EEPROM configuration that was read.
13100 *
13101 * This is the mapping of EEPROM fields to Adv Library fields.
13102 */
13103 asc_dvc->wdtr_able = eep_config.wdtr_able;
13104 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
13105 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
13106 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
13107 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
13108 asc_dvc->ppr_able = 0;
13109 asc_dvc->tagqng_able = eep_config.tagqng_able;
13110 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
13111 asc_dvc->max_host_qng = eep_config.max_host_qng;
13112 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
13113 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
13114 asc_dvc->start_motor = eep_config.start_motor;
13115 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
13116 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
13117 asc_dvc->no_scam = eep_config.scam_tolerant;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013118
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013119 /*
13120 * For every Target ID if any of its 'sdtr_speed[1234]' bits
13121 * are set, then set an 'sdtr_able' bit for it.
13122 */
13123 asc_dvc->sdtr_able = 0;
13124 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
13125 if (tid == 0) {
13126 sdtr_speed = asc_dvc->sdtr_speed1;
13127 } else if (tid == 4) {
13128 sdtr_speed = asc_dvc->sdtr_speed2;
13129 } else if (tid == 8) {
13130 sdtr_speed = asc_dvc->sdtr_speed3;
13131 } else if (tid == 12) {
13132 sdtr_speed = asc_dvc->sdtr_speed4;
13133 }
13134 if (sdtr_speed & ASC_MAX_TID) {
13135 asc_dvc->sdtr_able |= (1 << tid);
13136 }
13137 sdtr_speed >>= 4;
13138 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013139
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013140 /*
13141 * Set the host maximum queuing (max. 253, min. 16) and the per device
13142 * maximum queuing (max. 63, min. 4).
13143 */
13144 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
13145 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13146 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
13147 /* If the value is zero, assume it is uninitialized. */
13148 if (eep_config.max_host_qng == 0) {
13149 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
13150 } else {
13151 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
13152 }
13153 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013154
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013155 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
13156 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13157 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
13158 /* If the value is zero, assume it is uninitialized. */
13159 if (eep_config.max_dvc_qng == 0) {
13160 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
13161 } else {
13162 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
13163 }
13164 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013165
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013166 /*
13167 * If 'max_dvc_qng' is greater than 'max_host_qng', then
13168 * set 'max_dvc_qng' to 'max_host_qng'.
13169 */
13170 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
13171 eep_config.max_dvc_qng = eep_config.max_host_qng;
13172 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013173
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013174 /*
13175 * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
13176 * values based on possibly adjusted EEPROM values.
13177 */
13178 asc_dvc->max_host_qng = eep_config.max_host_qng;
13179 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013180
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013181 /*
13182 * If the EEPROM 'termination' field is set to automatic (0), then set
13183 * the ASC_DVC_CFG 'termination' field to automatic also.
13184 *
13185 * If the termination is specified with a non-zero 'termination'
13186 * value check that a legal value is set and set the ASC_DVC_CFG
13187 * 'termination' field appropriately.
13188 */
13189 if (eep_config.termination_se == 0) {
13190 termination = 0; /* auto termination for SE */
13191 } else {
13192 /* Enable manual control with low off / high off. */
13193 if (eep_config.termination_se == 1) {
13194 termination = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013195
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013196 /* Enable manual control with low off / high on. */
13197 } else if (eep_config.termination_se == 2) {
13198 termination = TERM_SE_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013199
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013200 /* Enable manual control with low on / high on. */
13201 } else if (eep_config.termination_se == 3) {
13202 termination = TERM_SE;
13203 } else {
13204 /*
13205 * The EEPROM 'termination_se' field contains a bad value.
13206 * Use automatic termination instead.
13207 */
13208 termination = 0;
13209 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13210 }
13211 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013212
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013213 if (eep_config.termination_lvd == 0) {
13214 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
13215 } else {
13216 /* Enable manual control with low off / high off. */
13217 if (eep_config.termination_lvd == 1) {
13218 asc_dvc->cfg->termination = termination;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013219
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013220 /* Enable manual control with low off / high on. */
13221 } else if (eep_config.termination_lvd == 2) {
13222 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013223
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013224 /* Enable manual control with low on / high on. */
13225 } else if (eep_config.termination_lvd == 3) {
13226 asc_dvc->cfg->termination = termination | TERM_LVD;
13227 } else {
13228 /*
13229 * The EEPROM 'termination_lvd' field contains a bad value.
13230 * Use automatic termination instead.
13231 */
13232 asc_dvc->cfg->termination = termination;
13233 warn_code |= ASC_WARN_EEPROM_TERMINATION;
13234 }
13235 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013236
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013237 return warn_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013238}
13239
13240/*
Matthew Wilcox51219352007-10-02 21:55:22 -040013241 * Initialize the ADV_DVC_VAR structure.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013242 *
Matthew Wilcox51219352007-10-02 21:55:22 -040013243 * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013244 *
Matthew Wilcox51219352007-10-02 21:55:22 -040013245 * For a non-fatal error return a warning code. If there are no warnings
13246 * then 0 is returned.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013247 */
Matthew Wilcox51219352007-10-02 21:55:22 -040013248static int __devinit
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013249AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013250{
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013251 struct asc_board *board = shost_priv(shost);
13252 ADV_DVC_VAR *asc_dvc = &board->dvc_var.adv_dvc_var;
Matthew Wilcox51219352007-10-02 21:55:22 -040013253 unsigned short warn_code = 0;
13254 AdvPortAddr iop_base = asc_dvc->iop_base;
13255 u16 cmd;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013256 int status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013257
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013258 asc_dvc->err_code = 0;
Matthew Wilcox51219352007-10-02 21:55:22 -040013259
13260 /*
13261 * Save the state of the PCI Configuration Command Register
13262 * "Parity Error Response Control" Bit. If the bit is clear (0),
13263 * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
13264 * DMA parity errors.
13265 */
13266 asc_dvc->cfg->control_flag = 0;
13267 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
13268 if ((cmd & PCI_COMMAND_PARITY) == 0)
13269 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
13270
Matthew Wilcox51219352007-10-02 21:55:22 -040013271 asc_dvc->cfg->chip_version =
13272 AdvGetChipVersion(iop_base, asc_dvc->bus_type);
13273
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013274 ASC_DBG(1, "iopb_chip_id_1: 0x%x 0x%x\n",
Matthew Wilcox51219352007-10-02 21:55:22 -040013275 (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
13276 (ushort)ADV_CHIP_ID_BYTE);
13277
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013278 ASC_DBG(1, "iopw_chip_id_0: 0x%x 0x%x\n",
Matthew Wilcox51219352007-10-02 21:55:22 -040013279 (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
13280 (ushort)ADV_CHIP_ID_WORD);
13281
13282 /*
13283 * Reset the chip to start and allow register writes.
13284 */
13285 if (AdvFindSignature(iop_base) == 0) {
13286 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
13287 return ADV_ERROR;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013288 } else {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013289 /*
Matthew Wilcox51219352007-10-02 21:55:22 -040013290 * The caller must set 'chip_type' to a valid setting.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013291 */
Matthew Wilcox51219352007-10-02 21:55:22 -040013292 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
13293 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
13294 asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
13295 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
13296 return ADV_ERROR;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013297 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013298
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013299 /*
Matthew Wilcox51219352007-10-02 21:55:22 -040013300 * Reset Chip.
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013301 */
Matthew Wilcox51219352007-10-02 21:55:22 -040013302 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13303 ADV_CTRL_REG_CMD_RESET);
13304 mdelay(100);
13305 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
13306 ADV_CTRL_REG_CMD_WR_IO_REG);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013307
Matthew Wilcox51219352007-10-02 21:55:22 -040013308 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
13309 status = AdvInitFrom38C1600EEP(asc_dvc);
13310 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
13311 status = AdvInitFrom38C0800EEP(asc_dvc);
13312 } else {
13313 status = AdvInitFrom3550EEP(asc_dvc);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013314 }
Matthew Wilcox51219352007-10-02 21:55:22 -040013315 warn_code |= status;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013316 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070013317
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013318 if (warn_code != 0)
13319 shost_printk(KERN_WARNING, shost, "warning: 0x%x\n", warn_code);
Matthew Wilcox51219352007-10-02 21:55:22 -040013320
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013321 if (asc_dvc->err_code)
13322 shost_printk(KERN_ERR, shost, "error code 0x%x\n",
13323 asc_dvc->err_code);
Matthew Wilcox51219352007-10-02 21:55:22 -040013324
13325 return asc_dvc->err_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013326}
Matthew Wilcox51219352007-10-02 21:55:22 -040013327#endif
13328
13329static struct scsi_host_template advansys_template = {
13330 .proc_name = DRV_NAME,
13331#ifdef CONFIG_PROC_FS
13332 .proc_info = advansys_proc_info,
13333#endif
13334 .name = DRV_NAME,
13335 .info = advansys_info,
13336 .queuecommand = advansys_queuecommand,
13337 .eh_bus_reset_handler = advansys_reset,
13338 .bios_param = advansys_biosparam,
13339 .slave_configure = advansys_slave_configure,
13340 /*
13341 * Because the driver may control an ISA adapter 'unchecked_isa_dma'
13342 * must be set. The flag will be cleared in advansys_board_found
13343 * for non-ISA adapters.
13344 */
13345 .unchecked_isa_dma = 1,
13346 /*
13347 * All adapters controlled by this driver are capable of large
13348 * scatter-gather lists. According to the mid-level SCSI documentation
13349 * this obviates any performance gain provided by setting
13350 * 'use_clustering'. But empirically while CPU utilization is increased
13351 * by enabling clustering, I/O throughput increases as well.
13352 */
13353 .use_clustering = ENABLE_CLUSTERING,
13354};
Linus Torvalds1da177e2005-04-16 15:20:36 -070013355
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013356static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013357{
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013358 struct asc_board *board = shost_priv(shost);
13359 struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013360 int req_cnt = 0;
13361 adv_req_t *reqp = NULL;
13362 int sg_cnt = 0;
13363 adv_sgblk_t *sgp;
13364 int warn_code, err_code;
13365
13366 /*
13367 * Allocate buffer carrier structures. The total size
13368 * is about 4 KB, so allocate all at once.
13369 */
Matthew Wilcox98d41c22007-10-02 21:55:37 -040013370 adv_dvc->carrier_buf = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
13371 ASC_DBG(1, "carrier_buf 0x%p\n", adv_dvc->carrier_buf);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013372
Matthew Wilcox98d41c22007-10-02 21:55:37 -040013373 if (!adv_dvc->carrier_buf)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013374 goto kmalloc_failed;
13375
13376 /*
13377 * Allocate up to 'max_host_qng' request structures for the Wide
13378 * board. The total size is about 16 KB, so allocate all at once.
13379 * If the allocation fails decrement and try again.
13380 */
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013381 for (req_cnt = adv_dvc->max_host_qng; req_cnt > 0; req_cnt--) {
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013382 reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
13383
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013384 ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013385 (ulong)sizeof(adv_req_t) * req_cnt);
13386
13387 if (reqp)
13388 break;
13389 }
13390
13391 if (!reqp)
13392 goto kmalloc_failed;
13393
Matthew Wilcox98d41c22007-10-02 21:55:37 -040013394 adv_dvc->orig_reqp = reqp;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013395
13396 /*
13397 * Allocate up to ADV_TOT_SG_BLOCK request structures for
13398 * the Wide board. Each structure is about 136 bytes.
13399 */
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013400 board->adv_sgblkp = NULL;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013401 for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
13402 sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
13403
13404 if (!sgp)
13405 break;
13406
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013407 sgp->next_sgblkp = board->adv_sgblkp;
13408 board->adv_sgblkp = sgp;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013409
13410 }
13411
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013412 ASC_DBG(1, "sg_cnt %d * %u = %u bytes\n", sg_cnt, sizeof(adv_sgblk_t),
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013413 (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
13414
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013415 if (!board->adv_sgblkp)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013416 goto kmalloc_failed;
13417
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013418 /*
13419 * Point 'adv_reqp' to the request structures and
13420 * link them together.
13421 */
13422 req_cnt--;
13423 reqp[req_cnt].next_reqp = NULL;
13424 for (; req_cnt > 0; req_cnt--) {
13425 reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
13426 }
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013427 board->adv_reqp = &reqp[0];
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013428
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013429 if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013430 ASC_DBG(2, "AdvInitAsc3550Driver()\n");
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013431 warn_code = AdvInitAsc3550Driver(adv_dvc);
13432 } else if (adv_dvc->chip_type == ADV_CHIP_ASC38C0800) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013433 ASC_DBG(2, "AdvInitAsc38C0800Driver()\n");
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013434 warn_code = AdvInitAsc38C0800Driver(adv_dvc);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013435 } else {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013436 ASC_DBG(2, "AdvInitAsc38C1600Driver()\n");
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013437 warn_code = AdvInitAsc38C1600Driver(adv_dvc);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013438 }
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013439 err_code = adv_dvc->err_code;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013440
13441 if (warn_code || err_code) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013442 shost_printk(KERN_WARNING, shost, "error: warn 0x%x, error "
13443 "0x%x\n", warn_code, err_code);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013444 }
13445
13446 goto exit;
13447
13448 kmalloc_failed:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013449 shost_printk(KERN_ERR, shost, "error: kmalloc() failed\n");
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013450 err_code = ADV_ERROR;
13451 exit:
13452 return err_code;
13453}
13454
Matthew Wilcox98d41c22007-10-02 21:55:37 -040013455static void advansys_wide_free_mem(struct asc_board *board)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013456{
Matthew Wilcox98d41c22007-10-02 21:55:37 -040013457 struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
13458 kfree(adv_dvc->carrier_buf);
13459 adv_dvc->carrier_buf = NULL;
13460 kfree(adv_dvc->orig_reqp);
13461 adv_dvc->orig_reqp = board->adv_reqp = NULL;
13462 while (board->adv_sgblkp) {
13463 adv_sgblk_t *sgp = board->adv_sgblkp;
13464 board->adv_sgblkp = sgp->next_sgblkp;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013465 kfree(sgp);
13466 }
13467}
13468
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013469static int __devinit advansys_board_found(struct Scsi_Host *shost,
13470 unsigned int iop, int bus_type)
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013471{
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013472 struct pci_dev *pdev;
Matthew Wilcoxd2411492007-10-02 21:55:31 -040013473 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013474 ASC_DVC_VAR *asc_dvc_varp = NULL;
13475 ADV_DVC_VAR *adv_dvc_varp = NULL;
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013476 int share_irq, warn_code, ret;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013477
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013478 pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013479
13480 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013481 ASC_DBG(1, "narrow board\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013482 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
13483 asc_dvc_varp->bus_type = bus_type;
13484 asc_dvc_varp->drv_ptr = boardp;
13485 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
13486 asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
13487 asc_dvc_varp->iop_base = iop;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013488 } else {
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040013489#ifdef CONFIG_PCI
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013490 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
13491 adv_dvc_varp->drv_ptr = boardp;
13492 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013493 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013494 ASC_DBG(1, "wide board ASC-3550\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013495 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
13496 } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013497 ASC_DBG(1, "wide board ASC-38C0800\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013498 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
13499 } else {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013500 ASC_DBG(1, "wide board ASC-38C1600\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013501 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
13502 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013503
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040013504 boardp->asc_n_io_port = pci_resource_len(pdev, 1);
13505 boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
13506 boardp->asc_n_io_port);
13507 if (!boardp->ioremap_addr) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013508 shost_printk(KERN_ERR, shost, "ioremap(%x, %d) "
13509 "returned NULL\n",
13510 pci_resource_start(pdev, 1),
13511 boardp->asc_n_io_port);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013512 ret = -ENODEV;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013513 goto err_shost;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013514 }
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013515 adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr;
13516 ASC_DBG(1, "iop_base: 0x%p\n", adv_dvc_varp->iop_base);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013517
13518 /*
13519 * Even though it isn't used to access wide boards, other
13520 * than for the debug line below, save I/O Port address so
13521 * that it can be reported.
13522 */
13523 boardp->ioport = iop;
13524
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013525 ASC_DBG(1, "iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
13526 (ushort)inp(iop + 1), (ushort)inpw(iop));
Matthew Wilcox57ba5fe2007-07-26 11:55:07 -040013527#endif /* CONFIG_PCI */
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013528 }
13529
13530#ifdef CONFIG_PROC_FS
13531 /*
13532 * Allocate buffer for printing information from
13533 * /proc/scsi/advansys/[0...].
13534 */
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013535 boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
13536 if (!boardp->prtbuf) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013537 shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n",
13538 ASC_PRTBUF_SIZE);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013539 ret = -ENOMEM;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013540 goto err_unmap;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013541 }
13542#endif /* CONFIG_PROC_FS */
13543
13544 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013545 /*
13546 * Set the board bus type and PCI IRQ before
13547 * calling AscInitGetConfig().
13548 */
13549 switch (asc_dvc_varp->bus_type) {
13550#ifdef CONFIG_ISA
13551 case ASC_IS_ISA:
13552 shost->unchecked_isa_dma = TRUE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060013553 share_irq = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013554 break;
13555 case ASC_IS_VL:
13556 shost->unchecked_isa_dma = FALSE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060013557 share_irq = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013558 break;
13559 case ASC_IS_EISA:
13560 shost->unchecked_isa_dma = FALSE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060013561 share_irq = IRQF_SHARED;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013562 break;
13563#endif /* CONFIG_ISA */
13564#ifdef CONFIG_PCI
13565 case ASC_IS_PCI:
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013566 shost->unchecked_isa_dma = FALSE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060013567 share_irq = IRQF_SHARED;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013568 break;
13569#endif /* CONFIG_PCI */
13570 default:
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013571 shost_printk(KERN_ERR, shost, "unknown adapter type: "
13572 "%d\n", asc_dvc_varp->bus_type);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013573 shost->unchecked_isa_dma = TRUE;
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060013574 share_irq = 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013575 break;
13576 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013577
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013578 /*
13579 * NOTE: AscInitGetConfig() may change the board's
13580 * bus_type value. The bus_type value should no
13581 * longer be used. If the bus_type field must be
13582 * referenced only use the bit-wise AND operator "&".
13583 */
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013584 ASC_DBG(2, "AscInitGetConfig()\n");
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013585 ret = AscInitGetConfig(shost) ? -ENODEV : 0;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013586 } else {
Matthew Wilcoxc2dce2f2007-09-09 08:56:30 -060013587#ifdef CONFIG_PCI
13588 /*
13589 * For Wide boards set PCI information before calling
13590 * AdvInitGetConfig().
13591 */
Matthew Wilcoxc2dce2f2007-09-09 08:56:30 -060013592 shost->unchecked_isa_dma = FALSE;
13593 share_irq = IRQF_SHARED;
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013594 ASC_DBG(2, "AdvInitGetConfig()\n");
Matthew Wilcox394dbf32007-07-26 11:56:40 -040013595
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013596 ret = AdvInitGetConfig(pdev, shost) ? -ENODEV : 0;
Matthew Wilcoxc2dce2f2007-09-09 08:56:30 -060013597#endif /* CONFIG_PCI */
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013598 }
13599
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013600 if (ret)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013601 goto err_free_proc;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013602
13603 /*
13604 * Save the EEPROM configuration so that it can be displayed
13605 * from /proc/scsi/advansys/[0...].
13606 */
13607 if (ASC_NARROW_BOARD(boardp)) {
13608
13609 ASCEEP_CONFIG *ep;
13610
13611 /*
13612 * Set the adapter's target id bit in the 'init_tidmask' field.
13613 */
13614 boardp->init_tidmask |=
13615 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
13616
13617 /*
13618 * Save EEPROM settings for the board.
13619 */
13620 ep = &boardp->eep_config.asc_eep;
13621
13622 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
13623 ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
13624 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
13625 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
13626 ep->start_motor = asc_dvc_varp->start_motor;
13627 ep->cntl = asc_dvc_varp->dvc_cntl;
13628 ep->no_scam = asc_dvc_varp->no_scam;
13629 ep->max_total_qng = asc_dvc_varp->max_total_qng;
13630 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
13631 /* 'max_tag_qng' is set to the same value for every device. */
13632 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
13633 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
13634 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
13635 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
13636 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
13637 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
13638 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
13639
13640 /*
13641 * Modify board configuration.
13642 */
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013643 ASC_DBG(2, "AscInitSetConfig()\n");
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013644 ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0;
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013645 if (ret)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013646 goto err_free_proc;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013647 } else {
13648 ADVEEP_3550_CONFIG *ep_3550;
13649 ADVEEP_38C0800_CONFIG *ep_38C0800;
13650 ADVEEP_38C1600_CONFIG *ep_38C1600;
13651
13652 /*
13653 * Save Wide EEP Configuration Information.
13654 */
13655 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
13656 ep_3550 = &boardp->eep_config.adv_3550_eep;
13657
13658 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
13659 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
13660 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
13661 ep_3550->termination = adv_dvc_varp->cfg->termination;
13662 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
13663 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
13664 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
13665 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
13666 ep_3550->ultra_able = adv_dvc_varp->ultra_able;
13667 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
13668 ep_3550->start_motor = adv_dvc_varp->start_motor;
13669 ep_3550->scsi_reset_delay =
13670 adv_dvc_varp->scsi_reset_wait;
13671 ep_3550->serial_number_word1 =
13672 adv_dvc_varp->cfg->serial1;
13673 ep_3550->serial_number_word2 =
13674 adv_dvc_varp->cfg->serial2;
13675 ep_3550->serial_number_word3 =
13676 adv_dvc_varp->cfg->serial3;
13677 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
13678 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
13679
13680 ep_38C0800->adapter_scsi_id =
13681 adv_dvc_varp->chip_scsi_id;
13682 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
13683 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
13684 ep_38C0800->termination_lvd =
13685 adv_dvc_varp->cfg->termination;
13686 ep_38C0800->disc_enable =
13687 adv_dvc_varp->cfg->disc_enable;
13688 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
13689 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
13690 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
13691 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
13692 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
13693 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
13694 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
13695 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
13696 ep_38C0800->start_motor = adv_dvc_varp->start_motor;
13697 ep_38C0800->scsi_reset_delay =
13698 adv_dvc_varp->scsi_reset_wait;
13699 ep_38C0800->serial_number_word1 =
13700 adv_dvc_varp->cfg->serial1;
13701 ep_38C0800->serial_number_word2 =
13702 adv_dvc_varp->cfg->serial2;
13703 ep_38C0800->serial_number_word3 =
13704 adv_dvc_varp->cfg->serial3;
13705 } else {
13706 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
13707
13708 ep_38C1600->adapter_scsi_id =
13709 adv_dvc_varp->chip_scsi_id;
13710 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
13711 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
13712 ep_38C1600->termination_lvd =
13713 adv_dvc_varp->cfg->termination;
13714 ep_38C1600->disc_enable =
13715 adv_dvc_varp->cfg->disc_enable;
13716 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
13717 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
13718 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
13719 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
13720 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
13721 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
13722 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
13723 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
13724 ep_38C1600->start_motor = adv_dvc_varp->start_motor;
13725 ep_38C1600->scsi_reset_delay =
13726 adv_dvc_varp->scsi_reset_wait;
13727 ep_38C1600->serial_number_word1 =
13728 adv_dvc_varp->cfg->serial1;
13729 ep_38C1600->serial_number_word2 =
13730 adv_dvc_varp->cfg->serial2;
13731 ep_38C1600->serial_number_word3 =
13732 adv_dvc_varp->cfg->serial3;
13733 }
13734
13735 /*
13736 * Set the adapter's target id bit in the 'init_tidmask' field.
13737 */
13738 boardp->init_tidmask |=
13739 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013740 }
13741
13742 /*
13743 * Channels are numbered beginning with 0. For AdvanSys one host
13744 * structure supports one channel. Multi-channel boards have a
13745 * separate host structure for each channel.
13746 */
13747 shost->max_channel = 0;
13748 if (ASC_NARROW_BOARD(boardp)) {
13749 shost->max_id = ASC_MAX_TID + 1;
13750 shost->max_lun = ASC_MAX_LUN + 1;
Matthew Wilcoxf05ec592007-09-09 08:56:36 -060013751 shost->max_cmd_len = ASC_MAX_CDB_LEN;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013752
13753 shost->io_port = asc_dvc_varp->iop_base;
13754 boardp->asc_n_io_port = ASC_IOADR_GAP;
13755 shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
13756
13757 /* Set maximum number of queues the adapter can handle. */
13758 shost->can_queue = asc_dvc_varp->max_total_qng;
13759 } else {
13760 shost->max_id = ADV_MAX_TID + 1;
13761 shost->max_lun = ADV_MAX_LUN + 1;
Matthew Wilcoxf05ec592007-09-09 08:56:36 -060013762 shost->max_cmd_len = ADV_MAX_CDB_LEN;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013763
13764 /*
13765 * Save the I/O Port address and length even though
13766 * I/O ports are not used to access Wide boards.
13767 * Instead the Wide boards are accessed with
13768 * PCI Memory Mapped I/O.
13769 */
13770 shost->io_port = iop;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013771
13772 shost->this_id = adv_dvc_varp->chip_scsi_id;
13773
13774 /* Set maximum number of queues the adapter can handle. */
13775 shost->can_queue = adv_dvc_varp->max_host_qng;
13776 }
13777
13778 /*
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013779 * Following v1.3.89, 'cmd_per_lun' is no longer needed
13780 * and should be set to zero.
13781 *
13782 * But because of a bug introduced in v1.3.89 if the driver is
13783 * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
13784 * SCSI function 'allocate_device' will panic. To allow the driver
13785 * to work as a module in these kernels set 'cmd_per_lun' to 1.
13786 *
13787 * Note: This is wrong. cmd_per_lun should be set to the depth
13788 * you want on untagged devices always.
13789 #ifdef MODULE
13790 */
13791 shost->cmd_per_lun = 1;
13792/* #else
13793 shost->cmd_per_lun = 0;
13794#endif */
13795
13796 /*
13797 * Set the maximum number of scatter-gather elements the
13798 * adapter can handle.
13799 */
13800 if (ASC_NARROW_BOARD(boardp)) {
13801 /*
13802 * Allow two commands with 'sg_tablesize' scatter-gather
13803 * elements to be executed simultaneously. This value is
13804 * the theoretical hardware limit. It may be decreased
13805 * below.
13806 */
13807 shost->sg_tablesize =
13808 (((asc_dvc_varp->max_total_qng - 2) / 2) *
13809 ASC_SG_LIST_PER_Q) + 1;
13810 } else {
13811 shost->sg_tablesize = ADV_MAX_SG_LIST;
13812 }
13813
13814 /*
13815 * The value of 'sg_tablesize' can not exceed the SCSI
13816 * mid-level driver definition of SG_ALL. SG_ALL also
13817 * must not be exceeded, because it is used to define the
13818 * size of the scatter-gather table in 'struct asc_sg_head'.
13819 */
13820 if (shost->sg_tablesize > SG_ALL) {
13821 shost->sg_tablesize = SG_ALL;
13822 }
13823
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013824 ASC_DBG(1, "sg_tablesize: %d\n", shost->sg_tablesize);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013825
13826 /* BIOS start address. */
13827 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013828 shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
13829 asc_dvc_varp->bus_type);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013830 } else {
13831 /*
13832 * Fill-in BIOS board variables. The Wide BIOS saves
13833 * information in LRAM that is used by the driver.
13834 */
13835 AdvReadWordLram(adv_dvc_varp->iop_base,
13836 BIOS_SIGNATURE, boardp->bios_signature);
13837 AdvReadWordLram(adv_dvc_varp->iop_base,
13838 BIOS_VERSION, boardp->bios_version);
13839 AdvReadWordLram(adv_dvc_varp->iop_base,
13840 BIOS_CODESEG, boardp->bios_codeseg);
13841 AdvReadWordLram(adv_dvc_varp->iop_base,
13842 BIOS_CODELEN, boardp->bios_codelen);
13843
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013844 ASC_DBG(1, "bios_signature 0x%x, bios_version 0x%x\n",
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013845 boardp->bios_signature, boardp->bios_version);
13846
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013847 ASC_DBG(1, "bios_codeseg 0x%x, bios_codelen 0x%x\n",
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013848 boardp->bios_codeseg, boardp->bios_codelen);
13849
13850 /*
13851 * If the BIOS saved a valid signature, then fill in
13852 * the BIOS code segment base address.
13853 */
13854 if (boardp->bios_signature == 0x55AA) {
13855 /*
13856 * Convert x86 realmode code segment to a linear
13857 * address by shifting left 4.
13858 */
13859 shost->base = ((ulong)boardp->bios_codeseg << 4);
13860 } else {
13861 shost->base = 0;
13862 }
13863 }
13864
13865 /*
13866 * Register Board Resources - I/O Port, DMA, IRQ
13867 */
13868
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013869 /* Register DMA Channel for Narrow boards. */
13870 shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
13871#ifdef CONFIG_ISA
13872 if (ASC_NARROW_BOARD(boardp)) {
13873 /* Register DMA channel for ISA bus. */
13874 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
13875 shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060013876 ret = request_dma(shost->dma_channel, DRV_NAME);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013877 if (ret) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013878 shost_printk(KERN_ERR, shost, "request_dma() "
13879 "%d failed %d\n",
13880 shost->dma_channel, ret);
Matthew Wilcox71f36112007-07-30 08:04:53 -060013881 goto err_free_proc;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013882 }
13883 AscEnableIsaDma(shost->dma_channel);
13884 }
13885 }
13886#endif /* CONFIG_ISA */
13887
13888 /* Register IRQ Number. */
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013889 ASC_DBG(2, "request_irq(%d, %p)\n", boardp->irq, shost);
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060013890
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013891 ret = request_irq(boardp->irq, advansys_interrupt, share_irq,
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060013892 DRV_NAME, shost);
Matthew Wilcox074c8fe2007-07-28 23:11:05 -060013893
13894 if (ret) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013895 if (ret == -EBUSY) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013896 shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
13897 "already in use\n", boardp->irq);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013898 } else if (ret == -EINVAL) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013899 shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
13900 "not valid\n", boardp->irq);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013901 } else {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013902 shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
13903 "failed with %d\n", boardp->irq, ret);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013904 }
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013905 goto err_free_dma;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013906 }
13907
13908 /*
13909 * Initialize board RISC chip and enable interrupts.
13910 */
13911 if (ASC_NARROW_BOARD(boardp)) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013912 ASC_DBG(2, "AscInitAsc1000Driver()\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013913 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013914
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013915 if (warn_code || asc_dvc_varp->err_code) {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013916 shost_printk(KERN_ERR, shost, "error: init_state 0x%x, "
13917 "warn 0x%x, error 0x%x\n",
13918 asc_dvc_varp->init_state, warn_code,
13919 asc_dvc_varp->err_code);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013920 if (asc_dvc_varp->err_code)
13921 ret = -ENODEV;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013922 }
13923 } else {
Matthew Wilcox9d0e96e2007-10-02 21:55:35 -040013924 if (advansys_wide_init_chip(shost))
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013925 ret = -ENODEV;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013926 }
13927
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013928 if (ret)
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013929 goto err_free_wide_mem;
13930
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013931 ASC_DBG_PRT_SCSI_HOST(2, shost);
13932
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013933 ret = scsi_add_host(shost, boardp->dev);
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060013934 if (ret)
13935 goto err_free_wide_mem;
13936
13937 scsi_scan_host(shost);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013938 return 0;
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013939
13940 err_free_wide_mem:
13941 advansys_wide_free_mem(boardp);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013942 free_irq(boardp->irq, shost);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013943 err_free_dma:
13944 if (shost->dma_channel != NO_ISA_DMA)
13945 free_dma(shost->dma_channel);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013946 err_free_proc:
13947 kfree(boardp->prtbuf);
13948 err_unmap:
13949 if (boardp->ioremap_addr)
13950 iounmap(boardp->ioremap_addr);
13951 err_shost:
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013952 return ret;
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013953}
13954
13955/*
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013956 * advansys_release()
13957 *
13958 * Release resources allocated for a single AdvanSys adapter.
13959 */
13960static int advansys_release(struct Scsi_Host *shost)
13961{
Matthew Wilcoxd2411492007-10-02 21:55:31 -040013962 struct asc_board *boardp = shost_priv(shost);
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013963 ASC_DBG(1, "begin\n");
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060013964 scsi_remove_host(shost);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013965 free_irq(boardp->irq, shost);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013966 if (shost->dma_channel != NO_ISA_DMA) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013967 ASC_DBG(1, "free_dma()\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013968 free_dma(shost->dma_channel);
13969 }
Matthew Wilcox9a256fa2007-10-02 21:55:28 -040013970 if (!ASC_NARROW_BOARD(boardp)) {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013971 iounmap(boardp->ioremap_addr);
Matthew Wilcoxb2c16f52007-07-29 17:30:28 -060013972 advansys_wide_free_mem(boardp);
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013973 }
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013974 kfree(boardp->prtbuf);
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060013975 scsi_host_put(shost);
Matthew Wilcoxb352f922007-10-02 21:55:33 -040013976 ASC_DBG(1, "end\n");
Matthew Wilcox27c868c2007-07-26 10:56:23 -040013977 return 0;
13978}
13979
Matthew Wilcox95c9f162007-09-09 08:56:39 -060013980#define ASC_IOADR_TABLE_MAX_IX 11
13981
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060013982static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
13983 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
13984 0x0210, 0x0230, 0x0250, 0x0330
13985};
13986
Matthew Wilcoxd361db42007-10-02 21:55:29 -040013987/*
13988 * The ISA IRQ number is found in bits 2 and 3 of the CfgLsw. It decodes as:
13989 * 00: 10
13990 * 01: 11
13991 * 10: 12
13992 * 11: 15
13993 */
13994static unsigned int __devinit advansys_isa_irq_no(PortAddr iop_base)
13995{
13996 unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
13997 unsigned int chip_irq = ((cfg_lsw >> 2) & 0x03) + 10;
13998 if (chip_irq == 13)
13999 chip_irq = 15;
14000 return chip_irq;
14001}
14002
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014003static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
14004{
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014005 int err = -ENODEV;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014006 PortAddr iop_base = _asc_def_iop_base[id];
14007 struct Scsi_Host *shost;
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014008 struct asc_board *board;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014009
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014010 if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040014011 ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014012 return -ENODEV;
14013 }
Matthew Wilcoxb352f922007-10-02 21:55:33 -040014014 ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014015 if (!AscFindSignature(iop_base))
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014016 goto release_region;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014017 if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014018 goto release_region;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014019
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014020 err = -ENOMEM;
14021 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014022 if (!shost)
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014023 goto release_region;
14024
Matthew Wilcoxd2411492007-10-02 21:55:31 -040014025 board = shost_priv(shost);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014026 board->irq = advansys_isa_irq_no(iop_base);
14027 board->dev = dev;
14028
14029 err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
14030 if (err)
14031 goto free_host;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014032
14033 dev_set_drvdata(dev, shost);
14034 return 0;
14035
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014036 free_host:
14037 scsi_host_put(shost);
14038 release_region:
Matthew Wilcox71f36112007-07-30 08:04:53 -060014039 release_region(iop_base, ASC_IOADR_GAP);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014040 return err;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014041}
14042
14043static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
14044{
Matthew Wilcox71f36112007-07-30 08:04:53 -060014045 int ioport = _asc_def_iop_base[id];
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014046 advansys_release(dev_get_drvdata(dev));
Matthew Wilcox71f36112007-07-30 08:04:53 -060014047 release_region(ioport, ASC_IOADR_GAP);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014048 return 0;
14049}
14050
14051static struct isa_driver advansys_isa_driver = {
14052 .probe = advansys_isa_probe,
14053 .remove = __devexit_p(advansys_isa_remove),
14054 .driver = {
14055 .owner = THIS_MODULE,
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014056 .name = DRV_NAME,
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014057 },
14058};
14059
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014060/*
14061 * The VLB IRQ number is found in bits 2 to 4 of the CfgLsw. It decodes as:
14062 * 000: invalid
14063 * 001: 10
14064 * 010: 11
14065 * 011: 12
14066 * 100: invalid
14067 * 101: 14
14068 * 110: 15
14069 * 111: invalid
14070 */
14071static unsigned int __devinit advansys_vlb_irq_no(PortAddr iop_base)
14072{
14073 unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
14074 unsigned int chip_irq = ((cfg_lsw >> 2) & 0x07) + 9;
14075 if ((chip_irq < 10) || (chip_irq == 13) || (chip_irq > 15))
14076 return 0;
14077 return chip_irq;
14078}
14079
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014080static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
14081{
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014082 int err = -ENODEV;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014083 PortAddr iop_base = _asc_def_iop_base[id];
14084 struct Scsi_Host *shost;
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014085 struct asc_board *board;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014086
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014087 if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
Matthew Wilcoxb352f922007-10-02 21:55:33 -040014088 ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014089 return -ENODEV;
14090 }
Matthew Wilcoxb352f922007-10-02 21:55:33 -040014091 ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014092 if (!AscFindSignature(iop_base))
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014093 goto release_region;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014094 /*
14095 * I don't think this condition can actually happen, but the old
14096 * driver did it, and the chances of finding a VLB setup in 2007
14097 * to do testing with is slight to none.
14098 */
14099 if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014100 goto release_region;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014101
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014102 err = -ENOMEM;
14103 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014104 if (!shost)
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014105 goto release_region;
14106
Matthew Wilcoxd2411492007-10-02 21:55:31 -040014107 board = shost_priv(shost);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014108 board->irq = advansys_vlb_irq_no(iop_base);
14109 board->dev = dev;
14110
14111 err = advansys_board_found(shost, iop_base, ASC_IS_VL);
14112 if (err)
14113 goto free_host;
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014114
14115 dev_set_drvdata(dev, shost);
14116 return 0;
14117
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014118 free_host:
14119 scsi_host_put(shost);
14120 release_region:
Matthew Wilcox71f36112007-07-30 08:04:53 -060014121 release_region(iop_base, ASC_IOADR_GAP);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014122 return -ENODEV;
14123}
14124
14125static struct isa_driver advansys_vlb_driver = {
14126 .probe = advansys_vlb_probe,
14127 .remove = __devexit_p(advansys_isa_remove),
14128 .driver = {
14129 .owner = THIS_MODULE,
Matthew Wilcoxb8e5152b2007-09-09 08:56:26 -060014130 .name = "advansys_vlb",
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014131 },
14132};
14133
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014134static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
14135 { "ABP7401" },
14136 { "ABP7501" },
14137 { "" }
14138};
14139
14140MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
14141
14142/*
14143 * EISA is a little more tricky than PCI; each EISA device may have two
14144 * channels, and this driver is written to make each channel its own Scsi_Host
14145 */
14146struct eisa_scsi_data {
14147 struct Scsi_Host *host[2];
14148};
14149
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014150/*
14151 * The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as:
14152 * 000: 10
14153 * 001: 11
14154 * 010: 12
14155 * 011: invalid
14156 * 100: 14
14157 * 101: 15
14158 * 110: invalid
14159 * 111: invalid
14160 */
14161static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev)
14162{
14163 unsigned short cfg_lsw = inw(edev->base_addr + 0xc86);
14164 unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
14165 if ((chip_irq == 13) || (chip_irq > 15))
14166 return 0;
14167 return chip_irq;
14168}
14169
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014170static int __devinit advansys_eisa_probe(struct device *dev)
14171{
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014172 int i, ioport, irq = 0;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014173 int err;
14174 struct eisa_device *edev = to_eisa_device(dev);
14175 struct eisa_scsi_data *data;
14176
14177 err = -ENOMEM;
14178 data = kzalloc(sizeof(*data), GFP_KERNEL);
14179 if (!data)
14180 goto fail;
14181 ioport = edev->base_addr + 0xc30;
14182
14183 err = -ENODEV;
14184 for (i = 0; i < 2; i++, ioport += 0x20) {
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014185 struct asc_board *board;
14186 struct Scsi_Host *shost;
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014187 if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
Matthew Wilcox71f36112007-07-30 08:04:53 -060014188 printk(KERN_WARNING "Region %x-%x busy\n", ioport,
14189 ioport + ASC_IOADR_GAP - 1);
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014190 continue;
Matthew Wilcox71f36112007-07-30 08:04:53 -060014191 }
14192 if (!AscFindSignature(ioport)) {
14193 release_region(ioport, ASC_IOADR_GAP);
14194 continue;
14195 }
14196
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014197 /*
14198 * I don't know why we need to do this for EISA chips, but
14199 * not for any others. It looks to be equivalent to
14200 * AscGetChipCfgMsw, but I may have overlooked something,
14201 * so I'm not converting it until I get an EISA board to
14202 * test with.
14203 */
14204 inw(ioport + 4);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014205
14206 if (!irq)
14207 irq = advansys_eisa_irq_no(edev);
14208
14209 err = -ENOMEM;
14210 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
14211 if (!shost)
14212 goto release_region;
14213
Matthew Wilcoxd2411492007-10-02 21:55:31 -040014214 board = shost_priv(shost);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014215 board->irq = irq;
14216 board->dev = dev;
14217
14218 err = advansys_board_found(shost, ioport, ASC_IS_EISA);
14219 if (!err) {
14220 data->host[i] = shost;
14221 continue;
Matthew Wilcox71f36112007-07-30 08:04:53 -060014222 }
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014223
14224 scsi_host_put(shost);
14225 release_region:
14226 release_region(ioport, ASC_IOADR_GAP);
14227 break;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014228 }
14229
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014230 if (err)
14231 goto free_data;
14232 dev_set_drvdata(dev, data);
14233 return 0;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014234
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014235 free_data:
14236 kfree(data->host[0]);
14237 kfree(data->host[1]);
14238 kfree(data);
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014239 fail:
14240 return err;
14241}
14242
14243static __devexit int advansys_eisa_remove(struct device *dev)
14244{
14245 int i;
14246 struct eisa_scsi_data *data = dev_get_drvdata(dev);
14247
14248 for (i = 0; i < 2; i++) {
Matthew Wilcox71f36112007-07-30 08:04:53 -060014249 int ioport;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014250 struct Scsi_Host *shost = data->host[i];
14251 if (!shost)
14252 continue;
Matthew Wilcox71f36112007-07-30 08:04:53 -060014253 ioport = shost->io_port;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014254 advansys_release(shost);
Matthew Wilcox71f36112007-07-30 08:04:53 -060014255 release_region(ioport, ASC_IOADR_GAP);
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014256 }
14257
14258 kfree(data);
14259 return 0;
14260}
14261
14262static struct eisa_driver advansys_eisa_driver = {
14263 .id_table = advansys_eisa_table,
14264 .driver = {
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014265 .name = DRV_NAME,
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014266 .probe = advansys_eisa_probe,
14267 .remove = __devexit_p(advansys_eisa_remove),
14268 }
14269};
14270
Dave Jones2672ea82006-08-02 17:11:49 -040014271/* PCI Devices supported by this driver */
14272static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014273 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
14274 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14275 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
14276 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14277 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
14278 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14279 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
14280 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14281 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
14282 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14283 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
14284 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
14285 {}
Dave Jones2672ea82006-08-02 17:11:49 -040014286};
Matthew Wilcox27c868c2007-07-26 10:56:23 -040014287
Dave Jones2672ea82006-08-02 17:11:49 -040014288MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014289
Matthew Wilcox9649af32007-07-26 21:51:47 -060014290static void __devinit advansys_set_latency(struct pci_dev *pdev)
14291{
14292 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
14293 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
14294 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
14295 } else {
14296 u8 latency;
14297 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
14298 if (latency < 0x20)
14299 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
14300 }
14301}
14302
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014303static int __devinit
14304advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
14305{
14306 int err, ioport;
14307 struct Scsi_Host *shost;
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014308 struct asc_board *board;
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014309
14310 err = pci_enable_device(pdev);
14311 if (err)
14312 goto fail;
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014313 err = pci_request_regions(pdev, DRV_NAME);
Matthew Wilcox71f36112007-07-30 08:04:53 -060014314 if (err)
14315 goto disable_device;
Matthew Wilcox9649af32007-07-26 21:51:47 -060014316 pci_set_master(pdev);
14317 advansys_set_latency(pdev);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014318
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014319 err = -ENODEV;
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014320 if (pci_resource_len(pdev, 0) == 0)
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014321 goto release_region;
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014322
14323 ioport = pci_resource_start(pdev, 0);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014324
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014325 err = -ENOMEM;
14326 shost = scsi_host_alloc(&advansys_template, sizeof(*board));
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014327 if (!shost)
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014328 goto release_region;
14329
Matthew Wilcoxd2411492007-10-02 21:55:31 -040014330 board = shost_priv(shost);
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014331 board->irq = pdev->irq;
14332 board->dev = &pdev->dev;
14333
14334 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
14335 pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
14336 pdev->device == PCI_DEVICE_ID_38C1600_REV1) {
14337 board->flags |= ASC_IS_WIDE_BOARD;
14338 }
14339
14340 err = advansys_board_found(shost, ioport, ASC_IS_PCI);
14341 if (err)
14342 goto free_host;
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014343
14344 pci_set_drvdata(pdev, shost);
14345 return 0;
14346
Matthew Wilcoxd361db42007-10-02 21:55:29 -040014347 free_host:
14348 scsi_host_put(shost);
14349 release_region:
Matthew Wilcox71f36112007-07-30 08:04:53 -060014350 pci_release_regions(pdev);
14351 disable_device:
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014352 pci_disable_device(pdev);
14353 fail:
14354 return err;
14355}
14356
14357static void __devexit advansys_pci_remove(struct pci_dev *pdev)
14358{
14359 advansys_release(pci_get_drvdata(pdev));
Matthew Wilcox71f36112007-07-30 08:04:53 -060014360 pci_release_regions(pdev);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014361 pci_disable_device(pdev);
14362}
14363
14364static struct pci_driver advansys_pci_driver = {
Matthew Wilcox01fbfe02007-09-09 08:56:40 -060014365 .name = DRV_NAME,
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014366 .id_table = advansys_pci_tbl,
14367 .probe = advansys_pci_probe,
14368 .remove = __devexit_p(advansys_pci_remove),
14369};
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040014370
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014371static int __init advansys_init(void)
14372{
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014373 int error;
14374
14375 error = isa_register_driver(&advansys_isa_driver,
14376 ASC_IOADR_TABLE_MAX_IX);
14377 if (error)
14378 goto fail;
14379
14380 error = isa_register_driver(&advansys_vlb_driver,
14381 ASC_IOADR_TABLE_MAX_IX);
14382 if (error)
14383 goto unregister_isa;
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014384
14385 error = eisa_driver_register(&advansys_eisa_driver);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014386 if (error)
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014387 goto unregister_vlb;
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014388
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014389 error = pci_register_driver(&advansys_pci_driver);
14390 if (error)
14391 goto unregister_eisa;
14392
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014393 return 0;
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014394
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014395 unregister_eisa:
14396 eisa_driver_unregister(&advansys_eisa_driver);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014397 unregister_vlb:
14398 isa_unregister_driver(&advansys_vlb_driver);
14399 unregister_isa:
14400 isa_unregister_driver(&advansys_isa_driver);
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014401 fail:
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014402 return error;
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014403}
14404
14405static void __exit advansys_exit(void)
14406{
Matthew Wilcox78e77d82007-07-29 21:46:15 -060014407 pci_unregister_driver(&advansys_pci_driver);
Matthew Wilcoxb09e05a2007-07-30 09:14:52 -060014408 eisa_driver_unregister(&advansys_eisa_driver);
Matthew Wilcoxc304ec92007-07-30 09:18:45 -060014409 isa_unregister_driver(&advansys_vlb_driver);
14410 isa_unregister_driver(&advansys_isa_driver);
Matthew Wilcox8dfb5372007-07-30 09:08:34 -060014411}
14412
14413module_init(advansys_init);
14414module_exit(advansys_exit);
14415
Matthew Wilcox8c6af9e2007-07-26 11:03:19 -040014416MODULE_LICENSE("GPL");