]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/scsi/qla2xxx/qla_init.c
[PATCH] qla2xxx: Kconfig dependency fix
[mv-sheeva.git] / drivers / scsi / qla2xxx / qla_init.c
index d2a367882e8bdc408cc5e7946fc2b5a921d47e5d..a6d2559217cded06fa9737cb9d9989190f9495e8 100644 (file)
@@ -2,7 +2,7 @@
  *                  QLOGIC LINUX SOFTWARE
  *
  * QLogic ISP2x00 device driver for Linux 2.6.x
- * Copyright (C) 2003-2004 QLogic Corporation
+ * Copyright (C) 2003-2005 QLogic Corporation
  * (www.qlogic.com)
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -564,20 +564,18 @@ qla2x00_reset_chip(scsi_qla_host_t *ha)
 }
 
 /**
- * qla24xx_reset_chip() - Reset ISP24xx chip.
+ * qla24xx_reset_risc() - Perform full reset of ISP24xx RISC.
  * @ha: HA context
  *
  * Returns 0 on success.
  */
-void
-qla24xx_reset_chip(scsi_qla_host_t *ha)
+static inline void
+qla24xx_reset_risc(scsi_qla_host_t *ha)
 {
        unsigned long flags = 0;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
        uint32_t cnt, d2;
 
-       ha->isp_ops.disable_intrs(ha);
-
        spin_lock_irqsave(&ha->hardware_lock, flags);
 
        /* Reset RISC. */
@@ -591,6 +589,17 @@ qla24xx_reset_chip(scsi_qla_host_t *ha)
 
        WRT_REG_DWORD(&reg->ctrl_status,
            CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
+       RD_REG_DWORD(&reg->ctrl_status);
+
+       /* Wait for firmware to complete NVRAM accesses. */
+       udelay(5);
+       d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
+       for (cnt = 10000 ; cnt && d2; cnt--) {
+               udelay(5);
+               d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
+               barrier();
+       }
+
        udelay(20);
        d2 = RD_REG_DWORD(&reg->ctrl_status);
        for (cnt = 6000000 ; cnt && (d2 & CSRX_ISP_SOFT_RESET); cnt--) {
@@ -618,6 +627,21 @@ qla24xx_reset_chip(scsi_qla_host_t *ha)
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 }
 
+/**
+ * qla24xx_reset_chip() - Reset ISP24xx chip.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+void
+qla24xx_reset_chip(scsi_qla_host_t *ha)
+{
+       ha->isp_ops.disable_intrs(ha);
+
+       /* Perform RISC reset. */
+       qla24xx_reset_risc(ha);
+}
+
 /**
  * qla2x00_chip_diag() - Test chip for proper operation.
  * @ha: HA context
@@ -753,49 +777,9 @@ int
 qla24xx_chip_diag(scsi_qla_host_t *ha)
 {
        int rval;
-       struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
-       unsigned long flags = 0;
-       uint32_t cnt, d2;
-
-       spin_lock_irqsave(&ha->hardware_lock, flags);
 
-       /* Reset RISC. */
-       WRT_REG_DWORD(&reg->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
-       for (cnt = 0; cnt < 30000; cnt++) {
-               if ((RD_REG_DWORD(&reg->ctrl_status) &
-                   CSRX_DMA_ACTIVE) == 0)
-                       break;
-
-               udelay(10);
-       }
-
-       WRT_REG_DWORD(&reg->ctrl_status,
-           CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
-       udelay(20);
-       d2 = RD_REG_DWORD(&reg->ctrl_status);
-       for (cnt = 6000000 ; cnt && (d2 & CSRX_ISP_SOFT_RESET); cnt--) {
-               udelay(5);
-               d2 = RD_REG_DWORD(&reg->ctrl_status);
-               barrier();
-       }
-
-       WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET);
-       RD_REG_DWORD(&reg->hccr);
-
-       WRT_REG_DWORD(&reg->hccr, HCCRX_REL_RISC_PAUSE);
-       RD_REG_DWORD(&reg->hccr);
-
-       WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_RESET);
-       RD_REG_DWORD(&reg->hccr);
-
-       d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
-       for (cnt = 6000000 ; cnt && d2; cnt--) {
-               udelay(5);
-               d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
-               barrier();
-       }
-
-       spin_unlock_irqrestore(&ha->hardware_lock, flags);
+       /* Perform RISC reset. */
+       qla24xx_reset_risc(ha);
 
        ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024;
 
@@ -2083,21 +2067,25 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
        rport_ids.port_name = be64_to_cpu(*(uint64_t *)fcport->port_name);
        rport_ids.port_id = fcport->d_id.b.domain << 16 |
            fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
+       rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
+       fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
+       if (!rport) {
+               qla_printk(KERN_WARNING, ha,
+                   "Unable to allocate fc remote port!\n");
+               return;
+       }
+       rport->dd_data = fcport;
+
        rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
        if (fcport->port_type == FCT_INITIATOR)
                rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
        if (fcport->port_type == FCT_TARGET)
                rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
+       fc_remote_port_rolechg(rport, rport_ids.roles);
 
-       fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
-       if (!rport)
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to allocate fc remote port!\n");
-
-       if (rport->scsi_target_id != -1 && rport->scsi_target_id < MAX_TARGETS)
+       if (rport->scsi_target_id != -1 &&
+           rport->scsi_target_id < ha->host->max_id)
                fcport->os_target_id = rport->scsi_target_id;
-
-       rport->dd_data = fcport;
 }
 
 /*