Commit ecc6ff95 authored by Ondrej Zary's avatar Ondrej Zary Committed by Martin K. Petersen

atp870u: Introduce atp885_init()

Move 885-specific init code to a separate function atp885_init()
Signed-off-by: default avatarOndrej Zary <linux@rainbow-software.org>
Reviewed-by: default avatarHannes Reinicke <hare@suse.de>
Acked-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c7e6a029
......@@ -1334,68 +1334,17 @@ static void atp880_init(struct Scsi_Host *shpnt)
shpnt->this_id = host_id;
}
/* return non-zero on detection */
static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
static void atp885_init(struct Scsi_Host *shpnt)
{
struct atp_unit *atpdev = shost_priv(shpnt);
struct pci_dev *pdev = atpdev->pdev;
unsigned char k, m, c;
unsigned int error,n;
unsigned char host_id;
struct Scsi_Host *shpnt = NULL;
struct atp_unit *atpdev;
unsigned int n;
unsigned char setupdata[2][16];
int err;
if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision < 2) {
dev_err(&pdev->dev, "ATP850S chips (AEC6710L/F cards) are not supported.\n");
return -ENODEV;
}
err = pci_enable_device(pdev);
if (err)
goto fail;
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
printk(KERN_ERR "atp870u: DMA mask required but not available.\n");
err = -EIO;
goto disable_device;
}
err = pci_request_regions(pdev, "atp870u");
if (err)
goto disable_device;
pci_set_master(pdev);
err = -ENOMEM;
shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit));
if (!shpnt)
goto release_region;
atpdev = shost_priv(shpnt);
atpdev->host = shpnt;
atpdev->pdev = pdev;
pci_set_drvdata(pdev, atpdev);
shpnt->io_port = pci_resource_start(pdev, 0);
shpnt->io_port &= 0xfffffff8;
shpnt->n_io_port = pci_resource_len(pdev, 0);
atpdev->baseport = shpnt->io_port;
shpnt->unique_id = shpnt->io_port;
shpnt->irq = pdev->irq;
err = atp870u_init_tables(shpnt);
if (err) {
dev_err(&pdev->dev, "Unable to allocate tables for Acard controller\n");
goto unregister;
}
if (is880(atpdev))
atp880_init(shpnt);
else if (is885(atpdev)) {
printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n"
, shpnt->io_port, shpnt->irq);
dev_info(&pdev->dev, "ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n",
shpnt->io_port, shpnt->irq);
atpdev->pdev = pdev;
atpdev->ioport[0] = shpnt->io_port + 0x80;
atpdev->ioport[1] = shpnt->io_port + 0xc0;
atpdev->pciport[0] = shpnt->io_port + 0x40;
......@@ -1404,52 +1353,41 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
c = atp_readb_base(atpdev, 0x29);
atp_writeb_base(atpdev, 0x29, c | 0x04);
n=0x1f80;
next_fblk_885:
if (n >= 0x2000) {
goto flash_ok_885;
}
n = 0x1f80;
while (n < 0x2000) {
atp_writew_base(atpdev, 0x3c, n);
if (atp_readl_base(atpdev, 0x38) == 0xffffffff) {
goto flash_ok_885;
}
for (m=0; m < 2; m++) {
atpdev->global_map[m]= 0;
for (k=0; k < 4; k++) {
if (atp_readl_base(atpdev, 0x38) == 0xffffffff)
break;
for (m = 0; m < 2; m++) {
atpdev->global_map[m] = 0;
for (k = 0; k < 4; k++) {
atp_writew_base(atpdev, 0x3c, n++);
((unsigned long *)&setupdata[m][0])[k] = atp_readl_base(atpdev, 0x38);
}
for (k=0; k < 4; k++) {
for (k = 0; k < 4; k++) {
atp_writew_base(atpdev, 0x3c, n++);
((unsigned long *)&atpdev->sp[m][0])[k] = atp_readl_base(atpdev, 0x38);
}
n += 8;
}
goto next_fblk_885;
flash_ok_885:
#ifdef ED_DBGP
printk( "Flash Read OK\n");
#endif
}
c = atp_readb_base(atpdev, 0x29);
atp_writeb_base(atpdev, 0x29, c & 0xfb);
for (c=0;c < 2;c++) {
atpdev->ultra_map[c]=0;
for (c = 0; c < 2; c++) {
atpdev->ultra_map[c] = 0;
atpdev->async[c] = 0;
for (k=0; k < 16; k++) {
n=1;
n = n << k;
if (atpdev->sp[c][k] > 1) {
for (k = 0; k < 16; k++) {
n = 1 << k;
if (atpdev->sp[c][k] > 1)
atpdev->ultra_map[c] |= n;
} else {
if (atpdev->sp[c][k] == 0) {
else
if (atpdev->sp[c][k] == 0)
atpdev->async[c] |= n;
}
}
}
atpdev->async[c] = ~(atpdev->async[c]);
if (atpdev->global_map[c] == 0) {
k=setupdata[c][1];
k = setupdata[c][1];
if ((k & 0x40) != 0)
atpdev->global_map[c] |= 0x20;
k &= 0x07;
......@@ -1474,21 +1412,21 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
atp_readb_io(atpdev, 1, 0x1b);
atp_readb_io(atpdev, 1, 0x17);
k=atpdev->host_id[0];
k = atpdev->host_id[0];
if (k > 7)
k = (k & 0x07) | 0x40;
atp_set_host_id(atpdev, 0, k);
k=atpdev->host_id[1];
k = atpdev->host_id[1];
if (k > 7)
k = (k & 0x07) | 0x40;
atp_set_host_id(atpdev, 1, k);
mdelay(600); /* this delay used to be called tscam_885() */
printk(KERN_INFO " Scanning Channel A SCSI Device ...\n");
dev_info(&pdev->dev, "Scanning Channel A SCSI Device ...\n");
atp_is(atpdev, 0, true, atp_readb_io(atpdev, 0, 0x1b) >> 7);
atp_writeb_io(atpdev, 0, 0x16, 0x80);
printk(KERN_INFO " Scanning Channel B SCSI Device ...\n");
dev_info(&pdev->dev, "Scanning Channel B SCSI Device ...\n");
atp_is(atpdev, 1, true, atp_readb_io(atpdev, 1, 0x1b) >> 7);
atp_writeb_io(atpdev, 1, 0x16, 0x80);
k = atp_readb_base(atpdev, 0x28) & 0xcf;
......@@ -1498,14 +1436,71 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
atp_writeb_base(atpdev, 0x1f, k);
k = atp_readb_base(atpdev, 0x29) | 0x01;
atp_writeb_base(atpdev, 0x29, k);
#ifdef ED_DBGP
//printk("atp885: atp_host[0] 0x%p\n", atp_host[0]);
#endif
shpnt->max_id = 16;
shpnt->max_lun = (atpdev->global_map[0] & 0x07) + 1;
shpnt->max_channel = 1;
shpnt->this_id = atpdev->host_id[0];
} else {
}
/* return non-zero on detection */
static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
unsigned char k;
unsigned int error;
unsigned char host_id;
struct Scsi_Host *shpnt = NULL;
struct atp_unit *atpdev;
int err;
if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision < 2) {
dev_err(&pdev->dev, "ATP850S chips (AEC6710L/F cards) are not supported.\n");
return -ENODEV;
}
err = pci_enable_device(pdev);
if (err)
goto fail;
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
printk(KERN_ERR "atp870u: DMA mask required but not available.\n");
err = -EIO;
goto disable_device;
}
err = pci_request_regions(pdev, "atp870u");
if (err)
goto disable_device;
pci_set_master(pdev);
err = -ENOMEM;
shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit));
if (!shpnt)
goto release_region;
atpdev = shost_priv(shpnt);
atpdev->host = shpnt;
atpdev->pdev = pdev;
pci_set_drvdata(pdev, atpdev);
shpnt->io_port = pci_resource_start(pdev, 0);
shpnt->io_port &= 0xfffffff8;
shpnt->n_io_port = pci_resource_len(pdev, 0);
atpdev->baseport = shpnt->io_port;
shpnt->unique_id = shpnt->io_port;
shpnt->irq = pdev->irq;
err = atp870u_init_tables(shpnt);
if (err) {
dev_err(&pdev->dev, "Unable to allocate tables for Acard controller\n");
goto unregister;
}
if (is880(atpdev))
atp880_init(shpnt);
else if (is885(atpdev))
atp885_init(shpnt);
else {
u8 scam_on;
bool wide_chip =
(ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 &&
......
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