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 <asm/uaccess.h>
12 static uint16_t qla2x00_nvram_request(scsi_qla_host_t
*, uint32_t);
13 static void qla2x00_nv_deselect(scsi_qla_host_t
*);
14 static void qla2x00_nv_write(scsi_qla_host_t
*, uint16_t);
17 * NVRAM support routines
21 * qla2x00_lock_nvram_access() -
25 qla2x00_lock_nvram_access(scsi_qla_host_t
*ha
)
28 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
30 if (!IS_QLA2100(ha
) && !IS_QLA2200(ha
) && !IS_QLA2300(ha
)) {
31 data
= RD_REG_WORD(®
->nvram
);
32 while (data
& NVR_BUSY
) {
34 data
= RD_REG_WORD(®
->nvram
);
38 WRT_REG_WORD(®
->u
.isp2300
.host_semaphore
, 0x1);
39 RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
41 data
= RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
42 while ((data
& BIT_0
) == 0) {
45 WRT_REG_WORD(®
->u
.isp2300
.host_semaphore
, 0x1);
46 RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
48 data
= RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
54 * qla2x00_unlock_nvram_access() -
58 qla2x00_unlock_nvram_access(scsi_qla_host_t
*ha
)
60 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
62 if (!IS_QLA2100(ha
) && !IS_QLA2200(ha
) && !IS_QLA2300(ha
)) {
63 WRT_REG_WORD(®
->u
.isp2300
.host_semaphore
, 0);
64 RD_REG_WORD(®
->u
.isp2300
.host_semaphore
);
69 * qla2x00_get_nvram_word() - Calculates word position in NVRAM and calls the
70 * request routine to get the word from NVRAM.
72 * @addr: Address in NVRAM to read
74 * Returns the word read from nvram @addr.
77 qla2x00_get_nvram_word(scsi_qla_host_t
*ha
, uint32_t addr
)
84 data
= qla2x00_nvram_request(ha
, nv_cmd
);
90 * qla2x00_write_nvram_word() - Write NVRAM data.
92 * @addr: Address in NVRAM to write
93 * @data: word to program
96 qla2x00_write_nvram_word(scsi_qla_host_t
*ha
, uint32_t addr
, uint16_t data
)
100 uint32_t nv_cmd
, wait_cnt
;
101 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
103 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
104 qla2x00_nv_write(ha
, 0);
105 qla2x00_nv_write(ha
, 0);
107 for (word
= 0; word
< 8; word
++)
108 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
110 qla2x00_nv_deselect(ha
);
113 nv_cmd
= (addr
<< 16) | NV_WRITE_OP
;
116 for (count
= 0; count
< 27; count
++) {
118 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
120 qla2x00_nv_write(ha
, 0);
125 qla2x00_nv_deselect(ha
);
127 /* Wait for NVRAM to become ready */
128 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
129 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
130 wait_cnt
= NVR_WAIT_CNT
;
133 DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n",
134 __func__
, ha
->host_no
));
138 word
= RD_REG_WORD(®
->nvram
);
139 } while ((word
& NVR_DATA_IN
) == 0);
141 qla2x00_nv_deselect(ha
);
144 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
145 for (count
= 0; count
< 10; count
++)
146 qla2x00_nv_write(ha
, 0);
148 qla2x00_nv_deselect(ha
);
152 qla2x00_write_nvram_word_tmo(scsi_qla_host_t
*ha
, uint32_t addr
, uint16_t data
,
158 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
162 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
163 qla2x00_nv_write(ha
, 0);
164 qla2x00_nv_write(ha
, 0);
166 for (word
= 0; word
< 8; word
++)
167 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
169 qla2x00_nv_deselect(ha
);
172 nv_cmd
= (addr
<< 16) | NV_WRITE_OP
;
175 for (count
= 0; count
< 27; count
++) {
177 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
179 qla2x00_nv_write(ha
, 0);
184 qla2x00_nv_deselect(ha
);
186 /* Wait for NVRAM to become ready */
187 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
188 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
191 word
= RD_REG_WORD(®
->nvram
);
193 ret
= QLA_FUNCTION_FAILED
;
196 } while ((word
& NVR_DATA_IN
) == 0);
198 qla2x00_nv_deselect(ha
);
201 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
202 for (count
= 0; count
< 10; count
++)
203 qla2x00_nv_write(ha
, 0);
205 qla2x00_nv_deselect(ha
);
211 * qla2x00_nvram_request() - Sends read command to NVRAM and gets data from
214 * @nv_cmd: NVRAM command
216 * Bit definitions for NVRAM command:
219 * Bit 25, 24 = opcode
220 * Bit 23-16 = address
221 * Bit 15-0 = write data
223 * Returns the word read from nvram @addr.
226 qla2x00_nvram_request(scsi_qla_host_t
*ha
, uint32_t nv_cmd
)
229 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
233 /* Send command to NVRAM. */
235 for (cnt
= 0; cnt
< 11; cnt
++) {
237 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
239 qla2x00_nv_write(ha
, 0);
243 /* Read data from NVRAM. */
244 for (cnt
= 0; cnt
< 16; cnt
++) {
245 WRT_REG_WORD(®
->nvram
, NVR_SELECT
| NVR_CLOCK
);
246 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
249 reg_data
= RD_REG_WORD(®
->nvram
);
250 if (reg_data
& NVR_DATA_IN
)
252 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
253 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
258 WRT_REG_WORD(®
->nvram
, NVR_DESELECT
);
259 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
266 * qla2x00_nv_write() - Clean NVRAM operations.
270 qla2x00_nv_deselect(scsi_qla_host_t
*ha
)
272 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
274 WRT_REG_WORD(®
->nvram
, NVR_DESELECT
);
275 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
280 * qla2x00_nv_write() - Prepare for NVRAM read/write operation.
282 * @data: Serial interface selector
285 qla2x00_nv_write(scsi_qla_host_t
*ha
, uint16_t data
)
287 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
289 WRT_REG_WORD(®
->nvram
, data
| NVR_SELECT
| NVR_WRT_ENABLE
);
290 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
292 WRT_REG_WORD(®
->nvram
, data
| NVR_SELECT
| NVR_CLOCK
|
294 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
296 WRT_REG_WORD(®
->nvram
, data
| NVR_SELECT
| NVR_WRT_ENABLE
);
297 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
302 * qla2x00_clear_nvram_protection() -
306 qla2x00_clear_nvram_protection(scsi_qla_host_t
*ha
)
309 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
310 uint32_t word
, wait_cnt
;
311 uint16_t wprot
, wprot_old
;
313 /* Clear NVRAM write protection. */
314 ret
= QLA_FUNCTION_FAILED
;
316 wprot_old
= cpu_to_le16(qla2x00_get_nvram_word(ha
, ha
->nvram_base
));
317 stat
= qla2x00_write_nvram_word_tmo(ha
, ha
->nvram_base
,
318 __constant_cpu_to_le16(0x1234), 100000);
319 wprot
= cpu_to_le16(qla2x00_get_nvram_word(ha
, ha
->nvram_base
));
320 if (stat
!= QLA_SUCCESS
|| wprot
!= 0x1234) {
322 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
323 qla2x00_nv_write(ha
, 0);
324 qla2x00_nv_write(ha
, 0);
325 for (word
= 0; word
< 8; word
++)
326 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
328 qla2x00_nv_deselect(ha
);
330 /* Enable protection register. */
331 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
332 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
333 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
334 for (word
= 0; word
< 8; word
++)
335 qla2x00_nv_write(ha
, NVR_DATA_OUT
| NVR_PR_ENABLE
);
337 qla2x00_nv_deselect(ha
);
339 /* Clear protection register (ffff is cleared). */
340 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
341 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
342 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
343 for (word
= 0; word
< 8; word
++)
344 qla2x00_nv_write(ha
, NVR_DATA_OUT
| NVR_PR_ENABLE
);
346 qla2x00_nv_deselect(ha
);
348 /* Wait for NVRAM to become ready. */
349 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
350 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
351 wait_cnt
= NVR_WAIT_CNT
;
354 DEBUG9_10(printk("%s(%ld): NVRAM didn't go "
355 "ready...\n", __func__
,
360 word
= RD_REG_WORD(®
->nvram
);
361 } while ((word
& NVR_DATA_IN
) == 0);
366 qla2x00_write_nvram_word(ha
, ha
->nvram_base
, wprot_old
);
372 qla2x00_set_nvram_protection(scsi_qla_host_t
*ha
, int stat
)
374 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
375 uint32_t word
, wait_cnt
;
377 if (stat
!= QLA_SUCCESS
)
380 /* Set NVRAM write protection. */
382 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
383 qla2x00_nv_write(ha
, 0);
384 qla2x00_nv_write(ha
, 0);
385 for (word
= 0; word
< 8; word
++)
386 qla2x00_nv_write(ha
, NVR_DATA_OUT
);
388 qla2x00_nv_deselect(ha
);
390 /* Enable protection register. */
391 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
392 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
393 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
394 for (word
= 0; word
< 8; word
++)
395 qla2x00_nv_write(ha
, NVR_DATA_OUT
| NVR_PR_ENABLE
);
397 qla2x00_nv_deselect(ha
);
399 /* Enable protection register. */
400 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
401 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
402 qla2x00_nv_write(ha
, NVR_PR_ENABLE
| NVR_DATA_OUT
);
403 for (word
= 0; word
< 8; word
++)
404 qla2x00_nv_write(ha
, NVR_PR_ENABLE
);
406 qla2x00_nv_deselect(ha
);
408 /* Wait for NVRAM to become ready. */
409 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
410 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
411 wait_cnt
= NVR_WAIT_CNT
;
414 DEBUG9_10(printk("%s(%ld): NVRAM didn't go ready...\n",
415 __func__
, ha
->host_no
));
419 word
= RD_REG_WORD(®
->nvram
);
420 } while ((word
& NVR_DATA_IN
) == 0);
424 /*****************************************************************************/
425 /* Flash Manipulation Routines */
426 /*****************************************************************************/
428 #define OPTROM_BURST_SIZE 0x1000
429 #define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4)
431 static inline uint32_t
432 flash_conf_to_access_addr(uint32_t faddr
)
434 return FARX_ACCESS_FLASH_CONF
| faddr
;
437 static inline uint32_t
438 flash_data_to_access_addr(uint32_t faddr
)
440 return FARX_ACCESS_FLASH_DATA
| faddr
;
443 static inline uint32_t
444 nvram_conf_to_access_addr(uint32_t naddr
)
446 return FARX_ACCESS_NVRAM_CONF
| naddr
;
449 static inline uint32_t
450 nvram_data_to_access_addr(uint32_t naddr
)
452 return FARX_ACCESS_NVRAM_DATA
| naddr
;
456 qla24xx_read_flash_dword(scsi_qla_host_t
*ha
, uint32_t addr
)
460 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
462 WRT_REG_DWORD(®
->flash_addr
, addr
& ~FARX_DATA_FLAG
);
463 /* Wait for READ cycle to complete. */
466 (RD_REG_DWORD(®
->flash_addr
) & FARX_DATA_FLAG
) == 0 &&
467 rval
== QLA_SUCCESS
; cnt
--) {
471 rval
= QLA_FUNCTION_TIMEOUT
;
475 /* TODO: What happens if we time out? */
477 if (rval
== QLA_SUCCESS
)
478 data
= RD_REG_DWORD(®
->flash_data
);
484 qla24xx_read_flash_data(scsi_qla_host_t
*ha
, uint32_t *dwptr
, uint32_t faddr
,
489 /* Dword reads to flash. */
490 for (i
= 0; i
< dwords
; i
++, faddr
++)
491 dwptr
[i
] = cpu_to_le32(qla24xx_read_flash_dword(ha
,
492 flash_data_to_access_addr(faddr
)));
498 qla24xx_write_flash_dword(scsi_qla_host_t
*ha
, uint32_t addr
, uint32_t data
)
502 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
504 WRT_REG_DWORD(®
->flash_data
, data
);
505 RD_REG_DWORD(®
->flash_data
); /* PCI Posting. */
506 WRT_REG_DWORD(®
->flash_addr
, addr
| FARX_DATA_FLAG
);
507 /* Wait for Write cycle to complete. */
509 for (cnt
= 500000; (RD_REG_DWORD(®
->flash_addr
) & FARX_DATA_FLAG
) &&
510 rval
== QLA_SUCCESS
; cnt
--) {
514 rval
= QLA_FUNCTION_TIMEOUT
;
521 qla24xx_get_flash_manufacturer(scsi_qla_host_t
*ha
, uint8_t *man_id
,
526 ids
= qla24xx_read_flash_dword(ha
, flash_data_to_access_addr(0xd03ab));
528 *flash_id
= MSB(ids
);
530 /* Check if man_id and flash_id are valid. */
531 if (ids
!= 0xDEADDEAD && (*man_id
== 0 || *flash_id
== 0)) {
532 /* Read information using 0x9f opcode
533 * Device ID, Mfg ID would be read in the format:
534 * <Ext Dev Info><Device ID Part2><Device ID Part 1><Mfg ID>
535 * Example: ATMEL 0x00 01 45 1F
536 * Extract MFG and Dev ID from last two bytes.
538 ids
= qla24xx_read_flash_dword(ha
,
539 flash_data_to_access_addr(0xd009f));
541 *flash_id
= MSB(ids
);
546 qla24xx_write_flash_data(scsi_qla_host_t
*ha
, uint32_t *dwptr
, uint32_t faddr
,
550 uint32_t liter
, miter
;
551 uint32_t sec_mask
, rest_addr
, conf_addr
;
552 uint32_t fdata
, findex
;
553 uint8_t man_id
, flash_id
;
554 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
555 dma_addr_t optrom_dma
;
561 /* Prepare burst-capable write on supported ISPs. */
562 if (IS_QLA25XX(ha
) && !(faddr
& 0xfff) &&
563 dwords
> OPTROM_BURST_DWORDS
) {
564 optrom
= dma_alloc_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
,
565 &optrom_dma
, GFP_KERNEL
);
567 qla_printk(KERN_DEBUG
, ha
,
568 "Unable to allocate memory for optrom burst write "
569 "(%x KB).\n", OPTROM_BURST_SIZE
/ 1024);
573 qla24xx_get_flash_manufacturer(ha
, &man_id
, &flash_id
);
574 DEBUG9(printk("%s(%ld): Flash man_id=%d flash_id=%d\n", __func__
,
575 ha
->host_no
, man_id
, flash_id
));
577 conf_addr
= flash_conf_to_access_addr(0x03d8);
579 case 0xbf: /* STT flash. */
580 if (flash_id
== 0x8e) {
587 if (flash_id
== 0x80)
588 conf_addr
= flash_conf_to_access_addr(0x0352);
590 case 0x13: /* ST M25P80. */
594 case 0x1f: // Atmel 26DF081A
597 conf_addr
= flash_conf_to_access_addr(0x0320);
600 /* Default to 64 kb sector size. */
606 /* Enable flash write. */
607 WRT_REG_DWORD(®
->ctrl_status
,
608 RD_REG_DWORD(®
->ctrl_status
) | CSRX_FLASH_ENABLE
);
609 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
611 /* Disable flash write-protection. */
612 qla24xx_write_flash_dword(ha
, flash_conf_to_access_addr(0x101), 0);
613 /* Some flash parts need an additional zero-write to clear bits.*/
614 qla24xx_write_flash_dword(ha
, flash_conf_to_access_addr(0x101), 0);
616 for (liter
= 0; liter
< dwords
; liter
++, faddr
++, dwptr
++) {
617 if (man_id
== 0x1f) {
619 fdata
= findex
& sec_mask
;
622 fdata
= (findex
& sec_mask
) << 2;
625 /* Are we at the beginning of a sector? */
626 if ((findex
& rest_addr
) == 0) {
627 /* Do sector unprotect at 4K boundry for Atmel part. */
629 qla24xx_write_flash_dword(ha
,
630 flash_conf_to_access_addr(0x0339),
631 (fdata
& 0xff00) | ((fdata
<< 16) &
632 0xff0000) | ((fdata
>> 16) & 0xff));
633 ret
= qla24xx_write_flash_dword(ha
, conf_addr
,
634 (fdata
& 0xff00) |((fdata
<< 16) &
635 0xff0000) | ((fdata
>> 16) & 0xff));
636 if (ret
!= QLA_SUCCESS
) {
637 DEBUG9(printk("%s(%ld) Unable to flash "
638 "sector: address=%x.\n", __func__
,
639 ha
->host_no
, faddr
));
644 /* Go with burst-write. */
645 if (optrom
&& (liter
+ OPTROM_BURST_DWORDS
) < dwords
) {
646 /* Copy data to DMA'ble buffer. */
647 for (miter
= 0, s
= optrom
, d
= dwptr
;
648 miter
< OPTROM_BURST_DWORDS
; miter
++, s
++, d
++)
649 *s
= cpu_to_le32(*d
);
651 ret
= qla2x00_load_ram(ha
, optrom_dma
,
652 flash_data_to_access_addr(faddr
),
653 OPTROM_BURST_DWORDS
);
654 if (ret
!= QLA_SUCCESS
) {
655 qla_printk(KERN_WARNING
, ha
,
656 "Unable to burst-write optrom segment "
657 "(%x/%x/%llx).\n", ret
,
658 flash_data_to_access_addr(faddr
),
660 qla_printk(KERN_WARNING
, ha
,
661 "Reverting to slow-write.\n");
663 dma_free_coherent(&ha
->pdev
->dev
,
664 OPTROM_BURST_SIZE
, optrom
, optrom_dma
);
667 liter
+= OPTROM_BURST_DWORDS
- 1;
668 faddr
+= OPTROM_BURST_DWORDS
- 1;
669 dwptr
+= OPTROM_BURST_DWORDS
- 1;
674 ret
= qla24xx_write_flash_dword(ha
,
675 flash_data_to_access_addr(faddr
), cpu_to_le32(*dwptr
));
676 if (ret
!= QLA_SUCCESS
) {
677 DEBUG9(printk("%s(%ld) Unable to program flash "
678 "address=%x data=%x.\n", __func__
,
679 ha
->host_no
, faddr
, *dwptr
));
683 /* Do sector protect at 4K boundry for Atmel part. */
684 if (man_id
== 0x1f &&
685 ((faddr
& rest_addr
) == rest_addr
))
686 qla24xx_write_flash_dword(ha
,
687 flash_conf_to_access_addr(0x0336),
688 (fdata
& 0xff00) | ((fdata
<< 16) &
689 0xff0000) | ((fdata
>> 16) & 0xff));
692 /* Enable flash write-protection. */
693 qla24xx_write_flash_dword(ha
, flash_conf_to_access_addr(0x101), 0x9c);
695 /* Disable flash write. */
696 WRT_REG_DWORD(®
->ctrl_status
,
697 RD_REG_DWORD(®
->ctrl_status
) & ~CSRX_FLASH_ENABLE
);
698 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
701 dma_free_coherent(&ha
->pdev
->dev
,
702 OPTROM_BURST_SIZE
, optrom
, optrom_dma
);
708 qla2x00_read_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
714 /* Word reads to NVRAM via registers. */
715 wptr
= (uint16_t *)buf
;
716 qla2x00_lock_nvram_access(ha
);
717 for (i
= 0; i
< bytes
>> 1; i
++, naddr
++)
718 wptr
[i
] = cpu_to_le16(qla2x00_get_nvram_word(ha
,
720 qla2x00_unlock_nvram_access(ha
);
726 qla24xx_read_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
732 /* Dword reads to flash. */
733 dwptr
= (uint32_t *)buf
;
734 for (i
= 0; i
< bytes
>> 2; i
++, naddr
++)
735 dwptr
[i
] = cpu_to_le32(qla24xx_read_flash_dword(ha
,
736 nvram_data_to_access_addr(naddr
)));
742 qla2x00_write_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
751 qla2x00_lock_nvram_access(ha
);
753 /* Disable NVRAM write-protection. */
754 stat
= qla2x00_clear_nvram_protection(ha
);
756 wptr
= (uint16_t *)buf
;
757 for (i
= 0; i
< bytes
>> 1; i
++, naddr
++) {
758 qla2x00_write_nvram_word(ha
, naddr
,
763 /* Enable NVRAM write-protection. */
764 qla2x00_set_nvram_protection(ha
, stat
);
766 qla2x00_unlock_nvram_access(ha
);
772 qla24xx_write_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
778 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
782 /* Enable flash write. */
783 WRT_REG_DWORD(®
->ctrl_status
,
784 RD_REG_DWORD(®
->ctrl_status
) | CSRX_FLASH_ENABLE
);
785 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
787 /* Disable NVRAM write-protection. */
788 qla24xx_write_flash_dword(ha
, nvram_conf_to_access_addr(0x101),
790 qla24xx_write_flash_dword(ha
, nvram_conf_to_access_addr(0x101),
793 /* Dword writes to flash. */
794 dwptr
= (uint32_t *)buf
;
795 for (i
= 0; i
< bytes
>> 2; i
++, naddr
++, dwptr
++) {
796 ret
= qla24xx_write_flash_dword(ha
,
797 nvram_data_to_access_addr(naddr
),
798 cpu_to_le32(*dwptr
));
799 if (ret
!= QLA_SUCCESS
) {
800 DEBUG9(printk("%s(%ld) Unable to program "
801 "nvram address=%x data=%x.\n", __func__
,
802 ha
->host_no
, naddr
, *dwptr
));
807 /* Enable NVRAM write-protection. */
808 qla24xx_write_flash_dword(ha
, nvram_conf_to_access_addr(0x101),
811 /* Disable flash write. */
812 WRT_REG_DWORD(®
->ctrl_status
,
813 RD_REG_DWORD(®
->ctrl_status
) & ~CSRX_FLASH_ENABLE
);
814 RD_REG_DWORD(®
->ctrl_status
); /* PCI Posting. */
820 qla25xx_read_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
826 /* Dword reads to flash. */
827 dwptr
= (uint32_t *)buf
;
828 for (i
= 0; i
< bytes
>> 2; i
++, naddr
++)
829 dwptr
[i
] = cpu_to_le32(qla24xx_read_flash_dword(ha
,
830 flash_data_to_access_addr(FA_VPD_NVRAM_ADDR
| naddr
)));
836 qla25xx_write_nvram_data(scsi_qla_host_t
*ha
, uint8_t *buf
, uint32_t naddr
,
839 return qla24xx_write_flash_data(ha
, (uint32_t *)buf
,
840 FA_VPD_NVRAM_ADDR
| naddr
, bytes
>> 2);
844 qla2x00_flip_colors(scsi_qla_host_t
*ha
, uint16_t *pflags
)
846 if (IS_QLA2322(ha
)) {
847 /* Flip all colors. */
848 if (ha
->beacon_color_state
== QLA_LED_ALL_ON
) {
850 ha
->beacon_color_state
= 0;
851 *pflags
= GPIO_LED_ALL_OFF
;
854 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
855 *pflags
= GPIO_LED_RGA_ON
;
858 /* Flip green led only. */
859 if (ha
->beacon_color_state
== QLA_LED_GRN_ON
) {
861 ha
->beacon_color_state
= 0;
862 *pflags
= GPIO_LED_GREEN_OFF_AMBER_OFF
;
865 ha
->beacon_color_state
= QLA_LED_GRN_ON
;
866 *pflags
= GPIO_LED_GREEN_ON_AMBER_OFF
;
872 qla2x00_beacon_blink(struct scsi_qla_host
*ha
)
874 uint16_t gpio_enable
;
876 uint16_t led_color
= 0;
878 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
881 reg
= (struct device_reg_2xxx __iomem
*)ha
->pio_address
;
883 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
885 /* Save the Original GPIOE. */
886 if (ha
->pio_address
) {
887 gpio_enable
= RD_REG_WORD_PIO(®
->gpioe
);
888 gpio_data
= RD_REG_WORD_PIO(®
->gpiod
);
890 gpio_enable
= RD_REG_WORD(®
->gpioe
);
891 gpio_data
= RD_REG_WORD(®
->gpiod
);
894 /* Set the modified gpio_enable values */
895 gpio_enable
|= GPIO_LED_MASK
;
897 if (ha
->pio_address
) {
898 WRT_REG_WORD_PIO(®
->gpioe
, gpio_enable
);
900 WRT_REG_WORD(®
->gpioe
, gpio_enable
);
901 RD_REG_WORD(®
->gpioe
);
904 qla2x00_flip_colors(ha
, &led_color
);
906 /* Clear out any previously set LED color. */
907 gpio_data
&= ~GPIO_LED_MASK
;
909 /* Set the new input LED color to GPIOD. */
910 gpio_data
|= led_color
;
912 /* Set the modified gpio_data values */
913 if (ha
->pio_address
) {
914 WRT_REG_WORD_PIO(®
->gpiod
, gpio_data
);
916 WRT_REG_WORD(®
->gpiod
, gpio_data
);
917 RD_REG_WORD(®
->gpiod
);
920 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
924 qla2x00_beacon_on(struct scsi_qla_host
*ha
)
926 uint16_t gpio_enable
;
929 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
931 ha
->fw_options
[1] &= ~FO1_SET_EMPHASIS_SWING
;
932 ha
->fw_options
[1] |= FO1_DISABLE_GPIO6_7
;
934 if (qla2x00_set_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
) {
935 qla_printk(KERN_WARNING
, ha
,
936 "Unable to update fw options (beacon on).\n");
937 return QLA_FUNCTION_FAILED
;
941 reg
= (struct device_reg_2xxx __iomem
*)ha
->pio_address
;
944 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
945 if (ha
->pio_address
) {
946 gpio_enable
= RD_REG_WORD_PIO(®
->gpioe
);
947 gpio_data
= RD_REG_WORD_PIO(®
->gpiod
);
949 gpio_enable
= RD_REG_WORD(®
->gpioe
);
950 gpio_data
= RD_REG_WORD(®
->gpiod
);
952 gpio_enable
|= GPIO_LED_MASK
;
954 /* Set the modified gpio_enable values. */
955 if (ha
->pio_address
) {
956 WRT_REG_WORD_PIO(®
->gpioe
, gpio_enable
);
958 WRT_REG_WORD(®
->gpioe
, gpio_enable
);
959 RD_REG_WORD(®
->gpioe
);
962 /* Clear out previously set LED colour. */
963 gpio_data
&= ~GPIO_LED_MASK
;
964 if (ha
->pio_address
) {
965 WRT_REG_WORD_PIO(®
->gpiod
, gpio_data
);
967 WRT_REG_WORD(®
->gpiod
, gpio_data
);
968 RD_REG_WORD(®
->gpiod
);
970 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
973 * Let the per HBA timer kick off the blinking process based on
974 * the following flags. No need to do anything else now.
976 ha
->beacon_blink_led
= 1;
977 ha
->beacon_color_state
= 0;
983 qla2x00_beacon_off(struct scsi_qla_host
*ha
)
985 int rval
= QLA_SUCCESS
;
987 ha
->beacon_blink_led
= 0;
989 /* Set the on flag so when it gets flipped it will be off. */
991 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
993 ha
->beacon_color_state
= QLA_LED_GRN_ON
;
995 ha
->isp_ops
->beacon_blink(ha
); /* This turns green LED off */
997 ha
->fw_options
[1] &= ~FO1_SET_EMPHASIS_SWING
;
998 ha
->fw_options
[1] &= ~FO1_DISABLE_GPIO6_7
;
1000 rval
= qla2x00_set_fw_options(ha
, ha
->fw_options
);
1001 if (rval
!= QLA_SUCCESS
)
1002 qla_printk(KERN_WARNING
, ha
,
1003 "Unable to update fw options (beacon off).\n");
1009 qla24xx_flip_colors(scsi_qla_host_t
*ha
, uint16_t *pflags
)
1011 /* Flip all colors. */
1012 if (ha
->beacon_color_state
== QLA_LED_ALL_ON
) {
1014 ha
->beacon_color_state
= 0;
1018 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
1019 *pflags
= GPDX_LED_YELLOW_ON
| GPDX_LED_AMBER_ON
;
1024 qla24xx_beacon_blink(struct scsi_qla_host
*ha
)
1026 uint16_t led_color
= 0;
1028 unsigned long flags
;
1029 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1031 /* Save the Original GPIOD. */
1032 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1033 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1035 /* Enable the gpio_data reg for update. */
1036 gpio_data
|= GPDX_LED_UPDATE_MASK
;
1038 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1039 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1041 /* Set the color bits. */
1042 qla24xx_flip_colors(ha
, &led_color
);
1044 /* Clear out any previously set LED color. */
1045 gpio_data
&= ~GPDX_LED_COLOR_MASK
;
1047 /* Set the new input LED color to GPIOD. */
1048 gpio_data
|= led_color
;
1050 /* Set the modified gpio_data values. */
1051 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1052 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1053 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1057 qla24xx_beacon_on(struct scsi_qla_host
*ha
)
1060 unsigned long flags
;
1061 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1063 if (ha
->beacon_blink_led
== 0) {
1064 /* Enable firmware for update */
1065 ha
->fw_options
[1] |= ADD_FO1_DISABLE_GPIO_LED_CTRL
;
1067 if (qla2x00_set_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
)
1068 return QLA_FUNCTION_FAILED
;
1070 if (qla2x00_get_fw_options(ha
, ha
->fw_options
) !=
1072 qla_printk(KERN_WARNING
, ha
,
1073 "Unable to update fw options (beacon on).\n");
1074 return QLA_FUNCTION_FAILED
;
1077 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1078 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1080 /* Enable the gpio_data reg for update. */
1081 gpio_data
|= GPDX_LED_UPDATE_MASK
;
1082 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1083 RD_REG_DWORD(®
->gpiod
);
1085 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1088 /* So all colors blink together. */
1089 ha
->beacon_color_state
= 0;
1091 /* Let the per HBA timer kick off the blinking process. */
1092 ha
->beacon_blink_led
= 1;
1098 qla24xx_beacon_off(struct scsi_qla_host
*ha
)
1101 unsigned long flags
;
1102 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1104 ha
->beacon_blink_led
= 0;
1105 ha
->beacon_color_state
= QLA_LED_ALL_ON
;
1107 ha
->isp_ops
->beacon_blink(ha
); /* Will flip to all off. */
1109 /* Give control back to firmware. */
1110 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1111 gpio_data
= RD_REG_DWORD(®
->gpiod
);
1113 /* Disable the gpio_data reg for update. */
1114 gpio_data
&= ~GPDX_LED_UPDATE_MASK
;
1115 WRT_REG_DWORD(®
->gpiod
, gpio_data
);
1116 RD_REG_DWORD(®
->gpiod
);
1117 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1119 ha
->fw_options
[1] &= ~ADD_FO1_DISABLE_GPIO_LED_CTRL
;
1121 if (qla2x00_set_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
) {
1122 qla_printk(KERN_WARNING
, ha
,
1123 "Unable to update fw options (beacon off).\n");
1124 return QLA_FUNCTION_FAILED
;
1127 if (qla2x00_get_fw_options(ha
, ha
->fw_options
) != QLA_SUCCESS
) {
1128 qla_printk(KERN_WARNING
, ha
,
1129 "Unable to get fw options (beacon off).\n");
1130 return QLA_FUNCTION_FAILED
;
1138 * Flash support routines
1142 * qla2x00_flash_enable() - Setup flash for reading and writing.
1146 qla2x00_flash_enable(scsi_qla_host_t
*ha
)
1149 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1151 data
= RD_REG_WORD(®
->ctrl_status
);
1152 data
|= CSR_FLASH_ENABLE
;
1153 WRT_REG_WORD(®
->ctrl_status
, data
);
1154 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1158 * qla2x00_flash_disable() - Disable flash and allow RISC to run.
1162 qla2x00_flash_disable(scsi_qla_host_t
*ha
)
1165 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1167 data
= RD_REG_WORD(®
->ctrl_status
);
1168 data
&= ~(CSR_FLASH_ENABLE
);
1169 WRT_REG_WORD(®
->ctrl_status
, data
);
1170 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1174 * qla2x00_read_flash_byte() - Reads a byte from flash
1176 * @addr: Address in flash to read
1178 * A word is read from the chip, but, only the lower byte is valid.
1180 * Returns the byte read from flash @addr.
1183 qla2x00_read_flash_byte(scsi_qla_host_t
*ha
, uint32_t addr
)
1186 uint16_t bank_select
;
1187 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1189 bank_select
= RD_REG_WORD(®
->ctrl_status
);
1191 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1192 /* Specify 64K address range: */
1193 /* clear out Module Select and Flash Address bits [19:16]. */
1194 bank_select
&= ~0xf8;
1195 bank_select
|= addr
>> 12 & 0xf0;
1196 bank_select
|= CSR_FLASH_64K_BANK
;
1197 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1198 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1200 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1201 data
= RD_REG_WORD(®
->flash_data
);
1203 return (uint8_t)data
;
1206 /* Setup bit 16 of flash address. */
1207 if ((addr
& BIT_16
) && ((bank_select
& CSR_FLASH_64K_BANK
) == 0)) {
1208 bank_select
|= CSR_FLASH_64K_BANK
;
1209 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1210 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1211 } else if (((addr
& BIT_16
) == 0) &&
1212 (bank_select
& CSR_FLASH_64K_BANK
)) {
1213 bank_select
&= ~(CSR_FLASH_64K_BANK
);
1214 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1215 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1218 /* Always perform IO mapped accesses to the FLASH registers. */
1219 if (ha
->pio_address
) {
1222 reg
= (struct device_reg_2xxx __iomem
*)ha
->pio_address
;
1223 WRT_REG_WORD_PIO(®
->flash_address
, (uint16_t)addr
);
1225 data
= RD_REG_WORD_PIO(®
->flash_data
);
1228 data2
= RD_REG_WORD_PIO(®
->flash_data
);
1229 } while (data
!= data2
);
1231 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1232 data
= qla2x00_debounce_register(®
->flash_data
);
1235 return (uint8_t)data
;
1239 * qla2x00_write_flash_byte() - Write a byte to flash
1241 * @addr: Address in flash to write
1242 * @data: Data to write
1245 qla2x00_write_flash_byte(scsi_qla_host_t
*ha
, uint32_t addr
, uint8_t data
)
1247 uint16_t bank_select
;
1248 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1250 bank_select
= RD_REG_WORD(®
->ctrl_status
);
1251 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1252 /* Specify 64K address range: */
1253 /* clear out Module Select and Flash Address bits [19:16]. */
1254 bank_select
&= ~0xf8;
1255 bank_select
|= addr
>> 12 & 0xf0;
1256 bank_select
|= CSR_FLASH_64K_BANK
;
1257 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1258 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1260 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1261 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1262 WRT_REG_WORD(®
->flash_data
, (uint16_t)data
);
1263 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1268 /* Setup bit 16 of flash address. */
1269 if ((addr
& BIT_16
) && ((bank_select
& CSR_FLASH_64K_BANK
) == 0)) {
1270 bank_select
|= CSR_FLASH_64K_BANK
;
1271 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1272 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1273 } else if (((addr
& BIT_16
) == 0) &&
1274 (bank_select
& CSR_FLASH_64K_BANK
)) {
1275 bank_select
&= ~(CSR_FLASH_64K_BANK
);
1276 WRT_REG_WORD(®
->ctrl_status
, bank_select
);
1277 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1280 /* Always perform IO mapped accesses to the FLASH registers. */
1281 if (ha
->pio_address
) {
1282 reg
= (struct device_reg_2xxx __iomem
*)ha
->pio_address
;
1283 WRT_REG_WORD_PIO(®
->flash_address
, (uint16_t)addr
);
1284 WRT_REG_WORD_PIO(®
->flash_data
, (uint16_t)data
);
1286 WRT_REG_WORD(®
->flash_address
, (uint16_t)addr
);
1287 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1288 WRT_REG_WORD(®
->flash_data
, (uint16_t)data
);
1289 RD_REG_WORD(®
->ctrl_status
); /* PCI Posting. */
1294 * qla2x00_poll_flash() - Polls flash for completion.
1296 * @addr: Address in flash to poll
1297 * @poll_data: Data to be polled
1298 * @man_id: Flash manufacturer ID
1299 * @flash_id: Flash ID
1301 * This function polls the device until bit 7 of what is read matches data
1302 * bit 7 or until data bit 5 becomes a 1. If that hapens, the flash ROM timed
1303 * out (a fatal error). The flash book recommeds reading bit 7 again after
1304 * reading bit 5 as a 1.
1306 * Returns 0 on success, else non-zero.
1309 qla2x00_poll_flash(scsi_qla_host_t
*ha
, uint32_t addr
, uint8_t poll_data
,
1310 uint8_t man_id
, uint8_t flash_id
)
1318 /* Wait for 30 seconds for command to finish. */
1320 for (cnt
= 3000000; cnt
; cnt
--) {
1321 flash_data
= qla2x00_read_flash_byte(ha
, addr
);
1322 if ((flash_data
& BIT_7
) == poll_data
) {
1327 if (man_id
!= 0x40 && man_id
!= 0xda) {
1328 if ((flash_data
& BIT_5
) && cnt
> 2)
1339 * qla2x00_program_flash_address() - Programs a flash address
1341 * @addr: Address in flash to program
1342 * @data: Data to be written in flash
1343 * @man_id: Flash manufacturer ID
1344 * @flash_id: Flash ID
1346 * Returns 0 on success, else non-zero.
1349 qla2x00_program_flash_address(scsi_qla_host_t
*ha
, uint32_t addr
, uint8_t data
,
1350 uint8_t man_id
, uint8_t flash_id
)
1352 /* Write Program Command Sequence. */
1353 if (IS_OEM_001(ha
)) {
1354 qla2x00_write_flash_byte(ha
, 0xaaa, 0xaa);
1355 qla2x00_write_flash_byte(ha
, 0x555, 0x55);
1356 qla2x00_write_flash_byte(ha
, 0xaaa, 0xa0);
1357 qla2x00_write_flash_byte(ha
, addr
, data
);
1359 if (man_id
== 0xda && flash_id
== 0xc1) {
1360 qla2x00_write_flash_byte(ha
, addr
, data
);
1364 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1365 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1366 qla2x00_write_flash_byte(ha
, 0x5555, 0xa0);
1367 qla2x00_write_flash_byte(ha
, addr
, data
);
1373 /* Wait for write to complete. */
1374 return qla2x00_poll_flash(ha
, addr
, data
, man_id
, flash_id
);
1378 * qla2x00_erase_flash() - Erase the flash.
1380 * @man_id: Flash manufacturer ID
1381 * @flash_id: Flash ID
1383 * Returns 0 on success, else non-zero.
1386 qla2x00_erase_flash(scsi_qla_host_t
*ha
, uint8_t man_id
, uint8_t flash_id
)
1388 /* Individual Sector Erase Command Sequence */
1389 if (IS_OEM_001(ha
)) {
1390 qla2x00_write_flash_byte(ha
, 0xaaa, 0xaa);
1391 qla2x00_write_flash_byte(ha
, 0x555, 0x55);
1392 qla2x00_write_flash_byte(ha
, 0xaaa, 0x80);
1393 qla2x00_write_flash_byte(ha
, 0xaaa, 0xaa);
1394 qla2x00_write_flash_byte(ha
, 0x555, 0x55);
1395 qla2x00_write_flash_byte(ha
, 0xaaa, 0x10);
1397 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1398 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1399 qla2x00_write_flash_byte(ha
, 0x5555, 0x80);
1400 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1401 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1402 qla2x00_write_flash_byte(ha
, 0x5555, 0x10);
1407 /* Wait for erase to complete. */
1408 return qla2x00_poll_flash(ha
, 0x00, 0x80, man_id
, flash_id
);
1412 * qla2x00_erase_flash_sector() - Erase a flash sector.
1414 * @addr: Flash sector to erase
1415 * @sec_mask: Sector address mask
1416 * @man_id: Flash manufacturer ID
1417 * @flash_id: Flash ID
1419 * Returns 0 on success, else non-zero.
1422 qla2x00_erase_flash_sector(scsi_qla_host_t
*ha
, uint32_t addr
,
1423 uint32_t sec_mask
, uint8_t man_id
, uint8_t flash_id
)
1425 /* Individual Sector Erase Command Sequence */
1426 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1427 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1428 qla2x00_write_flash_byte(ha
, 0x5555, 0x80);
1429 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1430 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1431 if (man_id
== 0x1f && flash_id
== 0x13)
1432 qla2x00_write_flash_byte(ha
, addr
& sec_mask
, 0x10);
1434 qla2x00_write_flash_byte(ha
, addr
& sec_mask
, 0x30);
1438 /* Wait for erase to complete. */
1439 return qla2x00_poll_flash(ha
, addr
, 0x80, man_id
, flash_id
);
1443 * qla2x00_get_flash_manufacturer() - Read manufacturer ID from flash chip.
1444 * @man_id: Flash manufacturer ID
1445 * @flash_id: Flash ID
1448 qla2x00_get_flash_manufacturer(scsi_qla_host_t
*ha
, uint8_t *man_id
,
1451 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1452 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1453 qla2x00_write_flash_byte(ha
, 0x5555, 0x90);
1454 *man_id
= qla2x00_read_flash_byte(ha
, 0x0000);
1455 *flash_id
= qla2x00_read_flash_byte(ha
, 0x0001);
1456 qla2x00_write_flash_byte(ha
, 0x5555, 0xaa);
1457 qla2x00_write_flash_byte(ha
, 0x2aaa, 0x55);
1458 qla2x00_write_flash_byte(ha
, 0x5555, 0xf0);
1462 qla2x00_read_flash_data(scsi_qla_host_t
*ha
, uint8_t *tmp_buf
, uint32_t saddr
,
1465 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1466 uint32_t midpoint
, ilength
;
1469 midpoint
= length
/ 2;
1471 WRT_REG_WORD(®
->nvram
, 0);
1472 RD_REG_WORD(®
->nvram
);
1473 for (ilength
= 0; ilength
< length
; saddr
++, ilength
++, tmp_buf
++) {
1474 if (ilength
== midpoint
) {
1475 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
1476 RD_REG_WORD(®
->nvram
);
1478 data
= qla2x00_read_flash_byte(ha
, saddr
);
1487 qla2x00_suspend_hba(struct scsi_qla_host
*ha
)
1490 unsigned long flags
;
1491 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1494 scsi_block_requests(ha
->host
);
1495 ha
->isp_ops
->disable_intrs(ha
);
1496 set_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1499 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1500 WRT_REG_WORD(®
->hccr
, HCCR_PAUSE_RISC
);
1501 RD_REG_WORD(®
->hccr
);
1502 if (IS_QLA2100(ha
) || IS_QLA2200(ha
) || IS_QLA2300(ha
)) {
1503 for (cnt
= 0; cnt
< 30000; cnt
++) {
1504 if ((RD_REG_WORD(®
->hccr
) & HCCR_RISC_PAUSE
) != 0)
1511 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1515 qla2x00_resume_hba(struct scsi_qla_host
*ha
)
1518 clear_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1519 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
1520 qla2xxx_wake_dpc(ha
);
1521 qla2x00_wait_for_hba_online(ha
);
1522 scsi_unblock_requests(ha
->host
);
1526 qla2x00_read_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1527 uint32_t offset
, uint32_t length
)
1529 uint32_t addr
, midpoint
;
1531 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1534 qla2x00_suspend_hba(ha
);
1537 midpoint
= ha
->optrom_size
/ 2;
1539 qla2x00_flash_enable(ha
);
1540 WRT_REG_WORD(®
->nvram
, 0);
1541 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
1542 for (addr
= offset
, data
= buf
; addr
< length
; addr
++, data
++) {
1543 if (addr
== midpoint
) {
1544 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
1545 RD_REG_WORD(®
->nvram
); /* PCI Posting. */
1548 *data
= qla2x00_read_flash_byte(ha
, addr
);
1550 qla2x00_flash_disable(ha
);
1553 qla2x00_resume_hba(ha
);
1559 qla2x00_write_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1560 uint32_t offset
, uint32_t length
)
1564 uint8_t man_id
, flash_id
, sec_number
, data
;
1566 uint32_t addr
, liter
, sec_mask
, rest_addr
;
1567 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1570 qla2x00_suspend_hba(ha
);
1575 /* Reset ISP chip. */
1576 WRT_REG_WORD(®
->ctrl_status
, CSR_ISP_SOFT_RESET
);
1577 pci_read_config_word(ha
->pdev
, PCI_COMMAND
, &wd
);
1579 /* Go with write. */
1580 qla2x00_flash_enable(ha
);
1581 do { /* Loop once to provide quick error exit */
1582 /* Structure of flash memory based on manufacturer */
1583 if (IS_OEM_001(ha
)) {
1584 /* OEM variant with special flash part. */
1585 man_id
= flash_id
= 0;
1590 qla2x00_get_flash_manufacturer(ha
, &man_id
, &flash_id
);
1592 case 0x20: /* ST flash. */
1593 if (flash_id
== 0xd2 || flash_id
== 0xe3) {
1595 * ST m29w008at part - 64kb sector size with
1596 * 32kb,8kb,8kb,16kb sectors at memory address
1604 * ST m29w010b part - 16kb sector size
1605 * Default to 16kb sectors
1610 case 0x40: /* Mostel flash. */
1611 /* Mostel v29c51001 part - 512 byte sector size. */
1615 case 0xbf: /* SST flash. */
1616 /* SST39sf10 part - 4kb sector size. */
1620 case 0xda: /* Winbond flash. */
1621 /* Winbond W29EE011 part - 256 byte sector size. */
1625 case 0xc2: /* Macronix flash. */
1626 /* 64k sector size. */
1627 if (flash_id
== 0x38 || flash_id
== 0x4f) {
1632 /* Fall through... */
1634 case 0x1f: /* Atmel flash. */
1635 /* 512k sector size. */
1636 if (flash_id
== 0x13) {
1637 rest_addr
= 0x7fffffff;
1638 sec_mask
= 0x80000000;
1641 /* Fall through... */
1643 case 0x01: /* AMD flash. */
1644 if (flash_id
== 0x38 || flash_id
== 0x40 ||
1646 /* Am29LV081 part - 64kb sector size. */
1647 /* Am29LV002BT part - 64kb sector size. */
1651 } else if (flash_id
== 0x3e) {
1653 * Am29LV008b part - 64kb sector size with
1654 * 32kb,8kb,8kb,16kb sector at memory address
1660 } else if (flash_id
== 0x20 || flash_id
== 0x6e) {
1662 * Am29LV010 part or AM29f010 - 16kb sector
1668 } else if (flash_id
== 0x6d) {
1669 /* Am29LV001 part - 8kb sector size. */
1675 /* Default to 16 kb sector size. */
1682 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1683 if (qla2x00_erase_flash(ha
, man_id
, flash_id
)) {
1684 rval
= QLA_FUNCTION_FAILED
;
1689 for (addr
= offset
, liter
= 0; liter
< length
; liter
++,
1692 /* Are we at the beginning of a sector? */
1693 if ((addr
& rest_addr
) == 0) {
1694 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
1695 if (addr
>= 0x10000UL
) {
1696 if (((addr
>> 12) & 0xf0) &&
1698 flash_id
== 0x3e) ||
1700 flash_id
== 0xd2))) {
1702 if (sec_number
== 1) {
1723 } else if (addr
== ha
->optrom_size
/ 2) {
1724 WRT_REG_WORD(®
->nvram
, NVR_SELECT
);
1725 RD_REG_WORD(®
->nvram
);
1728 if (flash_id
== 0xda && man_id
== 0xc1) {
1729 qla2x00_write_flash_byte(ha
, 0x5555,
1731 qla2x00_write_flash_byte(ha
, 0x2aaa,
1733 qla2x00_write_flash_byte(ha
, 0x5555,
1735 } else if (!IS_QLA2322(ha
) && !IS_QLA6322(ha
)) {
1737 if (qla2x00_erase_flash_sector(ha
,
1738 addr
, sec_mask
, man_id
,
1740 rval
= QLA_FUNCTION_FAILED
;
1743 if (man_id
== 0x01 && flash_id
== 0x6d)
1748 if (man_id
== 0x01 && flash_id
== 0x6d) {
1749 if (sec_number
== 1 &&
1750 addr
== (rest_addr
- 1)) {
1753 } else if (sec_number
== 3 && (addr
& 0x7ffe)) {
1759 if (qla2x00_program_flash_address(ha
, addr
, data
,
1760 man_id
, flash_id
)) {
1761 rval
= QLA_FUNCTION_FAILED
;
1767 qla2x00_flash_disable(ha
);
1770 qla2x00_resume_hba(ha
);
1776 qla24xx_read_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1777 uint32_t offset
, uint32_t length
)
1780 scsi_block_requests(ha
->host
);
1781 set_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1784 qla24xx_read_flash_data(ha
, (uint32_t *)buf
, offset
>> 2, length
>> 2);
1787 clear_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1788 scsi_unblock_requests(ha
->host
);
1794 qla24xx_write_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1795 uint32_t offset
, uint32_t length
)
1800 scsi_block_requests(ha
->host
);
1801 set_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1803 /* Go with write. */
1804 rval
= qla24xx_write_flash_data(ha
, (uint32_t *)buf
, offset
>> 2,
1807 /* Resume HBA -- RISC reset needed. */
1808 clear_bit(MBX_UPDATE_FLASH_ACTIVE
, &ha
->mbx_cmd_flags
);
1809 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
1810 qla2xxx_wake_dpc(ha
);
1811 qla2x00_wait_for_hba_online(ha
);
1812 scsi_unblock_requests(ha
->host
);
1818 qla25xx_read_optrom_data(struct scsi_qla_host
*ha
, uint8_t *buf
,
1819 uint32_t offset
, uint32_t length
)
1822 dma_addr_t optrom_dma
;
1825 uint32_t faddr
, left
, burst
;
1829 if (length
< OPTROM_BURST_SIZE
)
1832 optrom
= dma_alloc_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
,
1833 &optrom_dma
, GFP_KERNEL
);
1835 qla_printk(KERN_DEBUG
, ha
,
1836 "Unable to allocate memory for optrom burst read "
1837 "(%x KB).\n", OPTROM_BURST_SIZE
/ 1024);
1843 faddr
= offset
>> 2;
1845 burst
= OPTROM_BURST_DWORDS
;
1850 rval
= qla2x00_dump_ram(ha
, optrom_dma
,
1851 flash_data_to_access_addr(faddr
), burst
);
1853 qla_printk(KERN_WARNING
, ha
,
1854 "Unable to burst-read optrom segment "
1855 "(%x/%x/%llx).\n", rval
,
1856 flash_data_to_access_addr(faddr
), optrom_dma
);
1857 qla_printk(KERN_WARNING
, ha
,
1858 "Reverting to slow-read.\n");
1860 dma_free_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
,
1861 optrom
, optrom_dma
);
1865 memcpy(pbuf
, optrom
, burst
* 4);
1872 dma_free_coherent(&ha
->pdev
->dev
, OPTROM_BURST_SIZE
, optrom
,
1878 return qla24xx_read_optrom_data(ha
, buf
, offset
, length
);
1882 * qla2x00_get_fcode_version() - Determine an FCODE image's version.
1884 * @pcids: Pointer to the FCODE PCI data structure
1886 * The process of retrieving the FCODE version information is at best
1887 * described as interesting.
1889 * Within the first 100h bytes of the image an ASCII string is present
1890 * which contains several pieces of information including the FCODE
1891 * version. Unfortunately it seems the only reliable way to retrieve
1892 * the version is by scanning for another sentinel within the string,
1893 * the FCODE build date:
1895 * ... 2.00.02 10/17/02 ...
1897 * Returns QLA_SUCCESS on successful retrieval of version.
1900 qla2x00_get_fcode_version(scsi_qla_host_t
*ha
, uint32_t pcids
)
1902 int ret
= QLA_FUNCTION_FAILED
;
1903 uint32_t istart
, iend
, iter
, vend
;
1904 uint8_t do_next
, rbyte
, *vbyte
;
1906 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
1908 /* Skip the PCI data structure. */
1910 ((qla2x00_read_flash_byte(ha
, pcids
+ 0x0B) << 8) |
1911 qla2x00_read_flash_byte(ha
, pcids
+ 0x0A));
1912 iend
= istart
+ 0x100;
1914 /* Scan for the sentinel date string...eeewww. */
1917 while ((iter
< iend
) && !do_next
) {
1919 if (qla2x00_read_flash_byte(ha
, iter
) == '/') {
1920 if (qla2x00_read_flash_byte(ha
, iter
+ 2) ==
1923 else if (qla2x00_read_flash_byte(ha
,
1931 /* Backtrack to previous ' ' (space). */
1933 while ((iter
> istart
) && !do_next
) {
1935 if (qla2x00_read_flash_byte(ha
, iter
) == ' ')
1942 * Mark end of version tag, and find previous ' ' (space) or
1943 * string length (recent FCODE images -- major hack ahead!!!).
1947 while ((iter
> istart
) && !do_next
) {
1949 rbyte
= qla2x00_read_flash_byte(ha
, iter
);
1950 if (rbyte
== ' ' || rbyte
== 0xd || rbyte
== 0x10)
1956 /* Mark beginning of version tag, and copy data. */
1958 if ((vend
- iter
) &&
1959 ((vend
- iter
) < sizeof(ha
->fcode_revision
))) {
1960 vbyte
= ha
->fcode_revision
;
1961 while (iter
<= vend
) {
1962 *vbyte
++ = qla2x00_read_flash_byte(ha
, iter
);
1969 if (ret
!= QLA_SUCCESS
)
1970 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
1974 qla2x00_get_flash_version(scsi_qla_host_t
*ha
, void *mbuf
)
1976 int ret
= QLA_SUCCESS
;
1977 uint8_t code_type
, last_image
;
1978 uint32_t pcihdr
, pcids
;
1982 if (!ha
->pio_address
|| !mbuf
)
1983 return QLA_FUNCTION_FAILED
;
1985 memset(ha
->bios_revision
, 0, sizeof(ha
->bios_revision
));
1986 memset(ha
->efi_revision
, 0, sizeof(ha
->efi_revision
));
1987 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
1988 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
1990 qla2x00_flash_enable(ha
);
1992 /* Begin with first PCI expansion ROM header. */
1996 /* Verify PCI expansion ROM header. */
1997 if (qla2x00_read_flash_byte(ha
, pcihdr
) != 0x55 ||
1998 qla2x00_read_flash_byte(ha
, pcihdr
+ 0x01) != 0xaa) {
2000 DEBUG2(printk("scsi(%ld): No matching ROM "
2001 "signature.\n", ha
->host_no
));
2002 ret
= QLA_FUNCTION_FAILED
;
2006 /* Locate PCI data structure. */
2008 ((qla2x00_read_flash_byte(ha
, pcihdr
+ 0x19) << 8) |
2009 qla2x00_read_flash_byte(ha
, pcihdr
+ 0x18));
2011 /* Validate signature of PCI data structure. */
2012 if (qla2x00_read_flash_byte(ha
, pcids
) != 'P' ||
2013 qla2x00_read_flash_byte(ha
, pcids
+ 0x1) != 'C' ||
2014 qla2x00_read_flash_byte(ha
, pcids
+ 0x2) != 'I' ||
2015 qla2x00_read_flash_byte(ha
, pcids
+ 0x3) != 'R') {
2016 /* Incorrect header. */
2017 DEBUG2(printk("%s(): PCI data struct not found "
2018 "pcir_adr=%x.\n", __func__
, pcids
));
2019 ret
= QLA_FUNCTION_FAILED
;
2024 code_type
= qla2x00_read_flash_byte(ha
, pcids
+ 0x14);
2025 switch (code_type
) {
2026 case ROM_CODE_TYPE_BIOS
:
2027 /* Intel x86, PC-AT compatible. */
2028 ha
->bios_revision
[0] =
2029 qla2x00_read_flash_byte(ha
, pcids
+ 0x12);
2030 ha
->bios_revision
[1] =
2031 qla2x00_read_flash_byte(ha
, pcids
+ 0x13);
2032 DEBUG3(printk("%s(): read BIOS %d.%d.\n", __func__
,
2033 ha
->bios_revision
[1], ha
->bios_revision
[0]));
2035 case ROM_CODE_TYPE_FCODE
:
2036 /* Open Firmware standard for PCI (FCode). */
2038 qla2x00_get_fcode_version(ha
, pcids
);
2040 case ROM_CODE_TYPE_EFI
:
2041 /* Extensible Firmware Interface (EFI). */
2042 ha
->efi_revision
[0] =
2043 qla2x00_read_flash_byte(ha
, pcids
+ 0x12);
2044 ha
->efi_revision
[1] =
2045 qla2x00_read_flash_byte(ha
, pcids
+ 0x13);
2046 DEBUG3(printk("%s(): read EFI %d.%d.\n", __func__
,
2047 ha
->efi_revision
[1], ha
->efi_revision
[0]));
2050 DEBUG2(printk("%s(): Unrecognized code type %x at "
2051 "pcids %x.\n", __func__
, code_type
, pcids
));
2055 last_image
= qla2x00_read_flash_byte(ha
, pcids
+ 0x15) & BIT_7
;
2057 /* Locate next PCI expansion ROM. */
2058 pcihdr
+= ((qla2x00_read_flash_byte(ha
, pcids
+ 0x11) << 8) |
2059 qla2x00_read_flash_byte(ha
, pcids
+ 0x10)) * 512;
2060 } while (!last_image
);
2062 if (IS_QLA2322(ha
)) {
2063 /* Read firmware image information. */
2064 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
2066 memset(dbyte
, 0, 8);
2067 dcode
= (uint16_t *)dbyte
;
2069 qla2x00_read_flash_data(ha
, dbyte
, FA_RISC_CODE_ADDR
* 4 + 10,
2071 DEBUG3(printk("%s(%ld): dumping fw ver from flash:\n",
2072 __func__
, ha
->host_no
));
2073 DEBUG3(qla2x00_dump_buffer((uint8_t *)dbyte
, 8));
2075 if ((dcode
[0] == 0xffff && dcode
[1] == 0xffff &&
2076 dcode
[2] == 0xffff && dcode
[3] == 0xffff) ||
2077 (dcode
[0] == 0 && dcode
[1] == 0 && dcode
[2] == 0 &&
2079 DEBUG2(printk("%s(): Unrecognized fw revision at "
2080 "%x.\n", __func__
, FA_RISC_CODE_ADDR
* 4));
2082 /* values are in big endian */
2083 ha
->fw_revision
[0] = dbyte
[0] << 16 | dbyte
[1];
2084 ha
->fw_revision
[1] = dbyte
[2] << 16 | dbyte
[3];
2085 ha
->fw_revision
[2] = dbyte
[4] << 16 | dbyte
[5];
2089 qla2x00_flash_disable(ha
);
2095 qla24xx_get_flash_version(scsi_qla_host_t
*ha
, void *mbuf
)
2097 int ret
= QLA_SUCCESS
;
2098 uint32_t pcihdr
, pcids
;
2101 uint8_t code_type
, last_image
;
2105 return QLA_FUNCTION_FAILED
;
2107 memset(ha
->bios_revision
, 0, sizeof(ha
->bios_revision
));
2108 memset(ha
->efi_revision
, 0, sizeof(ha
->efi_revision
));
2109 memset(ha
->fcode_revision
, 0, sizeof(ha
->fcode_revision
));
2110 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
2114 /* Begin with first PCI expansion ROM header. */
2118 /* Verify PCI expansion ROM header. */
2119 qla24xx_read_flash_data(ha
, dcode
, pcihdr
>> 2, 0x20);
2120 bcode
= mbuf
+ (pcihdr
% 4);
2121 if (bcode
[0x0] != 0x55 || bcode
[0x1] != 0xaa) {
2123 DEBUG2(printk("scsi(%ld): No matching ROM "
2124 "signature.\n", ha
->host_no
));
2125 ret
= QLA_FUNCTION_FAILED
;
2129 /* Locate PCI data structure. */
2130 pcids
= pcihdr
+ ((bcode
[0x19] << 8) | bcode
[0x18]);
2132 qla24xx_read_flash_data(ha
, dcode
, pcids
>> 2, 0x20);
2133 bcode
= mbuf
+ (pcihdr
% 4);
2135 /* Validate signature of PCI data structure. */
2136 if (bcode
[0x0] != 'P' || bcode
[0x1] != 'C' ||
2137 bcode
[0x2] != 'I' || bcode
[0x3] != 'R') {
2138 /* Incorrect header. */
2139 DEBUG2(printk("%s(): PCI data struct not found "
2140 "pcir_adr=%x.\n", __func__
, pcids
));
2141 ret
= QLA_FUNCTION_FAILED
;
2146 code_type
= bcode
[0x14];
2147 switch (code_type
) {
2148 case ROM_CODE_TYPE_BIOS
:
2149 /* Intel x86, PC-AT compatible. */
2150 ha
->bios_revision
[0] = bcode
[0x12];
2151 ha
->bios_revision
[1] = bcode
[0x13];
2152 DEBUG3(printk("%s(): read BIOS %d.%d.\n", __func__
,
2153 ha
->bios_revision
[1], ha
->bios_revision
[0]));
2155 case ROM_CODE_TYPE_FCODE
:
2156 /* Open Firmware standard for PCI (FCode). */
2157 ha
->fcode_revision
[0] = bcode
[0x12];
2158 ha
->fcode_revision
[1] = bcode
[0x13];
2159 DEBUG3(printk("%s(): read FCODE %d.%d.\n", __func__
,
2160 ha
->fcode_revision
[1], ha
->fcode_revision
[0]));
2162 case ROM_CODE_TYPE_EFI
:
2163 /* Extensible Firmware Interface (EFI). */
2164 ha
->efi_revision
[0] = bcode
[0x12];
2165 ha
->efi_revision
[1] = bcode
[0x13];
2166 DEBUG3(printk("%s(): read EFI %d.%d.\n", __func__
,
2167 ha
->efi_revision
[1], ha
->efi_revision
[0]));
2170 DEBUG2(printk("%s(): Unrecognized code type %x at "
2171 "pcids %x.\n", __func__
, code_type
, pcids
));
2175 last_image
= bcode
[0x15] & BIT_7
;
2177 /* Locate next PCI expansion ROM. */
2178 pcihdr
+= ((bcode
[0x11] << 8) | bcode
[0x10]) * 512;
2179 } while (!last_image
);
2181 /* Read firmware image information. */
2182 memset(ha
->fw_revision
, 0, sizeof(ha
->fw_revision
));
2185 qla24xx_read_flash_data(ha
, dcode
, FA_RISC_CODE_ADDR
+ 4, 4);
2186 for (i
= 0; i
< 4; i
++)
2187 dcode
[i
] = be32_to_cpu(dcode
[i
]);
2189 if ((dcode
[0] == 0xffffffff && dcode
[1] == 0xffffffff &&
2190 dcode
[2] == 0xffffffff && dcode
[3] == 0xffffffff) ||
2191 (dcode
[0] == 0 && dcode
[1] == 0 && dcode
[2] == 0 &&
2193 DEBUG2(printk("%s(): Unrecognized fw version at %x.\n",
2194 __func__
, FA_RISC_CODE_ADDR
));
2196 ha
->fw_revision
[0] = dcode
[0];
2197 ha
->fw_revision
[1] = dcode
[1];
2198 ha
->fw_revision
[2] = dcode
[2];
2199 ha
->fw_revision
[3] = dcode
[3];