Commit 0e1cb392 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Linus Torvalds

[PATCH] Sun-3 VME support

Add Sun-3 VME support (by Sam Creasey):
  - Added VME version of the Sun-3 NCR5380 scsi driver.
  - Modified the Sun-3 dvma routines to support VME.
  - Added sun3_map_test() -- uses the ex_table to trap faults on VME mappings
    in order to determine if a card is present.  This seems a little hackish to
    be, but:
      1) All changes are entirely within Sun3-only code paths,
      2) netbsd, sunos, and mach all use this mechanism for VME probes anyway.
parent 9d0f75b8
......@@ -1125,8 +1125,8 @@ config SUN3_SCSI
depends on SUN3 && SCSI
help
This option will enable support for the OBIO (onboard io) NCR5380
SCSI controller found in the Sun 3/50 and 3/60. Note that this
driver does not provide support for VME SCSI boards.
SCSI controller found in the Sun 3/50 and 3/60, as well as for
"Sun3" type VME scsi controllers also based on the NCR5380.
General Linux information on the Sun 3 series (now discontinued)
is at <http://www.angelfire.com/ca2/tech68k/sun3.html>.
......
......@@ -117,3 +117,40 @@ void iounmap(void *addr)
{
vfree((void *)(PAGE_MASK & (unsigned long)addr));
}
/* sun3_map_test(addr, val) -- Reads a byte from addr, storing to val,
* trapping the potential read fault. Returns 0 if the access faulted,
* 1 on success.
*
* This function is primarily used to check addresses on the VME bus.
*
* Mucking with the page fault handler seems a little hackish to me, but
* SunOS, NetBSD, and Mach all implemented this check in such a manner,
* so I figure we're allowed.
*/
int sun3_map_test(unsigned long addr, char *val)
{
int ret = 0;
__asm__ __volatile__
(".globl _sun3_map_test_start\n"
"_sun3_map_test_start:\n"
"1: moveb (%2), (%0)\n"
" moveq #1, %1\n"
"2:\n"
".section .fixup,\"ax\"\n"
".even\n"
"3: moveq #0, %1\n"
" jmp 2b\n"
".previous\n"
".section __ex_table,\"a\"\n"
".align 4\n"
".long 1b,3b\n"
".previous\n"
".globl _sun3_map_test_end\n"
"_sun3_map_test_end:\n"
: "=a"(val), "=r"(ret)
: "a"(addr));
return ret;
}
......@@ -240,8 +240,14 @@ inline unsigned long dvma_map_align(unsigned long kaddr, int len, int align)
void dvma_unmap(void *baddr)
{
free_baddr((unsigned long)baddr);
unsigned long addr;
addr = (unsigned long)baddr;
/* check if this is a vme mapping */
if(!(addr & 0x00f00000))
addr |= 0xf00000;
free_baddr(addr);
return;
......
......@@ -42,7 +42,7 @@ obj-$(CONFIG_OKTAGON_SCSI) += NCR53C9x.o oktagon_esp.o oktagon_io.o
obj-$(CONFIG_ATARI_SCSI) += atari_scsi.o
obj-$(CONFIG_MAC_SCSI) += mac_scsi.o
obj-$(CONFIG_SCSI_MAC_ESP) += mac_esp.o NCR53C9x.o
obj-$(CONFIG_SUN3_SCSI) += sun3_scsi.o
obj-$(CONFIG_SUN3_SCSI) += sun3_scsi.o sun3_scsi_vme.o
obj-$(CONFIG_MVME16x_SCSI) += mvme16x.o 53c7xx.o
obj-$(CONFIG_BVME6000_SCSI) += bvme6000.o 53c7xx.o
obj-$(CONFIG_SCSI_SIM710) += sim710.o
......
......@@ -617,11 +617,11 @@ static void NCR5380_print_phase(struct Scsi_Host *instance)
status = NCR5380_read(STATUS_REG);
if (!(status & SR_REQ))
printk(KERN_DEBUG "scsi%d: REQ not asserted, phase unknown.\n", HOSTNO);
printk("scsi%d: REQ not asserted, phase unknown.\n", HOSTNO);
else {
for (i = 0; (phases[i].value != PHASE_UNKNOWN) &&
(phases[i].value != (status & PHASE_MASK)); ++i);
printk(KERN_DEBUG "scsi%d: phase %s\n", HOSTNO, phases[i].name);
printk("scsi%d: phase %s\n", HOSTNO, phases[i].name);
}
}
......@@ -755,11 +755,8 @@ static void NCR5380_print_status (struct Scsi_Host *instance)
static
char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length);
#ifndef NCR5380_proc_info
static
#endif
int NCR5380_proc_info (char *buffer, char **start, off_t offset,
int length, int hostno, int inout)
static int NCR5380_proc_info (char *buffer, char **start, off_t offset,
int length, int hostno, int inout)
{
char *pos = buffer;
struct Scsi_Host *instance;
......@@ -914,10 +911,7 @@ static void __init NCR5380_init (struct Scsi_Host *instance, int flags)
*/
/* Only make static if a wrapper function is used */
#ifndef NCR5380_queue_command
static
#endif
int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
{
SETUP_HOSTDATA(cmd->host);
Scsi_Cmnd *tmp;
......@@ -1319,11 +1313,14 @@ static void NCR5380_intr (int irq, void *dev_id, struct pt_regs *regs)
{
/* MS: Ignore unknown phase mismatch interrupts (caused by EOP interrupt) */
if (basr & BASR_PHASE_MATCH)
printk(KERN_NOTICE "scsi%d: unknown interrupt, "
INT_PRINTK("scsi%d: unknown interrupt, "
"BASR 0x%x, MR 0x%x, SR 0x%x\n",
HOSTNO, basr, NCR5380_read(MODE_REG),
NCR5380_read(STATUS_REG));
(void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
#ifdef SUN3_SCSI_VME
dregs->csr |= CSR_DMA_ENABLE;
#endif
}
} /* if !(SELECTION || PARITY) */
} /* BASR & IRQ */
......@@ -1333,6 +1330,9 @@ static void NCR5380_intr (int irq, void *dev_id, struct pt_regs *regs)
"BASR 0x%X, MR 0x%X, SR 0x%x\n", HOSTNO, basr,
NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG));
(void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
#ifdef SUN3_SCSI_VME
dregs->csr |= CSR_DMA_ENABLE;
#endif
}
if (!done) {
......@@ -1695,7 +1695,9 @@ static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
#ifndef SUPPORT_TAGS
hostdata->busy[cmd->target] |= (1 << cmd->lun);
#endif
#ifdef SUN3_SCSI_VME
dregs->csr |= CSR_INTR;
#endif
initialize_SCp(cmd);
......@@ -1922,19 +1924,18 @@ static int NCR5380_transfer_dma( struct Scsi_Host *instance,
printk("scsi%d: transfer_dma without setup!\n", HOSTNO);
BUG();
}
hostdata->dma_len = c;
DMA_PRINTK("scsi%d: initializing DMA for %s, %d bytes %s %p\n",
HOSTNO, (p & SR_IO) ? "reading" : "writing",
c, (p & SR_IO) ? "to" : "from", d);
c, (p & SR_IO) ? "to" : "from", *data);
/* netbsd turns off ints here, why not be safe and do it too */
save_flags(flags);
cli();
/* send start chain */
sun3_udc_write(UDC_CHN_START, UDC_CSR);
sun3scsi_dma_start(c, *data);
if (p & SR_IO) {
NCR5380_write(TARGET_COMMAND_REG, 1);
......@@ -1950,6 +1951,10 @@ static int NCR5380_transfer_dma( struct Scsi_Host *instance,
NCR5380_write(START_DMA_SEND_REG, 0);
}
#ifdef SUN3_SCSI_VME
dregs->csr |= CSR_DMA_ENABLE;
#endif
restore_flags(flags);
sun3_dma_active = 1;
......@@ -1988,6 +1993,10 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
unsigned char phase, tmp, extended_msg[10], old_phase=0xff;
Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
#ifdef SUN3_SCSI_VME
dregs->csr |= CSR_INTR;
#endif
while (1) {
tmp = NCR5380_read(STATUS_REG);
/* We only have a valid SCSI phase when REQ is asserted */
......@@ -2020,6 +2029,9 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
sun3_dma_setup_done = cmd;
}
}
#endif
#ifdef SUN3_SCSI_VME
dregs->csr |= CSR_INTR;
#endif
}
......@@ -2136,7 +2148,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
NCR5380_write(SELECT_ENABLE_REG, 0); /* disable reselects */
NCR5380_transfer_pio(instance, &phase, &len, &data);
cmd->SCp.Message = tmp;
switch (tmp) {
/*
* Linking lets us reduce the time required to get the
......@@ -2342,6 +2354,9 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
/* Wait for bus free to avoid nasty timeouts */
while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
barrier();
#ifdef SUN3_SCSI_VME
dregs->csr |= CSR_DMA_ENABLE;
#endif
return;
/*
* The SCSI data pointer is *IMPLICITLY* saved on a disconnect
......@@ -2677,10 +2692,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
* called where the loop started in NCR5380_main().
*/
#ifndef NCR5380_abort
static
#endif
int NCR5380_abort (Scsi_Cmnd *cmd)
static int NCR5380_abort (Scsi_Cmnd *cmd)
{
struct Scsi_Host *instance = cmd->host;
SETUP_HOSTDATA(instance);
......@@ -2874,7 +2886,7 @@ int NCR5380_abort (Scsi_Cmnd *cmd)
*
*/
int NCR5380_reset( Scsi_Cmnd *cmd, unsigned int reset_flags)
static int NCR5380_reset( Scsi_Cmnd *cmd, unsigned int reset_flags)
{
SETUP_HOSTDATA(cmd->host);
int i;
......
......@@ -525,6 +525,14 @@ static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmn
return 0;
}
static inline int sun3scsi_dma_start(unsigned long count, unsigned char *data)
{
sun3_udc_write(UDC_CHN_START, UDC_CSR);
return 0;
}
/* clean up after our dma is done */
static int sun3scsi_dma_finish(int write_flag)
{
......
......@@ -36,6 +36,11 @@
#ifndef SUN3_NCR5380_H
#define SUN3_NCR5380_H
#ifndef NULL
#define NULL 0
#endif
#define SUN3SCSI_PUBLIC_RELEASE 1
/*
......@@ -45,17 +50,19 @@
#define IRQ_SUN3_SCSI 2
#define IOBASE_SUN3_SCSI 0x00140000
int sun3scsi_abort (Scsi_Cmnd *);
int sun3scsi_detect (Scsi_Host_Template *);
int sun3scsi_release (struct Scsi_Host *);
const char *sun3scsi_info (struct Scsi_Host *);
int sun3scsi_reset(Scsi_Cmnd *, unsigned int);
int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
int sun3scsi_proc_info (char *buffer, char **start, off_t offset,
int length, int hostno, int inout);
#define IOBASE_SUN3_VMESCSI 0xff200000
#ifndef NULL
#define NULL 0
static int sun3scsi_abort (Scsi_Cmnd *);
static int sun3scsi_detect (Scsi_Host_Template *);
static const char *sun3scsi_info (struct Scsi_Host *);
static int sun3scsi_reset(Scsi_Cmnd *, unsigned int);
static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
static int sun3scsi_proc_info (char *buffer, char **start, off_t offset,
int length, int hostno, int inout);
#ifdef MODULE
static int sun3scsi_release (struct Scsi_Host *);
#else
#define sun3scsi_release NULL
#endif
#ifndef CMD_PER_LUN
......@@ -70,26 +77,36 @@ int sun3scsi_proc_info (char *buffer, char **start, off_t offset,
#define SG_TABLESIZE SG_NONE
#endif
#ifndef MAX_TAGS
#define MAX_TAGS 32
#endif
#ifndef USE_TAGGED_QUEUING
#define USE_TAGGED_QUEUING 0
#define USE_TAGGED_QUEUING 1
#endif
#include <scsi/scsicam.h>
#ifdef SUN3_SCSI_VME
#define SUN3_SCSI_NAME "Sun3 NCR5380 VME SCSI"
#else
#define SUN3_SCSI_NAME "Sun3 NCR5380 SCSI"
#endif
#define SUN3_NCR5380 { \
name: "Sun3 NCR5380 SCSI", \
detect: sun3scsi_detect, \
release: sun3scsi_release, /* Release */ \
info: sun3scsi_info, \
queuecommand: sun3scsi_queue_command, \
abort: sun3scsi_abort, \
reset: sun3scsi_reset, \
can_queue: CAN_QUEUE, /* can queue */ \
this_id: 7, /* id */ \
sg_tablesize: SG_ALL, /* sg_tablesize */ \
cmd_per_lun: CMD_PER_LUN, /* cmd per lun */ \
unchecked_isa_dma: 0, /* unchecked_isa_dma */ \
use_clustering: DISABLE_CLUSTERING \
.name = SUN3_SCSI_NAME, \
.detect = sun3scsi_detect, \
.release = sun3scsi_release, /* Release */ \
.info = sun3scsi_info, \
.queuecommand = sun3scsi_queue_command, \
.abort = sun3scsi_abort, \
.reset = sun3scsi_reset, \
.can_queue = CAN_QUEUE, /* can queue */ \
.this_id = 7, /* id */ \
.sg_tablesize = SG_TABLESIZE, /* sg_tablesize */ \
.cmd_per_lun = CMD_PER_LUN, /* cmd per lun */ \
.unchecked_isa_dma = 0, /* unchecked_isa_dma */ \
.use_clustering = DISABLE_CLUSTERING \
}
#ifndef HOSTS_C
......@@ -124,13 +141,20 @@ use_clustering: DISABLE_CLUSTERING \
/* additional registers - mainly DMA control regs */
/* these start at regbase + 8 -- directly after the NCR regs */
struct sun3_dma_regs {
unsigned short vmeregs[4]; /* unimpl vme stuff */
unsigned short udc_data; /* udc dma data reg */
unsigned short udc_addr; /* uda dma addr reg */
unsigned short dma_addr_hi; /* vme only */
unsigned short dma_addr_lo; /* vme only */
unsigned short dma_count_hi; /* vme only */
unsigned short dma_count_lo; /* vme only */
unsigned short udc_data; /* udc dma data reg (obio only) */
unsigned short udc_addr; /* uda dma addr reg (obio only) */
unsigned short fifo_data; /* fifo data reg, holds extra byte on
odd dma reads */
unsigned short fifo_count;
unsigned short csr; /* control/status reg */
unsigned short bpack_hi; /* vme only */
unsigned short bpack_lo; /* vme only */
unsigned short ivect; /* vme only */
unsigned short fifo_count_hi; /* vme only */
};
/* ucd chip specific regs - live in dvma space */
......@@ -179,11 +203,21 @@ struct sun3_udc_regs {
#define CSR_SDB_INT 0x200 /* sbc interrupt pending */
#define CSR_DMA_INT 0x100 /* dma interrupt pending */
#define CSR_LEFT 0xc0
#define CSR_LEFT_3 0xc0
#define CSR_LEFT_2 0x80
#define CSR_LEFT_1 0x40
#define CSR_PACK_ENABLE 0x20
#define CSR_DMA_ENABLE 0x10
#define CSR_SEND 0x8 /* 1 = send 0 = recv */
#define CSR_FIFO 0x2 /* reset fifo */
#define CSR_INTR 0x4 /* interrupt enable */
#define CSR_SCSI 0x1
#define VME_DATA24 0x3d00
// debugging printk's, taken from atari_scsi.h
/* Debugging printk definitions:
*
......@@ -365,8 +399,6 @@ struct sun3_udc_regs {
#define NCR_PRINT_STATUS(mask) \
((NDEBUG & (mask)) ? NCR5380_print_status(instance) : (void)0)
#define NDEBUG_ANY 0xffffffff
#endif /* ndef HOSTS_C */
......
This diff is collapsed.
......@@ -22,7 +22,8 @@ extern int dvma_map_iommu(unsigned long kaddr, unsigned long baddr,
#define dvma_malloc(x) dvma_malloc_align(x, 0)
#define dvma_map(x, y) dvma_map_align(x, y, 0)
#define dvma_map_vme(x, y) (dvma_map(x, y) & 0xfffff)
#define dvma_map_align_vme(x, y, z) (dvma_map_align (x, y, z) & 0xfffff)
extern unsigned long dvma_map_align(unsigned long kaddr, int len,
int align);
extern void *dvma_malloc_align(unsigned long len, unsigned long align);
......@@ -52,6 +53,8 @@ extern void dvma_free(void *vaddr);
/* virt <-> phys conversions */
#define dvma_vtop(x) ((unsigned long)(x) & 0xffffff)
#define dvma_ptov(x) ((unsigned long)(x) | 0xf000000)
#define dvma_vtovme(x) ((unsigned long)(x) & 0x00fffff)
#define dvma_vmetov(x) ((unsigned long)(x) | 0xff00000)
#define dvma_vtob(x) dvma_vtop(x)
#define dvma_btov(x) dvma_ptov(x)
......
......@@ -39,5 +39,11 @@ extern int show_sun3_interrupts(struct seq_file *, void *);
extern void sun3_process_int(int, struct pt_regs *);
extern volatile unsigned char* sun3_intreg;
/* master list of VME vectors -- don't fuck with this */
#define SUN3_VEC_FLOPPY 0x40
#define SUN3_VEC_VMESCSI0 0x40
#define SUN3_VEC_VMESCSI1 0x41
#define SUN3_VEC_CG 0xA8
#endif /* SUN3INTS_H */
......@@ -164,6 +164,7 @@ extern __inline__ void sun3_put_context(unsigned char c)
extern void *sun3_ioremap(unsigned long phys, unsigned long size,
unsigned long type);
extern int sun3_map_test(unsigned long addr, char *val);
#endif /* !__ASSEMBLY__ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment