Lines Matching +full:init +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2003-2013 QLogic Corporation
17 return readl((void __iomem *)(ha->nx_pcibase + addr)); in qla4_83xx_rd_reg()
22 writel(val, (void __iomem *)(ha->nx_pcibase + addr)); in qla4_83xx_wr_reg()
30 qla4_83xx_wr_reg(ha, QLA83XX_CRB_WIN_FUNC(ha->func_num), addr); in qla4_83xx_set_win_base()
31 val = qla4_83xx_rd_reg(ha, QLA83XX_CRB_WIN_FUNC(ha->func_num)); in qla4_83xx_set_win_base()
91 __func__, ha->func_num, lock_owner); in qla4_83xx_flash_lock()
98 qla4_83xx_wr_reg(ha, QLA83XX_FLASH_LOCK_ID, ha->func_num); in qla4_83xx_flash_lock()
169 flash_offset = addr & (QLA83XX_FLASH_SECTOR_SIZE - 1); in qla4_83xx_lockless_flash_read_u32()
188 (QLA83XX_FLASH_SECTOR_SIZE - 1)) { in qla4_83xx_lockless_flash_read_u32()
206 if (flash_offset > (QLA83XX_FLASH_SECTOR_SIZE - 1)) { in qla4_83xx_lockless_flash_read_u32()
262 lockid = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY); in qla4_83xx_lock_recovery()
269 ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY, in qla4_83xx_lock_recovery()
270 (ha->func_num << 2) | INTENT_TO_RECOVER); in qla4_83xx_lock_recovery()
275 lockid = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY); in qla4_83xx_lock_recovery()
276 if ((lockid & 0x3C) != (ha->func_num << 2)) in qla4_83xx_lock_recovery()
280 __func__, ha->func_num); in qla4_83xx_lock_recovery()
283 ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY, in qla4_83xx_lock_recovery()
284 (ha->func_num << 2) | PROCEED_TO_RECOVER); in qla4_83xx_lock_recovery()
287 ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCK_ID, 0xFF); in qla4_83xx_lock_recovery()
288 ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_UNLOCK); in qla4_83xx_lock_recovery()
290 /* Clear bits 0-5 in IDC_RECOVERY register*/ in qla4_83xx_lock_recovery()
291 ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY, 0); in qla4_83xx_lock_recovery()
294 lock = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCK); in qla4_83xx_lock_recovery()
296 lockid = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCK_ID); in qla4_83xx_lock_recovery()
297 lockid = ((lockid + (1 << 8)) & ~0xFF) | ha->func_num; in qla4_83xx_lock_recovery()
298 ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCK_ID, lockid); in qla4_83xx_lock_recovery()
322 /* Increment Counter (8-31) and update func_num (0-7) on in qla4_83xx_drv_lock()
325 lock_id = ((lock_id + (1 << 8)) & ~0xFF) | ha->func_num; in qla4_83xx_drv_lock()
333 first_owner = ha->isp_ops->rd_reg_direct(ha, in qla4_83xx_drv_lock()
342 __func__, ha->func_num, func_num, lock_cnt, in qla4_83xx_drv_lock()
351 __func__, ha->func_num); in qla4_83xx_drv_lock()
360 __func__, ha->func_num); in qla4_83xx_drv_lock()
366 __func__, ha->func_num); in qla4_83xx_drv_lock()
382 if ((id & 0xFF) != ha->func_num) { in qla4_83xx_drv_unlock()
384 __func__, ha->func_num, (id & 0xFF)); in qla4_83xx_drv_unlock()
388 /* Keep lock counter value, update the ha->func_num to 0xFF */ in qla4_83xx_drv_unlock()
423 /*-------------------------IDC State Machine ---------------------*/
453 ha->reg_tbl[QLA8XXX_CRB_DEV_PART_INFO]); in qla4_83xx_can_perform_reset()
455 drv_active = qla4_83xx_rd_reg(ha, ha->reg_tbl[QLA8XXX_CRB_DRV_ACTIVE]); in qla4_83xx_can_perform_reset()
458 * Lower 2 bits - device type, Upper 2 bits - physical port number */ in qla4_83xx_can_perform_reset()
492 if (!nic_present && (ha->func_num == iscsi_func_low)) { in qla4_83xx_can_perform_reset()
494 "%s: can reset - NIC not present and lower iSCSI function is %d\n", in qla4_83xx_can_perform_reset()
495 __func__, ha->func_num)); in qla4_83xx_can_perform_reset()
503 * qla4_83xx_need_reset_handler - Code to start reset sequence
516 if (!test_bit(AF_8XXX_RST_OWNER, &ha->flags)) { in qla4_83xx_need_reset_handler()
521 /* Non-reset owners ACK Reset and wait for device INIT state in qla4_83xx_need_reset_handler()
523 dev_init_timeout = jiffies + (ha->nx_dev_init_timeout * HZ); in qla4_83xx_need_reset_handler()
527 ql4_printk(KERN_INFO, ha, "%s: Non Reset owner dev init timeout\n", in qla4_83xx_need_reset_handler()
532 ha->isp_ops->idc_unlock(ha); in qla4_83xx_need_reset_handler()
534 ha->isp_ops->idc_lock(ha); in qla4_83xx_need_reset_handler()
541 reset_timeout = jiffies + (ha->nx_reset_timeout * HZ); in qla4_83xx_need_reset_handler()
556 ha->isp_ops->idc_unlock(ha); in qla4_83xx_need_reset_handler()
558 ha->isp_ops->idc_lock(ha); in qla4_83xx_need_reset_handler()
567 ql4_printk(KERN_INFO, ha, "%s: Reset_owner turning off drv_active of non-acking function 0x%x\n", in qla4_83xx_need_reset_handler()
574 clear_bit(AF_8XXX_RST_OWNER, &ha->flags); in qla4_83xx_need_reset_handler()
587 ha->nx_dev_init_timeout = idc_params & 0xFFFF; in qla4_83xx_get_idc_param()
588 ha->nx_reset_timeout = (idc_params >> 16) & 0xFFFF; in qla4_83xx_get_idc_param()
590 ha->nx_dev_init_timeout = ROM_DEV_INIT_TIMEOUT; in qla4_83xx_get_idc_param()
591 ha->nx_reset_timeout = ROM_DRV_RESET_ACK_TIMEOUT; in qla4_83xx_get_idc_param()
595 "%s: ha->nx_dev_init_timeout = %d, ha->nx_reset_timeout = %d\n", in qla4_83xx_get_idc_param()
596 __func__, ha->nx_dev_init_timeout, in qla4_83xx_get_idc_param()
597 ha->nx_reset_timeout)); in qla4_83xx_get_idc_param()
600 /*-------------------------Reset Sequence Functions-----------------------*/
606 if (!ha->reset_tmplt.buff) { in qla4_83xx_dump_reset_seq_hdr()
612 phdr = ha->reset_tmplt.buff; in qla4_83xx_dump_reset_seq_hdr()
692 } while (--retries); in qla4_83xx_check_cmd_peg_status()
698 * qla4_83xx_poll_reg - Poll the given CRB addr for duration msecs till
732 } while (retries--); in qla4_83xx_poll_reg()
736 ha->reset_tmplt.seq_error++; in qla4_83xx_poll_reg()
747 uint16_t *buff = (uint16_t *)ha->reset_tmplt.buff; in qla4_83xx_reset_seq_checksum_test()
748 int u16_count = ha->reset_tmplt.hdr->size / sizeof(uint16_t); in qla4_83xx_reset_seq_checksum_test()
751 while (u16_count-- > 0) in qla4_83xx_reset_seq_checksum_test()
770 * qla4_83xx_read_reset_template - Read Reset Template from Flash
779 ha->reset_tmplt.seq_error = 0; in qla4_83xx_read_reset_template()
780 ha->reset_tmplt.buff = vmalloc(QLA83XX_RESTART_TEMPLATE_SIZE); in qla4_83xx_read_reset_template()
781 if (ha->reset_tmplt.buff == NULL) { in qla4_83xx_read_reset_template()
787 p_buff = ha->reset_tmplt.buff; in qla4_83xx_read_reset_template()
806 ha->reset_tmplt.hdr = in qla4_83xx_read_reset_template()
807 (struct qla4_83xx_reset_template_hdr *)ha->reset_tmplt.buff; in qla4_83xx_read_reset_template()
810 tmplt_hdr_size = ha->reset_tmplt.hdr->hdr_size/sizeof(uint32_t); in qla4_83xx_read_reset_template()
812 (ha->reset_tmplt.hdr->signature != RESET_TMPLT_HDR_SIGNATURE)) { in qla4_83xx_read_reset_template()
818 addr = QLA83XX_RESET_TEMPLATE_ADDR + ha->reset_tmplt.hdr->hdr_size; in qla4_83xx_read_reset_template()
819 p_buff = ha->reset_tmplt.buff + ha->reset_tmplt.hdr->hdr_size; in qla4_83xx_read_reset_template()
820 tmplt_hdr_def_size = (ha->reset_tmplt.hdr->size - in qla4_83xx_read_reset_template()
821 ha->reset_tmplt.hdr->hdr_size) / sizeof(uint32_t); in qla4_83xx_read_reset_template()
825 __func__, ha->reset_tmplt.hdr->size)); in qla4_83xx_read_reset_template()
843 "%s: Reset Seq checksum passed, Get stop, start and init seq offsets\n", in qla4_83xx_read_reset_template()
846 /* Get STOP, START, INIT sequence offsets */ in qla4_83xx_read_reset_template()
847 ha->reset_tmplt.init_offset = ha->reset_tmplt.buff + in qla4_83xx_read_reset_template()
848 ha->reset_tmplt.hdr->init_seq_offset; in qla4_83xx_read_reset_template()
849 ha->reset_tmplt.start_offset = ha->reset_tmplt.buff + in qla4_83xx_read_reset_template()
850 ha->reset_tmplt.hdr->start_seq_offset; in qla4_83xx_read_reset_template()
851 ha->reset_tmplt.stop_offset = ha->reset_tmplt.buff + in qla4_83xx_read_reset_template()
852 ha->reset_tmplt.hdr->hdr_size; in qla4_83xx_read_reset_template()
858 vfree(ha->reset_tmplt.buff); in qla4_83xx_read_reset_template()
865 * qla4_83xx_read_write_crb_reg - Read from raddr and write value to waddr.
881 * qla4_83xx_rmw_crb_reg - Read Modify Write crb register
897 if (p_rmw_hdr->index_a) in qla4_83xx_rmw_crb_reg()
898 value = ha->reset_tmplt.array[p_rmw_hdr->index_a]; in qla4_83xx_rmw_crb_reg()
902 value &= p_rmw_hdr->test_mask; in qla4_83xx_rmw_crb_reg()
903 value <<= p_rmw_hdr->shl; in qla4_83xx_rmw_crb_reg()
904 value >>= p_rmw_hdr->shr; in qla4_83xx_rmw_crb_reg()
905 value |= p_rmw_hdr->or_value; in qla4_83xx_rmw_crb_reg()
906 value ^= p_rmw_hdr->xor_value; in qla4_83xx_rmw_crb_reg()
922 for (i = 0; i < p_hdr->count; i++, p_entry++) { in qla4_83xx_write_list()
923 qla4_83xx_wr_reg_indirect(ha, p_entry->arg1, p_entry->arg2); in qla4_83xx_write_list()
924 if (p_hdr->delay) in qla4_83xx_write_list()
925 udelay((uint32_t)(p_hdr->delay)); in qla4_83xx_write_list()
938 for (i = 0; i < p_hdr->count; i++, p_entry++) { in qla4_83xx_read_write_list()
939 qla4_83xx_read_write_crb_reg(ha, p_entry->arg1, p_entry->arg2); in qla4_83xx_read_write_list()
940 if (p_hdr->delay) in qla4_83xx_read_write_list()
941 udelay((uint32_t)(p_hdr->delay)); in qla4_83xx_read_write_list()
948 long delay; in qla4_83xx_poll_list() local
962 delay = (long)p_hdr->delay; in qla4_83xx_poll_list()
963 if (!delay) { in qla4_83xx_poll_list()
964 for (i = 0; i < p_hdr->count; i++, p_entry++) { in qla4_83xx_poll_list()
965 qla4_83xx_poll_reg(ha, p_entry->arg1, delay, in qla4_83xx_poll_list()
966 p_poll->test_mask, in qla4_83xx_poll_list()
967 p_poll->test_value); in qla4_83xx_poll_list()
970 for (i = 0; i < p_hdr->count; i++, p_entry++) { in qla4_83xx_poll_list()
971 if (qla4_83xx_poll_reg(ha, p_entry->arg1, delay, in qla4_83xx_poll_list()
972 p_poll->test_mask, in qla4_83xx_poll_list()
973 p_poll->test_value)) { in qla4_83xx_poll_list()
974 qla4_83xx_rd_reg_indirect(ha, p_entry->arg1, in qla4_83xx_poll_list()
976 qla4_83xx_rd_reg_indirect(ha, p_entry->arg2, in qla4_83xx_poll_list()
986 long delay; in qla4_83xx_poll_write_list() local
995 delay = (long)p_hdr->delay; in qla4_83xx_poll_write_list()
997 for (i = 0; i < p_hdr->count; i++, p_entry++) { in qla4_83xx_poll_write_list()
998 qla4_83xx_wr_reg_indirect(ha, p_entry->dr_addr, in qla4_83xx_poll_write_list()
999 p_entry->dr_value); in qla4_83xx_poll_write_list()
1000 qla4_83xx_wr_reg_indirect(ha, p_entry->ar_addr, in qla4_83xx_poll_write_list()
1001 p_entry->ar_value); in qla4_83xx_poll_write_list()
1002 if (delay) { in qla4_83xx_poll_write_list()
1003 if (qla4_83xx_poll_reg(ha, p_entry->ar_addr, delay, in qla4_83xx_poll_write_list()
1004 p_poll->test_mask, in qla4_83xx_poll_write_list()
1005 p_poll->test_value)) { in qla4_83xx_poll_write_list()
1009 ha->reset_tmplt.seq_index)); in qla4_83xx_poll_write_list()
1027 for (i = 0; i < p_hdr->count; i++, p_entry++) { in qla4_83xx_read_modify_write()
1028 qla4_83xx_rmw_crb_reg(ha, p_entry->arg1, p_entry->arg2, in qla4_83xx_read_modify_write()
1030 if (p_hdr->delay) in qla4_83xx_read_modify_write()
1031 udelay((uint32_t)(p_hdr->delay)); in qla4_83xx_read_modify_write()
1038 if (p_hdr->delay) in qla4_83xx_pause()
1039 mdelay((uint32_t)((long)p_hdr->delay)); in qla4_83xx_pause()
1045 long delay; in qla4_83xx_poll_read_list() local
1056 delay = (long)p_hdr->delay; in qla4_83xx_poll_read_list()
1058 for (i = 0; i < p_hdr->count; i++, p_entry++) { in qla4_83xx_poll_read_list()
1059 qla4_83xx_wr_reg_indirect(ha, p_entry->ar_addr, in qla4_83xx_poll_read_list()
1060 p_entry->ar_value); in qla4_83xx_poll_read_list()
1061 if (delay) { in qla4_83xx_poll_read_list()
1062 if (qla4_83xx_poll_reg(ha, p_entry->ar_addr, delay, in qla4_83xx_poll_read_list()
1063 p_poll->test_mask, in qla4_83xx_poll_read_list()
1064 p_poll->test_value)) { in qla4_83xx_poll_read_list()
1068 ha->reset_tmplt.seq_index)); in qla4_83xx_poll_read_list()
1070 index = ha->reset_tmplt.array_index; in qla4_83xx_poll_read_list()
1071 qla4_83xx_rd_reg_indirect(ha, p_entry->dr_addr, in qla4_83xx_poll_read_list()
1073 ha->reset_tmplt.array[index++] = value; in qla4_83xx_poll_read_list()
1076 ha->reset_tmplt.array_index = 1; in qla4_83xx_poll_read_list()
1085 ha->reset_tmplt.seq_end = 1; in qla4_83xx_seq_end()
1091 ha->reset_tmplt.template_end = 1; in qla4_83xx_template_end()
1093 if (ha->reset_tmplt.seq_error == 0) { in qla4_83xx_template_end()
1104 * qla4_83xx_process_reset_template - Process reset template.
1109 * of entries in sub-sequence and delay in microsecs or timeout in millisecs.
1121 ha->reset_tmplt.seq_end = 0; in qla4_83xx_process_reset_template()
1122 ha->reset_tmplt.template_end = 0; in qla4_83xx_process_reset_template()
1123 entries = ha->reset_tmplt.hdr->entries; in qla4_83xx_process_reset_template()
1124 index = ha->reset_tmplt.seq_index; in qla4_83xx_process_reset_template()
1126 for (; (!ha->reset_tmplt.seq_end) && (index < entries); index++) { in qla4_83xx_process_reset_template()
1129 switch (p_hdr->cmd) { in qla4_83xx_process_reset_template()
1161 __func__, p_hdr->cmd, index); in qla4_83xx_process_reset_template()
1166 p_entry += p_hdr->size; in qla4_83xx_process_reset_template()
1169 ha->reset_tmplt.seq_index = index; in qla4_83xx_process_reset_template()
1174 ha->reset_tmplt.seq_index = 0; in qla4_83xx_process_stop_seq()
1175 qla4_83xx_process_reset_template(ha, ha->reset_tmplt.stop_offset); in qla4_83xx_process_stop_seq()
1177 if (ha->reset_tmplt.seq_end != 1) in qla4_83xx_process_stop_seq()
1178 ql4_printk(KERN_ERR, ha, "%s: Abrupt STOP Sub-Sequence end.\n", in qla4_83xx_process_stop_seq()
1184 qla4_83xx_process_reset_template(ha, ha->reset_tmplt.start_offset); in qla4_83xx_process_start_seq()
1186 if (ha->reset_tmplt.template_end != 1) in qla4_83xx_process_start_seq()
1187 ql4_printk(KERN_ERR, ha, "%s: Abrupt START Sub-Sequence end.\n", in qla4_83xx_process_start_seq()
1193 qla4_83xx_process_reset_template(ha, ha->reset_tmplt.init_offset); in qla4_83xx_process_init_seq()
1195 if (ha->reset_tmplt.seq_end != 1) in qla4_83xx_process_init_seq()
1196 ql4_printk(KERN_ERR, ha, "%s: Abrupt INIT Sub-Sequence end.\n", in qla4_83xx_process_init_seq()
1209 * If IDC_CTRL BIT1 is set, clear it on going to INIT state and in qla4_83xx_restart()
1260 /*----------------------Interrupt Related functions ---------------------*/
1264 if (test_and_clear_bit(AF_83XX_IOCB_INTR_ON, &ha->flags)) in qla4_83xx_disable_iocb_intrs()
1272 if (test_and_clear_bit(AF_83XX_MBOX_INTR_ON, &ha->flags)) { in qla4_83xx_disable_mbox_intrs()
1273 ret = readl(&ha->qla4_83xx_reg->mbox_int); in qla4_83xx_disable_mbox_intrs()
1275 writel(mb_int, &ha->qla4_83xx_reg->mbox_int); in qla4_83xx_disable_mbox_intrs()
1276 writel(1, &ha->qla4_83xx_reg->leg_int_mask); in qla4_83xx_disable_mbox_intrs()
1288 if (!test_bit(AF_83XX_IOCB_INTR_ON, &ha->flags)) { in qla4_83xx_enable_iocb_intrs()
1290 set_bit(AF_83XX_IOCB_INTR_ON, &ha->flags); in qla4_83xx_enable_iocb_intrs()
1298 if (!test_bit(AF_83XX_MBOX_INTR_ON, &ha->flags)) { in qla4_83xx_enable_mbox_intrs()
1300 writel(mb_int, &ha->qla4_83xx_reg->mbox_int); in qla4_83xx_enable_mbox_intrs()
1301 writel(0, &ha->qla4_83xx_reg->leg_int_mask); in qla4_83xx_enable_mbox_intrs()
1302 set_bit(AF_83XX_MBOX_INTR_ON, &ha->flags); in qla4_83xx_enable_mbox_intrs()
1321 writel(mbx_cmd[i], &ha->qla4_83xx_reg->mailbox_in[i]); in qla4_83xx_queue_mbox_cmd()
1323 writel(mbx_cmd[0], &ha->qla4_83xx_reg->mailbox_in[0]); in qla4_83xx_queue_mbox_cmd()
1328 writel(HINT_MBX_INT_PENDING, &ha->qla4_83xx_reg->host_intr); in qla4_83xx_queue_mbox_cmd()
1335 intr_status = readl(&ha->qla4_83xx_reg->risc_intr); in qla4_83xx_process_mbox_intr()
1337 ha->mbox_status_count = outcount; in qla4_83xx_process_mbox_intr()
1338 ha->isp_ops->interrupt_service_routine(ha, intr_status); in qla4_83xx_process_mbox_intr()
1343 * qla4_83xx_isp_reset - Resets ISP and aborts all outstanding commands.
1351 ha->isp_ops->idc_lock(ha); in qla4_83xx_isp_reset()
1375 * non-reset-owner to force a reset. Non-reset-owner sets in qla4_83xx_isp_reset()
1376 * the IDC_CTRL BIT0 to prevent Reset-owner from doing a Reset in qla4_83xx_isp_reset()
1388 set_bit(AF_8XXX_RST_OWNER, &ha->flags); in qla4_83xx_isp_reset()
1390 ha->isp_ops->idc_unlock(ha); in qla4_83xx_isp_reset()
1393 ha->isp_ops->idc_lock(ha); in qla4_83xx_isp_reset()
1396 ha->isp_ops->idc_unlock(ha); in qla4_83xx_isp_reset()
1399 clear_bit(AF_FW_RECOVERY, &ha->flags); in qla4_83xx_isp_reset()
1410 DEBUG2(ql4_printk(KERN_INFO, ha, "SRE-Shim Ctrl:0x%x\n", val)); in qla4_83xx_dump_pause_control_regs()
1459 for (i = 7; i >= 0; i--) { in qla4_83xx_dump_pause_control_regs()
1473 for (i = 7; i >= 0; i--) { in qla4_83xx_dump_pause_control_regs()
1488 "IFB-Pause Thresholds: Port 2:0x%x, Port 3:0x%x\n", in qla4_83xx_dump_pause_control_regs()
1496 /* set SRE-Shim Control Register */ in __qla4_83xx_disable_pause()
1531 * qla4_83xx_eport_init - Initialize EPort.
1535 * serious hardware wedging issues. To prevent this perform eport init everytime
1558 ha->isp_ops->idc_lock(ha); in qla4_83xx_disable_pause()
1563 ha->isp_ops->idc_unlock(ha); in qla4_83xx_disable_pause()
1567 * qla4_83xx_is_detached - Check if we are marked invisible.
1576 if (test_bit(AF_INIT_DONE, &ha->flags) && in qla4_83xx_is_detached()
1577 !(drv_active & (1 << ha->func_num))) { in qla4_83xx_is_detached()