/*
 * (C) Copyright 2001
 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 * partly derived from
 * linux/drivers/scsi/sym53c8xx.c
 *
 */

/*
 * SCSI support based on the chip sym53C810.
 *
 * 09-19-2001 Andreas Heppel, Sysgo RTS GmbH <aheppel@sysgo.de>
 *		The local version of this driver for the BAB750 board does not
 *		use interrupts but polls the chip instead (see the call of
 *		'handle_scsi_int()' in 'scsi_issue()'.
 */

#include <common.h>

#ifdef CONFIG_SCSI_SYM53C8XX

#include <command.h>
#include <cmd_boot.h>
#include <pci.h>
#include <asm/processor.h>
#include <sym53c8xx.h>
#include <scsi.h>

#undef	SYM53C8XX_DEBUG

#ifdef	SYM53C8XX_DEBUG
#define	PRINTF(fmt,args...)	printf (fmt ,##args)
#else
#define PRINTF(fmt,args...)
#endif

#if (CONFIG_COMMANDS & CFG_CMD_SCSI) && defined(CONFIG_SCSI_SYM53C8XX)

#undef SCSI_SINGLE_STEP
/*
 * Single Step is only used for debug purposes
 */
#ifdef SCSI_SINGLE_STEP
static unsigned long start_script_select;
static unsigned long start_script_msgout;
static unsigned long start_script_msgin;
static unsigned long start_script_msg_ext;
static unsigned long start_script_cmd;
static unsigned long start_script_data_in;
static unsigned long start_script_data_out;
static unsigned long start_script_status;
static unsigned long start_script_complete;
static unsigned long start_script_error;
static unsigned long start_script_reselection;
static unsigned int len_script_select;
static unsigned int len_script_msgout;
static unsigned int len_script_msgin;
static unsigned int len_script_msg_ext;
static unsigned int len_script_cmd;
static unsigned int len_script_data_in;
static unsigned int len_script_data_out;
static unsigned int len_script_status;
static unsigned int len_script_complete;
static unsigned int len_script_error;
static unsigned int len_script_reselection;
#endif


static unsigned short scsi_int_mask;		/* shadow register for SCSI related interrupts */
static unsigned char  script_int_mask;	/* shadow register for SCRIPT related interrupts */
static unsigned long script_select[8]; /* script for selection */
static unsigned long script_msgout[8]; /* script for message out phase (NOT USED) */
static unsigned long script_msgin[14]; /* script for message in phase */
static unsigned long script_msg_ext[32]; /* script for message in phase when more than 1 byte message */
static unsigned long script_cmd[18];    /* script for command phase */
static unsigned long script_data_in[8]; /* script for data in phase */
static unsigned long script_data_out[8]; /* script for data out phase */
static unsigned long script_status[6]; /* script for status phase */
static unsigned long script_complete[10]; /* script for complete */
static unsigned long script_reselection[4]; /* script for reselection (NOT USED) */
static unsigned long script_error[2]; /* script for error handling */

static unsigned long int_stat[3]; /* interrupt status */
static unsigned long scsi_mem_addr; /* base memory address =SCSI_MEM_ADDRESS; */

#define bus_to_phys(a)	pci_mem_to_phys(busdevfunc, (unsigned long) (a))
#define phys_to_bus(a)	pci_phys_to_mem(busdevfunc, (unsigned long) (a))

#define SCSI_MAX_RETRY 3 /* number of retries in scsi_issue() */

#define SCSI_MAX_RETRY_NOT_READY 10 /* number of retries when device is not ready */
#define SCSI_NOT_READY_TIME_OUT 500 /* timeout per retry when not ready */

/*********************************************************************************
 * forward declerations
 */

void scsi_chip_init(void);
void handle_scsi_int(void);


/********************************************************************************
 * reports SCSI errors to the user
 */
