/*
|
/*
|
* linux/arch/arm/drivers/scsi/eesox.c
|
* linux/arch/arm/drivers/scsi/eesox.c
|
*
|
*
|
* Copyright (C) 1997-1998 Russell King
|
* Copyright (C) 1997-1998 Russell King
|
*
|
*
|
* This driver is based on experimentation. Hence, it may have made
|
* This driver is based on experimentation. Hence, it may have made
|
* assumptions about the particular card that I have available, and
|
* assumptions about the particular card that I have available, and
|
* may not be reliable!
|
* may not be reliable!
|
*
|
*
|
* Changelog:
|
* Changelog:
|
* 01-10-1997 RMK Created, READONLY version
|
* 01-10-1997 RMK Created, READONLY version
|
* 15-02-1998 RMK READ/WRITE version
|
* 15-02-1998 RMK READ/WRITE version
|
* added DMA support and hardware definitions
|
* added DMA support and hardware definitions
|
* 14-03-1998 RMK Updated DMA support
|
* 14-03-1998 RMK Updated DMA support
|
* Added terminator control
|
* Added terminator control
|
* 15-04-1998 RMK Only do PIO if FAS216 will allow it.
|
* 15-04-1998 RMK Only do PIO if FAS216 will allow it.
|
*/
|
*/
|
|
|
#include <linux/module.h>
|
#include <linux/module.h>
|
#include <linux/blk.h>
|
#include <linux/blk.h>
|
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
#include <linux/string.h>
|
#include <linux/string.h>
|
#include <linux/ioport.h>
|
#include <linux/ioport.h>
|
#include <linux/sched.h>
|
#include <linux/sched.h>
|
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
#include <linux/unistd.h>
|
#include <linux/unistd.h>
|
#include <linux/stat.h>
|
#include <linux/stat.h>
|
|
|
#include <asm/delay.h>
|
#include <asm/delay.h>
|
#include <asm/io.h>
|
#include <asm/io.h>
|
#include <asm/irq.h>
|
#include <asm/irq.h>
|
#include <asm/dma.h>
|
#include <asm/dma.h>
|
#include <asm/ecard.h>
|
#include <asm/ecard.h>
|
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
|
|
#include "sd.h"
|
#include "sd.h"
|
#include "hosts.h"
|
#include "hosts.h"
|
#include "eesox.h"
|
#include "eesox.h"
|
|
|
#define NO_IRQ 255
|
#define NO_IRQ 255
|
#define NO_DMA 255
|
#define NO_DMA 255
|
|
|
/* Configuration */
|
/* Configuration */
|
#define EESOX_XTALFREQ 40
|
#define EESOX_XTALFREQ 40
|
#define EESOX_ASYNC_PERIOD 200
|
#define EESOX_ASYNC_PERIOD 200
|
#define EESOX_SYNC_DEPTH 7
|
#define EESOX_SYNC_DEPTH 7
|
|
|
/*
|
/*
|
* List of devices that the driver will recognise
|
* List of devices that the driver will recognise
|
*/
|
*/
|
#define EESOXSCSI_LIST { MANU_EESOX, PROD_EESOX_SCSI2 }
|
#define EESOXSCSI_LIST { MANU_EESOX, PROD_EESOX_SCSI2 }
|
|
|
#define EESOX_FAS216_OFFSET 0xc00
|
#define EESOX_FAS216_OFFSET 0xc00
|
#define EESOX_FAS216_SHIFT 3
|
#define EESOX_FAS216_SHIFT 3
|
|
|
#define EESOX_STATUS 0xa00
|
#define EESOX_STATUS 0xa00
|
#define EESOX_STAT_INTR 0x01
|
#define EESOX_STAT_INTR 0x01
|
#define EESOX_STAT_DMA 0x02
|
#define EESOX_STAT_DMA 0x02
|
|
|
#define EESOX_CONTROL 0xa00
|
#define EESOX_CONTROL 0xa00
|
#define EESOX_INTR_ENABLE 0x04
|
#define EESOX_INTR_ENABLE 0x04
|
#define EESOX_TERM_ENABLE 0x02
|
#define EESOX_TERM_ENABLE 0x02
|
#define EESOX_RESET 0x01
|
#define EESOX_RESET 0x01
|
|
|
#define EESOX_DMA_OFFSET 0xe00
|
#define EESOX_DMA_OFFSET 0xe00
|
|
|
/*
|
/*
|
* Version
|
* Version
|
*/
|
*/
|
#define VER_MAJOR 0
|
#define VER_MAJOR 0
|
#define VER_MINOR 0
|
#define VER_MINOR 0
|
#define VER_PATCH 2
|
#define VER_PATCH 2
|
|
|
static struct expansion_card *ecs[MAX_ECARDS];
|
static struct expansion_card *ecs[MAX_ECARDS];
|
|
|
/*
|
/*
|
* Use term=0,1,0,0,0 to turn terminators on/off
|
* Use term=0,1,0,0,0 to turn terminators on/off
|
*/
|
*/
|
int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
|
int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
|
|
|
static struct proc_dir_entry proc_scsi_eesox = {
|
static struct proc_dir_entry proc_scsi_eesox = {
|
PROC_SCSI_QLOGICISP, 5, "eesox",
|
PROC_SCSI_QLOGICISP, 5, "eesox",
|
S_IFDIR | S_IRUGO | S_IXUGO, 2
|
S_IFDIR | S_IRUGO | S_IXUGO, 2
|
};
|
};
|
|
|
/* Prototype: void eesoxscsi_irqenable(ec, irqnr)
|
/* Prototype: void eesoxscsi_irqenable(ec, irqnr)
|
* Purpose : Enable interrupts on EESOX SCSI card
|
* Purpose : Enable interrupts on EESOX SCSI card
|
* Params : ec - expansion card structure
|
* Params : ec - expansion card structure
|
* : irqnr - interrupt number
|
* : irqnr - interrupt number
|
*/
|
*/
|
static void
|
static void
|
eesoxscsi_irqenable(struct expansion_card *ec, int irqnr)
|
eesoxscsi_irqenable(struct expansion_card *ec, int irqnr)
|
{
|
{
|
struct control *control = (struct control *)ec->irq_data;
|
struct control *control = (struct control *)ec->irq_data;
|
|
|
control->control |= EESOX_INTR_ENABLE;
|
control->control |= EESOX_INTR_ENABLE;
|
|
|
outb(control->control, control->io_port);
|
outb(control->control, control->io_port);
|
}
|
}
|
|
|
/* Prototype: void eesoxscsi_irqdisable(ec, irqnr)
|
/* Prototype: void eesoxscsi_irqdisable(ec, irqnr)
|
* Purpose : Disable interrupts on EESOX SCSI card
|
* Purpose : Disable interrupts on EESOX SCSI card
|
* Params : ec - expansion card structure
|
* Params : ec - expansion card structure
|
* : irqnr - interrupt number
|
* : irqnr - interrupt number
|
*/
|
*/
|
static void
|
static void
|
eesoxscsi_irqdisable(struct expansion_card *ec, int irqnr)
|
eesoxscsi_irqdisable(struct expansion_card *ec, int irqnr)
|
{
|
{
|
struct control *control = (struct control *)ec->irq_data;
|
struct control *control = (struct control *)ec->irq_data;
|
|
|
control->control &= ~EESOX_INTR_ENABLE;
|
control->control &= ~EESOX_INTR_ENABLE;
|
|
|
outb(control->control, control->io_port);
|
outb(control->control, control->io_port);
|
}
|
}
|
|
|
static const expansioncard_ops_t eesoxscsi_ops = {
|
static const expansioncard_ops_t eesoxscsi_ops = {
|
eesoxscsi_irqenable,
|
eesoxscsi_irqenable,
|
eesoxscsi_irqdisable,
|
eesoxscsi_irqdisable,
|
NULL,
|
NULL,
|
NULL,
|
NULL,
|
NULL,
|
NULL,
|
NULL
|
NULL
|
};
|
};
|
|
|
/* Prototype: void eesoxscsi_terminator_ctl(*host, on_off)
|
/* Prototype: void eesoxscsi_terminator_ctl(*host, on_off)
|
* Purpose : Turn the EESOX SCSI terminators on or off
|
* Purpose : Turn the EESOX SCSI terminators on or off
|
* Params : host - card to turn on/off
|
* Params : host - card to turn on/off
|
* : on_off - !0 to turn on, 0 to turn off
|
* : on_off - !0 to turn on, 0 to turn off
|
*/
|
*/
|
static void
|
static void
|
eesoxscsi_terminator_ctl(struct Scsi_Host *host, int on_off)
|
eesoxscsi_terminator_ctl(struct Scsi_Host *host, int on_off)
|
{
|
{
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
unsigned long flags;
|
unsigned long flags;
|
|
|
save_flags_cli(flags);
|
save_flags_cli(flags);
|
if (on_off)
|
if (on_off)
|
info->control.control |= EESOX_TERM_ENABLE;
|
info->control.control |= EESOX_TERM_ENABLE;
|
else
|
else
|
info->control.control &= ~EESOX_TERM_ENABLE;
|
info->control.control &= ~EESOX_TERM_ENABLE;
|
restore_flags(flags);
|
restore_flags(flags);
|
|
|
outb(info->control.control, info->control.io_port);
|
outb(info->control.control, info->control.io_port);
|
}
|
}
|
|
|
/* Prototype: void eesoxscsi_intr(irq, *dev_id, *regs)
|
/* Prototype: void eesoxscsi_intr(irq, *dev_id, *regs)
|
* Purpose : handle interrupts from EESOX SCSI card
|
* Purpose : handle interrupts from EESOX SCSI card
|
* Params : irq - interrupt number
|
* Params : irq - interrupt number
|
* dev_id - user-defined (Scsi_Host structure)
|
* dev_id - user-defined (Scsi_Host structure)
|
* regs - processor registers at interrupt
|
* regs - processor registers at interrupt
|
*/
|
*/
|
static void
|
static void
|
eesoxscsi_intr(int irq, void *dev_id, struct pt_regs *regs)
|
eesoxscsi_intr(int irq, void *dev_id, struct pt_regs *regs)
|
{
|
{
|
struct Scsi_Host *host = (struct Scsi_Host *)dev_id;
|
struct Scsi_Host *host = (struct Scsi_Host *)dev_id;
|
|
|
fas216_intr(host);
|
fas216_intr(host);
|
}
|
}
|
|
|
static void
|
static void
|
eesoxscsi_invalidate(char *addr, long len, fasdmadir_t direction)
|
eesoxscsi_invalidate(char *addr, long len, fasdmadir_t direction)
|
{
|
{
|
unsigned int page;
|
unsigned int page;
|
|
|
if (direction == DMA_OUT) {
|
if (direction == DMA_OUT) {
|
for(page = (unsigned int) addr; len > 0;
|
for(page = (unsigned int) addr; len > 0;
|
page += PAGE_SIZE, len -= PAGE_SIZE)
|
page += PAGE_SIZE, len -= PAGE_SIZE)
|
flush_page_to_ram(page);
|
flush_page_to_ram(page);
|
} else
|
} else
|
flush_cache_range(current->mm, (unsigned long)addr,
|
flush_cache_range(current->mm, (unsigned long)addr,
|
(unsigned long)addr + len);
|
(unsigned long)addr + len);
|
}
|
}
|
|
|
/* Prototype: fasdmatype_t eesoxscsi_dma_setup(host, SCpnt, direction, min_type)
|
/* Prototype: fasdmatype_t eesoxscsi_dma_setup(host, SCpnt, direction, min_type)
|
* Purpose : initialises DMA/PIO
|
* Purpose : initialises DMA/PIO
|
* Params : host - host
|
* Params : host - host
|
* SCpnt - command
|
* SCpnt - command
|
* direction - DMA on to/off of card
|
* direction - DMA on to/off of card
|
* min_type - minimum DMA support that we must have for this transfer
|
* min_type - minimum DMA support that we must have for this transfer
|
* Returns : type of transfer to be performed
|
* Returns : type of transfer to be performed
|
*/
|
*/
|
static fasdmatype_t
|
static fasdmatype_t
|
eesoxscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
|
eesoxscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
|
fasdmadir_t direction, fasdmatype_t min_type)
|
fasdmadir_t direction, fasdmatype_t min_type)
|
{
|
{
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
int dmach = host->dma_channel;
|
int dmach = host->dma_channel;
|
|
|
if (dmach != NO_DMA &&
|
if (dmach != NO_DMA &&
|
(min_type == fasdma_real_all || SCp->this_residual >= 512)) {
|
(min_type == fasdma_real_all || SCp->this_residual >= 512)) {
|
int buf;
|
int buf;
|
|
|
for(buf = 1; buf <= SCp->buffers_residual &&
|
for(buf = 1; buf <= SCp->buffers_residual &&
|
buf < NR_SG; buf++) {
|
buf < NR_SG; buf++) {
|
info->dmasg[buf].address = __virt_to_bus(
|
info->dmasg[buf].address = __virt_to_bus(
|
(unsigned long)SCp->buffer[buf].address);
|
(unsigned long)SCp->buffer[buf].address);
|
info->dmasg[buf].length = SCp->buffer[buf].length;
|
info->dmasg[buf].length = SCp->buffer[buf].length;
|
|
|
eesoxscsi_invalidate(SCp->buffer[buf].address,
|
eesoxscsi_invalidate(SCp->buffer[buf].address,
|
SCp->buffer[buf].length,
|
SCp->buffer[buf].length,
|
direction);
|
direction);
|
}
|
}
|
|
|
info->dmasg[0].address = __virt_to_phys((unsigned long)SCp->ptr);
|
info->dmasg[0].address = __virt_to_phys((unsigned long)SCp->ptr);
|
info->dmasg[0].length = SCp->this_residual;
|
info->dmasg[0].length = SCp->this_residual;
|
eesoxscsi_invalidate(SCp->ptr,
|
eesoxscsi_invalidate(SCp->ptr,
|
SCp->this_residual, direction);
|
SCp->this_residual, direction);
|
|
|
disable_dma(dmach);
|
disable_dma(dmach);
|
set_dma_sg(dmach, info->dmasg, buf);
|
set_dma_sg(dmach, info->dmasg, buf);
|
set_dma_mode(dmach,
|
set_dma_mode(dmach,
|
direction == DMA_OUT ? DMA_MODE_WRITE :
|
direction == DMA_OUT ? DMA_MODE_WRITE :
|
DMA_MODE_READ);
|
DMA_MODE_READ);
|
enable_dma(dmach);
|
enable_dma(dmach);
|
return fasdma_real_all;
|
return fasdma_real_all;
|
}
|
}
|
/*
|
/*
|
* We don't do DMA, we only do slow PIO
|
* We don't do DMA, we only do slow PIO
|
*
|
*
|
* Some day, we will do Pseudo DMA
|
* Some day, we will do Pseudo DMA
|
*/
|
*/
|
return fasdma_pseudo;
|
return fasdma_pseudo;
|
}
|
}
|
|
|
static void
|
static void
|
eesoxscsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
|
eesoxscsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
|
fasdmadir_t dir, int transfer_size)
|
fasdmadir_t dir, int transfer_size)
|
{
|
{
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
unsigned int status;
|
unsigned int status;
|
unsigned int length = SCp->this_residual;
|
unsigned int length = SCp->this_residual;
|
union {
|
union {
|
unsigned char *c;
|
unsigned char *c;
|
unsigned short *s;
|
unsigned short *s;
|
unsigned long *l;
|
unsigned long *l;
|
} buffer;
|
} buffer;
|
|
|
buffer.c = SCp->ptr;
|
buffer.c = SCp->ptr;
|
|
|
status = inb(host->io_port + EESOX_STATUS);
|
status = inb(host->io_port + EESOX_STATUS);
|
if (dir == DMA_IN) {
|
if (dir == DMA_IN) {
|
while (length > 8) {
|
while (length > 8) {
|
if (status & EESOX_STAT_DMA) {
|
if (status & EESOX_STAT_DMA) {
|
unsigned long l1, l2;
|
unsigned long l1, l2;
|
|
|
l1 = inw(info->dmaarea);
|
l1 = inw(info->dmaarea);
|
l1 |= inw(info->dmaarea) << 16;
|
l1 |= inw(info->dmaarea) << 16;
|
l2 = inw(info->dmaarea);
|
l2 = inw(info->dmaarea);
|
l2 |= inw(info->dmaarea) << 16;
|
l2 |= inw(info->dmaarea) << 16;
|
*buffer.l++ = l1;
|
*buffer.l++ = l1;
|
*buffer.l++ = l2;
|
*buffer.l++ = l2;
|
length -= 8;
|
length -= 8;
|
} else if (status & EESOX_STAT_INTR)
|
} else if (status & EESOX_STAT_INTR)
|
goto end;
|
goto end;
|
status = inb(host->io_port + EESOX_STATUS);
|
status = inb(host->io_port + EESOX_STATUS);
|
}
|
}
|
|
|
while (length > 1) {
|
while (length > 1) {
|
if (status & EESOX_STAT_DMA) {
|
if (status & EESOX_STAT_DMA) {
|
*buffer.s++ = inw(info->dmaarea);
|
*buffer.s++ = inw(info->dmaarea);
|
length -= 2;
|
length -= 2;
|
} else if (status & EESOX_STAT_INTR)
|
} else if (status & EESOX_STAT_INTR)
|
goto end;
|
goto end;
|
status = inb(host->io_port + EESOX_STATUS);
|
status = inb(host->io_port + EESOX_STATUS);
|
}
|
}
|
|
|
while (length > 0) {
|
while (length > 0) {
|
if (status & EESOX_STAT_DMA) {
|
if (status & EESOX_STAT_DMA) {
|
*buffer.c++ = inw(info->dmaarea);
|
*buffer.c++ = inw(info->dmaarea);
|
length -= 1;
|
length -= 1;
|
} else if (status & EESOX_STAT_INTR)
|
} else if (status & EESOX_STAT_INTR)
|
goto end;
|
goto end;
|
status = inb(host->io_port + EESOX_STATUS);
|
status = inb(host->io_port + EESOX_STATUS);
|
}
|
}
|
} else {
|
} else {
|
while (length > 8) {
|
while (length > 8) {
|
if (status & EESOX_STAT_DMA) {
|
if (status & EESOX_STAT_DMA) {
|
unsigned long l1, l2;
|
unsigned long l1, l2;
|
|
|
l1 = *buffer.l++;
|
l1 = *buffer.l++;
|
l2 = *buffer.l++;
|
l2 = *buffer.l++;
|
|
|
outw(l1, info->dmaarea);
|
outw(l1, info->dmaarea);
|
outw(l1 >> 16, info->dmaarea);
|
outw(l1 >> 16, info->dmaarea);
|
outw(l2, info->dmaarea);
|
outw(l2, info->dmaarea);
|
outw(l2 >> 16, info->dmaarea);
|
outw(l2 >> 16, info->dmaarea);
|
length -= 8;
|
length -= 8;
|
} else if (status & EESOX_STAT_INTR)
|
} else if (status & EESOX_STAT_INTR)
|
goto end;
|
goto end;
|
status = inb(host->io_port + EESOX_STATUS);
|
status = inb(host->io_port + EESOX_STATUS);
|
}
|
}
|
|
|
while (length > 1) {
|
while (length > 1) {
|
if (status & EESOX_STAT_DMA) {
|
if (status & EESOX_STAT_DMA) {
|
outw(*buffer.s++, info->dmaarea);
|
outw(*buffer.s++, info->dmaarea);
|
length -= 2;
|
length -= 2;
|
} else if (status & EESOX_STAT_INTR)
|
} else if (status & EESOX_STAT_INTR)
|
goto end;
|
goto end;
|
status = inb(host->io_port + EESOX_STATUS);
|
status = inb(host->io_port + EESOX_STATUS);
|
}
|
}
|
|
|
while (length > 0) {
|
while (length > 0) {
|
if (status & EESOX_STAT_DMA) {
|
if (status & EESOX_STAT_DMA) {
|
outw(*buffer.c++, info->dmaarea);
|
outw(*buffer.c++, info->dmaarea);
|
length -= 1;
|
length -= 1;
|
} else if (status & EESOX_STAT_INTR)
|
} else if (status & EESOX_STAT_INTR)
|
goto end;
|
goto end;
|
status = inb(host->io_port + EESOX_STATUS);
|
status = inb(host->io_port + EESOX_STATUS);
|
}
|
}
|
}
|
}
|
end:
|
end:
|
}
|
}
|
|
|
/* Prototype: int eesoxscsi_dma_stop(host, SCpnt)
|
/* Prototype: int eesoxscsi_dma_stop(host, SCpnt)
|
* Purpose : stops DMA/PIO
|
* Purpose : stops DMA/PIO
|
* Params : host - host
|
* Params : host - host
|
* SCpnt - command
|
* SCpnt - command
|
*/
|
*/
|
static void
|
static void
|
eesoxscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp)
|
eesoxscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp)
|
{
|
{
|
if (host->dma_channel != NO_DMA)
|
if (host->dma_channel != NO_DMA)
|
disable_dma(host->dma_channel);
|
disable_dma(host->dma_channel);
|
}
|
}
|
|
|
/* Prototype: int eesoxscsi_detect(Scsi_Host_Template * tpnt)
|
/* Prototype: int eesoxscsi_detect(Scsi_Host_Template * tpnt)
|
* Purpose : initialises EESOX SCSI driver
|
* Purpose : initialises EESOX SCSI driver
|
* Params : tpnt - template for this SCSI adapter
|
* Params : tpnt - template for this SCSI adapter
|
* Returns : >0 if host found, 0 otherwise.
|
* Returns : >0 if host found, 0 otherwise.
|
*/
|
*/
|
int
|
int
|
eesoxscsi_detect(Scsi_Host_Template *tpnt)
|
eesoxscsi_detect(Scsi_Host_Template *tpnt)
|
{
|
{
|
static const card_ids eesoxscsi_cids[] =
|
static const card_ids eesoxscsi_cids[] =
|
{ EESOXSCSI_LIST, { 0xffff, 0xffff} };
|
{ EESOXSCSI_LIST, { 0xffff, 0xffff} };
|
int count = 0;
|
int count = 0;
|
struct Scsi_Host *host;
|
struct Scsi_Host *host;
|
|
|
tpnt->proc_dir = &proc_scsi_eesox;
|
tpnt->proc_dir = &proc_scsi_eesox;
|
memset(ecs, 0, sizeof (ecs));
|
memset(ecs, 0, sizeof (ecs));
|
|
|
ecard_startfind();
|
ecard_startfind();
|
|
|
while(1) {
|
while(1) {
|
EESOXScsi_Info *info;
|
EESOXScsi_Info *info;
|
|
|
ecs[count] = ecard_find(0, eesoxscsi_cids);
|
ecs[count] = ecard_find(0, eesoxscsi_cids);
|
if (!ecs[count])
|
if (!ecs[count])
|
break;
|
break;
|
|
|
ecard_claim(ecs[count]);
|
ecard_claim(ecs[count]);
|
|
|
host = scsi_register(tpnt, sizeof (EESOXScsi_Info));
|
host = scsi_register(tpnt, sizeof (EESOXScsi_Info));
|
if (!host) {
|
if (!host) {
|
ecard_release(ecs[count]);
|
ecard_release(ecs[count]);
|
break;
|
break;
|
}
|
}
|
|
|
host->io_port = ecard_address(ecs[count], ECARD_IOC, ECARD_FAST);
|
host->io_port = ecard_address(ecs[count], ECARD_IOC, ECARD_FAST);
|
host->irq = ecs[count]->irq;
|
host->irq = ecs[count]->irq;
|
host->dma_channel = ecs[count]->dma;
|
host->dma_channel = ecs[count]->dma;
|
info = (EESOXScsi_Info *)host->hostdata;
|
info = (EESOXScsi_Info *)host->hostdata;
|
|
|
info->control.io_port = host->io_port + EESOX_CONTROL;
|
info->control.io_port = host->io_port + EESOX_CONTROL;
|
info->control.control = term[count] ? EESOX_TERM_ENABLE : 0;
|
info->control.control = term[count] ? EESOX_TERM_ENABLE : 0;
|
outb(info->control.control, info->control.io_port);
|
outb(info->control.control, info->control.io_port);
|
|
|
ecs[count]->irqaddr = (unsigned char *)
|
ecs[count]->irqaddr = (unsigned char *)
|
ioaddr(host->io_port + EESOX_STATUS);
|
ioaddr(host->io_port + EESOX_STATUS);
|
ecs[count]->irqmask = EESOX_STAT_INTR;
|
ecs[count]->irqmask = EESOX_STAT_INTR;
|
ecs[count]->irq_data = &info->control;
|
ecs[count]->irq_data = &info->control;
|
ecs[count]->ops = (expansioncard_ops_t *)&eesoxscsi_ops;
|
ecs[count]->ops = (expansioncard_ops_t *)&eesoxscsi_ops;
|
|
|
info->info.scsi.io_port = host->io_port + EESOX_FAS216_OFFSET;
|
info->info.scsi.io_port = host->io_port + EESOX_FAS216_OFFSET;
|
info->info.scsi.io_shift = EESOX_FAS216_SHIFT;
|
info->info.scsi.io_shift = EESOX_FAS216_SHIFT;
|
info->info.scsi.irq = host->irq;
|
info->info.scsi.irq = host->irq;
|
info->info.ifcfg.clockrate = EESOX_XTALFREQ;
|
info->info.ifcfg.clockrate = EESOX_XTALFREQ;
|
info->info.ifcfg.select_timeout = 255;
|
info->info.ifcfg.select_timeout = 255;
|
info->info.ifcfg.asyncperiod = EESOX_ASYNC_PERIOD;
|
info->info.ifcfg.asyncperiod = EESOX_ASYNC_PERIOD;
|
info->info.ifcfg.sync_max_depth = EESOX_SYNC_DEPTH;
|
info->info.ifcfg.sync_max_depth = EESOX_SYNC_DEPTH;
|
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
|
info->info.ifcfg.cntl3 = CNTL3_BS8 | CNTL3_FASTSCSI | CNTL3_FASTCLK;
|
info->info.ifcfg.disconnect_ok = 1;
|
info->info.ifcfg.disconnect_ok = 1;
|
info->info.ifcfg.wide_max_size = 0;
|
info->info.ifcfg.wide_max_size = 0;
|
info->info.dma.setup = eesoxscsi_dma_setup;
|
info->info.dma.setup = eesoxscsi_dma_setup;
|
info->info.dma.pseudo = eesoxscsi_dma_pseudo;
|
info->info.dma.pseudo = eesoxscsi_dma_pseudo;
|
info->info.dma.stop = eesoxscsi_dma_stop;
|
info->info.dma.stop = eesoxscsi_dma_stop;
|
info->dmaarea = host->io_port + EESOX_DMA_OFFSET;
|
info->dmaarea = host->io_port + EESOX_DMA_OFFSET;
|
|
|
request_region(host->io_port + EESOX_FAS216_OFFSET,
|
request_region(host->io_port + EESOX_FAS216_OFFSET,
|
16 << EESOX_FAS216_SHIFT, "eesox2-fas");
|
16 << EESOX_FAS216_SHIFT, "eesox2-fas");
|
|
|
if (request_irq(host->irq, eesoxscsi_intr,
|
if (request_irq(host->irq, eesoxscsi_intr,
|
SA_INTERRUPT, "eesox", host)) {
|
SA_INTERRUPT, "eesox", host)) {
|
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
|
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
|
host->host_no, host->irq);
|
host->host_no, host->irq);
|
host->irq = NO_IRQ;
|
host->irq = NO_IRQ;
|
}
|
}
|
|
|
if (request_dma(host->dma_channel, "eesox")) {
|
if (request_dma(host->dma_channel, "eesox")) {
|
printk("scsi%d: DMA%d not free, DMA disabled\n",
|
printk("scsi%d: DMA%d not free, DMA disabled\n",
|
host->host_no, host->dma_channel);
|
host->host_no, host->dma_channel);
|
host->dma_channel = NO_DMA;
|
host->dma_channel = NO_DMA;
|
}
|
}
|
|
|
fas216_init(host);
|
fas216_init(host);
|
++count;
|
++count;
|
}
|
}
|
return count;
|
return count;
|
}
|
}
|
|
|
/* Prototype: int eesoxscsi_release(struct Scsi_Host * host)
|
/* Prototype: int eesoxscsi_release(struct Scsi_Host * host)
|
* Purpose : releases all resources used by this adapter
|
* Purpose : releases all resources used by this adapter
|
* Params : host - driver host structure to return info for.
|
* Params : host - driver host structure to return info for.
|
*/
|
*/
|
int eesoxscsi_release(struct Scsi_Host *host)
|
int eesoxscsi_release(struct Scsi_Host *host)
|
{
|
{
|
int i;
|
int i;
|
|
|
fas216_release(host);
|
fas216_release(host);
|
|
|
if (host->irq != NO_IRQ)
|
if (host->irq != NO_IRQ)
|
free_irq(host->irq, host);
|
free_irq(host->irq, host);
|
if (host->dma_channel != NO_DMA)
|
if (host->dma_channel != NO_DMA)
|
free_dma(host->dma_channel);
|
free_dma(host->dma_channel);
|
release_region(host->io_port + EESOX_FAS216_OFFSET, 16 << EESOX_FAS216_SHIFT);
|
release_region(host->io_port + EESOX_FAS216_OFFSET, 16 << EESOX_FAS216_SHIFT);
|
|
|
for (i = 0; i < MAX_ECARDS; i++)
|
for (i = 0; i < MAX_ECARDS; i++)
|
if (ecs[i] &&
|
if (ecs[i] &&
|
host->io_port == ecard_address(ecs[i], ECARD_IOC, ECARD_FAST))
|
host->io_port == ecard_address(ecs[i], ECARD_IOC, ECARD_FAST))
|
ecard_release(ecs[i]);
|
ecard_release(ecs[i]);
|
return 0;
|
return 0;
|
}
|
}
|
|
|
/* Prototype: const char *eesoxscsi_info(struct Scsi_Host * host)
|
/* Prototype: const char *eesoxscsi_info(struct Scsi_Host * host)
|
* Purpose : returns a descriptive string about this interface,
|
* Purpose : returns a descriptive string about this interface,
|
* Params : host - driver host structure to return info for.
|
* Params : host - driver host structure to return info for.
|
* Returns : pointer to a static buffer containing null terminated string.
|
* Returns : pointer to a static buffer containing null terminated string.
|
*/
|
*/
|
const char *eesoxscsi_info(struct Scsi_Host *host)
|
const char *eesoxscsi_info(struct Scsi_Host *host)
|
{
|
{
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;
|
static char string[100], *p;
|
static char string[100], *p;
|
|
|
p = string;
|
p = string;
|
p += sprintf(string, "%s at port %X ", host->hostt->name, host->io_port);
|
p += sprintf(string, "%s at port %X ", host->hostt->name, host->io_port);
|
|
|
if (host->irq != NO_IRQ)
|
if (host->irq != NO_IRQ)
|
p += sprintf(p, "irq %d ", host->irq);
|
p += sprintf(p, "irq %d ", host->irq);
|
else
|
else
|
p += sprintf(p, "NO IRQ ");
|
p += sprintf(p, "NO IRQ ");
|
|
|
if (host->dma_channel != NO_DMA)
|
if (host->dma_channel != NO_DMA)
|
p += sprintf(p, "dma %d ", host->dma_channel);
|
p += sprintf(p, "dma %d ", host->dma_channel);
|
else
|
else
|
p += sprintf(p, "NO DMA ");
|
p += sprintf(p, "NO DMA ");
|
|
|
p += sprintf(p, "v%d.%d.%d scsi %s", VER_MAJOR, VER_MINOR, VER_PATCH,
|
p += sprintf(p, "v%d.%d.%d scsi %s", VER_MAJOR, VER_MINOR, VER_PATCH,
|
info->info.scsi.type);
|
info->info.scsi.type);
|
|
|
p += sprintf(p, " terminators %s",
|
p += sprintf(p, " terminators %s",
|
info->control.control & EESOX_TERM_ENABLE ? "on" : "off");
|
info->control.control & EESOX_TERM_ENABLE ? "on" : "off");
|
|
|
return string;
|
return string;
|
}
|
}
|
|
|
/* Prototype: int eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
|
/* Prototype: int eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
|
* Purpose : Set a driver specific function
|
* Purpose : Set a driver specific function
|
* Params : host - host to setup
|
* Params : host - host to setup
|
* : buffer - buffer containing string describing operation
|
* : buffer - buffer containing string describing operation
|
* : length - length of string
|
* : length - length of string
|
* Returns : -EINVAL, or 0
|
* Returns : -EINVAL, or 0
|
*/
|
*/
|
static int
|
static int
|
eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
|
eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
|
{
|
{
|
int ret = length;
|
int ret = length;
|
|
|
if (length >= 9 && strncmp(buffer, "EESOXSCSI", 9) == 0) {
|
if (length >= 9 && strncmp(buffer, "EESOXSCSI", 9) == 0) {
|
buffer += 9;
|
buffer += 9;
|
length -= 9;
|
length -= 9;
|
|
|
if (length >= 5 && strncmp(buffer, "term=", 5) == 0) {
|
if (length >= 5 && strncmp(buffer, "term=", 5) == 0) {
|
if (buffer[5] == '1')
|
if (buffer[5] == '1')
|
eesoxscsi_terminator_ctl(host, 1);
|
eesoxscsi_terminator_ctl(host, 1);
|
else if (buffer[5] == '0')
|
else if (buffer[5] == '0')
|
eesoxscsi_terminator_ctl(host, 0);
|
eesoxscsi_terminator_ctl(host, 0);
|
else
|
else
|
ret = -EINVAL;
|
ret = -EINVAL;
|
} else
|
} else
|
ret = -EINVAL;
|
ret = -EINVAL;
|
} else
|
} else
|
ret = -EINVAL;
|
ret = -EINVAL;
|
|
|
return ret;
|
return ret;
|
}
|
}
|
|
|
/* Prototype: int eesoxscsi_proc_info(char *buffer, char **start, off_t offset,
|
/* Prototype: int eesoxscsi_proc_info(char *buffer, char **start, off_t offset,
|
* int length, int host_no, int inout)
|
* int length, int host_no, int inout)
|
* Purpose : Return information about the driver to a user process accessing
|
* Purpose : Return information about the driver to a user process accessing
|
* the /proc filesystem.
|
* the /proc filesystem.
|
* Params : buffer - a buffer to write information to
|
* Params : buffer - a buffer to write information to
|
* start - a pointer into this buffer set by this routine to the start
|
* start - a pointer into this buffer set by this routine to the start
|
* of the required information.
|
* of the required information.
|
* offset - offset into information that we have read upto.
|
* offset - offset into information that we have read upto.
|
* length - length of buffer
|
* length - length of buffer
|
* host_no - host number to return information for
|
* host_no - host number to return information for
|
* inout - 0 for reading, 1 for writing.
|
* inout - 0 for reading, 1 for writing.
|
* Returns : length of data written to buffer.
|
* Returns : length of data written to buffer.
|
*/
|
*/
|
int eesoxscsi_proc_info(char *buffer, char **start, off_t offset,
|
int eesoxscsi_proc_info(char *buffer, char **start, off_t offset,
|
int length, int host_no, int inout)
|
int length, int host_no, int inout)
|
{
|
{
|
int pos, begin, first;
|
int pos, begin, first;
|
struct Scsi_Host *host = scsi_hostlist;
|
struct Scsi_Host *host = scsi_hostlist;
|
EESOXScsi_Info *info;
|
EESOXScsi_Info *info;
|
Scsi_Device *scd;
|
Scsi_Device *scd;
|
|
|
while (host) {
|
while (host) {
|
if (host->host_no == host_no)
|
if (host->host_no == host_no)
|
break;
|
break;
|
host = host->next;
|
host = host->next;
|
}
|
}
|
if (!host)
|
if (!host)
|
return 0;
|
return 0;
|
|
|
if (inout == 1)
|
if (inout == 1)
|
return eesoxscsi_set_proc_info(host, buffer, length);
|
return eesoxscsi_set_proc_info(host, buffer, length);
|
|
|
info = (EESOXScsi_Info *)host->hostdata;
|
info = (EESOXScsi_Info *)host->hostdata;
|
|
|
begin = 0;
|
begin = 0;
|
pos = sprintf(buffer,
|
pos = sprintf(buffer,
|
"EESOX SCSI driver version %d.%d.%d\n",
|
"EESOX SCSI driver version %d.%d.%d\n",
|
VER_MAJOR, VER_MINOR, VER_PATCH);
|
VER_MAJOR, VER_MINOR, VER_PATCH);
|
pos += sprintf(buffer + pos,
|
pos += sprintf(buffer + pos,
|
"Address: %08X IRQ : %d DMA : %d\n"
|
"Address: %08X IRQ : %d DMA : %d\n"
|
"FAS : %-10s TERM: %-3s\n\n"
|
"FAS : %-10s TERM: %-3s\n\n"
|
"Statistics:\n",
|
"Statistics:\n",
|
host->io_port, host->irq, host->dma_channel,
|
host->io_port, host->irq, host->dma_channel,
|
info->info.scsi.type, info->control.control & EESOX_TERM_ENABLE ? "on" : "off");
|
info->info.scsi.type, info->control.control & EESOX_TERM_ENABLE ? "on" : "off");
|
|
|
pos += sprintf(buffer+pos,
|
pos += sprintf(buffer+pos,
|
"Queued commands: %-10u Issued commands: %-10u\n"
|
"Queued commands: %-10u Issued commands: %-10u\n"
|
"Done commands : %-10u Reads : %-10u\n"
|
"Done commands : %-10u Reads : %-10u\n"
|
"Writes : %-10u Others : %-10u\n"
|
"Writes : %-10u Others : %-10u\n"
|
"Disconnects : %-10u Aborts : %-10u\n"
|
"Disconnects : %-10u Aborts : %-10u\n"
|
"Resets : %-10u\n",
|
"Resets : %-10u\n",
|
info->info.stats.queues, info->info.stats.removes,
|
info->info.stats.queues, info->info.stats.removes,
|
info->info.stats.fins, info->info.stats.reads,
|
info->info.stats.fins, info->info.stats.reads,
|
info->info.stats.writes, info->info.stats.miscs,
|
info->info.stats.writes, info->info.stats.miscs,
|
info->info.stats.disconnects, info->info.stats.aborts,
|
info->info.stats.disconnects, info->info.stats.aborts,
|
info->info.stats.resets);
|
info->info.stats.resets);
|
|
|
first = 1;
|
first = 1;
|
for (scd = scsi_devices; scd; scd = scd->next) {
|
for (scd = scsi_devices; scd; scd = scd->next) {
|
if (scd->host == host) {
|
if (scd->host == host) {
|
int len;
|
int len;
|
|
|
if (first) {
|
if (first) {
|
pos += sprintf(buffer+pos,
|
pos += sprintf(buffer+pos,
|
"\nAttached devices:\n");
|
"\nAttached devices:\n");
|
first = 0;
|
first = 0;
|
}
|
}
|
|
|
proc_print_scsidevice(scd, buffer, &len, pos);
|
proc_print_scsidevice(scd, buffer, &len, pos);
|
pos += len;
|
pos += len;
|
pos += sprintf(buffer+pos, "Extensions: ");
|
pos += sprintf(buffer+pos, "Extensions: ");
|
if (scd->tagged_supported)
|
if (scd->tagged_supported)
|
pos += sprintf(buffer+pos, "TAG %sabled [%d] ",
|
pos += sprintf(buffer+pos, "TAG %sabled [%d] ",
|
scd->tagged_queue ? "en" : "dis",
|
scd->tagged_queue ? "en" : "dis",
|
scd->current_tag);
|
scd->current_tag);
|
pos += sprintf(buffer+pos, "\n");
|
pos += sprintf(buffer+pos, "\n");
|
|
|
if (pos + begin < offset) {
|
if (pos + begin < offset) {
|
begin += pos;
|
begin += pos;
|
pos = 0;
|
pos = 0;
|
}
|
}
|
if (pos + begin > offset + length)
|
if (pos + begin > offset + length)
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
*start = buffer + (offset - begin);
|
*start = buffer + (offset - begin);
|
pos -= offset - begin;
|
pos -= offset - begin;
|
if (pos > length)
|
if (pos > length)
|
pos = length;
|
pos = length;
|
|
|
return pos;
|
return pos;
|
}
|
}
|
|
|
#ifdef MODULE
|
#ifdef MODULE
|
Scsi_Host_Template driver_template = EESOXSCSI;
|
Scsi_Host_Template driver_template = EESOXSCSI;
|
|
|
#include "scsi_module.c"
|
#include "scsi_module.c"
|
#endif
|
#endif
|
|
|