Lines Matching full:ap
48 static ssize_t ahci_led_show(struct ata_port *ap, char *buf);
49 static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
51 static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
59 static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask);
60 static int ahci_port_start(struct ata_port *ap);
61 static void ahci_port_stop(struct ata_port *ap);
64 static void ahci_freeze(struct ata_port *ap);
65 static void ahci_thaw(struct ata_port *ap);
66 static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep);
67 static void ahci_enable_fbs(struct ata_port *ap);
68 static void ahci_disable_fbs(struct ata_port *ap);
69 static void ahci_pmp_attach(struct ata_port *ap);
70 static void ahci_pmp_detach(struct ata_port *ap);
81 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
237 * @ap: Port to power on
243 static int ahci_rpm_get_port(struct ata_port *ap) in ahci_rpm_get_port() argument
245 return pm_runtime_get_sync(ap->dev); in ahci_rpm_get_port()
250 * @ap: Port to power down
255 static void ahci_rpm_put_port(struct ata_port *ap) in ahci_rpm_put_port() argument
257 pm_runtime_put(ap->dev); in ahci_rpm_put_port()
264 struct ata_port *ap = ata_shost_to_port(shost); in ahci_show_host_caps() local
265 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_host_caps()
274 struct ata_port *ap = ata_shost_to_port(shost); in ahci_show_host_cap2() local
275 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_host_cap2()
284 struct ata_port *ap = ata_shost_to_port(shost); in ahci_show_host_version() local
285 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_host_version()
294 struct ata_port *ap = ata_shost_to_port(shost); in ahci_show_port_cmd() local
295 void __iomem *port_mmio = ahci_port_base(ap); in ahci_show_port_cmd()
298 ahci_rpm_get_port(ap); in ahci_show_port_cmd()
300 ahci_rpm_put_port(ap); in ahci_show_port_cmd()
309 struct ata_port *ap = ata_shost_to_port(shost); in ahci_read_em_buffer() local
310 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_read_em_buffer()
318 ahci_rpm_get_port(ap); in ahci_read_em_buffer()
319 spin_lock_irqsave(ap->lock, flags); in ahci_read_em_buffer()
322 if (!(ap->flags & ATA_FLAG_EM) || em_ctl & EM_CTL_XMT || in ahci_read_em_buffer()
324 spin_unlock_irqrestore(ap->lock, flags); in ahci_read_em_buffer()
325 ahci_rpm_put_port(ap); in ahci_read_em_buffer()
330 spin_unlock_irqrestore(ap->lock, flags); in ahci_read_em_buffer()
331 ahci_rpm_put_port(ap); in ahci_read_em_buffer()
343 ata_port_warn(ap, in ahci_read_em_buffer()
358 spin_unlock_irqrestore(ap->lock, flags); in ahci_read_em_buffer()
359 ahci_rpm_put_port(ap); in ahci_read_em_buffer()
369 struct ata_port *ap = ata_shost_to_port(shost); in ahci_store_em_buffer() local
370 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_store_em_buffer()
379 if (!(ap->flags & ATA_FLAG_EM) || in ahci_store_em_buffer()
384 ahci_rpm_get_port(ap); in ahci_store_em_buffer()
385 spin_lock_irqsave(ap->lock, flags); in ahci_store_em_buffer()
389 spin_unlock_irqrestore(ap->lock, flags); in ahci_store_em_buffer()
390 ahci_rpm_put_port(ap); in ahci_store_em_buffer()
402 spin_unlock_irqrestore(ap->lock, flags); in ahci_store_em_buffer()
403 ahci_rpm_put_port(ap); in ahci_store_em_buffer()
412 struct ata_port *ap = ata_shost_to_port(shost); in ahci_show_em_supported() local
413 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_em_supported()
417 ahci_rpm_get_port(ap); in ahci_show_em_supported()
419 ahci_rpm_put_port(ap); in ahci_show_em_supported()
640 static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg) in ahci_scr_offset() argument
649 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_scr_offset()
659 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_scr_read()
660 int offset = ahci_scr_offset(link->ap, sc_reg); in ahci_scr_read()
671 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_scr_write()
672 int offset = ahci_scr_offset(link->ap, sc_reg); in ahci_scr_write()
681 void ahci_start_engine(struct ata_port *ap) in ahci_start_engine() argument
683 void __iomem *port_mmio = ahci_port_base(ap); in ahci_start_engine()
694 int ahci_stop_engine(struct ata_port *ap) in ahci_stop_engine() argument
696 void __iomem *port_mmio = ahci_port_base(ap); in ahci_stop_engine()
697 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_stop_engine()
707 (ap->link.lpm_policy > ATA_LPM_MAX_POWER) && in ahci_stop_engine()
708 ahci_set_lpm(&ap->link, ATA_LPM_MAX_POWER, ATA_LPM_WAKE_ONLY)) { in ahci_stop_engine()
709 dev_err(ap->host->dev, "Failed to wake up port before engine stop\n"); in ahci_stop_engine()
725 dev_err(ap->host->dev, "AHCI controller unavailable!\n"); in ahci_stop_engine()
734 tmp = ata_wait_register(ap, port_mmio + PORT_CMD, in ahci_stop_engine()
743 void ahci_start_fis_rx(struct ata_port *ap) in ahci_start_fis_rx() argument
745 void __iomem *port_mmio = ahci_port_base(ap); in ahci_start_fis_rx()
746 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_start_fis_rx()
747 struct ahci_port_priv *pp = ap->private_data; in ahci_start_fis_rx()
771 static int ahci_stop_fis_rx(struct ata_port *ap) in ahci_stop_fis_rx() argument
773 void __iomem *port_mmio = ahci_port_base(ap); in ahci_stop_fis_rx()
782 tmp = ata_wait_register(ap, port_mmio + PORT_CMD, PORT_CMD_FIS_ON, in ahci_stop_fis_rx()
790 static void ahci_power_up(struct ata_port *ap) in ahci_power_up() argument
792 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_power_up()
793 void __iomem *port_mmio = ahci_port_base(ap); in ahci_power_up()
811 struct ata_port *ap = link->ap; in ahci_set_lpm() local
812 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_set_lpm()
813 struct ahci_port_priv *pp = ap->private_data; in ahci_set_lpm()
814 void __iomem *port_mmio = ahci_port_base(ap); in ahci_set_lpm()
843 ata_msleep(ap, 10); in ahci_set_lpm()
865 ahci_set_aggressive_devslp(ap, true); in ahci_set_lpm()
867 ahci_set_aggressive_devslp(ap, false); in ahci_set_lpm()
882 static void ahci_power_down(struct ata_port *ap) in ahci_power_down() argument
884 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_power_down()
885 void __iomem *port_mmio = ahci_port_base(ap); in ahci_power_down()
903 static void ahci_start_port(struct ata_port *ap) in ahci_start_port() argument
905 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_start_port()
906 struct ahci_port_priv *pp = ap->private_data; in ahci_start_port()
913 ahci_start_fis_rx(ap); in ahci_start_port()
917 hpriv->start_engine(ap); in ahci_start_port()
920 if (ap->flags & ATA_FLAG_EM) { in ahci_start_port()
921 ata_for_each_link(link, ap, EDGE) { in ahci_start_port()
926 rc = ap->ops->transmit_led_message(ap, in ahci_start_port()
945 if (ap->flags & ATA_FLAG_SW_ACTIVITY) in ahci_start_port()
946 ata_for_each_link(link, ap, EDGE) in ahci_start_port()
951 static int ahci_deinit_port(struct ata_port *ap, const char **emsg) in ahci_deinit_port() argument
954 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_deinit_port()
957 rc = hpriv->stop_engine(ap); in ahci_deinit_port()
964 rc = ahci_stop_fis_rx(ap); in ahci_deinit_port()
1023 struct ata_port *ap = link->ap; in ahci_sw_activity() local
1024 struct ahci_port_priv *pp = ap->private_data; in ahci_sw_activity()
1039 struct ata_port *ap = link->ap; in ahci_sw_activity_blink() local
1046 led_message |= ap->port_no | (link->pmp << 8); in ahci_sw_activity_blink()
1052 spin_lock_irqsave(ap->lock, flags); in ahci_sw_activity_blink()
1075 spin_unlock_irqrestore(ap->lock, flags); in ahci_sw_activity_blink()
1076 ap->ops->transmit_led_message(ap, led_message, 4); in ahci_sw_activity_blink()
1081 struct ata_port *ap = link->ap; in ahci_init_sw_activity() local
1082 struct ahci_port_priv *pp = ap->private_data; in ahci_init_sw_activity()
1110 static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state, in ahci_transmit_led_message() argument
1113 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_transmit_led_message()
1114 struct ahci_port_priv *pp = ap->private_data; in ahci_transmit_led_message()
1129 ahci_rpm_get_port(ap); in ahci_transmit_led_message()
1130 spin_lock_irqsave(ap->lock, flags); in ahci_transmit_led_message()
1138 spin_unlock_irqrestore(ap->lock, flags); in ahci_transmit_led_message()
1139 ahci_rpm_put_port(ap); in ahci_transmit_led_message()
1151 message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no); in ahci_transmit_led_message()
1166 spin_unlock_irqrestore(ap->lock, flags); in ahci_transmit_led_message()
1167 ahci_rpm_put_port(ap); in ahci_transmit_led_message()
1172 static ssize_t ahci_led_show(struct ata_port *ap, char *buf) in ahci_led_show() argument
1174 struct ahci_port_priv *pp = ap->private_data; in ahci_led_show()
1179 ata_for_each_link(link, ap, EDGE) { in ahci_led_show()
1186 static ssize_t ahci_led_store(struct ata_port *ap, const char *buf, in ahci_led_store() argument
1191 struct ahci_port_priv *pp = ap->private_data; in ahci_led_store()
1213 return ap->ops->transmit_led_message(ap, state, size); in ahci_led_store()
1219 struct ata_port *ap = link->ap; in ahci_activity_store() local
1220 struct ahci_port_priv *pp = ap->private_data; in ahci_activity_store()
1231 port_led_state |= (ap->port_no | (link->pmp << 8)); in ahci_activity_store()
1232 ap->ops->transmit_led_message(ap, port_led_state, 4); in ahci_activity_store()
1238 port_led_state |= (ap->port_no | (link->pmp << 8)); in ahci_activity_store()
1240 ap->ops->transmit_led_message(ap, port_led_state, 4); in ahci_activity_store()
1250 struct ata_port *ap = link->ap; in ahci_activity_show() local
1251 struct ahci_port_priv *pp = ap->private_data; in ahci_activity_show()
1260 static void ahci_port_clear_pending_irq(struct ata_port *ap) in ahci_port_clear_pending_irq() argument
1262 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_clear_pending_irq()
1263 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_clear_pending_irq()
1268 dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp); in ahci_port_clear_pending_irq()
1273 dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp); in ahci_port_clear_pending_irq()
1277 writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT); in ahci_port_clear_pending_irq()
1280 static void ahci_port_init(struct device *dev, struct ata_port *ap, in ahci_port_init() argument
1288 rc = ahci_deinit_port(ap, &emsg); in ahci_port_init()
1292 ahci_port_clear_pending_irq(ap); in ahci_port_init()
1304 struct ata_port *ap = host->ports[i]; in ahci_init_controller() local
1306 port_mmio = ahci_port_base(ap); in ahci_init_controller()
1307 if (ata_port_is_dummy(ap)) in ahci_init_controller()
1310 ahci_port_init(host->dev, ap, i, mmio, port_mmio); in ahci_init_controller()
1323 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; in ahci_dev_config()
1336 unsigned int ahci_dev_classify(struct ata_port *ap) in ahci_dev_classify() argument
1338 void __iomem *port_mmio = ahci_port_base(ap); in ahci_dev_classify()
1348 return ata_port_classify(ap, &tf); in ahci_dev_classify()
1366 int ahci_kick_engine(struct ata_port *ap) in ahci_kick_engine() argument
1368 void __iomem *port_mmio = ahci_port_base(ap); in ahci_kick_engine()
1369 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_kick_engine()
1375 rc = hpriv->stop_engine(ap); in ahci_kick_engine()
1383 if (!busy && !sata_pmp_attached(ap)) { in ahci_kick_engine()
1399 tmp = ata_wait_register(ap, port_mmio + PORT_CMD, in ahci_kick_engine()
1406 hpriv->start_engine(ap); in ahci_kick_engine()
1411 static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp, in ahci_exec_polled_cmd() argument
1416 struct ahci_port_priv *pp = ap->private_data; in ahci_exec_polled_cmd()
1417 void __iomem *port_mmio = ahci_port_base(ap); in ahci_exec_polled_cmd()
1438 tmp = ata_wait_register(ap, port_mmio + PORT_CMD_ISSUE, in ahci_exec_polled_cmd()
1441 ahci_kick_engine(ap); in ahci_exec_polled_cmd()
1454 struct ata_port *ap = link->ap; in ahci_do_softreset() local
1455 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_softreset()
1456 struct ahci_port_priv *pp = ap->private_data; in ahci_do_softreset()
1465 rc = ahci_kick_engine(ap); in ahci_do_softreset()
1475 ahci_disable_fbs(ap); in ahci_do_softreset()
1488 if (ahci_exec_polled_cmd(ap, pmp, &tf, 0, in ahci_do_softreset()
1496 ata_msleep(ap, 1); in ahci_do_softreset()
1500 ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0); in ahci_do_softreset()
1517 *class = ahci_dev_classify(ap); in ahci_do_softreset()
1521 ahci_enable_fbs(ap); in ahci_do_softreset()
1532 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_check_ready()
1550 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_bad_pmp_check_ready()
1567 struct ata_port *ap = link->ap; in ahci_pmp_retry_softreset() local
1568 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_retry_softreset()
1599 struct ata_port *ap = link->ap; in ahci_do_hardreset() local
1600 struct ahci_port_priv *pp = ap->private_data; in ahci_do_hardreset()
1601 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_hardreset()
1606 hpriv->stop_engine(ap); in ahci_do_hardreset()
1613 ahci_port_clear_pending_irq(ap); in ahci_do_hardreset()
1618 hpriv->start_engine(ap); in ahci_do_hardreset()
1621 *class = ahci_dev_classify(ap); in ahci_do_hardreset()
1637 struct ata_port *ap = link->ap; in ahci_postreset() local
1638 void __iomem *port_mmio = ahci_port_base(ap); in ahci_postreset()
1678 struct ata_port *ap = qc->ap; in ahci_pmp_qc_defer() local
1679 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_qc_defer()
1681 if (!sata_pmp_attached(ap) || pp->fbs_enabled) in ahci_pmp_qc_defer()
1689 struct ata_port *ap = qc->ap; in ahci_qc_prep() local
1690 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_prep()
1727 static void ahci_fbs_dec_intr(struct ata_port *ap) in ahci_fbs_dec_intr() argument
1729 struct ahci_port_priv *pp = ap->private_data; in ahci_fbs_dec_intr()
1730 void __iomem *port_mmio = ahci_port_base(ap); in ahci_fbs_dec_intr()
1747 dev_err(ap->host->dev, "failed to clear device error\n"); in ahci_fbs_dec_intr()
1750 static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) in ahci_error_intr() argument
1752 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_intr()
1753 struct ahci_port_priv *pp = ap->private_data; in ahci_error_intr()
1754 struct ata_eh_info *host_ehi = &ap->link.eh_info; in ahci_error_intr()
1763 void __iomem *port_mmio = ahci_port_base(ap); in ahci_error_intr()
1767 if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links)) { in ahci_error_intr()
1768 link = &ap->pmp_link[pmp]; in ahci_error_intr()
1773 ata_for_each_link(link, ap, EDGE) in ahci_error_intr()
1778 link = &ap->link; in ahci_error_intr()
1780 active_qc = ata_qc_from_tag(ap, link->active_tag); in ahci_error_intr()
1788 ahci_scr_read(&ap->link, SCR_ERROR, &serror); in ahci_error_intr()
1789 ahci_scr_write(&ap->link, SCR_ERROR, serror); in ahci_error_intr()
1820 if (sata_pmp_attached(ap) && (irq_stat & PORT_IRQ_BAD_PMP)) { in ahci_error_intr()
1853 ata_port_freeze(ap); in ahci_error_intr()
1856 ahci_fbs_dec_intr(ap); in ahci_error_intr()
1858 ata_port_abort(ap); in ahci_error_intr()
1861 static void ahci_qc_complete(struct ata_port *ap, void __iomem *port_mmio) in ahci_qc_complete() argument
1863 struct ata_eh_info *ehi = &ap->link.eh_info; in ahci_qc_complete()
1864 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_complete()
1874 if (ap->qc_active) { in ahci_qc_complete()
1880 if (ap->qc_active && pp->active_link->sactive) in ahci_qc_complete()
1886 rc = ata_qc_complete_multiple(ap, qc_active); in ahci_qc_complete()
1887 if (unlikely(rc < 0 && !(ap->pflags & ATA_PFLAG_RESETTING))) { in ahci_qc_complete()
1890 ata_port_freeze(ap); in ahci_qc_complete()
1894 static void ahci_handle_port_interrupt(struct ata_port *ap, in ahci_handle_port_interrupt() argument
1897 struct ahci_port_priv *pp = ap->private_data; in ahci_handle_port_interrupt()
1898 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_handle_port_interrupt()
1901 if (unlikely(ap->pflags & ATA_PFLAG_RESETTING)) in ahci_handle_port_interrupt()
1904 if (sata_lpm_ignore_phy_events(&ap->link)) { in ahci_handle_port_interrupt()
1906 ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG); in ahci_handle_port_interrupt()
1915 ahci_qc_complete(ap, port_mmio); in ahci_handle_port_interrupt()
1916 ahci_error_intr(ap, status); in ahci_handle_port_interrupt()
1931 sata_async_notification(ap); in ahci_handle_port_interrupt()
1947 sata_async_notification(ap); in ahci_handle_port_interrupt()
1953 ahci_qc_complete(ap, port_mmio); in ahci_handle_port_interrupt()
1956 static void ahci_port_intr(struct ata_port *ap) in ahci_port_intr() argument
1958 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_intr()
1964 ahci_handle_port_interrupt(ap, port_mmio, status); in ahci_port_intr()
1969 struct ata_port *ap = dev_instance; in ahci_multi_irqs_intr_hard() local
1970 void __iomem *port_mmio = ahci_port_base(ap); in ahci_multi_irqs_intr_hard()
1976 spin_lock(ap->lock); in ahci_multi_irqs_intr_hard()
1977 ahci_handle_port_interrupt(ap, port_mmio, status); in ahci_multi_irqs_intr_hard()
1978 spin_unlock(ap->lock); in ahci_multi_irqs_intr_hard()
1988 struct ata_port *ap; in ahci_handle_port_intr() local
1993 ap = host->ports[i]; in ahci_handle_port_intr()
1994 if (ap) { in ahci_handle_port_intr()
1995 ahci_port_intr(ap); in ahci_handle_port_intr()
2049 struct ata_port *ap = qc->ap; in ahci_qc_issue() local
2050 void __iomem *port_mmio = ahci_port_base(ap); in ahci_qc_issue()
2051 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_issue()
2080 struct ahci_port_priv *pp = qc->ap->private_data; in ahci_qc_fill_rtf()
2124 static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask) in ahci_qc_ncq_fill_rtf() argument
2126 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_ncq_fill_rtf()
2130 if (!ap->qc_active) in ahci_qc_ncq_fill_rtf()
2152 qc = ata_qc_from_tag(ap, tag); in ahci_qc_ncq_fill_rtf()
2174 qc = ata_qc_from_tag(ap, tag); in ahci_qc_ncq_fill_rtf()
2188 static void ahci_freeze(struct ata_port *ap) in ahci_freeze() argument
2190 void __iomem *port_mmio = ahci_port_base(ap); in ahci_freeze()
2196 static void ahci_thaw(struct ata_port *ap) in ahci_thaw() argument
2198 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_thaw()
2200 void __iomem *port_mmio = ahci_port_base(ap); in ahci_thaw()
2202 struct ahci_port_priv *pp = ap->private_data; in ahci_thaw()
2207 writel(1 << ap->port_no, mmio + HOST_IRQ_STAT); in ahci_thaw()
2213 void ahci_error_handler(struct ata_port *ap) in ahci_error_handler() argument
2215 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_handler()
2217 if (!ata_port_is_frozen(ap)) { in ahci_error_handler()
2219 hpriv->stop_engine(ap); in ahci_error_handler()
2220 hpriv->start_engine(ap); in ahci_error_handler()
2223 sata_pmp_error_handler(ap); in ahci_error_handler()
2225 if (!ata_dev_enabled(ap->link.device)) in ahci_error_handler()
2226 hpriv->stop_engine(ap); in ahci_error_handler()
2232 struct ata_port *ap = qc->ap; in ahci_post_internal_cmd() local
2236 ahci_kick_engine(ap); in ahci_post_internal_cmd()
2239 static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) in ahci_set_aggressive_devslp() argument
2241 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_set_aggressive_devslp()
2242 void __iomem *port_mmio = ahci_port_base(ap); in ahci_set_aggressive_devslp()
2243 struct ata_device *dev = ap->link.device; in ahci_set_aggressive_devslp()
2250 dev_info(ap->host->dev, "port does not support device sleep\n"); in ahci_set_aggressive_devslp()
2280 rc = hpriv->stop_engine(ap); in ahci_set_aggressive_devslp()
2309 hpriv->start_engine(ap); in ahci_set_aggressive_devslp()
2319 static void ahci_enable_fbs(struct ata_port *ap) in ahci_enable_fbs() argument
2321 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_enable_fbs()
2322 struct ahci_port_priv *pp = ap->private_data; in ahci_enable_fbs()
2323 void __iomem *port_mmio = ahci_port_base(ap); in ahci_enable_fbs()
2337 rc = hpriv->stop_engine(ap); in ahci_enable_fbs()
2344 dev_info(ap->host->dev, "FBS is enabled\n"); in ahci_enable_fbs()
2348 dev_err(ap->host->dev, "Failed to enable FBS\n"); in ahci_enable_fbs()
2350 hpriv->start_engine(ap); in ahci_enable_fbs()
2353 static void ahci_disable_fbs(struct ata_port *ap) in ahci_disable_fbs() argument
2355 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_disable_fbs()
2356 struct ahci_port_priv *pp = ap->private_data; in ahci_disable_fbs()
2357 void __iomem *port_mmio = ahci_port_base(ap); in ahci_disable_fbs()
2370 rc = hpriv->stop_engine(ap); in ahci_disable_fbs()
2377 dev_err(ap->host->dev, "Failed to disable FBS\n"); in ahci_disable_fbs()
2379 dev_info(ap->host->dev, "FBS is disabled\n"); in ahci_disable_fbs()
2383 hpriv->start_engine(ap); in ahci_disable_fbs()
2386 static void ahci_pmp_attach(struct ata_port *ap) in ahci_pmp_attach() argument
2388 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_attach()
2389 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_attach()
2396 ahci_enable_fbs(ap); in ahci_pmp_attach()
2408 if (!ata_port_is_frozen(ap)) in ahci_pmp_attach()
2412 static void ahci_pmp_detach(struct ata_port *ap) in ahci_pmp_detach() argument
2414 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_detach()
2415 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_detach()
2418 ahci_disable_fbs(ap); in ahci_pmp_detach()
2427 if (!ata_port_is_frozen(ap)) in ahci_pmp_detach()
2431 int ahci_port_resume(struct ata_port *ap) in ahci_port_resume() argument
2433 ahci_rpm_get_port(ap); in ahci_port_resume()
2435 ahci_power_up(ap); in ahci_port_resume()
2436 ahci_start_port(ap); in ahci_port_resume()
2438 if (sata_pmp_attached(ap)) in ahci_port_resume()
2439 ahci_pmp_attach(ap); in ahci_port_resume()
2441 ahci_pmp_detach(ap); in ahci_port_resume()
2448 static void ahci_handle_s2idle(struct ata_port *ap) in ahci_handle_s2idle() argument
2450 void __iomem *port_mmio = ahci_port_base(ap); in ahci_handle_s2idle()
2457 ata_msleep(ap, devslp_idle_timeout); in ahci_handle_s2idle()
2460 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg) in ahci_port_suspend() argument
2465 rc = ahci_deinit_port(ap, &emsg); in ahci_port_suspend()
2467 ahci_power_down(ap); in ahci_port_suspend()
2469 ata_port_err(ap, "%s (%d)\n", emsg, rc); in ahci_port_suspend()
2470 ata_port_freeze(ap); in ahci_port_suspend()
2473 if (acpi_storage_d3(ap->host->dev)) in ahci_port_suspend()
2474 ahci_handle_s2idle(ap); in ahci_port_suspend()
2476 ahci_rpm_put_port(ap); in ahci_port_suspend()
2481 static int ahci_port_start(struct ata_port *ap) in ahci_port_start() argument
2483 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_start()
2484 struct device *dev = ap->host->dev; in ahci_port_start()
2494 if (ap->host->n_ports > 1) { in ahci_port_start()
2501 "%s%d", dev_driver_string(dev), ap->port_no); in ahci_port_start()
2505 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) { in ahci_port_start()
2506 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_start()
2512 ap->port_no); in ahci_port_start()
2516 ap->port_no); in ahci_port_start()
2568 ap->lock = &pp->lock; in ahci_port_start()
2571 ap->private_data = pp; in ahci_port_start()
2574 return ahci_port_resume(ap); in ahci_port_start()
2577 static void ahci_port_stop(struct ata_port *ap) in ahci_port_stop() argument
2580 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_stop()
2585 rc = ahci_deinit_port(ap, &emsg); in ahci_port_stop()
2587 ata_port_warn(ap, "%s (%d)\n", emsg, rc); in ahci_port_stop()
2593 writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT); in ahci_port_stop()
2595 ahci_rpm_put_port(ap); in ahci_port_stop()