void scsi_print_error(ccb *pccb)
{
	int i;
	printf("SCSI Error: Target %d LUN %d Command %02X\n",pccb->target, pccb->lun, pccb->cmd[0]);
	printf("       CCB: ");
	for(i=0;i<pccb->cmdlen;i++)
		printf("%02X ",pccb->cmd[i]);
	printf("(len=%d)\n",pccb->cmdlen);
	printf("     Cntrl: ");
	switch(pccb->contr_stat) {
		case SIR_COMPLETE: 						printf("Complete (no Error)\n"); break;
		case SIR_SEL_ATN_NO_MSG_OUT: 	printf("Selected with ATN no MSG out phase\n"); break;
		case SIR_CMD_OUT_ILL_PH: 			printf("Command out illegal phase\n"); break;
		case SIR_MSG_RECEIVED: 				printf("MSG received Error\n"); break;
		case SIR_DATA_IN_ERR: 				printf("Data in Error\n"); break;
		case SIR_DATA_OUT_ERR: 				printf("Data out Error\n"); break;
		case SIR_SCRIPT_ERROR: 				printf("Script Error\n"); break;
		case SIR_MSG_OUT_NO_CMD: 			printf("MSG out no Command phase\n"); break;
		case SIR_MSG_OVER7: 					printf("MSG in over 7 bytes\n"); break;
		case INT_ON_FY: 							printf("Interrupt on fly\n"); break;
		case SCSI_SEL_TIME_OUT:				printf("SCSI Selection Timeout\n"); break;
		case SCSI_HNS_TIME_OUT:				printf("SCSI Handshake Timeout\n"); break;
		case SCSI_MA_TIME_OUT:				printf("SCSI Phase Error\n"); break;
		case SCSI_UNEXP_DIS:					printf("SCSI unexpected disconnect\n"); break;
		default:											printf("unknown status %lx\n",pccb->contr_stat); break;
	}
	printf("     Sense: SK %x (",pccb->sense_buf[2]&0x0f);
	switch(pccb->sense_buf[2]&0xf) {
		case SENSE_NO_SENSE: printf("No Sense)"); break;
		case SENSE_RECOVERED_ERROR: printf("Recovered Error)"); break;
		case SENSE_NOT_READY:	printf("Not Ready)"); break;
		case SENSE_MEDIUM_ERROR: printf("Medium Error)"); break;
		case SENSE_HARDWARE_ERROR: printf("Hardware Error)"); break;
		case SENSE_ILLEGAL_REQUEST: printf("Illegal request)"); break;
		case SENSE_UNIT_ATTENTION: printf("Unit Attention)"); break;
		case SENSE_DATA_PROTECT: printf("Data Protect)"); break;
		case SENSE_BLANK_CHECK:	printf("Blank check)"); break;
		case SENSE_VENDOR_SPECIFIC: printf("Vendor specific)"); break;
		case SENSE_COPY_ABORTED: printf("Copy aborted)"); break;
		case SENSE_ABORTED_COMMAND:	printf("Aborted Command)"); break;
		case SENSE_VOLUME_OVERFLOW:	printf("Volume overflow)"); break;
		case SENSE_MISCOMPARE: printf("Misscompare\n"); break;
		default: printf("Illegal Sensecode\n"); break;
	}
	printf(" ASC %x ASCQ %x\n",pccb->sense_buf[12],pccb->sense_buf[13]);
	printf("    Status: ");
	switch(pccb->status) {
		case S_GOOD :	printf("Good\n"); break;
		case S_CHECK_COND: printf("Check condition\n"); break;
		case S_COND_MET: printf("Condition Met\n"); break;
		case S_BUSY: printf("Busy\n"); break;
		case S_INT: printf("Intermediate\n"); break;
		case S_INT_COND_MET: printf("Intermediate condition met\n"); break;
		case S_CONFLICT: printf("Reservation conflict\n"); break;
		case S_TERMINATED: printf("Command terminated\n"); break;
		case S_QUEUE_FULL: printf("Task set full\n"); break;
		default: printf("unknown: %02X\n",pccb->status); break;
	}

}



/******************************************************************************
 * sets-up the SCSI controller
 * the base memory address is retrived via the pci_read_config_dword
 */
void scsi_low_level_init(int busdevfunc)
{
	unsigned int cmd;
	unsigned int addr;
	unsigned char vec;

	pci_read_config_byte(busdevfunc, PCI_INTERRUPT_LINE, &vec);
	pci_read_config_dword(busdevfunc, PCI_BASE_ADDRESS_1, &addr);

	addr = bus_to_phys(addr & ~0xf);

	/*
	 * Enable bus mastering in case this has not been done, yet.
	 */
	pci_read_config_dword(busdevfunc, PCI_COMMAND, &cmd);
	cmd |= PCI_COMMAND_MASTER;
	pci_write_config_dword(busdevfunc, PCI_COMMAND, cmd);

	scsi_mem_addr = addr;

	scsi_chip_init();
	scsi_bus_reset();
}


/************************************************************************************
 * Low level Part of SCSI Driver
 */

/*
 * big-endian -> little endian conversion for the script
 */
unsigned long swap_script(unsigned long val)
{
	unsigned long tmp;
	tmp = ((val>>24)&0xff) | ((val>>8)&0xff00) | ((val<<8)&0xff0000) | ((val<<24)&0xff000000);
	return tmp;
}


void scsi_write_byte(ulong offset,unsigned char val)
{
	out8(scsi_mem_addr+offset,val);
}


unsigned char scsi_read_byte(ulong offset)
{
	return(in8(scsi_mem_addr+offset));
}


