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
43 char firm_ver[4]; // Firmware version
48 unsigned long io_mem_addr;
49 unsigned long io_mem_length;
50 CfgTable_struct __iomem *cfgtable;
52 int interrupts_enabled;
54 int commands_outstanding;
55 int max_outstanding; /* Debug */
58 int usage_count; /* number of opens all all minor devices */
60 // information about each logical volume
61 drive_info_struct drv[CISS_MAX_LUN];
63 struct access_method access;
65 /* queue and queue Info */
66 CommandList_struct *reqQ;
67 CommandList_struct *cmpQ;
69 unsigned int maxQsinceinit;
72 struct request_queue *queue;
74 //* pointers to command and error info pool */
75 CommandList_struct *cmd_pool;
76 dma_addr_t cmd_pool_dhandle;
77 ErrorInfo_struct *errinfo_pool;
78 dma_addr_t errinfo_pool_dhandle;
79 unsigned long *cmd_pool_bits;
84 // Disk structures we need to pass back
85 struct gendisk *gendisk[NWD];
86 #ifdef CONFIG_CISS_SCSI_TAPE
87 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
91 /* Defining the diffent access_menthods */
93 * Memory mapped FIFO interface (SMART 53xx cards)
95 #define SA5_DOORBELL 0x20
96 #define SA5_REQUEST_PORT_OFFSET 0x40
97 #define SA5_REPLY_INTR_MASK_OFFSET 0x34
98 #define SA5_REPLY_PORT_OFFSET 0x44
99 #define SA5_INTR_STATUS 0x30
100 #define SA5_SCRATCHPAD_OFFSET 0xB0
102 #define SA5_CTCFG_OFFSET 0xB4
103 #define SA5_CTMEM_OFFSET 0xB8
105 #define SA5_INTR_OFF 0x08
106 #define SA5B_INTR_OFF 0x04
107 #define SA5_INTR_PENDING 0x08
108 #define SA5B_INTR_PENDING 0x04
109 #define FIFO_EMPTY 0xffffffff
110 #define CCISS_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */
112 #define CISS_ERROR_BIT 0x02
114 #define CCISS_INTR_ON 1
115 #define CCISS_INTR_OFF 0
117 Send the command to the hardware
119 static void SA5_submit_command( ctlr_info_t *h, CommandList_struct *c)
122 printk("Sending %x - down to controller\n", c->busaddr );
123 #endif /* CCISS_DEBUG */
124 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
125 h->commands_outstanding++;
126 if ( h->commands_outstanding > h->max_outstanding)
127 h->max_outstanding = h->commands_outstanding;
131 * This card is the opposite of the other cards.
132 * 0 turns interrupts on...
133 * 0x08 turns them off...
135 static void SA5_intr_mask(ctlr_info_t *h, unsigned long val)
138 { /* Turn interrupts on */
139 h->interrupts_enabled = 1;
140 writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
141 } else /* Turn them off */
143 h->interrupts_enabled = 0;
144 writel( SA5_INTR_OFF,
145 h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
149 * This card is the opposite of the other cards.
150 * 0 turns interrupts on...
151 * 0x04 turns them off...
153 static void SA5B_intr_mask(ctlr_info_t *h, unsigned long val)
156 { /* Turn interrupts on */
157 h->interrupts_enabled = 1;
158 writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
159 } else /* Turn them off */
161 h->interrupts_enabled = 0;
162 writel( SA5B_INTR_OFF,
163 h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
167 * Returns true if fifo is full.
170 static unsigned long SA5_fifo_full(ctlr_info_t *h)
172 if( h->commands_outstanding >= h->max_commands)
179 * returns value read from hardware.
180 * returns FIFO_EMPTY if there is nothing to read
182 static unsigned long SA5_completed(ctlr_info_t *h)
184 unsigned long register_value
185 = readl(h->vaddr + SA5_REPLY_PORT_OFFSET);
186 if(register_value != FIFO_EMPTY)
188 h->commands_outstanding--;
190 printk("cciss: Read %lx back from board\n", register_value);
191 #endif /* CCISS_DEBUG */
196 printk("cciss: FIFO Empty read\n");
199 return ( register_value);
203 * Returns true if an interrupt is pending..
205 static unsigned long SA5_intr_pending(ctlr_info_t *h)
207 unsigned long register_value =
208 readl(h->vaddr + SA5_INTR_STATUS);
210 printk("cciss: intr_pending %lx\n", register_value);
211 #endif /* CCISS_DEBUG */
212 if( register_value & SA5_INTR_PENDING)
218 * Returns true if an interrupt is pending..
220 static unsigned long SA5B_intr_pending(ctlr_info_t *h)
222 unsigned long register_value =
223 readl(h->vaddr + SA5_INTR_STATUS);
225 printk("cciss: intr_pending %lx\n", register_value);
226 #endif /* CCISS_DEBUG */
227 if( register_value & SA5B_INTR_PENDING)
233 static struct access_method SA5_access = {
241 static struct access_method SA5B_access = {
252 struct access_method *access;
255 #define CCISS_LOCK(i) (hba[i]->queue->queue_lock)