Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ondrej Zary and committed by
Martin K. Petersen
ecc6ff95 c7e6a029

+113 -118
+113 -118
drivers/scsi/atp870u.c
··· 1334 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 1445 /* return non-zero on detection */ 1338 1446 static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 1339 1447 { 1340 - unsigned char k, m, c; 1341 - unsigned int error,n; 1448 + unsigned char k; 1449 + unsigned int error; 1342 1450 unsigned char host_id; 1343 1451 struct Scsi_Host *shpnt = NULL; 1344 1452 struct atp_unit *atpdev; 1345 - unsigned char setupdata[2][16]; 1346 1453 int err; 1347 1454 1348 1455 if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 && pdev->revision < 2) { ··· 1498 1391 1499 1392 if (is880(atpdev)) 1500 1393 atp880_init(shpnt); 1501 - else if (is885(atpdev)) { 1502 - printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" 1503 - , shpnt->io_port, shpnt->irq); 1504 - 1505 - atpdev->pdev = pdev; 1506 - atpdev->ioport[0] = shpnt->io_port + 0x80; 1507 - atpdev->ioport[1] = shpnt->io_port + 0xc0; 1508 - atpdev->pciport[0] = shpnt->io_port + 0x40; 1509 - atpdev->pciport[1] = shpnt->io_port + 0x50; 1510 - 1511 - c = atp_readb_base(atpdev, 0x29); 1512 - atp_writeb_base(atpdev, 0x29, c | 0x04); 1513 - 1514 - n=0x1f80; 1515 - next_fblk_885: 1516 - if (n >= 0x2000) { 1517 - goto flash_ok_885; 1518 - } 1519 - atp_writew_base(atpdev, 0x3c, n); 1520 - if (atp_readl_base(atpdev, 0x38) == 0xffffffff) { 1521 - goto flash_ok_885; 1522 - } 1523 - for (m=0; m < 2; m++) { 1524 - atpdev->global_map[m]= 0; 1525 - for (k=0; k < 4; k++) { 1526 - atp_writew_base(atpdev, 0x3c, n++); 1527 - ((unsigned long *)&setupdata[m][0])[k] = atp_readl_base(atpdev, 0x38); 1528 - } 1529 - for (k=0; k < 4; k++) { 1530 - atp_writew_base(atpdev, 0x3c, n++); 1531 - ((unsigned long *)&atpdev->sp[m][0])[k] = atp_readl_base(atpdev, 0x38); 1532 - } 1533 - n += 8; 1534 - } 1535 - goto next_fblk_885; 1536 - flash_ok_885: 1537 - #ifdef ED_DBGP 1538 - printk( "Flash Read OK\n"); 1539 - #endif 1540 - c = atp_readb_base(atpdev, 0x29); 1541 - atp_writeb_base(atpdev, 0x29, c & 0xfb); 1542 - for (c=0;c < 2;c++) { 1543 - atpdev->ultra_map[c]=0; 1544 - atpdev->async[c] = 0; 1545 - for (k=0; k < 16; k++) { 1546 - n=1; 1547 - n = n << k; 1548 - if (atpdev->sp[c][k] > 1) { 1549 - atpdev->ultra_map[c] |= n; 1550 - } else { 1551 - if (atpdev->sp[c][k] == 0) { 1552 - atpdev->async[c] |= n; 1553 - } 1554 - } 1555 - } 1556 - atpdev->async[c] = ~(atpdev->async[c]); 1557 - 1558 - if (atpdev->global_map[c] == 0) { 1559 - k=setupdata[c][1]; 1560 - if ((k & 0x40) != 0) 1561 - atpdev->global_map[c] |= 0x20; 1562 - k &= 0x07; 1563 - atpdev->global_map[c] |= k; 1564 - if ((setupdata[c][2] & 0x04) != 0) 1565 - atpdev->global_map[c] |= 0x08; 1566 - atpdev->host_id[c] = setupdata[c][0] & 0x07; 1567 - } 1568 - } 1569 - 1570 - k = atp_readb_base(atpdev, 0x28) & 0x8f; 1571 - k |= 0x10; 1572 - atp_writeb_base(atpdev, 0x28, k); 1573 - atp_writeb_pci(atpdev, 0, 1, 0x80); 1574 - atp_writeb_pci(atpdev, 1, 1, 0x80); 1575 - mdelay(100); 1576 - atp_writeb_pci(atpdev, 0, 1, 0); 1577 - atp_writeb_pci(atpdev, 1, 1, 0); 1578 - mdelay(1000); 1579 - atp_readb_io(atpdev, 0, 0x1b); 1580 - atp_readb_io(atpdev, 0, 0x17); 1581 - atp_readb_io(atpdev, 1, 0x1b); 1582 - atp_readb_io(atpdev, 1, 0x17); 1583 - 1584 - k=atpdev->host_id[0]; 1585 - if (k > 7) 1586 - k = (k & 0x07) | 0x40; 1587 - atp_set_host_id(atpdev, 0, k); 1588 - 1589 - k=atpdev->host_id[1]; 1590 - if (k > 7) 1591 - k = (k & 0x07) | 0x40; 1592 - atp_set_host_id(atpdev, 1, k); 1593 - 1594 - mdelay(600); /* this delay used to be called tscam_885() */ 1595 - printk(KERN_INFO " Scanning Channel A SCSI Device ...\n"); 1596 - atp_is(atpdev, 0, true, atp_readb_io(atpdev, 0, 0x1b) >> 7); 1597 - atp_writeb_io(atpdev, 0, 0x16, 0x80); 1598 - printk(KERN_INFO " Scanning Channel B SCSI Device ...\n"); 1599 - atp_is(atpdev, 1, true, atp_readb_io(atpdev, 1, 0x1b) >> 7); 1600 - atp_writeb_io(atpdev, 1, 0x16, 0x80); 1601 - k = atp_readb_base(atpdev, 0x28) & 0xcf; 1602 - k |= 0xc0; 1603 - atp_writeb_base(atpdev, 0x28, k); 1604 - k = atp_readb_base(atpdev, 0x1f) | 0x80; 1605 - atp_writeb_base(atpdev, 0x1f, k); 1606 - k = atp_readb_base(atpdev, 0x29) | 0x01; 1607 - atp_writeb_base(atpdev, 0x29, k); 1608 - #ifdef ED_DBGP 1609 - //printk("atp885: atp_host[0] 0x%p\n", atp_host[0]); 1610 - #endif 1611 - shpnt->max_id = 16; 1612 - shpnt->max_lun = (atpdev->global_map[0] & 0x07) + 1; 1613 - shpnt->max_channel = 1; 1614 - shpnt->this_id = atpdev->host_id[0]; 1615 - } else { 1394 + else if (is885(atpdev)) 1395 + atp885_init(shpnt); 1396 + else { 1616 1397 u8 scam_on; 1617 1398 bool wide_chip = 1618 1399 (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610 &&