/********************************************************************************
 * interrupt handler
 */
void handle_scsi_int(void)
{
	unsigned char stat,stat1,stat2;
	unsigned short sstat;
	int i;
#ifdef SCSI_SINGLE_STEP
	unsigned long tt;
#endif
	stat=scsi_read_byte(ISTAT);
	if((stat & DIP)==DIP) { /* DMA Interrupt pending */
		stat1=scsi_read_byte(DSTAT);
#ifdef SCSI_SINGLE_STEP
		if((stat1 & SSI)==SSI)
		{
			tt=in32r(scsi_mem_addr+DSP);
			if(((tt)>=start_script_select) && ((tt)<start_script_select+len_script_select)) {
				printf("select %d\n",(tt-start_script_select)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_msgout) && ((tt)<start_script_msgout+len_script_msgout)) {
				printf("msgout %d\n",(tt-start_script_msgout)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_msgin) && ((tt)<start_script_msgin+len_script_msgin)) {
				printf("msgin %d\n",(tt-start_script_msgin)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_msg_ext) && ((tt)<start_script_msg_ext+len_script_msg_ext)) {
				printf("msgin_ext %d\n",(tt-start_script_msg_ext)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_cmd) && ((tt)<start_script_cmd+len_script_cmd)) {
				printf("cmd %d\n",(tt-start_script_cmd)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_data_in) && ((tt)<start_script_data_in+len_script_data_in)) {
				printf("data_in %d\n",(tt-start_script_data_in)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_data_out) && ((tt)<start_script_data_out+len_script_data_out)) {
				printf("data_out %d\n",(tt-start_script_data_out)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_status) && ((tt)<start_script_status+len_script_status)) {
				printf("status %d\n",(tt-start_script_status)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_complete) && ((tt)<start_script_complete+len_script_complete)) {
				printf("complete %d\n",(tt-start_script_complete)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_error) && ((tt)<start_script_error+len_script_error)) {
				printf("error %d\n",(tt-start_script_error)>>2);
				goto end_single;
			}
			if(((tt)>=start_script_reselection) && ((tt)<start_script_reselection+len_script_reselection)) {
				printf("reselection %d\n",(tt-start_script_reselection)>>2);
				goto end_single;
			}
			printf("sc: %lx\n",tt);
end_single:
			stat2=scsi_read_byte(DCNTL);
			stat2|=STD;
			scsi_write_byte(DCNTL,stat2);
		}
#endif
		if((stat1 & SIR)==SIR) /* script interrupt */
		{
			int_stat[0]=in32(scsi_mem_addr+DSPS);
		}
		if((stat1 & DFE)==0) { /* fifo not epmty */
			scsi_write_byte(CTEST3,CLF); /* Clear DMA FIFO */
			stat2=scsi_read_byte(STEST3);
			scsi_write_byte(STEST3,(stat2 | CSF)); /* Clear SCSI FIFO */
		}
	}
	if((stat & SIP)==SIP) {  /* scsi interrupt */
		sstat = (unsigned short)scsi_read_byte(SIST+1);
		sstat <<=8;
		sstat |= (unsigned short)scsi_read_byte(SIST);
		for(i=0;i<3;i++) {
			if(int_stat[i]==0)
				break; /* found an empty int status */
		}
		int_stat[i]=SCSI_INT_STATE | sstat;
		stat1=scsi_read_byte(DSTAT);
		if((stat1 & DFE)==0) { /* fifo not epmty */
			scsi_write_byte(CTEST3,CLF); /* Clear DMA FIFO */
			stat2=scsi_read_byte(STEST3);
			scsi_write_byte(STEST3,(stat2 | CSF)); /* Clear SCSI FIFO */
		}
	}
	if((stat & INTF)==INTF) { /* interrupt on Fly */
		scsi_write_byte(ISTAT,stat); /* clear it */
		for(i=0;i<3;i++) {
			if(int_stat[i]==0)
				break; /* found an empty int status */
		}
		int_stat[i]=INT_ON_FY;
	}
}

void scsi_bus_reset(void)
{
	unsigned char t;
	int i;
	int end = CFG_SCSI_SPIN_UP_TIME*1000;

	t=scsi_read_byte(SCNTL1);
	scsi_write_byte(SCNTL1,(t | CRST));
	udelay(50);
	scsi_write_byte(SCNTL1,t);

	puts("waiting for devices to spin up");
	for(i=0;i<end;i++) {
		udelay(1000); /* give the devices time to spin up */
		if (i % 1000 == 0)
			putc('.');
	}
	putc('\n');
	scsi_chip_init(); /* reinit the chip ...*/

}

