* (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
+ * SPDX-License-Identifier: GPL-2.0+
* partly derived from
* linux/drivers/scsi/sym53c8xx.c
*
#include <common.h>
-#ifdef CONFIG_SCSI_SYM53C8XX
-
#include <command.h>
#include <pci.h>
#include <asm/processor.h>
#endif
-static unsigned short scsi_int_mask; /* shadow register for SCSI related interrupts */
+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_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 */
/********************************************************************************
* reports SCSI errors to the user
*/
-void scsi_print_error(ccb *pccb)
+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 ("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 (" 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;
+ 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
+ * the base memory address is retrieved via the pci_read_config_dword
*/
void scsi_low_level_init(int busdevfunc)
{
if((stat & DIP)==DIP) { /* DMA Interrupt pending */
stat1=scsi_read_byte(DSTAT);
#ifdef SCSI_SINGLE_STEP
- if((stat1 & SSI)==SSI)
- {
+ 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);
{
unsigned char t;
int i;
- int end = CFG_SCSI_SPIN_UP_TIME*1000;
+ int end = CONFIG_SYS_SCSI_SPIN_UP_TIME*1000;
t=scsi_read_byte(SCNTL1);
scsi_write_byte(SCNTL1,(t | CRST));
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);
int busdevfunc = pccb->priv;
int i;
unsigned short sstat;
- int retrycnt; /* retry counter */
+ 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 */
retry:
scsi_issue(pccb);
if(pccb->contr_stat!=SIR_COMPLETE)
- return FALSE;
+ return false;
if(pccb->status==S_GOOD)
- return TRUE;
+ return true;
if(pccb->status==S_CHECK_COND) { /* check condition */
for(i=0;i<16;i++)
tmpcmd[i]=pccb->cmd[i];
pccb->msgout[0]=SCSI_IDENTIFY;
transbytes=pccb->trans_bytes;
tmpptr=pccb->pdata;
- pccb->pdata=&pccb->sense_buf[0];
+ pccb->pdata = &pccb->sense_buf[0];
datalen=pccb->datalen;
pccb->datalen=14;
tmpstat=pccb->status;
case SENSE_NO_SENSE:
case SENSE_RECOVERED_ERROR:
/* seems to be ok */
- return TRUE;
+ 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;
+ return false;
break;
} /* else fall through */
case SENSE_UNIT_ATTENTION:
goto retry;
}
PRINTF("Target %d not ready, %d retried\n",pccb->target,retrycnt);
- return FALSE;
+ return false;
default:
- return FALSE;
+ return false;
}
}
PRINTF("Status = %X\n",pccb->status);
- return FALSE;
+ return false;
}
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 */
+#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,CFG_SCSI_SYM53C8XX_CCF); /* config value for none 40 mhz clocks */
+ 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 */
#endif
}
#endif
-
-
-#endif /* CONFIG_SCSI_SYM53C8XX */