Lines Matching refs:hwif

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