void scsi_int_enable(void)
{
	scsi_write_byte(SIEN,(unsigned char)scsi_int_mask);
	scsi_write_byte(SIEN+1,(unsigned char)(scsi_int_mask>>8));
	scsi_write_byte(DIEN,script_int_mask);
}

void scsi_write_dsp(unsigned long start)
{
	unsigned long val;
#ifdef SCSI_SINGLE_STEP
	unsigned char t;
#endif
	val = start;
	out32r(scsi_mem_addr + DSP,start);
#ifdef SCSI_SINGLE_STEP
	t=scsi_read_byte(DCNTL);
  t|=STD;
	scsi_write_byte(DCNTL,t);
#endif
}

/* only used for debug purposes */
void scsi_print_script(void)
{
	printf("script_select @         0x%08lX\n",(unsigned long)&script_select[0]);
	printf("script_msgout @         0x%08lX\n",(unsigned long)&script_msgout[0]);
	printf("script_msgin @          0x%08lX\n",(unsigned long)&script_msgin[0]);
	printf("script_msgext @         0x%08lX\n",(unsigned long)&script_msg_ext[0]);
	printf("script_cmd @            0x%08lX\n",(unsigned long)&script_cmd[0]);
	printf("script_data_in @        0x%08lX\n",(unsigned long)&script_data_in[0]);
	printf("script_data_out @       0x%08lX\n",(unsigned long)&script_data_out[0]);
	printf("script_status @         0x%08lX\n",(unsigned long)&script_status[0]);
	printf("script_complete @       0x%08lX\n",(unsigned long)&script_complete[0]);
	printf("script_error @          0x%08lX\n",(unsigned long)&script_error[0]);
}



void scsi_set_script(ccb *pccb)
{
	int busdevfunc = pccb->priv;
	int i;
	i=0;
	script_select[i++]=swap_script(SCR_REG_REG(GPREG, SCR_AND, 0xfe));
	script_select[i++]=0; /* LED ON */
	script_select[i++]=swap_script(SCR_CLR(SCR_TRG)); /* select initiator mode */
	script_select[i++]=0;
	/* script_select[i++]=swap_script(SCR_SEL_ABS_ATN | pccb->target << 16); */
	script_select[i++]=swap_script(SCR_SEL_ABS | pccb->target << 16);
	script_select[i++]=swap_script(phys_to_bus(&script_cmd[4])); /* error handling */
	script_select[i++]=swap_script(SCR_JUMP); /* next section */
	/*	script_select[i++]=swap_script((unsigned long)&script_msgout[0]); */ /* message out */
	script_select[i++]=swap_script(phys_to_bus(&script_cmd[0])); /* command out */

#ifdef SCSI_SINGLE_STEP
	start_script_select=(unsigned long)&script_select[0];
	len_script_select=i*4;
#endif

	i=0;
	script_msgout[i++]=swap_script(SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)));
	script_msgout[i++]=SIR_SEL_ATN_NO_MSG_OUT;
	script_msgout[i++]=swap_script(	SCR_MOVE_ABS(1) ^ SCR_MSG_OUT);
	script_msgout[i++]=swap_script(phys_to_bus(&pccb->msgout[0]));
	script_msgout[i++]=swap_script(SCR_JUMP ^ IFTRUE (WHEN (SCR_COMMAND))); /* if Command phase */
	script_msgout[i++]=swap_script(phys_to_bus(&script_cmd[0])); /* switch to command */
	script_msgout[i++]=swap_script(SCR_INT); /* interrupt if not */
	script_msgout[i++]=SIR_MSG_OUT_NO_CMD;

#ifdef SCSI_SINGLE_STEP
	start_script_msgout=(unsigned long)&script_msgout[0];
	len_script_msgout=i*4;
#endif
	i=0;
	script_cmd[i++]=swap_script(SCR_MOVE_ABS(pccb->cmdlen) ^ SCR_COMMAND);
	script_cmd[i++]=swap_script(phys_to_bus(&pccb->cmd[0]));
	script_cmd[i++]=swap_script(SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN))); /* message in ? */
	script_cmd[i++]=swap_script(phys_to_bus(&script_msgin[0]));
	script_cmd[i++]=swap_script(SCR_JUMP ^ IFTRUE (IF (SCR_DATA_OUT))); /* data out ? */
	script_cmd[i++]=swap_script(phys_to_bus(&script_data_out[0]));
	script_cmd[i++]=swap_script(SCR_JUMP ^ IFTRUE (IF (SCR_DATA_IN))); /* data in ? */
	script_cmd[i++]=swap_script(phys_to_bus(&script_data_in[0]));
	script_cmd[i++]=swap_script(SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)));  /* status ? */
	script_cmd[i++]=swap_script(phys_to_bus(&script_status[0]));
	script_cmd[i++]=swap_script(SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)));  /* command ? */
	script_cmd[i++]=swap_script(phys_to_bus(&script_cmd[0]));
	script_cmd[i++]=swap_script(SCR_JUMP ^ IFTRUE (IF (SCR_MSG_OUT)));  /* message out ? */
	script_cmd[i++]=swap_script(phys_to_bus(&script_msgout[0]));
	script_cmd[i++]=swap_script(SCR_JUMP ^ IFTRUE (IF (SCR_MSG_IN))); /* just for error handling message in ? */
	script_cmd[i++]=swap_script(phys_to_bus(&script_msgin[0]));
	script_cmd[i++]=swap_script(SCR_INT); /* interrupt if not */
	script_cmd[i++]=SIR_CMD_OUT_ILL_PH;
