patch-2.2.7 linux/drivers/scsi/qlogicisp.c

Next file: linux/drivers/scsi/qlogicisp_asm.c
Previous file: linux/drivers/scsi/ide-scsi.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.6/linux/drivers/scsi/qlogicisp.c linux/drivers/scsi/qlogicisp.c
@@ -27,6 +27,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/spinlock.h>
+#include <asm/byteorder.h>
 
 #include "sd.h"
 #include "hosts.h"
@@ -49,7 +50,7 @@
 /*  Macros used for debugging */
 
 #define DEBUG_ISP1020		0
-#define DEBUG_ISP1020_INT	0
+#define DEBUG_ISP1020_INTR	0
 #define DEBUG_ISP1020_SETUP	0
 #define TRACE_ISP		0
 
@@ -730,17 +731,17 @@
 	cmd->hdr.entry_type = ENTRY_COMMAND;
 	cmd->hdr.entry_cnt = 1;
 
-	cmd->handle = (u_int) virt_to_bus(Cmnd);
+	cmd->handle = cpu_to_le32((u_int) virt_to_bus(Cmnd));
 	cmd->target_lun = Cmnd->lun;
 	cmd->target_id = Cmnd->target;
-	cmd->cdb_length = Cmnd->cmd_len;
-	cmd->control_flags = CFLAG_READ | CFLAG_WRITE;
-	cmd->time_out = 30;
+	cmd->cdb_length = cpu_to_le16(Cmnd->cmd_len);
+	cmd->control_flags = cpu_to_le16(CFLAG_READ | CFLAG_WRITE);
+	cmd->time_out = cpu_to_le16(30);
 
 	memcpy(cmd->cdb, Cmnd->cmnd, Cmnd->cmd_len);
 
 	if (Cmnd->use_sg) {
-		cmd->segment_cnt = sg_count = Cmnd->use_sg;
+		cmd->segment_cnt = cpu_to_le16(sg_count = Cmnd->use_sg);
 		sg = (struct scatterlist *) Cmnd->request_buffer;
 		ds = cmd->dataseg;
 
@@ -749,8 +750,8 @@
 		if (n > 4)
 			n = 4;
 		for (i = 0; i < n; i++) {
-			ds[i].d_base  = (u_int) virt_to_bus(sg->address);
-			ds[i].d_count = sg->length;
+			ds[i].d_base  = cpu_to_le32((u_int) virt_to_bus(sg->address));
+			ds[i].d_count = cpu_to_le32(sg->length);
 			++sg;
 		}
 		sg_count -= 4;
@@ -776,18 +777,18 @@
 			if (n > 7)
 				n = 7;
 			for (i = 0; i < n; ++i) {
-				ds[i].d_base = (u_int)virt_to_bus(sg->address);
-				ds[i].d_count = sg->length;
+				ds[i].d_base = cpu_to_le32((u_int)virt_to_bus(sg->address));
+				ds[i].d_count = cpu_to_le32(sg->length);
 				++sg;
 			}
 			sg_count -= n;
 		}
 	} else {
 		cmd->dataseg[0].d_base =
-			(u_int) virt_to_bus(Cmnd->request_buffer);
+			cpu_to_le32((u_int) virt_to_bus(Cmnd->request_buffer));
 		cmd->dataseg[0].d_count =
-			(u_int) Cmnd->request_bufflen;
-		cmd->segment_cnt = 1;
+			cpu_to_le32((u_int) Cmnd->request_bufflen);
+		cmd->segment_cnt = cpu_to_le16(1);
 	}
 
 	outw(in_ptr, host->io_port + MBOX4);
