4 #include <linux/genhd.h>
10 #define MAX_PART (1 << NWD_SHIFT)
20 typedef struct ctlr_info ctlr_info_t
;
22 struct access_method
{
23 void (*submit_command
)(ctlr_info_t
*h
, CommandList_struct
*c
);
24 void (*set_intr_mask
)(ctlr_info_t
*h
, unsigned long val
);
25 unsigned long (*fifo_full
)(ctlr_info_t
*h
);
26 unsigned long (*intr_pending
)(ctlr_info_t
*h
);
27 unsigned long (*command_completed
)(ctlr_info_t
*h
);
29 typedef struct _drive_info_struct
33 struct request_queue
*queue
;
39 int raid_level
; /* set to -1 to indicate that
40 * the drive is not in use/configured
42 int busy_configuring
; /* This is set when a drive is being removed
43 * to prevent it from being opened or it's
44 * queue from being started.
47 __u8 serial_no
[16]; /* from inquiry page 0x83,
48 * not necc. null terminated.
50 char vendor
[VENDOR_LEN
+ 1]; /* SCSI vendor string */
51 char model
[MODEL_LEN
+ 1]; /* SCSI model string */
52 char rev
[REV_LEN
+ 1]; /* SCSI revision string */
55 #ifdef CONFIG_CISS_SCSI_TAPE
57 struct sendcmd_reject_list
{
59 unsigned long *complete
; /* array of NR_CMDS tags */
68 char firm_ver
[4]; // Firmware version
73 int nr_cmds
; /* Number of commands allowed on this controller */
74 CfgTable_struct __iomem
*cfgtable
;
75 int interrupts_enabled
;
78 int commands_outstanding
;
79 int max_outstanding
; /* Debug */
82 int usage_count
; /* number of opens all all minor devices */
83 # define DOORBELL_INT 0
84 # define PERF_MODE_INT 1
85 # define SIMPLE_MODE_INT 2
86 # define MEMQ_MODE_INT 3
88 unsigned int msix_vector
;
89 unsigned int msi_vector
;
90 int cciss_max_sectors
;
93 BYTE cciss_read_capacity
;
95 // information about each logical volume
96 drive_info_struct drv
[CISS_MAX_LUN
];
98 struct access_method access
;
100 /* queue and queue Info */
101 struct hlist_head reqQ
;
102 struct hlist_head cmpQ
;
104 unsigned int maxQsinceinit
;
108 //* pointers to command and error info pool */
109 CommandList_struct
*cmd_pool
;
110 dma_addr_t cmd_pool_dhandle
;
111 ErrorInfo_struct
*errinfo_pool
;
112 dma_addr_t errinfo_pool_dhandle
;
113 unsigned long *cmd_pool_bits
;
116 int busy_configuring
;
117 int busy_initializing
;
119 /* This element holds the zero based queue number of the last
120 * queue to be started. It is used for fairness.
124 // Disk structures we need to pass back
125 struct gendisk
*gendisk
[CISS_MAX_LUN
];
126 #ifdef CONFIG_CISS_SCSI_TAPE
127 void *scsi_ctlr
; /* ptr to structure containing scsi related stuff */
128 /* list of block side commands the scsi error handling sucked up */
129 /* and saved for later processing */
130 struct sendcmd_reject_list scsi_rejects
;
133 struct completion
*rescan_wait
;
134 struct task_struct
*cciss_scan_thread
;
138 /* Defining the diffent access_menthods */
140 * Memory mapped FIFO interface (SMART 53xx cards)
142 #define SA5_DOORBELL 0x20
143 #define SA5_REQUEST_PORT_OFFSET 0x40
144 #define SA5_REPLY_INTR_MASK_OFFSET 0x34
145 #define SA5_REPLY_PORT_OFFSET 0x44
146 #define SA5_INTR_STATUS 0x30
147 #define SA5_SCRATCHPAD_OFFSET 0xB0
149 #define SA5_CTCFG_OFFSET 0xB4
150 #define SA5_CTMEM_OFFSET 0xB8
152 #define SA5_INTR_OFF 0x08
153 #define SA5B_INTR_OFF 0x04
154 #define SA5_INTR_PENDING 0x08
155 #define SA5B_INTR_PENDING 0x04
156 #define FIFO_EMPTY 0xffffffff
157 #define CCISS_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */
159 #define CISS_ERROR_BIT 0x02
161 #define CCISS_INTR_ON 1
162 #define CCISS_INTR_OFF 0
164 Send the command to the hardware
166 static void SA5_submit_command( ctlr_info_t
*h
, CommandList_struct
*c
)
169 printk("Sending %x - down to controller\n", c
->busaddr
);
170 #endif /* CCISS_DEBUG */
171 writel(c
->busaddr
, h
->vaddr
+ SA5_REQUEST_PORT_OFFSET
);
172 h
->commands_outstanding
++;
173 if ( h
->commands_outstanding
> h
->max_outstanding
)
174 h
->max_outstanding
= h
->commands_outstanding
;
178 * This card is the opposite of the other cards.
179 * 0 turns interrupts on...
180 * 0x08 turns them off...
182 static void SA5_intr_mask(ctlr_info_t
*h
, unsigned long val
)
185 { /* Turn interrupts on */
186 h
->interrupts_enabled
= 1;
187 writel(0, h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
188 } else /* Turn them off */
190 h
->interrupts_enabled
= 0;
191 writel( SA5_INTR_OFF
,
192 h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
196 * This card is the opposite of the other cards.
197 * 0 turns interrupts on...
198 * 0x04 turns them off...
200 static void SA5B_intr_mask(ctlr_info_t
*h
, unsigned long val
)
203 { /* Turn interrupts on */
204 h
->interrupts_enabled
= 1;
205 writel(0, h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
206 } else /* Turn them off */
208 h
->interrupts_enabled
= 0;
209 writel( SA5B_INTR_OFF
,
210 h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
214 * Returns true if fifo is full.
217 static unsigned long SA5_fifo_full(ctlr_info_t
*h
)
219 if( h
->commands_outstanding
>= h
->max_commands
)
226 * returns value read from hardware.
227 * returns FIFO_EMPTY if there is nothing to read
229 static unsigned long SA5_completed(ctlr_info_t
*h
)
231 unsigned long register_value
232 = readl(h
->vaddr
+ SA5_REPLY_PORT_OFFSET
);
233 if(register_value
!= FIFO_EMPTY
)
235 h
->commands_outstanding
--;
237 printk("cciss: Read %lx back from board\n", register_value
);
238 #endif /* CCISS_DEBUG */
243 printk("cciss: FIFO Empty read\n");
246 return ( register_value
);
250 * Returns true if an interrupt is pending..
252 static unsigned long SA5_intr_pending(ctlr_info_t
*h
)
254 unsigned long register_value
=
255 readl(h
->vaddr
+ SA5_INTR_STATUS
);
257 printk("cciss: intr_pending %lx\n", register_value
);
258 #endif /* CCISS_DEBUG */
259 if( register_value
& SA5_INTR_PENDING
)
265 * Returns true if an interrupt is pending..
267 static unsigned long SA5B_intr_pending(ctlr_info_t
*h
)
269 unsigned long register_value
=
270 readl(h
->vaddr
+ SA5_INTR_STATUS
);
272 printk("cciss: intr_pending %lx\n", register_value
);
273 #endif /* CCISS_DEBUG */
274 if( register_value
& SA5B_INTR_PENDING
)
280 static struct access_method SA5_access
= {
288 static struct access_method SA5B_access
= {
299 struct access_method
*access
;
300 int nr_cmds
; /* Max cmds this kind of ctlr can handle. */
303 #define CCISS_LOCK(i) (&hba[i]->lock)