#ifdef SCSI_SINGLE_STEP
	start_script_cmd=(unsigned long)&script_cmd[0];
	len_script_cmd=i*4;
#endif
	i=0;
	script_data_out[i++]=swap_script(SCR_MOVE_ABS(pccb->datalen)^ SCR_DATA_OUT); /* move */
	script_data_out[i++]=swap_script(phys_to_bus(pccb->pdata)); /* pointer to buffer */
	script_data_out[i++]=swap_script(SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)));
	script_data_out[i++]=swap_script(phys_to_bus(&script_status[0]));
	script_data_out[i++]=swap_script(SCR_INT);
	script_data_out[i++]=SIR_DATA_OUT_ERR;

#ifdef SCSI_SINGLE_STEP
	start_script_data_out=(unsigned long)&script_data_out[0];
	len_script_data_out=i*4;
#endif
	i=0;
	script_data_in[i++]=swap_script(SCR_MOVE_ABS(pccb->datalen)^ SCR_DATA_IN); /* move  */
	script_data_in[i++]=swap_script(phys_to_bus(pccb->pdata)); /* pointer to buffer */
	script_data_in[i++]=swap_script(SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)));
	script_data_in[i++]=swap_script(phys_to_bus(&script_status[0]));
	script_data_in[i++]=swap_script(SCR_INT);
	script_data_in[i++]=SIR_DATA_IN_ERR;
#ifdef SCSI_SINGLE_STEP
	start_script_data_in=(unsigned long)&script_data_in[0];
	len_script_data_in=i*4;
#endif
	i=0;
	script_msgin[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN);
	script_msgin[i++]=swap_script(phys_to_bus(&pccb->msgin[0]));
	script_msgin[i++]=swap_script(SCR_JUMP ^ IFTRUE (DATA (M_COMPLETE)));
	script_msgin[i++]=swap_script(phys_to_bus(&script_complete[0]));
	script_msgin[i++]=swap_script(SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)));
	script_msgin[i++]=swap_script(phys_to_bus(&script_complete[0]));
	script_msgin[i++]=swap_script(SCR_JUMP ^ IFTRUE (DATA (M_SAVE_DP)));
	script_msgin[i++]=swap_script(phys_to_bus(&script_complete[0]));
	script_msgin[i++]=swap_script(SCR_JUMP ^ IFTRUE (DATA (M_RESTORE_DP)));
	script_msgin[i++]=swap_script(phys_to_bus(&script_complete[0]));
	script_msgin[i++]=swap_script(SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)));
	script_msgin[i++]=swap_script(phys_to_bus(&script_msg_ext[0]));
	script_msgin[i++]=swap_script(SCR_INT);
	script_msgin[i++]=SIR_MSG_RECEIVED;
#ifdef SCSI_SINGLE_STEP
	start_script_msgin=(unsigned long)&script_msgin[0];
	len_script_msgin=i*4;
