Lines Matching +full:udma +full:- +full:p

1 // SPDX-License-Identifier: GPL-2.0-only
3 * libata-acpi.c
26 …fermode, 0x2=lock/freeze lock, 0x4=DIPM, 0x8=FPDMA non-zero offset, 0x10=FPDMA DMA Setup FIS auto-
33 u8 tf[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */
38 kfree(dev->gtf_cache); in ata_acpi_clear_gtf()
39 dev->gtf_cache = NULL; in ata_acpi_clear_gtf()
50 #define ata_hotplug_data(context) (container_of((context), struct ata_acpi_hotplug_context, hp)->da…
53 * ata_dev_acpi_handle - provide the acpi_handle for an ata_device
62 return dev->flags & ATA_DFLAG_ACPI_DISABLED ? in ata_dev_acpi_handle()
63 NULL : ACPI_HANDLE(&dev->tdev); in ata_dev_acpi_handle()
70 dev->flags |= ATA_DFLAG_DETACH; in ata_acpi_detach_device()
77 tdev->flags |= ATA_DFLAG_DETACH; in ata_acpi_detach_device()
84 * ata_acpi_handle_hotplug - ACPI event handler backend
90 * the event is port-wide @dev is NULL. If the event is specific to a
94 * port-wide while unplug only kills the target device on device-wide
103 struct ata_eh_info *ehi = &ap->link.eh_info; in ata_acpi_handle_hotplug()
107 spin_lock_irqsave(ap->lock, flags); in ata_acpi_handle_hotplug()
129 spin_unlock_irqrestore(ap->lock, flags); in ata_acpi_handle_hotplug()
137 struct ata_device *dev = ata_hotplug_data(adev->hp).dev; in ata_acpi_dev_notify_dock()
138 ata_acpi_handle_hotplug(dev->link->ap, dev, event); in ata_acpi_dev_notify_dock()
144 ata_acpi_handle_hotplug(ata_hotplug_data(adev->hp).ap, NULL, event); in ata_acpi_ap_notify_dock()
156 if (dev->sdev) in ata_acpi_uevent()
157 kobj = &dev->sdev->sdev_gendev.kobj; in ata_acpi_uevent()
159 kobj = &ap->dev->kobj; in ata_acpi_uevent()
169 ata_acpi_uevent(ata_hotplug_data(adev->hp).ap, NULL, event); in ata_acpi_ap_uevent()
174 struct ata_device *dev = ata_hotplug_data(adev->hp).dev; in ata_acpi_dev_uevent()
175 ata_acpi_uevent(dev->link->ap, dev, event); in ata_acpi_dev_uevent()
181 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev); in ata_acpi_bind_port()
185 if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion) in ata_acpi_bind_port()
188 acpi_preset_companion(&ap->tdev, host_companion, ap->port_no); in ata_acpi_bind_port()
190 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) in ata_acpi_bind_port()
191 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; in ata_acpi_bind_port()
193 adev = ACPI_COMPANION(&ap->tdev); in ata_acpi_bind_port()
194 if (!adev || adev->hp) in ata_acpi_bind_port()
201 context->data.ap = ap; in ata_acpi_bind_port()
202 acpi_initialize_hp_context(adev, &context->hp, ata_acpi_ap_notify_dock, in ata_acpi_bind_port()
208 struct ata_port *ap = dev->link->ap; in ata_acpi_bind_dev()
209 struct acpi_device *port_companion = ACPI_COMPANION(&ap->tdev); in ata_acpi_bind_dev()
210 struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev); in ata_acpi_bind_dev()
220 (!(ap->flags & ATA_FLAG_ACPI_SATA) && !port_companion)) in ata_acpi_bind_dev()
223 if (ap->flags & ATA_FLAG_ACPI_SATA) { in ata_acpi_bind_dev()
225 adr = SATA_ADR(ap->port_no, NO_PORT_MULT); in ata_acpi_bind_dev()
227 adr = SATA_ADR(ap->port_no, dev->link->pmp); in ata_acpi_bind_dev()
230 adr = dev->devno; in ata_acpi_bind_dev()
234 acpi_preset_companion(&dev->tdev, parent, adr); in ata_acpi_bind_dev()
235 adev = ACPI_COMPANION(&dev->tdev); in ata_acpi_bind_dev()
236 if (!adev || adev->hp) in ata_acpi_bind_dev()
243 context->data.dev = dev; in ata_acpi_bind_dev()
244 acpi_initialize_hp_context(adev, &context->hp, ata_acpi_dev_notify_dock, in ata_acpi_bind_dev()
249 * ata_acpi_dissociate - dissociate ATA host from ACPI objects
265 for (i = 0; i < host->n_ports; i++) { in ata_acpi_dissociate()
266 struct ata_port *ap = host->ports[i]; in ata_acpi_dissociate()
269 if (ACPI_HANDLE(&ap->tdev) && gtm) in ata_acpi_dissociate()
275 * ata_acpi_gtm - execute _GTM
285 * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
293 acpi_handle handle = ACPI_HANDLE(&ap->tdev); in ata_acpi_gtm()
296 return -EINVAL; in ata_acpi_gtm()
300 rc = -ENOENT; in ata_acpi_gtm()
304 rc = -EINVAL; in ata_acpi_gtm()
312 if (out_obj->type != ACPI_TYPE_BUFFER) { in ata_acpi_gtm()
314 out_obj->type); in ata_acpi_gtm()
319 if (out_obj->buffer.length != sizeof(struct ata_acpi_gtm)) { in ata_acpi_gtm()
321 out_obj->buffer.length); in ata_acpi_gtm()
325 memcpy(gtm, out_obj->buffer.pointer, sizeof(struct ata_acpi_gtm)); in ata_acpi_gtm()
335 * ata_acpi_stm - execute _STM
345 * 0 on success, -ENOENT if _STM doesn't exist, -errno on failure.
360 in_params[1].buffer.pointer = (u8 *)ap->link.device[0].id; in ata_acpi_stm()
363 in_params[2].buffer.pointer = (u8 *)ap->link.device[1].id; in ata_acpi_stm()
368 status = acpi_evaluate_object(ACPI_HANDLE(&ap->tdev), "_STM", in ata_acpi_stm()
372 return -ENOENT; in ata_acpi_stm()
376 return -EINVAL; in ata_acpi_stm()
384 * ata_dev_get_GTF - get the drive bootup default taskfile settings
393 * The <variable number> is not known in advance, so have ACPI-CA
400 * Number of taskfiles on success, 0 if _GTF doesn't exist. -EINVAL
411 if (dev->gtf_cache) { in ata_dev_get_GTF()
412 out_obj = dev->gtf_cache; in ata_dev_get_GTF()
418 output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ in ata_dev_get_GTF()
423 out_obj = dev->gtf_cache = output.pointer; in ata_dev_get_GTF()
429 rc = -EINVAL; in ata_dev_get_GTF()
435 ata_dev_dbg(dev, "Run _GTF: length or ptr is NULL (0x%llx, 0x%p)\n", in ata_dev_get_GTF()
438 rc = -EINVAL; in ata_dev_get_GTF()
442 if (out_obj->type != ACPI_TYPE_BUFFER) { in ata_dev_get_GTF()
444 out_obj->type); in ata_dev_get_GTF()
445 rc = -EINVAL; in ata_dev_get_GTF()
449 if (out_obj->buffer.length % REGS_PER_GTF) { in ata_dev_get_GTF()
451 out_obj->buffer.length); in ata_dev_get_GTF()
452 rc = -EINVAL; in ata_dev_get_GTF()
457 rc = out_obj->buffer.length / REGS_PER_GTF; in ata_dev_get_GTF()
459 *gtf = (void *)out_obj->buffer.pointer; in ata_dev_get_GTF()
460 ata_dev_dbg(dev, "returning gtf=%p, gtf_count=%d\n", in ata_dev_get_GTF()
471 * ata_acpi_gtm_xfermask - determine xfermode from GTM parameter
492 unit = dev->devno; in ata_acpi_gtm_xfermask()
493 if (!(gtm->flags & 0x10)) in ata_acpi_gtm_xfermask()
497 mode = ata_timing_cycle2mode(ATA_SHIFT_PIO, gtm->drive[unit].pio); in ata_acpi_gtm_xfermask()
500 /* See if we have MWDMA or UDMA data. We don't bother with in ata_acpi_gtm_xfermask()
501 * MWDMA if UDMA is available as this means the BIOS set UDMA in ata_acpi_gtm_xfermask()
502 * and our error changedown if it works is UDMA to PIO anyway. in ata_acpi_gtm_xfermask()
504 if (!(gtm->flags & (1 << (2 * unit)))) in ata_acpi_gtm_xfermask()
509 mode = ata_timing_cycle2mode(type, gtm->drive[unit].dma); in ata_acpi_gtm_xfermask()
517 * ata_acpi_cbl_80wire - Check for 80 wire cable
527 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_acpi_cbl_80wire()
547 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in ata_acpi_gtf_to_tf()
548 tf->protocol = ATA_PROT_NODATA; in ata_acpi_gtf_to_tf()
549 tf->error = gtf->tf[0]; /* 0x1f1 */ in ata_acpi_gtf_to_tf()
550 tf->nsect = gtf->tf[1]; /* 0x1f2 */ in ata_acpi_gtf_to_tf()
551 tf->lbal = gtf->tf[2]; /* 0x1f3 */ in ata_acpi_gtf_to_tf()
552 tf->lbam = gtf->tf[3]; /* 0x1f4 */ in ata_acpi_gtf_to_tf()
553 tf->lbah = gtf->tf[4]; /* 0x1f5 */ in ata_acpi_gtf_to_tf()
554 tf->device = gtf->tf[5]; /* 0x1f6 */ in ata_acpi_gtf_to_tf()
555 tf->status = gtf->tf[6]; /* 0x1f7 */ in ata_acpi_gtf_to_tf()
562 if (dev->gtf_filter & ATA_ACPI_FILTER_SETXFER) { in ata_acpi_filter_tf()
566 if (tf->command == ATA_CMD_SET_FEATURES && in ata_acpi_filter_tf()
567 tf->feature == SETFEATURES_XFER) in ata_acpi_filter_tf()
571 if (dev->gtf_filter & ATA_ACPI_FILTER_LOCK) { in ata_acpi_filter_tf()
577 if (tf->command == ATA_CMD_CONF_OVERLAY && in ata_acpi_filter_tf()
578 tf->feature == ATA_DCO_FREEZE_LOCK) in ata_acpi_filter_tf()
582 if (tf->command == ATA_CMD_SEC_FREEZE_LOCK) in ata_acpi_filter_tf()
586 if ((!ptf || ptf->command != ATA_CMD_READ_NATIVE_MAX) && in ata_acpi_filter_tf()
587 tf->command == ATA_CMD_SET_MAX && in ata_acpi_filter_tf()
588 (tf->feature == ATA_SET_MAX_LOCK || in ata_acpi_filter_tf()
589 tf->feature == ATA_SET_MAX_FREEZE_LOCK)) in ata_acpi_filter_tf()
593 if (tf->command == ATA_CMD_SET_FEATURES && in ata_acpi_filter_tf()
594 tf->feature == SETFEATURES_SATA_ENABLE) { in ata_acpi_filter_tf()
596 if (dev->gtf_filter & ATA_ACPI_FILTER_DIPM && in ata_acpi_filter_tf()
597 tf->nsect == SATA_DIPM) in ata_acpi_filter_tf()
600 /* inhibit FPDMA non-zero offset */ in ata_acpi_filter_tf()
601 if (dev->gtf_filter & ATA_ACPI_FILTER_FPDMA_OFFSET && in ata_acpi_filter_tf()
602 (tf->nsect == SATA_FPDMA_OFFSET || in ata_acpi_filter_tf()
603 tf->nsect == SATA_FPDMA_IN_ORDER)) in ata_acpi_filter_tf()
607 if (dev->gtf_filter & ATA_ACPI_FILTER_FPDMA_AA && in ata_acpi_filter_tf()
608 tf->nsect == SATA_FPDMA_AA) in ata_acpi_filter_tf()
616 * ata_acpi_run_tf - send taskfile registers to host controller
618 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
636 * filtered out, -errno on other errors.
648 if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0) in ata_acpi_run_tf()
649 && (gtf->tf[3] == 0) && (gtf->tf[4] == 0) && (gtf->tf[5] == 0) in ata_acpi_run_tf()
650 && (gtf->tf[6] == 0)) in ata_acpi_run_tf()
693 rc = -EIO; in ata_acpi_run_tf()
708 * ata_acpi_exec_tfs - get then write drive taskfile settings
719 * -errno on other errors.
751 * ata_acpi_push_id - send Identify data to drive
755 * Must be after Identify (Packet) Device -- uses its data
764 * 0 on success, -ENOENT if _SDD doesn't exist, -errno on failure.
768 struct ata_port *ap = dev->link->ap; in ata_acpi_push_id()
774 __func__, dev->devno, ap->port_no); in ata_acpi_push_id()
781 in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS; in ata_acpi_push_id()
782 in_params[0].buffer.pointer = (u8 *)dev->id; in ata_acpi_push_id()
786 swap_buf_le16(dev->id, ATA_ID_WORDS); in ata_acpi_push_id()
789 swap_buf_le16(dev->id, ATA_ID_WORDS); in ata_acpi_push_id()
792 return -ENOENT; in ata_acpi_push_id()
796 return -EIO; in ata_acpi_push_id()
803 * ata_acpi_on_resume - ATA ACPI hook called on resume
806 * This function is called when @ap is resumed - right after port
817 if (ACPI_HANDLE(&ap->tdev) && gtm) { in ata_acpi_on_resume()
827 ata_for_each_dev(dev, &ap->link, ALL) { in ata_acpi_on_resume()
832 dev->flags |= ATA_DFLAG_ACPI_PENDING; in ata_acpi_on_resume()
839 ata_for_each_dev(dev, &ap->link, ALL) { in ata_acpi_on_resume()
842 dev->flags |= ATA_DFLAG_ACPI_PENDING; in ata_acpi_on_resume()
857 if (dev->class == ATA_DEV_ATAPI && in ata_acpi_choose_suspend_state()
862 return acpi_pm_device_sleep_state(&dev->tdev, NULL, d_max_in); in ata_acpi_choose_suspend_state()
872 ata_for_each_dev(dev, &ap->link, ENABLED) { in sata_acpi_set_state()
899 port_handle = ACPI_HANDLE(&ap->tdev); in pata_acpi_set_state()
908 ata_for_each_dev(dev, &ap->link, ENABLED) { in pata_acpi_set_state()
922 * ata_acpi_set_state - set the port power state
931 if (ap->flags & ATA_FLAG_ACPI_SATA) in ata_acpi_set_state()
938 * ata_acpi_on_devcfg - ATA ACPI hook called on device donfiguration
949 * -errno on failure.
953 struct ata_port *ap = dev->link->ap; in ata_acpi_on_devcfg()
954 struct ata_eh_context *ehc = &ap->link.eh_context; in ata_acpi_on_devcfg()
955 int acpi_sata = ap->flags & ATA_FLAG_ACPI_SATA; in ata_acpi_on_devcfg()
963 if (!(dev->flags & ATA_DFLAG_ACPI_PENDING) && in ata_acpi_on_devcfg()
964 !(acpi_sata && (ehc->i.flags & ATA_EHI_DID_HARDRESET))) in ata_acpi_on_devcfg()
970 if (rc && rc != -ENOENT) in ata_acpi_on_devcfg()
979 dev->flags &= ~ATA_DFLAG_ACPI_PENDING; in ata_acpi_on_devcfg()
995 if (rc == -EINVAL && !nr_executed && !ata_port_is_frozen(ap)) in ata_acpi_on_devcfg()
999 if (!(dev->flags & ATA_DFLAG_ACPI_FAILED)) { in ata_acpi_on_devcfg()
1000 dev->flags |= ATA_DFLAG_ACPI_FAILED; in ata_acpi_on_devcfg()
1004 dev->flags |= ATA_DFLAG_ACPI_DISABLED; in ata_acpi_on_devcfg()
1017 * ata_acpi_on_disable - ATA ACPI hook called when a device is disabled