@@ -861,22 +862,22 @@
 
 	DEBUG_INTR(printk("qlogicisp : response queue update\n"));
 	DEBUG_INTR(printk("qlogicisp : response queue depth %d\n",
-			  QUEUE_DEPTH(in_ptr, out_ptr)));
+			  QUEUE_DEPTH(in_ptr, out_ptr, RES_QUEUE_LEN)));
 
 	while (out_ptr != in_ptr) {
 		sts = (struct Status_Entry *) &hostdata->res[out_ptr][0];
 		out_ptr = (out_ptr + 1) & RES_QUEUE_LEN;
 
-		Cmnd = (Scsi_Cmnd *) bus_to_virt(sts->handle);
+		Cmnd = (Scsi_Cmnd *) bus_to_virt(le32_to_cpu(sts->handle));
 
 		TRACE("done", out_ptr, Cmnd);
 
-		if (sts->completion_status == CS_RESET_OCCURRED
-		    || sts->completion_status == CS_ABORTED
-		    || (sts->status_flags & STF_BUS_RESET))
+		if (le16_to_cpu(sts->completion_status) == CS_RESET_OCCURRED
+		    || le16_to_cpu(sts->completion_status) == CS_ABORTED
+		    || (le16_to_cpu(sts->status_flags) & STF_BUS_RESET))
 			hostdata->send_marker = 1;
 
-		if (sts->state_flags & SF_GOT_SENSE)
+		if (le16_to_cpu(sts->state_flags) & SF_GOT_SENSE)
 			memcpy(Cmnd->sense_buffer, sts->req_sense_data,
 			       sizeof(Cmnd->sense_buffer));
 
@@ -917,24 +918,24 @@
 	ENTER("isp1020_return_status");
 
 	DEBUG(printk("qlogicisp : completion status = 0x%04x\n",
-		     sts->completion_status));
+		     le16_to_cpu(sts->completion_status)));
 
-	switch(sts->completion_status) {
+	switch(le16_to_cpu(sts->completion_status)) {
 	      case CS_COMPLETE:
 		host_status = DID_OK;
 		break;
 	      case CS_INCOMPLETE:
-		if (!(sts->state_flags & SF_GOT_BUS))
+		if (!(le16_to_cpu(sts->state_flags) & SF_GOT_BUS))
 			host_status = DID_NO_CONNECT;
-		else if (!(sts->state_flags & SF_GOT_TARGET))
+		else if (!(le16_to_cpu(sts->state_flags) & SF_GOT_TARGET))
 			host_status = DID_BAD_TARGET;
-		else if (!(sts->state_flags & SF_SENT_CDB))
+		else if (!(le16_to_cpu(sts->state_flags) & SF_SENT_CDB))
 			host_status = DID_ERROR;
-		else if (!(sts->state_flags & SF_TRANSFERRED_DATA))
+		else if (!(le16_to_cpu(sts->state_flags) & SF_TRANSFERRED_DATA))
 			host_status = DID_ERROR;
-		else if (!(sts->state_flags & SF_GOT_STATUS))
+		else if (!(le16_to_cpu(sts->state_flags) & SF_GOT_STATUS))
 			host_status = DID_ERROR;
-		else if (!(sts->state_flags & SF_GOT_SENSE))
+		else if (!(le16_to_cpu(sts->state_flags) & SF_GOT_SENSE))
 			host_status = DID_ERROR;
 		break;
 	      case CS_DMA_ERROR:
@@ -970,17 +971,17 @@
 		break;
 	      default:
 		printk("qlogicisp : unknown completion status 0x%04x\n",
-		       sts->completion_status);
+		       le16_to_cpu(sts->completion_status));
 		host_status = DID_ERROR;
 		break;
 	}
 
 	DEBUG_INTR(printk("qlogicisp : host status (%s) scsi status %x\n",
-			  reason[host_status], sts->scsi_status));
+			  reason[host_status], le16_to_cpu(sts->scsi_status)));
 
 	LEAVE("isp1020_return_status");
 
-	return (sts->scsi_status & STATUS_MASK) | (host_status << 16);
+	return (le16_to_cpu(sts->scsi_status) & STATUS_MASK) | (host_status << 16);
 }
 
 
@@ -1082,7 +1083,9 @@
 	ENTER("isp1020_reset_hardware");
 
 	outw(ISP_RESET, host->io_port + PCI_INTF_CTL);
+	udelay(100);
 	outw(HCCR_RESET, host->io_port + HOST_HCCR);
+	udelay(100);
 	outw(HCCR_RELEASE, host->io_port + HOST_HCCR);
 	outw(HCCR_BIOS_DISABLE, host->io_port + HOST_HCCR);
 