#endif
	i=0;
	script_msg_ext[i++]=swap_script(SCR_CLR (SCR_ACK)); /* clear ACK */
	script_msg_ext[i++]=0;
	script_msg_ext[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN); /* assuming this is the msg length */
	script_msg_ext[i++]=swap_script(phys_to_bus(&pccb->msgin[1]));
	script_msg_ext[i++]=swap_script(SCR_JUMP ^ IFFALSE (IF (SCR_MSG_IN)));
	script_msg_ext[i++]=swap_script(phys_to_bus(&script_complete[0])); /* no more bytes */
	script_msg_ext[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN); /* next */
	script_msg_ext[i++]=swap_script(phys_to_bus(&pccb->msgin[2]));
	script_msg_ext[i++]=swap_script(SCR_JUMP ^ IFFALSE (IF (SCR_MSG_IN)));
	script_msg_ext[i++]=swap_script(phys_to_bus(&script_complete[0])); /* no more bytes */
	script_msg_ext[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN); /* next */
	script_msg_ext[i++]=swap_script(phys_to_bus(&pccb->msgin[3]));
	script_msg_ext[i++]=swap_script(SCR_JUMP ^ IFFALSE (IF (SCR_MSG_IN)));
	script_msg_ext[i++]=swap_script(phys_to_bus(&script_complete[0])); /* no more bytes */
	script_msg_ext[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN); /* next */
	script_msg_ext[i++]=swap_script(phys_to_bus(&pccb->msgin[4]));
	script_msg_ext[i++]=swap_script(SCR_JUMP ^ IFFALSE (IF (SCR_MSG_IN)));
	script_msg_ext[i++]=swap_script(phys_to_bus(&script_complete[0])); /* no more bytes */
	script_msg_ext[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN); /* next */
	script_msg_ext[i++]=swap_script(phys_to_bus(&pccb->msgin[5]));
	script_msg_ext[i++]=swap_script(SCR_JUMP ^ IFFALSE (IF (SCR_MSG_IN)));
	script_msg_ext[i++]=swap_script(phys_to_bus(&script_complete[0])); /* no more bytes */
	script_msg_ext[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN); /* next */
	script_msg_ext[i++]=swap_script(phys_to_bus(&pccb->msgin[6]));
	script_msg_ext[i++]=swap_script(SCR_JUMP ^ IFFALSE (IF (SCR_MSG_IN)));
	script_msg_ext[i++]=swap_script(phys_to_bus(&script_complete[0])); /* no more bytes */
	script_msg_ext[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_MSG_IN); /* next */
	script_msg_ext[i++]=swap_script(phys_to_bus(&pccb->msgin[7]));
	script_msg_ext[i++]=swap_script(SCR_JUMP ^ IFFALSE (IF (SCR_MSG_IN)));
	script_msg_ext[i++]=swap_script(phys_to_bus(&script_complete[0])); /* no more bytes */
	script_msg_ext[i++]=swap_script(SCR_INT);
	script_msg_ext[i++]=SIR_MSG_OVER7;
#ifdef SCSI_SINGLE_STEP
	start_script_msg_ext=(unsigned long)&script_msg_ext[0];
	len_script_msg_ext=i*4;
#endif
	i=0;
	script_status[i++]=swap_script(SCR_MOVE_ABS (1) ^ SCR_STATUS);
	script_status[i++]=swap_script(phys_to_bus(&pccb->status));
	script_status[i++]=swap_script(SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)));
	script_status[i++]=swap_script(phys_to_bus(&script_msgin[0]));
	script_status[i++]=swap_script(SCR_INT);
	script_status[i++]=SIR_STATUS_ILL_PH;
#ifdef SCSI_SINGLE_STEP
	start_script_status=(unsigned long)&script_status[0];
	len_script_status=i*4;
#endif
	i=0;
	script_complete[i++]=swap_script(SCR_REG_REG (SCNTL2, SCR_AND, 0x7f));
	script_complete[i++]=0;
	script_complete[i++]=swap_script(SCR_CLR (SCR_ACK|SCR_ATN));
	script_complete[i++]=0;
	script_complete[i++]=swap_script(SCR_WAIT_DISC);
	script_complete[i++]=0;
	script_complete[i++]=swap_script(SCR_REG_REG(GPREG, SCR_OR, 0x01));
	script_complete[i++]=0; /* LED OFF */
	script_complete[i++]=swap_script(SCR_INT);
	script_complete[i++]=SIR_COMPLETE;
#ifdef SCSI_SINGLE_STEP
	start_script_complete=(unsigned long)&script_complete[0];
	len_script_complete=i*4;
#endif
	i=0;
	script_error[i++]=swap_script(SCR_INT); /* interrupt if error */
	script_error[i++]=SIR_SCRIPT_ERROR;
#ifdef SCSI_SINGLE_STEP
	start_script_error=(unsigned long)&script_error[0];
	len_script_error=i*4;
#endif
	i=0;
	script_reselection[i++]=swap_script(SCR_CLR (SCR_TRG)); /* target status */
	script_reselection[i++]=0;
	script_reselection[i++]=swap_script(SCR_WAIT_RESEL);
	script_reselection[i++]=swap_script(phys_to_bus(&script_select[0])); /* len = 4 */
#ifdef SCSI_SINGLE_STEP
	start_script_reselection=(unsigned long)&script_reselection[0];
	len_script_reselection=i*4;
#endif
}



