diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_sup.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_sup.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index 303f8ee11f25..284827926eff 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c | |||
@@ -684,7 +684,7 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr) | |||
684 | "end=0x%x size=0x%x.\n", le32_to_cpu(region->code), start, | 684 | "end=0x%x size=0x%x.\n", le32_to_cpu(region->code), start, |
685 | le32_to_cpu(region->end) >> 2, le32_to_cpu(region->size))); | 685 | le32_to_cpu(region->end) >> 2, le32_to_cpu(region->size))); |
686 | 686 | ||
687 | switch (le32_to_cpu(region->code)) { | 687 | switch (le32_to_cpu(region->code) & 0xff) { |
688 | case FLT_REG_FW: | 688 | case FLT_REG_FW: |
689 | ha->flt_region_fw = start; | 689 | ha->flt_region_fw = start; |
690 | break; | 690 | break; |
@@ -944,9 +944,9 @@ qla24xx_unprotect_flash(struct qla_hw_data *ha) | |||
944 | if (!ha->fdt_wrt_disable) | 944 | if (!ha->fdt_wrt_disable) |
945 | return; | 945 | return; |
946 | 946 | ||
947 | /* Disable flash write-protection. */ | 947 | /* Disable flash write-protection, first clear SR protection bit */ |
948 | qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); | 948 | qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); |
949 | /* Some flash parts need an additional zero-write to clear bits.*/ | 949 | /* Then write zero again to clear remaining SR bits.*/ |
950 | qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); | 950 | qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0); |
951 | } | 951 | } |
952 | 952 | ||
@@ -980,12 +980,11 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, | |||
980 | uint32_t dwords) | 980 | uint32_t dwords) |
981 | { | 981 | { |
982 | int ret; | 982 | int ret; |
983 | uint32_t liter, miter; | 983 | uint32_t liter; |
984 | uint32_t sec_mask, rest_addr; | 984 | uint32_t sec_mask, rest_addr; |
985 | uint32_t fdata, findex; | 985 | uint32_t fdata; |
986 | dma_addr_t optrom_dma; | 986 | dma_addr_t optrom_dma; |
987 | void *optrom = NULL; | 987 | void *optrom = NULL; |
988 | uint32_t *s, *d; | ||
989 | struct qla_hw_data *ha = vha->hw; | 988 | struct qla_hw_data *ha = vha->hw; |
990 | 989 | ||
991 | ret = QLA_SUCCESS; | 990 | ret = QLA_SUCCESS; |
@@ -1003,17 +1002,15 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, | |||
1003 | } | 1002 | } |
1004 | 1003 | ||
1005 | rest_addr = (ha->fdt_block_size >> 2) - 1; | 1004 | rest_addr = (ha->fdt_block_size >> 2) - 1; |
1006 | sec_mask = (ha->optrom_size >> 2) - (ha->fdt_block_size >> 2); | 1005 | sec_mask = ~rest_addr; |
1007 | 1006 | ||
1008 | qla24xx_unprotect_flash(ha); | 1007 | qla24xx_unprotect_flash(ha); |
1009 | 1008 | ||
1010 | for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { | 1009 | for (liter = 0; liter < dwords; liter++, faddr++, dwptr++) { |
1011 | 1010 | fdata = (faddr & sec_mask) << 2; | |
1012 | findex = faddr; | ||
1013 | fdata = (findex & sec_mask) << 2; | ||
1014 | 1011 | ||
1015 | /* Are we at the beginning of a sector? */ | 1012 | /* Are we at the beginning of a sector? */ |
1016 | if ((findex & rest_addr) == 0) { | 1013 | if ((faddr & rest_addr) == 0) { |
1017 | /* Do sector unprotect. */ | 1014 | /* Do sector unprotect. */ |
1018 | if (ha->fdt_unprotect_sec_cmd) | 1015 | if (ha->fdt_unprotect_sec_cmd) |
1019 | qla24xx_write_flash_dword(ha, | 1016 | qla24xx_write_flash_dword(ha, |
@@ -1024,7 +1021,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, | |||
1024 | (fdata & 0xff00) |((fdata << 16) & | 1021 | (fdata & 0xff00) |((fdata << 16) & |
1025 | 0xff0000) | ((fdata >> 16) & 0xff)); | 1022 | 0xff0000) | ((fdata >> 16) & 0xff)); |
1026 | if (ret != QLA_SUCCESS) { | 1023 | if (ret != QLA_SUCCESS) { |
1027 | DEBUG9(qla_printk("Unable to flash sector: " | 1024 | DEBUG9(qla_printk("Unable to erase sector: " |
1028 | "address=%x.\n", faddr)); | 1025 | "address=%x.\n", faddr)); |
1029 | break; | 1026 | break; |
1030 | } | 1027 | } |
@@ -1033,9 +1030,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, | |||
1033 | /* Go with burst-write. */ | 1030 | /* Go with burst-write. */ |
1034 | if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { | 1031 | if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { |
1035 | /* Copy data to DMA'ble buffer. */ | 1032 | /* Copy data to DMA'ble buffer. */ |
1036 | for (miter = 0, s = optrom, d = dwptr; | 1033 | memcpy(optrom, dwptr, OPTROM_BURST_SIZE); |
1037 | miter < OPTROM_BURST_DWORDS; miter++, s++, d++) | ||
1038 | *s = cpu_to_le32(*d); | ||
1039 | 1034 | ||
1040 | ret = qla2x00_load_ram(vha, optrom_dma, | 1035 | ret = qla2x00_load_ram(vha, optrom_dma, |
1041 | flash_data_addr(ha, faddr), | 1036 | flash_data_addr(ha, faddr), |