Lines Matching refs:link
38 static unsigned int sata_pmp_read(struct ata_link *link, int reg, u32 *r_val) in sata_pmp_read() argument
40 struct ata_port *ap = link->ap; in sata_pmp_read()
41 struct ata_device *pmp_dev = ap->link.device; in sata_pmp_read()
50 tf.device = link->pmp; in sata_pmp_read()
75 static unsigned int sata_pmp_write(struct ata_link *link, int reg, u32 val) in sata_pmp_write() argument
77 struct ata_port *ap = link->ap; in sata_pmp_write()
78 struct ata_device *pmp_dev = ap->link.device; in sata_pmp_write()
86 tf.device = link->pmp; in sata_pmp_write()
111 struct ata_link *link = qc->dev->link; in sata_pmp_qc_defer_cmd_switch() local
112 struct ata_port *ap = link->ap; in sata_pmp_qc_defer_cmd_switch()
114 if (ap->excl_link == NULL || ap->excl_link == link) { in sata_pmp_qc_defer_cmd_switch()
115 if (ap->nr_active_links == 0 || ata_link_active(link)) { in sata_pmp_qc_defer_cmd_switch()
120 ap->excl_link = link; in sata_pmp_qc_defer_cmd_switch()
141 int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *r_val) in sata_pmp_scr_read() argument
148 err_mask = sata_pmp_read(link, reg, r_val); in sata_pmp_scr_read()
150 ata_link_warn(link, "failed to read SCR %d (Emask=0x%x)\n", in sata_pmp_scr_read()
172 int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val) in sata_pmp_scr_write() argument
179 err_mask = sata_pmp_write(link, reg, val); in sata_pmp_scr_write()
181 ata_link_warn(link, "failed to write SCR %d (Emask=0x%x)\n", in sata_pmp_scr_write()
203 int sata_pmp_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, in sata_pmp_set_lpm() argument
206 return sata_link_scr_lpm(link, policy, true); in sata_pmp_set_lpm()
232 err_mask = sata_pmp_read(dev->link, reg, &gscr[reg]); in sata_pmp_read_gscr()
260 struct ata_port *ap = dev->link->ap; in sata_pmp_configure()
281 err_mask = sata_pmp_write(dev->link, SATA_PMP_GSCR_ERROR_EN, in sata_pmp_configure()
298 err_mask = sata_pmp_read(&ap->link, PMP_GSCR_SII_POL, ®); in sata_pmp_configure()
305 err_mask = sata_pmp_write(&ap->link, PMP_GSCR_SII_POL, reg); in sata_pmp_configure()
361 struct ata_link *link = &pmp_link[i]; in sata_pmp_init_links() local
362 struct ata_eh_context *ehc = &link->eh_context; in sata_pmp_init_links()
364 link->flags = 0; in sata_pmp_init_links()
380 u32 *gscr = ap->link.device->gscr; in sata_pmp_quirks()
383 struct ata_link *link; in sata_pmp_quirks() local
387 ata_for_each_link(link, ap, EDGE) { in sata_pmp_quirks()
389 link->flags |= ATA_LFLAG_NO_LPM; in sata_pmp_quirks()
395 if (link->pmp < 5) in sata_pmp_quirks()
396 link->flags |= ATA_LFLAG_NO_SRST | in sata_pmp_quirks()
400 if (link->pmp == 5) in sata_pmp_quirks()
401 link->flags |= ATA_LFLAG_NO_SRST | in sata_pmp_quirks()
412 ata_for_each_link(link, ap, EDGE) in sata_pmp_quirks()
413 link->flags |= ATA_LFLAG_NO_LPM | in sata_pmp_quirks()
418 ata_for_each_link(link, ap, EDGE) { in sata_pmp_quirks()
420 link->flags |= ATA_LFLAG_NO_LPM; in sata_pmp_quirks()
427 if (link->pmp <= 5) in sata_pmp_quirks()
428 link->flags |= ATA_LFLAG_NO_SRST | in sata_pmp_quirks()
434 if (link->pmp == 6) in sata_pmp_quirks()
435 link->flags |= ATA_LFLAG_NO_SRST | in sata_pmp_quirks()
454 ata_for_each_link(link, ap, EDGE) { in sata_pmp_quirks()
458 link->flags |= ATA_LFLAG_NO_LPM | in sata_pmp_quirks()
464 ata_for_each_link(link, ap, EDGE) { in sata_pmp_quirks()
466 if (link->pmp == 4) in sata_pmp_quirks()
467 link->flags |= ATA_LFLAG_DISABLED; in sata_pmp_quirks()
487 struct ata_link *link = dev->link; in sata_pmp_attach() local
488 struct ata_port *ap = link->ap; in sata_pmp_attach()
499 if (!ata_is_host_link(link)) { in sata_pmp_attach()
509 WARN_ON(link->pmp != 0); in sata_pmp_attach()
510 link->pmp = SATA_PMP_CTRL_PORT; in sata_pmp_attach()
545 link->pmp = 0; in sata_pmp_attach()
561 struct ata_link *link = dev->link; in sata_pmp_detach() local
562 struct ata_port *ap = link->ap; in sata_pmp_detach()
568 WARN_ON(!ata_is_host_link(link) || dev->devno || in sata_pmp_detach()
569 link->pmp != SATA_PMP_CTRL_PORT); in sata_pmp_detach()
579 link->pmp = 0; in sata_pmp_detach()
650 struct ata_link *link = dev->link; in sata_pmp_revalidate() local
651 struct ata_port *ap = link->ap; in sata_pmp_revalidate()
657 ata_eh_about_to_do(link, NULL, ATA_EH_REVALIDATE); in sata_pmp_revalidate()
687 ata_eh_done(link, NULL, ATA_EH_REVALIDATE); in sata_pmp_revalidate()
715 err_mask = sata_pmp_read(dev->link, SATA_PMP_GSCR_PROD_ID, &prod_id); in sata_pmp_revalidate_quick()
755 struct ata_link *link = &ap->link; in sata_pmp_eh_recover_pmp() local
756 struct ata_eh_context *ehc = &link->eh_context; in sata_pmp_eh_recover_pmp()
757 struct ata_device *dev = link->device; in sata_pmp_eh_recover_pmp()
777 rc = ata_eh_reset(link, 0, prereset, softreset, hardreset, in sata_pmp_eh_recover_pmp()
780 ata_link_err(link, "failed to reset PMP, giving up\n"); in sata_pmp_eh_recover_pmp()
814 sata_down_spd_limit(link, 0); in sata_pmp_eh_recover_pmp()
847 struct ata_link *link; in sata_pmp_eh_handle_disabled_links() local
853 ata_for_each_link(link, ap, EDGE) { in sata_pmp_eh_handle_disabled_links()
854 if (!(link->flags & ATA_LFLAG_DISABLED)) in sata_pmp_eh_handle_disabled_links()
862 sata_link_hardreset(link, sata_deb_timing_normal, in sata_pmp_eh_handle_disabled_links()
867 rc = sata_scr_write(link, SCR_ERROR, SERR_PHYRDY_CHG); in sata_pmp_eh_handle_disabled_links()
869 ata_link_err(link, in sata_pmp_eh_handle_disabled_links()
883 static int sata_pmp_handle_link_fail(struct ata_link *link, int *link_tries) in sata_pmp_handle_link_fail() argument
885 struct ata_port *ap = link->ap; in sata_pmp_handle_link_fail()
888 if (link_tries[link->pmp] && --link_tries[link->pmp]) in sata_pmp_handle_link_fail()
892 if (!(link->flags & ATA_LFLAG_DISABLED)) { in sata_pmp_handle_link_fail()
893 ata_link_warn(link, in sata_pmp_handle_link_fail()
898 link->flags |= ATA_LFLAG_DISABLED; in sata_pmp_handle_link_fail()
902 ata_dev_disable(link->device); in sata_pmp_handle_link_fail()
903 link->eh_context.i.action = 0; in sata_pmp_handle_link_fail()
927 struct ata_link *pmp_link = &ap->link; in sata_pmp_eh_recover()
931 struct ata_link *link; in sata_pmp_eh_recover() local
938 ata_for_each_link(link, ap, EDGE) in sata_pmp_eh_recover()
939 link_tries[link->pmp] = ATA_EH_PMP_LINK_TRIES; in sata_pmp_eh_recover()
947 ata_for_each_dev(dev, &ap->link, ALL) in sata_pmp_eh_recover()
956 ata_for_each_link(link, ap, EDGE) in sata_pmp_eh_recover()
957 link_tries[link->pmp] = ATA_EH_PMP_LINK_TRIES; in sata_pmp_eh_recover()
991 ops->pmp_hardreset, ops->pmp_postreset, &link); in sata_pmp_eh_recover()
996 rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf); in sata_pmp_eh_recover()
998 sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf); in sata_pmp_eh_recover()
1004 ata_for_each_link(link, ap, EDGE) in sata_pmp_eh_recover()
1005 if (link->lpm_policy > ATA_LPM_MAX_POWER) in sata_pmp_eh_recover()
1040 ata_for_each_link(link, ap, EDGE) { in sata_pmp_eh_recover()
1041 if (!(gscr_error & (1 << link->pmp))) in sata_pmp_eh_recover()
1044 if (sata_pmp_handle_link_fail(link, link_tries)) { in sata_pmp_eh_recover()
1045 ata_ehi_hotplugged(&link->eh_context.i); in sata_pmp_eh_recover()
1048 ata_link_warn(link, in sata_pmp_eh_recover()
1050 ata_link_warn(link, in sata_pmp_eh_recover()
1064 if (sata_pmp_handle_link_fail(link, link_tries)) { in sata_pmp_eh_recover()