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>
10 #include <linux/vmalloc.h>
11 #include <asm/uaccess.h>
13 static uint16_t qla2x00_nvram_request(scsi_qla_host_t
*, uint32_t);
14 static void qla2x00_nv_deselect(scsi_qla_host_t
*);
15 static void qla2x00_nv_write(scsi_qla_host_t
*, uint16_t);
18 * NVRAM support routines
22 * qla2x00_lock_nvram_access() -
26 qla2x00_lock_nvram_access(scsi_qla_host_t
*ha
)
29 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
31 if (!IS_QLA2100(ha
) && !IS_QLA2200(ha
) && !IS_QLA2300(ha
)) {
32 data
= RD_REG_WORD(®
->nvram
);
33 while (data
& NVR_BUSY
) {
35 data
= RD_REG_WORD(®
->nvram
);
39 WRT_REG_WORD(®
->u
.isp2300
.host_semaphore
, 0x1);
40 RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
42 data
= RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
43 while ((data
& BIT_0
) == 0) {
46 WRT_REG_WORD(®
->u
.isp2300
.host_semaphore
, 0x1);
47 RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
49 data
= RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
55 * qla2x00_unlock_nvram_access() -
59 qla2x00_unlock_nvram_access(scsi_qla_host_t
*ha
)
61 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
63 if (!IS_QLA2100(ha
) && !IS_QLA2200(ha
) && !IS_QLA2300(ha
)) {
64 WRT_REG_WORD(®
->u
.isp2300
.host_semaphore
, 0);
65 RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
70 * qla2x00_get_nvram_word() - Calculates word position in NVRAM and calls the
71 * request routine to get the word from NVRAM.
73 * @addr: Address in NVRAM to read
75 * Returns the word read from nvram @addr.
78 qla2x00_get_nvram_word(scsi_qla_host_t
*ha
, uint32_t addr
)
85 data
= qla2x00_nvram_request(ha
, nv_cmd
);
91 * qla2x00_write_nvram_word() - Write NVRAM data.
93 * @addr: Address in NVRAM to write
94 * @data: word to program
97 qla2x00_write_nvram_word(scsi_qla_host_t
*ha
, uint32_t addr
, uint16_t data
)
101 uint32_t nv_cmd
, wait_cnt
;
102 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
104 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
105 qla2x00_nv_write(ha
, 0);
106 qla2x00_nv_write(ha
, 0);
108 for (word
= 0; word
< 8; word
++)
109 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
111 qla2x00_nv_deselect(ha
);
114 nv_cmd
= (addr
<< 16) | NV_WRITE_OP
;
117 for (count
= 0; count
< 27; count
++) {
119 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
121 qla2x00_nv_write(ha
, 0);
126 qla2x00_nv_deselect(ha
);
128 /* Wait for NVRAM to become ready */
129 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
130 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
131 wait_cnt
= NVR_WAIT_CNT
;
134 DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n",
135 __func__
, ha
->host_no
));
139 word
= RD_REG_WORD(®
->nvram
);
140 } while ((word
& NVR_DATA_IN
) == 0);
142 qla2x00_nv_deselect(ha
);
145 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
146 for (count
= 0; count
< 10; count
++)
147 qla2x00_nv_write(ha
, 0);
149 qla2x00_nv_deselect(ha
);
153 qla2x00_write_nvram_word_tmo(scsi_qla_host_t
*ha
, uint32_t addr
, uint16_t data
,
159 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
163 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
164 qla2x00_nv_write(ha
, 0);
165 qla2x00_nv_write(ha
, 0);
167 for (word
= 0; word
< 8; word
++)
168 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
170 qla2x00_nv_deselect(ha
);
173 nv_cmd
= (addr
<< 16) | NV_WRITE_OP
;
176 for (count
= 0; count
< 27; count
++) {
178 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
180 qla2x00_nv_write(ha
, 0);
185 qla2x00_nv_deselect(ha
);
187 /* Wait for NVRAM to become ready */
188 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
189 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
192 word
= RD_REG_WORD(®
->nvram
);
194 ret
= QLA_FUNCTION_FAILED
;
197 } while ((word
& NVR_DATA_IN
) == 0);
199 qla2x00_nv_deselect(ha
);
202 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
203 for (count
= 0; count
< 10; count
++)
204 qla2x00_nv_write(ha
, 0);
206 qla2x00_nv_deselect(ha
);
212 * qla2x00_nvram_request() - Sends read command to NVRAM and gets data from
215 * @nv_cmd: NVRAM command
217 * Bit definitions for NVRAM command:
220 * Bit 25, 24 = opcode
221 * Bit 23-16 = address
222 * Bit 15-0 = write data
224 * Returns the word read from nvram @addr.
227 qla2x00_nvram_request(scsi_qla_host_t
*ha
, uint32_t nv_cmd
)
230 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
234 /* Send command to NVRAM. */
236 for (cnt
= 0; cnt
< 11; cnt
++) {
238 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
240 qla2x00_nv_write(ha
, 0);
244 /* Read data from NVRAM. */
245 for (cnt
= 0; cnt
< 16; cnt
++) {
246 WRT_REG_WORD(®
->nvram
, NVR_SELECT
| NVR_CLOCK
);
247 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
250 reg_data
= RD_REG_WORD(®
->nvram
);
251 if (reg_data
& NVR_DATA_IN
)
253 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
254 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
259 WRT_REG_WORD(®
->nvram
, NVR_DESELECT
);
260 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
267 * qla2x00_nv_write() - Clean NVRAM operations.
271 qla2x00_nv_deselect(scsi_qla_host_t
*ha
)
273 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
275 WRT_REG_WORD(®
->nvram
, NVR_DESELECT
);
276 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
281 * qla2x00_nv_write() - Prepare for NVRAM read/write operation.
283 * @data: Serial interface selector
286 qla2x00_nv_write(scsi_qla_host_t
*ha
, uint16_t data
)
288 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
290 WRT_REG_WORD(®
->nvram
, data
| NVR_SELECT
| NVR_WRT_ENABLE
);
291 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
293 WRT_REG_WORD(®
->nvram
, data
| NVR_SELECT
| NVR_CLOCK
|
295 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
297 WRT_REG_WORD(®
->nvram
, data
| NVR_SELECT
| NVR_WRT_ENABLE
);
298 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
303 * qla2x00_clear_nvram_protection() -
307 qla2x00_clear_nvram_protection(scsi_qla_host_t
*ha
)
310 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
311 uint32_t word
, wait_cnt
;
312 uint16_t wprot
, wprot_old
;
314 /* Clear NVRAM write protection. */
315 ret
= QLA_FUNCTION_FAILED
;
317 wprot_old
= cpu_to_le16(qla2x00_get_nvram_word(ha
, ha
->nvram_base
));
318 stat
= qla2x00_write_nvram_word_tmo(ha
, ha
->nvram_base
,
319 __constant_cpu_to_le16(0x1234), 100000);
320 wprot
= cpu_to_le16(qla2x00_get_nvram_word(ha
, ha
->nvram_base
));
321 if (stat
!= QLA_SUCCESS
|| wprot
!= 0x1234) {
323 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
324 qla2x00_nv_write(ha
, 0);
325 qla2x00_nv_write(ha
, 0);
326 for (word
= 0; word
< 8; word
++)
327 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
329 qla2x00_nv_deselect(ha
);
331 /* Enable protection register. */
332 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
333 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
334 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
335 for (word
= 0; word
< 8; word
++)
336 qla2x00_nv_write(ha
, NVR_DATA_OUT
| NVR_PR_ENABLE
);
338 qla2x00_nv_deselect(ha
);
340 /* Clear protection register (ffff is cleared). */
341 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
342 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
343 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
344 for (word
= 0; word
< 8; word
++)
345 qla2x00_nv_write(ha
, NVR_DATA_OUT
| NVR_PR_ENABLE
);
347 qla2x00_nv_deselect(ha
);
349 /* Wait for NVRAM to become ready. */
350 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
351 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
352 wait_cnt
= NVR_WAIT_CNT
;
355 DEBUG9_10(printk("%s(%ld): NVRAM didn't go "
356 "ready...\n", __func__
,
361 word
= RD_REG_WORD(®
->nvram
);
362 } while ((word
& NVR_DATA_IN
) == 0);
367 qla2x00_write_nvram_word(ha
, ha
->nvram_base
, wprot_old
);
373 qla2x00_set_nvram_protection(scsi_qla_host_t
*ha
, int stat
)
375 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
376 uint32_t word
, wait_cnt
;
378 if (stat
!= QLA_SUCCESS
)
381 /* Set NVRAM write protection. */
383 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
384 qla2x00_nv_write(ha
, 0);
385 qla2x00_nv_write(ha
, 0);
386 for (word
= 0; word
< 8; word
++)
387 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
389 qla2x00_nv_deselect(ha
);
391 /* Enable protection register. */
392 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
393 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
394 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
395 for (word
= 0; word
< 8; word
++)
396 qla2x00_nv_write(ha
, NVR_DATA_OUT
| NVR_PR_ENABLE
);
398 qla2x00_nv_deselect(ha
);
400 /* Enable protection register. */
401 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
402 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
403 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
404 for (word
= 0; word
< 8; word
++)
405 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
407 qla2x00_nv_deselect(ha
);
409 /* Wait for NVRAM to become ready. */
410 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
411 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
412 wait_cnt
= NVR_WAIT_CNT
;
415 DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n",
416 __func__
, ha
->host_no
));
420 word
= RD_REG_WORD(®
->nvram
);
421 } while ((word
& NVR_DATA_IN
) == 0);
425 /*****************************************************************************/
426 /* Flash Manipulation Routines */
427 /*****************************************************************************/
429 #define OPTROM_BURST_SIZE 0x1000
430 #define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4)
432 static inline uint32_t
433 flash_conf_to_access_addr(uint32_t faddr
)
435 return FARX_ACCESS_FLASH_CONF
| faddr
;
438 static inline uint32_t
439 flash_data_to_access_addr(uint32_t faddr
)
441 return FARX_ACCESS_FLASH_DATA
| faddr
;
444 static inline uint32_t
445 nvram_conf_to_access_addr(uint32_t naddr
)
447 return FARX_ACCESS_NVRAM_CONF
| naddr
;
450 static inline uint32_t
451 nvram_data_to_access_addr(uint32_t naddr
)
453 return FARX_ACCESS_NVRAM_DATA
| naddr
;
457 qla24xx_read_flash_dword(scsi_qla_host_t
*ha
, uint32_t addr
)
461 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
463 WRT_REG_DWORD(®
->flash_addr
, addr
& ~FARX_DATA_FLAG
);
464 /* Wait for READ cycle to complete. */
467 (RD_REG_DWORD(®
->flash_addr
) & FARX_DATA_FLAG
) == 0 &&
468 rval
== QLA_SUCCESS
; cnt
--) {
472 rval
= QLA_FUNCTION_TIMEOUT
;
476 /* TODO: What happens if we time out? */
478 if (rval
== QLA_SUCCESS
)
479 data
= RD_REG_DWORD(®
->flash_data
);
485 qla24xx_read_flash_data(scsi_qla_host_t
*ha
, uint32_t *dwptr
, uint32_t faddr
,
490 /* Dword reads to flash. */
491 for (i
= 0; i
< dwords
; i
++, faddr
++)
492 dwptr
[i
] = cpu_to_le32(qla24xx_read_flash_dword(ha
,
493 flash_data_to_access_addr(faddr
)));
499 qla24xx_write_flash_dword(scsi_qla_host_t
*ha
, uint32_t addr
, uint32_t data
)
503 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
505 WRT_REG_DWORD(®
->flash_data
, data
);
506 RD_REG_DWORD(®
->flash_data
); /* PCI Posting. */
507 WRT_REG_DWORD(®
->flash_addr
, addr
| FARX_DATA_FLAG
);
508 /* Wait for Write cycle to complete. */
510 for (cnt
= 500000; (RD_REG_DWORD(®
->flash_addr
) & FARX_DATA_FLAG
) &&
511 rval
== QLA_SUCCESS
; cnt
--) {
515 rval
= QLA_FUNCTION_TIMEOUT
;
522 qla24xx_get_flash_manufacturer(scsi_qla_host_t
*ha
, uint8_t *man_id
,
527 ids
= qla24xx_read_flash_dword(ha
, flash_data_to_access_addr(0xd03ab));
529 *flash_id
= MSB(ids
);
531 /* Check if man_id and flash_id are valid. */
532 if (ids
!= 0xDEADDEAD && (*man_id
== 0 || *flash_id
== 0)) {
533 /* Read information using 0x9f opcode
534 * Device ID, Mfg ID would be read in the format:
535 * <Ext Dev Info><Device ID Part2><Device ID Part 1><Mfg ID>
536 * Example: ATMEL 0x00 01 45 1F
537 * Extract MFG and Dev ID from last two bytes.
539 ids
= qla24xx_read_flash_dword(ha
,
540 flash_data_to_access_addr(0xd009f));
542 *flash_id
= MSB(ids
);
547 qla24xx_write_flash_data(scsi_qla_host_t
*ha
, uint32_t *dwptr
, uint32_t faddr
,
551 uint32_t liter
, miter
;
552 uint32_t sec_mask
, rest_addr
, conf_addr
;
553 uint32_t fdata
, findex
, cnt
;
554 uint8_t man_id
, flash_id
;
555 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
556 dma_addr_t optrom_dma
;
562 /* Prepare burst-capable write on supported ISPs. */
563 if (IS_QLA25XX(ha
) && !(faddr
& 0xfff) &&
564 dwords
> OPTROM_BURST_DWORDS
) {
565 optrom
= dma_alloc_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
,
566 &optrom_dma
, GFP_KERNEL
);
568 qla_printk(KERN_DEBUG
, ha
,
569 "Unable to allocate memory for optrom burst write "
570 "(%x KB).\n", OPTROM_BURST_SIZE
/ 1024);
574 qla24xx_get_flash_manufacturer(ha
, &man_id
, &flash_id
);
575 DEBUG9(printk("%s(%ld): Flash man_id=%d flash_id=%d\n", __func__
,
576 ha
->host_no
, man_id
, flash_id
));
578 conf_addr
= flash_conf_to_access_addr(0x03d8);
580 case 0xbf: /* STT flash. */
581 if (flash_id
== 0x8e) {
588 if (flash_id
== 0x80)
589 conf_addr
= flash_conf_to_access_addr(0x0352);
591 case 0x13: /* ST M25P80. */
595 case 0x1f: // Atmel 26DF081A
598 conf_addr
= flash_conf_to_access_addr(0x0320);
601 /* Default to 64 kb sector size. */
607 /* Enable flash write. */
608 WRT_REG_DWORD(®
->ctrl_status
,
609 RD_REG_DWORD(®
->ctrl_status
) | CSRX_FLASH_ENABLE
);
610 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
612 /* Disable flash write-protection. */
613 qla24xx_write_flash_dword(ha
, flash_conf_to_access_addr(0x101), 0);
614 /* Some flash parts need an additional zero-write to clear bits.*/
615 qla24xx_write_flash_dword(ha
, flash_conf_to_access_addr(0x101), 0);
617 for (liter
= 0; liter
< dwords
; liter
++, faddr
++, dwptr
++) {
618 if (man_id
== 0x1f) {
620 fdata
= findex
& sec_mask
;
623 fdata
= (findex
& sec_mask
) << 2;
626 /* Are we at the beginning of a sector? */
627 if ((findex
& rest_addr
) == 0) {
628 /* Do sector unprotect at 4K boundry for Atmel part. */
630 qla24xx_write_flash_dword(ha
,
631 flash_conf_to_access_addr(0x0339),
632 (fdata
& 0xff00) | ((fdata
<< 16) &
633 0xff0000) | ((fdata
>> 16) & 0xff));
634 ret
= qla24xx_write_flash_dword(ha
, conf_addr
,
635 (fdata
& 0xff00) |((fdata
<< 16) &
636 0xff0000) | ((fdata
>> 16) & 0xff));
637 if (ret
!= QLA_SUCCESS
) {
638 DEBUG9(printk("%s(%ld) Unable to flash "
639 "sector: address=%x.\n", __func__
,
640 ha
->host_no
, faddr
));
645 /* Go with burst-write. */
646 if (optrom
&& (liter
+ OPTROM_BURST_DWORDS
) <= dwords
) {
647 /* Copy data to DMA'ble buffer. */
648 for (miter
= 0, s
= optrom
, d
= dwptr
;
649 miter
< OPTROM_BURST_DWORDS
; miter
++, s
++, d
++)
650 *s
= cpu_to_le32(*d
);
652 ret
= qla2x00_load_ram(ha
, optrom_dma
,
653 flash_data_to_access_addr(faddr
),
654 OPTROM_BURST_DWORDS
);
655 if (ret
!= QLA_SUCCESS
) {
656 qla_printk(KERN_WARNING
, ha
,
657 "Unable to burst-write optrom segment "
658 "(%x/%x/%llx).\n", ret
,
659 flash_data_to_access_addr(faddr
),
660 (unsigned long long)optrom_dma
);
661 qla_printk(KERN_WARNING
, ha
,
662 "Reverting to slow-write.\n");
664 dma_free_coherent(&ha
->pdev
->dev
,
665 OPTROM_BURST_SIZE
, optrom
, optrom_dma
);
668 liter
+= OPTROM_BURST_DWORDS
- 1;
669 faddr
+= OPTROM_BURST_DWORDS
- 1;
670 dwptr
+= OPTROM_BURST_DWORDS
- 1;
675 ret
= qla24xx_write_flash_dword(ha
,
676 flash_data_to_access_addr(faddr
), cpu_to_le32(*dwptr
));
677 if (ret
!= QLA_SUCCESS
) {
678 DEBUG9(printk("%s(%ld) Unable to program flash "
679 "address=%x data=%x.\n", __func__
,
680 ha
->host_no
, faddr
, *dwptr
));
684 /* Do sector protect at 4K boundry for Atmel part. */
685 if (man_id
== 0x1f &&
686 ((faddr
& rest_addr
) == rest_addr
))
687 qla24xx_write_flash_dword(ha
,
688 flash_conf_to_access_addr(0x0336),
689 (fdata
& 0xff00) | ((fdata
<< 16) &
690 0xff0000) | ((fdata
>> 16) & 0xff));
693 /* Enable flash write-protection and wait for completion. */
694 qla24xx_write_flash_dword(ha
, flash_conf_to_access_addr(0x101), 0x9c);
695 for (cnt
= 300; cnt
&&
696 qla24xx_read_flash_dword(ha
,
697 flash_conf_to_access_addr(0x005)) & BIT_0
;
702 /* Disable flash write. */
703 WRT_REG_DWORD(®
->ctrl_status
,
704 RD_REG_DWORD(®
->ctrl_status
) & ~CSRX_FLASH_ENABLE
);
705 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
708 dma_free_coherent(&ha
->pdev
->dev
,
709 OPTROM_BURST_SIZE
, optrom
, optrom_dma
);
715 qla2x00_read_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
721 /* Word reads to NVRAM via registers. */
722 wptr
= (uint16_t *)buf
;
723 qla2x00_lock_nvram_access(ha
);
724 for (i
= 0; i
< bytes
>> 1; i
++, naddr
++)
725 wptr
[i
] = cpu_to_le16(qla2x00_get_nvram_word(ha
,
727 qla2x00_unlock_nvram_access(ha
);
733 qla24xx_read_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
739 /* Dword reads to flash. */
740 dwptr
= (uint32_t *)buf
;
741 for (i
= 0; i
< bytes
>> 2; i
++, naddr
++)
742 dwptr
[i
] = cpu_to_le32(qla24xx_read_flash_dword(ha
,
743 nvram_data_to_access_addr(naddr
)));
749 qla2x00_write_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
759 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
760 qla2x00_lock_nvram_access(ha
);
762 /* Disable NVRAM write-protection. */
763 stat
= qla2x00_clear_nvram_protection(ha
);
765 wptr
= (uint16_t *)buf
;
766 for (i
= 0; i
< bytes
>> 1; i
++, naddr
++) {
767 qla2x00_write_nvram_word(ha
, naddr
,
772 /* Enable NVRAM write-protection. */
773 qla2x00_set_nvram_protection(ha
, stat
);
775 qla2x00_unlock_nvram_access(ha
);
776 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
782 qla24xx_write_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
788 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
793 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
794 /* Enable flash write. */
795 WRT_REG_DWORD(®
->ctrl_status
,
796 RD_REG_DWORD(®
->ctrl_status
) | CSRX_FLASH_ENABLE
);
797 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
799 /* Disable NVRAM write-protection. */
800 qla24xx_write_flash_dword(ha
, nvram_conf_to_access_addr(0x101),
802 qla24xx_write_flash_dword(ha
, nvram_conf_to_access_addr(0x101),
805 /* Dword writes to flash. */
806 dwptr
= (uint32_t *)buf
;
807 for (i
= 0; i
< bytes
>> 2; i
++, naddr
++, dwptr
++) {
808 ret
= qla24xx_write_flash_dword(ha
,
809 nvram_data_to_access_addr(naddr
),
810 cpu_to_le32(*dwptr
));
811 if (ret
!= QLA_SUCCESS
) {
812 DEBUG9(printk("%s(%ld) Unable to program "
813 "nvram address=%x data=%x.\n", __func__
,
814 ha
->host_no
, naddr
, *dwptr
));
819 /* Enable NVRAM write-protection. */
820 qla24xx_write_flash_dword(ha
, nvram_conf_to_access_addr(0x101),
823 /* Disable flash write. */
824 WRT_REG_DWORD(®
->ctrl_status
,
825 RD_REG_DWORD(®
->ctrl_status
) & ~CSRX_FLASH_ENABLE
);
826 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
827 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
833 qla25xx_read_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
839 /* Dword reads to flash. */
840 dwptr
= (uint32_t *)buf
;
841 for (i
= 0; i
< bytes
>> 2; i
++, naddr
++)
842 dwptr
[i
] = cpu_to_le32(qla24xx_read_flash_dword(ha
,
843 flash_data_to_access_addr(FA_VPD_NVRAM_ADDR
| naddr
)));
849 qla25xx_write_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
852 #define RMW_BUFFER_SIZE (64 * 1024)
855 dbuf
= vmalloc(RMW_BUFFER_SIZE
);
857 return QLA_MEMORY_ALLOC_FAILED
;
858 ha
->isp_ops
->read_optrom(ha
, dbuf
, FA_VPD_NVRAM_ADDR
<< 2,
860 memcpy(dbuf
+ (naddr
<< 2), buf
, bytes
);
861 ha
->isp_ops
->write_optrom(ha
, dbuf
, FA_VPD_NVRAM_ADDR
<< 2,
869 qla2x00_flip_colors(scsi_qla_host_t
*ha
, uint16_t *pflags
)
871 if (IS_QLA2322(ha
)) {
872 /* Flip all colors. */
873 if (ha
->beacon_color_state
== QLA_LED_ALL_ON
) {
875 ha
->beacon_color_state
= 0;
876 *pflags
= GPIO_LED_ALL_OFF
;
879 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
880 *pflags
= GPIO_LED_RGA_ON
;
883 /* Flip green led only. */
884 if (ha
->beacon_color_state
== QLA_LED_GRN_ON
) {
886 ha
->beacon_color_state
= 0;
887 *pflags
= GPIO_LED_GREEN_OFF_AMBER_OFF
;
890 ha
->beacon_color_state
= QLA_LED_GRN_ON
;
891 *pflags
= GPIO_LED_GREEN_ON_AMBER_OFF
;
896 #define PIO_REG(h, r) ((h)->pio_address + offsetof(struct device_reg_2xxx, r))
899 qla2x00_beacon_blink(struct scsi_qla_host
*ha
)
901 uint16_t gpio_enable
;
903 uint16_t led_color
= 0;
905 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
907 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
909 /* Save the Original GPIOE. */
910 if (ha
->pio_address
) {
911 gpio_enable
= RD_REG_WORD_PIO(PIO_REG(ha
, gpioe
));
912 gpio_data
= RD_REG_WORD_PIO(PIO_REG(ha
, gpiod
));
914 gpio_enable
= RD_REG_WORD(®
->gpioe
);
915 gpio_data
= RD_REG_WORD(®
->gpiod
);
918 /* Set the modified gpio_enable values */
919 gpio_enable
|= GPIO_LED_MASK
;
921 if (ha
->pio_address
) {
922 WRT_REG_WORD_PIO(PIO_REG(ha
, gpioe
), gpio_enable
);
924 WRT_REG_WORD(®
->gpioe
, gpio_enable
);
925 RD_REG_WORD(®
->gpioe
);
928 qla2x00_flip_colors(ha
, &led_color
);
930 /* Clear out any previously set LED color. */
931 gpio_data
&= ~GPIO_LED_MASK
;
933 /* Set the new input LED color to GPIOD. */
934 gpio_data
|= led_color
;
936 /* Set the modified gpio_data values */
937 if (ha
->pio_address
) {
938 WRT_REG_WORD_PIO(PIO_REG(ha
, gpiod
), gpio_data
);
940 WRT_REG_WORD(®
->gpiod
, gpio_data
);
941 RD_REG_WORD(®
->gpiod
);
944 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
948 qla2x00_beacon_on(struct scsi_qla_host
*ha
)
950 uint16_t gpio_enable
;
953 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
955 ha
->fw_options
[1] &= ~FO1_SET_EMPHASIS_SWING
;
956 ha
->fw_options
[1] |= FO1_DISABLE_GPIO6_7
;
958 if (qla2x00_set_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
) {
959 qla_printk(KERN_WARNING
, ha
,
960 "Unable to update fw options (beacon on).\n");
961 return QLA_FUNCTION_FAILED
;
965 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
966 if (ha
->pio_address
) {
967 gpio_enable
= RD_REG_WORD_PIO(PIO_REG(ha
, gpioe
));
968 gpio_data
= RD_REG_WORD_PIO(PIO_REG(ha
, gpiod
));
970 gpio_enable
= RD_REG_WORD(®
->gpioe
);
971 gpio_data
= RD_REG_WORD(®
->gpiod
);
973 gpio_enable
|= GPIO_LED_MASK
;
975 /* Set the modified gpio_enable values. */
976 if (ha
->pio_address
) {
977 WRT_REG_WORD_PIO(PIO_REG(ha
, gpioe
), gpio_enable
);
979 WRT_REG_WORD(®
->gpioe
, gpio_enable
);
980 RD_REG_WORD(®
->gpioe
);
983 /* Clear out previously set LED colour. */
984 gpio_data
&= ~GPIO_LED_MASK
;
985 if (ha
->pio_address
) {
986 WRT_REG_WORD_PIO(PIO_REG(ha
, gpiod
), gpio_data
);
988 WRT_REG_WORD(®
->gpiod
, gpio_data
);
989 RD_REG_WORD(®
->gpiod
);
991 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
994 * Let the per HBA timer kick off the blinking process based on
995 * the following flags. No need to do anything else now.
997 ha
->beacon_blink_led
= 1;
998 ha
->beacon_color_state
= 0;
1004 qla2x00_beacon_off(struct scsi_qla_host
*ha
)
1006 int rval
= QLA_SUCCESS
;
1008 ha
->beacon_blink_led
= 0;
1010 /* Set the on flag so when it gets flipped it will be off. */
1012 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
1014 ha
->beacon_color_state
= QLA_LED_GRN_ON
;
1016 ha
->isp_ops
->beacon_blink(ha
); /* This turns green LED off */
1018 ha
->fw_options
[1] &= ~FO1_SET_EMPHASIS_SWING
;
1019 ha
->fw_options
[1] &= ~FO1_DISABLE_GPIO6_7
;
1021 rval
= qla2x00_set_fw_options(ha
, ha
->fw_options
);
1022 if (rval
!= QLA_SUCCESS
)
1023 qla_printk(KERN_WARNING
, ha
,
1024 "Unable to update fw options (beacon off).\n");
1030 qla24xx_flip_colors(scsi_qla_host_t
*ha
, uint16_t *pflags
)
1032 /* Flip all colors. */
1033 if (ha
->beacon_color_state
== QLA_LED_ALL_ON
) {
1035 ha
->beacon_color_state
= 0;
1039 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
1040 *pflags
= GPDX_LED_YELLOW_ON
| GPDX_LED_AMBER_ON
;
1045 qla24xx_beacon_blink(struct scsi_qla_host
*ha
)
1047 uint16_t led_color
= 0;
1049 unsigned long flags
;
1050 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1052 /* Save the Original GPIOD. */
1053 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1054 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1056 /* Enable the gpio_data reg for update. */
1057 gpio_data
|= GPDX_LED_UPDATE_MASK
;
1059 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1060 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1062 /* Set the color bits. */
1063 qla24xx_flip_colors(ha
, &led_color
);
1065 /* Clear out any previously set LED color. */
1066 gpio_data
&= ~GPDX_LED_COLOR_MASK
;
1068 /* Set the new input LED color to GPIOD. */
1069 gpio_data
|= led_color
;
1071 /* Set the modified gpio_data values. */
1072 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1073 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1074 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1078 qla24xx_beacon_on(struct scsi_qla_host
*ha
)
1081 unsigned long flags
;
1082 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1084 if (ha
->beacon_blink_led
== 0) {
1085 /* Enable firmware for update */
1086 ha
->fw_options
[1] |= ADD_FO1_DISABLE_GPIO_LED_CTRL
;
1088 if (qla2x00_set_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
)
1089 return QLA_FUNCTION_FAILED
;
1091 if (qla2x00_get_fw_options(ha
, ha
->fw_options
) !=
1093 qla_printk(KERN_WARNING
, ha
,
1094 "Unable to update fw options (beacon on).\n");
1095 return QLA_FUNCTION_FAILED
;
1098 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1099 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1101 /* Enable the gpio_data reg for update. */
1102 gpio_data
|= GPDX_LED_UPDATE_MASK
;
1103 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1104 RD_REG_DWORD(®
->gpiod
);
1106 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1109 /* So all colors blink together. */
1110 ha
->beacon_color_state
= 0;
1112 /* Let the per HBA timer kick off the blinking process. */
1113 ha
->beacon_blink_led
= 1;
1119 qla24xx_beacon_off(struct scsi_qla_host
*ha
)
1122 unsigned long flags
;
1123 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1125 ha
->beacon_blink_led
= 0;
1126 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
1128 ha
->isp_ops
->beacon_blink(ha
); /* Will flip to all off. */
1130 /* Give control back to firmware. */
1131 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1132 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1134 /* Disable the gpio_data reg for update. */
1135 gpio_data
&= ~GPDX_LED_UPDATE_MASK
;
1136 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1137 RD_REG_DWORD(®
->gpiod
);
1138 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1140 ha
->fw_options
[1] &= ~ADD_FO1_DISABLE_GPIO_LED_CTRL
;
1142 if (qla2x00_set_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
) {
1143 qla_printk(KERN_WARNING
, ha
,
1144 "Unable to update fw options (beacon off).\n");
1145 return QLA_FUNCTION_FAILED
;
1148 if (qla2x00_get_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
) {
1149 qla_printk(KERN_WARNING
, ha
,
1150 "Unable to get fw options (beacon off).\n");
1151 return QLA_FUNCTION_FAILED
;
1159 * Flash support routines
1163 * qla2x00_flash_enable() - Setup flash for reading and writing.
1167 qla2x00_flash_enable(scsi_qla_host_t
*ha
)
1170 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1172 data
= RD_REG_WORD(®
->ctrl_status
);
1173 data
|= CSR_FLASH_ENABLE
;
1174 WRT_REG_WORD(®
->ctrl_status
, data
);
1175 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1179 * qla2x00_flash_disable() - Disable flash and allow RISC to run.
1183 qla2x00_flash_disable(scsi_qla_host_t
*ha
)
1186 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1188 data
= RD_REG_WORD(®
->ctrl_status
);
1189 data
&= ~(CSR_FLASH_ENABLE
);
1190 WRT_REG_WORD(®
->ctrl_status
, data
);
1191 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1195 * qla2x00_read_flash_byte() - Reads a byte from flash
1197 * @addr: Address in flash to read
1199 * A word is read from the chip, but, only the lower byte is valid.
1201 * Returns the byte read from flash @addr.
1204 qla2x00_read_flash_byte(scsi_qla_host_t
*ha
, uint32_t addr
)
1207 uint16_t bank_select
;
1208 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1210 bank_select
= RD_REG_WORD(®
->ctrl_status
);
1212 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1213 /* Specify 64K address range: */
1214 /* clear out Module Select and Flash Address bits [19:16]. */
1215 bank_select
&= ~0xf8;
1216 bank_select
|= addr
>> 12 & 0xf0;
1217 bank_select
|= CSR_FLASH_64K_BANK
;
1218 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1219 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1221 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1222 data
= RD_REG_WORD(®
->flash_data
);
1224 return (uint8_t)data
;
1227 /* Setup bit 16 of flash address. */
1228 if ((addr
& BIT_16
) && ((bank_select
& CSR_FLASH_64K_BANK
) == 0)) {
1229 bank_select
|= CSR_FLASH_64K_BANK
;
1230 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1231 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1232 } else if (((addr
& BIT_16
) == 0) &&
1233 (bank_select
& CSR_FLASH_64K_BANK
)) {
1234 bank_select
&= ~(CSR_FLASH_64K_BANK
);
1235 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1236 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1239 /* Always perform IO mapped accesses to the FLASH registers. */
1240 if (ha
->pio_address
) {
1243 WRT_REG_WORD_PIO(PIO_REG(ha
, flash_address
), (uint16_t)addr
);
1245 data
= RD_REG_WORD_PIO(PIO_REG(ha
, flash_data
));
1248 data2
= RD_REG_WORD_PIO(PIO_REG(ha
, flash_data
));
1249 } while (data
!= data2
);
1251 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1252 data
= qla2x00_debounce_register(®
->flash_data
);
1255 return (uint8_t)data
;
1259 * qla2x00_write_flash_byte() - Write a byte to flash
1261 * @addr: Address in flash to write
1262 * @data: Data to write
1265 qla2x00_write_flash_byte(scsi_qla_host_t
*ha
, uint32_t addr
, uint8_t data
)
1267 uint16_t bank_select
;
1268 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1270 bank_select
= RD_REG_WORD(®
->ctrl_status
);
1271 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1272 /* Specify 64K address range: */
1273 /* clear out Module Select and Flash Address bits [19:16]. */
1274 bank_select
&= ~0xf8;
1275 bank_select
|= addr
>> 12 & 0xf0;
1276 bank_select
|= CSR_FLASH_64K_BANK
;
1277 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1278 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1280 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1281 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1282 WRT_REG_WORD(®
->flash_data
, (uint16_t)data
);
1283 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1288 /* Setup bit 16 of flash address. */
1289 if ((addr
& BIT_16
) && ((bank_select
& CSR_FLASH_64K_BANK
) == 0)) {
1290 bank_select
|= CSR_FLASH_64K_BANK
;
1291 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1292 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1293 } else if (((addr
& BIT_16
) == 0) &&
1294 (bank_select
& CSR_FLASH_64K_BANK
)) {
1295 bank_select
&= ~(CSR_FLASH_64K_BANK
);
1296 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1297 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1300 /* Always perform IO mapped accesses to the FLASH registers. */
1301 if (ha
->pio_address
) {
1302 WRT_REG_WORD_PIO(PIO_REG(ha
, flash_address
), (uint16_t)addr
);
1303 WRT_REG_WORD_PIO(PIO_REG(ha
, flash_data
), (uint16_t)data
);
1305 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1306 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1307 WRT_REG_WORD(®
->flash_data
, (uint16_t)data
);
1308 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1313 * qla2x00_poll_flash() - Polls flash for completion.
1315 * @addr: Address in flash to poll
1316 * @poll_data: Data to be polled
1317 * @man_id: Flash manufacturer ID
1318 * @flash_id: Flash ID
1320 * This function polls the device until bit 7 of what is read matches data
1321 * bit 7 or until data bit 5 becomes a 1. If that hapens, the flash ROM timed
1322 * out (a fatal error). The flash book recommeds reading bit 7 again after
1323 * reading bit 5 as a 1.
1325 * Returns 0 on success, else non-zero.
1328 qla2x00_poll_flash(scsi_qla_host_t
*ha
, uint32_t addr
, uint8_t poll_data
,
1329 uint8_t man_id
, uint8_t flash_id
)
1337 /* Wait for 30 seconds for command to finish. */
1339 for (cnt
= 3000000; cnt
; cnt
--) {
1340 flash_data
= qla2x00_read_flash_byte(ha
, addr
);
1341 if ((flash_data
& BIT_7
) == poll_data
) {
1346 if (man_id
!= 0x40 && man_id
!= 0xda) {
1347 if ((flash_data
& BIT_5
) && cnt
> 2)
1358 * qla2x00_program_flash_address() - Programs a flash address
1360 * @addr: Address in flash to program
1361 * @data: Data to be written in flash
1362 * @man_id: Flash manufacturer ID
1363 * @flash_id: Flash ID
1365 * Returns 0 on success, else non-zero.
1368 qla2x00_program_flash_address(scsi_qla_host_t
*ha
, uint32_t addr
, uint8_t data
,
1369 uint8_t man_id
, uint8_t flash_id
)
1371 /* Write Program Command Sequence. */
1372 if (IS_OEM_001(ha
)) {
1373 qla2x00_write_flash_byte(ha
, 0xaaa, 0xaa);
1374 qla2x00_write_flash_byte(ha
, 0x555, 0x55);
1375 qla2x00_write_flash_byte(ha
, 0xaaa, 0xa0);
1376 qla2x00_write_flash_byte(ha
, addr
, data
);
1378 if (man_id
== 0xda && flash_id
== 0xc1) {
1379 qla2x00_write_flash_byte(ha
, addr
, data
);
1383 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1384 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1385 qla2x00_write_flash_byte(ha
, 0x5555, 0xa0);
1386 qla2x00_write_flash_byte(ha
, addr
, data
);
1392 /* Wait for write to complete. */
1393 return qla2x00_poll_flash(ha
, addr
, data
, man_id
, flash_id
);
1397 * qla2x00_erase_flash() - Erase the flash.
1399 * @man_id: Flash manufacturer ID
1400 * @flash_id: Flash ID
1402 * Returns 0 on success, else non-zero.
1405 qla2x00_erase_flash(scsi_qla_host_t
*ha
, uint8_t man_id
, uint8_t flash_id
)
1407 /* Individual Sector Erase Command Sequence */
1408 if (IS_OEM_001(ha
)) {
1409 qla2x00_write_flash_byte(ha
, 0xaaa, 0xaa);
1410 qla2x00_write_flash_byte(ha
, 0x555, 0x55);
1411 qla2x00_write_flash_byte(ha
, 0xaaa, 0x80);
1412 qla2x00_write_flash_byte(ha
, 0xaaa, 0xaa);
1413 qla2x00_write_flash_byte(ha
, 0x555, 0x55);
1414 qla2x00_write_flash_byte(ha
, 0xaaa, 0x10);
1416 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1417 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1418 qla2x00_write_flash_byte(ha
, 0x5555, 0x80);
1419 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1420 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1421 qla2x00_write_flash_byte(ha
, 0x5555, 0x10);
1426 /* Wait for erase to complete. */
1427 return qla2x00_poll_flash(ha
, 0x00, 0x80, man_id
, flash_id
);
1431 * qla2x00_erase_flash_sector() - Erase a flash sector.
1433 * @addr: Flash sector to erase
1434 * @sec_mask: Sector address mask
1435 * @man_id: Flash manufacturer ID
1436 * @flash_id: Flash ID
1438 * Returns 0 on success, else non-zero.
1441 qla2x00_erase_flash_sector(scsi_qla_host_t
*ha
, uint32_t addr
,
1442 uint32_t sec_mask
, uint8_t man_id
, uint8_t flash_id
)
1444 /* Individual Sector Erase Command Sequence */
1445 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1446 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1447 qla2x00_write_flash_byte(ha
, 0x5555, 0x80);
1448 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1449 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1450 if (man_id
== 0x1f && flash_id
== 0x13)
1451 qla2x00_write_flash_byte(ha
, addr
& sec_mask
, 0x10);
1453 qla2x00_write_flash_byte(ha
, addr
& sec_mask
, 0x30);
1457 /* Wait for erase to complete. */
1458 return qla2x00_poll_flash(ha
, addr
, 0x80, man_id
, flash_id
);
1462 * qla2x00_get_flash_manufacturer() - Read manufacturer ID from flash chip.
1463 * @man_id: Flash manufacturer ID
1464 * @flash_id: Flash ID
1467 qla2x00_get_flash_manufacturer(scsi_qla_host_t
*ha
, uint8_t *man_id
,
1470 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1471 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1472 qla2x00_write_flash_byte(ha
, 0x5555, 0x90);
1473 *man_id
= qla2x00_read_flash_byte(ha
, 0x0000);
1474 *flash_id
= qla2x00_read_flash_byte(ha
, 0x0001);
1475 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1476 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1477 qla2x00_write_flash_byte(ha
, 0x5555, 0xf0);
1481 qla2x00_read_flash_data(scsi_qla_host_t
*ha
, uint8_t *tmp_buf
, uint32_t saddr
,
1484 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1485 uint32_t midpoint
, ilength
;
1488 midpoint
= length
/ 2;
1490 WRT_REG_WORD(®
->nvram
, 0);
1491 RD_REG_WORD(®
->nvram
);
1492 for (ilength
= 0; ilength
< length
; saddr
++, ilength
++, tmp_buf
++) {
1493 if (ilength
== midpoint
) {
1494 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
1495 RD_REG_WORD(®
->nvram
);
1497 data
= qla2x00_read_flash_byte(ha
, saddr
);
1506 qla2x00_suspend_hba(struct scsi_qla_host
*ha
)
1509 unsigned long flags
;
1510 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1513 scsi_block_requests(ha
->host
);
1514 ha
->isp_ops
->disable_intrs(ha
);
1515 set_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1518 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1519 WRT_REG_WORD(®
->hccr
, HCCR_PAUSE_RISC
);
1520 RD_REG_WORD(®
->hccr
);
1521 if (IS_QLA2100(ha
) || IS_QLA2200(ha
) || IS_QLA2300(ha
)) {
1522 for (cnt
= 0; cnt
< 30000; cnt
++) {
1523 if ((RD_REG_WORD(®
->hccr
) & HCCR_RISC_PAUSE
) != 0)
1530 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1534 qla2x00_resume_hba(struct scsi_qla_host
*ha
)
1537 clear_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1538 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
1539 qla2xxx_wake_dpc(ha
);
1540 qla2x00_wait_for_hba_online(ha
);
1541 scsi_unblock_requests(ha
->host
);
1545 qla2x00_read_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1546 uint32_t offset
, uint32_t length
)
1548 uint32_t addr
, midpoint
;
1550 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1553 qla2x00_suspend_hba(ha
);
1556 midpoint
= ha
->optrom_size
/ 2;
1558 qla2x00_flash_enable(ha
);
1559 WRT_REG_WORD(®
->nvram
, 0);
1560 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
1561 for (addr
= offset
, data
= buf
; addr
< length
; addr
++, data
++) {
1562 if (addr
== midpoint
) {
1563 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
1564 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
1567 *data
= qla2x00_read_flash_byte(ha
, addr
);
1569 qla2x00_flash_disable(ha
);
1572 qla2x00_resume_hba(ha
);
1578 qla2x00_write_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1579 uint32_t offset
, uint32_t length
)
1583 uint8_t man_id
, flash_id
, sec_number
, data
;
1585 uint32_t addr
, liter
, sec_mask
, rest_addr
;
1586 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1589 qla2x00_suspend_hba(ha
);
1594 /* Reset ISP chip. */
1595 WRT_REG_WORD(®
->ctrl_status
, CSR_ISP_SOFT_RESET
);
1596 pci_read_config_word(ha
->pdev
, PCI_COMMAND
, &wd
);
1598 /* Go with write. */
1599 qla2x00_flash_enable(ha
);
1600 do { /* Loop once to provide quick error exit */
1601 /* Structure of flash memory based on manufacturer */
1602 if (IS_OEM_001(ha
)) {
1603 /* OEM variant with special flash part. */
1604 man_id
= flash_id
= 0;
1609 qla2x00_get_flash_manufacturer(ha
, &man_id
, &flash_id
);
1611 case 0x20: /* ST flash. */
1612 if (flash_id
== 0xd2 || flash_id
== 0xe3) {
1614 * ST m29w008at part - 64kb sector size with
1615 * 32kb,8kb,8kb,16kb sectors at memory address
1623 * ST m29w010b part - 16kb sector size
1624 * Default to 16kb sectors
1629 case 0x40: /* Mostel flash. */
1630 /* Mostel v29c51001 part - 512 byte sector size. */
1634 case 0xbf: /* SST flash. */
1635 /* SST39sf10 part - 4kb sector size. */
1639 case 0xda: /* Winbond flash. */
1640 /* Winbond W29EE011 part - 256 byte sector size. */
1644 case 0xc2: /* Macronix flash. */
1645 /* 64k sector size. */
1646 if (flash_id
== 0x38 || flash_id
== 0x4f) {
1651 /* Fall through... */
1653 case 0x1f: /* Atmel flash. */
1654 /* 512k sector size. */
1655 if (flash_id
== 0x13) {
1656 rest_addr
= 0x7fffffff;
1657 sec_mask
= 0x80000000;
1660 /* Fall through... */
1662 case 0x01: /* AMD flash. */
1663 if (flash_id
== 0x38 || flash_id
== 0x40 ||
1665 /* Am29LV081 part - 64kb sector size. */
1666 /* Am29LV002BT part - 64kb sector size. */
1670 } else if (flash_id
== 0x3e) {
1672 * Am29LV008b part - 64kb sector size with
1673 * 32kb,8kb,8kb,16kb sector at memory address
1679 } else if (flash_id
== 0x20 || flash_id
== 0x6e) {
1681 * Am29LV010 part or AM29f010 - 16kb sector
1687 } else if (flash_id
== 0x6d) {
1688 /* Am29LV001 part - 8kb sector size. */
1694 /* Default to 16 kb sector size. */
1701 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1702 if (qla2x00_erase_flash(ha
, man_id
, flash_id
)) {
1703 rval
= QLA_FUNCTION_FAILED
;
1708 for (addr
= offset
, liter
= 0; liter
< length
; liter
++,
1711 /* Are we at the beginning of a sector? */
1712 if ((addr
& rest_addr
) == 0) {
1713 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1714 if (addr
>= 0x10000UL
) {
1715 if (((addr
>> 12) & 0xf0) &&
1717 flash_id
== 0x3e) ||
1719 flash_id
== 0xd2))) {
1721 if (sec_number
== 1) {
1742 } else if (addr
== ha
->optrom_size
/ 2) {
1743 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
1744 RD_REG_WORD(®
->nvram
);
1747 if (flash_id
== 0xda && man_id
== 0xc1) {
1748 qla2x00_write_flash_byte(ha
, 0x5555,
1750 qla2x00_write_flash_byte(ha
, 0x2aaa,
1752 qla2x00_write_flash_byte(ha
, 0x5555,
1754 } else if (!IS_QLA2322(ha
) && !IS_QLA6322(ha
)) {
1756 if (qla2x00_erase_flash_sector(ha
,
1757 addr
, sec_mask
, man_id
,
1759 rval
= QLA_FUNCTION_FAILED
;
1762 if (man_id
== 0x01 && flash_id
== 0x6d)
1767 if (man_id
== 0x01 && flash_id
== 0x6d) {
1768 if (sec_number
== 1 &&
1769 addr
== (rest_addr
- 1)) {
1772 } else if (sec_number
== 3 && (addr
& 0x7ffe)) {
1778 if (qla2x00_program_flash_address(ha
, addr
, data
,
1779 man_id
, flash_id
)) {
1780 rval
= QLA_FUNCTION_FAILED
;
1786 qla2x00_flash_disable(ha
);
1789 qla2x00_resume_hba(ha
);
1795 qla24xx_read_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1796 uint32_t offset
, uint32_t length
)
1799 scsi_block_requests(ha
->host
);
1800 set_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1803 qla24xx_read_flash_data(ha
, (uint32_t *)buf
, offset
>> 2, length
>> 2);
1806 clear_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1807 scsi_unblock_requests(ha
->host
);
1813 qla24xx_write_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1814 uint32_t offset
, uint32_t length
)
1819 scsi_block_requests(ha
->host
);
1820 set_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1822 /* Go with write. */
1823 rval
= qla24xx_write_flash_data(ha
, (uint32_t *)buf
, offset
>> 2,
1826 /* Resume HBA -- RISC reset needed. */
1827 clear_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1828 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
1829 qla2xxx_wake_dpc(ha
);
1830 qla2x00_wait_for_hba_online(ha
);
1831 scsi_unblock_requests(ha
->host
);
1837 qla25xx_read_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1838 uint32_t offset
, uint32_t length
)
1841 dma_addr_t optrom_dma
;
1844 uint32_t faddr
, left
, burst
;
1848 if (length
< OPTROM_BURST_SIZE
)
1851 optrom
= dma_alloc_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
,
1852 &optrom_dma
, GFP_KERNEL
);
1854 qla_printk(KERN_DEBUG
, ha
,
1855 "Unable to allocate memory for optrom burst read "
1856 "(%x KB).\n", OPTROM_BURST_SIZE
/ 1024);
1862 faddr
= offset
>> 2;
1864 burst
= OPTROM_BURST_DWORDS
;
1869 rval
= qla2x00_dump_ram(ha
, optrom_dma
,
1870 flash_data_to_access_addr(faddr
), burst
);
1872 qla_printk(KERN_WARNING
, ha
,
1873 "Unable to burst-read optrom segment "
1874 "(%x/%x/%llx).\n", rval
,
1875 flash_data_to_access_addr(faddr
),
1876 (unsigned long long)optrom_dma
);
1877 qla_printk(KERN_WARNING
, ha
,
1878 "Reverting to slow-read.\n");
1880 dma_free_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
,
1881 optrom
, optrom_dma
);
1885 memcpy(pbuf
, optrom
, burst
* 4);
1892 dma_free_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
, optrom
,
1898 return qla24xx_read_optrom_data(ha
, buf
, offset
, length
);
1902 * qla2x00_get_fcode_version() - Determine an FCODE image's version.
1904 * @pcids: Pointer to the FCODE PCI data structure
1906 * The process of retrieving the FCODE version information is at best
1907 * described as interesting.
1909 * Within the first 100h bytes of the image an ASCII string is present
1910 * which contains several pieces of information including the FCODE
1911 * version. Unfortunately it seems the only reliable way to retrieve
1912 * the version is by scanning for another sentinel within the string,
1913 * the FCODE build date:
1915 * ... 2.00.02 10/17/02 ...
1917 * Returns QLA_SUCCESS on successful retrieval of version.
1920 qla2x00_get_fcode_version(scsi_qla_host_t
*ha
, uint32_t pcids
)
1922 int ret
= QLA_FUNCTION_FAILED
;
1923 uint32_t istart
, iend
, iter
, vend
;
1924 uint8_t do_next
, rbyte
, *vbyte
;
1926 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
1928 /* Skip the PCI data structure. */
1930 ((qla2x00_read_flash_byte(ha
, pcids
+ 0x0B) << 8) |
1931 qla2x00_read_flash_byte(ha
, pcids
+ 0x0A));
1932 iend
= istart
+ 0x100;
1934 /* Scan for the sentinel date string...eeewww. */
1937 while ((iter
< iend
) && !do_next
) {
1939 if (qla2x00_read_flash_byte(ha
, iter
) == '/') {
1940 if (qla2x00_read_flash_byte(ha
, iter
+ 2) ==
1943 else if (qla2x00_read_flash_byte(ha
,
1951 /* Backtrack to previous ' ' (space). */
1953 while ((iter
> istart
) && !do_next
) {
1955 if (qla2x00_read_flash_byte(ha
, iter
) == ' ')
1962 * Mark end of version tag, and find previous ' ' (space) or
1963 * string length (recent FCODE images -- major hack ahead!!!).
1967 while ((iter
> istart
) && !do_next
) {
1969 rbyte
= qla2x00_read_flash_byte(ha
, iter
);
1970 if (rbyte
== ' ' || rbyte
== 0xd || rbyte
== 0x10)
1976 /* Mark beginning of version tag, and copy data. */
1978 if ((vend
- iter
) &&
1979 ((vend
- iter
) < sizeof(ha
->fcode_revision
))) {
1980 vbyte
= ha
->fcode_revision
;
1981 while (iter
<= vend
) {
1982 *vbyte
++ = qla2x00_read_flash_byte(ha
, iter
);
1989 if (ret
!= QLA_SUCCESS
)
1990 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
1994 qla2x00_get_flash_version(scsi_qla_host_t
*ha
, void *mbuf
)
1996 int ret
= QLA_SUCCESS
;
1997 uint8_t code_type
, last_image
;
1998 uint32_t pcihdr
, pcids
;
2002 if (!ha
->pio_address
|| !mbuf
)
2003 return QLA_FUNCTION_FAILED
;
2005 memset(ha
->bios_revision
, 0, sizeof(ha
->bios_revision
));
2006 memset(ha
->efi_revision
, 0, sizeof(ha
->efi_revision
));
2007 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
2008 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
2010 qla2x00_flash_enable(ha
);
2012 /* Begin with first PCI expansion ROM header. */
2016 /* Verify PCI expansion ROM header. */
2017 if (qla2x00_read_flash_byte(ha
, pcihdr
) != 0x55 ||
2018 qla2x00_read_flash_byte(ha
, pcihdr
+ 0x01) != 0xaa) {
2020 DEBUG2(printk("scsi(%ld): No matching ROM "
2021 "signature.\n", ha
->host_no
));
2022 ret
= QLA_FUNCTION_FAILED
;
2026 /* Locate PCI data structure. */
2028 ((qla2x00_read_flash_byte(ha
, pcihdr
+ 0x19) << 8) |
2029 qla2x00_read_flash_byte(ha
, pcihdr
+ 0x18));
2031 /* Validate signature of PCI data structure. */
2032 if (qla2x00_read_flash_byte(ha
, pcids
) != 'P' ||
2033 qla2x00_read_flash_byte(ha
, pcids
+ 0x1) != 'C' ||
2034 qla2x00_read_flash_byte(ha
, pcids
+ 0x2) != 'I' ||
2035 qla2x00_read_flash_byte(ha
, pcids
+ 0x3) != 'R') {
2036 /* Incorrect header. */
2037 DEBUG2(printk("%s(): PCI data struct not found "
2038 "pcir_adr=%x.\n", __func__
, pcids
));
2039 ret
= QLA_FUNCTION_FAILED
;
2044 code_type
= qla2x00_read_flash_byte(ha
, pcids
+ 0x14);
2045 switch (code_type
) {
2046 case ROM_CODE_TYPE_BIOS
:
2047 /* Intel x86, PC-AT compatible. */
2048 ha
->bios_revision
[0] =
2049 qla2x00_read_flash_byte(ha
, pcids
+ 0x12);
2050 ha
->bios_revision
[1] =
2051 qla2x00_read_flash_byte(ha
, pcids
+ 0x13);
2052 DEBUG3(printk("%s(): read BIOS %d.%d.\n", __func__
,
2053 ha
->bios_revision
[1], ha
->bios_revision
[0]));
2055 case ROM_CODE_TYPE_FCODE
:
2056 /* Open Firmware standard for PCI (FCode). */
2058 qla2x00_get_fcode_version(ha
, pcids
);
2060 case ROM_CODE_TYPE_EFI
:
2061 /* Extensible Firmware Interface (EFI). */
2062 ha
->efi_revision
[0] =
2063 qla2x00_read_flash_byte(ha
, pcids
+ 0x12);
2064 ha
->efi_revision
[1] =
2065 qla2x00_read_flash_byte(ha
, pcids
+ 0x13);
2066 DEBUG3(printk("%s(): read EFI %d.%d.\n", __func__
,
2067 ha
->efi_revision
[1], ha
->efi_revision
[0]));
2070 DEBUG2(printk("%s(): Unrecognized code type %x at "
2071 "pcids %x.\n", __func__
, code_type
, pcids
));
2075 last_image
= qla2x00_read_flash_byte(ha
, pcids
+ 0x15) & BIT_7
;
2077 /* Locate next PCI expansion ROM. */
2078 pcihdr
+= ((qla2x00_read_flash_byte(ha
, pcids
+ 0x11) << 8) |
2079 qla2x00_read_flash_byte(ha
, pcids
+ 0x10)) * 512;
2080 } while (!last_image
);
2082 if (IS_QLA2322(ha
)) {
2083 /* Read firmware image information. */
2084 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
2086 memset(dbyte
, 0, 8);
2087 dcode
= (uint16_t *)dbyte
;
2089 qla2x00_read_flash_data(ha
, dbyte
, FA_RISC_CODE_ADDR
* 4 + 10,
2091 DEBUG3(printk("%s(%ld): dumping fw ver from flash:\n",
2092 __func__
, ha
->host_no
));
2093 DEBUG3(qla2x00_dump_buffer((uint8_t *)dbyte
, 8));
2095 if ((dcode
[0] == 0xffff && dcode
[1] == 0xffff &&
2096 dcode
[2] == 0xffff && dcode
[3] == 0xffff) ||
2097 (dcode
[0] == 0 && dcode
[1] == 0 && dcode
[2] == 0 &&
2099 DEBUG2(printk("%s(): Unrecognized fw revision at "
2100 "%x.\n", __func__
, FA_RISC_CODE_ADDR
* 4));
2102 /* values are in big endian */
2103 ha
->fw_revision
[0] = dbyte
[0] << 16 | dbyte
[1];
2104 ha
->fw_revision
[1] = dbyte
[2] << 16 | dbyte
[3];
2105 ha
->fw_revision
[2] = dbyte
[4] << 16 | dbyte
[5];
2109 qla2x00_flash_disable(ha
);
2115 qla24xx_get_flash_version(scsi_qla_host_t
*ha
, void *mbuf
)
2117 int ret
= QLA_SUCCESS
;
2118 uint32_t pcihdr
, pcids
;
2121 uint8_t code_type
, last_image
;
2125 return QLA_FUNCTION_FAILED
;
2127 memset(ha
->bios_revision
, 0, sizeof(ha
->bios_revision
));
2128 memset(ha
->efi_revision
, 0, sizeof(ha
->efi_revision
));
2129 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
2130 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
2134 /* Begin with first PCI expansion ROM header. */
2138 /* Verify PCI expansion ROM header. */
2139 qla24xx_read_flash_data(ha
, dcode
, pcihdr
>> 2, 0x20);
2140 bcode
= mbuf
+ (pcihdr
% 4);
2141 if (bcode
[0x0] != 0x55 || bcode
[0x1] != 0xaa) {
2143 DEBUG2(printk("scsi(%ld): No matching ROM "
2144 "signature.\n", ha
->host_no
));
2145 ret
= QLA_FUNCTION_FAILED
;
2149 /* Locate PCI data structure. */
2150 pcids
= pcihdr
+ ((bcode
[0x19] << 8) | bcode
[0x18]);
2152 qla24xx_read_flash_data(ha
, dcode
, pcids
>> 2, 0x20);
2153 bcode
= mbuf
+ (pcihdr
% 4);
2155 /* Validate signature of PCI data structure. */
2156 if (bcode
[0x0] != 'P' || bcode
[0x1] != 'C' ||
2157 bcode
[0x2] != 'I' || bcode
[0x3] != 'R') {
2158 /* Incorrect header. */
2159 DEBUG2(printk("%s(): PCI data struct not found "
2160 "pcir_adr=%x.\n", __func__
, pcids
));
2161 ret
= QLA_FUNCTION_FAILED
;
2166 code_type
= bcode
[0x14];
2167 switch (code_type
) {
2168 case ROM_CODE_TYPE_BIOS
:
2169 /* Intel x86, PC-AT compatible. */
2170 ha
->bios_revision
[0] = bcode
[0x12];
2171 ha
->bios_revision
[1] = bcode
[0x13];
2172 DEBUG3(printk("%s(): read BIOS %d.%d.\n", __func__
,
2173 ha
->bios_revision
[1], ha
->bios_revision
[0]));
2175 case ROM_CODE_TYPE_FCODE
:
2176 /* Open Firmware standard for PCI (FCode). */
2177 ha
->fcode_revision
[0] = bcode
[0x12];
2178 ha
->fcode_revision
[1] = bcode
[0x13];
2179 DEBUG3(printk("%s(): read FCODE %d.%d.\n", __func__
,
2180 ha
->fcode_revision
[1], ha
->fcode_revision
[0]));
2182 case ROM_CODE_TYPE_EFI
:
2183 /* Extensible Firmware Interface (EFI). */
2184 ha
->efi_revision
[0] = bcode
[0x12];
2185 ha
->efi_revision
[1] = bcode
[0x13];
2186 DEBUG3(printk("%s(): read EFI %d.%d.\n", __func__
,
2187 ha
->efi_revision
[1], ha
->efi_revision
[0]));
2190 DEBUG2(printk("%s(): Unrecognized code type %x at "
2191 "pcids %x.\n", __func__
, code_type
, pcids
));
2195 last_image
= bcode
[0x15] & BIT_7
;
2197 /* Locate next PCI expansion ROM. */
2198 pcihdr
+= ((bcode
[0x11] << 8) | bcode
[0x10]) * 512;
2199 } while (!last_image
);
2201 /* Read firmware image information. */
2202 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
2205 qla24xx_read_flash_data(ha
, dcode
, FA_RISC_CODE_ADDR
+ 4, 4);
2206 for (i
= 0; i
< 4; i
++)
2207 dcode
[i
] = be32_to_cpu(dcode
[i
]);
2209 if ((dcode
[0] == 0xffffffff && dcode
[1] == 0xffffffff &&
2210 dcode
[2] == 0xffffffff && dcode
[3] == 0xffffffff) ||
2211 (dcode
[0] == 0 && dcode
[1] == 0 && dcode
[2] == 0 &&
2213 DEBUG2(printk("%s(): Unrecognized fw version at %x.\n",
2214 __func__
, FA_RISC_CODE_ADDR
));
2216 ha
->fw_revision
[0] = dcode
[0];
2217 ha
->fw_revision
[1] = dcode
[1];
2218 ha
->fw_revision
[2] = dcode
[2];
2219 ha
->fw_revision
[3] = dcode
[3];