void scsi_issue(ccb *pccb)
{
	int busdevfunc = pccb->priv;
	int i;
	unsigned short sstat;
 	int retrycnt;  /* retry counter */
	for(i=0;i<3;i++)
		int_stat[i]=0; /* delete all int status */
	/* struct pccb must be set-up correctly */
	retrycnt=0;
	PRINTF("ID %d issue cmd %02X\n",pccb->target,pccb->cmd[0]);
	pccb->trans_bytes=0; /* no bytes transfered yet */
	scsi_set_script(pccb); /* fill in SCRIPT		*/
	scsi_int_mask=STO | UDC | MA; /* | CMP; / * Interrupts which are enabled */
	script_int_mask=0xff; /* enable all Ints */
	scsi_int_enable();
	scsi_write_dsp(phys_to_bus(&script_select[0])); /* start script */
	/* now we have to wait for IRQs */
retry:
	/*
	 * This version of the driver is _not_ interrupt driven,
	 * but polls the chip's interrupt registers (ISTAT, DSTAT).
	 */
	while(int_stat[0]==0)
		handle_scsi_int();

	if(int_stat[0]==SIR_COMPLETE) {
		if(pccb->msgin[0]==M_DISCONNECT) {
			PRINTF("Wait for reselection\n");
			for(i=0;i<3;i++)
				int_stat[i]=0; /* delete all int status */
			scsi_write_dsp(phys_to_bus(&script_reselection[0])); /* start reselection script */
			goto retry;
		}
		pccb->contr_stat=SIR_COMPLETE;
		return;
	}
	if((int_stat[0] & SCSI_INT_STATE)==SCSI_INT_STATE) { /* scsi interrupt */
		sstat=(unsigned short)int_stat[0];
		if((sstat & STO)==STO) { /* selection timeout */
			pccb->contr_stat=SCSI_SEL_TIME_OUT;
			scsi_write_byte(GPREG,0x01);
			PRINTF("ID: %X Selection Timeout\n",pccb->target);
			return;
		}
		if((sstat & UDC)==UDC) { /* unexpected disconnect */
			pccb->contr_stat=SCSI_UNEXP_DIS;
			scsi_write_byte(GPREG,0x01);
			PRINTF("ID: %X Unexpected Disconnect\n",pccb->target);
			return;
		}
		if((sstat & RSL)==RSL) { /* reselection */
			pccb->contr_stat=SCSI_UNEXP_DIS;
			scsi_write_byte(GPREG,0x01);
			PRINTF("ID: %X Unexpected Disconnect\n",pccb->target);
			return;
		}
		if(((sstat & MA)==MA)||((sstat & HTH)==HTH)) { /* phase missmatch */
			if(retrycnt<SCSI_MAX_RETRY) {
				pccb->trans_bytes=pccb->datalen -
					((unsigned long)scsi_read_byte(DBC) |
					((unsigned long)scsi_read_byte(DBC+1)<<8) |
					((unsigned long)scsi_read_byte(DBC+2)<<16));
				for(i=0;i<3;i++)
					int_stat[i]=0; /* delete all int status */
				retrycnt++;
				PRINTF("ID: %X Phase Missmatch Retry %d Phase %02X transfered %lx\n",
						pccb->target,retrycnt,scsi_read_byte(SBCL),pccb->trans_bytes);
				scsi_write_dsp(phys_to_bus(&script_cmd[4])); /* start retry script */
				goto retry;
			}
			if((sstat & MA)==MA)
				pccb->contr_stat=SCSI_MA_TIME_OUT;
			else
				pccb->contr_stat=SCSI_HNS_TIME_OUT;
			PRINTF("Phase Missmatch stat %lx\n",pccb->contr_stat);
			return;
		} /* no phase int */
/*		if((sstat & CMP)==CMP) {
			pccb->contr_stat=SIR_COMPLETE;
			return;
		}
*/
		PRINTF("SCSI INT %lX\n",int_stat[0]);
		pccb->contr_stat=int_stat[0];
		return;
	} /* end scsi int */
	PRINTF("SCRIPT INT %lX phase %02X\n",int_stat[0],scsi_read_byte(SBCL));
	pccb->contr_stat=int_stat[0];
	return;
}

