Lines Matching refs:hwif

195 	ide_hwif_t *hwif = drive->hwif;  in do_identify()  local
203 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); in do_identify()
254 ide_hwif_t *hwif = drive->hwif; in ide_dev_read_id() local
255 struct ide_io_ports *io_ports = &hwif->io_ports; in ide_dev_read_id()
256 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_dev_read_id()
266 tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); in ide_dev_read_id()
275 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) { in ide_dev_read_id()
276 a = tp_ops->read_altstatus(hwif); in ide_dev_read_id()
277 s = tp_ops->read_status(hwif); in ide_dev_read_id()
300 tp_ops->exec_command(hwif, cmd); in ide_dev_read_id()
315 s = tp_ops->read_status(hwif); in ide_dev_read_id()
324 (void)tp_ops->read_status(hwif); in ide_dev_read_id()
334 ide_hwif_t *hwif = drive->hwif; in ide_busy_sleep() local
341 stat = altstatus ? hwif->tp_ops->read_altstatus(hwif) in ide_busy_sleep()
342 : hwif->tp_ops->read_status(hwif); in ide_busy_sleep()
356 drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_DEVICE); in ide_read_device()
384 ide_hwif_t *hwif = drive->hwif; in do_probe() local
385 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in do_probe()
410 tp_ops->dev_select(hwif->devices[0]); in do_probe()
418 stat = tp_ops->read_status(hwif); in do_probe()
427 stat = tp_ops->read_status(hwif); in do_probe()
438 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); in do_probe()
444 stat = tp_ops->read_status(hwif); in do_probe()
455 tp_ops->dev_select(hwif->devices[0]); in do_probe()
458 (void)tp_ops->read_status(hwif); in do_probe()
540 ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); in hwif_release_dev() local
542 complete(&hwif->gendev_rel_comp); in hwif_release_dev()
545 static int ide_register_port(ide_hwif_t *hwif) in ide_register_port() argument
550 dev_set_name(&hwif->gendev, "%s", hwif->name); in ide_register_port()
551 dev_set_drvdata(&hwif->gendev, hwif); in ide_register_port()
552 if (hwif->gendev.parent == NULL) in ide_register_port()
553 hwif->gendev.parent = hwif->dev; in ide_register_port()
554 hwif->gendev.release = hwif_release_dev; in ide_register_port()
556 ret = device_register(&hwif->gendev); in ide_register_port()
563 hwif->portdev = device_create(ide_port_class, &hwif->gendev, in ide_register_port()
564 MKDEV(0, 0), hwif, "%s", hwif->name); in ide_register_port()
565 if (IS_ERR(hwif->portdev)) { in ide_register_port()
566 ret = PTR_ERR(hwif->portdev); in ide_register_port()
567 device_unregister(&hwif->gendev); in ide_register_port()
599 static int ide_port_wait_ready(ide_hwif_t *hwif) in ide_port_wait_ready() argument
601 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_port_wait_ready()
605 printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); in ide_port_wait_ready()
615 rc = ide_wait_not_busy(hwif, 35000); in ide_port_wait_ready()
620 ide_port_for_each_dev(i, drive, hwif) { in ide_port_wait_ready()
625 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_port_wait_ready()
627 rc = ide_wait_not_busy(hwif, 35000); in ide_port_wait_ready()
637 tp_ops->dev_select(hwif->devices[0]); in ide_port_wait_ready()
653 ide_drive_t *dev0 = dev1->hwif->devices[0]; in ide_undecoded_slave()
680 static int ide_probe_port(ide_hwif_t *hwif) in ide_probe_port() argument
686 BUG_ON(hwif->present); in ide_probe_port()
688 if ((hwif->devices[0]->dev_flags & IDE_DFLAG_NOPROBE) && in ide_probe_port()
689 (hwif->devices[1]->dev_flags & IDE_DFLAG_NOPROBE)) in ide_probe_port()
696 irqd = hwif->irq; in ide_probe_port()
698 disable_irq(hwif->irq); in ide_probe_port()
700 if (ide_port_wait_ready(hwif) == -EBUSY) in ide_probe_port()
701 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); in ide_probe_port()
707 ide_port_for_each_dev(i, drive, hwif) { in ide_probe_port()
723 static void ide_port_tune_devices(ide_hwif_t *hwif) in ide_port_tune_devices() argument
725 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_tune_devices()
729 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
736 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
741 if (hwif->dma_ops) in ide_port_tune_devices()
766 ide_hwif_t *hwif = drive->hwif; in ide_init_queue() local
785 set->numa_node = hwif_to_node(hwif); in ide_init_queue()
801 if (hwif->rqsize < max_sectors) in ide_init_queue()
802 max_sectors = hwif->rqsize; in ide_init_queue()
832 static int ide_port_setup_devices(ide_hwif_t *hwif) in ide_port_setup_devices() argument
838 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_setup_devices()
855 ide_hwif_t *hwif; in ide_host_enable_irqs() local
858 ide_host_for_each_port(i, hwif, host) { in ide_host_enable_irqs()
859 if (hwif == NULL) in ide_host_enable_irqs()
863 hwif->tp_ops->read_status(hwif); in ide_host_enable_irqs()
866 if (hwif->io_ports.ctl_addr) in ide_host_enable_irqs()
867 hwif->tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_host_enable_irqs()
874 static int init_irq (ide_hwif_t *hwif) in init_irq() argument
876 struct ide_io_ports *io_ports = &hwif->io_ports; in init_irq()
877 struct ide_host *host = hwif->host; in init_irq()
885 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) in init_irq()
889 printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, in init_irq()
891 io_ports->ctl_addr, hwif->irq); in init_irq()
893 printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, in init_irq()
894 io_ports->data_addr, hwif->irq); in init_irq()
896 if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) in init_irq()
913 ide_hwif_t *hwif = data; in ata_probe() local
915 ide_drive_t *drive = hwif->devices[unit]; in ata_probe()
966 ide_hwif_t *hwif = drive->hwif; in ide_init_disk() local
969 disk->major = hwif->major; in ide_init_disk()
971 sprintf(disk->disk_name, "hd%c", 'a' + hwif->index * MAX_DRIVES + unit); in ide_init_disk()
995 static int hwif_init(ide_hwif_t *hwif) in hwif_init() argument
997 if (!hwif->irq) { in hwif_init()
998 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name); in hwif_init()
1002 if (register_blkdev(hwif->major, hwif->name)) in hwif_init()
1005 if (!hwif->sg_max_nents) in hwif_init()
1006 hwif->sg_max_nents = PRD_ENTRIES; in hwif_init()
1008 hwif->sg_table = kmalloc_array(hwif->sg_max_nents, in hwif_init()
1011 if (!hwif->sg_table) { in hwif_init()
1012 printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); in hwif_init()
1016 sg_init_table(hwif->sg_table, hwif->sg_max_nents); in hwif_init()
1018 if (init_irq(hwif)) { in hwif_init()
1020 hwif->name, hwif->irq); in hwif_init()
1024 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, in hwif_init()
1025 THIS_MODULE, ata_probe, ata_lock, hwif); in hwif_init()
1029 unregister_blkdev(hwif->major, hwif->name); in hwif_init()
1033 static void hwif_register_devices(ide_hwif_t *hwif) in hwif_register_devices() argument
1038 ide_port_for_each_present_dev(i, drive, hwif) { in hwif_register_devices()
1042 dev_set_name(dev, "%u.%u", hwif->index, i); in hwif_register_devices()
1044 dev->parent = &hwif->gendev; in hwif_register_devices()
1055 static void ide_port_init_devices(ide_hwif_t *hwif) in ide_port_init_devices() argument
1057 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_init_devices()
1061 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices()
1062 drive->dn = i + hwif->channel * 2; in ide_port_init_devices()
1064 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) in ide_port_init_devices()
1066 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) in ide_port_init_devices()
1068 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) in ide_port_init_devices()
1070 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) in ide_port_init_devices()
1080 static void ide_init_port(ide_hwif_t *hwif, unsigned int port, in ide_init_port() argument
1083 hwif->channel = port; in ide_init_port()
1085 hwif->chipset = d->chipset ? d->chipset : ide_pci; in ide_init_port()
1088 d->init_iops(hwif); in ide_init_port()
1091 hwif->host_flags |= d->host_flags; in ide_init_port()
1092 hwif->pio_mask = d->pio_mask; in ide_init_port()
1095 hwif->tp_ops = d->tp_ops; in ide_init_port()
1098 if ((hwif->host_flags & IDE_HFLAG_DTC2278) == 0 || hwif->channel == 0) in ide_init_port()
1099 hwif->port_ops = d->port_ops; in ide_init_port()
1101 hwif->swdma_mask = d->swdma_mask; in ide_init_port()
1102 hwif->mwdma_mask = d->mwdma_mask; in ide_init_port()
1103 hwif->ultra_mask = d->udma_mask; in ide_init_port()
1108 hwif->dma_ops = d->dma_ops; in ide_init_port()
1111 rc = d->init_dma(hwif, d); in ide_init_port()
1113 rc = ide_hwif_setup_dma(hwif, d); in ide_init_port()
1116 printk(KERN_INFO "%s: DMA disabled\n", hwif->name); in ide_init_port()
1118 hwif->dma_ops = NULL; in ide_init_port()
1119 hwif->dma_base = 0; in ide_init_port()
1120 hwif->swdma_mask = 0; in ide_init_port()
1121 hwif->mwdma_mask = 0; in ide_init_port()
1122 hwif->ultra_mask = 0; in ide_init_port()
1127 ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) in ide_init_port()
1128 hwif->host->host_flags |= IDE_HFLAG_SERIALIZE; in ide_init_port()
1131 hwif->rqsize = d->max_sectors; in ide_init_port()
1133 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || in ide_init_port()
1134 (hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA)) in ide_init_port()
1135 hwif->rqsize = 256; in ide_init_port()
1137 hwif->rqsize = 65536; in ide_init_port()
1142 d->init_hwif(hwif); in ide_init_port()
1145 static void ide_port_cable_detect(ide_hwif_t *hwif) in ide_port_cable_detect() argument
1147 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_cable_detect()
1149 if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) { in ide_port_cable_detect()
1150 if (hwif->cbl != ATA_CBL_PATA40_SHORT) in ide_port_cable_detect()
1151 hwif->cbl = port_ops->cable_detect(hwif); in ide_port_cable_detect()
1161 ide_hwif_t *hwif = drive->hwif; in drive_rq_insert_work() local
1169 spin_lock_irq(&hwif->lock); in drive_rq_insert_work()
1174 spin_unlock_irq(&hwif->lock); in drive_rq_insert_work()
1176 spin_lock_irq(&hwif->lock); in drive_rq_insert_work()
1178 spin_unlock_irq(&hwif->lock); in drive_rq_insert_work()
1190 static void ide_port_init_devices_data(ide_hwif_t *hwif) in ide_port_init_devices_data() argument
1195 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices_data()
1196 u8 j = (hwif->index * MAX_DRIVES) + i; in ide_port_init_devices_data()
1205 drive->hwif = hwif; in ide_port_init_devices_data()
1223 static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) in ide_init_port_data() argument
1226 hwif->index = index; in ide_init_port_data()
1227 hwif->major = ide_hwif_to_major[index]; in ide_init_port_data()
1229 hwif->name[0] = 'i'; in ide_init_port_data()
1230 hwif->name[1] = 'd'; in ide_init_port_data()
1231 hwif->name[2] = 'e'; in ide_init_port_data()
1232 hwif->name[3] = '0' + index; in ide_init_port_data()
1234 spin_lock_init(&hwif->lock); in ide_init_port_data()
1236 timer_setup(&hwif->timer, ide_timer_expiry, 0); in ide_init_port_data()
1238 init_completion(&hwif->gendev_rel_comp); in ide_init_port_data()
1240 hwif->tp_ops = &default_tp_ops; in ide_init_port_data()
1242 ide_port_init_devices_data(hwif); in ide_init_port_data()
1245 static void ide_init_port_hw(ide_hwif_t *hwif, struct ide_hw *hw) in ide_init_port_hw() argument
1247 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); in ide_init_port_hw()
1248 hwif->irq = hw->irq; in ide_init_port_hw()
1249 hwif->dev = hw->dev; in ide_init_port_hw()
1250 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; in ide_init_port_hw()
1251 hwif->config_data = hw->config; in ide_init_port_hw()
1303 static void ide_port_free_devices(ide_hwif_t *hwif) in ide_port_free_devices() argument
1308 ide_port_for_each_dev(i, drive, hwif) { in ide_port_free_devices()
1314 static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) in ide_port_alloc_devices() argument
1336 hwif->devices[i] = drive; in ide_port_alloc_devices()
1343 ide_port_free_devices(hwif); in ide_port_alloc_devices()
1360 ide_hwif_t *hwif; in ide_host_alloc() local
1366 hwif = kzalloc_node(sizeof(*hwif), GFP_KERNEL, node); in ide_host_alloc()
1367 if (hwif == NULL) in ide_host_alloc()
1370 if (ide_port_alloc_devices(hwif, node) < 0) { in ide_host_alloc()
1371 kfree(hwif); in ide_host_alloc()
1379 ide_port_free_devices(hwif); in ide_host_alloc()
1380 kfree(hwif); in ide_host_alloc()
1384 ide_init_port_data(hwif, idx); in ide_host_alloc()
1386 hwif->host = host; in ide_host_alloc()
1388 host->ports[i] = hwif; in ide_host_alloc()
1411 static void ide_port_free(ide_hwif_t *hwif) in ide_port_free() argument
1413 ide_port_free_devices(hwif); in ide_port_free()
1414 ide_free_port_slot(hwif->index); in ide_port_free()
1415 kfree(hwif); in ide_port_free()
1418 static void ide_disable_port(ide_hwif_t *hwif) in ide_disable_port() argument
1420 struct ide_host *host = hwif->host; in ide_disable_port()
1423 printk(KERN_INFO "%s: disabling port\n", hwif->name); in ide_disable_port()
1426 if (host->ports[i] == hwif) { in ide_disable_port()
1432 ide_port_free(hwif); in ide_disable_port()
1438 ide_hwif_t *hwif, *mate = NULL; in ide_host_register() local
1444 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1445 if (hwif == NULL) { in ide_host_register()
1450 ide_init_port_hw(hwif, hws[i]); in ide_host_register()
1451 ide_port_apply_params(hwif); in ide_host_register()
1454 hwif->mate = mate; in ide_host_register()
1455 mate->mate = hwif; in ide_host_register()
1458 mate = (i & 1) ? NULL : hwif; in ide_host_register()
1460 ide_init_port(hwif, i & 1, d); in ide_host_register()
1461 ide_port_cable_detect(hwif); in ide_host_register()
1463 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_host_register()
1465 ide_port_init_devices(hwif); in ide_host_register()
1468 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1469 if (hwif == NULL) in ide_host_register()
1472 if (ide_probe_port(hwif) == 0) in ide_host_register()
1473 hwif->present = 1; in ide_host_register()
1475 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_host_register()
1477 if ((hwif->host_flags & IDE_HFLAG_4DRIVES) == 0 || in ide_host_register()
1478 hwif->mate == NULL || hwif->mate->present == 0) { in ide_host_register()
1479 if (ide_register_port(hwif)) { in ide_host_register()
1480 ide_disable_port(hwif); in ide_host_register()
1485 if (hwif->present) in ide_host_register()
1486 ide_port_tune_devices(hwif); in ide_host_register()
1491 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1492 if (hwif == NULL) in ide_host_register()
1495 if (hwif_init(hwif) == 0) { in ide_host_register()
1497 "interface\n", hwif->name); in ide_host_register()
1498 device_unregister(hwif->portdev); in ide_host_register()
1499 device_unregister(&hwif->gendev); in ide_host_register()
1500 ide_disable_port(hwif); in ide_host_register()
1504 if (hwif->present) in ide_host_register()
1505 if (ide_port_setup_devices(hwif) == 0) { in ide_host_register()
1506 hwif->present = 0; in ide_host_register()
1512 ide_acpi_init_port(hwif); in ide_host_register()
1514 if (hwif->present) in ide_host_register()
1515 ide_acpi_port_init_devices(hwif); in ide_host_register()
1518 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1519 if (hwif == NULL) in ide_host_register()
1522 ide_sysfs_register_port(hwif); in ide_host_register()
1523 ide_proc_register_port(hwif); in ide_host_register()
1525 if (hwif->present) { in ide_host_register()
1526 ide_proc_port_register_devices(hwif); in ide_host_register()
1527 hwif_register_devices(hwif); in ide_host_register()
1558 static void __ide_port_unregister_devices(ide_hwif_t *hwif) in __ide_port_unregister_devices() argument
1563 ide_port_for_each_present_dev(i, drive, hwif) { in __ide_port_unregister_devices()
1569 void ide_port_unregister_devices(ide_hwif_t *hwif) in ide_port_unregister_devices() argument
1572 __ide_port_unregister_devices(hwif); in ide_port_unregister_devices()
1573 hwif->present = 0; in ide_port_unregister_devices()
1574 ide_port_init_devices_data(hwif); in ide_port_unregister_devices()
1593 static void ide_unregister(ide_hwif_t *hwif) in ide_unregister() argument
1600 if (hwif->present) { in ide_unregister()
1601 __ide_port_unregister_devices(hwif); in ide_unregister()
1602 hwif->present = 0; in ide_unregister()
1605 ide_proc_unregister_port(hwif); in ide_unregister()
1607 if (!hwif->host->get_lock) in ide_unregister()
1608 free_irq(hwif->irq, hwif); in ide_unregister()
1610 device_unregister(hwif->portdev); in ide_unregister()
1611 device_unregister(&hwif->gendev); in ide_unregister()
1612 wait_for_completion(&hwif->gendev_rel_comp); in ide_unregister()
1617 blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); in ide_unregister()
1618 kfree(hwif->sg_table); in ide_unregister()
1619 unregister_blkdev(hwif->major, hwif->name); in ide_unregister()
1621 ide_release_dma_engine(hwif); in ide_unregister()
1628 ide_hwif_t *hwif; in ide_host_free() local
1631 ide_host_for_each_port(i, hwif, host) { in ide_host_free()
1632 if (hwif) in ide_host_free()
1633 ide_port_free(hwif); in ide_host_free()
1642 ide_hwif_t *hwif; in ide_host_remove() local
1645 ide_host_for_each_port(i, hwif, host) { in ide_host_remove()
1646 if (hwif) in ide_host_remove()
1647 ide_unregister(hwif); in ide_host_remove()
1654 void ide_port_scan(ide_hwif_t *hwif) in ide_port_scan() argument
1658 ide_port_apply_params(hwif); in ide_port_scan()
1659 ide_port_cable_detect(hwif); in ide_port_scan()
1661 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_port_scan()
1663 ide_port_init_devices(hwif); in ide_port_scan()
1665 rc = ide_probe_port(hwif); in ide_port_scan()
1667 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_port_scan()
1672 hwif->present = 1; in ide_port_scan()
1674 ide_port_tune_devices(hwif); in ide_port_scan()
1675 ide_port_setup_devices(hwif); in ide_port_scan()
1676 ide_acpi_port_init_devices(hwif); in ide_port_scan()
1677 hwif_register_devices(hwif); in ide_port_scan()
1678 ide_proc_port_register_devices(hwif); in ide_port_scan()