2 * HighPoint RR3xxx controller driver for Linux
3 * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * Please report bugs/comments/suggestions to linux@highpoint-tech.com
16 * For more information, visit http://www.highpoint-tech.com
24 __le32 inbound_msgaddr0
;
25 __le32 inbound_msgaddr1
;
26 __le32 outbound_msgaddr0
;
27 __le32 outbound_msgaddr1
;
28 __le32 inbound_doorbell
;
29 __le32 inbound_intstatus
;
30 __le32 inbound_intmask
;
31 __le32 outbound_doorbell
;
32 __le32 outbound_intstatus
;
33 __le32 outbound_intmask
;
36 __le32 outbound_queue
;
39 #define IOPMU_QUEUE_EMPTY 0xffffffff
40 #define IOPMU_QUEUE_MASK_HOST_BITS 0xf0000000
41 #define IOPMU_QUEUE_ADDR_HOST_BIT 0x80000000
42 #define IOPMU_QUEUE_REQUEST_SIZE_BIT 0x40000000
43 #define IOPMU_QUEUE_REQUEST_RESULT_BIT 0x40000000
45 #define IOPMU_OUTBOUND_INT_MSG0 1
46 #define IOPMU_OUTBOUND_INT_MSG1 2
47 #define IOPMU_OUTBOUND_INT_DOORBELL 4
48 #define IOPMU_OUTBOUND_INT_POSTQUEUE 8
49 #define IOPMU_OUTBOUND_INT_PCI 0x10
51 #define IOPMU_INBOUND_INT_MSG0 1
52 #define IOPMU_INBOUND_INT_MSG1 2
53 #define IOPMU_INBOUND_INT_DOORBELL 4
54 #define IOPMU_INBOUND_INT_ERROR 8
55 #define IOPMU_INBOUND_INT_POSTQUEUE 0x10
57 enum hpt_iopmu_message
{
58 /* host-to-iop messages */
59 IOPMU_INBOUND_MSG0_NOP
= 0,
60 IOPMU_INBOUND_MSG0_RESET
,
61 IOPMU_INBOUND_MSG0_FLUSH
,
62 IOPMU_INBOUND_MSG0_SHUTDOWN
,
63 IOPMU_INBOUND_MSG0_STOP_BACKGROUND_TASK
,
64 IOPMU_INBOUND_MSG0_START_BACKGROUND_TASK
,
65 IOPMU_INBOUND_MSG0_MAX
= 0xff,
66 /* iop-to-host messages */
67 IOPMU_OUTBOUND_MSG0_REGISTER_DEVICE_0
= 0x100,
68 IOPMU_OUTBOUND_MSG0_REGISTER_DEVICE_MAX
= 0x1ff,
69 IOPMU_OUTBOUND_MSG0_UNREGISTER_DEVICE_0
= 0x200,
70 IOPMU_OUTBOUND_MSG0_UNREGISTER_DEVICE_MAX
= 0x2ff,
71 IOPMU_OUTBOUND_MSG0_REVALIDATE_DEVICE_0
= 0x300,
72 IOPMU_OUTBOUND_MSG0_REVALIDATE_DEVICE_MAX
= 0x3ff,
75 struct hpt_iop_request_header
81 __le32 context
; /* host context */
85 #define IOP_REQUEST_FLAG_SYNC_REQUEST 1
86 #define IOP_REQUEST_FLAG_BIST_REQUEST 2
87 #define IOP_REQUEST_FLAG_REMAPPED 4
88 #define IOP_REQUEST_FLAG_OUTPUT_CONTEXT 8
90 enum hpt_iop_request_type
{
91 IOP_REQUEST_TYPE_GET_CONFIG
= 0,
92 IOP_REQUEST_TYPE_SET_CONFIG
,
93 IOP_REQUEST_TYPE_BLOCK_COMMAND
,
94 IOP_REQUEST_TYPE_SCSI_COMMAND
,
95 IOP_REQUEST_TYPE_IOCTL_COMMAND
,
99 enum hpt_iop_result_type
{
100 IOP_RESULT_PENDING
= 0,
105 IOP_RESULT_INVALID_REQUEST
,
106 IOP_RESULT_BAD_TARGET
,
107 IOP_RESULT_MODE_SENSE_CHECK_CONDITION
,
110 struct hpt_iop_request_get_config
112 struct hpt_iop_request_header header
;
113 __le32 interface_version
;
114 __le32 firmware_version
;
118 __le32 data_transfer_length
;
119 __le32 alignment_mask
;
124 struct hpt_iop_request_set_config
126 struct hpt_iop_request_header header
;
129 __le16 max_host_request_size
;
136 __le32 eot
; /* non-zero: end of table */
140 struct hpt_iop_request_block_command
142 struct hpt_iop_request_header header
;
147 __le16 command
; /* IOP_BLOCK_COMMAND_{READ,WRITE} */
150 struct hpt_iopsg sg_list
[1];
153 #define IOP_BLOCK_COMMAND_READ 1
154 #define IOP_BLOCK_COMMAND_WRITE 2
155 #define IOP_BLOCK_COMMAND_VERIFY 3
156 #define IOP_BLOCK_COMMAND_FLUSH 4
157 #define IOP_BLOCK_COMMAND_SHUTDOWN 5
159 struct hpt_iop_request_scsi_command
161 struct hpt_iop_request_header header
;
167 __le32 dataxfer_length
;
168 struct hpt_iopsg sg_list
[1];
171 struct hpt_iop_request_ioctl_command
173 struct hpt_iop_request_header header
;
177 __le32 bytes_returned
;
179 /* out data should be put at buf[(inbuf_size+3)&~3] */
182 #define HPTIOP_MAX_REQUESTS 256u
184 struct hptiop_request
{
185 struct hptiop_request
* next
;
188 struct scsi_cmnd
* scp
;
192 struct hpt_scsi_pointer
{
195 dma_addr_t dma_handle
;
198 #define HPT_SCP(scp) ((struct hpt_scsi_pointer *)&(scp)->SCp)
201 struct hpt_iopmu __iomem
* iop
;
202 struct Scsi_Host
* host
;
203 struct pci_dev
* pcidev
;
205 /* IOP config info */
206 u32 interface_version
;
207 u32 firmware_version
;
211 u32 max_request_size
;
212 u32 max_sg_descriptors
;
214 u32 req_size
; /* host-allocated request buffer size */
220 struct hptiop_request
* req_list
;
221 struct hptiop_request reqs
[HPTIOP_MAX_REQUESTS
];
223 /* used to free allocated dma area */
225 dma_addr_t dma_coherent_handle
;
227 atomic_t reset_count
;
230 wait_queue_head_t reset_wq
;
231 wait_queue_head_t ioctl_wq
;
236 struct hptiop_hba
* hba
;
242 u32
* bytes_returned
;
243 void (*done
)(struct hpt_ioctl_k
*);
244 int result
; /* HPT_IOCTL_RESULT_ */
247 #define HPT_IOCTL_RESULT_OK 0
248 #define HPT_IOCTL_RESULT_FAILED (-1)
251 #define dprintk(fmt, args...) do { printk(fmt, ##args); } while(0)
253 #define dprintk(fmt, args...)