uchar sdtr_period_offset[ASC_MAX_TID + 1];
ushort pci_slot_info;
uchar adapter_info[6];
- struct device *dev;
} ASC_DVC_CFG;
#define ASC_DEF_DVC_CNTL 0xFFFF
static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
static ushort AscInitFromEEP(ASC_DVC_VAR *);
-static ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
static int AscTestExternalLram(ASC_DVC_VAR *);
static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
#define BIOS_CTRL_AIPP_DIS 0x2000
#define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
-#define ADV_3550_IOLEN 0x40 /* I/O Port Range in bytes */
#define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
-#define ADV_38C0800_IOLEN 0x100 /* I/O Port Range in bytes */
/*
* XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
* #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
*/
#define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
-#define ADV_38C1600_IOLEN 0x100 /* I/O Port Range 256 bytes */
-#define ADV_38C1600_MEMLEN 0x1000 /* Memory Range 4KB bytes */
/*
* Byte I/O register address from base of 'iop_base'.
ushort serial1; /* EEPROM serial number word 1 */
ushort serial2; /* EEPROM serial number word 2 */
ushort serial3; /* EEPROM serial number word 3 */
- struct device *dev; /* pointer to the pci dev structure for this board */
} ADV_DVC_CFG;
struct adv_dvc_var;
*/
static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
static int AdvISR(ADV_DVC_VAR *);
-static int AdvInitGetConfig(ADV_DVC_VAR *);
static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
* field. It is guaranteed to be allocated from DMA-able memory.
*/
typedef struct asc_board {
+ struct device *dev;
int id; /* Board Id */
uint flags; /* Board flags */
union {
ASC_DVC_VAR *asc_dvc_varp;
ADV_DVC_VAR *adv_dvc_varp;
char *busname;
- int iolen;
char *widename = NULL;
boardp = ASC_BOARDP(shost);
} else {
busname = "ISA";
}
- /* Don't reference 'shost->n_io_port'; It may be truncated. */
sprintf(info,
"AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
ASC_VERSION, busname,
(ulong)shost->io_port,
- (ulong)shost->io_port + boardp->asc_n_io_port -
- 1, shost->irq, shost->dma_channel);
+ (ulong)shost->io_port + ASC_IOADR_GAP - 1,
+ shost->irq, shost->dma_channel);
} else {
if (asc_dvc_varp->bus_type & ASC_IS_VL) {
busname = "VL";
"bus type %d\n", boardp->id,
asc_dvc_varp->bus_type);
}
- /* Don't reference 'shost->n_io_port'; It may be truncated. */
sprintf(info,
"AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
ASC_VERSION, busname, (ulong)shost->io_port,
- (ulong)shost->io_port + boardp->asc_n_io_port -
- 1, shost->irq);
+ (ulong)shost->io_port + ASC_IOADR_GAP - 1,
+ shost->irq);
}
} else {
/*
*/
adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
- iolen = ADV_3550_IOLEN;
widename = "Ultra-Wide";
} else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
- iolen = ADV_38C0800_IOLEN;
widename = "Ultra2-Wide";
} else {
- iolen = ADV_38C1600_IOLEN;
widename = "Ultra3-Wide";
}
sprintf(info,
"AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
- (ulong)adv_dvc_varp->iop_base + iolen - 1, shost->irq);
+ (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
}
ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
ASC_DBG(1, "advansys_info: end\n");
ASC_DBG(2, "asc_scsi_done_list: begin\n");
while (scp != NULL) {
asc_board_t *boardp;
- struct device *dev;
ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
tscp = REQPNEXT(scp);
boardp = ASC_BOARDP(scp->device->host);
- if (ASC_NARROW_BOARD(boardp))
- dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
- else
- dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
-
if (scp->use_sg)
- dma_unmap_sg(dev,
+ dma_unmap_sg(boardp->dev,
(struct scatterlist *)scp->request_buffer,
scp->use_sg, scp->sc_data_direction);
else if (scp->request_bufflen)
- dma_unmap_single(dev, scp->SCp.dma_handle,
+ dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
scp->request_bufflen,
scp->sc_data_direction);
*/
static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
{
- struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
-
/*
* Mutually exclusive access is required to 'asc_scsi_q' and
* 'asc_sg_head' until after the request is started.
*/
ASC_STATS(scp->device->host, cont_cnt);
scp->SCp.dma_handle = scp->request_bufflen ?
- dma_map_single(dev, scp->request_buffer,
+ dma_map_single(boardp->dev, scp->request_buffer,
scp->request_bufflen,
scp->sc_data_direction) : 0;
asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
struct scatterlist *slp;
slp = (struct scatterlist *)scp->request_buffer;
- use_sg =
- dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
+ use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
+ scp->sc_data_direction);
if (use_sg > scp->device->host->sg_tablesize) {
- ASC_PRINT3
- ("asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
- boardp->id, use_sg,
- scp->device->host->sg_tablesize);
- dma_unmap_sg(dev, slp, scp->use_sg,
+ ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
+ "sg_tablesize %d\n", boardp->id, use_sg,
+ scp->device->host->sg_tablesize);
+ dma_unmap_sg(boardp->dev, slp, scp->use_sg,
scp->sc_data_direction);
scp->result = HOST_BYTE(DID_ERROR);
asc_enqueue(&boardp->done, scp, ASC_BACK);
ADV_SCSI_REQ_Q *scsiqp;
int i;
int ret;
- struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
/*
* Allocate an adv_req_t structure from the board to execute
if (scp->request_bufflen) {
scsiqp->vdata_addr = scp->request_buffer;
scp->SCp.dma_handle =
- dma_map_single(dev, scp->request_buffer,
+ dma_map_single(boardp->dev, scp->request_buffer,
scp->request_bufflen,
scp->sc_data_direction);
} else {
int use_sg;
slp = (struct scatterlist *)scp->request_buffer;
- use_sg =
- dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
+ use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
+ scp->sc_data_direction);
if (use_sg > ADV_MAX_SG_LIST) {
- ASC_PRINT3
- ("adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
- boardp->id, use_sg,
- scp->device->host->sg_tablesize);
- dma_unmap_sg(dev, slp, scp->use_sg,
+ ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
+ "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
+ scp->device->host->sg_tablesize);
+ dma_unmap_sg(boardp->dev, slp, scp->use_sg,
scp->sc_data_direction);
scp->result = HOST_BYTE(DID_ERROR);
asc_enqueue(&boardp->done, scp, ASC_BACK);
/*
- * Free the 'adv_req_t' structure by adding it back to the
- * board free list.
+ * Free the 'adv_req_t' structure by adding it back
+ * to the board free list.
*/
reqp->next_reqp = boardp->adv_reqp;
boardp->adv_reqp = reqp;
return ASC_ERROR;
}
- if ((ret =
- adv_get_sglist(boardp, reqp, scp,
- use_sg)) != ADV_SUCCESS) {
+ ret = adv_get_sglist(boardp, reqp, scp, use_sg);
+ if (ret != ADV_SUCCESS) {
/*
- * Free the adv_req_t structure by adding it back to the
- * board free list.
+ * Free the adv_req_t structure by adding it back to
+ * the board free list.
*/
reqp->next_reqp = boardp->adv_reqp;
boardp->adv_reqp = reqp;
boardp->asc_n_io_port);
ASC_PRT_NEXT();
- /* 'shost->n_io_port' may be truncated because it is only one byte. */
- len = asc_prt_line(cp, leftlen,
- " io_port 0x%x, n_io_port 0x%x\n",
- shost->io_port, shost->n_io_port);
+ len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
ASC_PRT_NEXT();
if (ASC_NARROW_BOARD(boardp)) {
printk(" host_busy %u, host_no %d, last_reset %d,\n",
s->host_busy, s->host_no, (unsigned)s->last_reset);
- printk(" base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
- (ulong)s->base, (ulong)s->io_port, s->n_io_port, s->irq);
+ printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
+ (ulong)s->base, (ulong)s->io_port, s->irq);
printk(" dma_channel %d, this_id %d, can_queue %d,\n",
s->dma_channel, s->this_id, s->can_queue);
return warn_code;
}
-static ushort __devinit AscInitSetConfig(ASC_DVC_VAR *asc_dvc)
+static unsigned short __devinit
+AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
{
- ushort warn_code = 0;
+ PortAddr iop_base = asc_dvc->iop_base;
+ unsigned short cfg_msw;
+ unsigned short warn_code = 0;
asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
if (asc_dvc->err_code != 0)
- return (UW_ERR);
- if (AscFindSignature(asc_dvc->iop_base)) {
- warn_code |= AscInitFromAscDvcVar(asc_dvc);
- asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
- } else {
+ return UW_ERR;
+ if (!AscFindSignature(asc_dvc->iop_base)) {
asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
+ return 0;
}
- return (warn_code);
-}
-static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
-{
- PortAddr iop_base;
- ushort cfg_msw;
- ushort warn_code;
-
- iop_base = asc_dvc->iop_base;
- warn_code = 0;
cfg_msw = AscGetChipCfgMsw(iop_base);
if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
}
#ifdef CONFIG_PCI
if (asc_dvc->bus_type & ASC_IS_PCI) {
- struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
cfg_msw &= 0xFFC0;
AscSetChipCfgMsw(iop_base, cfg_msw);
if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
}
#endif /* CONFIG_ISA */
- return (warn_code);
+
+ asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
+ return warn_code;
}
static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
* For a non-fatal error return a warning code. If there are no warnings
* then 0 is returned.
*/
-static int __devinit AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
+static int __devinit
+AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
{
unsigned short warn_code = 0;
AdvPortAddr iop_base = asc_dvc->iop_base;
- struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
u16 cmd;
int status;
memset(boardp, 0, sizeof(asc_board_t));
boardp->id = asc_board_count++;
spin_lock_init(&boardp->lock);
+ boardp->dev = dev;
/*
* Handle both narrow and wide boards.
#endif /* CONFIG_PROC_FS */
if (ASC_NARROW_BOARD(boardp)) {
- asc_dvc_varp->cfg->dev = dev;
/*
* Set the board bus type and PCI IRQ before
* calling AscInitGetConfig().
break;
}
} else {
- adv_dvc_varp->cfg->dev = dev;
/*
* For Wide boards set PCI information before calling
* AdvInitGetConfig().
}
} else {
ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
- if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
+
+ ret = AdvInitGetConfig(pdev, adv_dvc_varp);
+ if (ret != 0) {
ASC_PRINT2
("AdvInitGetConfig: board %d: warning: 0x%x\n",
boardp->id, ret);
* Modify board configuration.
*/
ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
- switch (ret = AscInitSetConfig(asc_dvc_varp)) {
+ switch (ret = AscInitSetConfig(pdev, asc_dvc_varp)) {
case 0: /* No error. */
break;
case ASC_WARN_IO_PORT_ROTATE:
shost->can_queue = adv_dvc_varp->max_host_qng;
}
- /*
- * 'n_io_port' currently is one byte.
- *
- * Set a value to 'n_io_port', but never referenced it because
- * it may be truncated.
- */
- shost->n_io_port = boardp->asc_n_io_port <= 255 ?
- boardp->asc_n_io_port : 255;
-
/*
* Following v1.3.89, 'cmd_per_lun' is no longer needed
* and should be set to zero.