/*
 * (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>

#include <command.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 defined(CONFIG_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 = CONFIG_SYS_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)
{
#ifdef SCSI_SINGLE_STEP
	unsigned char t;
#endif
	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 CONFIG_SYS_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,CONFIG_SYS_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
