4 #include <linux/genhd.h>
11 #define MAX_PART (1 << NWD_SHIFT)
16 #define MAJOR_NR COMPAQ_CISS_MAJOR
19 typedef struct ctlr_info ctlr_info_t
;
21 struct access_method
{
22 void (*submit_command
)(ctlr_info_t
*h
, CommandList_struct
*c
);
23 void (*set_intr_mask
)(ctlr_info_t
*h
, unsigned long val
);
24 unsigned long (*fifo_full
)(ctlr_info_t
*h
);
25 unsigned long (*intr_pending
)(ctlr_info_t
*h
);
26 unsigned long (*command_completed
)(ctlr_info_t
*h
);
28 typedef struct _drive_info_struct
32 struct request_queue
*queue
;
38 int raid_level
; /* set to -1 to indicate that
39 * the drive is not in use/configured
41 int busy_configuring
; /*This is set when the drive is being removed
42 *to prevent it from being opened or it's queue
47 #ifdef CONFIG_CISS_SCSI_TAPE
49 struct sendcmd_reject_list
{
51 unsigned long *complete
; /* array of NR_CMDS tags */
60 char firm_ver
[4]; // Firmware version
65 unsigned long io_mem_addr
;
66 unsigned long io_mem_length
;
67 CfgTable_struct __iomem
*cfgtable
;
69 int interrupts_enabled
;
72 int commands_outstanding
;
73 int max_outstanding
; /* Debug */
76 int usage_count
; /* number of opens all all minor devices */
78 // information about each logical volume
79 drive_info_struct drv
[CISS_MAX_LUN
];
81 struct access_method access
;
83 /* queue and queue Info */
84 CommandList_struct
*reqQ
;
85 CommandList_struct
*cmpQ
;
87 unsigned int maxQsinceinit
;
91 //* pointers to command and error info pool */
92 CommandList_struct
*cmd_pool
;
93 dma_addr_t cmd_pool_dhandle
;
94 ErrorInfo_struct
*errinfo_pool
;
95 dma_addr_t errinfo_pool_dhandle
;
96 unsigned long *cmd_pool_bits
;
100 int busy_initializing
;
102 /* This element holds the zero based queue number of the last
103 * queue to be started. It is used for fairness.
107 // Disk structures we need to pass back
108 struct gendisk
*gendisk
[NWD
];
109 #ifdef CONFIG_CISS_SCSI_TAPE
110 void *scsi_ctlr
; /* ptr to structure containing scsi related stuff */
111 /* list of block side commands the scsi error handling sucked up */
112 /* and saved for later processing */
113 struct sendcmd_reject_list scsi_rejects
;
118 /* Defining the diffent access_menthods */
120 * Memory mapped FIFO interface (SMART 53xx cards)
122 #define SA5_DOORBELL 0x20
123 #define SA5_REQUEST_PORT_OFFSET 0x40
124 #define SA5_REPLY_INTR_MASK_OFFSET 0x34
125 #define SA5_REPLY_PORT_OFFSET 0x44
126 #define SA5_INTR_STATUS 0x30
127 #define SA5_SCRATCHPAD_OFFSET 0xB0
129 #define SA5_CTCFG_OFFSET 0xB4
130 #define SA5_CTMEM_OFFSET 0xB8
132 #define SA5_INTR_OFF 0x08
133 #define SA5B_INTR_OFF 0x04
134 #define SA5_INTR_PENDING 0x08
135 #define SA5B_INTR_PENDING 0x04
136 #define FIFO_EMPTY 0xffffffff
137 #define CCISS_FIRMWARE_READY 0xffff0000 /* value in scratchpad register */
139 #define CISS_ERROR_BIT 0x02
141 #define CCISS_INTR_ON 1
142 #define CCISS_INTR_OFF 0
144 Send the command to the hardware
146 static void SA5_submit_command( ctlr_info_t
*h
, CommandList_struct
*c
)
149 printk("Sending %x - down to controller\n", c
->busaddr
);
150 #endif /* CCISS_DEBUG */
151 writel(c
->busaddr
, h
->vaddr
+ SA5_REQUEST_PORT_OFFSET
);
152 h
->commands_outstanding
++;
153 if ( h
->commands_outstanding
> h
->max_outstanding
)
154 h
->max_outstanding
= h
->commands_outstanding
;
158 * This card is the opposite of the other cards.
159 * 0 turns interrupts on...
160 * 0x08 turns them off...
162 static void SA5_intr_mask(ctlr_info_t
*h
, unsigned long val
)
165 { /* Turn interrupts on */
166 h
->interrupts_enabled
= 1;
167 writel(0, h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
168 } else /* Turn them off */
170 h
->interrupts_enabled
= 0;
171 writel( SA5_INTR_OFF
,
172 h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
176 * This card is the opposite of the other cards.
177 * 0 turns interrupts on...
178 * 0x04 turns them off...
180 static void SA5B_intr_mask(ctlr_info_t
*h
, unsigned long val
)
183 { /* Turn interrupts on */
184 h
->interrupts_enabled
= 1;
185 writel(0, h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
186 } else /* Turn them off */
188 h
->interrupts_enabled
= 0;
189 writel( SA5B_INTR_OFF
,
190 h
->vaddr
+ SA5_REPLY_INTR_MASK_OFFSET
);
194 * Returns true if fifo is full.
197 static unsigned long SA5_fifo_full(ctlr_info_t
*h
)
199 if( h
->commands_outstanding
>= h
->max_commands
)
206 * returns value read from hardware.
207 * returns FIFO_EMPTY if there is nothing to read
209 static unsigned long SA5_completed(ctlr_info_t
*h
)
211 unsigned long register_value
212 = readl(h
->vaddr
+ SA5_REPLY_PORT_OFFSET
);
213 if(register_value
!= FIFO_EMPTY
)
215 h
->commands_outstanding
--;
217 printk("cciss: Read %lx back from board\n", register_value
);
218 #endif /* CCISS_DEBUG */
223 printk("cciss: FIFO Empty read\n");
226 return ( register_value
);
230 * Returns true if an interrupt is pending..
232 static unsigned long SA5_intr_pending(ctlr_info_t
*h
)
234 unsigned long register_value
=
235 readl(h
->vaddr
+ SA5_INTR_STATUS
);
237 printk("cciss: intr_pending %lx\n", register_value
);
238 #endif /* CCISS_DEBUG */
239 if( register_value
& SA5_INTR_PENDING
)
245 * Returns true if an interrupt is pending..
247 static unsigned long SA5B_intr_pending(ctlr_info_t
*h
)
249 unsigned long register_value
=
250 readl(h
->vaddr
+ SA5_INTR_STATUS
);
252 printk("cciss: intr_pending %lx\n", register_value
);
253 #endif /* CCISS_DEBUG */
254 if( register_value
& SA5B_INTR_PENDING
)
260 static struct access_method SA5_access
= {
268 static struct access_method SA5B_access
= {
279 struct access_method
*access
;
282 #define CCISS_LOCK(i) (&hba[i]->lock)