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 dump_size, data_ram_cnt;
33 risc_address = data_ram_cnt = 0;
38 spin_lock_irqsave(&ha->hardware_lock, flags);
40 if (ha->fw_dump != NULL) {
41 qla_printk(KERN_WARNING, ha,
42 "Firmware has been previously dumped (%p) -- ignoring "
43 "request...\n", ha->fw_dump);
44 goto qla2300_fw_dump_failed;
47 /* Allocate (large) dump buffer. */
48 dump_size = sizeof(struct qla2300_fw_dump);
49 dump_size += (ha->fw_memory_size - 0x11000) * sizeof(uint16_t);
50 ha->fw_dump_order = get_order(dump_size);
51 ha->fw_dump = (struct qla2300_fw_dump *) __get_free_pages(GFP_ATOMIC,
53 if (ha->fw_dump == NULL) {
54 qla_printk(KERN_WARNING, ha,
55 "Unable to allocated memory for firmware dump (%d/%d).\n",
56 ha->fw_dump_order, dump_size);
57 goto qla2300_fw_dump_failed;
62 fw->hccr = RD_REG_WORD(®->hccr);
65 WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC);
68 (RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0 &&
69 rval == QLA_SUCCESS; cnt--) {
73 rval = QLA_FUNCTION_TIMEOUT;
76 RD_REG_WORD(®->hccr); /* PCI Posting. */
80 if (rval == QLA_SUCCESS) {
81 dmp_reg = (uint16_t __iomem *)(reg + 0);
82 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++)
83 fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
85 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10);
86 for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2; cnt++)
87 fw->risc_host_reg[cnt] = RD_REG_WORD(dmp_reg++);
89 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x40);
90 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
91 fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
93 WRT_REG_WORD(®->ctrl_status, 0x40);
94 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
95 for (cnt = 0; cnt < sizeof(fw->resp_dma_reg) / 2; cnt++)
96 fw->resp_dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
98 WRT_REG_WORD(®->ctrl_status, 0x50);
99 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
100 for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++)
101 fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
103 WRT_REG_WORD(®->ctrl_status, 0x00);
104 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0);
105 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++)
106 fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
108 WRT_REG_WORD(®->pcr, 0x2000);
109 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
110 for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++)
111 fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
113 WRT_REG_WORD(®->pcr, 0x2200);
114 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
115 for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++)
116 fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
118 WRT_REG_WORD(®->pcr, 0x2400);
119 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
120 for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++)
121 fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
123 WRT_REG_WORD(®->pcr, 0x2600);
124 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
125 for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++)
126 fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
128 WRT_REG_WORD(®->pcr, 0x2800);
129 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
130 for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++)
131 fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
133 WRT_REG_WORD(®->pcr, 0x2A00);
134 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
135 for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++)
136 fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
138 WRT_REG_WORD(®->pcr, 0x2C00);
139 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
140 for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++)
141 fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
143 WRT_REG_WORD(®->pcr, 0x2E00);
144 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
145 for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++)
146 fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
148 WRT_REG_WORD(®->ctrl_status, 0x10);
149 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
150 for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++)
151 fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
153 WRT_REG_WORD(®->ctrl_status, 0x20);
154 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
155 for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++)
156 fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
158 WRT_REG_WORD(®->ctrl_status, 0x30);
159 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
160 for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++)
161 fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
164 WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET);
165 for (cnt = 0; cnt < 30000; cnt++) {
166 if ((RD_REG_WORD(®->ctrl_status) &
167 CSR_ISP_SOFT_RESET) == 0)
174 if (!IS_QLA2300(ha)) {
175 for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
176 rval == QLA_SUCCESS; cnt--) {
180 rval = QLA_FUNCTION_TIMEOUT;
184 if (rval == QLA_SUCCESS) {
186 risc_address = 0x800;
187 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
188 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
190 for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
191 cnt++, risc_address++) {
192 WRT_MAILBOX_REG(ha, reg, 1, (uint16_t)risc_address);
193 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
195 for (timer = 6000000; timer; timer--) {
196 /* Check for pending interrupts. */
197 stat = RD_REG_DWORD(®->u.isp2300.host_status);
198 if (stat & HSR_RISC_INT) {
201 if (stat == 0x1 || stat == 0x2) {
202 set_bit(MBX_INTERRUPT,
205 mb0 = RD_MAILBOX_REG(ha, reg, 0);
206 mb2 = RD_MAILBOX_REG(ha, reg, 2);
208 /* Release mailbox registers. */
209 WRT_REG_WORD(®->semaphore, 0);
210 WRT_REG_WORD(®->hccr,
212 RD_REG_WORD(®->hccr);
214 } else if (stat == 0x10 || stat == 0x11) {
215 set_bit(MBX_INTERRUPT,
218 mb0 = RD_MAILBOX_REG(ha, reg, 0);
219 mb2 = RD_MAILBOX_REG(ha, reg, 2);
221 WRT_REG_WORD(®->hccr,
223 RD_REG_WORD(®->hccr);
227 /* clear this intr; it wasn't a mailbox intr */
228 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
229 RD_REG_WORD(®->hccr);
234 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
235 rval = mb0 & MBS_MASK;
236 fw->risc_ram[cnt] = mb2;
238 rval = QLA_FUNCTION_FAILED;
242 if (rval == QLA_SUCCESS) {
243 /* Get stack SRAM. */
244 risc_address = 0x10000;
245 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_EXTENDED);
246 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
248 for (cnt = 0; cnt < sizeof(fw->stack_ram) / 2 && rval == QLA_SUCCESS;
249 cnt++, risc_address++) {
250 WRT_MAILBOX_REG(ha, reg, 1, LSW(risc_address));
251 WRT_MAILBOX_REG(ha, reg, 8, MSW(risc_address));
252 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
254 for (timer = 6000000; timer; timer--) {
255 /* Check for pending interrupts. */
256 stat = RD_REG_DWORD(®->u.isp2300.host_status);
257 if (stat & HSR_RISC_INT) {
260 if (stat == 0x1 || stat == 0x2) {
261 set_bit(MBX_INTERRUPT,
264 mb0 = RD_MAILBOX_REG(ha, reg, 0);
265 mb2 = RD_MAILBOX_REG(ha, reg, 2);
267 /* Release mailbox registers. */
268 WRT_REG_WORD(®->semaphore, 0);
269 WRT_REG_WORD(®->hccr,
271 RD_REG_WORD(®->hccr);
273 } else if (stat == 0x10 || stat == 0x11) {
274 set_bit(MBX_INTERRUPT,
277 mb0 = RD_MAILBOX_REG(ha, reg, 0);
278 mb2 = RD_MAILBOX_REG(ha, reg, 2);
280 WRT_REG_WORD(®->hccr,
282 RD_REG_WORD(®->hccr);
286 /* clear this intr; it wasn't a mailbox intr */
287 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
288 RD_REG_WORD(®->hccr);
293 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
294 rval = mb0 & MBS_MASK;
295 fw->stack_ram[cnt] = mb2;
297 rval = QLA_FUNCTION_FAILED;
301 if (rval == QLA_SUCCESS) {
303 risc_address = 0x11000;
304 data_ram_cnt = ha->fw_memory_size - risc_address + 1;
305 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_EXTENDED);
306 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
308 for (cnt = 0; cnt < data_ram_cnt && rval == QLA_SUCCESS;
309 cnt++, risc_address++) {
310 WRT_MAILBOX_REG(ha, reg, 1, LSW(risc_address));
311 WRT_MAILBOX_REG(ha, reg, 8, MSW(risc_address));
312 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
314 for (timer = 6000000; timer; timer--) {
315 /* Check for pending interrupts. */
316 stat = RD_REG_DWORD(®->u.isp2300.host_status);
317 if (stat & HSR_RISC_INT) {
320 if (stat == 0x1 || stat == 0x2) {
321 set_bit(MBX_INTERRUPT,
324 mb0 = RD_MAILBOX_REG(ha, reg, 0);
325 mb2 = RD_MAILBOX_REG(ha, reg, 2);
327 /* Release mailbox registers. */
328 WRT_REG_WORD(®->semaphore, 0);
329 WRT_REG_WORD(®->hccr,
331 RD_REG_WORD(®->hccr);
333 } else if (stat == 0x10 || stat == 0x11) {
334 set_bit(MBX_INTERRUPT,
337 mb0 = RD_MAILBOX_REG(ha, reg, 0);
338 mb2 = RD_MAILBOX_REG(ha, reg, 2);
340 WRT_REG_WORD(®->hccr,
342 RD_REG_WORD(®->hccr);
346 /* clear this intr; it wasn't a mailbox intr */
347 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
348 RD_REG_WORD(®->hccr);
353 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
354 rval = mb0 & MBS_MASK;
355 fw->data_ram[cnt] = mb2;
357 rval = QLA_FUNCTION_FAILED;
362 if (rval != QLA_SUCCESS) {
363 qla_printk(KERN_WARNING, ha,
364 "Failed to dump firmware (%x)!!!\n", rval);
366 free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
369 qla_printk(KERN_INFO, ha,
370 "Firmware dump saved to temp buffer (%ld/%p).\n",
371 ha->host_no, ha->fw_dump);
374 qla2300_fw_dump_failed:
375 if (!hardware_locked)
376 spin_unlock_irqrestore(&ha->hardware_lock, flags);
380 * qla2300_ascii_fw_dump() - Converts a binary firmware dump to ASCII.
384 qla2300_ascii_fw_dump(scsi_qla_host_t *ha)
389 struct qla2300_fw_dump *fw;
390 uint32_t data_ram_cnt;
392 uiter = ha->fw_dump_buffer;
395 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
396 ha->isp_ops.fw_version_str(ha, fw_info));
398 qla_uprintf(&uiter, "\n[==>BEG]\n");
400 qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr);
402 qla_uprintf(&uiter, "PBIU Registers:");
403 for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
405 qla_uprintf(&uiter, "\n");
407 qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]);
410 qla_uprintf(&uiter, "\n\nReqQ-RspQ-Risc2Host Status registers:");
411 for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) {
413 qla_uprintf(&uiter, "\n");
415 qla_uprintf(&uiter, "%04x ", fw->risc_host_reg[cnt]);
418 qla_uprintf(&uiter, "\n\nMailbox Registers:");
419 for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
421 qla_uprintf(&uiter, "\n");
423 qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]);
426 qla_uprintf(&uiter, "\n\nAuto Request Response DMA Registers:");
427 for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) {
429 qla_uprintf(&uiter, "\n");
431 qla_uprintf(&uiter, "%04x ", fw->resp_dma_reg[cnt]);
434 qla_uprintf(&uiter, "\n\nDMA Registers:");
435 for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
437 qla_uprintf(&uiter, "\n");
439 qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]);
442 qla_uprintf(&uiter, "\n\nRISC Hardware Registers:");
443 for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
445 qla_uprintf(&uiter, "\n");
447 qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]);
450 qla_uprintf(&uiter, "\n\nRISC GP0 Registers:");
451 for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
453 qla_uprintf(&uiter, "\n");
455 qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]);
458 qla_uprintf(&uiter, "\n\nRISC GP1 Registers:");
459 for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
461 qla_uprintf(&uiter, "\n");
463 qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]);
466 qla_uprintf(&uiter, "\n\nRISC GP2 Registers:");
467 for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
469 qla_uprintf(&uiter, "\n");
471 qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]);
474 qla_uprintf(&uiter, "\n\nRISC GP3 Registers:");
475 for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
477 qla_uprintf(&uiter, "\n");
479 qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]);
482 qla_uprintf(&uiter, "\n\nRISC GP4 Registers:");
483 for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
485 qla_uprintf(&uiter, "\n");
487 qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]);
490 qla_uprintf(&uiter, "\n\nRISC GP5 Registers:");
491 for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
493 qla_uprintf(&uiter, "\n");
495 qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]);
498 qla_uprintf(&uiter, "\n\nRISC GP6 Registers:");
499 for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
501 qla_uprintf(&uiter, "\n");
503 qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]);
506 qla_uprintf(&uiter, "\n\nRISC GP7 Registers:");
507 for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
509 qla_uprintf(&uiter, "\n");
511 qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]);
514 qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:");
515 for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
517 qla_uprintf(&uiter, "\n");
519 qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]);
522 qla_uprintf(&uiter, "\n\nFPM B0 Registers:");
523 for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
525 qla_uprintf(&uiter, "\n");
527 qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]);
530 qla_uprintf(&uiter, "\n\nFPM B1 Registers:");
531 for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
533 qla_uprintf(&uiter, "\n");
535 qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]);
538 qla_uprintf(&uiter, "\n\nCode RAM Dump:");
539 for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
541 qla_uprintf(&uiter, "\n%04x: ", cnt + 0x0800);
543 qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]);
546 qla_uprintf(&uiter, "\n\nStack RAM Dump:");
547 for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) {
549 qla_uprintf(&uiter, "\n%05x: ", cnt + 0x10000);
551 qla_uprintf(&uiter, "%04x ", fw->stack_ram[cnt]);
554 qla_uprintf(&uiter, "\n\nData RAM Dump:");
555 data_ram_cnt = ha->fw_memory_size - 0x11000 + 1;
556 for (cnt = 0; cnt < data_ram_cnt; cnt++) {
558 qla_uprintf(&uiter, "\n%05x: ", cnt + 0x11000);
560 qla_uprintf(&uiter, "%04x ", fw->data_ram[cnt]);
563 qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump.");
567 * qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware.
569 * @hardware_locked: Called with the hardware_lock
572 qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
576 uint16_t risc_address;
578 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
579 uint16_t __iomem *dmp_reg;
581 struct qla2100_fw_dump *fw;
587 if (!hardware_locked)
588 spin_lock_irqsave(&ha->hardware_lock, flags);
590 if (ha->fw_dump != NULL) {
591 qla_printk(KERN_WARNING, ha,
592 "Firmware has been previously dumped (%p) -- ignoring "
593 "request...\n", ha->fw_dump);
594 goto qla2100_fw_dump_failed;
597 /* Allocate (large) dump buffer. */
598 ha->fw_dump_order = get_order(sizeof(struct qla2100_fw_dump));
599 ha->fw_dump = (struct qla2100_fw_dump *) __get_free_pages(GFP_ATOMIC,
601 if (ha->fw_dump == NULL) {
602 qla_printk(KERN_WARNING, ha,
603 "Unable to allocated memory for firmware dump (%d/%Zd).\n",
604 ha->fw_dump_order, sizeof(struct qla2100_fw_dump));
605 goto qla2100_fw_dump_failed;
610 fw->hccr = RD_REG_WORD(®->hccr);
613 WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC);
614 for (cnt = 30000; (RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0 &&
615 rval == QLA_SUCCESS; cnt--) {
619 rval = QLA_FUNCTION_TIMEOUT;
621 if (rval == QLA_SUCCESS) {
622 dmp_reg = (uint16_t __iomem *)(reg + 0);
623 for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++)
624 fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
626 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x10);
627 for (cnt = 0; cnt < ha->mbx_count; cnt++) {
629 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xe0);
631 fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
634 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x20);
635 for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++)
636 fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
638 WRT_REG_WORD(®->ctrl_status, 0x00);
639 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0xA0);
640 for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++)
641 fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
643 WRT_REG_WORD(®->pcr, 0x2000);
644 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
645 for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++)
646 fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
648 WRT_REG_WORD(®->pcr, 0x2100);
649 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
650 for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++)
651 fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
653 WRT_REG_WORD(®->pcr, 0x2200);
654 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
655 for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++)
656 fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
658 WRT_REG_WORD(®->pcr, 0x2300);
659 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
660 for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++)
661 fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
663 WRT_REG_WORD(®->pcr, 0x2400);
664 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
665 for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++)
666 fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
668 WRT_REG_WORD(®->pcr, 0x2500);
669 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
670 for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++)
671 fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
673 WRT_REG_WORD(®->pcr, 0x2600);
674 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
675 for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++)
676 fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
678 WRT_REG_WORD(®->pcr, 0x2700);
679 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
680 for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++)
681 fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
683 WRT_REG_WORD(®->ctrl_status, 0x10);
684 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
685 for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++)
686 fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
688 WRT_REG_WORD(®->ctrl_status, 0x20);
689 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
690 for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++)
691 fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
693 WRT_REG_WORD(®->ctrl_status, 0x30);
694 dmp_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
695 for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++)
696 fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
699 WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET);
702 for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
703 rval == QLA_SUCCESS; cnt--) {
707 rval = QLA_FUNCTION_TIMEOUT;
711 if (rval == QLA_SUCCESS && (IS_QLA2200(ha) || (IS_QLA2100(ha) &&
712 (RD_REG_WORD(®->mctr) & (BIT_1 | BIT_0)) != 0))) {
714 WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC);
716 (RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0 &&
717 rval == QLA_SUCCESS; cnt--) {
721 rval = QLA_FUNCTION_TIMEOUT;
723 if (rval == QLA_SUCCESS) {
724 /* Set memory configuration and timing. */
726 WRT_REG_WORD(®->mctr, 0xf1);
728 WRT_REG_WORD(®->mctr, 0xf2);
729 RD_REG_WORD(®->mctr); /* PCI Posting. */
732 WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC);
736 if (rval == QLA_SUCCESS) {
738 risc_address = 0x1000;
739 WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
740 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
742 for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
743 cnt++, risc_address++) {
744 WRT_MAILBOX_REG(ha, reg, 1, risc_address);
745 WRT_REG_WORD(®->hccr, HCCR_SET_HOST_INT);
747 for (timer = 6000000; timer != 0; timer--) {
748 /* Check for pending interrupts. */
749 if (RD_REG_WORD(®->istatus) & ISR_RISC_INT) {
750 if (RD_REG_WORD(®->semaphore) & BIT_0) {
751 set_bit(MBX_INTERRUPT,
754 mb0 = RD_MAILBOX_REG(ha, reg, 0);
755 mb2 = RD_MAILBOX_REG(ha, reg, 2);
757 WRT_REG_WORD(®->semaphore, 0);
758 WRT_REG_WORD(®->hccr,
760 RD_REG_WORD(®->hccr);
763 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
764 RD_REG_WORD(®->hccr);
769 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
770 rval = mb0 & MBS_MASK;
771 fw->risc_ram[cnt] = mb2;
773 rval = QLA_FUNCTION_FAILED;
777 if (rval != QLA_SUCCESS) {
778 qla_printk(KERN_WARNING, ha,
779 "Failed to dump firmware (%x)!!!\n", rval);
781 free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
784 qla_printk(KERN_INFO, ha,
785 "Firmware dump saved to temp buffer (%ld/%p).\n",
786 ha->host_no, ha->fw_dump);
789 qla2100_fw_dump_failed:
790 if (!hardware_locked)
791 spin_unlock_irqrestore(&ha->hardware_lock, flags);
795 * qla2100_ascii_fw_dump() - Converts a binary firmware dump to ASCII.
799 qla2100_ascii_fw_dump(scsi_qla_host_t *ha)
804 struct qla2100_fw_dump *fw;
806 uiter = ha->fw_dump_buffer;
809 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
810 ha->isp_ops.fw_version_str(ha, fw_info));
812 qla_uprintf(&uiter, "\n[==>BEG]\n");
814 qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr);
816 qla_uprintf(&uiter, "PBIU Registers:");
817 for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
819 qla_uprintf(&uiter, "\n");
821 qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]);
824 qla_uprintf(&uiter, "\n\nMailbox Registers:");
825 for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
827 qla_uprintf(&uiter, "\n");
829 qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]);
832 qla_uprintf(&uiter, "\n\nDMA Registers:");
833 for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
835 qla_uprintf(&uiter, "\n");
837 qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]);
840 qla_uprintf(&uiter, "\n\nRISC Hardware Registers:");
841 for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
843 qla_uprintf(&uiter, "\n");
845 qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]);
848 qla_uprintf(&uiter, "\n\nRISC GP0 Registers:");
849 for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
851 qla_uprintf(&uiter, "\n");
853 qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]);
856 qla_uprintf(&uiter, "\n\nRISC GP1 Registers:");
857 for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
859 qla_uprintf(&uiter, "\n");
861 qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]);
864 qla_uprintf(&uiter, "\n\nRISC GP2 Registers:");
865 for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
867 qla_uprintf(&uiter, "\n");
869 qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]);
872 qla_uprintf(&uiter, "\n\nRISC GP3 Registers:");
873 for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
875 qla_uprintf(&uiter, "\n");
877 qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]);
880 qla_uprintf(&uiter, "\n\nRISC GP4 Registers:");
881 for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
883 qla_uprintf(&uiter, "\n");
885 qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]);
888 qla_uprintf(&uiter, "\n\nRISC GP5 Registers:");
889 for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
891 qla_uprintf(&uiter, "\n");
893 qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]);
896 qla_uprintf(&uiter, "\n\nRISC GP6 Registers:");
897 for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
899 qla_uprintf(&uiter, "\n");
901 qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]);
904 qla_uprintf(&uiter, "\n\nRISC GP7 Registers:");
905 for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
907 qla_uprintf(&uiter, "\n");
909 qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]);
912 qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:");
913 for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
915 qla_uprintf(&uiter, "\n");
917 qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]);
920 qla_uprintf(&uiter, "\n\nFPM B0 Registers:");
921 for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
923 qla_uprintf(&uiter, "\n");
925 qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]);
928 qla_uprintf(&uiter, "\n\nFPM B1 Registers:");
929 for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
931 qla_uprintf(&uiter, "\n");
933 qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]);
936 qla_uprintf(&uiter, "\n\nRISC SRAM:");
937 for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
939 qla_uprintf(&uiter, "\n%04x: ", cnt + 0x1000);
941 qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]);
944 qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump.");
950 qla_uprintf(char **uiter, char *fmt, ...)
957 len = vsprintf(buf, fmt, args);
960 for (iter = 0; iter < len; iter++, *uiter += 1)
961 *uiter[0] = buf[iter];
968 qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
972 uint32_t risc_address;
976 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
977 uint32_t __iomem *dmp_reg;
979 uint16_t __iomem *mbx_reg;
981 struct qla24xx_fw_dump *fw;
982 uint32_t ext_mem_cnt;
984 risc_address = ext_mem_cnt = 0;
985 memset(mb, 0, sizeof(mb));
988 if (!hardware_locked)
989 spin_lock_irqsave(&ha->hardware_lock, flags);
991 if (!ha->fw_dump24) {
992 qla_printk(KERN_WARNING, ha,
993 "No buffer available for dump!!!\n");
994 goto qla24xx_fw_dump_failed;
998 qla_printk(KERN_WARNING, ha,
999 "Firmware has been previously dumped (%p) -- ignoring "
1000 "request...\n", ha->fw_dump24);
1001 goto qla24xx_fw_dump_failed;
1003 fw = (struct qla24xx_fw_dump *) ha->fw_dump24;
1006 fw->host_status = RD_REG_DWORD(®->host_status);
1009 if ((RD_REG_DWORD(®->hccr) & HCCRX_RISC_PAUSE) == 0) {
1010 WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET |
1011 HCCRX_CLR_HOST_INT);
1012 RD_REG_DWORD(®->hccr); /* PCI Posting. */
1013 WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_PAUSE);
1015 (RD_REG_DWORD(®->hccr) & HCCRX_RISC_PAUSE) == 0 &&
1016 rval == QLA_SUCCESS; cnt--) {
1020 rval = QLA_FUNCTION_TIMEOUT;
1024 if (rval == QLA_SUCCESS) {
1025 /* Host interface registers. */
1026 dmp_reg = (uint32_t __iomem *)(reg + 0);
1027 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++)
1028 fw->host_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1030 /* Disable interrupts. */
1031 WRT_REG_DWORD(®->ictrl, 0);
1032 RD_REG_DWORD(®->ictrl);
1034 /* Shadow registers. */
1035 WRT_REG_DWORD(®->iobase_addr, 0x0F70);
1036 RD_REG_DWORD(®->iobase_addr);
1037 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1038 WRT_REG_DWORD(dmp_reg, 0xB0000000);
1039 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1040 fw->shadow_reg[0] = RD_REG_DWORD(dmp_reg);
1042 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1043 WRT_REG_DWORD(dmp_reg, 0xB0100000);
1044 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1045 fw->shadow_reg[1] = RD_REG_DWORD(dmp_reg);
1047 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1048 WRT_REG_DWORD(dmp_reg, 0xB0200000);
1049 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1050 fw->shadow_reg[2] = RD_REG_DWORD(dmp_reg);
1052 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1053 WRT_REG_DWORD(dmp_reg, 0xB0300000);
1054 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1055 fw->shadow_reg[3] = RD_REG_DWORD(dmp_reg);
1057 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1058 WRT_REG_DWORD(dmp_reg, 0xB0400000);
1059 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1060 fw->shadow_reg[4] = RD_REG_DWORD(dmp_reg);
1062 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1063 WRT_REG_DWORD(dmp_reg, 0xB0500000);
1064 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1065 fw->shadow_reg[5] = RD_REG_DWORD(dmp_reg);
1067 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
1068 WRT_REG_DWORD(dmp_reg, 0xB0600000);
1069 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
1070 fw->shadow_reg[6] = RD_REG_DWORD(dmp_reg);
1072 /* Mailbox registers. */
1073 mbx_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80);
1074 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
1075 fw->mailbox_reg[cnt] = RD_REG_WORD(mbx_reg++);
1077 /* Transfer sequence registers. */
1078 iter_reg = fw->xseq_gp_reg;
1079 WRT_REG_DWORD(®->iobase_addr, 0xBF00);
1080 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1081 for (cnt = 0; cnt < 16; cnt++)
1082 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1084 WRT_REG_DWORD(®->iobase_addr, 0xBF10);
1085 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1086 for (cnt = 0; cnt < 16; cnt++)
1087 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1089 WRT_REG_DWORD(®->iobase_addr, 0xBF20);
1090 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1091 for (cnt = 0; cnt < 16; cnt++)
1092 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1094 WRT_REG_DWORD(®->iobase_addr, 0xBF30);
1095 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1096 for (cnt = 0; cnt < 16; cnt++)
1097 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1099 WRT_REG_DWORD(®->iobase_addr, 0xBF40);
1100 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1101 for (cnt = 0; cnt < 16; cnt++)
1102 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1104 WRT_REG_DWORD(®->iobase_addr, 0xBF50);
1105 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1106 for (cnt = 0; cnt < 16; cnt++)
1107 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1109 WRT_REG_DWORD(®->iobase_addr, 0xBF60);
1110 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1111 for (cnt = 0; cnt < 16; cnt++)
1112 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1114 WRT_REG_DWORD(®->iobase_addr, 0xBF70);
1115 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1116 for (cnt = 0; cnt < 16; cnt++)
1117 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1119 WRT_REG_DWORD(®->iobase_addr, 0xBFE0);
1120 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1121 for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++)
1122 fw->xseq_0_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1124 WRT_REG_DWORD(®->iobase_addr, 0xBFF0);
1125 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1126 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++)
1127 fw->xseq_1_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1129 /* Receive sequence registers. */
1130 iter_reg = fw->rseq_gp_reg;
1131 WRT_REG_DWORD(®->iobase_addr, 0xFF00);
1132 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1133 for (cnt = 0; cnt < 16; cnt++)
1134 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1136 WRT_REG_DWORD(®->iobase_addr, 0xFF10);
1137 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1138 for (cnt = 0; cnt < 16; cnt++)
1139 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1141 WRT_REG_DWORD(®->iobase_addr, 0xFF20);
1142 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1143 for (cnt = 0; cnt < 16; cnt++)
1144 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1146 WRT_REG_DWORD(®->iobase_addr, 0xFF30);
1147 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1148 for (cnt = 0; cnt < 16; cnt++)
1149 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1151 WRT_REG_DWORD(®->iobase_addr, 0xFF40);
1152 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1153 for (cnt = 0; cnt < 16; cnt++)
1154 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1156 WRT_REG_DWORD(®->iobase_addr, 0xFF50);
1157 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1158 for (cnt = 0; cnt < 16; cnt++)
1159 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1161 WRT_REG_DWORD(®->iobase_addr, 0xFF60);
1162 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1163 for (cnt = 0; cnt < 16; cnt++)
1164 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1166 WRT_REG_DWORD(®->iobase_addr, 0xFF70);
1167 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1168 for (cnt = 0; cnt < 16; cnt++)
1169 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1171 WRT_REG_DWORD(®->iobase_addr, 0xFFD0);
1172 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1173 for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++)
1174 fw->rseq_0_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1176 WRT_REG_DWORD(®->iobase_addr, 0xFFE0);
1177 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1178 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++)
1179 fw->rseq_1_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1181 WRT_REG_DWORD(®->iobase_addr, 0xFFF0);
1182 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1183 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++)
1184 fw->rseq_2_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1186 /* Command DMA registers. */
1187 WRT_REG_DWORD(®->iobase_addr, 0x7100);
1188 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1189 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++)
1190 fw->cmd_dma_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1193 iter_reg = fw->req0_dma_reg;
1194 WRT_REG_DWORD(®->iobase_addr, 0x7200);
1195 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1196 for (cnt = 0; cnt < 8; cnt++)
1197 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1199 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4);
1200 for (cnt = 0; cnt < 7; cnt++)
1201 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1203 iter_reg = fw->resp0_dma_reg;
1204 WRT_REG_DWORD(®->iobase_addr, 0x7300);
1205 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1206 for (cnt = 0; cnt < 8; cnt++)
1207 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1209 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4);
1210 for (cnt = 0; cnt < 7; cnt++)
1211 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1213 iter_reg = fw->req1_dma_reg;
1214 WRT_REG_DWORD(®->iobase_addr, 0x7400);
1215 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1216 for (cnt = 0; cnt < 8; cnt++)
1217 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1219 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4);
1220 for (cnt = 0; cnt < 7; cnt++)
1221 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1223 /* Transmit DMA registers. */
1224 iter_reg = fw->xmt0_dma_reg;
1225 WRT_REG_DWORD(®->iobase_addr, 0x7600);
1226 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1227 for (cnt = 0; cnt < 16; cnt++)
1228 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1230 WRT_REG_DWORD(®->iobase_addr, 0x7610);
1231 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1232 for (cnt = 0; cnt < 16; cnt++)
1233 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1235 iter_reg = fw->xmt1_dma_reg;
1236 WRT_REG_DWORD(®->iobase_addr, 0x7620);
1237 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1238 for (cnt = 0; cnt < 16; cnt++)
1239 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1241 WRT_REG_DWORD(®->iobase_addr, 0x7630);
1242 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1243 for (cnt = 0; cnt < 16; cnt++)
1244 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1246 iter_reg = fw->xmt2_dma_reg;
1247 WRT_REG_DWORD(®->iobase_addr, 0x7640);
1248 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1249 for (cnt = 0; cnt < 16; cnt++)
1250 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1252 WRT_REG_DWORD(®->iobase_addr, 0x7650);
1253 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1254 for (cnt = 0; cnt < 16; cnt++)
1255 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1257 iter_reg = fw->xmt3_dma_reg;
1258 WRT_REG_DWORD(®->iobase_addr, 0x7660);
1259 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1260 for (cnt = 0; cnt < 16; cnt++)
1261 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1263 WRT_REG_DWORD(®->iobase_addr, 0x7670);
1264 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1265 for (cnt = 0; cnt < 16; cnt++)
1266 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1268 iter_reg = fw->xmt4_dma_reg;
1269 WRT_REG_DWORD(®->iobase_addr, 0x7680);
1270 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1271 for (cnt = 0; cnt < 16; cnt++)
1272 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1274 WRT_REG_DWORD(®->iobase_addr, 0x7690);
1275 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1276 for (cnt = 0; cnt < 16; cnt++)
1277 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1279 WRT_REG_DWORD(®->iobase_addr, 0x76A0);
1280 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1281 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++)
1282 fw->xmt_data_dma_reg[cnt] = RD_REG_DWORD(dmp_reg++);
1284 /* Receive DMA registers. */
1285 iter_reg = fw->rcvt0_data_dma_reg;
1286 WRT_REG_DWORD(®->iobase_addr, 0x7700);
1287 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1288 for (cnt = 0; cnt < 16; cnt++)
1289 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1291 WRT_REG_DWORD(®->iobase_addr, 0x7710);
1292 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1293 for (cnt = 0; cnt < 16; cnt++)
1294 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1296 iter_reg = fw->rcvt1_data_dma_reg;
1297 WRT_REG_DWORD(®->iobase_addr, 0x7720);
1298 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1299 for (cnt = 0; cnt < 16; cnt++)
1300 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1302 WRT_REG_DWORD(®->iobase_addr, 0x7730);
1303 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1304 for (cnt = 0; cnt < 16; cnt++)
1305 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1307 /* RISC registers. */
1308 iter_reg = fw->risc_gp_reg;
1309 WRT_REG_DWORD(®->iobase_addr, 0x0F00);
1310 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1311 for (cnt = 0; cnt < 16; cnt++)
1312 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1314 WRT_REG_DWORD(®->iobase_addr, 0x0F10);
1315 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1316 for (cnt = 0; cnt < 16; cnt++)
1317 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1319 WRT_REG_DWORD(®->iobase_addr, 0x0F20);
1320 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1321 for (cnt = 0; cnt < 16; cnt++)
1322 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1324 WRT_REG_DWORD(®->iobase_addr, 0x0F30);
1325 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1326 for (cnt = 0; cnt < 16; cnt++)
1327 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1329 WRT_REG_DWORD(®->iobase_addr, 0x0F40);
1330 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1331 for (cnt = 0; cnt < 16; cnt++)
1332 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1334 WRT_REG_DWORD(®->iobase_addr, 0x0F50);
1335 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1336 for (cnt = 0; cnt < 16; cnt++)
1337 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1339 WRT_REG_DWORD(®->iobase_addr, 0x0F60);
1340 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1341 for (cnt = 0; cnt < 16; cnt++)
1342 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1344 WRT_REG_DWORD(®->iobase_addr, 0x0F70);
1345 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1346 for (cnt = 0; cnt < 16; cnt++)
1347 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1349 /* Local memory controller registers. */
1350 iter_reg = fw->lmc_reg;
1351 WRT_REG_DWORD(®->iobase_addr, 0x3000);
1352 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1353 for (cnt = 0; cnt < 16; cnt++)
1354 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1356 WRT_REG_DWORD(®->iobase_addr, 0x3010);
1357 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1358 for (cnt = 0; cnt < 16; cnt++)
1359 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1361 WRT_REG_DWORD(®->iobase_addr, 0x3020);
1362 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1363 for (cnt = 0; cnt < 16; cnt++)
1364 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1366 WRT_REG_DWORD(®->iobase_addr, 0x3030);
1367 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1368 for (cnt = 0; cnt < 16; cnt++)
1369 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1371 WRT_REG_DWORD(®->iobase_addr, 0x3040);
1372 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1373 for (cnt = 0; cnt < 16; cnt++)
1374 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1376 WRT_REG_DWORD(®->iobase_addr, 0x3050);
1377 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1378 for (cnt = 0; cnt < 16; cnt++)
1379 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1381 WRT_REG_DWORD(®->iobase_addr, 0x3060);
1382 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1383 for (cnt = 0; cnt < 16; cnt++)
1384 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1386 /* Fibre Protocol Module registers. */
1387 iter_reg = fw->fpm_hdw_reg;
1388 WRT_REG_DWORD(®->iobase_addr, 0x4000);
1389 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1390 for (cnt = 0; cnt < 16; cnt++)
1391 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1393 WRT_REG_DWORD(®->iobase_addr, 0x4010);
1394 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1395 for (cnt = 0; cnt < 16; cnt++)
1396 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1398 WRT_REG_DWORD(®->iobase_addr, 0x4020);
1399 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1400 for (cnt = 0; cnt < 16; cnt++)
1401 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1403 WRT_REG_DWORD(®->iobase_addr, 0x4030);
1404 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1405 for (cnt = 0; cnt < 16; cnt++)
1406 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1408 WRT_REG_DWORD(®->iobase_addr, 0x4040);
1409 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1410 for (cnt = 0; cnt < 16; cnt++)
1411 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1413 WRT_REG_DWORD(®->iobase_addr, 0x4050);
1414 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1415 for (cnt = 0; cnt < 16; cnt++)
1416 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1418 WRT_REG_DWORD(®->iobase_addr, 0x4060);
1419 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1420 for (cnt = 0; cnt < 16; cnt++)
1421 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1423 WRT_REG_DWORD(®->iobase_addr, 0x4070);
1424 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1425 for (cnt = 0; cnt < 16; cnt++)
1426 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1428 WRT_REG_DWORD(®->iobase_addr, 0x4080);
1429 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1430 for (cnt = 0; cnt < 16; cnt++)
1431 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1433 WRT_REG_DWORD(®->iobase_addr, 0x4090);
1434 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1435 for (cnt = 0; cnt < 16; cnt++)
1436 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1438 WRT_REG_DWORD(®->iobase_addr, 0x40A0);
1439 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1440 for (cnt = 0; cnt < 16; cnt++)
1441 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1443 WRT_REG_DWORD(®->iobase_addr, 0x40B0);
1444 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1445 for (cnt = 0; cnt < 16; cnt++)
1446 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1448 /* Frame Buffer registers. */
1449 iter_reg = fw->fb_hdw_reg;
1450 WRT_REG_DWORD(®->iobase_addr, 0x6000);
1451 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1452 for (cnt = 0; cnt < 16; cnt++)
1453 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1455 WRT_REG_DWORD(®->iobase_addr, 0x6010);
1456 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1457 for (cnt = 0; cnt < 16; cnt++)
1458 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1460 WRT_REG_DWORD(®->iobase_addr, 0x6020);
1461 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1462 for (cnt = 0; cnt < 16; cnt++)
1463 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1465 WRT_REG_DWORD(®->iobase_addr, 0x6030);
1466 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1467 for (cnt = 0; cnt < 16; cnt++)
1468 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1470 WRT_REG_DWORD(®->iobase_addr, 0x6040);
1471 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1472 for (cnt = 0; cnt < 16; cnt++)
1473 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1475 WRT_REG_DWORD(®->iobase_addr, 0x6100);
1476 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1477 for (cnt = 0; cnt < 16; cnt++)
1478 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1480 WRT_REG_DWORD(®->iobase_addr, 0x6130);
1481 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1482 for (cnt = 0; cnt < 16; cnt++)
1483 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1485 WRT_REG_DWORD(®->iobase_addr, 0x6150);
1486 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1487 for (cnt = 0; cnt < 16; cnt++)
1488 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1490 WRT_REG_DWORD(®->iobase_addr, 0x6170);
1491 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1492 for (cnt = 0; cnt < 16; cnt++)
1493 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1495 WRT_REG_DWORD(®->iobase_addr, 0x6190);
1496 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1497 for (cnt = 0; cnt < 16; cnt++)
1498 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1500 WRT_REG_DWORD(®->iobase_addr, 0x61B0);
1501 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0);
1502 for (cnt = 0; cnt < 16; cnt++)
1503 *iter_reg++ = RD_REG_DWORD(dmp_reg++);
1506 WRT_REG_DWORD(®->ctrl_status,
1507 CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
1508 for (cnt = 0; cnt < 30000; cnt++) {
1509 if ((RD_REG_DWORD(®->ctrl_status) &
1510 CSRX_DMA_ACTIVE) == 0)
1516 WRT_REG_DWORD(®->ctrl_status,
1517 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
1518 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
1521 /* Wait for firmware to complete NVRAM accesses. */
1522 mb[0] = (uint32_t) RD_REG_WORD(®->mailbox0);
1523 for (cnt = 10000 ; cnt && mb[0]; cnt--) {
1525 mb[0] = (uint32_t) RD_REG_WORD(®->mailbox0);
1529 /* Wait for soft-reset to complete. */
1530 for (cnt = 0; cnt < 30000; cnt++) {
1531 if ((RD_REG_DWORD(®->ctrl_status) &
1532 CSRX_ISP_SOFT_RESET) == 0)
1537 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_RESET);
1538 RD_REG_DWORD(®->hccr); /* PCI Posting. */
1541 for (cnt = 30000; RD_REG_WORD(®->mailbox0) != 0 &&
1542 rval == QLA_SUCCESS; cnt--) {
1546 rval = QLA_FUNCTION_TIMEOUT;
1550 if (rval == QLA_SUCCESS) {
1552 risc_address = 0x20000;
1553 WRT_REG_WORD(®->mailbox0, MBC_READ_RAM_EXTENDED);
1554 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1556 for (cnt = 0; cnt < sizeof(fw->code_ram) / 4 && rval == QLA_SUCCESS;
1557 cnt++, risc_address++) {
1558 WRT_REG_WORD(®->mailbox1, LSW(risc_address));
1559 WRT_REG_WORD(®->mailbox8, MSW(risc_address));
1560 RD_REG_WORD(®->mailbox8);
1561 WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT);
1563 for (timer = 6000000; timer; timer--) {
1564 /* Check for pending interrupts. */
1565 stat = RD_REG_DWORD(®->host_status);
1566 if (stat & HSRX_RISC_INT) {
1569 if (stat == 0x1 || stat == 0x2 ||
1570 stat == 0x10 || stat == 0x11) {
1571 set_bit(MBX_INTERRUPT,
1572 &ha->mbx_cmd_flags);
1574 mb[0] = RD_REG_WORD(®->mailbox0);
1575 mb[2] = RD_REG_WORD(®->mailbox2);
1576 mb[3] = RD_REG_WORD(®->mailbox3);
1578 WRT_REG_DWORD(®->hccr,
1579 HCCRX_CLR_RISC_INT);
1580 RD_REG_DWORD(®->hccr);
1584 /* Clear this intr; it wasn't a mailbox intr */
1585 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT);
1586 RD_REG_DWORD(®->hccr);
1591 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
1592 rval = mb[0] & MBS_MASK;
1593 fw->code_ram[cnt] = (mb[3] << 16) | mb[2];
1595 rval = QLA_FUNCTION_FAILED;
1599 if (rval == QLA_SUCCESS) {
1600 /* External Memory. */
1601 risc_address = 0x100000;
1602 ext_mem_cnt = ha->fw_memory_size - 0x100000 + 1;
1603 WRT_REG_WORD(®->mailbox0, MBC_READ_RAM_EXTENDED);
1604 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1606 for (cnt = 0; cnt < ext_mem_cnt && rval == QLA_SUCCESS;
1607 cnt++, risc_address++) {
1608 WRT_REG_WORD(®->mailbox1, LSW(risc_address));
1609 WRT_REG_WORD(®->mailbox8, MSW(risc_address));
1610 RD_REG_WORD(®->mailbox8);
1611 WRT_REG_DWORD(®->hccr, HCCRX_SET_HOST_INT);
1613 for (timer = 6000000; timer; timer--) {
1614 /* Check for pending interrupts. */
1615 stat = RD_REG_DWORD(®->host_status);
1616 if (stat & HSRX_RISC_INT) {
1619 if (stat == 0x1 || stat == 0x2 ||
1620 stat == 0x10 || stat == 0x11) {
1621 set_bit(MBX_INTERRUPT,
1622 &ha->mbx_cmd_flags);
1624 mb[0] = RD_REG_WORD(®->mailbox0);
1625 mb[2] = RD_REG_WORD(®->mailbox2);
1626 mb[3] = RD_REG_WORD(®->mailbox3);
1628 WRT_REG_DWORD(®->hccr,
1629 HCCRX_CLR_RISC_INT);
1630 RD_REG_DWORD(®->hccr);
1634 /* Clear this intr; it wasn't a mailbox intr */
1635 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT);
1636 RD_REG_DWORD(®->hccr);
1641 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
1642 rval = mb[0] & MBS_MASK;
1643 fw->ext_mem[cnt] = (mb[3] << 16) | mb[2];
1645 rval = QLA_FUNCTION_FAILED;
1649 if (rval != QLA_SUCCESS) {
1650 qla_printk(KERN_WARNING, ha,
1651 "Failed to dump firmware (%x)!!!\n", rval);
1655 qla_printk(KERN_INFO, ha,
1656 "Firmware dump saved to temp buffer (%ld/%p).\n",
1657 ha->host_no, ha->fw_dump24);
1661 qla24xx_fw_dump_failed:
1662 if (!hardware_locked)
1663 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1667 qla24xx_ascii_fw_dump(scsi_qla_host_t *ha)
1671 struct qla24xx_fw_dump *fw;
1672 uint32_t ext_mem_cnt;
1674 uiter = ha->fw_dump_buffer;
1677 qla_uprintf(&uiter, "ISP FW Version %d.%02d.%02d Attributes %04x\n",
1678 ha->fw_major_version, ha->fw_minor_version,
1679 ha->fw_subminor_version, ha->fw_attributes);
1681 qla_uprintf(&uiter, "\nR2H Status Register\n%04x\n", fw->host_status);
1683 qla_uprintf(&uiter, "\nHost Interface Registers");
1684 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++) {
1686 qla_uprintf(&uiter, "\n");
1688 qla_uprintf(&uiter, "%08x ", fw->host_reg[cnt]);
1691 qla_uprintf(&uiter, "\n\nShadow Registers");
1692 for (cnt = 0; cnt < sizeof(fw->shadow_reg) / 4; cnt++) {
1694 qla_uprintf(&uiter, "\n");
1696 qla_uprintf(&uiter, "%08x ", fw->shadow_reg[cnt]);
1699 qla_uprintf(&uiter, "\n\nMailbox Registers");
1700 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) {
1702 qla_uprintf(&uiter, "\n");
1704 qla_uprintf(&uiter, "%08x ", fw->mailbox_reg[cnt]);
1707 qla_uprintf(&uiter, "\n\nXSEQ GP Registers");
1708 for (cnt = 0; cnt < sizeof(fw->xseq_gp_reg) / 4; cnt++) {
1710 qla_uprintf(&uiter, "\n");
1712 qla_uprintf(&uiter, "%08x ", fw->xseq_gp_reg[cnt]);
1715 qla_uprintf(&uiter, "\n\nXSEQ-0 Registers");
1716 for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++) {
1718 qla_uprintf(&uiter, "\n");
1720 qla_uprintf(&uiter, "%08x ", fw->xseq_0_reg[cnt]);
1723 qla_uprintf(&uiter, "\n\nXSEQ-1 Registers");
1724 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++) {
1726 qla_uprintf(&uiter, "\n");
1728 qla_uprintf(&uiter, "%08x ", fw->xseq_1_reg[cnt]);
1731 qla_uprintf(&uiter, "\n\nRSEQ GP Registers");
1732 for (cnt = 0; cnt < sizeof(fw->rseq_gp_reg) / 4; cnt++) {
1734 qla_uprintf(&uiter, "\n");
1736 qla_uprintf(&uiter, "%08x ", fw->rseq_gp_reg[cnt]);
1739 qla_uprintf(&uiter, "\n\nRSEQ-0 Registers");
1740 for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++) {
1742 qla_uprintf(&uiter, "\n");
1744 qla_uprintf(&uiter, "%08x ", fw->rseq_0_reg[cnt]);
1747 qla_uprintf(&uiter, "\n\nRSEQ-1 Registers");
1748 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++) {
1750 qla_uprintf(&uiter, "\n");
1752 qla_uprintf(&uiter, "%08x ", fw->rseq_1_reg[cnt]);
1755 qla_uprintf(&uiter, "\n\nRSEQ-2 Registers");
1756 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++) {
1758 qla_uprintf(&uiter, "\n");
1760 qla_uprintf(&uiter, "%08x ", fw->rseq_2_reg[cnt]);
1763 qla_uprintf(&uiter, "\n\nCommand DMA Registers");
1764 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++) {
1766 qla_uprintf(&uiter, "\n");
1768 qla_uprintf(&uiter, "%08x ", fw->cmd_dma_reg[cnt]);
1771 qla_uprintf(&uiter, "\n\nRequest0 Queue DMA Channel Registers");
1772 for (cnt = 0; cnt < sizeof(fw->req0_dma_reg) / 4; cnt++) {
1774 qla_uprintf(&uiter, "\n");
1776 qla_uprintf(&uiter, "%08x ", fw->req0_dma_reg[cnt]);
1779 qla_uprintf(&uiter, "\n\nResponse0 Queue DMA Channel Registers");
1780 for (cnt = 0; cnt < sizeof(fw->resp0_dma_reg) / 4; cnt++) {
1782 qla_uprintf(&uiter, "\n");
1784 qla_uprintf(&uiter, "%08x ", fw->resp0_dma_reg[cnt]);
1787 qla_uprintf(&uiter, "\n\nRequest1 Queue DMA Channel Registers");
1788 for (cnt = 0; cnt < sizeof(fw->req1_dma_reg) / 4; cnt++) {
1790 qla_uprintf(&uiter, "\n");
1792 qla_uprintf(&uiter, "%08x ", fw->req1_dma_reg[cnt]);
1795 qla_uprintf(&uiter, "\n\nXMT0 Data DMA Registers");
1796 for (cnt = 0; cnt < sizeof(fw->xmt0_dma_reg) / 4; cnt++) {
1798 qla_uprintf(&uiter, "\n");
1800 qla_uprintf(&uiter, "%08x ", fw->xmt0_dma_reg[cnt]);
1803 qla_uprintf(&uiter, "\n\nXMT1 Data DMA Registers");
1804 for (cnt = 0; cnt < sizeof(fw->xmt1_dma_reg) / 4; cnt++) {
1806 qla_uprintf(&uiter, "\n");
1808 qla_uprintf(&uiter, "%08x ", fw->xmt1_dma_reg[cnt]);
1811 qla_uprintf(&uiter, "\n\nXMT2 Data DMA Registers");
1812 for (cnt = 0; cnt < sizeof(fw->xmt2_dma_reg) / 4; cnt++) {
1814 qla_uprintf(&uiter, "\n");
1816 qla_uprintf(&uiter, "%08x ", fw->xmt2_dma_reg[cnt]);
1819 qla_uprintf(&uiter, "\n\nXMT3 Data DMA Registers");
1820 for (cnt = 0; cnt < sizeof(fw->xmt3_dma_reg) / 4; cnt++) {
1822 qla_uprintf(&uiter, "\n");
1824 qla_uprintf(&uiter, "%08x ", fw->xmt3_dma_reg[cnt]);
1827 qla_uprintf(&uiter, "\n\nXMT4 Data DMA Registers");
1828 for (cnt = 0; cnt < sizeof(fw->xmt4_dma_reg) / 4; cnt++) {
1830 qla_uprintf(&uiter, "\n");
1832 qla_uprintf(&uiter, "%08x ", fw->xmt4_dma_reg[cnt]);
1835 qla_uprintf(&uiter, "\n\nXMT Data DMA Common Registers");
1836 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++) {
1838 qla_uprintf(&uiter, "\n");
1840 qla_uprintf(&uiter, "%08x ", fw->xmt_data_dma_reg[cnt]);
1843 qla_uprintf(&uiter, "\n\nRCV Thread 0 Data DMA Registers");
1844 for (cnt = 0; cnt < sizeof(fw->rcvt0_data_dma_reg) / 4; cnt++) {
1846 qla_uprintf(&uiter, "\n");
1848 qla_uprintf(&uiter, "%08x ", fw->rcvt0_data_dma_reg[cnt]);
1851 qla_uprintf(&uiter, "\n\nRCV Thread 1 Data DMA Registers");
1852 for (cnt = 0; cnt < sizeof(fw->rcvt1_data_dma_reg) / 4; cnt++) {
1854 qla_uprintf(&uiter, "\n");
1856 qla_uprintf(&uiter, "%08x ", fw->rcvt1_data_dma_reg[cnt]);
1859 qla_uprintf(&uiter, "\n\nRISC GP Registers");
1860 for (cnt = 0; cnt < sizeof(fw->risc_gp_reg) / 4; cnt++) {
1862 qla_uprintf(&uiter, "\n");
1864 qla_uprintf(&uiter, "%08x ", fw->risc_gp_reg[cnt]);
1867 qla_uprintf(&uiter, "\n\nLMC Registers");
1868 for (cnt = 0; cnt < sizeof(fw->lmc_reg) / 4; cnt++) {
1870 qla_uprintf(&uiter, "\n");
1872 qla_uprintf(&uiter, "%08x ", fw->lmc_reg[cnt]);
1875 qla_uprintf(&uiter, "\n\nFPM Hardware Registers");
1876 for (cnt = 0; cnt < sizeof(fw->fpm_hdw_reg) / 4; cnt++) {
1878 qla_uprintf(&uiter, "\n");
1880 qla_uprintf(&uiter, "%08x ", fw->fpm_hdw_reg[cnt]);
1883 qla_uprintf(&uiter, "\n\nFB Hardware Registers");
1884 for (cnt = 0; cnt < sizeof(fw->fb_hdw_reg) / 4; cnt++) {
1886 qla_uprintf(&uiter, "\n");
1888 qla_uprintf(&uiter, "%08x ", fw->fb_hdw_reg[cnt]);
1891 qla_uprintf(&uiter, "\n\nCode RAM");
1892 for (cnt = 0; cnt < sizeof (fw->code_ram) / 4; cnt++) {
1894 qla_uprintf(&uiter, "\n%08x: ", cnt + 0x20000);
1896 qla_uprintf(&uiter, "%08x ", fw->code_ram[cnt]);
1899 qla_uprintf(&uiter, "\n\nExternal Memory");
1900 ext_mem_cnt = ha->fw_memory_size - 0x100000 + 1;
1901 for (cnt = 0; cnt < ext_mem_cnt; cnt++) {
1903 qla_uprintf(&uiter, "\n%08x: ", cnt + 0x100000);
1905 qla_uprintf(&uiter, "%08x ", fw->ext_mem[cnt]);
1908 qla_uprintf(&uiter, "\n[<==END] ISP Debug Dump");
1912 /****************************************************************************/
1913 /* Driver Debug Functions. */
1914 /****************************************************************************/
1917 qla2x00_dump_regs(scsi_qla_host_t *ha)
1919 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1921 printk("Mailbox registers:\n");
1922 printk("scsi(%ld): mbox 0 0x%04x \n",
1923 ha->host_no, RD_MAILBOX_REG(ha, reg, 0));
1924 printk("scsi(%ld): mbox 1 0x%04x \n",
1925 ha->host_no, RD_MAILBOX_REG(ha, reg, 1));
1926 printk("scsi(%ld): mbox 2 0x%04x \n",
1927 ha->host_no, RD_MAILBOX_REG(ha, reg, 2));
1928 printk("scsi(%ld): mbox 3 0x%04x \n",
1929 ha->host_no, RD_MAILBOX_REG(ha, reg, 3));
1930 printk("scsi(%ld): mbox 4 0x%04x \n",
1931 ha->host_no, RD_MAILBOX_REG(ha, reg, 4));
1932 printk("scsi(%ld): mbox 5 0x%04x \n",
1933 ha->host_no, RD_MAILBOX_REG(ha, reg, 5));
1938 qla2x00_dump_buffer(uint8_t * b, uint32_t size)
1943 printk(" 0 1 2 3 4 5 6 7 8 9 "
1944 "Ah Bh Ch Dh Eh Fh\n");
1945 printk("----------------------------------------"
1946 "----------------------\n");
1948 for (cnt = 0; cnt < size;) {
1950 printk("%02x",(uint32_t) c);
1961 /**************************************************************************
1962 * qla2x00_print_scsi_cmd
1963 * Dumps out info about the scsi cmd and srb.
1965 * cmd : struct scsi_cmnd
1966 **************************************************************************/
1968 qla2x00_print_scsi_cmd(struct scsi_cmnd * cmd)
1971 struct scsi_qla_host *ha;
1974 ha = (struct scsi_qla_host *)cmd->device->host->hostdata;
1976 sp = (srb_t *) cmd->SCp.ptr;
1977 printk("SCSI Command @=0x%p, Handle=0x%p\n", cmd, cmd->host_scribble);
1978 printk(" chan=0x%02x, target=0x%02x, lun=0x%02x, cmd_len=0x%02x\n",
1979 cmd->device->channel, cmd->device->id, cmd->device->lun,
1982 for (i = 0; i < cmd->cmd_len; i++) {
1983 printk("0x%02x ", cmd->cmnd[i]);
1985 printk("\n seg_cnt=%d, allowed=%d, retries=%d\n",
1986 cmd->use_sg, cmd->allowed, cmd->retries);
1987 printk(" request buffer=0x%p, request buffer len=0x%x\n",
1988 cmd->request_buffer, cmd->request_bufflen);
1989 printk(" tag=%d, transfersize=0x%x\n",
1990 cmd->tag, cmd->transfersize);
1991 printk(" serial_number=%lx, SP=%p\n", cmd->serial_number, sp);
1992 printk(" data direction=%d\n", cmd->sc_data_direction);
1997 printk(" sp flags=0x%x\n", sp->flags);
1998 printk(" state=%d\n", sp->state);
2002 qla2x00_dump_pkt(void *pkt)
2005 uint8_t *data = (uint8_t *) pkt;
2007 for (i = 0; i < 64; i++) {
2009 printk("\n%02x: ", i);
2011 printk("%02x ", data[i]);
2016 #if defined(QL_DEBUG_ROUTINES)
2018 * qla2x00_formatted_dump_buffer
2019 * Prints string plus buffer.
2022 * string = Null terminated string (no newline at end).
2023 * buffer = buffer address.
2024 * wd_size = word size 8, 16, 32 or 64 bits
2025 * count = number of words.
2028 qla2x00_formatted_dump_buffer(char *string, uint8_t * buffer,
2029 uint8_t wd_size, uint32_t count)
2035 if (strcmp(string, "") != 0)
2036 printk("%s\n",string);
2040 printk(" 0 1 2 3 4 5 6 7 "
2041 "8 9 Ah Bh Ch Dh Eh Fh\n");
2042 printk("-----------------------------------------"
2043 "-------------------------------------\n");
2045 for (cnt = 1; cnt <= count; cnt++, buffer++) {
2046 printk("%02x",*buffer);
2056 printk(" 0 2 4 6 8 Ah "
2058 printk("-----------------------------------------"
2061 buf16 = (uint16_t *) buffer;
2062 for (cnt = 1; cnt <= count; cnt++, buf16++) {
2063 printk("%4x",*buf16);
2067 else if (*buf16 < 10)
2076 printk(" 0 4 8 Ch\n");
2077 printk("------------------------------------------\n");
2079 buf32 = (uint32_t *) buffer;
2080 for (cnt = 1; cnt <= count; cnt++, buf32++) {
2081 printk("%8x", *buf32);
2085 else if (*buf32 < 10)