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

atp870u: Introduce atp880_init()

Move 880-specific init code to a separate function atp880_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 f5f53a38
...@@ -1249,87 +1249,34 @@ static void atp_set_host_id(struct atp_unit *atp, u8 c, u8 host_id) ...@@ -1249,87 +1249,34 @@ static void atp_set_host_id(struct atp_unit *atp, u8 c, u8 host_id)
atp_writeb_io(atp, c, 0x11, 0x20); atp_writeb_io(atp, c, 0x11, 0x20);
} }
/* return non-zero on detection */ static void atp880_init(struct Scsi_Host *shpnt)
static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
unsigned char k, m, c; struct atp_unit *atpdev = shost_priv(shpnt);
unsigned int error,n; struct pci_dev *pdev = atpdev->pdev;
unsigned char host_id; unsigned char k, m, host_id;
struct Scsi_Host *shpnt = NULL; unsigned int n;
struct atp_unit *atpdev;
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))) { pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);
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)) {
pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);//JCC082803
atpdev->ioport[0] = shpnt->io_port + 0x40; atpdev->ioport[0] = shpnt->io_port + 0x40;
atpdev->pciport[0] = shpnt->io_port + 0x28; atpdev->pciport[0] = shpnt->io_port + 0x28;
host_id = atp_readb_base(atpdev, 0x39); host_id = atp_readb_base(atpdev, 0x39) >> 4;
host_id >>= 0x04;
printk(KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:" dev_info(&pdev->dev, "ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n",
" IO:%lx, IRQ:%d.\n", shpnt->io_port, shpnt->irq); shpnt->io_port, shpnt->irq);
atpdev->host_id[0] = host_id; atpdev->host_id[0] = host_id;
atpdev->global_map[0] = atp_readb_base(atpdev, 0x35); atpdev->global_map[0] = atp_readb_base(atpdev, 0x35);
atpdev->ultra_map[0] = atp_readw_base(atpdev, 0x3c); atpdev->ultra_map[0] = atp_readw_base(atpdev, 0x3c);
n = 0x3f09; n = 0x3f09;
next_fblk_880: while (n < 0x4000) {
if (n >= 0x4000)
goto flash_ok_880;
m = 0; m = 0;
atp_writew_base(atpdev, 0x34, n); atp_writew_base(atpdev, 0x34, n);
n += 0x0002; n += 0x0002;
if (atp_readb_base(atpdev, 0x30) == 0xff) if (atp_readb_base(atpdev, 0x30) == 0xff)
goto flash_ok_880; break;
atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30); atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31); atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
...@@ -1354,25 +1301,21 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1354,25 +1301,21 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32); atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33); atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
n += 0x0018; n += 0x0018;
goto next_fblk_880; }
flash_ok_880:
atp_writew_base(atpdev, 0x34, 0); atp_writew_base(atpdev, 0x34, 0);
atpdev->ultra_map[0] = 0; atpdev->ultra_map[0] = 0;
atpdev->async[0] = 0; atpdev->async[0] = 0;
for (k = 0; k < 16; k++) { for (k = 0; k < 16; k++) {
n = 1; n = 1 << k;
n = n << k; if (atpdev->sp[0][k] > 1)
if (atpdev->sp[0][k] > 1) {
atpdev->ultra_map[0] |= n; atpdev->ultra_map[0] |= n;
} else { else
if (atpdev->sp[0][k] == 0) if (atpdev->sp[0][k] == 0)
atpdev->async[0] |= n; atpdev->async[0] |= n;
} }
}
atpdev->async[0] = ~(atpdev->async[0]); atpdev->async[0] = ~(atpdev->async[0]);
atp_writeb_base(atpdev, 0x35, atpdev->global_map[0]); atp_writeb_base(atpdev, 0x35, atpdev->global_map[0]);
k = atp_readb_base(atpdev, 0x38) & 0x80; k = atp_readb_base(atpdev, 0x38) & 0x80;
atp_writeb_base(atpdev, 0x38, k); atp_writeb_base(atpdev, 0x38, k);
atp_writeb_base(atpdev, 0x3b, 0x20); atp_writeb_base(atpdev, 0x3b, 0x20);
...@@ -1389,7 +1332,66 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1389,7 +1332,66 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
atp_writeb_base(atpdev, 0x38, 0xb0); atp_writeb_base(atpdev, 0x38, 0xb0);
shpnt->max_id = 16; shpnt->max_id = 16;
shpnt->this_id = host_id; shpnt->this_id = host_id;
} else if (is885(atpdev)) { }
/* return non-zero on detection */
static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
unsigned char k, m, c;
unsigned int error,n;
unsigned char host_id;
struct Scsi_Host *shpnt = NULL;
struct atp_unit *atpdev;
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" printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n"
, shpnt->io_port, shpnt->irq); , shpnt->io_port, shpnt->irq);
......
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