Lines Matching +full:fails +full:- +full:without +full:- +full:test +full:- +full:cd
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
5 * Copyright (c) 1995-2000 Advanced System Products, Inc.
6 * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
34 #include <linux/dma-mapping.h>
116 #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
133 * Narrow boards only support 12-byte commands, while wide boards
134 * extend to 16-byte commands.
400 #define ASC_IERR_BIST_PRE_TEST 0x0800 /* BIST pre-test error */
401 #define ASC_IERR_BIST_RAM_TEST 0x1000 /* BIST RAM test error */
421 * is Ultra-capable or not. These tables let us convert from one to the other.
577 * between big and little-endian platforms so they are
581 #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
582 #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
584 ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
586 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
883 * Define total number of simultaneous maximum element scatter-gather
886 * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
889 * structures or 255 scatter-gather elements.
894 * Define maximum number of scatter-gather elements per request.
932 /* bit 13 set - Term Polarity Control */
933 /* bit 14 set - BIOS Enable */
934 /* bit 15 set - Big Endian Mode */
952 uchar termination; /* 11 0 - automatic */
953 /* 1 - low off / high off */
954 /* 2 - low off / high on */
955 /* 3 - low on / high on */
965 /* bit 4 BIOS support bootable CD */
1001 /* bit 13 set - Load CIS */
1002 /* bit 14 set - BIOS Enable */
1003 /* bit 15 set - Big Endian Mode */
1007 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1021 uchar termination_se; /* 11 0 - automatic */
1022 /* 1 - low off / high off */
1023 /* 2 - low off / high on */
1024 /* 3 - low on / high on */
1027 uchar termination_lvd; /* 11 0 - automatic */
1028 /* 1 - low off / high off */
1029 /* 2 - low off / high on */
1030 /* 3 - low on / high on */
1038 /* bit 4 BIOS support bootable CD */
1050 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1051 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1055 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1101 /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
1102 /* clear - Func. 0 INTA, Func. 1 INTB */
1103 /* bit 13 set - Load CIS */
1104 /* bit 14 set - BIOS Enable */
1105 /* bit 15 set - Big Endian Mode */
1109 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
1123 uchar termination_se; /* 11 0 - automatic */
1124 /* 1 - low off / high off */
1125 /* 2 - low off / high on */
1126 /* 3 - low on / high on */
1129 uchar termination_lvd; /* 11 0 - automatic */
1130 /* 1 - low off / high off */
1131 /* 2 - low off / high on */
1132 /* 3 - low on / high on */
1140 /* bit 4 BIOS support bootable CD */
1152 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
1153 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
1157 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
1223 * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
1427 #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
1428 #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
1436 * Addendum for ASC-38C0800 Chip
1438 * The ASC-38C1600 Chip uses the same definitions except that the
1441 * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
1442 * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
1443 * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
1508 * ASC-38C0800 RAM BIST Register bit definitions
1557 #define ADV_ERROR (-1)
1582 #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
1583 #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
1584 #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
1585 #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
1641 #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
1659 * little-endian.
1694 #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
1695 #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
1696 #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
1712 uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
1737 * ADV_SCSI_REQ_Q - microcode request structure
1741 * in this structure. Do not change the structure definition here without
1764 uchar cdb[12]; /* SCSI CDB bytes 0-11. */
1767 uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
1771 * End of microcode structure - 60 bytes. The rest of the structure
1784 * to the Mid-Level SCSI request structure.
1787 * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
1788 * up to 255 scatter-gather elements may be used per request or
1796 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
1802 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
1804 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
1826 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
1827 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
1828 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
1829 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
1886 #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
1934 /* Write little-endian double word (4 bytes) to LRAM */
1935 /* Because of unspecified C language ordering don't use auto-increment. */
1981 * ADV_TRUE(1) - Queue was successfully aborted.
1982 * ADV_FALSE(0) - Queue was not found on the active queue list.
1995 * ADV_TRUE(1) - All requests on the target are purged.
1996 * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
2055 #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
2064 * number of scatter-gather elements the driver supports in a
2070 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
2075 #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
2086 #define ASC_ERROR (-1)
2099 (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
2105 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
2158 * 1: High-Level Tracing
2159 * 2-N: Verbose Tracing
2234 unsigned int xfer_elem; /* # scatter-gather elements */
2235 unsigned int xfer_sect; /* # 512-byte blocks */
2244 * field. It is guaranteed to be allocated from DMA-able memory.
2286 struct dma_pool *adv_sgblk_pool; /* Scatter-gather structures. */
2297 #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
2310 "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl); in asc_prt_asc_dvc_var()
2312 printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type, in asc_prt_asc_dvc_var()
2313 (unsigned)h->init_sdtr); in asc_prt_asc_dvc_var()
2316 "chip_no 0x%x,\n", (unsigned)h->sdtr_done, in asc_prt_asc_dvc_var()
2317 (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready, in asc_prt_asc_dvc_var()
2318 (unsigned)h->chip_no); in asc_prt_asc_dvc_var()
2321 "%u,\n", (unsigned)h->queue_full_or_busy, in asc_prt_asc_dvc_var()
2322 (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait); in asc_prt_asc_dvc_var()
2325 "in_critical_cnt %u,\n", (unsigned)h->is_in_int, in asc_prt_asc_dvc_var()
2326 (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng, in asc_prt_asc_dvc_var()
2327 (unsigned)h->in_critical_cnt); in asc_prt_asc_dvc_var()
2330 "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage, in asc_prt_asc_dvc_var()
2331 (unsigned)h->init_state, (unsigned)h->no_scam, in asc_prt_asc_dvc_var()
2332 (unsigned)h->pci_fix_asyn_xfer); in asc_prt_asc_dvc_var()
2334 printk(" cfg 0x%lx\n", (ulong)h->cfg); in asc_prt_asc_dvc_var()
2345 h->can_tagged_qng, h->cmd_qng_enabled); in asc_prt_asc_dvc_cfg()
2347 h->disc_enable, h->sdtr_enable); in asc_prt_asc_dvc_cfg()
2350 "chip_version %d,\n", h->chip_scsi_id, h->isa_dma_speed, in asc_prt_asc_dvc_cfg()
2351 h->isa_dma_channel, h->chip_version); in asc_prt_asc_dvc_cfg()
2354 h->mcode_date, h->mcode_version); in asc_prt_asc_dvc_cfg()
2367 (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able); in asc_prt_adv_dvc_var()
2370 (unsigned)h->sdtr_able, (unsigned)h->wdtr_able); in asc_prt_adv_dvc_var()
2373 (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait); in asc_prt_adv_dvc_var()
2376 (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng, in asc_prt_adv_dvc_var()
2377 h->carr_freelist); in asc_prt_adv_dvc_var()
2379 printk(" icq_sp 0x%p, irq_sp 0x%p\n", h->icq_sp, h->irq_sp); in asc_prt_adv_dvc_var()
2382 (unsigned)h->no_scam, (unsigned)h->tagqng_able); in asc_prt_adv_dvc_var()
2385 (unsigned)h->chip_scsi_id, (ulong)h->cfg); in asc_prt_adv_dvc_var()
2398 h->disc_enable, h->termination); in asc_prt_adv_dvc_cfg()
2401 h->chip_version, h->mcode_date); in asc_prt_adv_dvc_cfg()
2404 h->mcode_version, h->control_flag); in asc_prt_adv_dvc_cfg()
2414 printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev)); in asc_prt_scsi_host()
2416 scsi_host_busy(s), s->host_no); in asc_prt_scsi_host()
2419 (ulong)s->base, (ulong)s->io_port, boardp->irq); in asc_prt_scsi_host()
2422 s->dma_channel, s->this_id, s->can_queue); in asc_prt_scsi_host()
2425 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma); in asc_prt_scsi_host()
2428 asc_prt_asc_dvc_var(&boardp->dvc_var.asc_dvc_var); in asc_prt_scsi_host()
2429 asc_prt_asc_dvc_cfg(&boardp->dvc_cfg.asc_dvc_cfg); in asc_prt_scsi_host()
2431 asc_prt_adv_dvc_var(&boardp->dvc_var.adv_dvc_var); in asc_prt_scsi_host()
2432 asc_prt_adv_dvc_cfg(&boardp->dvc_cfg.adv_dvc_cfg); in asc_prt_scsi_host()
2440 * or 8 double-words per line.
2453 /* Display a maximum of 8 double-words per line. */ in asc_prt_hex()
2454 if ((k = (l - i) / 4) >= 8) { in asc_prt_hex()
2458 m = (l - i) % 4; in asc_prt_hex()
2505 q->q2.target_ix, q->q1.target_lun, q->q2.srb_tag, in asc_prt_asc_scsi_q()
2506 q->q2.tag_code); in asc_prt_asc_scsi_q()
2510 (ulong)le32_to_cpu(q->q1.data_addr), in asc_prt_asc_scsi_q()
2511 (ulong)le32_to_cpu(q->q1.data_cnt), in asc_prt_asc_scsi_q()
2512 (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len); in asc_prt_asc_scsi_q()
2515 (ulong)q->cdbptr, q->q2.cdb_len, in asc_prt_asc_scsi_q()
2516 (ulong)q->sg_head, q->q1.sg_queue_cnt); in asc_prt_asc_scsi_q()
2518 if (q->sg_head) { in asc_prt_asc_scsi_q()
2519 sgp = q->sg_head; in asc_prt_asc_scsi_q()
2521 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt, in asc_prt_asc_scsi_q()
2522 sgp->queue_cnt); in asc_prt_asc_scsi_q()
2523 for (i = 0; i < sgp->entry_cnt; i++) { in asc_prt_asc_scsi_q()
2525 i, (ulong)le32_to_cpu(sgp->sg_list[i].addr), in asc_prt_asc_scsi_q()
2526 (ulong)le32_to_cpu(sgp->sg_list[i].bytes)); in asc_prt_asc_scsi_q()
2539 q->d2.srb_tag, q->d2.target_ix, q->d2.cdb_len, in asc_prt_asc_qdone_info()
2540 q->d2.tag_code); in asc_prt_asc_qdone_info()
2543 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg); in asc_prt_asc_qdone_info()
2558 b->sg_cnt, (u32)le32_to_cpu(b->sg_ptr)); in asc_prt_adv_sgblock()
2559 BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK); in asc_prt_adv_sgblock()
2560 if (b->sg_ptr != 0) in asc_prt_adv_sgblock()
2561 BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK); in asc_prt_adv_sgblock()
2562 for (i = 0; i < b->sg_cnt; i++) { in asc_prt_adv_sgblock()
2564 i, (u32)le32_to_cpu(b->sg_list[i].sg_addr), in asc_prt_adv_sgblock()
2565 (u32)le32_to_cpu(b->sg_list[i].sg_count)); in asc_prt_adv_sgblock()
2583 q->target_id, q->target_lun, q->srb_tag); in asc_prt_adv_scsi_req_q()
2586 q->cntl, (ulong)le32_to_cpu(q->data_addr)); in asc_prt_adv_scsi_req_q()
2589 (ulong)le32_to_cpu(q->data_cnt), in asc_prt_adv_scsi_req_q()
2590 (ulong)le32_to_cpu(q->sense_addr), q->sense_len); in asc_prt_adv_scsi_req_q()
2594 q->cdb_len, q->done_status, q->host_status, q->scsi_status); in asc_prt_adv_scsi_req_q()
2597 q->sg_working_ix, q->target_cmd); in asc_prt_adv_scsi_req_q()
2600 (ulong)le32_to_cpu(q->scsiq_rptr), in asc_prt_adv_scsi_req_q()
2601 (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr); in asc_prt_adv_scsi_req_q()
2604 if (q->sg_list_ptr != NULL) { in asc_prt_adv_scsi_req_q()
2605 sgblkp = container_of(q->sg_list_ptr, adv_sgblk_t, sg_block); in asc_prt_adv_scsi_req_q()
2608 sg_ptr = &sgblkp->sg_block; in asc_prt_adv_scsi_req_q()
2610 if (sg_ptr->sg_ptr == 0) { in asc_prt_adv_scsi_req_q()
2613 sgblkp = sgblkp->next_sgblkp; in asc_prt_adv_scsi_req_q()
2639 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; in advansys_info()
2641 if (asc_dvc_varp->bus_type & ASC_IS_ISA) { in advansys_info()
2642 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) == in advansys_info()
2649 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X", in advansys_info()
2651 (ulong)shost->io_port, in advansys_info()
2652 (ulong)shost->io_port + ASC_IOADR_GAP - 1, in advansys_info()
2653 boardp->irq, shost->dma_channel); in advansys_info()
2655 if (asc_dvc_varp->bus_type & ASC_IS_VL) { in advansys_info()
2657 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) { in advansys_info()
2659 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) { in advansys_info()
2660 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA) in advansys_info()
2669 "type %d\n", asc_dvc_varp->bus_type); in advansys_info()
2672 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X", in advansys_info()
2673 ASC_VERSION, busname, (ulong)shost->io_port, in advansys_info()
2674 (ulong)shost->io_port + ASC_IOADR_GAP - 1, in advansys_info()
2675 boardp->irq); in advansys_info()
2681 * Memory-mapped I/O is used instead of I/O space to access in advansys_info()
2685 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var; in advansys_info()
2686 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in advansys_info()
2687 widename = "Ultra-Wide"; in advansys_info()
2688 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in advansys_info()
2689 widename = "Ultra2-Wide"; in advansys_info()
2691 widename = "Ultra3-Wide"; in advansys_info()
2694 "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X", in advansys_info()
2695 ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base, in advansys_info()
2696 (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, boardp->irq); in advansys_info()
2718 shost->host_no); in asc_prt_board_devices()
2721 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; in asc_prt_board_devices()
2723 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; in asc_prt_board_devices()
2728 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) in asc_prt_board_devices()
2748 if (boardp->bios_signature != 0x55AA) { in asc_prt_adv_bios()
2749 seq_puts(m, "Disabled or Pre-3.1\n" in asc_prt_adv_bios()
2750 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n" in asc_prt_adv_bios()
2753 major = (boardp->bios_version >> 12) & 0xF; in asc_prt_adv_bios()
2754 minor = (boardp->bios_version >> 8) & 0xF; in asc_prt_adv_bios()
2755 letter = (boardp->bios_version & 0xFF); in asc_prt_adv_bios()
2766 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) { in asc_prt_adv_bios()
2775 * is found in at bit 15-9 (7 bits) of word 1.
2777 * Serial Number consists fo 12 alpha-numeric digits.
2779 * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
2780 * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
2781 * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
2782 * 5 - Product revision (A-J) Word0: " "
2784 * Signature Word1: 15-9 (7 bits)
2785 * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
2786 * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
2788 * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
2804 * First word - 6 digits. in asc_get_eeprom_string()
2808 /* Product type - 1st digit. */ in asc_get_eeprom_string()
2815 /* Manufacturing location - 2nd digit. */ in asc_get_eeprom_string()
2818 /* Product ID - 3rd, 4th digits. */ in asc_get_eeprom_string()
2824 /* Product revision - 5th digit. */ in asc_get_eeprom_string()
2833 * Year - 6th digit. in asc_get_eeprom_string()
2844 /* Week of year - 7th, 8th digits. */ in asc_get_eeprom_string()
2855 /* Serial number - 9th digit. */ in asc_get_eeprom_string()
2887 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; in asc_prt_asc_board_eeprom()
2888 ep = &boardp->eep_config.asc_eep; in asc_prt_asc_board_eeprom()
2892 shost->host_no); in asc_prt_asc_board_eeprom()
2894 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr) in asc_prt_asc_board_eeprom()
2897 else if (ep->adapter_info[5] == 0xBB) in asc_prt_asc_board_eeprom()
2899 " Default Settings Used for EEPROM-less Adapter.\n"); in asc_prt_asc_board_eeprom()
2905 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, in asc_prt_asc_board_eeprom()
2906 ep->max_tag_qng); in asc_prt_asc_board_eeprom()
2909 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam); in asc_prt_asc_board_eeprom()
2918 (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); in asc_prt_asc_board_eeprom()
2923 (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); in asc_prt_asc_board_eeprom()
2928 (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); in asc_prt_asc_board_eeprom()
2933 (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); in asc_prt_asc_board_eeprom()
2937 if (asc_dvc_varp->bus_type & ASC_IS_ISA) { in asc_prt_asc_board_eeprom()
2964 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var; in asc_prt_adv_board_eeprom()
2965 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
2966 ep_3550 = &boardp->eep_config.adv_3550_eep; in asc_prt_adv_board_eeprom()
2967 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in asc_prt_adv_board_eeprom()
2968 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep; in asc_prt_adv_board_eeprom()
2970 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep; in asc_prt_adv_board_eeprom()
2975 shost->host_no); in asc_prt_adv_board_eeprom()
2977 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
2978 wordp = &ep_3550->serial_number_word1; in asc_prt_adv_board_eeprom()
2979 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in asc_prt_adv_board_eeprom()
2980 wordp = &ep_38C0800->serial_number_word1; in asc_prt_adv_board_eeprom()
2982 wordp = &ep_38C1600->serial_number_word1; in asc_prt_adv_board_eeprom()
2990 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) in asc_prt_adv_board_eeprom()
2993 ep_3550->adapter_scsi_id, in asc_prt_adv_board_eeprom()
2994 ep_3550->max_host_qng, ep_3550->max_dvc_qng); in asc_prt_adv_board_eeprom()
2995 else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) in asc_prt_adv_board_eeprom()
2998 ep_38C0800->adapter_scsi_id, in asc_prt_adv_board_eeprom()
2999 ep_38C0800->max_host_qng, in asc_prt_adv_board_eeprom()
3000 ep_38C0800->max_dvc_qng); in asc_prt_adv_board_eeprom()
3004 ep_38C1600->adapter_scsi_id, in asc_prt_adv_board_eeprom()
3005 ep_38C1600->max_host_qng, in asc_prt_adv_board_eeprom()
3006 ep_38C1600->max_dvc_qng); in asc_prt_adv_board_eeprom()
3007 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
3008 word = ep_3550->termination; in asc_prt_adv_board_eeprom()
3009 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in asc_prt_adv_board_eeprom()
3010 word = ep_38C0800->termination_lvd; in asc_prt_adv_board_eeprom()
3012 word = ep_38C1600->termination_lvd; in asc_prt_adv_board_eeprom()
3030 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) in asc_prt_adv_board_eeprom()
3033 ep_3550->termination, termstr, in asc_prt_adv_board_eeprom()
3034 ep_3550->bios_ctrl); in asc_prt_adv_board_eeprom()
3035 else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) in asc_prt_adv_board_eeprom()
3038 ep_38C0800->termination_lvd, termstr, in asc_prt_adv_board_eeprom()
3039 ep_38C0800->bios_ctrl); in asc_prt_adv_board_eeprom()
3043 ep_38C1600->termination_lvd, termstr, in asc_prt_adv_board_eeprom()
3044 ep_38C1600->bios_ctrl); in asc_prt_adv_board_eeprom()
3051 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
3052 word = ep_3550->disc_enable; in asc_prt_adv_board_eeprom()
3053 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in asc_prt_adv_board_eeprom()
3054 word = ep_38C0800->disc_enable; in asc_prt_adv_board_eeprom()
3056 word = ep_38C1600->disc_enable; in asc_prt_adv_board_eeprom()
3064 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
3065 word = ep_3550->tagqng_able; in asc_prt_adv_board_eeprom()
3066 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in asc_prt_adv_board_eeprom()
3067 word = ep_38C0800->tagqng_able; in asc_prt_adv_board_eeprom()
3069 word = ep_38C1600->tagqng_able; in asc_prt_adv_board_eeprom()
3077 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
3078 word = ep_3550->start_motor; in asc_prt_adv_board_eeprom()
3079 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in asc_prt_adv_board_eeprom()
3080 word = ep_38C0800->start_motor; in asc_prt_adv_board_eeprom()
3082 word = ep_38C1600->start_motor; in asc_prt_adv_board_eeprom()
3090 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
3094 (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ? in asc_prt_adv_board_eeprom()
3099 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
3103 (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i)) in asc_prt_adv_board_eeprom()
3108 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in asc_prt_adv_board_eeprom()
3109 word = ep_3550->wdtr_able; in asc_prt_adv_board_eeprom()
3110 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in asc_prt_adv_board_eeprom()
3111 word = ep_38C0800->wdtr_able; in asc_prt_adv_board_eeprom()
3113 word = ep_38C1600->wdtr_able; in asc_prt_adv_board_eeprom()
3121 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 || in asc_prt_adv_board_eeprom()
3122 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) { in asc_prt_adv_board_eeprom()
3128 sdtr_speed = adv_dvc_varp->sdtr_speed1; in asc_prt_adv_board_eeprom()
3130 sdtr_speed = adv_dvc_varp->sdtr_speed2; in asc_prt_adv_board_eeprom()
3132 sdtr_speed = adv_dvc_varp->sdtr_speed3; in asc_prt_adv_board_eeprom()
3134 sdtr_speed = adv_dvc_varp->sdtr_speed4; in asc_prt_adv_board_eeprom()
3178 shost->host_no); in asc_prt_driver_conf()
3182 scsi_host_busy(shost), shost->max_id, in asc_prt_driver_conf()
3183 shost->max_lun, shost->max_channel); in asc_prt_driver_conf()
3187 shost->unique_id, shost->can_queue, shost->this_id, in asc_prt_driver_conf()
3188 shost->sg_tablesize, shost->cmd_per_lun); in asc_prt_driver_conf()
3192 shost->unchecked_isa_dma); in asc_prt_driver_conf()
3196 boardp->flags, shost->last_reset, jiffies, in asc_prt_driver_conf()
3197 boardp->asc_n_io_port); in asc_prt_driver_conf()
3199 seq_printf(m, " io_port 0x%lx\n", shost->io_port); in asc_prt_driver_conf()
3202 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; in asc_prt_driver_conf()
3204 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; in asc_prt_driver_conf()
3222 v = &boardp->dvc_var.asc_dvc_var; in asc_prt_asc_board_info()
3223 c = &boardp->dvc_cfg.asc_dvc_cfg; in asc_prt_asc_board_info()
3224 chip_scsi_id = c->chip_scsi_id; in asc_prt_asc_board_info()
3228 shost->host_no); in asc_prt_asc_board_info()
3232 c->chip_version, c->mcode_date, c->mcode_version, in asc_prt_asc_board_info()
3233 v->err_code); in asc_prt_asc_board_info()
3237 " Total Command Pending: %d\n", v->cur_total_qng); in asc_prt_asc_board_info()
3242 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_asc_board_info()
3247 (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); in asc_prt_asc_board_info()
3254 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_asc_board_info()
3257 seq_printf(m, " %X:%u", i, v->cur_dvc_qng[i]); in asc_prt_asc_board_info()
3264 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_asc_board_info()
3267 seq_printf(m, " %X:%u", i, v->max_dvc_qng[i]); in asc_prt_asc_board_info()
3274 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_asc_board_info()
3277 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) in asc_prt_asc_board_info()
3278 seq_printf(m, " %X:Y-%d", in asc_prt_asc_board_info()
3279 i, boardp->queue_full_cnt[i]); in asc_prt_asc_board_info()
3287 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_asc_board_info()
3292 (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); in asc_prt_asc_board_info()
3300 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) || in asc_prt_asc_board_info()
3301 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_asc_board_info()
3307 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) { in asc_prt_asc_board_info()
3311 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - in asc_prt_asc_board_info()
3316 v->sdtr_period_tbl[syn_period_ix], in asc_prt_asc_board_info()
3317 250 / v->sdtr_period_tbl[syn_period_ix], in asc_prt_asc_board_info()
3319 v->sdtr_period_tbl[syn_period_ix])); in asc_prt_asc_board_info()
3322 boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET); in asc_prt_asc_board_info()
3325 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { in asc_prt_asc_board_info()
3334 seq_puts(m, " * = Re-negotiation pending before next command.\n"); in asc_prt_asc_board_info()
3359 v = &boardp->dvc_var.adv_dvc_var; in asc_prt_adv_board_info()
3360 c = &boardp->dvc_cfg.adv_dvc_cfg; in asc_prt_adv_board_info()
3361 iop_base = v->iop_base; in asc_prt_adv_board_info()
3362 chip_scsi_id = v->chip_scsi_id; in asc_prt_adv_board_info()
3366 shost->host_no); in asc_prt_adv_board_info()
3370 (unsigned long)v->iop_base, in asc_prt_adv_board_info()
3372 v->err_code); in asc_prt_adv_board_info()
3375 "mcode_version 0x%x\n", c->chip_version, in asc_prt_adv_board_info()
3376 c->mcode_date, c->mcode_version); in asc_prt_adv_board_info()
3382 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_adv_board_info()
3394 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_adv_board_info()
3407 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_adv_board_info()
3422 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_adv_board_info()
3436 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_adv_board_info()
3459 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { in asc_prt_adv_board_info()
3478 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) || in asc_prt_adv_board_info()
3521 seq_puts(m, " * = Re-negotiation pending before next command.\n"); in asc_prt_adv_board_info()
3532 struct asc_stats *s = &boardp->asc_stats; in asc_prt_board_stats()
3536 shost->host_no); in asc_prt_board_stats()
3540 s->queuecommand, s->reset, s->biosparam, in asc_prt_board_stats()
3541 s->interrupt); in asc_prt_board_stats()
3545 s->callback, s->done, s->build_error, in asc_prt_board_stats()
3546 s->adv_build_noreq, s->adv_build_nosg); in asc_prt_board_stats()
3550 s->exe_noerror, s->exe_busy, s->exe_error, in asc_prt_board_stats()
3551 s->exe_unknown); in asc_prt_board_stats()
3556 if (s->xfer_cnt > 0) { in asc_prt_board_stats()
3558 s->xfer_cnt, s->xfer_elem); in asc_prt_board_stats()
3561 s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2)); in asc_prt_board_stats()
3565 s->xfer_elem / s->xfer_cnt, in asc_prt_board_stats()
3566 ASC_TENTHS(s->xfer_elem, s->xfer_cnt)); in asc_prt_board_stats()
3569 (s->xfer_sect / 2) / s->xfer_elem, in asc_prt_board_stats()
3570 ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem)); in asc_prt_board_stats()
3573 (s->xfer_sect / 2) / s->xfer_cnt, in asc_prt_board_stats()
3574 ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt)); in asc_prt_board_stats()
3580 * advansys_show_info() - /proc/scsi/advansys/{0,1,2,3,...}
3652 ASC_STATS(scp->device->host, done); in asc_scsi_done()
3653 scp->scsi_done(scp); in asc_scsi_done()
3721 iop_base = asc_dvc->iop_base; in AscResetChipAndScsiBus()
3723 && (i-- > 0)) { in AscResetChipAndScsiBus()
3779 AscSetChipLramAddr(iop_base, addr - 1); in AscReadLramByte()
3821 addr--; in AscWriteLramByte()
3836 * The source data is assumed to be in little-endian order in memory
3837 * and is maintained in little-endian order when written to LRAM.
3848 * On a little-endian system the second argument below in AscMemWordCopyPtrToLram()
3849 * produces a little-endian ushort which is written to in AscMemWordCopyPtrToLram()
3850 * LRAM in little-endian order. On a big-endian system in AscMemWordCopyPtrToLram()
3851 * the second argument produces a big-endian ushort which in AscMemWordCopyPtrToLram()
3852 * is "transparently" byte-swapped by outpw() and written in AscMemWordCopyPtrToLram()
3853 * in little-endian order to LRAM. in AscMemWordCopyPtrToLram()
3863 * The source data is assumed to be in little-endian order in memory
3864 * and is maintained in little-endian order when written to LRAM.
3882 * The source data is assumed to be in little-endian order in LRAM
3883 * and is maintained in little-endian order when written to memory.
3917 iop_base = asc_dvc->iop_base; in AscInitLram()
3919 (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) * in AscInitLram()
3926 (uchar)(asc_dvc->max_total_qng)); in AscInitLram()
3931 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) { in AscInitLram()
3935 (uchar)(i - 1)); in AscInitLram()
3942 (uchar)(asc_dvc->max_total_qng - 1)); in AscInitLram()
3944 (uchar)asc_dvc->max_total_qng); in AscInitLram()
3947 for (; i <= (uchar)(asc_dvc->max_total_qng + 3); in AscInitLram()
3975 (ushort)((mcode_size - in AscLoadMicroCode()
3976 s_addr - (ushort) in AscLoadMicroCode()
3991 iop_base = asc_dvc->iop_base; in AscInitQLinkVar()
3993 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng); in AscInitQLinkVar()
3995 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng); in AscInitQLinkVar()
3997 (uchar)((int)asc_dvc->max_total_qng + 1)); in AscInitQLinkVar()
3999 (uchar)((int)asc_dvc->max_total_qng + 2)); in AscInitQLinkVar()
4001 asc_dvc->max_total_qng); in AscInitQLinkVar()
4023 iop_base = asc_dvc->iop_base; in AscInitMicroCodeVar()
4027 asc_dvc->cfg->sdtr_period_offset[i]); in AscInitMicroCodeVar()
4032 asc_dvc->cfg->disc_enable); in AscInitMicroCodeVar()
4034 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id)); in AscInitMicroCodeVar()
4037 BUG_ON((unsigned long)asc_dvc->overrun_buf & 7); in AscInitMicroCodeVar()
4038 asc_dvc->overrun_dma = dma_map_single(board->dev, asc_dvc->overrun_buf, in AscInitMicroCodeVar()
4040 if (dma_mapping_error(board->dev, asc_dvc->overrun_dma)) { in AscInitMicroCodeVar()
4041 warn_code = -ENOMEM; in AscInitMicroCodeVar()
4044 phy_addr = cpu_to_le32(asc_dvc->overrun_dma); in AscInitMicroCodeVar()
4051 asc_dvc->cfg->mcode_date = in AscInitMicroCodeVar()
4053 asc_dvc->cfg->mcode_version = in AscInitMicroCodeVar()
4058 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR; in AscInitMicroCodeVar()
4059 warn_code = -EINVAL; in AscInitMicroCodeVar()
4063 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP; in AscInitMicroCodeVar()
4064 warn_code = -EIO; in AscInitMicroCodeVar()
4071 dma_unmap_single(board->dev, asc_dvc->overrun_dma, in AscInitMicroCodeVar()
4074 asc_dvc->overrun_dma = 0; in AscInitMicroCodeVar()
4087 iop_base = asc_dvc->iop_base; in AscInitAsc1000Driver()
4089 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) && in AscInitAsc1000Driver()
4090 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) { in AscInitAsc1000Driver()
4092 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */ in AscInitAsc1000Driver()
4094 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC; in AscInitAsc1000Driver()
4095 if (asc_dvc->err_code != 0) in AscInitAsc1000Driver()
4097 if (!AscFindSignature(asc_dvc->iop_base)) { in AscInitAsc1000Driver()
4098 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; in AscInitAsc1000Driver()
4104 err = request_firmware(&fw, fwname, asc_dvc->drv_ptr->dev); in AscInitAsc1000Driver()
4108 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM; in AscInitAsc1000Driver()
4111 if (fw->size < 4) { in AscInitAsc1000Driver()
4113 fw->size, fwname); in AscInitAsc1000Driver()
4115 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM; in AscInitAsc1000Driver()
4116 return -EINVAL; in AscInitAsc1000Driver()
4118 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | in AscInitAsc1000Driver()
4119 (fw->data[1] << 8) | fw->data[0]; in AscInitAsc1000Driver()
4121 if (AscLoadMicroCode(iop_base, 0, &fw->data[4], in AscInitAsc1000Driver()
4122 fw->size - 4) != chksum) { in AscInitAsc1000Driver()
4123 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM; in AscInitAsc1000Driver()
4129 if (!asc_dvc->overrun_dma) in AscInitAsc1000Driver()
4131 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC; in AscInitAsc1000Driver()
4146 * 1-Byte Code:
4152 * Multi-Byte Code:
4217 carr_paddr = adv_dvc->carrier_addr + carr_offset; in AdvBuildCarrierFreelist()
4219 adv_dvc->carrier[i].carr_pa = cpu_to_le32(carr_paddr); in AdvBuildCarrierFreelist()
4220 adv_dvc->carrier[i].carr_va = cpu_to_le32(carr_offset); in AdvBuildCarrierFreelist()
4221 adv_dvc->carrier[i].areq_vpa = 0; in AdvBuildCarrierFreelist()
4225 adv_dvc->carrier[i].next_vpa = cpu_to_le32(next_offset); in AdvBuildCarrierFreelist()
4233 adv_dvc->carr_freelist = &adv_dvc->carrier[1]; in AdvBuildCarrierFreelist()
4243 return &adv_dvc->carrier[index]; in adv_get_carrier()
4248 ADV_CARR_T *carrp = adv_dvc->carr_freelist; in adv_get_next_carrier()
4249 u32 next_vpa = le32_to_cpu(carrp->next_vpa); in adv_get_next_carrier()
4256 adv_dvc->carr_freelist = adv_get_carrier(adv_dvc, next_vpa); in adv_get_next_carrier()
4260 carrp->next_vpa = cpu_to_le32(ADV_CQ_STOPPER); in adv_get_next_carrier()
4270 struct asc_board *boardp = adv_dvc->drv_ptr; in adv_get_reqp()
4272 BUG_ON(offset > adv_dvc->max_host_qng); in adv_get_reqp()
4273 return &boardp->adv_reqp[offset]; in adv_get_reqp()
4282 * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
4286 * ADV_TRUE - command completed successfully
4287 * ADV_FALSE - command failed
4288 * ADV_ERROR - command timed out
4297 iop_base = asc_dvc->iop_base; in AdvSendIdleCmd()
4301 * to a non-zero value to indicate when the command is completed. in AdvSendIdleCmd()
4302 * The non-zero result is one of the IDLE_CMD_STATUS_* values in AdvSendIdleCmd()
4320 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) { in AdvSendIdleCmd()
4322 * Clear the tickle value. In the ASC-3550 the RISC flag in AdvSendIdleCmd()
4349 * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
4350 * ADV_FALSE(0) - Microcode command failed.
4351 * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
4376 * Send the SCSI Bus Reset end idle command which de-asserts in AdvResetSB()
4384 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */ in AdvResetSB()
4390 * Initialize the ASC-3550.
4394 * For a non-fatal error return a warning code. If there are no warnings
4414 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */ in AdvInitAsc3550Driver()
4419 if (asc_dvc->err_code != 0) in AdvInitAsc3550Driver()
4425 if (asc_dvc->chip_type != ADV_CHIP_ASC3550) { in AdvInitAsc3550Driver()
4426 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE; in AdvInitAsc3550Driver()
4431 iop_base = asc_dvc->iop_base; in AdvInitAsc3550Driver()
4449 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) { in AdvInitAsc3550Driver()
4453 bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2]; in AdvInitAsc3550Driver()
4470 err = request_firmware(&fw, fwname, asc_dvc->drv_ptr->dev); in AdvInitAsc3550Driver()
4474 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM; in AdvInitAsc3550Driver()
4477 if (fw->size < 4) { in AdvInitAsc3550Driver()
4479 fw->size, fwname); in AdvInitAsc3550Driver()
4481 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM; in AdvInitAsc3550Driver()
4482 return -EINVAL; in AdvInitAsc3550Driver()
4484 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | in AdvInitAsc3550Driver()
4485 (fw->data[1] << 8) | fw->data[0]; in AdvInitAsc3550Driver()
4486 asc_dvc->err_code = AdvLoadMicrocode(iop_base, &fw->data[4], in AdvInitAsc3550Driver()
4487 fw->size - 4, ADV_3550_MEMSIZE, in AdvInitAsc3550Driver()
4490 if (asc_dvc->err_code) in AdvInitAsc3550Driver()
4518 asc_dvc->cfg->mcode_date); in AdvInitAsc3550Driver()
4520 asc_dvc->cfg->mcode_version); in AdvInitAsc3550Driver()
4533 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) { in AdvInitAsc3550Driver()
4540 * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO in AdvInitAsc3550Driver()
4553 * the BIOS and warm boot to work without a SCSI bus hang on in AdvInitAsc3550Driver()
4555 * Without the SCSI Bus Reset, before an Inquiry a device can't in AdvInitAsc3550Driver()
4558 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) { in AdvInitAsc3550Driver()
4560 asc_dvc->wdtr_able); in AdvInitAsc3550Driver()
4562 asc_dvc->sdtr_able); in AdvInitAsc3550Driver()
4573 * without determining here whether the device supports SDTR. in AdvInitAsc3550Driver()
4575 * 4-bit speed SDTR speed name in AdvInitAsc3550Driver()
4589 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) { in AdvInitAsc3550Driver()
4615 asc_dvc->cfg->disc_enable); in AdvInitAsc3550Driver()
4625 asc_dvc->chip_scsi_id); in AdvInitAsc3550Driver()
4642 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION; in AdvInitAsc3550Driver()
4652 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE; in AdvInitAsc3550Driver()
4657 * If this is a differential board and a single-ended device in AdvInitAsc3550Driver()
4661 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE; in AdvInitAsc3550Driver()
4670 * then 'termination' was set-up in AdvInitFrom3550EEPROM() and in AdvInitAsc3550Driver()
4673 if (asc_dvc->cfg->termination == 0) { in AdvInitAsc3550Driver()
4678 asc_dvc->cfg->termination |= TERM_CTL_SEL; in AdvInitAsc3550Driver()
4688 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L); in AdvInitAsc3550Driver()
4697 asc_dvc->cfg->termination |= TERM_CTL_H; in AdvInitAsc3550Driver()
4718 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL)); in AdvInitAsc3550Driver()
4738 * MEM_CFG may be accessed as a word or byte, but only bits 0-7 in AdvInitAsc3550Driver()
4741 * ASC-3550 has 8KB internal memory. in AdvInitAsc3550Driver()
4753 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); in AdvInitAsc3550Driver()
4758 * Set-up the Host->RISC Initiator Command Queue (ICQ). in AdvInitAsc3550Driver()
4761 asc_dvc->icq_sp = adv_get_next_carrier(asc_dvc); in AdvInitAsc3550Driver()
4762 if (!asc_dvc->icq_sp) { in AdvInitAsc3550Driver()
4763 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; in AdvInitAsc3550Driver()
4770 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa); in AdvInitAsc3550Driver()
4773 * Set-up the RISC->Host Initiator Response Queue (IRQ). in AdvInitAsc3550Driver()
4775 asc_dvc->irq_sp = adv_get_next_carrier(asc_dvc); in AdvInitAsc3550Driver()
4776 if (!asc_dvc->irq_sp) { in AdvInitAsc3550Driver()
4777 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; in AdvInitAsc3550Driver()
4784 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa); in AdvInitAsc3550Driver()
4785 asc_dvc->carr_pending_cnt = 0; in AdvInitAsc3550Driver()
4802 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) { in AdvInitAsc3550Driver()
4808 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == in AdvInitAsc3550Driver()
4833 * Initialize the ASC-38C0800.
4837 * For a non-fatal error return a warning code. If there are no warnings
4858 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */ in AdvInitAsc38C0800Driver()
4863 if (asc_dvc->err_code != 0) in AdvInitAsc38C0800Driver()
4869 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) { in AdvInitAsc38C0800Driver()
4870 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE; in AdvInitAsc38C0800Driver()
4875 iop_base = asc_dvc->iop_base; in AdvInitAsc38C0800Driver()
4902 * RAM BIST (RAM Built-In Self Test) in AdvInitAsc38C0800Driver()
4905 * Function: Bit 7-6(RW) : RAM mode in AdvInitAsc38C0800Driver()
4907 * Pre-test Mode : 0x40 in AdvInitAsc38C0800Driver()
4908 * RAM Test Mode : 0x80 in AdvInitAsc38C0800Driver()
4911 * Bit 3-0(RO) : Status in AdvInitAsc38C0800Driver()
4923 * LRAM Pre-test in AdvInitAsc38C0800Driver()
4936 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST; in AdvInitAsc38C0800Driver()
4944 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST; in AdvInitAsc38C0800Driver()
4950 * LRAM Test - It takes about 1.5 ms to run through the test. in AdvInitAsc38C0800Driver()
4962 asc_dvc->bist_err_code = byte; /* for BIOS display message */ in AdvInitAsc38C0800Driver()
4963 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST; in AdvInitAsc38C0800Driver()
4967 /* We need to reset back to normal mode after LRAM test passes. */ in AdvInitAsc38C0800Driver()
4970 err = request_firmware(&fw, fwname, asc_dvc->drv_ptr->dev); in AdvInitAsc38C0800Driver()
4974 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM; in AdvInitAsc38C0800Driver()
4977 if (fw->size < 4) { in AdvInitAsc38C0800Driver()
4979 fw->size, fwname); in AdvInitAsc38C0800Driver()
4981 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM; in AdvInitAsc38C0800Driver()
4982 return -EINVAL; in AdvInitAsc38C0800Driver()
4984 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | in AdvInitAsc38C0800Driver()
4985 (fw->data[1] << 8) | fw->data[0]; in AdvInitAsc38C0800Driver()
4986 asc_dvc->err_code = AdvLoadMicrocode(iop_base, &fw->data[4], in AdvInitAsc38C0800Driver()
4987 fw->size - 4, ADV_38C0800_MEMSIZE, in AdvInitAsc38C0800Driver()
4990 if (asc_dvc->err_code) in AdvInitAsc38C0800Driver()
5018 asc_dvc->cfg->mcode_date); in AdvInitAsc38C0800Driver()
5020 asc_dvc->cfg->mcode_version); in AdvInitAsc38C0800Driver()
5045 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) { in AdvInitAsc38C0800Driver()
5052 * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2] in AdvInitAsc38C0800Driver()
5055 * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes. in AdvInitAsc38C0800Driver()
5070 * the BIOS and warm boot to work without a SCSI bus hang on in AdvInitAsc38C0800Driver()
5072 * Without the SCSI Bus Reset, before an Inquiry a device can't in AdvInitAsc38C0800Driver()
5075 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) { in AdvInitAsc38C0800Driver()
5077 asc_dvc->wdtr_able); in AdvInitAsc38C0800Driver()
5079 asc_dvc->sdtr_able); in AdvInitAsc38C0800Driver()
5089 * without determining here whether the device supports SDTR. in AdvInitAsc38C0800Driver()
5092 asc_dvc->cfg->disc_enable); in AdvInitAsc38C0800Driver()
5093 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1); in AdvInitAsc38C0800Driver()
5094 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2); in AdvInitAsc38C0800Driver()
5095 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3); in AdvInitAsc38C0800Driver()
5096 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4); in AdvInitAsc38C0800Driver()
5106 asc_dvc->chip_scsi_id); in AdvInitAsc38C0800Driver()
5124 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE; in AdvInitAsc38C0800Driver()
5140 asc_dvc->err_code = ASC_IERR_HVD_DEVICE; in AdvInitAsc38C0800Driver()
5149 * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready in AdvInitAsc38C0800Driver()
5152 if ((asc_dvc->cfg->termination & TERM_SE) == 0) { in AdvInitAsc38C0800Driver()
5159 asc_dvc->cfg->termination |= TERM_SE; in AdvInitAsc38C0800Driver()
5164 asc_dvc->cfg->termination |= TERM_SE_HI; in AdvInitAsc38C0800Driver()
5169 if ((asc_dvc->cfg->termination & TERM_LVD) == 0) { in AdvInitAsc38C0800Driver()
5176 asc_dvc->cfg->termination |= TERM_LVD; in AdvInitAsc38C0800Driver()
5193 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0); in AdvInitAsc38C0800Driver()
5219 * MEM_CFG may be accessed as a word or byte, but only bits 0-7 in AdvInitAsc38C0800Driver()
5222 * ASC-38C0800 has 16KB internal memory. in AdvInitAsc38C0800Driver()
5234 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); in AdvInitAsc38C0800Driver()
5239 * Set-up the Host->RISC Initiator Command Queue (ICQ). in AdvInitAsc38C0800Driver()
5242 asc_dvc->icq_sp = adv_get_next_carrier(asc_dvc); in AdvInitAsc38C0800Driver()
5243 if (!asc_dvc->icq_sp) { in AdvInitAsc38C0800Driver()
5245 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; in AdvInitAsc38C0800Driver()
5253 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa); in AdvInitAsc38C0800Driver()
5256 * Set-up the RISC->Host Initiator Response Queue (IRQ). in AdvInitAsc38C0800Driver()
5258 asc_dvc->irq_sp = adv_get_next_carrier(asc_dvc); in AdvInitAsc38C0800Driver()
5259 if (!asc_dvc->irq_sp) { in AdvInitAsc38C0800Driver()
5261 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; in AdvInitAsc38C0800Driver()
5270 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa); in AdvInitAsc38C0800Driver()
5271 asc_dvc->carr_pending_cnt = 0; in AdvInitAsc38C0800Driver()
5288 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) { in AdvInitAsc38C0800Driver()
5294 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == in AdvInitAsc38C0800Driver()
5319 * Initialize the ASC-38C1600.
5323 * For a non-fatal error return a warning code. If there are no warnings
5344 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */ in AdvInitAsc38C1600Driver()
5349 if (asc_dvc->err_code != 0) { in AdvInitAsc38C1600Driver()
5356 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) { in AdvInitAsc38C1600Driver()
5357 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE; in AdvInitAsc38C1600Driver()
5362 iop_base = asc_dvc->iop_base; in AdvInitAsc38C1600Driver()
5390 * RAM BIST (Built-In Self Test) in AdvInitAsc38C1600Driver()
5393 * Function: Bit 7-6(RW) : RAM mode in AdvInitAsc38C1600Driver()
5395 * Pre-test Mode : 0x40 in AdvInitAsc38C1600Driver()
5396 * RAM Test Mode : 0x80 in AdvInitAsc38C1600Driver()
5399 * Bit 3-0(RO) : Status in AdvInitAsc38C1600Driver()
5411 * LRAM Pre-test in AdvInitAsc38C1600Driver()
5424 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST; in AdvInitAsc38C1600Driver()
5432 asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST; in AdvInitAsc38C1600Driver()
5438 * LRAM Test - It takes about 1.5 ms to run through the test. in AdvInitAsc38C1600Driver()
5450 asc_dvc->bist_err_code = byte; /* for BIOS display message */ in AdvInitAsc38C1600Driver()
5451 asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST; in AdvInitAsc38C1600Driver()
5455 /* We need to reset back to normal mode after LRAM test passes. */ in AdvInitAsc38C1600Driver()
5458 err = request_firmware(&fw, fwname, asc_dvc->drv_ptr->dev); in AdvInitAsc38C1600Driver()
5462 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM; in AdvInitAsc38C1600Driver()
5465 if (fw->size < 4) { in AdvInitAsc38C1600Driver()
5467 fw->size, fwname); in AdvInitAsc38C1600Driver()
5469 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM; in AdvInitAsc38C1600Driver()
5470 return -EINVAL; in AdvInitAsc38C1600Driver()
5472 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | in AdvInitAsc38C1600Driver()
5473 (fw->data[1] << 8) | fw->data[0]; in AdvInitAsc38C1600Driver()
5474 asc_dvc->err_code = AdvLoadMicrocode(iop_base, &fw->data[4], in AdvInitAsc38C1600Driver()
5475 fw->size - 4, ADV_38C1600_MEMSIZE, in AdvInitAsc38C1600Driver()
5478 if (asc_dvc->err_code) in AdvInitAsc38C1600Driver()
5506 asc_dvc->cfg->mcode_date); in AdvInitAsc38C1600Driver()
5508 asc_dvc->cfg->mcode_version); in AdvInitAsc38C1600Driver()
5533 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) { in AdvInitAsc38C1600Driver()
5545 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) { in AdvInitAsc38C1600Driver()
5552 * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4], in AdvInitAsc38C1600Driver()
5565 * the BIOS and warm boot to work without a SCSI bus hang on in AdvInitAsc38C1600Driver()
5567 * Without the SCSI Bus Reset, before an Inquiry a device can't in AdvInitAsc38C1600Driver()
5570 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) { in AdvInitAsc38C1600Driver()
5572 asc_dvc->wdtr_able); in AdvInitAsc38C1600Driver()
5574 asc_dvc->sdtr_able); in AdvInitAsc38C1600Driver()
5584 * without determining here whether the device supports SDTR. in AdvInitAsc38C1600Driver()
5587 asc_dvc->cfg->disc_enable); in AdvInitAsc38C1600Driver()
5588 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1); in AdvInitAsc38C1600Driver()
5589 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2); in AdvInitAsc38C1600Driver()
5590 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3); in AdvInitAsc38C1600Driver()
5591 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4); in AdvInitAsc38C1600Driver()
5601 asc_dvc->chip_scsi_id); in AdvInitAsc38C1600Driver()
5609 * Each ASC-38C1600 function has only two cable detect bits. in AdvInitAsc38C1600Driver()
5620 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE; in AdvInitAsc38C1600Driver()
5625 * Each ASC-38C1600 function has two connectors. Only an HVD device in AdvInitAsc38C1600Driver()
5633 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE; in AdvInitAsc38C1600Driver()
5638 * Each function in the ASC-38C1600 uses only the SE cable detect and in AdvInitAsc38C1600Driver()
5647 * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is in AdvInitAsc38C1600Driver()
5650 if ((asc_dvc->cfg->termination & TERM_SE) == 0) { in AdvInitAsc38C1600Driver()
5658 asc_dvc->cfg->termination |= TERM_SE; in AdvInitAsc38C1600Driver()
5662 if (PCI_FUNC(pdev->devfn) == 0) { in AdvInitAsc38C1600Driver()
5663 /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */ in AdvInitAsc38C1600Driver()
5665 /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */ in AdvInitAsc38C1600Driver()
5666 asc_dvc->cfg->termination |= TERM_SE_HI; in AdvInitAsc38C1600Driver()
5680 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE); in AdvInitAsc38C1600Driver()
5708 * MEM_CFG may be accessed as a word or byte, but only bits 0-7 in AdvInitAsc38C1600Driver()
5711 * ASC-38C1600 has 32KB internal memory. in AdvInitAsc38C1600Driver()
5713 * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come in AdvInitAsc38C1600Driver()
5731 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); in AdvInitAsc38C1600Driver()
5736 * Set-up the Host->RISC Initiator Command Queue (ICQ). in AdvInitAsc38C1600Driver()
5738 asc_dvc->icq_sp = adv_get_next_carrier(asc_dvc); in AdvInitAsc38C1600Driver()
5739 if (!asc_dvc->icq_sp) { in AdvInitAsc38C1600Driver()
5740 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; in AdvInitAsc38C1600Driver()
5749 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa); in AdvInitAsc38C1600Driver()
5751 le32_to_cpu(asc_dvc->icq_sp->carr_pa)); in AdvInitAsc38C1600Driver()
5754 * Set-up the RISC->Host Initiator Response Queue (IRQ). in AdvInitAsc38C1600Driver()
5756 asc_dvc->irq_sp = adv_get_next_carrier(asc_dvc); in AdvInitAsc38C1600Driver()
5757 if (!asc_dvc->irq_sp) { in AdvInitAsc38C1600Driver()
5758 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; in AdvInitAsc38C1600Driver()
5765 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa); in AdvInitAsc38C1600Driver()
5766 asc_dvc->carr_pending_cnt = 0; in AdvInitAsc38C1600Driver()
5782 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) { in AdvInitAsc38C1600Driver()
5787 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == in AdvInitAsc38C1600Driver()
5816 * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
5817 * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
5828 iop_base = asc_dvc->iop_base; in AdvResetChipAndSB()
5835 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) { in AdvResetChipAndSB()
5864 * re-initializing the chip. in AdvResetChipAndSB()
5866 asc_dvc->err_code = 0; in AdvResetChipAndSB()
5867 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) { in AdvResetChipAndSB()
5869 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) { in AdvResetChipAndSB()
5892 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) { in AdvResetChipAndSB()
5905 * adv_async_callback() - Adv Library asynchronous event callback function.
5941 * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
5947 struct asc_board *boardp = adv_dvc_varp->drv_ptr; in adv_isr_callback()
5963 scp = scsi_host_find_tag(boardp->shost, scsiqp->srb_tag); in adv_isr_callback()
5971 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len); in adv_isr_callback()
5973 reqp = (adv_req_t *)scp->host_scribble; in adv_isr_callback()
5983 scp->host_scribble = NULL; in adv_isr_callback()
5984 reqp->cmndp = NULL; in adv_isr_callback()
5986 ASC_STATS(boardp->shost, callback); in adv_isr_callback()
5987 ASC_DBG(1, "shost 0x%p\n", boardp->shost); in adv_isr_callback()
5989 sense_addr = le32_to_cpu(scsiqp->sense_addr); in adv_isr_callback()
5990 dma_unmap_single(boardp->dev, sense_addr, in adv_isr_callback()
5996 switch (scsiqp->done_status) { in adv_isr_callback()
5999 scp->result = 0; in adv_isr_callback()
6007 resid_cnt = le32_to_cpu(scsiqp->data_cnt); in adv_isr_callback()
6018 switch (scsiqp->host_status) { in adv_isr_callback()
6020 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) { in adv_isr_callback()
6022 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, in adv_isr_callback()
6036 scp->result = DRIVER_BYTE(DRIVER_SENSE) | in adv_isr_callback()
6037 STATUS_BYTE(scsiqp->scsi_status); in adv_isr_callback()
6039 scp->result = STATUS_BYTE(scsiqp->scsi_status); in adv_isr_callback()
6045 ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status); in adv_isr_callback()
6046 scp->result = HOST_BYTE(DID_BAD_TARGET); in adv_isr_callback()
6053 scp->result = in adv_isr_callback()
6054 HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status); in adv_isr_callback()
6058 ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status); in adv_isr_callback()
6059 scp->result = in adv_isr_callback()
6060 HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status); in adv_isr_callback()
6069 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 && in adv_isr_callback()
6070 scsiqp->done_status == QD_NO_ERROR && in adv_isr_callback()
6071 scsiqp->host_status == QHSTA_NO_ERROR) { in adv_isr_callback()
6072 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id); in adv_isr_callback()
6080 while ((sgblkp = reqp->sgblkp) != NULL) { in adv_isr_callback()
6082 reqp->sgblkp = sgblkp->next_sgblkp; in adv_isr_callback()
6084 dma_pool_free(boardp->adv_sgblk_pool, sgblkp, in adv_isr_callback()
6085 sgblkp->sg_addr); in adv_isr_callback()
6095 * The function disables and re-enables interrupts.
6107 * ADV_TRUE(1) - interrupt was pending
6108 * ADV_FALSE(0) - no interrupt was pending
6120 iop_base = asc_dvc->iop_base; in AdvISR()
6140 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 || in AdvISR()
6141 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) { in AdvISR()
6143 asc_dvc->carr_pending_cnt != 0) { in AdvISR()
6146 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) { in AdvISR()
6161 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ADV_RQ_DONE) != 0) { in AdvISR()
6171 u32 pa_offset = le32_to_cpu(asc_dvc->irq_sp->areq_vpa); in AdvISR()
6173 asc_dvc->irq_sp, pa_offset); in AdvISR()
6175 scsiq = &reqp->scsi_req_q; in AdvISR()
6183 scsiq->done_status = QD_NO_ERROR; in AdvISR()
6184 scsiq->host_status = scsiq->scsi_status = 0; in AdvISR()
6185 scsiq->data_cnt = 0L; in AdvISR()
6193 free_carrp = asc_dvc->irq_sp; in AdvISR()
6194 asc_dvc->irq_sp = adv_get_carrier(asc_dvc, in AdvISR()
6197 free_carrp->next_vpa = asc_dvc->carr_freelist->carr_va; in AdvISR()
6198 asc_dvc->carr_freelist = free_carrp; in AdvISR()
6199 asc_dvc->carr_pending_cnt--; in AdvISR()
6201 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id); in AdvISR()
6206 scsiq->cntl = 0; in AdvISR()
6226 if (asc_dvc->err_code == 0) { in AscSetLibErrorCode()
6227 asc_dvc->err_code = err_code; in AscSetLibErrorCode()
6228 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W, in AscSetLibErrorCode()
6270 period_table = asc_dvc->sdtr_period_tbl; in AscGetSynPeriodIndex()
6271 max_index = (int)asc_dvc->max_sdtr_index; in AscGetSynPeriodIndex()
6272 min_index = (int)asc_dvc->min_sdtr_index; in AscGetSynPeriodIndex()
6274 for (i = min_index; i < (max_index - 1); i++) { in AscGetSynPeriodIndex()
6288 PortAddr iop_base = asc_dvc->iop_base; in AscMsgOutSDTR()
6299 if (sdtr_period_index <= asc_dvc->max_sdtr_index) { in AscMsgOutSDTR()
6320 if (sdtr_period_ix > asc_dvc->max_sdtr_index) in AscCalSDTRData()
6382 BUG_ON(!asc_dvc->drv_ptr); in AscIsrChipHalted()
6383 boardp = asc_dvc->drv_ptr; in AscIsrChipHalted()
6385 iop_base = asc_dvc->iop_base; in AscIsrChipHalted()
6397 if (asc_dvc->pci_fix_asyn_xfer & target_id) { in AscIsrChipHalted()
6403 if (asc_dvc->pci_fix_asyn_xfer & target_id) { in AscIsrChipHalted()
6405 boardp->sdtr_data[tid_no] = 0; in AscIsrChipHalted()
6410 if (asc_dvc->pci_fix_asyn_xfer & target_id) { in AscIsrChipHalted()
6412 boardp->sdtr_data[tid_no] = asyn_sdtr; in AscIsrChipHalted()
6432 asc_dvc->sdtr_period_tbl[asc_dvc->min_sdtr_index]) in AscIsrChipHalted()
6434 asc_dvc->sdtr_period_tbl[asc_dvc-> in AscIsrChipHalted()
6438 asc_dvc->sdtr_period_tbl[asc_dvc-> in AscIsrChipHalted()
6448 asc_dvc->init_sdtr &= ~target_id; in AscIsrChipHalted()
6449 asc_dvc->sdtr_done &= ~target_id; in AscIsrChipHalted()
6452 boardp->sdtr_data[tid_no] = asyn_sdtr; in AscIsrChipHalted()
6458 asc_dvc->init_sdtr &= ~target_id; in AscIsrChipHalted()
6459 asc_dvc->sdtr_done &= ~target_id; in AscIsrChipHalted()
6464 asc_dvc->sdtr_done |= target_id; in AscIsrChipHalted()
6465 asc_dvc->init_sdtr |= target_id; in AscIsrChipHalted()
6466 asc_dvc->pci_fix_asyn_xfer &= in AscIsrChipHalted()
6475 boardp->sdtr_data[tid_no] = sdtr_data; in AscIsrChipHalted()
6481 asc_dvc->pci_fix_asyn_xfer &= in AscIsrChipHalted()
6490 boardp->sdtr_data[tid_no] = sdtr_data; in AscIsrChipHalted()
6491 asc_dvc->sdtr_done |= target_id; in AscIsrChipHalted()
6492 asc_dvc->init_sdtr |= target_id; in AscIsrChipHalted()
6537 if ((asc_dvc->init_sdtr & target_id) != 0) { in AscIsrChipHalted()
6539 asc_dvc->sdtr_done &= ~target_id; in AscIsrChipHalted()
6544 asc_dvc-> in AscIsrChipHalted()
6546 (uchar)(asc_dvc-> in AscIsrChipHalted()
6547 max_sdtr_index - in AscIsrChipHalted()
6561 if ((asc_dvc->pci_fix_asyn_xfer & target_id) in AscIsrChipHalted()
6562 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id) in AscIsrChipHalted()
6600 asc_dvc->init_sdtr &= ~target_id; in AscIsrChipHalted()
6601 asc_dvc->sdtr_done &= ~target_id; in AscIsrChipHalted()
6603 boardp->sdtr_data[tid_no] = asyn_sdtr; in AscIsrChipHalted()
6621 if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) { in AscIsrChipHalted()
6628 asc_dvc->queue_full_or_busy |= target_id; in AscIsrChipHalted()
6632 cur_dvc_qng -= 1; in AscIsrChipHalted()
6633 asc_dvc->max_dvc_qng[tid_no] = in AscIsrChipHalted()
6648 boardp->queue_full |= target_id; in AscIsrChipHalted()
6649 boardp->queue_full_cnt[tid_no] = in AscIsrChipHalted()
6703 scsiq->q_status = (uchar)_val; in _AscCopyLramScsiDoneQ()
6704 scsiq->q_no = (uchar)(_val >> 8); in _AscCopyLramScsiDoneQ()
6707 scsiq->cntl = (uchar)_val; in _AscCopyLramScsiDoneQ()
6712 scsiq->sense_len = (uchar)_val; in _AscCopyLramScsiDoneQ()
6713 scsiq->extra_bytes = (uchar)(_val >> 8); in _AscCopyLramScsiDoneQ()
6718 scsiq->remain_bytes = (((u32)AscReadLramWord(iop_base, in _AscCopyLramScsiDoneQ()
6726 scsiq->remain_bytes += AscReadLramWord(iop_base, in _AscCopyLramScsiDoneQ()
6730 scsiq->remain_bytes &= max_dma_count; in _AscCopyLramScsiDoneQ()
6735 * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
6741 struct asc_board *boardp = asc_dvc_varp->drv_ptr; in asc_isr_callback()
6751 srb_tag = qdonep->d2.srb_tag - 1; in asc_isr_callback()
6752 scp = scsi_host_find_tag(boardp->shost, srb_tag); in asc_isr_callback()
6756 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len); in asc_isr_callback()
6758 ASC_STATS(boardp->shost, callback); in asc_isr_callback()
6760 dma_unmap_single(boardp->dev, scp->SCp.dma_handle, in asc_isr_callback()
6765 switch (qdonep->d3.done_stat) { in asc_isr_callback()
6768 scp->result = 0; in asc_isr_callback()
6776 if (scsi_bufflen(scp) != 0 && qdonep->remain_bytes != 0 && in asc_isr_callback()
6777 qdonep->remain_bytes <= scsi_bufflen(scp)) { in asc_isr_callback()
6779 (unsigned)qdonep->remain_bytes); in asc_isr_callback()
6780 scsi_set_resid(scp, qdonep->remain_bytes); in asc_isr_callback()
6786 switch (qdonep->d3.host_stat) { in asc_isr_callback()
6788 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) { in asc_isr_callback()
6790 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, in asc_isr_callback()
6804 scp->result = DRIVER_BYTE(DRIVER_SENSE) | in asc_isr_callback()
6805 STATUS_BYTE(qdonep->d3.scsi_stat); in asc_isr_callback()
6807 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat); in asc_isr_callback()
6813 ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat); in asc_isr_callback()
6814 scp->result = HOST_BYTE(DID_BAD_TARGET); in asc_isr_callback()
6821 scp->result = in asc_isr_callback()
6822 HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3. in asc_isr_callback()
6824 STATUS_BYTE(qdonep->d3.scsi_stat); in asc_isr_callback()
6828 ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat); in asc_isr_callback()
6829 scp->result = in asc_isr_callback()
6830 HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3. in asc_isr_callback()
6832 STATUS_BYTE(qdonep->d3.scsi_stat); in asc_isr_callback()
6841 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 && in asc_isr_callback()
6842 qdonep->d3.done_stat == QD_NO_ERROR && in asc_isr_callback()
6843 qdonep->d3.host_stat == QHSTA_NO_ERROR) { in asc_isr_callback()
6844 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id); in asc_isr_callback()
6869 iop_base = asc_dvc->iop_base; in AscIsrQDone()
6880 asc_dvc->max_dma_count); in AscIsrQDone()
6884 (uchar)(scsiq-> in AscIsrQDone()
6887 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix); in AscIsrQDone()
6888 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix); in AscIsrQDone()
6889 if ((scsiq->cntl & QC_SG_HEAD) != 0) { in AscIsrQDone()
6901 scsiq->d3.done_stat = QD_WITH_ERROR; in AscIsrQDone()
6902 scsiq->d3.host_stat = in AscIsrQDone()
6914 if (asc_dvc->queue_full_or_busy & target_id) { in AscIsrQDone()
6919 scsiq->d2. in AscIsrQDone()
6921 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) { in AscIsrQDone()
6928 asc_dvc->queue_full_or_busy &= ~target_id; in AscIsrQDone()
6931 if (asc_dvc->cur_total_qng >= n_q_used) { in AscIsrQDone()
6932 asc_dvc->cur_total_qng -= n_q_used; in AscIsrQDone()
6933 if (asc_dvc->cur_dvc_qng[tid_no] != 0) { in AscIsrQDone()
6934 asc_dvc->cur_dvc_qng[tid_no]--; in AscIsrQDone()
6938 scsiq->d3.done_stat = QD_WITH_ERROR; in AscIsrQDone()
6941 if ((scsiq->d2.srb_tag == 0UL) || in AscIsrQDone()
6942 ((scsiq->q_status & QS_ABORTED) != 0)) { in AscIsrQDone()
6944 } else if (scsiq->q_status == QS_DONE) { in AscIsrQDone()
6950 if (scsiq->extra_bytes != 0) { in AscIsrQDone()
6951 scsiq->remain_bytes += scsiq->extra_bytes; in AscIsrQDone()
6953 if (scsiq->d3.done_stat == QD_WITH_ERROR) { in AscIsrQDone()
6954 if (scsiq->d3.host_stat == in AscIsrQDone()
6956 if ((scsiq-> in AscIsrQDone()
6959 scsiq->d3.done_stat = in AscIsrQDone()
6961 scsiq->d3.host_stat = in AscIsrQDone()
6964 scsiq->d3.done_stat = in AscIsrQDone()
6966 scsiq->d3.host_stat = in AscIsrQDone()
6969 } else if (scsiq->d3.host_stat == in AscIsrQDone()
6983 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) { in AscIsrQDone()
6990 asc_dvc->unit_not_ready &= ~target_id; in AscIsrQDone()
6991 if (scsiq->d3.done_stat != QD_NO_ERROR) { in AscIsrQDone()
6992 asc_dvc->start_motor &= in AscIsrQDone()
7001 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) { in AscIsrQDone()
7021 iop_base = asc_dvc->iop_base; in AscISR()
7027 if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) { in AscISR()
7030 if (asc_dvc->in_critical_cnt != 0) { in AscISR()
7034 if (asc_dvc->is_in_int) { in AscISR()
7038 asc_dvc->is_in_int = true; in AscISR()
7044 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) { in AscISR()
7047 asc_dvc->sdtr_done = 0; in AscISR()
7050 CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) { in AscISR()
7073 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) { in AscISR()
7092 asc_dvc->is_in_int = false; in AscISR()
7107 struct Scsi_Host *shost = scp->device->host; in advansys_reset()
7120 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var; in advansys_reset()
7127 if (asc_dvc->err_code || !asc_dvc->overrun_dma) { in advansys_reset()
7129 "0x%x, status: 0x%x\n", asc_dvc->err_code, in advansys_reset()
7146 ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var; in advansys_reset()
7163 spin_lock_irqsave(shost->host_lock, flags); in advansys_reset()
7165 spin_unlock_irqrestore(shost->host_lock, flags); in advansys_reset()
7188 struct asc_board *boardp = shost_priv(sdev->host); in advansys_biosparam()
7191 ASC_STATS(sdev->host, biosparam); in advansys_biosparam()
7193 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl & in advansys_biosparam()
7202 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl & in advansys_biosparam()
7217 * First-level interrupt handler.
7229 spin_lock_irqsave(shost->host_lock, flags); in advansys_interrupt()
7231 if (AscIsIntPending(shost->io_port)) { in advansys_interrupt()
7235 AscISR(&boardp->dvc_var.asc_dvc_var); in advansys_interrupt()
7239 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) { in advansys_interrupt()
7244 spin_unlock_irqrestore(shost->host_lock, flags); in advansys_interrupt()
7286 char type = sdev->type; in AscAsyncFix()
7287 ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id; in AscAsyncFix()
7289 if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN)) in AscAsyncFix()
7291 if (asc_dvc->init_sdtr & tid_bits) in AscAsyncFix()
7294 if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0)) in AscAsyncFix()
7295 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits; in AscAsyncFix()
7297 asc_dvc->pci_fix_asyn_xfer |= tid_bits; in AscAsyncFix()
7300 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits; in AscAsyncFix()
7302 if (asc_dvc->pci_fix_asyn_xfer & tid_bits) in AscAsyncFix()
7303 AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id, in AscAsyncFix()
7310 ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id; in advansys_narrow_slave_configure()
7311 ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng; in advansys_narrow_slave_configure()
7313 if (sdev->lun == 0) { in advansys_narrow_slave_configure()
7314 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr; in advansys_narrow_slave_configure()
7315 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) { in advansys_narrow_slave_configure()
7316 asc_dvc->init_sdtr |= tid_bit; in advansys_narrow_slave_configure()
7318 asc_dvc->init_sdtr &= ~tid_bit; in advansys_narrow_slave_configure()
7321 if (orig_init_sdtr != asc_dvc->init_sdtr) in advansys_narrow_slave_configure()
7325 if (sdev->tagged_supported) { in advansys_narrow_slave_configure()
7326 if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) { in advansys_narrow_slave_configure()
7327 if (sdev->lun == 0) { in advansys_narrow_slave_configure()
7328 asc_dvc->cfg->can_tagged_qng |= tid_bit; in advansys_narrow_slave_configure()
7329 asc_dvc->use_tagged_qng |= tid_bit; in advansys_narrow_slave_configure()
7332 asc_dvc->max_dvc_qng[sdev->id]); in advansys_narrow_slave_configure()
7335 if (sdev->lun == 0) { in advansys_narrow_slave_configure()
7336 asc_dvc->cfg->can_tagged_qng &= ~tid_bit; in advansys_narrow_slave_configure()
7337 asc_dvc->use_tagged_qng &= ~tid_bit; in advansys_narrow_slave_configure()
7341 if ((sdev->lun == 0) && in advansys_narrow_slave_configure()
7342 (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) { in advansys_narrow_slave_configure()
7343 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B, in advansys_narrow_slave_configure()
7344 asc_dvc->cfg->disc_enable); in advansys_narrow_slave_configure()
7345 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B, in advansys_narrow_slave_configure()
7346 asc_dvc->use_tagged_qng); in advansys_narrow_slave_configure()
7347 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B, in advansys_narrow_slave_configure()
7348 asc_dvc->cfg->can_tagged_qng); in advansys_narrow_slave_configure()
7350 asc_dvc->max_dvc_qng[sdev->id] = in advansys_narrow_slave_configure()
7351 asc_dvc->cfg->max_tag_qng[sdev->id]; in advansys_narrow_slave_configure()
7352 AscWriteLramByte(asc_dvc->iop_base, in advansys_narrow_slave_configure()
7353 (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id), in advansys_narrow_slave_configure()
7354 asc_dvc->max_dvc_qng[sdev->id]); in advansys_narrow_slave_configure()
7428 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able); in advansys_wide_enable_ppr()
7429 adv_dvc->ppr_able |= tidmask; in advansys_wide_enable_ppr()
7430 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able); in advansys_wide_enable_ppr()
7436 AdvPortAddr iop_base = adv_dvc->iop_base; in advansys_wide_slave_configure()
7437 unsigned short tidmask = 1 << sdev->id; in advansys_wide_slave_configure()
7439 if (sdev->lun == 0) { in advansys_wide_slave_configure()
7446 if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr) in advansys_wide_slave_configure()
7448 if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr) in advansys_wide_slave_configure()
7450 if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr) in advansys_wide_slave_configure()
7459 if ((adv_dvc->tagqng_able & tidmask) && in advansys_wide_slave_configure()
7460 sdev->tagged_supported) { in advansys_wide_slave_configure()
7467 ASC_MC_NUMBER_OF_MAX_CMD + sdev->id, in advansys_wide_slave_configure()
7468 adv_dvc->max_dvc_qng); in advansys_wide_slave_configure()
7472 if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) in advansys_wide_slave_configure()
7473 scsi_change_queue_depth(sdev, adv_dvc->max_dvc_qng); in advansys_wide_slave_configure()
7482 struct asc_board *boardp = shost_priv(sdev->host); in advansys_slave_configure()
7486 &boardp->dvc_var.asc_dvc_var); in advansys_slave_configure()
7489 &boardp->dvc_var.adv_dvc_var); in advansys_slave_configure()
7496 struct asc_board *board = shost_priv(scp->device->host); in asc_get_sense_buffer_dma()
7498 scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer, in asc_get_sense_buffer_dma()
7501 if (dma_mapping_error(board->dev, scp->SCp.dma_handle)) { in asc_get_sense_buffer_dma()
7505 return cpu_to_le32(scp->SCp.dma_handle); in asc_get_sense_buffer_dma()
7511 struct asc_dvc_var *asc_dvc = &boardp->dvc_var.asc_dvc_var; in asc_build_req()
7521 srb_tag = scp->request->tag + 1; in asc_build_req()
7522 asc_scsi_q->q2.srb_tag = srb_tag; in asc_build_req()
7527 asc_scsi_q->cdbptr = &scp->cmnd[0]; in asc_build_req()
7528 asc_scsi_q->q2.cdb_len = scp->cmd_len; in asc_build_req()
7529 asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id); in asc_build_req()
7530 asc_scsi_q->q1.target_lun = scp->device->lun; in asc_build_req()
7531 asc_scsi_q->q2.target_ix = in asc_build_req()
7532 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun); in asc_build_req()
7533 asc_scsi_q->q1.sense_addr = asc_get_sense_buffer_dma(scp); in asc_build_req()
7534 asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE; in asc_build_req()
7535 if (!asc_scsi_q->q1.sense_addr) in asc_build_req()
7549 if ((asc_dvc->cur_dvc_qng[scp->device->id] > 0) && in asc_build_req()
7550 (boardp->reqcnt[scp->device->id] % 255) == 0) { in asc_build_req()
7551 asc_scsi_q->q2.tag_code = ORDERED_QUEUE_TAG; in asc_build_req()
7553 asc_scsi_q->q2.tag_code = SIMPLE_QUEUE_TAG; in asc_build_req()
7566 if (use_sg > scp->device->host->sg_tablesize) { in asc_build_req()
7569 scp->device->host->sg_tablesize); in asc_build_req()
7571 scp->result = HOST_BYTE(DID_ERROR); in asc_build_req()
7575 asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) + in asc_build_req()
7579 scp->result = HOST_BYTE(DID_SOFT_ERROR); in asc_build_req()
7583 asc_scsi_q->q1.cntl |= QC_SG_HEAD; in asc_build_req()
7584 asc_scsi_q->sg_head = asc_sg_head; in asc_build_req()
7585 asc_scsi_q->q1.data_cnt = 0; in asc_build_req()
7586 asc_scsi_q->q1.data_addr = 0; in asc_build_req()
7588 asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg; in asc_build_req()
7589 ASC_STATS_ADD(scp->device->host, xfer_elem, in asc_build_req()
7590 asc_sg_head->entry_cnt); in asc_build_req()
7593 * Convert scatter-gather list into ASC_SG_HEAD list. in asc_build_req()
7596 asc_sg_head->sg_list[sgcnt].addr = in asc_build_req()
7598 asc_sg_head->sg_list[sgcnt].bytes = in asc_build_req()
7600 ASC_STATS_ADD(scp->device->host, xfer_sect, in asc_build_req()
7605 ASC_STATS(scp->device->host, xfer_cnt); in asc_build_req()
7608 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); in asc_build_req()
7614 * Build scatter-gather list for Adv Library (Wide Board).
7617 * if the total number of scatter-gather elements exceeds
7622 * ADV_SUCCESS(1) - SG List successfully created
7623 * ADV_ERROR(-1) - SG List creation failed
7640 reqp->sgblkp = NULL; in adv_get_sglist()
7646 * (15) scatter-gather elements. in adv_get_sglist()
7648 sgblkp = dma_pool_alloc(boardp->adv_sgblk_pool, GFP_ATOMIC, in adv_get_sglist()
7652 ASC_STATS(scp->device->host, adv_build_nosg); in adv_get_sglist()
7658 while ((sgblkp = reqp->sgblkp) != NULL) { in adv_get_sglist()
7660 reqp->sgblkp = sgblkp->next_sgblkp; in adv_get_sglist()
7661 sgblkp->next_sgblkp = NULL; in adv_get_sglist()
7662 dma_pool_free(boardp->adv_sgblk_pool, sgblkp, in adv_get_sglist()
7663 sgblkp->sg_addr); in adv_get_sglist()
7668 sgblkp->sg_addr = sgblk_paddr; in adv_get_sglist()
7669 sgblkp->next_sgblkp = NULL; in adv_get_sglist()
7670 sg_block = &sgblkp->sg_block; in adv_get_sglist()
7676 if (reqp->sgblkp == NULL) { in adv_get_sglist()
7677 /* Request's first scatter-gather block. */ in adv_get_sglist()
7678 reqp->sgblkp = sgblkp; in adv_get_sglist()
7684 scsiqp->sg_list_ptr = sg_block; in adv_get_sglist()
7685 scsiqp->sg_real_addr = cpu_to_le32(sgblk_paddr); in adv_get_sglist()
7687 /* Request's second or later scatter-gather block. */ in adv_get_sglist()
7688 prev_sgblkp->next_sgblkp = sgblkp; in adv_get_sglist()
7694 prev_sg_block->sg_ptr = cpu_to_le32(sgblk_paddr); in adv_get_sglist()
7698 sg_block->sg_list[i].sg_addr = in adv_get_sglist()
7700 sg_block->sg_list[i].sg_count = in adv_get_sglist()
7702 ASC_STATS_ADD(scp->device->host, xfer_sect, in adv_get_sglist()
7705 if (--sg_elem_cnt == 0) { in adv_get_sglist()
7707 * Last ADV_SG_BLOCK and scatter-gather entry. in adv_get_sglist()
7709 sg_block->sg_cnt = i + 1; in adv_get_sglist()
7710 sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */ in adv_get_sglist()
7715 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK; in adv_get_sglist()
7727 * Multi-byte fields in the ADV_SCSI_REQ_Q that are used by the
7729 * to little-endian order.
7735 u32 srb_tag = scp->request->tag; in adv_build_req()
7746 reqp = &boardp->adv_reqp[srb_tag]; in adv_build_req()
7747 if (reqp->cmndp && reqp->cmndp != scp ) { in adv_build_req()
7749 ASC_STATS(scp->device->host, adv_build_noreq); in adv_build_req()
7753 reqp->req_addr = boardp->adv_reqp_addr + (srb_tag * sizeof(adv_req_t)); in adv_build_req()
7755 scsiqp = &reqp->scsi_req_q; in adv_build_req()
7760 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0; in adv_build_req()
7765 scsiqp->srb_tag = srb_tag; in adv_build_req()
7770 reqp->cmndp = scp; in adv_build_req()
7771 scp->host_scribble = (void *)reqp; in adv_build_req()
7778 scsiqp->cdb_len = scp->cmd_len; in adv_build_req()
7780 memcpy(scsiqp->cdb, scp->cmnd, scp->cmd_len < 12 ? scp->cmd_len : 12); in adv_build_req()
7782 if (scp->cmd_len > 12) { in adv_build_req()
7783 int cdb16_len = scp->cmd_len - 12; in adv_build_req()
7785 memcpy(scsiqp->cdb16, &scp->cmnd[12], cdb16_len); in adv_build_req()
7788 scsiqp->target_id = scp->device->id; in adv_build_req()
7789 scsiqp->target_lun = scp->device->lun; in adv_build_req()
7791 sense_addr = dma_map_single(boardp->dev, scp->sense_buffer, in adv_build_req()
7793 if (dma_mapping_error(boardp->dev, sense_addr)) { in adv_build_req()
7795 ASC_STATS(scp->device->host, adv_build_noreq); in adv_build_req()
7798 scsiqp->sense_addr = cpu_to_le32(sense_addr); in adv_build_req()
7799 scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE; in adv_build_req()
7806 ASC_STATS(scp->device->host, adv_build_noreq); in adv_build_req()
7809 /* Zero-length transfer */ in adv_build_req()
7810 reqp->sgblkp = NULL; in adv_build_req()
7811 scsiqp->data_cnt = 0; in adv_build_req()
7813 scsiqp->data_addr = 0; in adv_build_req()
7814 scsiqp->sg_list_ptr = NULL; in adv_build_req()
7815 scsiqp->sg_real_addr = 0; in adv_build_req()
7820 scp->device->host->sg_tablesize); in adv_build_req()
7822 scp->result = HOST_BYTE(DID_ERROR); in adv_build_req()
7823 reqp->cmndp = NULL; in adv_build_req()
7824 scp->host_scribble = NULL; in adv_build_req()
7829 scsiqp->data_cnt = cpu_to_le32(scsi_bufflen(scp)); in adv_build_req()
7834 scp->result = HOST_BYTE(DID_ERROR); in adv_build_req()
7835 reqp->cmndp = NULL; in adv_build_req()
7836 scp->host_scribble = NULL; in adv_build_req()
7841 ASC_STATS_ADD(scp->device->host, xfer_elem, use_sg); in adv_build_req()
7844 ASC_STATS(scp->device->host, xfer_cnt); in adv_build_req()
7847 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); in adv_build_req()
7858 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q); in AscSgListToQueue()
7859 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0) in AscSgListToQueue()
7874 if ((asc_dvc->unit_not_ready & target_id) || in AscGetNumOfFreeQueue()
7875 (asc_dvc->queue_full_or_busy & target_id)) { in AscGetNumOfFreeQueue()
7879 cur_used_qs = (uint) asc_dvc->cur_total_qng + in AscGetNumOfFreeQueue()
7880 (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q; in AscGetNumOfFreeQueue()
7882 cur_used_qs = (uint) asc_dvc->cur_total_qng + in AscGetNumOfFreeQueue()
7885 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) { in AscGetNumOfFreeQueue()
7886 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs; in AscGetNumOfFreeQueue()
7887 if (asc_dvc->cur_dvc_qng[tid_no] >= in AscGetNumOfFreeQueue()
7888 asc_dvc->max_dvc_qng[tid_no]) { in AscGetNumOfFreeQueue()
7894 if ((n_qs > asc_dvc->last_q_shortage) in AscGetNumOfFreeQueue()
7895 && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) { in AscGetNumOfFreeQueue()
7896 asc_dvc->last_q_shortage = n_qs; in AscGetNumOfFreeQueue()
7966 iop_base = asc_dvc->iop_base; in AscPutReadyQueue()
7967 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) && in AscPutReadyQueue()
7968 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) { in AscPutReadyQueue()
7969 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix); in AscPutReadyQueue()
7972 (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1); in AscPutReadyQueue()
7975 asc_dvc->sdtr_period_tbl[syn_period_ix], in AscPutReadyQueue()
7977 scsiq->q1.cntl |= QC_MSG_OUT; in AscPutReadyQueue()
7980 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) { in AscPutReadyQueue()
7981 scsiq->q2.tag_code &= ~SIMPLE_QUEUE_TAG; in AscPutReadyQueue()
7983 scsiq->q1.status = QS_FREE; in AscPutReadyQueue()
7986 (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1); in AscPutReadyQueue()
7990 (uchar *)&scsiq->q1.cntl, in AscPutReadyQueue()
7991 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1); in AscPutReadyQueue()
7994 (ushort)(((ushort)scsiq->q1. in AscPutReadyQueue()
8015 iop_base = asc_dvc->iop_base; in AscPutReadySgListQueue()
8016 sg_head = scsiq->sg_head; in AscPutReadySgListQueue()
8017 saved_data_addr = scsiq->q1.data_addr; in AscPutReadySgListQueue()
8018 saved_data_cnt = scsiq->q1.data_cnt; in AscPutReadySgListQueue()
8019 scsiq->q1.data_addr = cpu_to_le32(sg_head->sg_list[0].addr); in AscPutReadySgListQueue()
8020 scsiq->q1.data_cnt = cpu_to_le32(sg_head->sg_list[0].bytes); in AscPutReadySgListQueue()
8026 sg_entry_cnt = sg_head->entry_cnt - 1; in AscPutReadySgListQueue()
8029 scsiq->q1.cntl |= QC_SG_HEAD; in AscPutReadySgListQueue()
8032 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt; in AscPutReadySgListQueue()
8035 for (i = 0; i < sg_head->queue_cnt; i++) { in AscPutReadySgListQueue()
8039 sg_entry_cnt -= ASC_SG_LIST_PER_Q; in AscPutReadySgListQueue()
8047 ASC_SG_LIST_PER_Q - 1; in AscPutReadySgListQueue()
8049 ASC_SG_LIST_PER_Q - 1; in AscPutReadySgListQueue()
8060 sg_entry_cnt - 1; in AscPutReadySgListQueue()
8062 sg_entry_cnt - 1; in AscPutReadySgListQueue()
8077 (uchar *)&sg_head-> in AscPutReadySgListQueue()
8081 scsiq->next_sg_index = sg_index; in AscPutReadySgListQueue()
8084 scsiq->q1.cntl &= ~QC_SG_HEAD; in AscPutReadySgListQueue()
8087 scsiq->q1.data_addr = saved_data_addr; in AscPutReadySgListQueue()
8088 scsiq->q1.data_cnt = saved_data_cnt; in AscPutReadySgListQueue()
8102 iop_base = asc_dvc->iop_base; in AscSendScsiQueue()
8103 target_ix = scsiq->q2.target_ix; in AscSendScsiQueue()
8111 asc_dvc->last_q_shortage = 0; in AscSendScsiQueue()
8112 scsiq->sg_head->queue_cnt = n_q_required - 1; in AscSendScsiQueue()
8113 scsiq->q1.q_no = free_q_head; in AscSendScsiQueue()
8120 scsiq->q1.q_no = free_q_head; in AscSendScsiQueue()
8126 asc_dvc->cur_total_qng += n_q_required; in AscSendScsiQueue()
8127 asc_dvc->cur_dvc_qng[tid_no]++; in AscSendScsiQueue()
8171 iop_base = asc_dvc->iop_base; in AscExeScsiQueue()
8172 sg_head = scsiq->sg_head; in AscExeScsiQueue()
8173 if (asc_dvc->err_code != 0) in AscExeScsiQueue()
8175 scsiq->q1.q_no = 0; in AscExeScsiQueue()
8176 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) { in AscExeScsiQueue()
8177 scsiq->q1.extra_bytes = 0; in AscExeScsiQueue()
8180 target_ix = scsiq->q2.target_ix; in AscExeScsiQueue()
8183 if (scsiq->cdbptr[0] == REQUEST_SENSE) { in AscExeScsiQueue()
8184 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) { in AscExeScsiQueue()
8185 asc_dvc->sdtr_done &= ~scsiq->q1.target_id; in AscExeScsiQueue()
8188 asc_dvc-> in AscExeScsiQueue()
8190 (uchar)(asc_dvc-> in AscExeScsiQueue()
8191 max_sdtr_index - in AscExeScsiQueue()
8195 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT); in AscExeScsiQueue()
8198 if (asc_dvc->in_critical_cnt != 0) { in AscExeScsiQueue()
8202 asc_dvc->in_critical_cnt++; in AscExeScsiQueue()
8203 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) { in AscExeScsiQueue()
8204 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) { in AscExeScsiQueue()
8205 asc_dvc->in_critical_cnt--; in AscExeScsiQueue()
8209 asc_dvc->in_critical_cnt--; in AscExeScsiQueue()
8213 scsiq->q1.data_addr = cpu_to_le32(sg_head->sg_list[0].addr); in AscExeScsiQueue()
8214 scsiq->q1.data_cnt = cpu_to_le32(sg_head->sg_list[0].bytes); in AscExeScsiQueue()
8215 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE); in AscExeScsiQueue()
8217 sg_entry_cnt_minus_one = sg_entry_cnt - 1; in AscExeScsiQueue()
8219 scsi_cmd = scsiq->cdbptr[0]; in AscExeScsiQueue()
8221 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) && in AscExeScsiQueue()
8222 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) { in AscExeScsiQueue()
8223 if (scsiq->q1.cntl & QC_SG_HEAD) { in AscExeScsiQueue()
8226 data_cnt += le32_to_cpu(sg_head->sg_list[i]. in AscExeScsiQueue()
8230 data_cnt = le32_to_cpu(scsiq->q1.data_cnt); in AscExeScsiQueue()
8253 scsiq->q2.tag_code &= ~SIMPLE_QUEUE_TAG; in AscExeScsiQueue()
8254 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX | in AscExeScsiQueue()
8257 scsiq->q2.tag_code &= 0x27; in AscExeScsiQueue()
8259 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) { in AscExeScsiQueue()
8260 if (asc_dvc->bug_fix_cntl) { in AscExeScsiQueue()
8261 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) { in AscExeScsiQueue()
8264 addr = le32_to_cpu(sg_head-> in AscExeScsiQueue()
8268 le32_to_cpu(sg_head-> in AscExeScsiQueue()
8276 ((scsiq->q2. in AscExeScsiQueue()
8280 scsiq->q2.tag_code |= in AscExeScsiQueue()
8282 scsiq->q1.extra_bytes = in AscExeScsiQueue()
8285 le32_to_cpu(sg_head-> in AscExeScsiQueue()
8289 data_cnt -= extra_bytes; in AscExeScsiQueue()
8290 sg_head-> in AscExeScsiQueue()
8299 sg_head->entry_to_copy = sg_head->entry_cnt; in AscExeScsiQueue()
8303 || ((scsiq->q1.cntl & QC_URGENT) != 0)) { in AscExeScsiQueue()
8307 asc_dvc->in_critical_cnt--; in AscExeScsiQueue()
8312 if (asc_dvc->bug_fix_cntl) { in AscExeScsiQueue()
8313 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) { in AscExeScsiQueue()
8317 le32_to_cpu(scsiq->q1.data_addr) + in AscExeScsiQueue()
8318 le32_to_cpu(scsiq->q1.data_cnt); in AscExeScsiQueue()
8323 ((scsiq->q2. in AscExeScsiQueue()
8328 le32_to_cpu(scsiq->q1. in AscExeScsiQueue()
8332 scsiq->q2.tag_code |= in AscExeScsiQueue()
8334 data_cnt -= extra_bytes; in AscExeScsiQueue()
8335 scsiq->q1.data_cnt = in AscExeScsiQueue()
8338 scsiq->q1.extra_bytes = in AscExeScsiQueue()
8347 ((scsiq->q1.cntl & QC_URGENT) != 0)) { in AscExeScsiQueue()
8350 asc_dvc->in_critical_cnt--; in AscExeScsiQueue()
8355 asc_dvc->in_critical_cnt--; in AscExeScsiQueue()
8360 * AdvExeScsiQueue() - Send a request to the RISC microcode program.
8369 * Multi-byte fields in the ADV_SCSI_REQ_Q that are used by the microcode
8370 * for DMA addresses or math operations are byte swapped to little-endian
8374 * ADV_SUCCESS(1) - The request was successfully queued.
8375 * ADV_BUSY(0) - Resource unavailable; Retry again after pending
8377 * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
8384 ADV_SCSI_REQ_Q *scsiq = &reqp->scsi_req_q; in AdvExeScsiQueue()
8389 if (scsiq->target_id > ADV_MAX_TID) { in AdvExeScsiQueue()
8390 scsiq->host_status = QHSTA_M_INVALID_DEVICE; in AdvExeScsiQueue()
8391 scsiq->done_status = QD_WITH_ERROR; in AdvExeScsiQueue()
8395 iop_base = asc_dvc->iop_base; in AdvExeScsiQueue()
8407 asc_dvc->carr_pending_cnt++; in AdvExeScsiQueue()
8410 scsiq->scsiq_ptr = cpu_to_le32(scsiq->srb_tag); in AdvExeScsiQueue()
8411 scsiq->scsiq_rptr = cpu_to_le32(reqp->req_addr); in AdvExeScsiQueue()
8413 scsiq->carr_va = asc_dvc->icq_sp->carr_va; in AdvExeScsiQueue()
8414 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa; in AdvExeScsiQueue()
8421 asc_dvc->icq_sp->areq_vpa = scsiq->scsiq_rptr; in AdvExeScsiQueue()
8428 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa; in AdvExeScsiQueue()
8433 asc_dvc->icq_sp = new_carrp; in AdvExeScsiQueue()
8435 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 || in AdvExeScsiQueue()
8436 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) { in AdvExeScsiQueue()
8441 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) { in AdvExeScsiQueue()
8443 * Clear the tickle value. In the ASC-3550 the RISC flag in AdvExeScsiQueue()
8450 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) { in AdvExeScsiQueue()
8456 le32_to_cpu(new_carrp->carr_pa)); in AdvExeScsiQueue()
8468 struct asc_board *boardp = shost_priv(scp->device->host); in asc_execute_scsi_cmnd()
8473 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var; in asc_execute_scsi_cmnd()
8478 ASC_STATS(scp->device->host, build_error); in asc_execute_scsi_cmnd()
8484 err_code = asc_dvc->err_code; in asc_execute_scsi_cmnd()
8486 ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var; in asc_execute_scsi_cmnd()
8505 ASC_STATS(scp->device->host, build_error); in asc_execute_scsi_cmnd()
8510 err_code = adv_dvc->err_code; in asc_execute_scsi_cmnd()
8515 ASC_STATS(scp->device->host, exe_noerror); in asc_execute_scsi_cmnd()
8520 boardp->reqcnt[scp->device->id]++; in asc_execute_scsi_cmnd()
8525 ASC_STATS(scp->device->host, exe_busy); in asc_execute_scsi_cmnd()
8530 ASC_STATS(scp->device->host, exe_error); in asc_execute_scsi_cmnd()
8531 scp->result = HOST_BYTE(DID_ERROR); in asc_execute_scsi_cmnd()
8536 ASC_STATS(scp->device->host, exe_unknown); in asc_execute_scsi_cmnd()
8537 scp->result = HOST_BYTE(DID_ERROR); in asc_execute_scsi_cmnd()
8546 * advansys_queuecommand() - interrupt-driven I/O entrypoint.
8554 struct Scsi_Host *shost = scp->device->host; in advansys_queuecommand_lck()
8558 scp->scsi_done = done; in advansys_queuecommand_lck()
8597 * The PCI BIOS is re-located by the motherboard BIOS. Because in AscGetChipBiosAddress()
8655 return ASC_CHIP_MIN_VER_EISA - 1 + revision; in AscGetChipVersion()
8667 outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4))); in AscEnableIsaDma()
8668 outp(0x00D4, (ushort)(dma_channel - 4)); in AscEnableIsaDma()
8722 value = dma_channel - 4; in AscSetIsaDmaChannel()
8758 iop_base = asc_dvc->iop_base; in AscInitAscDvcVar()
8759 asc_dvc->err_code = 0; in AscInitAscDvcVar()
8760 if ((asc_dvc->bus_type & in AscInitAscDvcVar()
8762 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE; in AscInitAscDvcVar()
8766 asc_dvc->bug_fix_cntl = 0; in AscInitAscDvcVar()
8767 asc_dvc->pci_fix_asyn_xfer = 0; in AscInitAscDvcVar()
8768 asc_dvc->pci_fix_asyn_xfer_always = 0; in AscInitAscDvcVar()
8769 /* asc_dvc->init_state initialized in AscInitGetConfig(). */ in AscInitAscDvcVar()
8770 asc_dvc->sdtr_done = 0; in AscInitAscDvcVar()
8771 asc_dvc->cur_total_qng = 0; in AscInitAscDvcVar()
8772 asc_dvc->is_in_int = false; in AscInitAscDvcVar()
8773 asc_dvc->in_critical_cnt = 0; in AscInitAscDvcVar()
8774 asc_dvc->last_q_shortage = 0; in AscInitAscDvcVar()
8775 asc_dvc->use_tagged_qng = 0; in AscInitAscDvcVar()
8776 asc_dvc->no_scam = 0; in AscInitAscDvcVar()
8777 asc_dvc->unit_not_ready = 0; in AscInitAscDvcVar()
8778 asc_dvc->queue_full_or_busy = 0; in AscInitAscDvcVar()
8779 asc_dvc->redo_scam = 0; in AscInitAscDvcVar()
8780 asc_dvc->res2 = 0; in AscInitAscDvcVar()
8781 asc_dvc->min_sdtr_index = 0; in AscInitAscDvcVar()
8782 asc_dvc->cfg->can_tagged_qng = 0; in AscInitAscDvcVar()
8783 asc_dvc->cfg->cmd_qng_enabled = 0; in AscInitAscDvcVar()
8784 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL; in AscInitAscDvcVar()
8785 asc_dvc->init_sdtr = 0; in AscInitAscDvcVar()
8786 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG; in AscInitAscDvcVar()
8787 asc_dvc->scsi_reset_wait = 3; in AscInitAscDvcVar()
8788 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET; in AscInitAscDvcVar()
8789 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type); in AscInitAscDvcVar()
8790 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET; in AscInitAscDvcVar()
8791 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET; in AscInitAscDvcVar()
8792 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID; in AscInitAscDvcVar()
8793 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type); in AscInitAscDvcVar()
8794 asc_dvc->cfg->chip_version = chip_version; in AscInitAscDvcVar()
8795 asc_dvc->sdtr_period_tbl = asc_syn_xfer_period; in AscInitAscDvcVar()
8796 asc_dvc->max_sdtr_index = 7; in AscInitAscDvcVar()
8797 if ((asc_dvc->bus_type & ASC_IS_PCI) && in AscInitAscDvcVar()
8799 asc_dvc->bus_type = ASC_IS_PCI_ULTRA; in AscInitAscDvcVar()
8800 asc_dvc->sdtr_period_tbl = asc_syn_ultra_xfer_period; in AscInitAscDvcVar()
8801 asc_dvc->max_sdtr_index = 15; in AscInitAscDvcVar()
8811 if (asc_dvc->bus_type == ASC_IS_PCI) { in AscInitAscDvcVar()
8816 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED; in AscInitAscDvcVar()
8818 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) { in AscInitAscDvcVar()
8821 asc_dvc->bus_type = ASC_IS_ISAPNP; in AscInitAscDvcVar()
8823 asc_dvc->cfg->isa_dma_channel = in AscInitAscDvcVar()
8828 asc_dvc->cur_dvc_qng[i] = 0; in AscInitAscDvcVar()
8829 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG; in AscInitAscDvcVar()
8830 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L; in AscInitAscDvcVar()
8831 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L; in AscInitAscDvcVar()
8832 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG; in AscInitAscDvcVar()
8879 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2; in AscGetEEPConfig()
8884 /* Read two config words; Byte-swapping done by AscReadEEPWord(). */ in AscGetEEPConfig()
8896 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) { in AscGetEEPConfig()
8900 * Swap all char fields - must unswap bytes already swapped in AscGetEEPConfig()
8905 /* Don't swap word field at the end - cntl field. */ in AscGetEEPConfig()
8925 iop_base = asc_dvc->iop_base; in AscTestExternalLram()
8994 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2; in AscSetEEPConfigOnce()
9013 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) { in AscSetEEPConfigOnce()
9025 /* Don't swap word field at the end - cntl field. */ in AscSetEEPConfigOnce()
9042 * Read two config words; Byte-swapping done by AscReadEEPWord(). in AscSetEEPConfigOnce()
9056 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) { in AscSetEEPConfigOnce()
9066 /* Don't swap word field at the end - cntl field. */ in AscSetEEPConfigOnce()
9110 iop_base = asc_dvc->iop_base; in AscInitFromEEP()
9116 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE; in AscInitFromEEP()
9118 mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */ in AscInitFromEEP()
9121 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP; in AscInitFromEEP()
9126 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR; in AscInitFromEEP()
9137 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type); in AscInitFromEEP()
9144 if (asc_dvc->cfg->chip_version == 3) { in AscInitFromEEP()
9145 if (eep_config->cfg_lsw != cfg_lsw) { in AscInitFromEEP()
9147 eep_config->cfg_lsw = in AscInitFromEEP()
9150 if (eep_config->cfg_msw != cfg_msw) { in AscInitFromEEP()
9152 eep_config->cfg_msw = in AscInitFromEEP()
9157 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK; in AscInitFromEEP()
9158 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON; in AscInitFromEEP()
9159 ASC_DBG(1, "eep_config->chksum 0x%x\n", eep_config->chksum); in AscInitFromEEP()
9160 if (chksum != eep_config->chksum) { in AscInitFromEEP()
9161 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) == in AscInitFromEEP()
9163 ASC_DBG(1, "chksum error ignored; EEPROM-less board\n"); in AscInitFromEEP()
9164 eep_config->init_sdtr = 0xFF; in AscInitFromEEP()
9165 eep_config->disc_enable = 0xFF; in AscInitFromEEP()
9166 eep_config->start_motor = 0xFF; in AscInitFromEEP()
9167 eep_config->use_cmd_qng = 0; in AscInitFromEEP()
9168 eep_config->max_total_qng = 0xF0; in AscInitFromEEP()
9169 eep_config->max_tag_qng = 0x20; in AscInitFromEEP()
9170 eep_config->cntl = 0xBFFF; in AscInitFromEEP()
9172 eep_config->no_scam = 0; in AscInitFromEEP()
9173 eep_config->adapter_info[0] = 0; in AscInitFromEEP()
9174 eep_config->adapter_info[1] = 0; in AscInitFromEEP()
9175 eep_config->adapter_info[2] = 0; in AscInitFromEEP()
9176 eep_config->adapter_info[3] = 0; in AscInitFromEEP()
9177 eep_config->adapter_info[4] = 0; in AscInitFromEEP()
9178 /* Indicate EEPROM-less board. */ in AscInitFromEEP()
9179 eep_config->adapter_info[5] = 0xBB; in AscInitFromEEP()
9182 ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n"); in AscInitFromEEP()
9187 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr; in AscInitFromEEP()
9188 asc_dvc->cfg->disc_enable = eep_config->disc_enable; in AscInitFromEEP()
9189 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng; in AscInitFromEEP()
9190 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config); in AscInitFromEEP()
9191 asc_dvc->start_motor = eep_config->start_motor; in AscInitFromEEP()
9192 asc_dvc->dvc_cntl = eep_config->cntl; in AscInitFromEEP()
9193 asc_dvc->no_scam = eep_config->no_scam; in AscInitFromEEP()
9194 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0]; in AscInitFromEEP()
9195 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1]; in AscInitFromEEP()
9196 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2]; in AscInitFromEEP()
9197 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3]; in AscInitFromEEP()
9198 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4]; in AscInitFromEEP()
9199 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5]; in AscInitFromEEP()
9201 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == in AscInitFromEEP()
9203 eep_config->max_total_qng = in AscInitFromEEP()
9205 eep_config->max_tag_qng = in AscInitFromEEP()
9208 eep_config->cfg_msw |= 0x0800; in AscInitFromEEP()
9211 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG; in AscInitFromEEP()
9212 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG; in AscInitFromEEP()
9216 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) { in AscInitFromEEP()
9217 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG; in AscInitFromEEP()
9219 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) { in AscInitFromEEP()
9220 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG; in AscInitFromEEP()
9222 if (eep_config->max_tag_qng > eep_config->max_total_qng) { in AscInitFromEEP()
9223 eep_config->max_tag_qng = eep_config->max_total_qng; in AscInitFromEEP()
9225 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) { in AscInitFromEEP()
9226 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC; in AscInitFromEEP()
9228 asc_dvc->max_total_qng = eep_config->max_total_qng; in AscInitFromEEP()
9229 if ((eep_config->use_cmd_qng & eep_config->disc_enable) != in AscInitFromEEP()
9230 eep_config->use_cmd_qng) { in AscInitFromEEP()
9231 eep_config->disc_enable = eep_config->use_cmd_qng; in AscInitFromEEP()
9236 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config); in AscInitFromEEP()
9237 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) && in AscInitFromEEP()
9238 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) { in AscInitFromEEP()
9239 asc_dvc->min_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX; in AscInitFromEEP()
9243 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i]; in AscInitFromEEP()
9244 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng; in AscInitFromEEP()
9245 asc_dvc->cfg->sdtr_period_offset[i] = in AscInitFromEEP()
9247 (asc_dvc->min_sdtr_index << 4)); in AscInitFromEEP()
9249 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base); in AscInitFromEEP()
9252 asc_dvc->bus_type)) != 0) { in AscInitFromEEP()
9254 ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n", in AscInitFromEEP()
9258 ("AscInitFromEEP: Successfully re-wrote EEPROM.\n"); in AscInitFromEEP()
9267 ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var; in AscInitGetConfig()
9270 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG; in AscInitGetConfig()
9271 if (asc_dvc->err_code != 0) in AscInitGetConfig()
9272 return asc_dvc->err_code; in AscInitGetConfig()
9274 if (AscFindSignature(asc_dvc->iop_base)) { in AscInitGetConfig()
9277 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG; in AscInitGetConfig()
9278 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) in AscInitGetConfig()
9279 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT; in AscInitGetConfig()
9281 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; in AscInitGetConfig()
9311 if (asc_dvc->err_code != 0) in AscInitGetConfig()
9313 "0x%x\n", asc_dvc->err_code, asc_dvc->init_state); in AscInitGetConfig()
9315 return asc_dvc->err_code; in AscInitGetConfig()
9321 ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var; in AscInitSetConfig()
9322 PortAddr iop_base = asc_dvc->iop_base; in AscInitSetConfig()
9326 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG; in AscInitSetConfig()
9327 if (asc_dvc->err_code != 0) in AscInitSetConfig()
9328 return asc_dvc->err_code; in AscInitSetConfig()
9329 if (!AscFindSignature(asc_dvc->iop_base)) { in AscInitSetConfig()
9330 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; in AscInitSetConfig()
9331 return asc_dvc->err_code; in AscInitSetConfig()
9340 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) != in AscInitSetConfig()
9341 asc_dvc->cfg->cmd_qng_enabled) { in AscInitSetConfig()
9342 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled; in AscInitSetConfig()
9349 if (asc_dvc->bus_type & ASC_IS_PCI) { in AscInitSetConfig()
9352 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) { in AscInitSetConfig()
9354 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) || in AscInitSetConfig()
9355 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) { in AscInitSetConfig()
9356 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB; in AscInitSetConfig()
9357 asc_dvc->bug_fix_cntl |= in AscInitSetConfig()
9363 if (asc_dvc->bus_type == ASC_IS_ISAPNP) { in AscInitSetConfig()
9364 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) in AscInitSetConfig()
9366 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN; in AscInitSetConfig()
9369 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) != in AscInitSetConfig()
9370 asc_dvc->cfg->chip_scsi_id) { in AscInitSetConfig()
9371 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID; in AscInitSetConfig()
9374 if (asc_dvc->bus_type & ASC_IS_ISA) { in AscInitSetConfig()
9375 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel); in AscInitSetConfig()
9376 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed); in AscInitSetConfig()
9380 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG; in AscInitSetConfig()
9409 if (asc_dvc->err_code != 0) in AscInitSetConfig()
9411 "0x%x\n", asc_dvc->err_code, asc_dvc->init_state); in AscInitSetConfig()
9413 return asc_dvc->err_code; in AscInitSetConfig()
9429 * on big-endian platforms so char fields read as words are actually being
9430 * unswapped on big-endian platforms.
9474 0, /* -disc_enable */
9537 , /* 22-29 oem_name[16] */
9602 , /* 22-29 oem_name[16] */
9667 , /* 22-29 oem_name[16] */
9732 , /* 22-29 oem_name[16] */
10136 * For a non-fatal error return a warning code. If there are no warnings
10147 iop_base = asc_dvc->iop_base; in AdvInitFrom3550EEP()
10170 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); in AdvInitFrom3550EEP()
10173 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2); in AdvInitFrom3550EEP()
10176 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3); in AdvInitFrom3550EEP()
10186 asc_dvc->wdtr_able = eep_config.wdtr_able; in AdvInitFrom3550EEP()
10187 asc_dvc->sdtr_able = eep_config.sdtr_able; in AdvInitFrom3550EEP()
10188 asc_dvc->ultra_able = eep_config.ultra_able; in AdvInitFrom3550EEP()
10189 asc_dvc->tagqng_able = eep_config.tagqng_able; in AdvInitFrom3550EEP()
10190 asc_dvc->cfg->disc_enable = eep_config.disc_enable; in AdvInitFrom3550EEP()
10191 asc_dvc->max_host_qng = eep_config.max_host_qng; in AdvInitFrom3550EEP()
10192 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; in AdvInitFrom3550EEP()
10193 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID); in AdvInitFrom3550EEP()
10194 asc_dvc->start_motor = eep_config.start_motor; in AdvInitFrom3550EEP()
10195 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay; in AdvInitFrom3550EEP()
10196 asc_dvc->bios_ctrl = eep_config.bios_ctrl; in AdvInitFrom3550EEP()
10197 asc_dvc->no_scam = eep_config.scam_tolerant; in AdvInitFrom3550EEP()
10198 asc_dvc->cfg->serial1 = eep_config.serial_number_word1; in AdvInitFrom3550EEP()
10199 asc_dvc->cfg->serial2 = eep_config.serial_number_word2; in AdvInitFrom3550EEP()
10200 asc_dvc->cfg->serial3 = eep_config.serial_number_word3; in AdvInitFrom3550EEP()
10240 asc_dvc->max_host_qng = eep_config.max_host_qng; in AdvInitFrom3550EEP()
10241 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; in AdvInitFrom3550EEP()
10247 * If the termination is specified with a non-zero 'termination' in AdvInitFrom3550EEP()
10252 asc_dvc->cfg->termination = 0; /* auto termination */ in AdvInitFrom3550EEP()
10256 asc_dvc->cfg->termination = TERM_CTL_SEL; in AdvInitFrom3550EEP()
10260 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H; in AdvInitFrom3550EEP()
10264 asc_dvc->cfg->termination = in AdvInitFrom3550EEP()
10271 asc_dvc->cfg->termination = 0; in AdvInitFrom3550EEP()
10286 * For a non-fatal error return a warning code. If there are no warnings
10299 iop_base = asc_dvc->iop_base; in AdvInitFrom38C0800EEP()
10323 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); in AdvInitFrom38C0800EEP()
10326 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2); in AdvInitFrom38C0800EEP()
10329 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3); in AdvInitFrom38C0800EEP()
10339 asc_dvc->wdtr_able = eep_config.wdtr_able; in AdvInitFrom38C0800EEP()
10340 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1; in AdvInitFrom38C0800EEP()
10341 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2; in AdvInitFrom38C0800EEP()
10342 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3; in AdvInitFrom38C0800EEP()
10343 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4; in AdvInitFrom38C0800EEP()
10344 asc_dvc->tagqng_able = eep_config.tagqng_able; in AdvInitFrom38C0800EEP()
10345 asc_dvc->cfg->disc_enable = eep_config.disc_enable; in AdvInitFrom38C0800EEP()
10346 asc_dvc->max_host_qng = eep_config.max_host_qng; in AdvInitFrom38C0800EEP()
10347 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; in AdvInitFrom38C0800EEP()
10348 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID); in AdvInitFrom38C0800EEP()
10349 asc_dvc->start_motor = eep_config.start_motor; in AdvInitFrom38C0800EEP()
10350 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay; in AdvInitFrom38C0800EEP()
10351 asc_dvc->bios_ctrl = eep_config.bios_ctrl; in AdvInitFrom38C0800EEP()
10352 asc_dvc->no_scam = eep_config.scam_tolerant; in AdvInitFrom38C0800EEP()
10353 asc_dvc->cfg->serial1 = eep_config.serial_number_word1; in AdvInitFrom38C0800EEP()
10354 asc_dvc->cfg->serial2 = eep_config.serial_number_word2; in AdvInitFrom38C0800EEP()
10355 asc_dvc->cfg->serial3 = eep_config.serial_number_word3; in AdvInitFrom38C0800EEP()
10361 asc_dvc->sdtr_able = 0; in AdvInitFrom38C0800EEP()
10364 sdtr_speed = asc_dvc->sdtr_speed1; in AdvInitFrom38C0800EEP()
10366 sdtr_speed = asc_dvc->sdtr_speed2; in AdvInitFrom38C0800EEP()
10368 sdtr_speed = asc_dvc->sdtr_speed3; in AdvInitFrom38C0800EEP()
10370 sdtr_speed = asc_dvc->sdtr_speed4; in AdvInitFrom38C0800EEP()
10373 asc_dvc->sdtr_able |= (1 << tid); in AdvInitFrom38C0800EEP()
10416 asc_dvc->max_host_qng = eep_config.max_host_qng; in AdvInitFrom38C0800EEP()
10417 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; in AdvInitFrom38C0800EEP()
10423 * If the termination is specified with a non-zero 'termination' in AdvInitFrom38C0800EEP()
10452 asc_dvc->cfg->termination = termination; /* auto termination for LVD */ in AdvInitFrom38C0800EEP()
10456 asc_dvc->cfg->termination = termination; in AdvInitFrom38C0800EEP()
10460 asc_dvc->cfg->termination = termination | TERM_LVD_HI; in AdvInitFrom38C0800EEP()
10464 asc_dvc->cfg->termination = termination | TERM_LVD; in AdvInitFrom38C0800EEP()
10470 asc_dvc->cfg->termination = termination; in AdvInitFrom38C0800EEP()
10485 * For a non-fatal error return a warning code. If there are no warnings
10498 iop_base = asc_dvc->iop_base; in AdvInitFrom38C1600EEP()
10518 if (PCI_FUNC(pdev->devfn) != 0) { in AdvInitFrom38C1600EEP()
10532 * 1 - Function 1 interrupt line wired to INT A. in AdvInitFrom38C1600EEP()
10533 * 0 - Function 1 interrupt line wired to INT B. in AdvInitFrom38C1600EEP()
10550 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); in AdvInitFrom38C1600EEP()
10552 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2); in AdvInitFrom38C1600EEP()
10554 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3); in AdvInitFrom38C1600EEP()
10565 asc_dvc->wdtr_able = eep_config.wdtr_able; in AdvInitFrom38C1600EEP()
10566 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1; in AdvInitFrom38C1600EEP()
10567 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2; in AdvInitFrom38C1600EEP()
10568 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3; in AdvInitFrom38C1600EEP()
10569 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4; in AdvInitFrom38C1600EEP()
10570 asc_dvc->ppr_able = 0; in AdvInitFrom38C1600EEP()
10571 asc_dvc->tagqng_able = eep_config.tagqng_able; in AdvInitFrom38C1600EEP()
10572 asc_dvc->cfg->disc_enable = eep_config.disc_enable; in AdvInitFrom38C1600EEP()
10573 asc_dvc->max_host_qng = eep_config.max_host_qng; in AdvInitFrom38C1600EEP()
10574 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; in AdvInitFrom38C1600EEP()
10575 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID); in AdvInitFrom38C1600EEP()
10576 asc_dvc->start_motor = eep_config.start_motor; in AdvInitFrom38C1600EEP()
10577 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay; in AdvInitFrom38C1600EEP()
10578 asc_dvc->bios_ctrl = eep_config.bios_ctrl; in AdvInitFrom38C1600EEP()
10579 asc_dvc->no_scam = eep_config.scam_tolerant; in AdvInitFrom38C1600EEP()
10585 asc_dvc->sdtr_able = 0; in AdvInitFrom38C1600EEP()
10588 sdtr_speed = asc_dvc->sdtr_speed1; in AdvInitFrom38C1600EEP()
10590 sdtr_speed = asc_dvc->sdtr_speed2; in AdvInitFrom38C1600EEP()
10592 sdtr_speed = asc_dvc->sdtr_speed3; in AdvInitFrom38C1600EEP()
10594 sdtr_speed = asc_dvc->sdtr_speed4; in AdvInitFrom38C1600EEP()
10597 asc_dvc->sdtr_able |= (1 << tid); in AdvInitFrom38C1600EEP()
10640 asc_dvc->max_host_qng = eep_config.max_host_qng; in AdvInitFrom38C1600EEP()
10641 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; in AdvInitFrom38C1600EEP()
10647 * If the termination is specified with a non-zero 'termination' in AdvInitFrom38C1600EEP()
10676 asc_dvc->cfg->termination = termination; /* auto termination for LVD */ in AdvInitFrom38C1600EEP()
10680 asc_dvc->cfg->termination = termination; in AdvInitFrom38C1600EEP()
10684 asc_dvc->cfg->termination = termination | TERM_LVD_HI; in AdvInitFrom38C1600EEP()
10688 asc_dvc->cfg->termination = termination | TERM_LVD; in AdvInitFrom38C1600EEP()
10694 asc_dvc->cfg->termination = termination; in AdvInitFrom38C1600EEP()
10707 * For a non-fatal error return a warning code. If there are no warnings
10713 ADV_DVC_VAR *asc_dvc = &board->dvc_var.adv_dvc_var; in AdvInitGetConfig()
10715 AdvPortAddr iop_base = asc_dvc->iop_base; in AdvInitGetConfig()
10719 asc_dvc->err_code = 0; in AdvInitGetConfig()
10727 asc_dvc->cfg->control_flag = 0; in AdvInitGetConfig()
10730 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR; in AdvInitGetConfig()
10732 asc_dvc->cfg->chip_version = in AdvInitGetConfig()
10733 AdvGetChipVersion(iop_base, asc_dvc->bus_type); in AdvInitGetConfig()
10747 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; in AdvInitGetConfig()
10753 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 && in AdvInitGetConfig()
10754 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 && in AdvInitGetConfig()
10755 asc_dvc->chip_type != ADV_CHIP_ASC38C1600) { in AdvInitGetConfig()
10756 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE; in AdvInitGetConfig()
10769 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) { in AdvInitGetConfig()
10771 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) { in AdvInitGetConfig()
10782 if (asc_dvc->err_code) in AdvInitGetConfig()
10784 asc_dvc->err_code); in AdvInitGetConfig()
10786 return asc_dvc->err_code; in AdvInitGetConfig()
10804 * for non-ISA adapters.
10812 struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var; in advansys_wide_init_chip()
10820 adv_dvc->carrier = dma_alloc_coherent(board->dev, in advansys_wide_init_chip()
10821 ADV_CARRIER_BUFSIZE, &adv_dvc->carrier_addr, GFP_KERNEL); in advansys_wide_init_chip()
10822 ASC_DBG(1, "carrier 0x%p\n", adv_dvc->carrier); in advansys_wide_init_chip()
10824 if (!adv_dvc->carrier) in advansys_wide_init_chip()
10830 * If the allocation fails decrement and try again. in advansys_wide_init_chip()
10832 board->adv_reqp_size = adv_dvc->max_host_qng * sizeof(adv_req_t); in advansys_wide_init_chip()
10833 if (board->adv_reqp_size & 0x1f) { in advansys_wide_init_chip()
10835 board->adv_reqp_size = ADV_32BALIGN(board->adv_reqp_size); in advansys_wide_init_chip()
10837 board->adv_reqp = dma_alloc_coherent(board->dev, board->adv_reqp_size, in advansys_wide_init_chip()
10838 &board->adv_reqp_addr, GFP_KERNEL); in advansys_wide_init_chip()
10840 if (!board->adv_reqp) in advansys_wide_init_chip()
10843 ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", board->adv_reqp, in advansys_wide_init_chip()
10844 adv_dvc->max_host_qng, board->adv_reqp_size); in advansys_wide_init_chip()
10851 board->adv_sgblk_pool = dma_pool_create("adv_sgblk", board->dev, in advansys_wide_init_chip()
10857 if (!board->adv_sgblk_pool) in advansys_wide_init_chip()
10860 if (adv_dvc->chip_type == ADV_CHIP_ASC3550) { in advansys_wide_init_chip()
10863 } else if (adv_dvc->chip_type == ADV_CHIP_ASC38C0800) { in advansys_wide_init_chip()
10870 err_code = adv_dvc->err_code; in advansys_wide_init_chip()
10888 struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var; in advansys_wide_free_mem()
10890 if (adv_dvc->carrier) { in advansys_wide_free_mem()
10891 dma_free_coherent(board->dev, ADV_CARRIER_BUFSIZE, in advansys_wide_free_mem()
10892 adv_dvc->carrier, adv_dvc->carrier_addr); in advansys_wide_free_mem()
10893 adv_dvc->carrier = NULL; in advansys_wide_free_mem()
10895 if (board->adv_reqp) { in advansys_wide_free_mem()
10896 dma_free_coherent(board->dev, board->adv_reqp_size, in advansys_wide_free_mem()
10897 board->adv_reqp, board->adv_reqp_addr); in advansys_wide_free_mem()
10898 board->adv_reqp = NULL; in advansys_wide_free_mem()
10900 if (board->adv_sgblk_pool) { in advansys_wide_free_mem()
10901 dma_pool_destroy(board->adv_sgblk_pool); in advansys_wide_free_mem()
10902 board->adv_sgblk_pool = NULL; in advansys_wide_free_mem()
10915 pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL; in advansys_board_found()
10919 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; in advansys_board_found()
10920 asc_dvc_varp->bus_type = bus_type; in advansys_board_found()
10921 asc_dvc_varp->drv_ptr = boardp; in advansys_board_found()
10922 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg; in advansys_board_found()
10923 asc_dvc_varp->iop_base = iop; in advansys_board_found()
10926 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var; in advansys_board_found()
10927 adv_dvc_varp->drv_ptr = boardp; in advansys_board_found()
10928 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg; in advansys_board_found()
10929 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) { in advansys_board_found()
10930 ASC_DBG(1, "wide board ASC-3550\n"); in advansys_board_found()
10931 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550; in advansys_board_found()
10932 } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) { in advansys_board_found()
10933 ASC_DBG(1, "wide board ASC-38C0800\n"); in advansys_board_found()
10934 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800; in advansys_board_found()
10936 ASC_DBG(1, "wide board ASC-38C1600\n"); in advansys_board_found()
10937 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600; in advansys_board_found()
10940 boardp->asc_n_io_port = pci_resource_len(pdev, 1); in advansys_board_found()
10941 boardp->ioremap_addr = pci_ioremap_bar(pdev, 1); in advansys_board_found()
10942 if (!boardp->ioremap_addr) { in advansys_board_found()
10946 boardp->asc_n_io_port); in advansys_board_found()
10947 ret = -ENODEV; in advansys_board_found()
10950 adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr; in advansys_board_found()
10951 ASC_DBG(1, "iop_base: 0x%p\n", adv_dvc_varp->iop_base); in advansys_board_found()
10958 boardp->ioport = iop; in advansys_board_found()
10970 switch (asc_dvc_varp->bus_type) { in advansys_board_found()
10973 shost->unchecked_isa_dma = true; in advansys_board_found()
10977 shost->unchecked_isa_dma = false; in advansys_board_found()
10981 shost->unchecked_isa_dma = false; in advansys_board_found()
10987 shost->unchecked_isa_dma = false; in advansys_board_found()
10993 "%d\n", asc_dvc_varp->bus_type); in advansys_board_found()
10994 shost->unchecked_isa_dma = false; in advansys_board_found()
11003 * referenced only use the bit-wise AND operator "&". in advansys_board_found()
11006 ret = AscInitGetConfig(shost) ? -ENODEV : 0; in advansys_board_found()
11013 shost->unchecked_isa_dma = false; in advansys_board_found()
11017 ret = AdvInitGetConfig(pdev, shost) ? -ENODEV : 0; in advansys_board_found()
11020 ret = -ENODEV; in advansys_board_found()
11038 boardp->init_tidmask |= in advansys_board_found()
11039 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id); in advansys_board_found()
11044 ep = &boardp->eep_config.asc_eep; in advansys_board_found()
11046 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable; in advansys_board_found()
11047 ep->disc_enable = asc_dvc_varp->cfg->disc_enable; in advansys_board_found()
11048 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled; in advansys_board_found()
11049 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed); in advansys_board_found()
11050 ep->start_motor = asc_dvc_varp->start_motor; in advansys_board_found()
11051 ep->cntl = asc_dvc_varp->dvc_cntl; in advansys_board_found()
11052 ep->no_scam = asc_dvc_varp->no_scam; in advansys_board_found()
11053 ep->max_total_qng = asc_dvc_varp->max_total_qng; in advansys_board_found()
11054 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id); in advansys_board_found()
11056 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0]; in advansys_board_found()
11057 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0]; in advansys_board_found()
11058 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1]; in advansys_board_found()
11059 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2]; in advansys_board_found()
11060 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3]; in advansys_board_found()
11061 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4]; in advansys_board_found()
11062 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5]; in advansys_board_found()
11068 ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0; in advansys_board_found()
11079 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { in advansys_board_found()
11080 ep_3550 = &boardp->eep_config.adv_3550_eep; in advansys_board_found()
11082 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id; in advansys_board_found()
11083 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng; in advansys_board_found()
11084 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng; in advansys_board_found()
11085 ep_3550->termination = adv_dvc_varp->cfg->termination; in advansys_board_found()
11086 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable; in advansys_board_found()
11087 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl; in advansys_board_found()
11088 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able; in advansys_board_found()
11089 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able; in advansys_board_found()
11090 ep_3550->ultra_able = adv_dvc_varp->ultra_able; in advansys_board_found()
11091 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able; in advansys_board_found()
11092 ep_3550->start_motor = adv_dvc_varp->start_motor; in advansys_board_found()
11093 ep_3550->scsi_reset_delay = in advansys_board_found()
11094 adv_dvc_varp->scsi_reset_wait; in advansys_board_found()
11095 ep_3550->serial_number_word1 = in advansys_board_found()
11096 adv_dvc_varp->cfg->serial1; in advansys_board_found()
11097 ep_3550->serial_number_word2 = in advansys_board_found()
11098 adv_dvc_varp->cfg->serial2; in advansys_board_found()
11099 ep_3550->serial_number_word3 = in advansys_board_found()
11100 adv_dvc_varp->cfg->serial3; in advansys_board_found()
11101 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { in advansys_board_found()
11102 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep; in advansys_board_found()
11104 ep_38C0800->adapter_scsi_id = in advansys_board_found()
11105 adv_dvc_varp->chip_scsi_id; in advansys_board_found()
11106 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng; in advansys_board_found()
11107 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng; in advansys_board_found()
11108 ep_38C0800->termination_lvd = in advansys_board_found()
11109 adv_dvc_varp->cfg->termination; in advansys_board_found()
11110 ep_38C0800->disc_enable = in advansys_board_found()
11111 adv_dvc_varp->cfg->disc_enable; in advansys_board_found()
11112 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl; in advansys_board_found()
11113 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able; in advansys_board_found()
11114 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able; in advansys_board_found()
11115 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1; in advansys_board_found()
11116 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2; in advansys_board_found()
11117 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3; in advansys_board_found()
11118 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4; in advansys_board_found()
11119 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able; in advansys_board_found()
11120 ep_38C0800->start_motor = adv_dvc_varp->start_motor; in advansys_board_found()
11121 ep_38C0800->scsi_reset_delay = in advansys_board_found()
11122 adv_dvc_varp->scsi_reset_wait; in advansys_board_found()
11123 ep_38C0800->serial_number_word1 = in advansys_board_found()
11124 adv_dvc_varp->cfg->serial1; in advansys_board_found()
11125 ep_38C0800->serial_number_word2 = in advansys_board_found()
11126 adv_dvc_varp->cfg->serial2; in advansys_board_found()
11127 ep_38C0800->serial_number_word3 = in advansys_board_found()
11128 adv_dvc_varp->cfg->serial3; in advansys_board_found()
11130 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep; in advansys_board_found()
11132 ep_38C1600->adapter_scsi_id = in advansys_board_found()
11133 adv_dvc_varp->chip_scsi_id; in advansys_board_found()
11134 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng; in advansys_board_found()
11135 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng; in advansys_board_found()
11136 ep_38C1600->termination_lvd = in advansys_board_found()
11137 adv_dvc_varp->cfg->termination; in advansys_board_found()
11138 ep_38C1600->disc_enable = in advansys_board_found()
11139 adv_dvc_varp->cfg->disc_enable; in advansys_board_found()
11140 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl; in advansys_board_found()
11141 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able; in advansys_board_found()
11142 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able; in advansys_board_found()
11143 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1; in advansys_board_found()
11144 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2; in advansys_board_found()
11145 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3; in advansys_board_found()
11146 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4; in advansys_board_found()
11147 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able; in advansys_board_found()
11148 ep_38C1600->start_motor = adv_dvc_varp->start_motor; in advansys_board_found()
11149 ep_38C1600->scsi_reset_delay = in advansys_board_found()
11150 adv_dvc_varp->scsi_reset_wait; in advansys_board_found()
11151 ep_38C1600->serial_number_word1 = in advansys_board_found()
11152 adv_dvc_varp->cfg->serial1; in advansys_board_found()
11153 ep_38C1600->serial_number_word2 = in advansys_board_found()
11154 adv_dvc_varp->cfg->serial2; in advansys_board_found()
11155 ep_38C1600->serial_number_word3 = in advansys_board_found()
11156 adv_dvc_varp->cfg->serial3; in advansys_board_found()
11162 boardp->init_tidmask |= in advansys_board_found()
11163 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id); in advansys_board_found()
11168 * structure supports one channel. Multi-channel boards have a in advansys_board_found()
11171 shost->max_channel = 0; in advansys_board_found()
11173 shost->max_id = ASC_MAX_TID + 1; in advansys_board_found()
11174 shost->max_lun = ASC_MAX_LUN + 1; in advansys_board_found()
11175 shost->max_cmd_len = ASC_MAX_CDB_LEN; in advansys_board_found()
11177 shost->io_port = asc_dvc_varp->iop_base; in advansys_board_found()
11178 boardp->asc_n_io_port = ASC_IOADR_GAP; in advansys_board_found()
11179 shost->this_id = asc_dvc_varp->cfg->chip_scsi_id; in advansys_board_found()
11182 shost->can_queue = asc_dvc_varp->max_total_qng; in advansys_board_found()
11184 shost->max_id = ADV_MAX_TID + 1; in advansys_board_found()
11185 shost->max_lun = ADV_MAX_LUN + 1; in advansys_board_found()
11186 shost->max_cmd_len = ADV_MAX_CDB_LEN; in advansys_board_found()
11194 shost->io_port = iop; in advansys_board_found()
11196 shost->this_id = adv_dvc_varp->chip_scsi_id; in advansys_board_found()
11199 shost->can_queue = adv_dvc_varp->max_host_qng; in advansys_board_found()
11203 * Set the maximum number of scatter-gather elements the in advansys_board_found()
11208 * Allow two commands with 'sg_tablesize' scatter-gather in advansys_board_found()
11213 shost->sg_tablesize = in advansys_board_found()
11214 (((asc_dvc_varp->max_total_qng - 2) / 2) * in advansys_board_found()
11217 shost->sg_tablesize = ADV_MAX_SG_LIST; in advansys_board_found()
11222 * mid-level driver definition of SG_ALL. SG_ALL also in advansys_board_found()
11224 * size of the scatter-gather table in 'struct asc_sg_head'. in advansys_board_found()
11226 if (shost->sg_tablesize > SG_ALL) { in advansys_board_found()
11227 shost->sg_tablesize = SG_ALL; in advansys_board_found()
11230 ASC_DBG(1, "sg_tablesize: %d\n", shost->sg_tablesize); in advansys_board_found()
11234 shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base, in advansys_board_found()
11235 asc_dvc_varp->bus_type); in advansys_board_found()
11238 * Fill-in BIOS board variables. The Wide BIOS saves in advansys_board_found()
11241 AdvReadWordLram(adv_dvc_varp->iop_base, in advansys_board_found()
11242 BIOS_SIGNATURE, boardp->bios_signature); in advansys_board_found()
11243 AdvReadWordLram(adv_dvc_varp->iop_base, in advansys_board_found()
11244 BIOS_VERSION, boardp->bios_version); in advansys_board_found()
11245 AdvReadWordLram(adv_dvc_varp->iop_base, in advansys_board_found()
11246 BIOS_CODESEG, boardp->bios_codeseg); in advansys_board_found()
11247 AdvReadWordLram(adv_dvc_varp->iop_base, in advansys_board_found()
11248 BIOS_CODELEN, boardp->bios_codelen); in advansys_board_found()
11251 boardp->bios_signature, boardp->bios_version); in advansys_board_found()
11254 boardp->bios_codeseg, boardp->bios_codelen); in advansys_board_found()
11260 if (boardp->bios_signature == 0x55AA) { in advansys_board_found()
11265 shost->base = ((ulong)boardp->bios_codeseg << 4); in advansys_board_found()
11267 shost->base = 0; in advansys_board_found()
11272 * Register Board Resources - I/O Port, DMA, IRQ in advansys_board_found()
11276 shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */ in advansys_board_found()
11280 if (asc_dvc_varp->bus_type & ASC_IS_ISA) { in advansys_board_found()
11281 shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel; in advansys_board_found()
11282 ret = request_dma(shost->dma_channel, DRV_NAME); in advansys_board_found()
11286 shost->dma_channel, ret); in advansys_board_found()
11289 AscEnableIsaDma(shost->dma_channel); in advansys_board_found()
11295 ASC_DBG(2, "request_irq(%d, %p)\n", boardp->irq, shost); in advansys_board_found()
11297 ret = request_irq(boardp->irq, advansys_interrupt, share_irq, in advansys_board_found()
11301 if (ret == -EBUSY) { in advansys_board_found()
11303 "already in use\n", boardp->irq); in advansys_board_found()
11304 } else if (ret == -EINVAL) { in advansys_board_found()
11306 "not valid\n", boardp->irq); in advansys_board_found()
11309 "failed with %d\n", boardp->irq, ret); in advansys_board_found()
11320 asc_dvc_varp->overrun_buf = kzalloc(ASC_OVERRUN_BSIZE, GFP_KERNEL); in advansys_board_found()
11321 if (!asc_dvc_varp->overrun_buf) { in advansys_board_found()
11322 ret = -ENOMEM; in advansys_board_found()
11327 if (warn_code || asc_dvc_varp->err_code) { in advansys_board_found()
11330 asc_dvc_varp->init_state, warn_code, in advansys_board_found()
11331 asc_dvc_varp->err_code); in advansys_board_found()
11332 if (!asc_dvc_varp->overrun_dma) { in advansys_board_found()
11333 ret = -ENODEV; in advansys_board_found()
11339 ret = -ENODEV; in advansys_board_found()
11346 ret = scsi_add_host(shost, boardp->dev); in advansys_board_found()
11355 if (asc_dvc_varp->overrun_dma) in advansys_board_found()
11356 dma_unmap_single(boardp->dev, asc_dvc_varp->overrun_dma, in advansys_board_found()
11358 kfree(asc_dvc_varp->overrun_buf); in advansys_board_found()
11362 free_irq(boardp->irq, shost); in advansys_board_found()
11365 if (shost->dma_channel != NO_ISA_DMA) in advansys_board_found()
11366 free_dma(shost->dma_channel); in advansys_board_found()
11369 if (boardp->ioremap_addr) in advansys_board_found()
11370 iounmap(boardp->ioremap_addr); in advansys_board_found()
11387 free_irq(board->irq, shost); in advansys_release()
11389 if (shost->dma_channel != NO_ISA_DMA) { in advansys_release()
11391 free_dma(shost->dma_channel); in advansys_release()
11395 dma_unmap_single(board->dev, in advansys_release()
11396 board->dvc_var.asc_dvc_var.overrun_dma, in advansys_release()
11398 kfree(board->dvc_var.asc_dvc_var.overrun_buf); in advansys_release()
11400 iounmap(board->ioremap_addr); in advansys_release()
11433 int err = -ENODEV; in advansys_isa_probe()
11440 return -ENODEV; in advansys_isa_probe()
11448 err = -ENOMEM; in advansys_isa_probe()
11454 board->irq = advansys_isa_irq_no(iop_base); in advansys_isa_probe()
11455 board->dev = dev; in advansys_isa_probe()
11456 board->shost = shost; in advansys_isa_probe()
11511 int err = -ENODEV; in advansys_vlb_probe()
11518 return -ENODEV; in advansys_vlb_probe()
11531 err = -ENOMEM; in advansys_vlb_probe()
11537 board->irq = advansys_vlb_irq_no(iop_base); in advansys_vlb_probe()
11538 board->dev = dev; in advansys_vlb_probe()
11539 board->shost = shost; in advansys_vlb_probe()
11552 return -ENODEV; in advansys_vlb_probe()
11593 unsigned short cfg_lsw = inw(edev->base_addr + 0xc86); in advansys_eisa_irq_no()
11607 err = -ENOMEM; in advansys_eisa_probe()
11611 ioport = edev->base_addr + 0xc30; in advansys_eisa_probe()
11613 err = -ENODEV; in advansys_eisa_probe()
11618 printk(KERN_WARNING "Region %x-%x busy\n", ioport, in advansys_eisa_probe()
11619 ioport + ASC_IOADR_GAP - 1); in advansys_eisa_probe()
11632 * test with. in advansys_eisa_probe()
11639 err = -ENOMEM; in advansys_eisa_probe()
11645 board->irq = irq; in advansys_eisa_probe()
11646 board->dev = dev; in advansys_eisa_probe()
11647 board->shost = shost; in advansys_eisa_probe()
11651 data->host[i] = shost; in advansys_eisa_probe()
11667 kfree(data->host[0]); in advansys_eisa_probe()
11668 kfree(data->host[1]); in advansys_eisa_probe()
11681 struct Scsi_Host *shost = data->host[i]; in advansys_eisa_remove()
11684 ioport = shost->io_port; in advansys_eisa_remove()
11723 if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) || in advansys_set_latency()
11724 (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) { in advansys_set_latency()
11750 err = -ENODEV; in advansys_pci_probe()
11756 err = -ENOMEM; in advansys_pci_probe()
11762 board->irq = pdev->irq; in advansys_pci_probe()
11763 board->dev = &pdev->dev; in advansys_pci_probe()
11764 board->shost = shost; in advansys_pci_probe()
11766 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW || in advansys_pci_probe()
11767 pdev->device == PCI_DEVICE_ID_38C0800_REV1 || in advansys_pci_probe()
11768 pdev->device == PCI_DEVICE_ID_38C1600_REV1) { in advansys_pci_probe()
11769 board->flags |= ASC_IS_WIDE_BOARD; in advansys_pci_probe()