int scsi_exec(ccb *pccb)
{
	unsigned char tmpcmd[16],tmpstat;
	int i,retrycnt,t;
	unsigned long transbytes,datalen;
	unsigned char *tmpptr;
	retrycnt=0;
retry:
	scsi_issue(pccb);
	if(pccb->contr_stat!=SIR_COMPLETE)
		return FALSE;
	if(pccb->status==S_GOOD)
		return TRUE;
	if(pccb->status==S_CHECK_COND) { /* check condition */
		for(i=0;i<16;i++)
			tmpcmd[i]=pccb->cmd[i];
		pccb->cmd[0]=SCSI_REQ_SENSE;
		pccb->cmd[1]=pccb->lun<<5;
		pccb->cmd[2]=0;
		pccb->cmd[3]=0;
		pccb->cmd[4]=14;
		pccb->cmd[5]=0;
		pccb->cmdlen=6;
		pccb->msgout[0]=SCSI_IDENTIFY;
		transbytes=pccb->trans_bytes;
		tmpptr=pccb->pdata;
		pccb->pdata=&pccb->sense_buf[0];
		datalen=pccb->datalen;
		pccb->datalen=14;
		tmpstat=pccb->status;
		scsi_issue(pccb);
		for(i=0;i<16;i++)
			pccb->cmd[i]=tmpcmd[i];
		pccb->trans_bytes=transbytes;
		pccb->pdata=tmpptr;
		pccb->datalen=datalen;
		pccb->status=tmpstat;
		PRINTF("Request_sense sense key %x ASC %x ASCQ %x\n",pccb->sense_buf[2]&0x0f,
			pccb->sense_buf[12],pccb->sense_buf[13]);
		switch(pccb->sense_buf[2]&0xf) {
			case SENSE_NO_SENSE:
			case SENSE_RECOVERED_ERROR:
				/* seems to be ok */
				return TRUE;
				break;
			case SENSE_NOT_READY:
				if((pccb->sense_buf[12]!=0x04)||(pccb->sense_buf[13]!=0x01)) {
					/* if device is not in process of becoming ready */
					return FALSE;
					break;
				} /* else fall through */
			case SENSE_UNIT_ATTENTION:
				if(retrycnt<SCSI_MAX_RETRY_NOT_READY) {
					PRINTF("Target %d not ready, retry %d\n",pccb->target,retrycnt);
					for(t=0;t<SCSI_NOT_READY_TIME_OUT;t++)
						udelay(1000); /* 1sec wait */
					retrycnt++;
					goto retry;
				}
				PRINTF("Target %d not ready, %d retried\n",pccb->target,retrycnt);
				return FALSE;
			default:
				return FALSE;
		}
	}
	PRINTF("Status = %X\n",pccb->status);
	return FALSE;
}




void scsi_chip_init(void)
{
	/* first we issue a soft reset */
	scsi_write_byte(ISTAT,SRST);
	udelay(1000);
	scsi_write_byte(ISTAT,0);
	/* setup chip */
	scsi_write_byte(SCNTL0,0xC0); /* full arbitration no start, no message, parity disabled, master */
	scsi_write_byte(SCNTL1,0x00);
	scsi_write_byte(SCNTL2,0x00);
#ifndef CFG_SCSI_SYM53C8XX_CCF    /* config value for none 40 mhz clocks */
	scsi_write_byte(SCNTL3,0x13); /* synchronous clock 40/4=10MHz, asynchronous 40MHz */
#else
	scsi_write_byte(SCNTL3,CFG_SCSI_SYM53C8XX_CCF); /* config value for none 40 mhz clocks */
#endif
	scsi_write_byte(SCID,0x47); /* ID=7, enable reselection */
	scsi_write_byte(SXFER,0x00); /* synchronous transfer period 10MHz, asynchronous */
	scsi_write_byte(SDID,0x00);  /* targed SCSI ID = 0 */
	scsi_int_mask=0x0000; /* no Interrupt is enabled */
	script_int_mask=0x00;
	scsi_int_enable();
	scsi_write_byte(GPREG,0x01); /* GPIO0 is LED (off) */
	scsi_write_byte(GPCNTL,0x0E); /* GPIO0 is Output */
	scsi_write_byte(STIME0,0x08); /* handshake timer disabled, selection timeout 512msec */
	scsi_write_byte(RESPID,0x80); /* repond only to the own ID (reselection) */
	scsi_write_byte(STEST1,0x00); /* not isolated, SCLK is used */
	scsi_write_byte(STEST2,0x00); /* no Lowlevel Mode? */
	scsi_write_byte(STEST3,0x80); /* enable tolerANT */
	scsi_write_byte(CTEST3,0x04); /* clear FIFO */
	scsi_write_byte(CTEST4,0x00);
	scsi_write_byte(CTEST5,0x00);
#ifdef SCSI_SINGLE_STEP
/*	scsi_write_byte(DCNTL,IRQM | SSM);	*/
	scsi_write_byte(DCNTL,IRQD | SSM);
	scsi_write_byte(DMODE,MAN);
#else
/*	scsi_write_byte(DCNTL,IRQM);	*/
	scsi_write_byte(DCNTL,IRQD);
	scsi_write_byte(DMODE,0x00);
#endif
}
#endif /* (CONFIG_COMMANDS & CFG_CMD_SCSI) */


#endif /* CONFIG_SCSI_SYM53C8XX */
