unsigned char	target  = SCpnt->device->id; 
unsigned char	target  = scmd_id(SCpnt); 
static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt){	nsp32_hw_data  *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;	unsigned int	base    = SCpnt->device->host->io_port;	unsigned int	host_id = SCpnt->device->host->this_id;	unsigned char	target  = SCpnt->device->id;	unsigned char	phase;	int		status;	unsigned short	command	= 0;	unsigned int	msgout  = 0;	unsigned short	execph;	int		i;	nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "in");	/*	 * IRQ disable	 */	nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK);	/*	 * check bus line	 */	phase = nsp32_read1(base, SCSI_BUS_MONITOR);	if(((phase & BUSMON_BSY) == 1) || (phase & BUSMON_SEL) == 1) {		nsp32_msg(KERN_WARNING, "bus busy");		SCpnt->result = DID_BUS_BUSY << 16;		status = 1;		goto out;        }	/*	 * clear execph	 */	execph = nsp32_read2(base, SCSI_EXECUTE_PHASE);	/*	 * clear FIFO counter to set CDBs	 */	nsp32_write2(base, COMMAND_CONTROL, CLEAR_CDB_FIFO_POINTER);	/*	 * set CDB0 - CDB15	 */	for (i = 0; i < SCpnt->cmd_len; i++) {		nsp32_write1(base, COMMAND_DATA, SCpnt->cmnd[i]);        }	nsp32_dbg(NSP32_DEBUG_CDB_CONTENTS, "CDB[0]=[0x%x]", SCpnt->cmnd[0]);	/*	 * set SCSIOUT LATCH(initiator)/TARGET(target) (OR-ed) ID	 */	nsp32_write1(base, SCSI_OUT_LATCH_TARGET_ID, BIT(host_id) | BIT(target));	/*	 * set SCSI MSGOUT REG	 *	 * Note: If the range of msgout_len is 1 - 3, fill scsi_msgout.	 *       over 3 messages needs another routine.	 */	if (data->msgout_len == 0) {		nsp32_msg(KERN_ERR, "SCSI MsgOut without any message!");		SCpnt->result = DID_ERROR << 16;		status = 1;		goto out;	} else if (data->msgout_len > 0 && data->msgout_len <= 3) {		msgout = 0;		for (i = 0; i < data->msgout_len; i++) {			/*			 * the sending order of the message is:			 *  MCNT 3: MSG#0 -> MSG#1 -> MSG#2			 *  MCNT 2:          MSG#1 -> MSG#2			 *  MCNT 1:                   MSG#2    			 */			msgout >>= 8;			msgout |= ((unsigned int)(data->msgoutbuf[i]) << 24);		}		msgout |= MV_VALID;	/* MV valid */		msgout |= (unsigned int)data->msgout_len; /* len */		nsp32_write4(base, SCSI_MSG_OUT, msgout);	} else {		/* data->msgout_len > 3 */		nsp32_write4(base, SCSI_MSG_OUT, 0);	}	/*	 * set selection timeout(= 250ms)	 */	nsp32_write2(base, SEL_TIME_OUT,   SEL_TIMEOUT_TIME);	/*	 * set SREQ hazard killer sampling rate	 * 	 * TODO: sample_rate (BASE+0F) is 0 when internal clock = 40MHz.	 *      check other internal clock!	 */	nsp32_write1(base, SREQ_SMPL_RATE, data->cur_target->sample_reg);	/*	 * clear Arbit	 */	nsp32_write1(base, SET_ARBIT,      ARBIT_CLEAR);	/*	 * set SYNCREG	 * Don't set BM_START_ADR before setting this register.	 */	nsp32_write1(base, SYNC_REG,  data->cur_target->syncreg);	/*	 * set ACKWIDTH	 */	nsp32_write1(base, ACK_WIDTH, data->cur_target->ackwidth);	nsp32_dbg(NSP32_DEBUG_AUTOSCSI,		  "syncreg=0x%x, ackwidth=0x%x, sgtpaddr=0x%x, id=0x%x",		  nsp32_read1(base, SYNC_REG), nsp32_read1(base, ACK_WIDTH),		  nsp32_read4(base, SGT_ADR), nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID));	nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "msgout_len=%d, msgout=0x%x",		  data->msgout_len, msgout);	/*	 * set SGT ADDR (physical address)	 */	nsp32_write4(base, SGT_ADR, data->cur_lunt->sglun_paddr);	/*	 * set TRANSFER CONTROL REG	 */	command = 0;	command |= (TRANSFER_GO | ALL_COUNTER_CLR);	if (data->trans_method & NSP32_TRANSFER_BUSMASTER) {		if (SCpnt->request_bufflen > 0) {			command |= BM_START;		}	} else if (data->trans_method & NSP32_TRANSFER_MMIO) {		command |= CB_MMIO_MODE;	} else if (data->trans_method & NSP32_TRANSFER_PIO) {		command |= CB_IO_MODE;	}	nsp32_write2(base, TRANSFER_CONTROL, command);	/*	 * start AUTO SCSI, kick off arbitration	 */	command = (CLEAR_CDB_FIFO_POINTER |		   AUTOSCSI_START         |		   AUTO_MSGIN_00_OR_04    |		   AUTO_MSGIN_02          |		   AUTO_ATN                );	nsp32_write2(base, COMMAND_CONTROL, command);	/*	 * Check arbitration	 */	status = nsp32_arbitration(SCpnt, base); out:	/*	 * IRQ enable	 */	nsp32_write2(base, IRQ_CONTROL, 0);	return status;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/nsp32.c/clean/drivers/scsi/nsp32.c