Lines Matching refs:hwif

193 	ide_hwif_t *hwif = drive->hwif;  in do_identify()  local
201 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); in do_identify()
252 ide_hwif_t *hwif = drive->hwif; in ide_dev_read_id() local
253 struct ide_io_ports *io_ports = &hwif->io_ports; in ide_dev_read_id()
254 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_dev_read_id()
264 tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); in ide_dev_read_id()
273 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) { in ide_dev_read_id()
274 a = tp_ops->read_altstatus(hwif); in ide_dev_read_id()
275 s = tp_ops->read_status(hwif); in ide_dev_read_id()
298 tp_ops->exec_command(hwif, cmd); in ide_dev_read_id()
313 s = tp_ops->read_status(hwif); in ide_dev_read_id()
322 (void)tp_ops->read_status(hwif); in ide_dev_read_id()
332 ide_hwif_t *hwif = drive->hwif; in ide_busy_sleep() local
339 stat = altstatus ? hwif->tp_ops->read_altstatus(hwif) in ide_busy_sleep()
340 : hwif->tp_ops->read_status(hwif); in ide_busy_sleep()
354 drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_DEVICE); in ide_read_device()
382 ide_hwif_t *hwif = drive->hwif; in do_probe() local
383 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in do_probe()
408 tp_ops->dev_select(hwif->devices[0]); in do_probe()
416 stat = tp_ops->read_status(hwif); in do_probe()
425 stat = tp_ops->read_status(hwif); in do_probe()
436 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); in do_probe()
442 stat = tp_ops->read_status(hwif); in do_probe()
453 tp_ops->dev_select(hwif->devices[0]); in do_probe()
456 (void)tp_ops->read_status(hwif); in do_probe()
538 ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); in hwif_release_dev() local
540 complete(&hwif->gendev_rel_comp); in hwif_release_dev()
543 static int ide_register_port(ide_hwif_t *hwif) in ide_register_port() argument
548 dev_set_name(&hwif->gendev, "%s", hwif->name); in ide_register_port()
549 dev_set_drvdata(&hwif->gendev, hwif); in ide_register_port()
550 if (hwif->gendev.parent == NULL) in ide_register_port()
551 hwif->gendev.parent = hwif->dev; in ide_register_port()
552 hwif->gendev.release = hwif_release_dev; in ide_register_port()
554 ret = device_register(&hwif->gendev); in ide_register_port()
561 hwif->portdev = device_create(ide_port_class, &hwif->gendev, in ide_register_port()
562 MKDEV(0, 0), hwif, "%s", hwif->name); in ide_register_port()
563 if (IS_ERR(hwif->portdev)) { in ide_register_port()
564 ret = PTR_ERR(hwif->portdev); in ide_register_port()
565 device_unregister(&hwif->gendev); in ide_register_port()
597 static int ide_port_wait_ready(ide_hwif_t *hwif) in ide_port_wait_ready() argument
599 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_port_wait_ready()
603 printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); in ide_port_wait_ready()
613 rc = ide_wait_not_busy(hwif, 35000); in ide_port_wait_ready()
618 ide_port_for_each_dev(i, drive, hwif) { in ide_port_wait_ready()
623 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_port_wait_ready()
625 rc = ide_wait_not_busy(hwif, 35000); in ide_port_wait_ready()
635 tp_ops->dev_select(hwif->devices[0]); in ide_port_wait_ready()
651 ide_drive_t *dev0 = dev1->hwif->devices[0]; in ide_undecoded_slave()
678 static int ide_probe_port(ide_hwif_t *hwif) in ide_probe_port() argument
684 BUG_ON(hwif->present); in ide_probe_port()
686 if ((hwif->devices[0]->dev_flags & IDE_DFLAG_NOPROBE) && in ide_probe_port()
687 (hwif->devices[1]->dev_flags & IDE_DFLAG_NOPROBE)) in ide_probe_port()
694 irqd = hwif->irq; in ide_probe_port()
696 disable_irq(hwif->irq); in ide_probe_port()
698 if (ide_port_wait_ready(hwif) == -EBUSY) in ide_probe_port()
699 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); in ide_probe_port()
705 ide_port_for_each_dev(i, drive, hwif) { in ide_probe_port()
721 static void ide_port_tune_devices(ide_hwif_t *hwif) in ide_port_tune_devices() argument
723 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_tune_devices()
727 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
734 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
739 if (hwif->dma_ops) in ide_port_tune_devices()
750 ide_hwif_t *hwif = drive->hwif; in ide_init_queue() local
762 q = blk_init_queue_node(do_ide_request, NULL, hwif_to_node(hwif)); in ide_init_queue()
769 if (hwif->rqsize < max_sectors) in ide_init_queue()
770 max_sectors = hwif->rqsize; in ide_init_queue()
804 static int ide_port_setup_devices(ide_hwif_t *hwif) in ide_port_setup_devices() argument
810 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_setup_devices()
827 ide_hwif_t *hwif; in ide_host_enable_irqs() local
830 ide_host_for_each_port(i, hwif, host) { in ide_host_enable_irqs()
831 if (hwif == NULL) in ide_host_enable_irqs()
835 hwif->tp_ops->read_status(hwif); in ide_host_enable_irqs()
838 if (hwif->io_ports.ctl_addr) in ide_host_enable_irqs()
839 hwif->tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_host_enable_irqs()
846 static int init_irq (ide_hwif_t *hwif) in init_irq() argument
848 struct ide_io_ports *io_ports = &hwif->io_ports; in init_irq()
849 struct ide_host *host = hwif->host; in init_irq()
857 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) in init_irq()
861 printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, in init_irq()
863 io_ports->ctl_addr, hwif->irq); in init_irq()
865 printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, in init_irq()
866 io_ports->data_addr, hwif->irq); in init_irq()
868 if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) in init_irq()
885 ide_hwif_t *hwif = data; in ata_probe() local
887 ide_drive_t *drive = hwif->devices[unit]; in ata_probe()
938 ide_hwif_t *hwif = drive->hwif; in ide_init_disk() local
941 disk->major = hwif->major; in ide_init_disk()
943 sprintf(disk->disk_name, "hd%c", 'a' + hwif->index * MAX_DRIVES + unit); in ide_init_disk()
963 static int hwif_init(ide_hwif_t *hwif) in hwif_init() argument
965 if (!hwif->irq) { in hwif_init()
966 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name); in hwif_init()
970 if (register_blkdev(hwif->major, hwif->name)) in hwif_init()
973 if (!hwif->sg_max_nents) in hwif_init()
974 hwif->sg_max_nents = PRD_ENTRIES; in hwif_init()
976 hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, in hwif_init()
978 if (!hwif->sg_table) { in hwif_init()
979 printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); in hwif_init()
983 sg_init_table(hwif->sg_table, hwif->sg_max_nents); in hwif_init()
985 if (init_irq(hwif)) { in hwif_init()
987 hwif->name, hwif->irq); in hwif_init()
991 blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, in hwif_init()
992 THIS_MODULE, ata_probe, ata_lock, hwif); in hwif_init()
996 unregister_blkdev(hwif->major, hwif->name); in hwif_init()
1000 static void hwif_register_devices(ide_hwif_t *hwif) in hwif_register_devices() argument
1005 ide_port_for_each_present_dev(i, drive, hwif) { in hwif_register_devices()
1009 dev_set_name(dev, "%u.%u", hwif->index, i); in hwif_register_devices()
1011 dev->parent = &hwif->gendev; in hwif_register_devices()
1022 static void ide_port_init_devices(ide_hwif_t *hwif) in ide_port_init_devices() argument
1024 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_init_devices()
1028 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices()
1029 drive->dn = i + hwif->channel * 2; in ide_port_init_devices()
1031 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) in ide_port_init_devices()
1033 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) in ide_port_init_devices()
1035 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) in ide_port_init_devices()
1037 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) in ide_port_init_devices()
1047 static void ide_init_port(ide_hwif_t *hwif, unsigned int port, in ide_init_port() argument
1050 hwif->channel = port; in ide_init_port()
1052 hwif->chipset = d->chipset ? d->chipset : ide_pci; in ide_init_port()
1055 d->init_iops(hwif); in ide_init_port()
1058 hwif->host_flags |= d->host_flags; in ide_init_port()
1059 hwif->pio_mask = d->pio_mask; in ide_init_port()
1062 hwif->tp_ops = d->tp_ops; in ide_init_port()
1065 if ((hwif->host_flags & IDE_HFLAG_DTC2278) == 0 || hwif->channel == 0) in ide_init_port()
1066 hwif->port_ops = d->port_ops; in ide_init_port()
1068 hwif->swdma_mask = d->swdma_mask; in ide_init_port()
1069 hwif->mwdma_mask = d->mwdma_mask; in ide_init_port()
1070 hwif->ultra_mask = d->udma_mask; in ide_init_port()
1075 hwif->dma_ops = d->dma_ops; in ide_init_port()
1078 rc = d->init_dma(hwif, d); in ide_init_port()
1080 rc = ide_hwif_setup_dma(hwif, d); in ide_init_port()
1083 printk(KERN_INFO "%s: DMA disabled\n", hwif->name); in ide_init_port()
1085 hwif->dma_ops = NULL; in ide_init_port()
1086 hwif->dma_base = 0; in ide_init_port()
1087 hwif->swdma_mask = 0; in ide_init_port()
1088 hwif->mwdma_mask = 0; in ide_init_port()
1089 hwif->ultra_mask = 0; in ide_init_port()
1094 ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) in ide_init_port()
1095 hwif->host->host_flags |= IDE_HFLAG_SERIALIZE; in ide_init_port()
1098 hwif->rqsize = d->max_sectors; in ide_init_port()
1100 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || in ide_init_port()
1101 (hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA)) in ide_init_port()
1102 hwif->rqsize = 256; in ide_init_port()
1104 hwif->rqsize = 65536; in ide_init_port()
1109 d->init_hwif(hwif); in ide_init_port()
1112 static void ide_port_cable_detect(ide_hwif_t *hwif) in ide_port_cable_detect() argument
1114 const struct ide_port_ops *port_ops = hwif->port_ops; in ide_port_cable_detect()
1116 if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) { in ide_port_cable_detect()
1117 if (hwif->cbl != ATA_CBL_PATA40_SHORT) in ide_port_cable_detect()
1118 hwif->cbl = port_ops->cable_detect(hwif); in ide_port_cable_detect()
1126 static void ide_port_init_devices_data(ide_hwif_t *hwif) in ide_port_init_devices_data() argument
1131 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices_data()
1132 u8 j = (hwif->index * MAX_DRIVES) + i; in ide_port_init_devices_data()
1141 drive->hwif = hwif; in ide_port_init_devices_data()
1156 static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) in ide_init_port_data() argument
1159 hwif->index = index; in ide_init_port_data()
1160 hwif->major = ide_hwif_to_major[index]; in ide_init_port_data()
1162 hwif->name[0] = 'i'; in ide_init_port_data()
1163 hwif->name[1] = 'd'; in ide_init_port_data()
1164 hwif->name[2] = 'e'; in ide_init_port_data()
1165 hwif->name[3] = '0' + index; in ide_init_port_data()
1167 spin_lock_init(&hwif->lock); in ide_init_port_data()
1169 init_timer(&hwif->timer); in ide_init_port_data()
1170 hwif->timer.function = &ide_timer_expiry; in ide_init_port_data()
1171 hwif->timer.data = (unsigned long)hwif; in ide_init_port_data()
1173 init_completion(&hwif->gendev_rel_comp); in ide_init_port_data()
1175 hwif->tp_ops = &default_tp_ops; in ide_init_port_data()
1177 ide_port_init_devices_data(hwif); in ide_init_port_data()
1180 static void ide_init_port_hw(ide_hwif_t *hwif, struct ide_hw *hw) in ide_init_port_hw() argument
1182 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); in ide_init_port_hw()
1183 hwif->irq = hw->irq; in ide_init_port_hw()
1184 hwif->dev = hw->dev; in ide_init_port_hw()
1185 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; in ide_init_port_hw()
1186 hwif->config_data = hw->config; in ide_init_port_hw()
1238 static void ide_port_free_devices(ide_hwif_t *hwif) in ide_port_free_devices() argument
1243 ide_port_for_each_dev(i, drive, hwif) { in ide_port_free_devices()
1249 static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) in ide_port_alloc_devices() argument
1272 hwif->devices[i] = drive; in ide_port_alloc_devices()
1277 ide_port_free_devices(hwif); in ide_port_alloc_devices()
1294 ide_hwif_t *hwif; in ide_host_alloc() local
1300 hwif = kzalloc_node(sizeof(*hwif), GFP_KERNEL, node); in ide_host_alloc()
1301 if (hwif == NULL) in ide_host_alloc()
1304 if (ide_port_alloc_devices(hwif, node) < 0) { in ide_host_alloc()
1305 kfree(hwif); in ide_host_alloc()
1313 ide_port_free_devices(hwif); in ide_host_alloc()
1314 kfree(hwif); in ide_host_alloc()
1318 ide_init_port_data(hwif, idx); in ide_host_alloc()
1320 hwif->host = host; in ide_host_alloc()
1322 host->ports[i] = hwif; in ide_host_alloc()
1345 static void ide_port_free(ide_hwif_t *hwif) in ide_port_free() argument
1347 ide_port_free_devices(hwif); in ide_port_free()
1348 ide_free_port_slot(hwif->index); in ide_port_free()
1349 kfree(hwif); in ide_port_free()
1352 static void ide_disable_port(ide_hwif_t *hwif) in ide_disable_port() argument
1354 struct ide_host *host = hwif->host; in ide_disable_port()
1357 printk(KERN_INFO "%s: disabling port\n", hwif->name); in ide_disable_port()
1360 if (host->ports[i] == hwif) { in ide_disable_port()
1366 ide_port_free(hwif); in ide_disable_port()
1372 ide_hwif_t *hwif, *mate = NULL; in ide_host_register() local
1375 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1376 if (hwif == NULL) { in ide_host_register()
1381 ide_init_port_hw(hwif, hws[i]); in ide_host_register()
1382 ide_port_apply_params(hwif); in ide_host_register()
1385 hwif->mate = mate; in ide_host_register()
1386 mate->mate = hwif; in ide_host_register()
1389 mate = (i & 1) ? NULL : hwif; in ide_host_register()
1391 ide_init_port(hwif, i & 1, d); in ide_host_register()
1392 ide_port_cable_detect(hwif); in ide_host_register()
1394 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_host_register()
1396 ide_port_init_devices(hwif); in ide_host_register()
1399 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1400 if (hwif == NULL) in ide_host_register()
1403 if (ide_probe_port(hwif) == 0) in ide_host_register()
1404 hwif->present = 1; in ide_host_register()
1406 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_host_register()
1408 if ((hwif->host_flags & IDE_HFLAG_4DRIVES) == 0 || in ide_host_register()
1409 hwif->mate == NULL || hwif->mate->present == 0) { in ide_host_register()
1410 if (ide_register_port(hwif)) { in ide_host_register()
1411 ide_disable_port(hwif); in ide_host_register()
1416 if (hwif->present) in ide_host_register()
1417 ide_port_tune_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 (hwif_init(hwif) == 0) { in ide_host_register()
1428 "interface\n", hwif->name); in ide_host_register()
1429 device_unregister(&hwif->gendev); in ide_host_register()
1430 ide_disable_port(hwif); in ide_host_register()
1434 if (hwif->present) in ide_host_register()
1435 if (ide_port_setup_devices(hwif) == 0) { in ide_host_register()
1436 hwif->present = 0; in ide_host_register()
1442 ide_acpi_init_port(hwif); in ide_host_register()
1444 if (hwif->present) in ide_host_register()
1445 ide_acpi_port_init_devices(hwif); in ide_host_register()
1448 ide_host_for_each_port(i, hwif, host) { in ide_host_register()
1449 if (hwif == NULL) in ide_host_register()
1452 ide_sysfs_register_port(hwif); in ide_host_register()
1453 ide_proc_register_port(hwif); in ide_host_register()
1455 if (hwif->present) { in ide_host_register()
1456 ide_proc_port_register_devices(hwif); in ide_host_register()
1457 hwif_register_devices(hwif); in ide_host_register()
1488 static void __ide_port_unregister_devices(ide_hwif_t *hwif) in __ide_port_unregister_devices() argument
1493 ide_port_for_each_present_dev(i, drive, hwif) { in __ide_port_unregister_devices()
1499 void ide_port_unregister_devices(ide_hwif_t *hwif) in ide_port_unregister_devices() argument
1502 __ide_port_unregister_devices(hwif); in ide_port_unregister_devices()
1503 hwif->present = 0; in ide_port_unregister_devices()
1504 ide_port_init_devices_data(hwif); in ide_port_unregister_devices()
1523 static void ide_unregister(ide_hwif_t *hwif) in ide_unregister() argument
1530 if (hwif->present) { in ide_unregister()
1531 __ide_port_unregister_devices(hwif); in ide_unregister()
1532 hwif->present = 0; in ide_unregister()
1535 ide_proc_unregister_port(hwif); in ide_unregister()
1537 if (!hwif->host->get_lock) in ide_unregister()
1538 free_irq(hwif->irq, hwif); in ide_unregister()
1540 device_unregister(hwif->portdev); in ide_unregister()
1541 device_unregister(&hwif->gendev); in ide_unregister()
1542 wait_for_completion(&hwif->gendev_rel_comp); in ide_unregister()
1547 blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); in ide_unregister()
1548 kfree(hwif->sg_table); in ide_unregister()
1549 unregister_blkdev(hwif->major, hwif->name); in ide_unregister()
1551 ide_release_dma_engine(hwif); in ide_unregister()
1558 ide_hwif_t *hwif; in ide_host_free() local
1561 ide_host_for_each_port(i, hwif, host) { in ide_host_free()
1562 if (hwif) in ide_host_free()
1563 ide_port_free(hwif); in ide_host_free()
1572 ide_hwif_t *hwif; in ide_host_remove() local
1575 ide_host_for_each_port(i, hwif, host) { in ide_host_remove()
1576 if (hwif) in ide_host_remove()
1577 ide_unregister(hwif); in ide_host_remove()
1584 void ide_port_scan(ide_hwif_t *hwif) in ide_port_scan() argument
1588 ide_port_apply_params(hwif); in ide_port_scan()
1589 ide_port_cable_detect(hwif); in ide_port_scan()
1591 hwif->port_flags |= IDE_PFLAG_PROBING; in ide_port_scan()
1593 ide_port_init_devices(hwif); in ide_port_scan()
1595 rc = ide_probe_port(hwif); in ide_port_scan()
1597 hwif->port_flags &= ~IDE_PFLAG_PROBING; in ide_port_scan()
1602 hwif->present = 1; in ide_port_scan()
1604 ide_port_tune_devices(hwif); in ide_port_scan()
1605 ide_port_setup_devices(hwif); in ide_port_scan()
1606 ide_acpi_port_init_devices(hwif); in ide_port_scan()
1607 hwif_register_devices(hwif); in ide_port_scan()
1608 ide_proc_port_register_devices(hwif); in ide_port_scan()