4 #include <linux/genhd.h>
11 #define MAX_PART (1 << NWD_SHIFT)
17 typedef struct ctlr_info ctlr_info_t;
19 struct access_method {
20 void (*submit_command)(ctlr_info_t *h, CommandList_struct *c);
21 void (*set_intr_mask)(ctlr_info_t *h, unsigned long val);
22 unsigned long (*fifo_full)(ctlr_info_t *h);
23 unsigned long (*intr_pending)(ctlr_info_t *h);
24 unsigned long (*command_completed)(ctlr_info_t *h);
26 typedef struct _drive_info_struct
30 struct request_queue *queue;
36 int raid_level; /* set to -1 to indicate that
37 * the drive is not in use/configured
39 int busy_configuring; /*This is set when the drive is being removed
40 *to prevent it from being opened or it's queue
45 #ifdef CONFIG_CISS_SCSI_TAPE
47 struct sendcmd_reject_list {
49 unsigned long *complete; /* array of NR_CMDS tags */
58 char firm_ver[4]; // Firmware version
63 unsigned long io_mem_addr;
64 unsigned long io_mem_length;
65 CfgTable_struct __iomem *cfgtable;
66 int interrupts_enabled;
69 int commands_outstanding;
70 int max_outstanding; /* Debug */
73 int usage_count; /* number of opens all all minor devices */
74 # define DOORBELL_INT 0
75 # define PERF_MODE_INT 1
76 # define SIMPLE_MODE_INT 2
77 # define MEMQ_MODE_INT 3
79 unsigned int msix_vector;
80 unsigned int msi_vector;
82 // information about each logical volume
83 drive_info_struct drv[CISS_MAX_LUN];
85 struct access_method access;
87 /* queue and queue Info */
88 CommandList_struct *reqQ;
89 CommandList_struct *cmpQ;
91 unsigned int maxQsinceinit;
95 //* pointers to command and error info pool */
96 CommandList_struct *cmd_pool;
97 dma_addr_t cmd_pool_dhandle;
98 ErrorInfo_struct *errinfo_pool;
99 dma_addr_t errinfo_pool_dhandle;
100 unsigned long *cmd_pool_bits;
103 int busy_configuring;
104 int busy_initializing;
106 /* This element holds the zero based queue number of the last
107 * queue to be started. It is used for fairness.
111 // Disk structures we need to pass back
112 struct gendisk *gendisk[NWD];
113 #ifdef CONFIG_CISS_SCSI_TAPE
114 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
115 /* list of block side commands the scsi error handling sucked up */
116 /* and saved for later processing */
117 struct sendcmd_reject_list scsi_rejects;
122 /* Defining the diffent access_menthods */
124 * Memory mapped FIFO interface (SMART 53xx cards)
126 #define SA5_DOORBELL 0x20
127 #define SA5_REQUEST_PORT_OFFSET 0x40
128 #define SA5_REPLY_INTR_MASK_OFFSET 0x34
129 #define SA5_REPLY_PORT_OFFSET 0x44
130 #define SA5_INTR_STATUS 0x30
131 #define SA5_SCRATCHPAD_OFFSET 0xB0
133 #define SA5_CTCFG_OFFSET 0xB4
134 #define SA5_CTMEM_OFFSET 0xB8
136 #define SA5_INTR_OFF 0x08
137 #define SA5B_INTR_OFF 0x04
138 #define SA5_INTR_PENDING 0x08
139 #define SA5B_INTR_PENDING 0x04
140 #define FIFO_EMPTY 0xffffffff
141 #define CCISS_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */
143 #define CISS_ERROR_BIT 0x02
145 #define CCISS_INTR_ON 1
146 #define CCISS_INTR_OFF 0
148 Send the command to the hardware
150 static void SA5_submit_command( ctlr_info_t *h, CommandList_struct *c)
153 printk("Sending %x - down to controller\n", c->busaddr );
154 #endif /* CCISS_DEBUG */
155 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
156 h->commands_outstanding++;
157 if ( h->commands_outstanding > h->max_outstanding)
158 h->max_outstanding = h->commands_outstanding;
162 * This card is the opposite of the other cards.
163 * 0 turns interrupts on...
164 * 0x08 turns them off...
166 static void SA5_intr_mask(ctlr_info_t *h, unsigned long val)
169 { /* Turn interrupts on */
170 h->interrupts_enabled = 1;
171 writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
172 } else /* Turn them off */
174 h->interrupts_enabled = 0;
175 writel( SA5_INTR_OFF,
176 h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
180 * This card is the opposite of the other cards.
181 * 0 turns interrupts on...
182 * 0x04 turns them off...
184 static void SA5B_intr_mask(ctlr_info_t *h, unsigned long val)
187 { /* Turn interrupts on */
188 h->interrupts_enabled = 1;
189 writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
190 } else /* Turn them off */
192 h->interrupts_enabled = 0;
193 writel( SA5B_INTR_OFF,
194 h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
198 * Returns true if fifo is full.
201 static unsigned long SA5_fifo_full(ctlr_info_t *h)
203 if( h->commands_outstanding >= h->max_commands)
210 * returns value read from hardware.
211 * returns FIFO_EMPTY if there is nothing to read
213 static unsigned long SA5_completed(ctlr_info_t *h)
215 unsigned long register_value
216 = readl(h->vaddr + SA5_REPLY_PORT_OFFSET);
217 if(register_value != FIFO_EMPTY)
219 h->commands_outstanding--;
221 printk("cciss: Read %lx back from board\n", register_value);
222 #endif /* CCISS_DEBUG */
227 printk("cciss: FIFO Empty read\n");
230 return ( register_value);
234 * Returns true if an interrupt is pending..
236 static unsigned long SA5_intr_pending(ctlr_info_t *h)
238 unsigned long register_value =
239 readl(h->vaddr + SA5_INTR_STATUS);
241 printk("cciss: intr_pending %lx\n", register_value);
242 #endif /* CCISS_DEBUG */
243 if( register_value & SA5_INTR_PENDING)
249 * Returns true if an interrupt is pending..
251 static unsigned long SA5B_intr_pending(ctlr_info_t *h)
253 unsigned long register_value =
254 readl(h->vaddr + SA5_INTR_STATUS);
256 printk("cciss: intr_pending %lx\n", register_value);
257 #endif /* CCISS_DEBUG */
258 if( register_value & SA5B_INTR_PENDING)
264 static struct access_method SA5_access = {
272 static struct access_method SA5B_access = {
283 struct access_method *access;
286 #define CCISS_LOCK(i) (&hba[i]->lock)