aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:31 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:31 -0500
commitc413b9b94d9a8e7548cc4b2e04b7df0439ce76fd (patch)
tree5d23110a0d1f87ad0c88fb1746194e532808eaab /drivers/ide/ide-probe.c
parent1ebf74936b1fccb5b65940f99ccddd74ec4d1fef (diff)
ide: add struct ide_port_info instances to legacy host drivers
* Remove 'struct pci_dev *dev' argument from ide_hwif_setup_dma(). * Un-static ide_hwif_setup_dma() and add CONFIG_BLK_DEV_IDEDMA_PCI=n version. * Add 'const struct ide_port_info *d' argument to ide_device_add[_all](). * Factor out generic ports init from ide_pci_setup_ports() to ide_init_port(), move it to ide-probe.c and call it in in ide_device_add_all() instead of ide_pci_setup_ports(). * Move ->mate setup to ide_device_add_all() from ide_port_init(). * Add IDE_HFLAG_NO_AUTOTUNE host flag for host drivers that don't enable ->autotune currently. * Setup hwif->chipset in ide_init_port() but iff pi->chipset is set (to not override setup done by ide_hwif_configure()). * Add ETRAX host handling to ide_device_add_all(). * cmd640.c: set IDE_HFLAG_ABUSE_* also for CONFIG_BLK_DEV_CMD640_ENHANCED=n. * pmac.c: make pmac_ide_setup_dma() return an error value and move DMA masks setup to pmac_ide_setup_device(). * Add 'struct ide_port_info' instances to legacy host drivers, pass them to ide_device_add() calls and then remove open-coded ports initialization. Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c82
1 files changed, 78 insertions, 4 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 98a8af44bf64..4c3d2cf3be5b 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1289,12 +1289,86 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1289 } 1289 }
1290} 1290}
1291 1291
1292int ide_device_add_all(u8 *idx) 1292static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
1293 const struct ide_port_info *d)
1293{ 1294{
1294 ide_hwif_t *hwif; 1295 if (d->chipset != ide_etrax100)
1296 hwif->channel = port;
1297
1298 if (d->chipset)
1299 hwif->chipset = d->chipset;
1300
1301 if (d->init_iops)
1302 d->init_iops(hwif);
1303
1304 if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0)
1305 ide_hwif_setup_dma(hwif, d);
1306
1307 if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) ||
1308 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
1309 hwif->irq = port ? 15 : 14;
1310
1311 hwif->host_flags = d->host_flags;
1312 hwif->pio_mask = d->pio_mask;
1313
1314 if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate)
1315 hwif->mate->serialized = hwif->serialized = 1;
1316
1317 if (d->host_flags & IDE_HFLAG_IO_32BIT) {
1318 hwif->drives[0].io_32bit = 1;
1319 hwif->drives[1].io_32bit = 1;
1320 }
1321
1322 if (d->host_flags & IDE_HFLAG_UNMASK_IRQS) {
1323 hwif->drives[0].unmask = 1;
1324 hwif->drives[1].unmask = 1;
1325 }
1326
1327 hwif->swdma_mask = d->swdma_mask;
1328 hwif->mwdma_mask = d->mwdma_mask;
1329 hwif->ultra_mask = d->udma_mask;
1330
1331 /* reset DMA masks only for SFF-style DMA controllers */
1332 if ((d->host_flags && IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0)
1333 hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0;
1334
1335 if ((d->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0) {
1336 hwif->drives[0].autotune = 1;
1337 hwif->drives[1].autotune = 1;
1338 }
1339
1340 if (d->host_flags & IDE_HFLAG_RQSIZE_256)
1341 hwif->rqsize = 256;
1342
1343 /* call chipset specific routine for each enabled port */
1344 if (d->init_hwif)
1345 d->init_hwif(hwif);
1346}
1347
1348int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
1349{
1350 ide_hwif_t *hwif, *mate = NULL;
1295 int i, rc = 0; 1351 int i, rc = 0;
1296 1352
1297 for (i = 0; i < MAX_HWIFS; i++) { 1353 for (i = 0; i < MAX_HWIFS; i++) {
1354 if (d == NULL || idx[i] == 0xff) {
1355 mate = NULL;
1356 continue;
1357 }
1358
1359 hwif = &ide_hwifs[idx[i]];
1360
1361 if (d->chipset != ide_etrax100 && (i & 1) && mate) {
1362 hwif->mate = mate;
1363 mate->mate = hwif;
1364 }
1365
1366 mate = (i & 1) ? NULL : hwif;
1367
1368 ide_init_port(hwif, i & 1, d);
1369 }
1370
1371 for (i = 0; i < MAX_HWIFS; i++) {
1298 if (idx[i] == 0xff) 1372 if (idx[i] == 0xff)
1299 continue; 1373 continue;
1300 1374
@@ -1362,7 +1436,7 @@ int ide_device_add_all(u8 *idx)
1362} 1436}
1363EXPORT_SYMBOL_GPL(ide_device_add_all); 1437EXPORT_SYMBOL_GPL(ide_device_add_all);
1364 1438
1365int ide_device_add(u8 idx[4]) 1439int ide_device_add(u8 idx[4], const struct ide_port_info *d)
1366{ 1440{
1367 u8 idx_all[MAX_HWIFS]; 1441 u8 idx_all[MAX_HWIFS];
1368 int i; 1442 int i;
@@ -1370,6 +1444,6 @@ int ide_device_add(u8 idx[4])
1370 for (i = 0; i < MAX_HWIFS; i++) 1444 for (i = 0; i < MAX_HWIFS; i++)
1371 idx_all[i] = (i < 4) ? idx[i] : 0xff; 1445 idx_all[i] = (i < 4) ? idx[i] : 0xff;
1372 1446
1373 return ide_device_add_all(idx_all); 1447 return ide_device_add_all(idx_all, d);
1374} 1448}
1375EXPORT_SYMBOL_GPL(ide_device_add); 1449EXPORT_SYMBOL_GPL(ide_device_add);