2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/delay.h>
11 static int qla_uprintf(char **, char *, ...);
14 * qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
16 * @hardware_locked: Called with the hardware_lock
19 qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
23 uint32_t risc_address;
27 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
28 uint16_t __iomem *dmp_reg;
30 struct qla2300_fw_dump *fw;
31 uint32_t data_ram_cnt;
33 risc_address = data_ram_cnt = 0;
38 spin_lock_irqsave(&ha->hardware_lock, flags);
41 qla_printk(KERN_WARNING, ha,
42 "No buffer available for dump!!!\n");
43 goto qla2300_fw_dump_failed;
47 qla_printk(KERN_WARNING, ha,
48 "Firmware has been previously dumped (%p) -- ignoring "
49 "request...\n", ha->fw_dump);
50 goto qla2300_fw_dump_failed;
55 fw->hccr = RD_REG_WORD(®->hccr);
58 WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC);
61 (RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0 &&
62 rval == QLA_SUCCESS; cnt--) {
66 rval = QLA_FUNCTION_TIMEOUT;
69 RD_REG_WORD(®->hccr); /* PCI Posting. */
73 if (rval == QLA_SUCCESS) {
74 dmp_reg = (uint16_t __iomem *)(reg + 0);
75 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++)
76 fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
78 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10);
79 for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2; cnt++)
80 fw->risc_host_reg[cnt] = RD_REG_WORD(dmp_reg++);
82 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x40);
83 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
84 fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
86 WRT_REG_WORD(®->ctrl_status, 0x40);
87 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
88 for (cnt = 0; cnt < sizeof(fw->resp_dma_reg) / 2; cnt++)
89 fw->resp_dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
91 WRT_REG_WORD(®->ctrl_status, 0x50);
92 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
93 for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++)
94 fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
96 WRT_REG_WORD(®->ctrl_status, 0x00);
97 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0);
98 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++)
99 fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
101 WRT_REG_WORD(®->pcr, 0x2000);
102 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
103 for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++)
104 fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
106 WRT_REG_WORD(®->pcr, 0x2200);
107 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
108 for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++)
109 fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
111 WRT_REG_WORD(®->pcr, 0x2400);
112 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
113 for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++)
114 fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
116 WRT_REG_WORD(®->pcr, 0x2600);
117 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
118 for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++)
119 fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
121 WRT_REG_WORD(®->pcr, 0x2800);
122 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
123 for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++)
124 fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
126 WRT_REG_WORD(®->pcr, 0x2A00);
127 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
128 for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++)
129 fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
131 WRT_REG_WORD(®->pcr, 0x2C00);
132 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
133 for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++)
134 fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
136 WRT_REG_WORD(®->pcr, 0x2E00);
137 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
138 for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++)
139 fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
141 WRT_REG_WORD(®->ctrl_status, 0x10);
142 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
143 for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++)
144 fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
146 WRT_REG_WORD(®->ctrl_status, 0x20);
147 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
148 for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++)
149 fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
151 WRT_REG_WORD(®->ctrl_status, 0x30);
152 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
153 for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++)
154 fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
157 WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET);
158 for (cnt = 0; cnt < 30000; cnt++) {
159 if ((RD_REG_WORD(®->ctrl_status) &
160 CSR_ISP_SOFT_RESET) == 0)
167 if (!IS_QLA2300(ha)) {
168 for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
169 rval == QLA_SUCCESS; cnt--) {
173 rval = QLA_FUNCTION_TIMEOUT;
177 if (rval == QLA_SUCCESS) {
179 risc_address = 0x800;
180 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
181 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
183 for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
184 cnt++, risc_address++) {
185 WRT_MAILBOX_REG(ha, reg, 1, (uint16_t)risc_address);
186 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
188 for (timer = 6000000; timer; timer--) {
189 /* Check for pending interrupts. */
190 stat = RD_REG_DWORD(®->u.isp2300.host_status);
191 if (stat & HSR_RISC_INT) {
194 if (stat == 0x1 || stat == 0x2) {
195 set_bit(MBX_INTERRUPT,
198 mb0 = RD_MAILBOX_REG(ha, reg, 0);
199 mb2 = RD_MAILBOX_REG(ha, reg, 2);
201 /* Release mailbox registers. */
202 WRT_REG_WORD(®->semaphore, 0);
203 WRT_REG_WORD(®->hccr,
205 RD_REG_WORD(®->hccr);
207 } else if (stat == 0x10 || stat == 0x11) {
208 set_bit(MBX_INTERRUPT,
211 mb0 = RD_MAILBOX_REG(ha, reg, 0);
212 mb2 = RD_MAILBOX_REG(ha, reg, 2);
214 WRT_REG_WORD(®->hccr,
216 RD_REG_WORD(®->hccr);
220 /* clear this intr; it wasn't a mailbox intr */
221 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
222 RD_REG_WORD(®->hccr);
227 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
228 rval = mb0 & MBS_MASK;
229 fw->risc_ram[cnt] = mb2;
231 rval = QLA_FUNCTION_FAILED;
235 if (rval == QLA_SUCCESS) {
236 /* Get stack SRAM. */
237 risc_address = 0x10000;
238 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_EXTENDED);
239 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
241 for (cnt = 0; cnt < sizeof(fw->stack_ram) / 2 && rval == QLA_SUCCESS;
242 cnt++, risc_address++) {
243 WRT_MAILBOX_REG(ha, reg, 1, LSW(risc_address));
244 WRT_MAILBOX_REG(ha, reg, 8, MSW(risc_address));
245 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
247 for (timer = 6000000; timer; timer--) {
248 /* Check for pending interrupts. */
249 stat = RD_REG_DWORD(®->u.isp2300.host_status);
250 if (stat & HSR_RISC_INT) {
253 if (stat == 0x1 || stat == 0x2) {
254 set_bit(MBX_INTERRUPT,
257 mb0 = RD_MAILBOX_REG(ha, reg, 0);
258 mb2 = RD_MAILBOX_REG(ha, reg, 2);
260 /* Release mailbox registers. */
261 WRT_REG_WORD(®->semaphore, 0);
262 WRT_REG_WORD(®->hccr,
264 RD_REG_WORD(®->hccr);
266 } else if (stat == 0x10 || stat == 0x11) {
267 set_bit(MBX_INTERRUPT,
270 mb0 = RD_MAILBOX_REG(ha, reg, 0);
271 mb2 = RD_MAILBOX_REG(ha, reg, 2);
273 WRT_REG_WORD(®->hccr,
275 RD_REG_WORD(®->hccr);
279 /* clear this intr; it wasn't a mailbox intr */
280 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
281 RD_REG_WORD(®->hccr);
286 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
287 rval = mb0 & MBS_MASK;
288 fw->stack_ram[cnt] = mb2;
290 rval = QLA_FUNCTION_FAILED;
294 if (rval == QLA_SUCCESS) {
296 risc_address = 0x11000;
297 data_ram_cnt = ha->fw_memory_size - risc_address + 1;
298 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_EXTENDED);
299 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
301 for (cnt = 0; cnt < data_ram_cnt && rval == QLA_SUCCESS;
302 cnt++, risc_address++) {
303 WRT_MAILBOX_REG(ha, reg, 1, LSW(risc_address));
304 WRT_MAILBOX_REG(ha, reg, 8, MSW(risc_address));
305 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
307 for (timer = 6000000; timer; timer--) {
308 /* Check for pending interrupts. */
309 stat = RD_REG_DWORD(®->u.isp2300.host_status);
310 if (stat & HSR_RISC_INT) {
313 if (stat == 0x1 || stat == 0x2) {
314 set_bit(MBX_INTERRUPT,
317 mb0 = RD_MAILBOX_REG(ha, reg, 0);
318 mb2 = RD_MAILBOX_REG(ha, reg, 2);
320 /* Release mailbox registers. */
321 WRT_REG_WORD(®->semaphore, 0);
322 WRT_REG_WORD(®->hccr,
324 RD_REG_WORD(®->hccr);
326 } else if (stat == 0x10 || stat == 0x11) {
327 set_bit(MBX_INTERRUPT,
330 mb0 = RD_MAILBOX_REG(ha, reg, 0);
331 mb2 = RD_MAILBOX_REG(ha, reg, 2);
333 WRT_REG_WORD(®->hccr,
335 RD_REG_WORD(®->hccr);
339 /* clear this intr; it wasn't a mailbox intr */
340 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
341 RD_REG_WORD(®->hccr);
346 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
347 rval = mb0 & MBS_MASK;
348 fw->data_ram[cnt] = mb2;
350 rval = QLA_FUNCTION_FAILED;
354 if (rval != QLA_SUCCESS) {
355 qla_printk(KERN_WARNING, ha,
356 "Failed to dump firmware (%x)!!!\n", rval);
360 qla_printk(KERN_INFO, ha,
361 "Firmware dump saved to temp buffer (%ld/%p).\n",
362 ha->host_no, ha->fw_dump);
366 qla2300_fw_dump_failed:
367 if (!hardware_locked)
368 spin_unlock_irqrestore(&ha->hardware_lock, flags);
372 * qla2300_ascii_fw_dump() - Converts a binary firmware dump to ASCII.
376 qla2300_ascii_fw_dump(scsi_qla_host_t *ha)
381 struct qla2300_fw_dump *fw;
382 uint32_t data_ram_cnt;
384 uiter = ha->fw_dump_buffer;
387 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
388 ha->isp_ops.fw_version_str(ha, fw_info));
390 qla_uprintf(&uiter, "\n[==>BEG]\n");
392 qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr);
394 qla_uprintf(&uiter, "PBIU Registers:");
395 for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
397 qla_uprintf(&uiter, "\n");
399 qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]);
402 qla_uprintf(&uiter, "\n\nReqQ-RspQ-Risc2Host Status registers:");
403 for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) {
405 qla_uprintf(&uiter, "\n");
407 qla_uprintf(&uiter, "%04x ", fw->risc_host_reg[cnt]);
410 qla_uprintf(&uiter, "\n\nMailbox Registers:");
411 for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
413 qla_uprintf(&uiter, "\n");
415 qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]);
418 qla_uprintf(&uiter, "\n\nAuto Request Response DMA Registers:");
419 for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) {
421 qla_uprintf(&uiter, "\n");
423 qla_uprintf(&uiter, "%04x ", fw->resp_dma_reg[cnt]);
426 qla_uprintf(&uiter, "\n\nDMA Registers:");
427 for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
429 qla_uprintf(&uiter, "\n");
431 qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]);
434 qla_uprintf(&uiter, "\n\nRISC Hardware Registers:");
435 for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
437 qla_uprintf(&uiter, "\n");
439 qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]);
442 qla_uprintf(&uiter, "\n\nRISC GP0 Registers:");
443 for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
445 qla_uprintf(&uiter, "\n");
447 qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]);
450 qla_uprintf(&uiter, "\n\nRISC GP1 Registers:");
451 for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
453 qla_uprintf(&uiter, "\n");
455 qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]);
458 qla_uprintf(&uiter, "\n\nRISC GP2 Registers:");
459 for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
461 qla_uprintf(&uiter, "\n");
463 qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]);
466 qla_uprintf(&uiter, "\n\nRISC GP3 Registers:");
467 for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
469 qla_uprintf(&uiter, "\n");
471 qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]);
474 qla_uprintf(&uiter, "\n\nRISC GP4 Registers:");
475 for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
477 qla_uprintf(&uiter, "\n");
479 qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]);
482 qla_uprintf(&uiter, "\n\nRISC GP5 Registers:");
483 for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
485 qla_uprintf(&uiter, "\n");
487 qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]);
490 qla_uprintf(&uiter, "\n\nRISC GP6 Registers:");
491 for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
493 qla_uprintf(&uiter, "\n");
495 qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]);
498 qla_uprintf(&uiter, "\n\nRISC GP7 Registers:");
499 for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
501 qla_uprintf(&uiter, "\n");
503 qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]);
506 qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:");
507 for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
509 qla_uprintf(&uiter, "\n");
511 qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]);
514 qla_uprintf(&uiter, "\n\nFPM B0 Registers:");
515 for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
517 qla_uprintf(&uiter, "\n");
519 qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]);
522 qla_uprintf(&uiter, "\n\nFPM B1 Registers:");
523 for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
525 qla_uprintf(&uiter, "\n");
527 qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]);
530 qla_uprintf(&uiter, "\n\nCode RAM Dump:");
531 for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
533 qla_uprintf(&uiter, "\n%04x: ", cnt + 0x0800);
535 qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]);
538 qla_uprintf(&uiter, "\n\nStack RAM Dump:");
539 for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) {
541 qla_uprintf(&uiter, "\n%05x: ", cnt + 0x10000);
543 qla_uprintf(&uiter, "%04x ", fw->stack_ram[cnt]);
546 qla_uprintf(&uiter, "\n\nData RAM Dump:");
547 data_ram_cnt = ha->fw_memory_size - 0x11000 + 1;
548 for (cnt = 0; cnt < data_ram_cnt; cnt++) {
550 qla_uprintf(&uiter, "\n%05x: ", cnt + 0x11000);
552 qla_uprintf(&uiter, "%04x ", fw->data_ram[cnt]);
555 qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump.");
559 * qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware.
561 * @hardware_locked: Called with the hardware_lock
564 qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
568 uint16_t risc_address;
570 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
571 uint16_t __iomem *dmp_reg;
573 struct qla2100_fw_dump *fw;
579 if (!hardware_locked)
580 spin_lock_irqsave(&ha->hardware_lock, flags);
583 qla_printk(KERN_WARNING, ha,
584 "No buffer available for dump!!!\n");
585 goto qla2100_fw_dump_failed;
589 qla_printk(KERN_WARNING, ha,
590 "Firmware has been previously dumped (%p) -- ignoring "
591 "request...\n", ha->fw_dump);
592 goto qla2100_fw_dump_failed;
597 fw->hccr = RD_REG_WORD(®->hccr);
600 WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC);
601 for (cnt = 30000; (RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0 &&
602 rval == QLA_SUCCESS; cnt--) {
606 rval = QLA_FUNCTION_TIMEOUT;
608 if (rval == QLA_SUCCESS) {
609 dmp_reg = (uint16_t __iomem *)(reg + 0);
610 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++)
611 fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
613 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10);
614 for (cnt = 0; cnt < ha->mbx_count; cnt++) {
616 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xe0);
618 fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
621 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x20);
622 for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++)
623 fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
625 WRT_REG_WORD(®->ctrl_status, 0x00);
626 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0);
627 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++)
628 fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
630 WRT_REG_WORD(®->pcr, 0x2000);
631 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
632 for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++)
633 fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
635 WRT_REG_WORD(®->pcr, 0x2100);
636 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
637 for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++)
638 fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
640 WRT_REG_WORD(®->pcr, 0x2200);
641 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
642 for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++)
643 fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
645 WRT_REG_WORD(®->pcr, 0x2300);
646 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
647 for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++)
648 fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
650 WRT_REG_WORD(®->pcr, 0x2400);
651 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
652 for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++)
653 fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
655 WRT_REG_WORD(®->pcr, 0x2500);
656 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
657 for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++)
658 fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
660 WRT_REG_WORD(®->pcr, 0x2600);
661 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
662 for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++)
663 fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
665 WRT_REG_WORD(®->pcr, 0x2700);
666 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
667 for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++)
668 fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
670 WRT_REG_WORD(®->ctrl_status, 0x10);
671 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
672 for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++)
673 fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
675 WRT_REG_WORD(®->ctrl_status, 0x20);
676 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
677 for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++)
678 fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
680 WRT_REG_WORD(®->ctrl_status, 0x30);
681 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
682 for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++)
683 fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
686 WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET);
689 for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
690 rval == QLA_SUCCESS; cnt--) {
694 rval = QLA_FUNCTION_TIMEOUT;
698 if (rval == QLA_SUCCESS && (IS_QLA2200(ha) || (IS_QLA2100(ha) &&
699 (RD_REG_WORD(®->mctr) & (BIT_1 | BIT_0)) != 0))) {
701 WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC);
703 (RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0 &&
704 rval == QLA_SUCCESS; cnt--) {
708 rval = QLA_FUNCTION_TIMEOUT;
710 if (rval == QLA_SUCCESS) {
711 /* Set memory configuration and timing. */
713 WRT_REG_WORD(®->mctr, 0xf1);
715 WRT_REG_WORD(®->mctr, 0xf2);
716 RD_REG_WORD(®->mctr); /* PCI Posting. */
719 WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC);
723 if (rval == QLA_SUCCESS) {
725 risc_address = 0x1000;
726 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
727 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
729 for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
730 cnt++, risc_address++) {
731 WRT_MAILBOX_REG(ha, reg, 1, risc_address);
732 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
734 for (timer = 6000000; timer != 0; timer--) {
735 /* Check for pending interrupts. */
736 if (RD_REG_WORD(®->istatus) & ISR_RISC_INT) {
737 if (RD_REG_WORD(®->semaphore) & BIT_0) {
738 set_bit(MBX_INTERRUPT,
741 mb0 = RD_MAILBOX_REG(ha, reg, 0);
742 mb2 = RD_MAILBOX_REG(ha, reg, 2);
744 WRT_REG_WORD(®->semaphore, 0);
745 WRT_REG_WORD(®->hccr,
747 RD_REG_WORD(®->hccr);
750 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
751 RD_REG_WORD(®->hccr);
756 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
757 rval = mb0 & MBS_MASK;
758 fw->risc_ram[cnt] = mb2;
760 rval = QLA_FUNCTION_FAILED;
764 if (rval != QLA_SUCCESS) {
765 qla_printk(KERN_WARNING, ha,
766 "Failed to dump firmware (%x)!!!\n", rval);
770 qla_printk(KERN_INFO, ha,
771 "Firmware dump saved to temp buffer (%ld/%p).\n",
772 ha->host_no, ha->fw_dump);
776 qla2100_fw_dump_failed:
777 if (!hardware_locked)
778 spin_unlock_irqrestore(&ha->hardware_lock, flags);
782 * qla2100_ascii_fw_dump() - Converts a binary firmware dump to ASCII.
786 qla2100_ascii_fw_dump(scsi_qla_host_t *ha)
791 struct qla2100_fw_dump *fw;
793 uiter = ha->fw_dump_buffer;
796 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
797 ha->isp_ops.fw_version_str(ha, fw_info));
799 qla_uprintf(&uiter, "\n[==>BEG]\n");
801 qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr);
803 qla_uprintf(&uiter, "PBIU Registers:");
804 for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
806 qla_uprintf(&uiter, "\n");
808 qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]);
811 qla_uprintf(&uiter, "\n\nMailbox Registers:");
812 for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
814 qla_uprintf(&uiter, "\n");
816 qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]);
819 qla_uprintf(&uiter, "\n\nDMA Registers:");
820 for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
822 qla_uprintf(&uiter, "\n");
824 qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]);
827 qla_uprintf(&uiter, "\n\nRISC Hardware Registers:");
828 for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
830 qla_uprintf(&uiter, "\n");
832 qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]);
835 qla_uprintf(&uiter, "\n\nRISC GP0 Registers:");
836 for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
838 qla_uprintf(&uiter, "\n");
840 qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]);
843 qla_uprintf(&uiter, "\n\nRISC GP1 Registers:");
844 for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
846 qla_uprintf(&uiter, "\n");
848 qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]);
851 qla_uprintf(&uiter, "\n\nRISC GP2 Registers:");
852 for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
854 qla_uprintf(&uiter, "\n");
856 qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]);
859 qla_uprintf(&uiter, "\n\nRISC GP3 Registers:");
860 for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
862 qla_uprintf(&uiter, "\n");
864 qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]);
867 qla_uprintf(&uiter, "\n\nRISC GP4 Registers:");
868 for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
870 qla_uprintf(&uiter, "\n");
872 qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]);
875 qla_uprintf(&uiter, "\n\nRISC GP5 Registers:");
876 for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
878 qla_uprintf(&uiter, "\n");
880 qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]);
883 qla_uprintf(&uiter, "\n\nRISC GP6 Registers:");
884 for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
886 qla_uprintf(&uiter, "\n");
888 qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]);
891 qla_uprintf(&uiter, "\n\nRISC GP7 Registers:");
892 for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
894 qla_uprintf(&uiter, "\n");
896 qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]);
899 qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:");
900 for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
902 qla_uprintf(&uiter, "\n");
904 qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]);
907 qla_uprintf(&uiter, "\n\nFPM B0 Registers:");
908 for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
910 qla_uprintf(&uiter, "\n");
912 qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]);
915 qla_uprintf(&uiter, "\n\nFPM B1 Registers:");
916 for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
918 qla_uprintf(&uiter, "\n");
920 qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]);
923 qla_uprintf(&uiter, "\n\nRISC SRAM:");
924 for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
926 qla_uprintf(&uiter, "\n%04x: ", cnt + 0x1000);
928 qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]);
931 qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump.");
937 qla_uprintf(char **uiter, char *fmt, ...)
944 len = vsprintf(buf, fmt, args);
947 for (iter = 0; iter < len; iter++, *uiter += 1)
948 *uiter[0] = buf[iter];
955 qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
959 uint32_t risc_address;
963 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
964 uint32_t __iomem *dmp_reg;
966 uint16_t __iomem *mbx_reg;
968 struct qla24xx_fw_dump *fw;
969 uint32_t ext_mem_cnt;
971 risc_address = ext_mem_cnt = 0;
972 memset(mb, 0, sizeof(mb));
975 if (!hardware_locked)
976 spin_lock_irqsave(&ha->hardware_lock, flags);
979 qla_printk(KERN_WARNING, ha,
980 "No buffer available for dump!!!\n");
981 goto qla24xx_fw_dump_failed;
985 qla_printk(KERN_WARNING, ha,
986 "Firmware has been previously dumped (%p) -- ignoring "
987 "request...\n", ha->fw_dump);
988 goto qla24xx_fw_dump_failed;
993 fw->host_status = RD_REG_DWORD(®->host_status);
996 if ((RD_REG_DWORD(®->hccr) & HCCRX_RISC_PAUSE) == 0) {
997 WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET |
999 RD_REG_DWORD(®->hccr); /* PCI Posting. */
1000 WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_PAUSE);
1002 (RD_REG_DWORD(®->hccr) & HCCRX_RISC_PAUSE) == 0 &&
1003 rval == QLA_SUCCESS; cnt--) {
1007 rval = QLA_FUNCTION_TIMEOUT;
1011 if (rval == QLA_SUCCESS) {
1012 /* Host interface registers. */
1013 dmp_reg = (uint32_t __iomem *)(reg + 0);
1014 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++)
1015 fw->host_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1017 /* Disable interrupts. */
1018 WRT_REG_DWORD(®->ictrl, 0);
1019 RD_REG_DWORD(®->ictrl);
1021 /* Shadow registers. */
1022 WRT_REG_DWORD(®->iobase_addr, 0x0F70);
1023 RD_REG_DWORD(®->iobase_addr);
1024 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1025 WRT_REG_DWORD(dmp_reg, 0xB0000000);
1026 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1027 fw->shadow_reg[0] = RD_REG_DWORD(dmp_reg);
1029 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1030 WRT_REG_DWORD(dmp_reg, 0xB0100000);
1031 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1032 fw->shadow_reg[1] = RD_REG_DWORD(dmp_reg);
1034 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1035 WRT_REG_DWORD(dmp_reg, 0xB0200000);
1036 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1037 fw->shadow_reg[2] = RD_REG_DWORD(dmp_reg);
1039 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1040 WRT_REG_DWORD(dmp_reg, 0xB0300000);
1041 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1042 fw->shadow_reg[3] = RD_REG_DWORD(dmp_reg);
1044 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1045 WRT_REG_DWORD(dmp_reg, 0xB0400000);
1046 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1047 fw->shadow_reg[4] = RD_REG_DWORD(dmp_reg);
1049 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1050 WRT_REG_DWORD(dmp_reg, 0xB0500000);
1051 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1052 fw->shadow_reg[5] = RD_REG_DWORD(dmp_reg);
1054 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1055 WRT_REG_DWORD(dmp_reg, 0xB0600000);
1056 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1057 fw->shadow_reg[6] = RD_REG_DWORD(dmp_reg);
1059 /* Mailbox registers. */
1060 mbx_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
1061 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
1062 fw->mailbox_reg[cnt] = RD_REG_WORD(mbx_reg++);
1064 /* Transfer sequence registers. */
1065 iter_reg = fw->xseq_gp_reg;
1066 WRT_REG_DWORD(®->iobase_addr, 0xBF00);
1067 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1068 for (cnt = 0; cnt < 16; cnt++)
1069 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1071 WRT_REG_DWORD(®->iobase_addr, 0xBF10);
1072 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1073 for (cnt = 0; cnt < 16; cnt++)
1074 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1076 WRT_REG_DWORD(®->iobase_addr, 0xBF20);
1077 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1078 for (cnt = 0; cnt < 16; cnt++)
1079 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1081 WRT_REG_DWORD(®->iobase_addr, 0xBF30);
1082 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1083 for (cnt = 0; cnt < 16; cnt++)
1084 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1086 WRT_REG_DWORD(®->iobase_addr, 0xBF40);
1087 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1088 for (cnt = 0; cnt < 16; cnt++)
1089 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1091 WRT_REG_DWORD(®->iobase_addr, 0xBF50);
1092 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1093 for (cnt = 0; cnt < 16; cnt++)
1094 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1096 WRT_REG_DWORD(®->iobase_addr, 0xBF60);
1097 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1098 for (cnt = 0; cnt < 16; cnt++)
1099 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1101 WRT_REG_DWORD(®->iobase_addr, 0xBF70);
1102 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1103 for (cnt = 0; cnt < 16; cnt++)
1104 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1106 WRT_REG_DWORD(®->iobase_addr, 0xBFE0);
1107 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1108 for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++)
1109 fw->xseq_0_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1111 WRT_REG_DWORD(®->iobase_addr, 0xBFF0);
1112 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1113 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++)
1114 fw->xseq_1_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1116 /* Receive sequence registers. */
1117 iter_reg = fw->rseq_gp_reg;
1118 WRT_REG_DWORD(®->iobase_addr, 0xFF00);
1119 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1120 for (cnt = 0; cnt < 16; cnt++)
1121 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1123 WRT_REG_DWORD(®->iobase_addr, 0xFF10);
1124 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1125 for (cnt = 0; cnt < 16; cnt++)
1126 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1128 WRT_REG_DWORD(®->iobase_addr, 0xFF20);
1129 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1130 for (cnt = 0; cnt < 16; cnt++)
1131 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1133 WRT_REG_DWORD(®->iobase_addr, 0xFF30);
1134 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1135 for (cnt = 0; cnt < 16; cnt++)
1136 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1138 WRT_REG_DWORD(®->iobase_addr, 0xFF40);
1139 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1140 for (cnt = 0; cnt < 16; cnt++)
1141 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1143 WRT_REG_DWORD(®->iobase_addr, 0xFF50);
1144 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1145 for (cnt = 0; cnt < 16; cnt++)
1146 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1148 WRT_REG_DWORD(®->iobase_addr, 0xFF60);
1149 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1150 for (cnt = 0; cnt < 16; cnt++)
1151 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1153 WRT_REG_DWORD(®->iobase_addr, 0xFF70);
1154 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1155 for (cnt = 0; cnt < 16; cnt++)
1156 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1158 WRT_REG_DWORD(®->iobase_addr, 0xFFD0);
1159 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1160 for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++)
1161 fw->rseq_0_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1163 WRT_REG_DWORD(®->iobase_addr, 0xFFE0);
1164 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1165 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++)
1166 fw->rseq_1_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1168 WRT_REG_DWORD(®->iobase_addr, 0xFFF0);
1169 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1170 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++)
1171 fw->rseq_2_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1173 /* Command DMA registers. */
1174 WRT_REG_DWORD(®->iobase_addr, 0x7100);
1175 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1176 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++)
1177 fw->cmd_dma_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1180 iter_reg = fw->req0_dma_reg;
1181 WRT_REG_DWORD(®->iobase_addr, 0x7200);
1182 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1183 for (cnt = 0; cnt < 8; cnt++)
1184 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1186 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4);
1187 for (cnt = 0; cnt < 7; cnt++)
1188 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1190 iter_reg = fw->resp0_dma_reg;
1191 WRT_REG_DWORD(®->iobase_addr, 0x7300);
1192 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1193 for (cnt = 0; cnt < 8; cnt++)
1194 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1196 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4);
1197 for (cnt = 0; cnt < 7; cnt++)
1198 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1200 iter_reg = fw->req1_dma_reg;
1201 WRT_REG_DWORD(®->iobase_addr, 0x7400);
1202 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1203 for (cnt = 0; cnt < 8; cnt++)
1204 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1206 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4);
1207 for (cnt = 0; cnt < 7; cnt++)
1208 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1210 /* Transmit DMA registers. */
1211 iter_reg = fw->xmt0_dma_reg;
1212 WRT_REG_DWORD(®->iobase_addr, 0x7600);
1213 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1214 for (cnt = 0; cnt < 16; cnt++)
1215 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1217 WRT_REG_DWORD(®->iobase_addr, 0x7610);
1218 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1219 for (cnt = 0; cnt < 16; cnt++)
1220 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1222 iter_reg = fw->xmt1_dma_reg;
1223 WRT_REG_DWORD(®->iobase_addr, 0x7620);
1224 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1225 for (cnt = 0; cnt < 16; cnt++)
1226 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1228 WRT_REG_DWORD(®->iobase_addr, 0x7630);
1229 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1230 for (cnt = 0; cnt < 16; cnt++)
1231 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1233 iter_reg = fw->xmt2_dma_reg;
1234 WRT_REG_DWORD(®->iobase_addr, 0x7640);
1235 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1236 for (cnt = 0; cnt < 16; cnt++)
1237 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1239 WRT_REG_DWORD(®->iobase_addr, 0x7650);
1240 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1241 for (cnt = 0; cnt < 16; cnt++)
1242 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1244 iter_reg = fw->xmt3_dma_reg;
1245 WRT_REG_DWORD(®->iobase_addr, 0x7660);
1246 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1247 for (cnt = 0; cnt < 16; cnt++)
1248 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1250 WRT_REG_DWORD(®->iobase_addr, 0x7670);
1251 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1252 for (cnt = 0; cnt < 16; cnt++)
1253 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1255 iter_reg = fw->xmt4_dma_reg;
1256 WRT_REG_DWORD(®->iobase_addr, 0x7680);
1257 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1258 for (cnt = 0; cnt < 16; cnt++)
1259 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1261 WRT_REG_DWORD(®->iobase_addr, 0x7690);
1262 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1263 for (cnt = 0; cnt < 16; cnt++)
1264 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1266 WRT_REG_DWORD(®->iobase_addr, 0x76A0);
1267 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1268 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++)
1269 fw->xmt_data_dma_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1271 /* Receive DMA registers. */
1272 iter_reg = fw->rcvt0_data_dma_reg;
1273 WRT_REG_DWORD(®->iobase_addr, 0x7700);
1274 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1275 for (cnt = 0; cnt < 16; cnt++)
1276 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1278 WRT_REG_DWORD(®->iobase_addr, 0x7710);
1279 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1280 for (cnt = 0; cnt < 16; cnt++)
1281 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1283 iter_reg = fw->rcvt1_data_dma_reg;
1284 WRT_REG_DWORD(®->iobase_addr, 0x7720);
1285 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1286 for (cnt = 0; cnt < 16; cnt++)
1287 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1289 WRT_REG_DWORD(®->iobase_addr, 0x7730);
1290 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1291 for (cnt = 0; cnt < 16; cnt++)
1292 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1294 /* RISC registers. */
1295 iter_reg = fw->risc_gp_reg;
1296 WRT_REG_DWORD(®->iobase_addr, 0x0F00);
1297 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1298 for (cnt = 0; cnt < 16; cnt++)
1299 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1301 WRT_REG_DWORD(®->iobase_addr, 0x0F10);
1302 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1303 for (cnt = 0; cnt < 16; cnt++)
1304 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1306 WRT_REG_DWORD(®->iobase_addr, 0x0F20);
1307 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1308 for (cnt = 0; cnt < 16; cnt++)
1309 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1311 WRT_REG_DWORD(®->iobase_addr, 0x0F30);
1312 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1313 for (cnt = 0; cnt < 16; cnt++)
1314 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1316 WRT_REG_DWORD(®->iobase_addr, 0x0F40);
1317 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1318 for (cnt = 0; cnt < 16; cnt++)
1319 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1321 WRT_REG_DWORD(®->iobase_addr, 0x0F50);
1322 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1323 for (cnt = 0; cnt < 16; cnt++)
1324 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1326 WRT_REG_DWORD(®->iobase_addr, 0x0F60);
1327 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1328 for (cnt = 0; cnt < 16; cnt++)
1329 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1331 WRT_REG_DWORD(®->iobase_addr, 0x0F70);
1332 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1333 for (cnt = 0; cnt < 16; cnt++)
1334 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1336 /* Local memory controller registers. */
1337 iter_reg = fw->lmc_reg;
1338 WRT_REG_DWORD(®->iobase_addr, 0x3000);
1339 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1340 for (cnt = 0; cnt < 16; cnt++)
1341 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1343 WRT_REG_DWORD(®->iobase_addr, 0x3010);
1344 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1345 for (cnt = 0; cnt < 16; cnt++)
1346 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1348 WRT_REG_DWORD(®->iobase_addr, 0x3020);
1349 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1350 for (cnt = 0; cnt < 16; cnt++)
1351 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1353 WRT_REG_DWORD(®->iobase_addr, 0x3030);
1354 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1355 for (cnt = 0; cnt < 16; cnt++)
1356 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1358 WRT_REG_DWORD(®->iobase_addr, 0x3040);
1359 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1360 for (cnt = 0; cnt < 16; cnt++)
1361 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1363 WRT_REG_DWORD(®->iobase_addr, 0x3050);
1364 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1365 for (cnt = 0; cnt < 16; cnt++)
1366 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1368 WRT_REG_DWORD(®->iobase_addr, 0x3060);
1369 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1370 for (cnt = 0; cnt < 16; cnt++)
1371 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1373 /* Fibre Protocol Module registers. */
1374 iter_reg = fw->fpm_hdw_reg;
1375 WRT_REG_DWORD(®->iobase_addr, 0x4000);
1376 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1377 for (cnt = 0; cnt < 16; cnt++)
1378 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1380 WRT_REG_DWORD(®->iobase_addr, 0x4010);
1381 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1382 for (cnt = 0; cnt < 16; cnt++)
1383 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1385 WRT_REG_DWORD(®->iobase_addr, 0x4020);
1386 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1387 for (cnt = 0; cnt < 16; cnt++)
1388 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1390 WRT_REG_DWORD(®->iobase_addr, 0x4030);
1391 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1392 for (cnt = 0; cnt < 16; cnt++)
1393 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1395 WRT_REG_DWORD(®->iobase_addr, 0x4040);
1396 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1397 for (cnt = 0; cnt < 16; cnt++)
1398 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1400 WRT_REG_DWORD(®->iobase_addr, 0x4050);
1401 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1402 for (cnt = 0; cnt < 16; cnt++)
1403 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1405 WRT_REG_DWORD(®->iobase_addr, 0x4060);
1406 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1407 for (cnt = 0; cnt < 16; cnt++)
1408 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1410 WRT_REG_DWORD(®->iobase_addr, 0x4070);
1411 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1412 for (cnt = 0; cnt < 16; cnt++)
1413 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1415 WRT_REG_DWORD(®->iobase_addr, 0x4080);
1416 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1417 for (cnt = 0; cnt < 16; cnt++)
1418 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1420 WRT_REG_DWORD(®->iobase_addr, 0x4090);
1421 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1422 for (cnt = 0; cnt < 16; cnt++)
1423 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1425 WRT_REG_DWORD(®->iobase_addr, 0x40A0);
1426 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1427 for (cnt = 0; cnt < 16; cnt++)
1428 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1430 WRT_REG_DWORD(®->iobase_addr, 0x40B0);
1431 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1432 for (cnt = 0; cnt < 16; cnt++)
1433 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1435 /* Frame Buffer registers. */
1436 iter_reg = fw->fb_hdw_reg;
1437 WRT_REG_DWORD(®->iobase_addr, 0x6000);
1438 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1439 for (cnt = 0; cnt < 16; cnt++)
1440 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1442 WRT_REG_DWORD(®->iobase_addr, 0x6010);
1443 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1444 for (cnt = 0; cnt < 16; cnt++)
1445 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1447 WRT_REG_DWORD(®->iobase_addr, 0x6020);
1448 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1449 for (cnt = 0; cnt < 16; cnt++)
1450 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1452 WRT_REG_DWORD(®->iobase_addr, 0x6030);
1453 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1454 for (cnt = 0; cnt < 16; cnt++)
1455 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1457 WRT_REG_DWORD(®->iobase_addr, 0x6040);
1458 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1459 for (cnt = 0; cnt < 16; cnt++)
1460 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1462 WRT_REG_DWORD(®->iobase_addr, 0x6100);
1463 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1464 for (cnt = 0; cnt < 16; cnt++)
1465 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1467 WRT_REG_DWORD(®->iobase_addr, 0x6130);
1468 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1469 for (cnt = 0; cnt < 16; cnt++)
1470 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1472 WRT_REG_DWORD(®->iobase_addr, 0x6150);
1473 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1474 for (cnt = 0; cnt < 16; cnt++)
1475 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1477 WRT_REG_DWORD(®->iobase_addr, 0x6170);
1478 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1479 for (cnt = 0; cnt < 16; cnt++)
1480 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1482 WRT_REG_DWORD(®->iobase_addr, 0x6190);
1483 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1484 for (cnt = 0; cnt < 16; cnt++)
1485 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1487 WRT_REG_DWORD(®->iobase_addr, 0x61B0);
1488 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1489 for (cnt = 0; cnt < 16; cnt++)
1490 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1493 WRT_REG_DWORD(®->ctrl_status,
1494 CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
1495 for (cnt = 0; cnt < 30000; cnt++) {
1496 if ((RD_REG_DWORD(®->ctrl_status) &
1497 CSRX_DMA_ACTIVE) == 0)
1503 WRT_REG_DWORD(®->ctrl_status,
1504 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
1505 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
1508 /* Wait for firmware to complete NVRAM accesses. */
1509 mb[0] = (uint32_t) RD_REG_WORD(®->mailbox0);
1510 for (cnt = 10000 ; cnt && mb[0]; cnt--) {
1512 mb[0] = (uint32_t) RD_REG_WORD(®->mailbox0);
1516 /* Wait for soft-reset to complete. */
1517 for (cnt = 0; cnt < 30000; cnt++) {
1518 if ((RD_REG_DWORD(®->ctrl_status) &
1519 CSRX_ISP_SOFT_RESET) == 0)
1524 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_RESET);
1525 RD_REG_DWORD(®->hccr); /* PCI Posting. */
1528 for (cnt = 30000; RD_REG_WORD(®->mailbox0) != 0 &&
1529 rval == QLA_SUCCESS; cnt--) {
1533 rval = QLA_FUNCTION_TIMEOUT;
1537 if (rval == QLA_SUCCESS) {
1539 risc_address = 0x20000;
1540 WRT_REG_WORD(®->mailbox0, MBC_READ_RAM_EXTENDED);
1541 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1543 for (cnt = 0; cnt < sizeof(fw->code_ram) / 4 && rval == QLA_SUCCESS;
1544 cnt++, risc_address++) {
1545 WRT_REG_WORD(®->mailbox1, LSW(risc_address));
1546 WRT_REG_WORD(®->mailbox8, MSW(risc_address));
1547 RD_REG_WORD(®->mailbox8);
1548 WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT);
1550 for (timer = 6000000; timer; timer--) {
1551 /* Check for pending interrupts. */
1552 stat = RD_REG_DWORD(®->host_status);
1553 if (stat & HSRX_RISC_INT) {
1556 if (stat == 0x1 || stat == 0x2 ||
1557 stat == 0x10 || stat == 0x11) {
1558 set_bit(MBX_INTERRUPT,
1559 &ha->mbx_cmd_flags);
1561 mb[0] = RD_REG_WORD(®->mailbox0);
1562 mb[2] = RD_REG_WORD(®->mailbox2);
1563 mb[3] = RD_REG_WORD(®->mailbox3);
1565 WRT_REG_DWORD(®->hccr,
1566 HCCRX_CLR_RISC_INT);
1567 RD_REG_DWORD(®->hccr);
1571 /* Clear this intr; it wasn't a mailbox intr */
1572 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT);
1573 RD_REG_DWORD(®->hccr);
1578 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
1579 rval = mb[0] & MBS_MASK;
1580 fw->code_ram[cnt] = (mb[3] << 16) | mb[2];
1582 rval = QLA_FUNCTION_FAILED;
1586 if (rval == QLA_SUCCESS) {
1587 /* External Memory. */
1588 risc_address = 0x100000;
1589 ext_mem_cnt = ha->fw_memory_size - 0x100000 + 1;
1590 WRT_REG_WORD(®->mailbox0, MBC_READ_RAM_EXTENDED);
1591 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1593 for (cnt = 0; cnt < ext_mem_cnt && rval == QLA_SUCCESS;
1594 cnt++, risc_address++) {
1595 WRT_REG_WORD(®->mailbox1, LSW(risc_address));
1596 WRT_REG_WORD(®->mailbox8, MSW(risc_address));
1597 RD_REG_WORD(®->mailbox8);
1598 WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT);
1600 for (timer = 6000000; timer; timer--) {
1601 /* Check for pending interrupts. */
1602 stat = RD_REG_DWORD(®->host_status);
1603 if (stat & HSRX_RISC_INT) {
1606 if (stat == 0x1 || stat == 0x2 ||
1607 stat == 0x10 || stat == 0x11) {
1608 set_bit(MBX_INTERRUPT,
1609 &ha->mbx_cmd_flags);
1611 mb[0] = RD_REG_WORD(®->mailbox0);
1612 mb[2] = RD_REG_WORD(®->mailbox2);
1613 mb[3] = RD_REG_WORD(®->mailbox3);
1615 WRT_REG_DWORD(®->hccr,
1616 HCCRX_CLR_RISC_INT);
1617 RD_REG_DWORD(®->hccr);
1621 /* Clear this intr; it wasn't a mailbox intr */
1622 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT);
1623 RD_REG_DWORD(®->hccr);
1628 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
1629 rval = mb[0] & MBS_MASK;
1630 fw->ext_mem[cnt] = (mb[3] << 16) | mb[2];
1632 rval = QLA_FUNCTION_FAILED;
1636 if (rval != QLA_SUCCESS) {
1637 qla_printk(KERN_WARNING, ha,
1638 "Failed to dump firmware (%x)!!!\n", rval);
1642 qla_printk(KERN_INFO, ha,
1643 "Firmware dump saved to temp buffer (%ld/%p).\n",
1644 ha->host_no, ha->fw_dump);
1648 qla24xx_fw_dump_failed:
1649 if (!hardware_locked)
1650 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1654 qla24xx_ascii_fw_dump(scsi_qla_host_t *ha)
1658 struct qla24xx_fw_dump *fw;
1659 uint32_t ext_mem_cnt;
1661 uiter = ha->fw_dump_buffer;
1664 qla_uprintf(&uiter, "ISP FW Version %d.%02d.%02d Attributes %04x\n",
1665 ha->fw_major_version, ha->fw_minor_version,
1666 ha->fw_subminor_version, ha->fw_attributes);
1668 qla_uprintf(&uiter, "\nR2H Status Register\n%04x\n", fw->host_status);
1670 qla_uprintf(&uiter, "\nHost Interface Registers");
1671 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++) {
1673 qla_uprintf(&uiter, "\n");
1675 qla_uprintf(&uiter, "%08x ", fw->host_reg[cnt]);
1678 qla_uprintf(&uiter, "\n\nShadow Registers");
1679 for (cnt = 0; cnt < sizeof(fw->shadow_reg) / 4; cnt++) {
1681 qla_uprintf(&uiter, "\n");
1683 qla_uprintf(&uiter, "%08x ", fw->shadow_reg[cnt]);
1686 qla_uprintf(&uiter, "\n\nMailbox Registers");
1687 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) {
1689 qla_uprintf(&uiter, "\n");
1691 qla_uprintf(&uiter, "%08x ", fw->mailbox_reg[cnt]);
1694 qla_uprintf(&uiter, "\n\nXSEQ GP Registers");
1695 for (cnt = 0; cnt < sizeof(fw->xseq_gp_reg) / 4; cnt++) {
1697 qla_uprintf(&uiter, "\n");
1699 qla_uprintf(&uiter, "%08x ", fw->xseq_gp_reg[cnt]);
1702 qla_uprintf(&uiter, "\n\nXSEQ-0 Registers");
1703 for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++) {
1705 qla_uprintf(&uiter, "\n");
1707 qla_uprintf(&uiter, "%08x ", fw->xseq_0_reg[cnt]);
1710 qla_uprintf(&uiter, "\n\nXSEQ-1 Registers");
1711 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++) {
1713 qla_uprintf(&uiter, "\n");
1715 qla_uprintf(&uiter, "%08x ", fw->xseq_1_reg[cnt]);
1718 qla_uprintf(&uiter, "\n\nRSEQ GP Registers");
1719 for (cnt = 0; cnt < sizeof(fw->rseq_gp_reg) / 4; cnt++) {
1721 qla_uprintf(&uiter, "\n");
1723 qla_uprintf(&uiter, "%08x ", fw->rseq_gp_reg[cnt]);
1726 qla_uprintf(&uiter, "\n\nRSEQ-0 Registers");
1727 for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++) {
1729 qla_uprintf(&uiter, "\n");
1731 qla_uprintf(&uiter, "%08x ", fw->rseq_0_reg[cnt]);
1734 qla_uprintf(&uiter, "\n\nRSEQ-1 Registers");
1735 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++) {
1737 qla_uprintf(&uiter, "\n");
1739 qla_uprintf(&uiter, "%08x ", fw->rseq_1_reg[cnt]);
1742 qla_uprintf(&uiter, "\n\nRSEQ-2 Registers");
1743 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++) {
1745 qla_uprintf(&uiter, "\n");
1747 qla_uprintf(&uiter, "%08x ", fw->rseq_2_reg[cnt]);
1750 qla_uprintf(&uiter, "\n\nCommand DMA Registers");
1751 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++) {
1753 qla_uprintf(&uiter, "\n");
1755 qla_uprintf(&uiter, "%08x ", fw->cmd_dma_reg[cnt]);
1758 qla_uprintf(&uiter, "\n\nRequest0 Queue DMA Channel Registers");
1759 for (cnt = 0; cnt < sizeof(fw->req0_dma_reg) / 4; cnt++) {
1761 qla_uprintf(&uiter, "\n");
1763 qla_uprintf(&uiter, "%08x ", fw->req0_dma_reg[cnt]);
1766 qla_uprintf(&uiter, "\n\nResponse0 Queue DMA Channel Registers");
1767 for (cnt = 0; cnt < sizeof(fw->resp0_dma_reg) / 4; cnt++) {
1769 qla_uprintf(&uiter, "\n");
1771 qla_uprintf(&uiter, "%08x ", fw->resp0_dma_reg[cnt]);
1774 qla_uprintf(&uiter, "\n\nRequest1 Queue DMA Channel Registers");
1775 for (cnt = 0; cnt < sizeof(fw->req1_dma_reg) / 4; cnt++) {
1777 qla_uprintf(&uiter, "\n");
1779 qla_uprintf(&uiter, "%08x ", fw->req1_dma_reg[cnt]);
1782 qla_uprintf(&uiter, "\n\nXMT0 Data DMA Registers");
1783 for (cnt = 0; cnt < sizeof(fw->xmt0_dma_reg) / 4; cnt++) {
1785 qla_uprintf(&uiter, "\n");
1787 qla_uprintf(&uiter, "%08x ", fw->xmt0_dma_reg[cnt]);
1790 qla_uprintf(&uiter, "\n\nXMT1 Data DMA Registers");
1791 for (cnt = 0; cnt < sizeof(fw->xmt1_dma_reg) / 4; cnt++) {
1793 qla_uprintf(&uiter, "\n");
1795 qla_uprintf(&uiter, "%08x ", fw->xmt1_dma_reg[cnt]);
1798 qla_uprintf(&uiter, "\n\nXMT2 Data DMA Registers");
1799 for (cnt = 0; cnt < sizeof(fw->xmt2_dma_reg) / 4; cnt++) {
1801 qla_uprintf(&uiter, "\n");
1803 qla_uprintf(&uiter, "%08x ", fw->xmt2_dma_reg[cnt]);
1806 qla_uprintf(&uiter, "\n\nXMT3 Data DMA Registers");
1807 for (cnt = 0; cnt < sizeof(fw->xmt3_dma_reg) / 4; cnt++) {
1809 qla_uprintf(&uiter, "\n");
1811 qla_uprintf(&uiter, "%08x ", fw->xmt3_dma_reg[cnt]);
1814 qla_uprintf(&uiter, "\n\nXMT4 Data DMA Registers");
1815 for (cnt = 0; cnt < sizeof(fw->xmt4_dma_reg) / 4; cnt++) {
1817 qla_uprintf(&uiter, "\n");
1819 qla_uprintf(&uiter, "%08x ", fw->xmt4_dma_reg[cnt]);
1822 qla_uprintf(&uiter, "\n\nXMT Data DMA Common Registers");
1823 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++) {
1825 qla_uprintf(&uiter, "\n");
1827 qla_uprintf(&uiter, "%08x ", fw->xmt_data_dma_reg[cnt]);
1830 qla_uprintf(&uiter, "\n\nRCV Thread 0 Data DMA Registers");
1831 for (cnt = 0; cnt < sizeof(fw->rcvt0_data_dma_reg) / 4; cnt++) {
1833 qla_uprintf(&uiter, "\n");
1835 qla_uprintf(&uiter, "%08x ", fw->rcvt0_data_dma_reg[cnt]);
1838 qla_uprintf(&uiter, "\n\nRCV Thread 1 Data DMA Registers");
1839 for (cnt = 0; cnt < sizeof(fw->rcvt1_data_dma_reg) / 4; cnt++) {
1841 qla_uprintf(&uiter, "\n");
1843 qla_uprintf(&uiter, "%08x ", fw->rcvt1_data_dma_reg[cnt]);
1846 qla_uprintf(&uiter, "\n\nRISC GP Registers");
1847 for (cnt = 0; cnt < sizeof(fw->risc_gp_reg) / 4; cnt++) {
1849 qla_uprintf(&uiter, "\n");
1851 qla_uprintf(&uiter, "%08x ", fw->risc_gp_reg[cnt]);
1854 qla_uprintf(&uiter, "\n\nLMC Registers");
1855 for (cnt = 0; cnt < sizeof(fw->lmc_reg) / 4; cnt++) {
1857 qla_uprintf(&uiter, "\n");
1859 qla_uprintf(&uiter, "%08x ", fw->lmc_reg[cnt]);
1862 qla_uprintf(&uiter, "\n\nFPM Hardware Registers");
1863 for (cnt = 0; cnt < sizeof(fw->fpm_hdw_reg) / 4; cnt++) {
1865 qla_uprintf(&uiter, "\n");
1867 qla_uprintf(&uiter, "%08x ", fw->fpm_hdw_reg[cnt]);
1870 qla_uprintf(&uiter, "\n\nFB Hardware Registers");
1871 for (cnt = 0; cnt < sizeof(fw->fb_hdw_reg) / 4; cnt++) {
1873 qla_uprintf(&uiter, "\n");
1875 qla_uprintf(&uiter, "%08x ", fw->fb_hdw_reg[cnt]);
1878 qla_uprintf(&uiter, "\n\nCode RAM");
1879 for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
1881 qla_uprintf(&uiter, "\n%08x: ", cnt + 0x20000);
1883 qla_uprintf(&uiter, "%08x ", fw->code_ram[cnt]);
1886 qla_uprintf(&uiter, "\n\nExternal Memory");
1887 ext_mem_cnt = ha->fw_memory_size - 0x100000 + 1;
1888 for (cnt = 0; cnt < ext_mem_cnt; cnt++) {
1890 qla_uprintf(&uiter, "\n%08x: ", cnt + 0x100000);
1892 qla_uprintf(&uiter, "%08x ", fw->ext_mem[cnt]);
1895 qla_uprintf(&uiter, "\n[<==END] ISP Debug Dump");
1899 /****************************************************************************/
1900 /* Driver Debug Functions. */
1901 /****************************************************************************/
1904 qla2x00_dump_regs(scsi_qla_host_t *ha)
1906 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1908 printk("Mailbox registers:\n");
1909 printk("scsi(%ld): mbox 0 0x%04x \n",
1910 ha->host_no, RD_MAILBOX_REG(ha, reg, 0));
1911 printk("scsi(%ld): mbox 1 0x%04x \n",
1912 ha->host_no, RD_MAILBOX_REG(ha, reg, 1));
1913 printk("scsi(%ld): mbox 2 0x%04x \n",
1914 ha->host_no, RD_MAILBOX_REG(ha, reg, 2));
1915 printk("scsi(%ld): mbox 3 0x%04x \n",
1916 ha->host_no, RD_MAILBOX_REG(ha, reg, 3));
1917 printk("scsi(%ld): mbox 4 0x%04x \n",
1918 ha->host_no, RD_MAILBOX_REG(ha, reg, 4));
1919 printk("scsi(%ld): mbox 5 0x%04x \n",
1920 ha->host_no, RD_MAILBOX_REG(ha, reg, 5));
1925 qla2x00_dump_buffer(uint8_t * b, uint32_t size)
1930 printk(" 0 1 2 3 4 5 6 7 8 9 "
1931 "Ah Bh Ch Dh Eh Fh\n");
1932 printk("----------------------------------------"
1933 "----------------------\n");
1935 for (cnt = 0; cnt < size;) {
1937 printk("%02x",(uint32_t) c);
1948 /**************************************************************************
1949 * qla2x00_print_scsi_cmd
1950 * Dumps out info about the scsi cmd and srb.
1952 * cmd : struct scsi_cmnd
1953 **************************************************************************/
1955 qla2x00_print_scsi_cmd(struct scsi_cmnd * cmd)
1958 struct scsi_qla_host *ha;
1961 ha = (struct scsi_qla_host *)cmd->device->host->hostdata;
1963 sp = (srb_t *) cmd->SCp.ptr;
1964 printk("SCSI Command @=0x%p, Handle=0x%p\n", cmd, cmd->host_scribble);
1965 printk(" chan=0x%02x, target=0x%02x, lun=0x%02x, cmd_len=0x%02x\n",
1966 cmd->device->channel, cmd->device->id, cmd->device->lun,
1969 for (i = 0; i < cmd->cmd_len; i++) {
1970 printk("0x%02x ", cmd->cmnd[i]);
1972 printk("\n seg_cnt=%d, allowed=%d, retries=%d\n",
1973 cmd->use_sg, cmd->allowed, cmd->retries);
1974 printk(" request buffer=0x%p, request buffer len=0x%x\n",
1975 cmd->request_buffer, cmd->request_bufflen);
1976 printk(" tag=%d, transfersize=0x%x\n",
1977 cmd->tag, cmd->transfersize);
1978 printk(" serial_number=%lx, SP=%p\n", cmd->serial_number, sp);
1979 printk(" data direction=%d\n", cmd->sc_data_direction);
1984 printk(" sp flags=0x%x\n", sp->flags);
1988 qla2x00_dump_pkt(void *pkt)
1991 uint8_t *data = (uint8_t *) pkt;
1993 for (i = 0; i < 64; i++) {
1995 printk("\n%02x: ", i);
1997 printk("%02x ", data[i]);
2002 #if defined(QL_DEBUG_ROUTINES)
2004 * qla2x00_formatted_dump_buffer
2005 * Prints string plus buffer.
2008 * string = Null terminated string (no newline at end).
2009 * buffer = buffer address.
2010 * wd_size = word size 8, 16, 32 or 64 bits
2011 * count = number of words.
2014 qla2x00_formatted_dump_buffer(char *string, uint8_t * buffer,
2015 uint8_t wd_size, uint32_t count)
2021 if (strcmp(string, "") != 0)
2022 printk("%s\n",string);
2026 printk(" 0 1 2 3 4 5 6 7 "
2027 "8 9 Ah Bh Ch Dh Eh Fh\n");
2028 printk("-----------------------------------------"
2029 "-------------------------------------\n");
2031 for (cnt = 1; cnt <= count; cnt++, buffer++) {
2032 printk("%02x",*buffer);
2042 printk(" 0 2 4 6 8 Ah "
2044 printk("-----------------------------------------"
2047 buf16 = (uint16_t *) buffer;
2048 for (cnt = 1; cnt <= count; cnt++, buf16++) {
2049 printk("%4x",*buf16);
2053 else if (*buf16 < 10)
2062 printk(" 0 4 8 Ch\n");
2063 printk("------------------------------------------\n");
2065 buf32 = (uint32_t *) buffer;
2066 for (cnt = 1; cnt <= count; cnt++, buf32++) {
2067 printk("%8x", *buf32);
2071 else if (*buf32 < 10)