aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorGiridhar Malavali <giridhar.malavali@qlogic.com>2010-09-03 18:20:52 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-09-05 14:34:58 -0400
commit77e334d240aa0a771f861656d639ea13e9fc6569 (patch)
tree78f0ca76d036c92be400939defb66fb573fbb6c5 /drivers/scsi
parent35e0cbd4b282e541d05ca21694beb26c087bb49e (diff)
[SCSI] qla2xxx: Cleanup some dead-code and make some functions static.
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h11
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c385
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.h5
3 files changed, 202 insertions, 199 deletions
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 4edfc731ea96..967bc9278bf7 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -501,7 +501,6 @@ extern void qla24xx_wrt_rsp_reg(struct qla_hw_data *, uint16_t, uint16_t);
501/* PCI related functions */ 501/* PCI related functions */
502extern int qla82xx_pci_config(struct scsi_qla_host *); 502extern int qla82xx_pci_config(struct scsi_qla_host *);
503extern int qla82xx_pci_mem_read_2M(struct qla_hw_data *, u64, void *, int); 503extern int qla82xx_pci_mem_read_2M(struct qla_hw_data *, u64, void *, int);
504extern int qla82xx_pci_mem_write_2M(struct qla_hw_data *, u64, void *, int);
505extern char *qla82xx_pci_info_str(struct scsi_qla_host *, char *); 504extern char *qla82xx_pci_info_str(struct scsi_qla_host *, char *);
506extern int qla82xx_pci_region_offset(struct pci_dev *, int); 505extern int qla82xx_pci_region_offset(struct pci_dev *, int);
507extern int qla82xx_iospace_config(struct qla_hw_data *); 506extern int qla82xx_iospace_config(struct qla_hw_data *);
@@ -509,7 +508,6 @@ extern int qla82xx_iospace_config(struct qla_hw_data *);
509/* Initialization related functions */ 508/* Initialization related functions */
510extern void qla82xx_reset_chip(struct scsi_qla_host *); 509extern void qla82xx_reset_chip(struct scsi_qla_host *);
511extern void qla82xx_config_rings(struct scsi_qla_host *); 510extern void qla82xx_config_rings(struct scsi_qla_host *);
512extern int qla82xx_pinit_from_rom(scsi_qla_host_t *);
513extern void qla82xx_watchdog(scsi_qla_host_t *); 511extern void qla82xx_watchdog(scsi_qla_host_t *);
514extern int qla82xx_start_firmware(scsi_qla_host_t *); 512extern int qla82xx_start_firmware(scsi_qla_host_t *);
515 513
@@ -534,26 +532,17 @@ extern irqreturn_t qla82xx_msix_default(int, void *);
534extern irqreturn_t qla82xx_msix_rsp_q(int, void *); 532extern irqreturn_t qla82xx_msix_rsp_q(int, void *);
535extern void qla82xx_enable_intrs(struct qla_hw_data *); 533extern void qla82xx_enable_intrs(struct qla_hw_data *);
536extern void qla82xx_disable_intrs(struct qla_hw_data *); 534extern void qla82xx_disable_intrs(struct qla_hw_data *);
537extern void qla82xx_mbx_completion(scsi_qla_host_t *, uint16_t);
538extern void qla82xx_poll(int, void *); 535extern void qla82xx_poll(int, void *);
539extern void qla82xx_init_flags(struct qla_hw_data *); 536extern void qla82xx_init_flags(struct qla_hw_data *);
540 537
541/* ISP 8021 hardware related */ 538/* ISP 8021 hardware related */
542extern void qla82xx_set_drv_active(scsi_qla_host_t *); 539extern void qla82xx_set_drv_active(scsi_qla_host_t *);
543extern int qla82xx_crb_win_lock(struct qla_hw_data *);
544extern void qla82xx_crb_win_unlock(struct qla_hw_data *); 540extern void qla82xx_crb_win_unlock(struct qla_hw_data *);
545extern int qla82xx_pci_get_crb_addr_2M(struct qla_hw_data *, ulong *);
546extern int qla82xx_wr_32(struct qla_hw_data *, ulong, u32); 541extern int qla82xx_wr_32(struct qla_hw_data *, ulong, u32);
547extern int qla82xx_rd_32(struct qla_hw_data *, ulong); 542extern int qla82xx_rd_32(struct qla_hw_data *, ulong);
548extern int qla82xx_rdmem(struct qla_hw_data *, u64, void *, int); 543extern int qla82xx_rdmem(struct qla_hw_data *, u64, void *, int);
549extern int qla82xx_wrmem(struct qla_hw_data *, u64, void *, int); 544extern int qla82xx_wrmem(struct qla_hw_data *, u64, void *, int);
550extern int qla82xx_check_for_bad_spd(struct qla_hw_data *);
551extern int qla82xx_load_fw(scsi_qla_host_t *);
552extern int qla82xx_rom_lock(struct qla_hw_data *);
553extern void qla82xx_rom_unlock(struct qla_hw_data *); 545extern void qla82xx_rom_unlock(struct qla_hw_data *);
554extern int qla82xx_rom_fast_read(struct qla_hw_data *, int , int *);
555extern int qla82xx_do_rom_fast_read(struct qla_hw_data *, int, int *);
556extern unsigned long qla82xx_decode_crb_addr(unsigned long);
557 546
558/* ISP 8021 IDC */ 547/* ISP 8021 IDC */
559extern void qla82xx_clear_drv_active(struct qla_hw_data *); 548extern void qla82xx_clear_drv_active(struct qla_hw_data *);
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 2ad91100a7e4..614d745d7e11 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -403,6 +403,54 @@ qla82xx_pci_set_crbwindow(struct qla_hw_data *ha, u64 off)
403 return off; 403 return off;
404} 404}
405 405
406static int
407qla82xx_pci_get_crb_addr_2M(struct qla_hw_data *ha, ulong *off)
408{
409 struct crb_128M_2M_sub_block_map *m;
410
411 if (*off >= QLA82XX_CRB_MAX)
412 return -1;
413
414 if (*off >= QLA82XX_PCI_CAMQM && (*off < QLA82XX_PCI_CAMQM_2M_END)) {
415 *off = (*off - QLA82XX_PCI_CAMQM) +
416 QLA82XX_PCI_CAMQM_2M_BASE + ha->nx_pcibase;
417 return 0;
418 }
419
420 if (*off < QLA82XX_PCI_CRBSPACE)
421 return -1;
422
423 *off -= QLA82XX_PCI_CRBSPACE;
424
425 /* Try direct map */
426 m = &crb_128M_2M_map[CRB_BLK(*off)].sub_block[CRB_SUBBLK(*off)];
427
428 if (m->valid && (m->start_128M <= *off) && (m->end_128M > *off)) {
429 *off = *off + m->start_2M - m->start_128M + ha->nx_pcibase;
430 return 0;
431 }
432 /* Not in direct map, use crb window */
433 return 1;
434}
435
436#define CRB_WIN_LOCK_TIMEOUT 100000000
437static int qla82xx_crb_win_lock(struct qla_hw_data *ha)
438{
439 int done = 0, timeout = 0;
440
441 while (!done) {
442 /* acquire semaphore3 from PCI HW block */
443 done = qla82xx_rd_32(ha, QLA82XX_PCIE_REG(PCIE_SEM7_LOCK));
444 if (done == 1)
445 break;
446 if (timeout >= CRB_WIN_LOCK_TIMEOUT)
447 return -1;
448 timeout++;
449 }
450 qla82xx_wr_32(ha, QLA82XX_CRB_WIN_LOCK_ID, ha->portnum);
451 return 0;
452}
453
406int 454int
407qla82xx_wr_32(struct qla_hw_data *ha, ulong off, u32 data) 455qla82xx_wr_32(struct qla_hw_data *ha, ulong off, u32 data)
408{ 456{
@@ -453,24 +501,6 @@ qla82xx_rd_32(struct qla_hw_data *ha, ulong off)
453 return data; 501 return data;
454} 502}
455 503
456#define CRB_WIN_LOCK_TIMEOUT 100000000
457int qla82xx_crb_win_lock(struct qla_hw_data *ha)
458{
459 int done = 0, timeout = 0;
460
461 while (!done) {
462 /* acquire semaphore3 from PCI HW block */
463 done = qla82xx_rd_32(ha, QLA82XX_PCIE_REG(PCIE_SEM7_LOCK));
464 if (done == 1)
465 break;
466 if (timeout >= CRB_WIN_LOCK_TIMEOUT)
467 return -1;
468 timeout++;
469 }
470 qla82xx_wr_32(ha, QLA82XX_CRB_WIN_LOCK_ID, ha->portnum);
471 return 0;
472}
473
474#define IDC_LOCK_TIMEOUT 100000000 504#define IDC_LOCK_TIMEOUT 100000000
475int qla82xx_idc_lock(struct qla_hw_data *ha) 505int qla82xx_idc_lock(struct qla_hw_data *ha)
476{ 506{
@@ -504,36 +534,6 @@ void qla82xx_idc_unlock(struct qla_hw_data *ha)
504 qla82xx_rd_32(ha, QLA82XX_PCIE_REG(PCIE_SEM5_UNLOCK)); 534 qla82xx_rd_32(ha, QLA82XX_PCIE_REG(PCIE_SEM5_UNLOCK));
505} 535}
506 536
507int
508qla82xx_pci_get_crb_addr_2M(struct qla_hw_data *ha, ulong *off)
509{
510 struct crb_128M_2M_sub_block_map *m;
511
512 if (*off >= QLA82XX_CRB_MAX)
513 return -1;
514
515 if (*off >= QLA82XX_PCI_CAMQM && (*off < QLA82XX_PCI_CAMQM_2M_END)) {
516 *off = (*off - QLA82XX_PCI_CAMQM) +
517 QLA82XX_PCI_CAMQM_2M_BASE + ha->nx_pcibase;
518 return 0;
519 }
520
521 if (*off < QLA82XX_PCI_CRBSPACE)
522 return -1;
523
524 *off -= QLA82XX_PCI_CRBSPACE;
525
526 /* Try direct map */
527 m = &crb_128M_2M_map[CRB_BLK(*off)].sub_block[CRB_SUBBLK(*off)];
528
529 if (m->valid && (m->start_128M <= *off) && (m->end_128M > *off)) {
530 *off = *off + m->start_2M - m->start_128M + ha->nx_pcibase;
531 return 0;
532 }
533 /* Not in direct map, use crb window */
534 return 1;
535}
536
537/* PCI Windowing for DDR regions. */ 537/* PCI Windowing for DDR regions. */
538#define QLA82XX_ADDR_IN_RANGE(addr, low, high) \ 538#define QLA82XX_ADDR_IN_RANGE(addr, low, high) \
539 (((addr) <= (high)) && ((addr) >= (low))) 539 (((addr) <= (high)) && ((addr) >= (low)))
@@ -557,7 +557,7 @@ qla82xx_pci_mem_bound_check(struct qla_hw_data *ha,
557 557
558int qla82xx_pci_set_window_warning_count; 558int qla82xx_pci_set_window_warning_count;
559 559
560unsigned long 560static unsigned long
561qla82xx_pci_set_window(struct qla_hw_data *ha, unsigned long long addr) 561qla82xx_pci_set_window(struct qla_hw_data *ha, unsigned long long addr)
562{ 562{
563 int window; 563 int window;
@@ -798,7 +798,8 @@ qla82xx_pci_mem_write_direct(struct qla_hw_data *ha,
798} 798}
799 799
800#define MTU_FUDGE_FACTOR 100 800#define MTU_FUDGE_FACTOR 100
801unsigned long qla82xx_decode_crb_addr(unsigned long addr) 801static unsigned long
802qla82xx_decode_crb_addr(unsigned long addr)
802{ 803{
803 int i; 804 int i;
804 unsigned long base_addr, offset, pci_base; 805 unsigned long base_addr, offset, pci_base;
@@ -824,7 +825,7 @@ unsigned long qla82xx_decode_crb_addr(unsigned long addr)
824static long rom_max_timeout = 100; 825static long rom_max_timeout = 100;
825static long qla82xx_rom_lock_timeout = 100; 826static long qla82xx_rom_lock_timeout = 100;
826 827
827int 828static int
828qla82xx_rom_lock(struct qla_hw_data *ha) 829qla82xx_rom_lock(struct qla_hw_data *ha)
829{ 830{
830 int done = 0, timeout = 0; 831 int done = 0, timeout = 0;
@@ -842,7 +843,7 @@ qla82xx_rom_lock(struct qla_hw_data *ha)
842 return 0; 843 return 0;
843} 844}
844 845
845int 846static int
846qla82xx_wait_rom_busy(struct qla_hw_data *ha) 847qla82xx_wait_rom_busy(struct qla_hw_data *ha)
847{ 848{
848 long timeout = 0; 849 long timeout = 0;
@@ -862,7 +863,7 @@ qla82xx_wait_rom_busy(struct qla_hw_data *ha)
862 return 0; 863 return 0;
863} 864}
864 865
865int 866static int
866qla82xx_wait_rom_done(struct qla_hw_data *ha) 867qla82xx_wait_rom_done(struct qla_hw_data *ha)
867{ 868{
868 long timeout = 0; 869 long timeout = 0;
@@ -882,7 +883,7 @@ qla82xx_wait_rom_done(struct qla_hw_data *ha)
882 return 0; 883 return 0;
883} 884}
884 885
885int 886static int
886qla82xx_do_rom_fast_read(struct qla_hw_data *ha, int addr, int *valp) 887qla82xx_do_rom_fast_read(struct qla_hw_data *ha, int addr, int *valp)
887{ 888{
888 qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_ADDRESS, addr); 889 qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_ADDRESS, addr);
@@ -905,7 +906,7 @@ qla82xx_do_rom_fast_read(struct qla_hw_data *ha, int addr, int *valp)
905 return 0; 906 return 0;
906} 907}
907 908
908int 909static int
909qla82xx_rom_fast_read(struct qla_hw_data *ha, int addr, int *valp) 910qla82xx_rom_fast_read(struct qla_hw_data *ha, int addr, int *valp)
910{ 911{
911 int ret, loops = 0; 912 int ret, loops = 0;
@@ -926,7 +927,7 @@ qla82xx_rom_fast_read(struct qla_hw_data *ha, int addr, int *valp)
926 return ret; 927 return ret;
927} 928}
928 929
929int 930static int
930qla82xx_read_status_reg(struct qla_hw_data *ha, uint32_t *val) 931qla82xx_read_status_reg(struct qla_hw_data *ha, uint32_t *val)
931{ 932{
932 qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_RDSR); 933 qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_RDSR);
@@ -940,7 +941,7 @@ qla82xx_read_status_reg(struct qla_hw_data *ha, uint32_t *val)
940 return 0; 941 return 0;
941} 942}
942 943
943int 944static int
944qla82xx_flash_wait_write_finish(struct qla_hw_data *ha) 945qla82xx_flash_wait_write_finish(struct qla_hw_data *ha)
945{ 946{
946 long timeout = 0; 947 long timeout = 0;
@@ -964,7 +965,7 @@ qla82xx_flash_wait_write_finish(struct qla_hw_data *ha)
964 return ret; 965 return ret;
965} 966}
966 967
967int 968static int
968qla82xx_flash_set_write_enable(struct qla_hw_data *ha) 969qla82xx_flash_set_write_enable(struct qla_hw_data *ha)
969{ 970{
970 uint32_t val; 971 uint32_t val;
@@ -981,7 +982,7 @@ qla82xx_flash_set_write_enable(struct qla_hw_data *ha)
981 return 0; 982 return 0;
982} 983}
983 984
984int 985static int
985qla82xx_write_status_reg(struct qla_hw_data *ha, uint32_t val) 986qla82xx_write_status_reg(struct qla_hw_data *ha, uint32_t val)
986{ 987{
987 if (qla82xx_flash_set_write_enable(ha)) 988 if (qla82xx_flash_set_write_enable(ha))
@@ -996,7 +997,7 @@ qla82xx_write_status_reg(struct qla_hw_data *ha, uint32_t val)
996 return qla82xx_flash_wait_write_finish(ha); 997 return qla82xx_flash_wait_write_finish(ha);
997} 998}
998 999
999int 1000static int
1000qla82xx_write_disable_flash(struct qla_hw_data *ha) 1001qla82xx_write_disable_flash(struct qla_hw_data *ha)
1001{ 1002{
1002 qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_WRDI); 1003 qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_WRDI);
@@ -1008,7 +1009,7 @@ qla82xx_write_disable_flash(struct qla_hw_data *ha)
1008 return 0; 1009 return 0;
1009} 1010}
1010 1011
1011int 1012static int
1012ql82xx_rom_lock_d(struct qla_hw_data *ha) 1013ql82xx_rom_lock_d(struct qla_hw_data *ha)
1013{ 1014{
1014 int loops = 0; 1015 int loops = 0;
@@ -1024,7 +1025,7 @@ ql82xx_rom_lock_d(struct qla_hw_data *ha)
1024 return 0;; 1025 return 0;;
1025} 1026}
1026 1027
1027int 1028static int
1028qla82xx_write_flash_dword(struct qla_hw_data *ha, uint32_t flashaddr, 1029qla82xx_write_flash_dword(struct qla_hw_data *ha, uint32_t flashaddr,
1029 uint32_t data) 1030 uint32_t data)
1030{ 1031{
@@ -1061,7 +1062,8 @@ done_write:
1061/* This routine does CRB initialize sequence 1062/* This routine does CRB initialize sequence
1062 * to put the ISP into operational state 1063 * to put the ISP into operational state
1063 */ 1064 */
1064int qla82xx_pinit_from_rom(scsi_qla_host_t *vha) 1065static int
1066qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
1065{ 1067{
1066 int addr, val; 1068 int addr, val;
1067 int i ; 1069 int i ;
@@ -1207,7 +1209,8 @@ int qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
1207 return 0; 1209 return 0;
1208} 1210}
1209 1211
1210int qla82xx_check_for_bad_spd(struct qla_hw_data *ha) 1212static int
1213qla82xx_check_for_bad_spd(struct qla_hw_data *ha)
1211{ 1214{
1212 u32 val = 0; 1215 u32 val = 0;
1213 val = qla82xx_rd_32(ha, BOOT_LOADER_DIMM_STATUS); 1216 val = qla82xx_rd_32(ha, BOOT_LOADER_DIMM_STATUS);
@@ -1225,7 +1228,116 @@ int qla82xx_check_for_bad_spd(struct qla_hw_data *ha)
1225 return 0; 1228 return 0;
1226} 1229}
1227 1230
1228int 1231static int
1232qla82xx_pci_mem_write_2M(struct qla_hw_data *ha,
1233 u64 off, void *data, int size)
1234{
1235 int i, j, ret = 0, loop, sz[2], off0;
1236 int scale, shift_amount, startword;
1237 uint32_t temp;
1238 uint64_t off8, mem_crb, tmpw, word[2] = {0, 0};
1239
1240 /*
1241 * If not MN, go check for MS or invalid.
1242 */
1243 if (off >= QLA82XX_ADDR_QDR_NET && off <= QLA82XX_P3_ADDR_QDR_NET_MAX)
1244 mem_crb = QLA82XX_CRB_QDR_NET;
1245 else {
1246 mem_crb = QLA82XX_CRB_DDR_NET;
1247 if (qla82xx_pci_mem_bound_check(ha, off, size) == 0)
1248 return qla82xx_pci_mem_write_direct(ha,
1249 off, data, size);
1250 }
1251
1252 off0 = off & 0x7;
1253 sz[0] = (size < (8 - off0)) ? size : (8 - off0);
1254 sz[1] = size - sz[0];
1255
1256 off8 = off & 0xfffffff0;
1257 loop = (((off & 0xf) + size - 1) >> 4) + 1;
1258 shift_amount = 4;
1259 scale = 2;
1260 startword = (off & 0xf)/8;
1261
1262 for (i = 0; i < loop; i++) {
1263 if (qla82xx_pci_mem_read_2M(ha, off8 +
1264 (i << shift_amount), &word[i * scale], 8))
1265 return -1;
1266 }
1267
1268 switch (size) {
1269 case 1:
1270 tmpw = *((uint8_t *)data);
1271 break;
1272 case 2:
1273 tmpw = *((uint16_t *)data);
1274 break;
1275 case 4:
1276 tmpw = *((uint32_t *)data);
1277 break;
1278 case 8:
1279 default:
1280 tmpw = *((uint64_t *)data);
1281 break;
1282 }
1283
1284 if (sz[0] == 8) {
1285 word[startword] = tmpw;
1286 } else {
1287 word[startword] &=
1288 ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8));
1289 word[startword] |= tmpw << (off0 * 8);
1290 }
1291 if (sz[1] != 0) {
1292 word[startword+1] &= ~(~0ULL << (sz[1] * 8));
1293 word[startword+1] |= tmpw >> (sz[0] * 8);
1294 }
1295
1296 /*
1297 * don't lock here - write_wx gets the lock if each time
1298 * write_lock_irqsave(&adapter->adapter_lock, flags);
1299 * netxen_nic_pci_change_crbwindow_128M(adapter, 0);
1300 */
1301 for (i = 0; i < loop; i++) {
1302 temp = off8 + (i << shift_amount);
1303 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_ADDR_LO, temp);
1304 temp = 0;
1305 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_ADDR_HI, temp);
1306 temp = word[i * scale] & 0xffffffff;
1307 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_WRDATA_LO, temp);
1308 temp = (word[i * scale] >> 32) & 0xffffffff;
1309 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_WRDATA_HI, temp);
1310 temp = word[i*scale + 1] & 0xffffffff;
1311 qla82xx_wr_32(ha, mem_crb +
1312 MIU_TEST_AGT_WRDATA_UPPER_LO, temp);
1313 temp = (word[i*scale + 1] >> 32) & 0xffffffff;
1314 qla82xx_wr_32(ha, mem_crb +
1315 MIU_TEST_AGT_WRDATA_UPPER_HI, temp);
1316
1317 temp = MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1318 qla82xx_wr_32(ha, mem_crb + MIU_TEST_AGT_CTRL, temp);
1319 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1320 qla82xx_wr_32(ha, mem_crb + MIU_TEST_AGT_CTRL, temp);
1321
1322 for (j = 0; j < MAX_CTL_CHECK; j++) {
1323 temp = qla82xx_rd_32(ha, mem_crb + MIU_TEST_AGT_CTRL);
1324 if ((temp & MIU_TA_CTL_BUSY) == 0)
1325 break;
1326 }
1327
1328 if (j >= MAX_CTL_CHECK) {
1329 if (printk_ratelimit())
1330 dev_err(&ha->pdev->dev,
1331 "failed to write through agent\n");
1332 ret = -1;
1333 break;
1334 }
1335 }
1336
1337 return ret;
1338}
1339
1340static int
1229qla82xx_fw_load_from_flash(struct qla_hw_data *ha) 1341qla82xx_fw_load_from_flash(struct qla_hw_data *ha)
1230{ 1342{
1231 int i; 1343 int i;
@@ -1357,114 +1469,6 @@ qla82xx_pci_mem_read_2M(struct qla_hw_data *ha,
1357 return 0; 1469 return 0;
1358} 1470}
1359 1471
1360int
1361qla82xx_pci_mem_write_2M(struct qla_hw_data *ha,
1362 u64 off, void *data, int size)
1363{
1364 int i, j, ret = 0, loop, sz[2], off0;
1365 int scale, shift_amount, startword;
1366 uint32_t temp;
1367 uint64_t off8, mem_crb, tmpw, word[2] = {0, 0};
1368
1369 /*
1370 * If not MN, go check for MS or invalid.
1371 */
1372 if (off >= QLA82XX_ADDR_QDR_NET && off <= QLA82XX_P3_ADDR_QDR_NET_MAX)
1373 mem_crb = QLA82XX_CRB_QDR_NET;
1374 else {
1375 mem_crb = QLA82XX_CRB_DDR_NET;
1376 if (qla82xx_pci_mem_bound_check(ha, off, size) == 0)
1377 return qla82xx_pci_mem_write_direct(ha,
1378 off, data, size);
1379 }
1380
1381 off0 = off & 0x7;
1382 sz[0] = (size < (8 - off0)) ? size : (8 - off0);
1383 sz[1] = size - sz[0];
1384
1385 off8 = off & 0xfffffff0;
1386 loop = (((off & 0xf) + size - 1) >> 4) + 1;
1387 shift_amount = 4;
1388 scale = 2;
1389 startword = (off & 0xf)/8;
1390
1391 for (i = 0; i < loop; i++) {
1392 if (qla82xx_pci_mem_read_2M(ha, off8 +
1393 (i << shift_amount), &word[i * scale], 8))
1394 return -1;
1395 }
1396
1397 switch (size) {
1398 case 1:
1399 tmpw = *((uint8_t *)data);
1400 break;
1401 case 2:
1402 tmpw = *((uint16_t *)data);
1403 break;
1404 case 4:
1405 tmpw = *((uint32_t *)data);
1406 break;
1407 case 8:
1408 default:
1409 tmpw = *((uint64_t *)data);
1410 break;
1411 }
1412
1413 if (sz[0] == 8) {
1414 word[startword] = tmpw;
1415 } else {
1416 word[startword] &=
1417 ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8));
1418 word[startword] |= tmpw << (off0 * 8);
1419 }
1420 if (sz[1] != 0) {
1421 word[startword+1] &= ~(~0ULL << (sz[1] * 8));
1422 word[startword+1] |= tmpw >> (sz[0] * 8);
1423 }
1424
1425 /*
1426 * don't lock here - write_wx gets the lock if each time
1427 * write_lock_irqsave(&adapter->adapter_lock, flags);
1428 * netxen_nic_pci_change_crbwindow_128M(adapter, 0);
1429 */
1430 for (i = 0; i < loop; i++) {
1431 temp = off8 + (i << shift_amount);
1432 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_ADDR_LO, temp);
1433 temp = 0;
1434 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_ADDR_HI, temp);
1435 temp = word[i * scale] & 0xffffffff;
1436 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_WRDATA_LO, temp);
1437 temp = (word[i * scale] >> 32) & 0xffffffff;
1438 qla82xx_wr_32(ha, mem_crb+MIU_TEST_AGT_WRDATA_HI, temp);
1439 temp = word[i*scale + 1] & 0xffffffff;
1440 qla82xx_wr_32(ha, mem_crb +
1441 MIU_TEST_AGT_WRDATA_UPPER_LO, temp);
1442 temp = (word[i*scale + 1] >> 32) & 0xffffffff;
1443 qla82xx_wr_32(ha, mem_crb +
1444 MIU_TEST_AGT_WRDATA_UPPER_HI, temp);
1445
1446 temp = MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1447 qla82xx_wr_32(ha, mem_crb + MIU_TEST_AGT_CTRL, temp);
1448 temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE;
1449 qla82xx_wr_32(ha, mem_crb + MIU_TEST_AGT_CTRL, temp);
1450
1451 for (j = 0; j < MAX_CTL_CHECK; j++) {
1452 temp = qla82xx_rd_32(ha, mem_crb + MIU_TEST_AGT_CTRL);
1453 if ((temp & MIU_TA_CTL_BUSY) == 0)
1454 break;
1455 }
1456
1457 if (j >= MAX_CTL_CHECK) {
1458 if (printk_ratelimit())
1459 dev_err(&ha->pdev->dev,
1460 "failed to write through agent\n");
1461 ret = -1;
1462 break;
1463 }
1464 }
1465
1466 return ret;
1467}
1468 1472
1469static struct qla82xx_uri_table_desc * 1473static struct qla82xx_uri_table_desc *
1470qla82xx_get_table_desc(const u8 *unirom, int section) 1474qla82xx_get_table_desc(const u8 *unirom, int section)
@@ -1725,7 +1729,8 @@ void qla82xx_reset_adapter(struct scsi_qla_host *vha)
1725 ha->isp_ops->disable_intrs(ha); 1729 ha->isp_ops->disable_intrs(ha);
1726} 1730}
1727 1731
1728int qla82xx_fw_load_from_blob(struct qla_hw_data *ha) 1732static int
1733qla82xx_fw_load_from_blob(struct qla_hw_data *ha)
1729{ 1734{
1730 u64 *ptr64; 1735 u64 *ptr64;
1731 u32 i, flashaddr, size; 1736 u32 i, flashaddr, size;
@@ -1836,7 +1841,8 @@ qla82xx_validate_firmware_blob(scsi_qla_host_t *vha, uint8_t fw_type)
1836 return 0; 1841 return 0;
1837} 1842}
1838 1843
1839int qla82xx_check_cmdpeg_state(struct qla_hw_data *ha) 1844static int
1845qla82xx_check_cmdpeg_state(struct qla_hw_data *ha)
1840{ 1846{
1841 u32 val = 0; 1847 u32 val = 0;
1842 int retries = 60; 1848 int retries = 60;
@@ -1874,7 +1880,8 @@ int qla82xx_check_cmdpeg_state(struct qla_hw_data *ha)
1874 return QLA_FUNCTION_FAILED; 1880 return QLA_FUNCTION_FAILED;
1875} 1881}
1876 1882
1877int qla82xx_check_rcvpeg_state(struct qla_hw_data *ha) 1883static int
1884qla82xx_check_rcvpeg_state(struct qla_hw_data *ha)
1878{ 1885{
1879 u32 val = 0; 1886 u32 val = 0;
1880 int retries = 60; 1887 int retries = 60;
@@ -1933,7 +1940,7 @@ static struct qla82xx_legacy_intr_set legacy_intr[] = \
1933 * @ha: SCSI driver HA context 1940 * @ha: SCSI driver HA context
1934 * @mb0: Mailbox0 register 1941 * @mb0: Mailbox0 register
1935 */ 1942 */
1936void 1943static void
1937qla82xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) 1944qla82xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0)
1938{ 1945{
1939 uint16_t cnt; 1946 uint16_t cnt;
@@ -2267,10 +2274,11 @@ qla82xx_set_drv_active(scsi_qla_host_t *vha)
2267 2274
2268 /* If reset value is all FF's, initialize DRV_ACTIVE */ 2275 /* If reset value is all FF's, initialize DRV_ACTIVE */
2269 if (drv_active == 0xffffffff) { 2276 if (drv_active == 0xffffffff) {
2270 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_ACTIVE, 0); 2277 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_ACTIVE,
2278 QLA82XX_DRV_NOT_ACTIVE);
2271 drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); 2279 drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE);
2272 } 2280 }
2273 drv_active |= (1 << (ha->portnum * 4)); 2281 drv_active |= (QLA82XX_DRV_ACTIVE << (ha->portnum * 4));
2274 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_ACTIVE, drv_active); 2282 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_ACTIVE, drv_active);
2275} 2283}
2276 2284
@@ -2280,7 +2288,7 @@ qla82xx_clear_drv_active(struct qla_hw_data *ha)
2280 uint32_t drv_active; 2288 uint32_t drv_active;
2281 2289
2282 drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); 2290 drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE);
2283 drv_active &= ~(1 << (ha->portnum * 4)); 2291 drv_active &= ~(QLA82XX_DRV_ACTIVE << (ha->portnum * 4));
2284 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_ACTIVE, drv_active); 2292 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_ACTIVE, drv_active);
2285} 2293}
2286 2294
@@ -2291,7 +2299,7 @@ qla82xx_need_reset(struct qla_hw_data *ha)
2291 int rval; 2299 int rval;
2292 2300
2293 drv_state = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_STATE); 2301 drv_state = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_STATE);
2294 rval = drv_state & (1 << (ha->portnum * 4)); 2302 rval = drv_state & (QLA82XX_DRVST_RST_RDY << (ha->portnum * 4));
2295 return rval; 2303 return rval;
2296} 2304}
2297 2305
@@ -2305,7 +2313,7 @@ qla82xx_set_rst_ready(struct qla_hw_data *ha)
2305 2313
2306 /* If reset value is all FF's, initialize DRV_STATE */ 2314 /* If reset value is all FF's, initialize DRV_STATE */
2307 if (drv_state == 0xffffffff) { 2315 if (drv_state == 0xffffffff) {
2308 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); 2316 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, QLA82XX_DRVST_NOT_RDY);
2309 drv_state = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_STATE); 2317 drv_state = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_STATE);
2310 } 2318 }
2311 drv_state |= (QLA82XX_DRVST_RST_RDY << (ha->portnum * 4)); 2319 drv_state |= (QLA82XX_DRVST_RST_RDY << (ha->portnum * 4));
@@ -2335,7 +2343,8 @@ qla82xx_set_qsnt_ready(struct qla_hw_data *ha)
2335 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, qsnt_state); 2343 qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, qsnt_state);
2336} 2344}
2337 2345
2338int qla82xx_load_fw(scsi_qla_host_t *vha) 2346static int
2347qla82xx_load_fw(scsi_qla_host_t *vha)
2339{ 2348{
2340 int rst; 2349 int rst;
2341 struct fw_blob *blob; 2350 struct fw_blob *blob;
@@ -2419,7 +2428,7 @@ qla82xx_start_firmware(scsi_qla_host_t *vha)
2419 struct qla_hw_data *ha = vha->hw; 2428 struct qla_hw_data *ha = vha->hw;
2420 2429
2421 /* scrub dma mask expansion register */ 2430 /* scrub dma mask expansion register */
2422 qla82xx_wr_32(ha, CRB_DMA_SHIFT, 0x55555555); 2431 qla82xx_wr_32(ha, CRB_DMA_SHIFT, QLA82XX_DMA_SHIFT_VALUE);
2423 2432
2424 /* Put both the PEG CMD and RCV PEG to default state 2433 /* Put both the PEG CMD and RCV PEG to default state
2425 * of 0 before resetting the hardware 2434 * of 0 before resetting the hardware
@@ -2869,7 +2878,7 @@ queuing_error:
2869 return QLA_FUNCTION_FAILED; 2878 return QLA_FUNCTION_FAILED;
2870} 2879}
2871 2880
2872uint32_t * 2881static uint32_t *
2873qla82xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, 2882qla82xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
2874 uint32_t length) 2883 uint32_t length)
2875{ 2884{
@@ -2890,7 +2899,7 @@ done_read:
2890 return dwptr; 2899 return dwptr;
2891} 2900}
2892 2901
2893int 2902static int
2894qla82xx_unprotect_flash(struct qla_hw_data *ha) 2903qla82xx_unprotect_flash(struct qla_hw_data *ha)
2895{ 2904{
2896 int ret; 2905 int ret;
@@ -2921,7 +2930,7 @@ done_unprotect:
2921 return ret; 2930 return ret;
2922} 2931}
2923 2932
2924int 2933static int
2925qla82xx_protect_flash(struct qla_hw_data *ha) 2934qla82xx_protect_flash(struct qla_hw_data *ha)
2926{ 2935{
2927 int ret; 2936 int ret;
@@ -2950,7 +2959,7 @@ done_protect:
2950 return ret; 2959 return ret;
2951} 2960}
2952 2961
2953int 2962static int
2954qla82xx_erase_sector(struct qla_hw_data *ha, int addr) 2963qla82xx_erase_sector(struct qla_hw_data *ha, int addr)
2955{ 2964{
2956 int ret = 0; 2965 int ret = 0;
diff --git a/drivers/scsi/qla2xxx/qla_nx.h b/drivers/scsi/qla2xxx/qla_nx.h
index 15559cab39f8..51ec0c5380e8 100644
--- a/drivers/scsi/qla2xxx/qla_nx.h
+++ b/drivers/scsi/qla2xxx/qla_nx.h
@@ -26,6 +26,7 @@
26#define CRB_RCVPEG_STATE QLA82XX_REG(0x13c) 26#define CRB_RCVPEG_STATE QLA82XX_REG(0x13c)
27#define BOOT_LOADER_DIMM_STATUS QLA82XX_REG(0x54) 27#define BOOT_LOADER_DIMM_STATUS QLA82XX_REG(0x54)
28#define CRB_DMA_SHIFT QLA82XX_REG(0xcc) 28#define CRB_DMA_SHIFT QLA82XX_REG(0xcc)
29#define QLA82XX_DMA_SHIFT_VALUE 0x55555555
29 30
30#define QLA82XX_HW_H0_CH_HUB_ADR 0x05 31#define QLA82XX_HW_H0_CH_HUB_ADR 0x05
31#define QLA82XX_HW_H1_CH_HUB_ADR 0x0E 32#define QLA82XX_HW_H1_CH_HUB_ADR 0x0E
@@ -583,6 +584,10 @@
583#define QLA82XX_DRVST_RST_RDY 1 584#define QLA82XX_DRVST_RST_RDY 1
584#define QLA82XX_DRVST_QSNT_RDY 2 585#define QLA82XX_DRVST_QSNT_RDY 2
585 586
587/* Different drive active state */
588#define QLA82XX_DRV_NOT_ACTIVE 0
589#define QLA82XX_DRV_ACTIVE 1
590
586/* 591/*
587 * The PCI VendorID and DeviceID for our board. 592 * The PCI VendorID and DeviceID for our board.
588 */ 593 */