diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2015-11-17 13:24:27 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2015-11-25 22:08:54 -0500 |
commit | ecc6ff95d1a84f0a025112e071be40dd905a5168 (patch) | |
tree | 9c6ab4a49089cecac4e26ad6c701481d16a05c9d /drivers/scsi/atp870u.c | |
parent | c7e6a0298d56694d79189cd9127ac8ec1c2275ca (diff) |
atp870u: Introduce atp885_init()
Move 885-specific init code to a separate function atp885_init()
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/atp870u.c')
-rw-r--r-- | drivers/scsi/atp870u.c | 231 |
1 files changed, 113 insertions, 118 deletions
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c index c1fd9fb8d40f..584b90f46212 100644 --- a/drivers/scsi/atp870u.c +++ b/drivers/scsi/atp870u.c | |||
@@ -1334,15 +1334,122 @@ static void atp880_init(struct Scsi_Host *shpnt) | |||
1334 | shpnt->this_id = host_id; | 1334 | shpnt->this_id = host_id; |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | static void atp885_init(struct Scsi_Host *shpnt) | ||
1338 | { | ||
1339 | struct atp_unit *atpdev = shost_priv(shpnt); | ||
1340 | struct pci_dev *pdev = atpdev->pdev; | ||
1341 | unsigned char k, m, c; | ||
1342 | unsigned int n; | ||
1343 | unsigned char setupdata[2][16]; | ||
1344 | |||
1345 | dev_info(&pdev->dev, "ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n", | ||
1346 | shpnt->io_port, shpnt->irq); | ||
1347 | |||
1348 | atpdev->ioport[0] = shpnt->io_port + 0x80; | ||
1349 | atpdev->ioport[1] = shpnt->io_port + 0xc0; | ||
1350 | atpdev->pciport[0] = shpnt->io_port + 0x40; | ||
1351 | atpdev->pciport[1] = shpnt->io_port + 0x50; | ||
1352 | |||
1353 | c = atp_readb_base(atpdev, 0x29); | ||
1354 | atp_writeb_base(atpdev, 0x29, c | 0x04); | ||
1355 | |||
1356 | n = 0x1f80; | ||
1357 | while (n < 0x2000) { | ||
1358 | atp_writew_base(atpdev, 0x3c, n); | ||
1359 | if (atp_readl_base(atpdev, 0x38) == 0xffffffff) | ||
1360 | break; | ||
1361 | for (m = 0; m < 2; m++) { | ||
1362 | atpdev->global_map[m] = 0; | ||
1363 | for (k = 0; k < 4; k++) { | ||
1364 | atp_writew_base(atpdev, 0x3c, n++); | ||
1365 | ((unsigned long *)&setupdata[m][0])[k] = atp_readl_base(atpdev, 0x38); | ||
1366 | } | ||
1367 | for (k = 0; k < 4; k++) { | ||
1368 | atp_writew_base(atpdev, 0x3c, n++); | ||
1369 | ((unsigned long *)&atpdev->sp[m][0])[k] = atp_readl_base(atpdev, 0x38); | ||
1370 | } | ||
1371 | n += 8; | ||
1372 | } | ||
1373 | } | ||
1374 | c = atp_readb_base(atpdev, 0x29); | ||
1375 | atp_writeb_base(atpdev, 0x29, c & 0xfb); | ||
1376 | for (c = 0; c < 2; c++) { | ||
1377 | atpdev->ultra_map[c] = 0; | ||
1378 | atpdev->async[c] = 0; | ||
1379 | for (k = 0; k < 16; k++) { | ||
1380 | n = 1 << k; | ||
1381 | if (atpdev->sp[c][k] > 1) | ||
1382 | atpdev->ultra_map[c] |= n; | ||
1383 | else | ||
1384 | if (atpdev->sp[c][k] == 0) | ||
1385 | atpdev->async[c] |= n; | ||
1386 | } | ||
1387 | atpdev->async[c] = ~(atpdev->async[c]); | ||
1388 | |||
1389 | if (atpdev->global_map[c] == 0) { | ||
1390 | k = setupdata[c][1]; | ||
1391 | if ((k & 0x40) != 0) | ||
1392 | atpdev->global_map[c] |= 0x20; | ||
1393 | k &= 0x07; | ||
1394 | atpdev->global_map[c] |= k; | ||
1395 | if ((setupdata[c][2] & 0x04) != 0) | ||
1396 | atpdev->global_map[c] |= 0x08; | ||
1397 | atpdev->host_id[c] = setupdata[c][0] & 0x07; | ||
1398 | } | ||
1399 | } | ||
1400 | |||
1401 | k = atp_readb_base(atpdev, 0x28) & 0x8f; | ||
1402 | k |= 0x10; | ||
1403 | atp_writeb_base(atpdev, 0x28, k); | ||
1404 | atp_writeb_pci(atpdev, 0, 1, 0x80); | ||
1405 | atp_writeb_pci(atpdev, 1, 1, 0x80); | ||
1406 | mdelay(100); | ||
1407 | atp_writeb_pci(atpdev, 0, 1, 0); | ||
1408 | atp_writeb_pci(atpdev, 1, 1, 0); | ||
1409 | mdelay(1000); | ||
1410 | atp_readb_io(atpdev, 0, 0x1b); | ||
1411 | atp_readb_io(atpdev, 0, 0x17); | ||
1412 | atp_readb_io(atpdev, 1, 0x1b); | ||
1413 | atp_readb_io(atpdev, 1, 0x17); | ||
1414 | |||
1415 | k = atpdev->host_id[0]; | ||
1416 | if (k > 7) | ||
1417 | k = (k & 0x07) | 0x40; | ||
1418 | atp_set_host_id(atpdev, 0, k); | ||
1419 | |||
1420 | k = atpdev->host_id[1]; | ||
1421 | if (k > 7) | ||
1422 | k = (k & 0x07) | 0x40; | ||
1423 | atp_set_host_id(atpdev, 1, k); | ||
1424 | |||
1425 | mdelay(600); /* this delay used to be called tscam_885() */ | ||
1426 | dev_info(&pdev->dev, "Scanning Channel A SCSI Device ...\n"); | ||
1427 | atp_is(atpdev, 0, true, atp_readb_io(atpdev, 0, 0x1b) >> 7); | ||
1428 | atp_writeb_io(atpdev, 0, 0x16, 0x80); | ||
1429 | dev_info(&pdev->dev, "Scanning Channel B SCSI Device ...\n"); | ||
1430 | atp_is(atpdev, 1, true, atp_readb_io(atpdev, 1, 0x1b) >> 7); | ||
1431 | atp_writeb_io(atpdev, 1, 0x16, 0x80); | ||
1432 | k = atp_readb_base(atpdev, 0x28) & 0xcf; | ||
1433 | k |= 0xc0; | ||
1434 | atp_writeb_base(atpdev, 0x28, k); | ||
1435 | k = atp_readb_base(atpdev, 0x1f) | 0x80; | ||
1436 | atp_writeb_base(atpdev, 0x1f, k); | ||
1437 | k = atp_readb_base(atpdev, 0x29) | 0x01; | ||
1438 | atp_writeb_base(atpdev, 0x29, k); | ||
1439 | shpnt->max_id = 16; | ||
1440 | shpnt->max_lun = (atpdev->global_map[0] & 0x07) + 1; | ||
1441 | shpnt->max_channel = 1; | ||
1442 | shpnt->this_id = atpdev->host_id[0]; | ||
1443 | } | ||
1444 | |||
1337 | /* return non-zero on detection */ | 1445 | /* return non-zero on detection */ |
1338 | static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 1446 | static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
1339 | { | 1447 | { |
1340 | unsigned char k, m, c; | 1448 | unsigned char k; |
1341 | unsigned int error,n; | 1449 | unsigned int error; |
1342 | unsigned char host_id; | 1450 | unsigned char host_id; |
1343 | struct Scsi_Host *shpnt = NULL; | 1451 | struct Scsi_Host *shpnt = NULL; |
1344 | struct atp_unit *atpdev; | 1452 | struct atp_unit *atpdev; |
1345 | unsigned char setupdata[2][16]; | ||
1346 | int err; | 1453 | int err; |
1347 | 1454 | ||
1348 | if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision < 2) { | 1455 | if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision < 2) { |
@@ -1391,121 +1498,9 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1391 | 1498 | ||
1392 | if (is880(atpdev)) | 1499 | if (is880(atpdev)) |
1393 | atp880_init(shpnt); | 1500 | atp880_init(shpnt); |
1394 | else if (is885(atpdev)) { | 1501 | else if (is885(atpdev)) |
1395 | printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" | 1502 | atp885_init(shpnt); |
1396 | , shpnt->io_port, shpnt->irq); | 1503 | else { |
1397 | |||
1398 | atpdev->pdev = pdev; | ||
1399 | atpdev->ioport[0] = shpnt->io_port + 0x80; | ||
1400 | atpdev->ioport[1] = shpnt->io_port + 0xc0; | ||
1401 | atpdev->pciport[0] = shpnt->io_port + 0x40; | ||
1402 | atpdev->pciport[1] = shpnt->io_port + 0x50; | ||
1403 | |||
1404 | c = atp_readb_base(atpdev, 0x29); | ||
1405 | atp_writeb_base(atpdev, 0x29, c | 0x04); | ||
1406 | |||
1407 | n=0x1f80; | ||
1408 | next_fblk_885: | ||
1409 | if (n >= 0x2000) { | ||
1410 | goto flash_ok_885; | ||
1411 | } | ||
1412 | atp_writew_base(atpdev, 0x3c, n); | ||
1413 | if (atp_readl_base(atpdev, 0x38) == 0xffffffff) { | ||
1414 | goto flash_ok_885; | ||
1415 | } | ||
1416 | for (m=0; m < 2; m++) { | ||
1417 | atpdev->global_map[m]= 0; | ||
1418 | for (k=0; k < 4; k++) { | ||
1419 | atp_writew_base(atpdev, 0x3c, n++); | ||
1420 | ((unsigned long *)&setupdata[m][0])[k] = atp_readl_base(atpdev, 0x38); | ||
1421 | } | ||
1422 | for (k=0; k < 4; k++) { | ||
1423 | atp_writew_base(atpdev, 0x3c, n++); | ||
1424 | ((unsigned long *)&atpdev->sp[m][0])[k] = atp_readl_base(atpdev, 0x38); | ||
1425 | } | ||
1426 | n += 8; | ||
1427 | } | ||
1428 | goto next_fblk_885; | ||
1429 | flash_ok_885: | ||
1430 | #ifdef ED_DBGP | ||
1431 | printk( "Flash Read OK\n"); | ||
1432 | #endif | ||
1433 | c = atp_readb_base(atpdev, 0x29); | ||
1434 | atp_writeb_base(atpdev, 0x29, c & 0xfb); | ||
1435 | for (c=0;c < 2;c++) { | ||
1436 | atpdev->ultra_map[c]=0; | ||
1437 | atpdev->async[c] = 0; | ||
1438 | for (k=0; k < 16; k++) { | ||
1439 | n=1; | ||
1440 | n = n << k; | ||
1441 | if (atpdev->sp[c][k] > 1) { | ||
1442 | atpdev->ultra_map[c] |= n; | ||
1443 | } else { | ||
1444 | if (atpdev->sp[c][k] == 0) { | ||
1445 | atpdev->async[c] |= n; | ||
1446 | } | ||
1447 | } | ||
1448 | } | ||
1449 | atpdev->async[c] = ~(atpdev->async[c]); | ||
1450 | |||
1451 | if (atpdev->global_map[c] == 0) { | ||
1452 | k=setupdata[c][1]; | ||
1453 | if ((k & 0x40) != 0) | ||
1454 | atpdev->global_map[c] |= 0x20; | ||
1455 | k &= 0x07; | ||
1456 | atpdev->global_map[c] |= k; | ||
1457 | if ((setupdata[c][2] & 0x04) != 0) | ||
1458 | atpdev->global_map[c] |= 0x08; | ||
1459 | atpdev->host_id[c] = setupdata[c][0] & 0x07; | ||
1460 | } | ||
1461 | } | ||
1462 | |||
1463 | k = atp_readb_base(atpdev, 0x28) & 0x8f; | ||
1464 | k |= 0x10; | ||
1465 | atp_writeb_base(atpdev, 0x28, k); | ||
1466 | atp_writeb_pci(atpdev, 0, 1, 0x80); | ||
1467 | atp_writeb_pci(atpdev, 1, 1, 0x80); | ||
1468 | mdelay(100); | ||
1469 | atp_writeb_pci(atpdev, 0, 1, 0); | ||
1470 | atp_writeb_pci(atpdev, 1, 1, 0); | ||
1471 | mdelay(1000); | ||
1472 | atp_readb_io(atpdev, 0, 0x1b); | ||
1473 | atp_readb_io(atpdev, 0, 0x17); | ||
1474 | atp_readb_io(atpdev, 1, 0x1b); | ||
1475 | atp_readb_io(atpdev, 1, 0x17); | ||
1476 | |||
1477 | k=atpdev->host_id[0]; | ||
1478 | if (k > 7) | ||
1479 | k = (k & 0x07) | 0x40; | ||
1480 | atp_set_host_id(atpdev, 0, k); | ||
1481 | |||
1482 | k=atpdev->host_id[1]; | ||
1483 | if (k > 7) | ||
1484 | k = (k & 0x07) | 0x40; | ||
1485 | atp_set_host_id(atpdev, 1, k); | ||
1486 | |||
1487 | mdelay(600); /* this delay used to be called tscam_885() */ | ||
1488 | printk(KERN_INFO " Scanning Channel A SCSI Device ...\n"); | ||
1489 | atp_is(atpdev, 0, true, atp_readb_io(atpdev, 0, 0x1b) >> 7); | ||
1490 | atp_writeb_io(atpdev, 0, 0x16, 0x80); | ||
1491 | printk(KERN_INFO " Scanning Channel B SCSI Device ...\n"); | ||
1492 | atp_is(atpdev, 1, true, atp_readb_io(atpdev, 1, 0x1b) >> 7); | ||
1493 | atp_writeb_io(atpdev, 1, 0x16, 0x80); | ||
1494 | k = atp_readb_base(atpdev, 0x28) & 0xcf; | ||
1495 | k |= 0xc0; | ||
1496 | atp_writeb_base(atpdev, 0x28, k); | ||
1497 | k = atp_readb_base(atpdev, 0x1f) | 0x80; | ||
1498 | atp_writeb_base(atpdev, 0x1f, k); | ||
1499 | k = atp_readb_base(atpdev, 0x29) | 0x01; | ||
1500 | atp_writeb_base(atpdev, 0x29, k); | ||
1501 | #ifdef ED_DBGP | ||
1502 | //printk("atp885: atp_host[0] 0x%p\n", atp_host[0]); | ||
1503 | #endif | ||
1504 | shpnt->max_id = 16; | ||
1505 | shpnt->max_lun = (atpdev->global_map[0] & 0x07) + 1; | ||
1506 | shpnt->max_channel = 1; | ||
1507 | shpnt->this_id = atpdev->host_id[0]; | ||
1508 | } else { | ||
1509 | u8 scam_on; | 1504 | u8 scam_on; |
1510 | bool wide_chip = | 1505 | bool wide_chip = |
1511 | (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && | 1506 | (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && |