Lines Matching refs:hwif

194 	ide_hwif_t *hwif = drive->hwif;  in do_identify()  local
202 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); in do_identify()
253 ide_hwif_t *hwif = drive->hwif; in ide_dev_read_id() local
254 struct ide_io_ports *io_ports = &hwif->io_ports; in ide_dev_read_id()
255 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_dev_read_id()
265 tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); in ide_dev_read_id()
274 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) { in ide_dev_read_id()
275 a = tp_ops->read_altstatus(hwif); in ide_dev_read_id()
276 s = tp_ops->read_status(hwif); in ide_dev_read_id()
299 tp_ops->exec_command(hwif, cmd); in ide_dev_read_id()
314 s = tp_ops->read_status(hwif); in ide_dev_read_id()
323 (void)tp_ops->read_status(hwif); in ide_dev_read_id()
333 ide_hwif_t *hwif = drive->hwif; in ide_busy_sleep() local
340 stat = altstatus ? hwif->tp_ops->read_altstatus(hwif) in ide_busy_sleep()
341 : hwif->tp_ops->read_status(hwif); in ide_busy_sleep()
355 drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_DEVICE); in ide_read_device()
383 ide_hwif_t *hwif = drive->hwif; in do_probe() local
384 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in do_probe()
409 tp_ops->dev_select(hwif->devices[0]); in do_probe()
417 stat = tp_ops->read_status(hwif); in do_probe()
426 stat = tp_ops->read_status(hwif); in do_probe()
437 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); in do_probe()
443 stat = tp_ops->read_status(hwif); in do_probe()
454 tp_ops->dev_select(hwif->devices[0]); in do_probe()
457 (void)tp_ops->read_status(hwif); in do_probe()
539 ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); in hwif_release_dev() local
541 complete(&hwif->gendev_rel_comp); in hwif_release_dev()
544 static int ide_register_port(ide_hwif_t *hwif) in ide_register_port() argument
549 dev_set_name(&hwif->gendev, "%s", hwif->name); in ide_register_port()
550 dev_set_drvdata(&hwif->gendev, hwif); in ide_register_port()
551 if (hwif->gendev.parent == NULL) in ide_register_port()
552 hwif->gendev.parent = hwif->dev; in ide_register_port()
553 hwif->gendev.release = hwif_release_dev; in ide_register_port()
555 ret = device_register(&hwif->gendev); in ide_register_port()
562 hwif->portdev = device_create(ide_port_class, &hwif->gendev, in ide_register_port()
563 MKDEV(0, 0), hwif, "%s", hwif->name); in ide_register_port()
564 if (IS_ERR(hwif->portdev)) { in ide_register_port()
565 ret = PTR_ERR(hwif->portdev); in ide_register_port()
566 device_unregister(&hwif->gendev); in ide_register_port()
598 static int ide_port_wait_ready(ide_hwif_t *hwif) in ide_port_wait_ready() argument
600 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_port_wait_ready()
604 printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); in ide_port_wait_ready()
614 rc = ide_wait_not_busy(hwif, 35000); in ide_port_wait_ready()
619 ide_port_for_each_dev(i, drive, hwif) { in ide_port_wait_ready()
624 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_port_wait_ready()
626 rc = ide_wait_not_busy(hwif, 35000); in ide_port_wait_ready()
636 tp_ops->dev_select(hwif->devices[0]); in ide_port_wait_ready()
652 ide_drive_t *dev0 = dev1->hwif->devices[0]; in ide_undecoded_slave()
679 static int ide_probe_port(ide_hwif_t *hwif) in ide_probe_port() argument
685 BUG_ON(hwif->present); in ide_probe_port()
687 if ((hwif->devices[0]->dev_flags & IDE_DFLAG_NOPROBE) && in ide_probe_port()
688 (hwif->devices[1]->dev_flags & IDE_DFLAG_NOPROBE)) in ide_probe_port()
695 irqd = hwif->irq; in ide_probe_port()
697 disable_irq(hwif->irq); in ide_probe_port()
699 if (ide_port_wait_ready(hwif) == -EBUSY) in ide_probe_port()
700 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); in ide_probe_port()
706 ide_port_for_each_dev(i, drive, hwif) { in ide_probe_port()
722 static void ide_port_tune_devices(ide_hwif_t *hwif) in ide_port_tune_devices() argument
724 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_tune_devices()
728 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
735 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
740 if (hwif->dma_ops) in ide_port_tune_devices()
759 ide_hwif_t *hwif = drive->hwif; in ide_init_queue() local
770 q = blk_alloc_queue_node(GFP_KERNEL, hwif_to_node(hwif), NULL); in ide_init_queue()
786 if (hwif->rqsize < max_sectors) in ide_init_queue()
787 max_sectors = hwif->rqsize; in ide_init_queue()
817 static int ide_port_setup_devices(ide_hwif_t *hwif) in ide_port_setup_devices() argument
823 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_setup_devices()
840 ide_hwif_t *hwif; in ide_host_enable_irqs() local
843 ide_host_for_each_port(i, hwif, host) { in ide_host_enable_irqs()
844 if (hwif == NULL) in ide_host_enable_irqs()
848 hwif->tp_ops->read_status(hwif); in ide_host_enable_irqs()
851 if (hwif->io_ports.ctl_addr) in ide_host_enable_irqs()
852 hwif->tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_host_enable_irqs()
859 static int init_irq (ide_hwif_t *hwif) in init_irq() argument
861 struct ide_io_ports *io_ports = &hwif->io_ports; in init_irq()
862 struct ide_host *host = hwif->host; in init_irq()
870 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) in init_irq()
874 printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, in init_irq()
876 io_ports->ctl_addr, hwif->irq); in init_irq()
878 printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, in init_irq()
879 io_ports->data_addr, hwif->irq); in init_irq()
881 if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) in init_irq()
898 ide_hwif_t *hwif = data; in ata_probe() local
900 ide_drive_t *drive = hwif->devices[unit]; in ata_probe()
951 ide_hwif_t *hwif = drive->hwif; in ide_init_disk() local
954 disk->major = hwif->major; in ide_init_disk()
956 sprintf(disk->disk_name, "hd%c", 'a' + hwif->index * MAX_DRIVES + unit); in ide_init_disk()
976 static int hwif_init(ide_hwif_t *hwif) in hwif_init() argument
978 if (!hwif->irq) { in hwif_init()
979 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name); in hwif_init()
983 if (register_blkdev(hwif->major, hwif->name)) in hwif_init()
986 if (!hwif->sg_max_nents) in hwif_init()
987 hwif->sg_max_nents = PRD_ENTRIES; in hwif_init()
989 hwif->sg_table = kmalloc_array(hwif->sg_max_nents, in hwif_init()
992 if (!hwif->sg_table) { in hwif_init()
993 printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); in hwif_init()
997 sg_init_table(hwif->sg_table, hwif->sg_max_nents); in hwif_init()
999 if (init_irq(hwif)) { in hwif_init()
1001 hwif->name, hwif->irq); in hwif_init()
1005 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, in hwif_init()
1006 THIS_MODULE, ata_probe, ata_lock, hwif); in hwif_init()
1010 unregister_blkdev(hwif->major, hwif->name); in hwif_init()
1014 static void hwif_register_devices(ide_hwif_t *hwif) in hwif_register_devices() argument
1019 ide_port_for_each_present_dev(i, drive, hwif) { in hwif_register_devices()
1023 dev_set_name(dev, "%u.%u", hwif->index, i); in hwif_register_devices()
1025 dev->parent = &hwif->gendev; in hwif_register_devices()
1036 static void ide_port_init_devices(ide_hwif_t *hwif) in ide_port_init_devices() argument
1038 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_init_devices()
1042 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices()
1043 drive->dn = i + hwif->channel * 2; in ide_port_init_devices()
1045 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) in ide_port_init_devices()
1047 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) in ide_port_init_devices()
1049 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) in ide_port_init_devices()
1051 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) in ide_port_init_devices()
1061 static void ide_init_port(ide_hwif_t *hwif, unsigned int port, in ide_init_port() argument
1064 hwif->channel = port; in ide_init_port()
1066 hwif->chipset = d->chipset ? d->chipset : ide_pci; in ide_init_port()
1069 d->init_iops(hwif); in ide_init_port()
1072 hwif->host_flags |= d->host_flags; in ide_init_port()
1073 hwif->pio_mask = d->pio_mask; in ide_init_port()
1076 hwif->tp_ops = d->tp_ops; in ide_init_port()
1079 if ((hwif->host_flags & IDE_HFLAG_DTC2278) == 0 || hwif->channel == 0) in ide_init_port()
1080 hwif->port_ops = d->port_ops; in ide_init_port()
1082 hwif->swdma_mask = d->swdma_mask; in ide_init_port()
1083 hwif->mwdma_mask = d->mwdma_mask; in ide_init_port()
1084 hwif->ultra_mask = d->udma_mask; in ide_init_port()
1089 hwif->dma_ops = d->dma_ops; in ide_init_port()
1092 rc = d->init_dma(hwif, d); in ide_init_port()
1094 rc = ide_hwif_setup_dma(hwif, d); in ide_init_port()
1097 printk(KERN_INFO "%s: DMA disabled\n", hwif->name); in ide_init_port()
1099 hwif->dma_ops = NULL; in ide_init_port()
1100 hwif->dma_base = 0; in ide_init_port()
1101 hwif->swdma_mask = 0; in ide_init_port()
1102 hwif->mwdma_mask = 0; in ide_init_port()
1103 hwif->ultra_mask = 0; in ide_init_port()
1108 ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) in ide_init_port()
1109 hwif->host->host_flags |= IDE_HFLAG_SERIALIZE; in ide_init_port()
1112 hwif->rqsize = d->max_sectors; in ide_init_port()
1114 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || in ide_init_port()
1115 (hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA)) in ide_init_port()
1116 hwif->rqsize = 256; in ide_init_port()
1118 hwif->rqsize = 65536; in ide_init_port()
1123 d->init_hwif(hwif); in ide_init_port()
1126 static void ide_port_cable_detect(ide_hwif_t *hwif) in ide_port_cable_detect() argument
1128 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_cable_detect()
1130 if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) { in ide_port_cable_detect()
1131 if (hwif->cbl != ATA_CBL_PATA40_SHORT) in ide_port_cable_detect()
1132 hwif->cbl = port_ops->cable_detect(hwif); in ide_port_cable_detect()
1140 static void ide_port_init_devices_data(ide_hwif_t *hwif) in ide_port_init_devices_data() argument
1145 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices_data()
1146 u8 j = (hwif->index * MAX_DRIVES) + i; in ide_port_init_devices_data()
1157 drive->hwif = hwif; in ide_port_init_devices_data()
1172 static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) in ide_init_port_data() argument
1175 hwif->index = index; in ide_init_port_data()
1176 hwif->major = ide_hwif_to_major[index]; in ide_init_port_data()
1178 hwif->name[0] = 'i'; in ide_init_port_data()
1179 hwif->name[1] = 'd'; in ide_init_port_data()
1180 hwif->name[2] = 'e'; in ide_init_port_data()
1181 hwif->name[3] = '0' + index; in ide_init_port_data()
1183 spin_lock_init(&hwif->lock); in ide_init_port_data()
1185 timer_setup(&hwif->timer, ide_timer_expiry, 0); in ide_init_port_data()
1187 init_completion(&hwif->gendev_rel_comp); in ide_init_port_data()
1189 hwif->tp_ops = &default_tp_ops; in ide_init_port_data()
1191 ide_port_init_devices_data(hwif); in ide_init_port_data()
1194 static void ide_init_port_hw(ide_hwif_t *hwif, struct ide_hw *hw) in ide_init_port_hw() argument
1196 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); in ide_init_port_hw()
1197 hwif->irq = hw->irq; in ide_init_port_hw()
1198 hwif->dev = hw->dev; in ide_init_port_hw()
1199 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; in ide_init_port_hw()
1200 hwif->config_data = hw->config; in ide_init_port_hw()
1252 static void ide_port_free_devices(ide_hwif_t *hwif) in ide_port_free_devices() argument
1257 ide_port_for_each_dev(i, drive, hwif) { in ide_port_free_devices()
1264 static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) in ide_port_alloc_devices() argument
1291 hwif->devices[i] = drive; in ide_port_alloc_devices()
1300 ide_port_free_devices(hwif); in ide_port_alloc_devices()
1317 ide_hwif_t *hwif; in ide_host_alloc() local
1323 hwif = kzalloc_node(sizeof(*hwif), GFP_KERNEL, node); in ide_host_alloc()
1324 if (hwif == NULL) in ide_host_alloc()
1327 if (ide_port_alloc_devices(hwif, node) < 0) { in ide_host_alloc()
1328 kfree(hwif); in ide_host_alloc()
1336 ide_port_free_devices(hwif); in ide_host_alloc()
1337 kfree(hwif); in ide_host_alloc()
1341 ide_init_port_data(hwif, idx); in ide_host_alloc()
1343 hwif->host = host; in ide_host_alloc()
1345 host->ports[i] = hwif; in ide_host_alloc()
1368 static void ide_port_free(ide_hwif_t *hwif) in ide_port_free() argument
1370 ide_port_free_devices(hwif); in ide_port_free()
1371 ide_free_port_slot(hwif->index); in ide_port_free()
1372 kfree(hwif); in ide_port_free()
1375 static void ide_disable_port(ide_hwif_t *hwif) in ide_disable_port() argument
1377 struct ide_host *host = hwif->host; in ide_disable_port()
1380 printk(KERN_INFO "%s: disabling port\n", hwif->name); in ide_disable_port()
1383 if (host->ports[i] == hwif) { in ide_disable_port()
1389 ide_port_free(hwif); in ide_disable_port()
1395 ide_hwif_t *hwif, *mate = NULL; in ide_host_register() local
1398 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1399 if (hwif == NULL) { in ide_host_register()
1404 ide_init_port_hw(hwif, hws[i]); in ide_host_register()
1405 ide_port_apply_params(hwif); in ide_host_register()
1408 hwif->mate = mate; in ide_host_register()
1409 mate->mate = hwif; in ide_host_register()
1412 mate = (i & 1) ? NULL : hwif; in ide_host_register()
1414 ide_init_port(hwif, i & 1, d); in ide_host_register()
1415 ide_port_cable_detect(hwif); in ide_host_register()
1417 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_host_register()
1419 ide_port_init_devices(hwif); in ide_host_register()
1422 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1423 if (hwif == NULL) in ide_host_register()
1426 if (ide_probe_port(hwif) == 0) in ide_host_register()
1427 hwif->present = 1; in ide_host_register()
1429 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_host_register()
1431 if ((hwif->host_flags & IDE_HFLAG_4DRIVES) == 0 || in ide_host_register()
1432 hwif->mate == NULL || hwif->mate->present == 0) { in ide_host_register()
1433 if (ide_register_port(hwif)) { in ide_host_register()
1434 ide_disable_port(hwif); in ide_host_register()
1439 if (hwif->present) in ide_host_register()
1440 ide_port_tune_devices(hwif); in ide_host_register()
1445 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1446 if (hwif == NULL) in ide_host_register()
1449 if (hwif_init(hwif) == 0) { in ide_host_register()
1451 "interface\n", hwif->name); in ide_host_register()
1452 device_unregister(hwif->portdev); in ide_host_register()
1453 device_unregister(&hwif->gendev); in ide_host_register()
1454 ide_disable_port(hwif); in ide_host_register()
1458 if (hwif->present) in ide_host_register()
1459 if (ide_port_setup_devices(hwif) == 0) { in ide_host_register()
1460 hwif->present = 0; in ide_host_register()
1466 ide_acpi_init_port(hwif); in ide_host_register()
1468 if (hwif->present) in ide_host_register()
1469 ide_acpi_port_init_devices(hwif); in ide_host_register()
1472 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1473 if (hwif == NULL) in ide_host_register()
1476 ide_sysfs_register_port(hwif); in ide_host_register()
1477 ide_proc_register_port(hwif); in ide_host_register()
1479 if (hwif->present) { in ide_host_register()
1480 ide_proc_port_register_devices(hwif); in ide_host_register()
1481 hwif_register_devices(hwif); in ide_host_register()
1512 static void __ide_port_unregister_devices(ide_hwif_t *hwif) in __ide_port_unregister_devices() argument
1517 ide_port_for_each_present_dev(i, drive, hwif) { in __ide_port_unregister_devices()
1523 void ide_port_unregister_devices(ide_hwif_t *hwif) in ide_port_unregister_devices() argument
1526 __ide_port_unregister_devices(hwif); in ide_port_unregister_devices()
1527 hwif->present = 0; in ide_port_unregister_devices()
1528 ide_port_init_devices_data(hwif); in ide_port_unregister_devices()
1547 static void ide_unregister(ide_hwif_t *hwif) in ide_unregister() argument
1554 if (hwif->present) { in ide_unregister()
1555 __ide_port_unregister_devices(hwif); in ide_unregister()
1556 hwif->present = 0; in ide_unregister()
1559 ide_proc_unregister_port(hwif); in ide_unregister()
1561 if (!hwif->host->get_lock) in ide_unregister()
1562 free_irq(hwif->irq, hwif); in ide_unregister()
1564 device_unregister(hwif->portdev); in ide_unregister()
1565 device_unregister(&hwif->gendev); in ide_unregister()
1566 wait_for_completion(&hwif->gendev_rel_comp); in ide_unregister()
1571 blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); in ide_unregister()
1572 kfree(hwif->sg_table); in ide_unregister()
1573 unregister_blkdev(hwif->major, hwif->name); in ide_unregister()
1575 ide_release_dma_engine(hwif); in ide_unregister()
1582 ide_hwif_t *hwif; in ide_host_free() local
1585 ide_host_for_each_port(i, hwif, host) { in ide_host_free()
1586 if (hwif) in ide_host_free()
1587 ide_port_free(hwif); in ide_host_free()
1596 ide_hwif_t *hwif; in ide_host_remove() local
1599 ide_host_for_each_port(i, hwif, host) { in ide_host_remove()
1600 if (hwif) in ide_host_remove()
1601 ide_unregister(hwif); in ide_host_remove()
1608 void ide_port_scan(ide_hwif_t *hwif) in ide_port_scan() argument
1612 ide_port_apply_params(hwif); in ide_port_scan()
1613 ide_port_cable_detect(hwif); in ide_port_scan()
1615 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_port_scan()
1617 ide_port_init_devices(hwif); in ide_port_scan()
1619 rc = ide_probe_port(hwif); in ide_port_scan()
1621 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_port_scan()
1626 hwif->present = 1; in ide_port_scan()
1628 ide_port_tune_devices(hwif); in ide_port_scan()
1629 ide_port_setup_devices(hwif); in ide_port_scan()
1630 ide_acpi_port_init_devices(hwif); in ide_port_scan()
1631 hwif_register_devices(hwif); in ide_port_scan()
1632 ide_proc_port_register_devices(hwif); in ide_port_scan()