@@ -1103,27 +1106,25 @@
 	printk("qlogicisp : mbox 5 0x%04x \n", inw(host->io_port + MBOX5));
 #endif /* DEBUG_ISP1020 */
 
+	param[0] = MBOX_NO_OP;
+	isp1020_mbox_command(host, param);
+	if (param[0] != MBOX_COMMAND_COMPLETE) {
+		printk("qlogicisp : NOP test failed\n");
+		return 1;
+	}
+
 	DEBUG(printk("qlogicisp : loading risc ram\n"));
 
 #if RELOAD_FIRMWARE
-	/* Do not reload firmware if 1040B, i.e. revision 5 chip.  */
-	if (((struct isp1020_hostdata *) host->hostdata)->revision >= 5)
-		printk("qlogicisp : 1040B or later chip,"
-		       " firmware not (re)loaded\n");
-	else
-	{
-		int i;
-		for (i = 0; i < risc_code_length01; i++) {
-			param[0] = MBOX_WRITE_RAM_WORD;
-			param[1] = risc_code_addr01 + i;
-			param[2] = risc_code01[i];
-
-			isp1020_mbox_command(host, param);
-
-			if (param[0] != MBOX_COMMAND_COMPLETE) {
-				printk("qlogicisp : firmware load failure\n");
-				return 1;
-			}
+	for (loop_count = 0; loop_count < risc_code_length01; loop_count++) {
+		param[0] = MBOX_WRITE_RAM_WORD;
+		param[1] = risc_code_addr01 + loop_count;
+		param[2] = risc_code01[loop_count];
+		isp1020_mbox_command(host, param);
+		if (param[0] != MBOX_COMMAND_COMPLETE) {
+			printk("qlogicisp : firmware load failure at %d\n",
+			    loop_count);
+			return 1;
 		}
 	}
 #endif /* RELOAD_FIRMWARE */
@@ -1200,6 +1201,15 @@
 		return 1;
 	}
 
+#ifdef __sparc__
+	command |= (PCI_COMMAND_MASTER|PCI_COMMAND_IO|PCI_COMMAND_MEMORY|
+		    PCI_COMMAND_INVALIDATE|PCI_COMMAND_SERR);
+	pci_write_config_word(pdev, PCI_COMMAND, command);
+	pci_read_config_word(pdev, PCI_COMMAND, &command);
+	pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 16);
+	pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
+#endif
+
 	if (command & PCI_COMMAND_IO && (io_base & 3) == 1)
 		io_base &= PCI_BASE_ADDRESS_IO_MASK;
 	else {
@@ -1227,6 +1237,8 @@
 
 	sh->irq = irq;
 	sh->io_port = io_base;
+	sh->max_id = MAX_TARGETS;
+	sh->max_lun = MAX_LUNS;
 
 	LEAVE("isp1020_init");
 
@@ -1691,14 +1703,15 @@
 	printk("qlogicisp : entry count = 0x%02x, type = 0x%02x, flags = 0x%02x\n",
 	       status->hdr.entry_cnt, status->hdr.entry_type, status->hdr.flags);
 	printk("qlogicisp : scsi status = 0x%04x, completion status = 0x%04x\n",
-	       status->scsi_status, status->completion_status);
+	       le16_to_cpu(status->scsi_status), le16_to_cpu(status->completion_status));
 	printk("qlogicisp : state flags = 0x%04x, status flags = 0x%04x\n",
-	       status->state_flags, status->status_flags);
+	       le16_to_cpu(status->state_flags), le16_to_cpu(status->status_flags));
 	printk("qlogicisp : time = 0x%04x, request sense length = 0x%04x\n",
-	       status->time, status->req_sense_len);
-	printk("qlogicisp : residual transfer length = 0x%08x\n", status->residual);
+	       le16_to_cpu(status->time), le16_to_cpu(status->req_sense_len));
+	printk("qlogicisp : residual transfer length = 0x%08x\n",
+	       le32_to_cpu(status->residual));
 
-	for (i = 0; i < status->req_sense_len; i++)
+	for (i = 0; i < le16_to_cpu(status->req_sense_len); i++)
 		printk("qlogicisp : sense data = 0x%02x\n", status->req_sense_data[i]);
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)