summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Zary <linux@rainbow-software.org>2015-11-17 13:24:26 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2015-11-25 22:08:54 -0500
commitc7e6a0298d56694d79189cd9127ac8ec1c2275ca (patch)
treeee2a1e1a8715899718daa5a86d4a01e5752c83f2
parentf5f53a38c2f8671f9fc249c711411ba44d76a618 (diff)
atp870u: Introduce atp880_init()
Move 880-specific init code to a separate function atp880_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>
-rw-r--r--drivers/scsi/atp870u.c174
1 files changed, 88 insertions, 86 deletions
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index 3c66539e5781..c1fd9fb8d40f 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -1249,6 +1249,91 @@ static void atp_set_host_id(struct atp_unit *atp, u8 c, u8 host_id)
1249 atp_writeb_io(atp, c, 0x11, 0x20); 1249 atp_writeb_io(atp, c, 0x11, 0x20);
1250} 1250}
1251 1251
1252static void atp880_init(struct Scsi_Host *shpnt)
1253{
1254 struct atp_unit *atpdev = shost_priv(shpnt);
1255 struct pci_dev *pdev = atpdev->pdev;
1256 unsigned char k, m, host_id;
1257 unsigned int n;
1258
1259 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);
1260
1261 atpdev->ioport[0] = shpnt->io_port + 0x40;
1262 atpdev->pciport[0] = shpnt->io_port + 0x28;
1263
1264 host_id = atp_readb_base(atpdev, 0x39) >> 4;
1265
1266 dev_info(&pdev->dev, "ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n",
1267 shpnt->io_port, shpnt->irq);
1268 atpdev->host_id[0] = host_id;
1269
1270 atpdev->global_map[0] = atp_readb_base(atpdev, 0x35);
1271 atpdev->ultra_map[0] = atp_readw_base(atpdev, 0x3c);
1272
1273 n = 0x3f09;
1274 while (n < 0x4000) {
1275 m = 0;
1276 atp_writew_base(atpdev, 0x34, n);
1277 n += 0x0002;
1278 if (atp_readb_base(atpdev, 0x30) == 0xff)
1279 break;
1280
1281 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1282 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1283 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1284 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1285 atp_writew_base(atpdev, 0x34, n);
1286 n += 0x0002;
1287 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1288 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1289 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1290 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1291 atp_writew_base(atpdev, 0x34, n);
1292 n += 0x0002;
1293 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1294 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1295 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1296 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1297 atp_writew_base(atpdev, 0x34, n);
1298 n += 0x0002;
1299 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1300 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1301 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1302 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1303 n += 0x0018;
1304 }
1305 atp_writew_base(atpdev, 0x34, 0);
1306 atpdev->ultra_map[0] = 0;
1307 atpdev->async[0] = 0;
1308 for (k = 0; k < 16; k++) {
1309 n = 1 << k;
1310 if (atpdev->sp[0][k] > 1)
1311 atpdev->ultra_map[0] |= n;
1312 else
1313 if (atpdev->sp[0][k] == 0)
1314 atpdev->async[0] |= n;
1315 }
1316 atpdev->async[0] = ~(atpdev->async[0]);
1317 atp_writeb_base(atpdev, 0x35, atpdev->global_map[0]);
1318
1319 k = atp_readb_base(atpdev, 0x38) & 0x80;
1320 atp_writeb_base(atpdev, 0x38, k);
1321 atp_writeb_base(atpdev, 0x3b, 0x20);
1322 mdelay(32);
1323 atp_writeb_base(atpdev, 0x3b, 0);
1324 mdelay(32);
1325 atp_readb_io(atpdev, 0, 0x1b);
1326 atp_readb_io(atpdev, 0, 0x17);
1327
1328 atp_set_host_id(atpdev, 0, host_id);
1329
1330 tscam(shpnt, true, atp_readb_base(atpdev, 0x22));
1331 atp_is(atpdev, 0, true, atp_readb_base(atpdev, 0x3f) & 0x40);
1332 atp_writeb_base(atpdev, 0x38, 0xb0);
1333 shpnt->max_id = 16;
1334 shpnt->this_id = host_id;
1335}
1336
1252/* return non-zero on detection */ 1337/* return non-zero on detection */
1253static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 1338static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1254{ 1339{
@@ -1304,92 +1389,9 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1304 goto unregister; 1389 goto unregister;
1305 } 1390 }
1306 1391
1307 if (is880(atpdev)) { 1392 if (is880(atpdev))
1308 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x80);//JCC082803 1393 atp880_init(shpnt);
1309 1394 else if (is885(atpdev)) {
1310 atpdev->ioport[0] = shpnt->io_port + 0x40;
1311 atpdev->pciport[0] = shpnt->io_port + 0x28;
1312
1313 host_id = atp_readb_base(atpdev, 0x39);
1314 host_id >>= 0x04;
1315
1316 printk(KERN_INFO " ACARD AEC-67160 PCI Ultra3 LVD Host Adapter:"
1317 " IO:%lx, IRQ:%d.\n", shpnt->io_port, shpnt->irq);
1318 atpdev->host_id[0] = host_id;
1319
1320 atpdev->global_map[0] = atp_readb_base(atpdev, 0x35);
1321 atpdev->ultra_map[0] = atp_readw_base(atpdev, 0x3c);
1322
1323 n = 0x3f09;
1324next_fblk_880:
1325 if (n >= 0x4000)
1326 goto flash_ok_880;
1327
1328 m = 0;
1329 atp_writew_base(atpdev, 0x34, n);
1330 n += 0x0002;
1331 if (atp_readb_base(atpdev, 0x30) == 0xff)
1332 goto flash_ok_880;
1333
1334 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1335 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1336 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1337 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1338 atp_writew_base(atpdev, 0x34, n);
1339 n += 0x0002;
1340 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1341 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1342 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1343 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1344 atp_writew_base(atpdev, 0x34, n);
1345 n += 0x0002;
1346 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1347 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1348 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1349 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1350 atp_writew_base(atpdev, 0x34, n);
1351 n += 0x0002;
1352 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x30);
1353 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x31);
1354 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x32);
1355 atpdev->sp[0][m++] = atp_readb_base(atpdev, 0x33);
1356 n += 0x0018;
1357 goto next_fblk_880;
1358flash_ok_880:
1359 atp_writew_base(atpdev, 0x34, 0);
1360 atpdev->ultra_map[0] = 0;
1361 atpdev->async[0] = 0;
1362 for (k = 0; k < 16; k++) {
1363 n = 1;
1364 n = n << k;
1365 if (atpdev->sp[0][k] > 1) {
1366 atpdev->ultra_map[0] |= n;
1367 } else {
1368 if (atpdev->sp[0][k] == 0)
1369 atpdev->async[0] |= n;
1370 }
1371 }
1372 atpdev->async[0] = ~(atpdev->async[0]);
1373 atp_writeb_base(atpdev, 0x35, atpdev->global_map[0]);
1374
1375
1376 k = atp_readb_base(atpdev, 0x38) & 0x80;
1377 atp_writeb_base(atpdev, 0x38, k);
1378 atp_writeb_base(atpdev, 0x3b, 0x20);
1379 mdelay(32);
1380 atp_writeb_base(atpdev, 0x3b, 0);
1381 mdelay(32);
1382 atp_readb_io(atpdev, 0, 0x1b);
1383 atp_readb_io(atpdev, 0, 0x17);
1384
1385 atp_set_host_id(atpdev, 0, host_id);
1386
1387 tscam(shpnt, true, atp_readb_base(atpdev, 0x22));
1388 atp_is(atpdev, 0, true, atp_readb_base(atpdev, 0x3f) & 0x40);
1389 atp_writeb_base(atpdev, 0x38, 0xb0);
1390 shpnt->max_id = 16;
1391 shpnt->this_id = host_id;
1392 } else if (is885(atpdev)) {
1393 printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n" 1395 printk(KERN_INFO " ACARD AEC-67162 PCI Ultra3 LVD Host Adapter: IO:%lx, IRQ:%d.\n"
1394 , shpnt->io_port, shpnt->irq); 1396 , shpnt->io_port, shpnt->irq);
1395 1397