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()
639 static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg) in ahci_scr_offset() argument
648 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_scr_offset()
658 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_scr_read()
659 int offset = ahci_scr_offset(link->ap, sc_reg); in ahci_scr_read()
670 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_scr_write()
671 int offset = ahci_scr_offset(link->ap, sc_reg); in ahci_scr_write()
680 void ahci_start_engine(struct ata_port *ap) in ahci_start_engine() argument
682 void __iomem *port_mmio = ahci_port_base(ap); in ahci_start_engine()
693 int ahci_stop_engine(struct ata_port *ap) in ahci_stop_engine() argument
695 void __iomem *port_mmio = ahci_port_base(ap); in ahci_stop_engine()
696 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_stop_engine()
706 (ap->link.lpm_policy > ATA_LPM_MAX_POWER) && in ahci_stop_engine()
707 ahci_set_lpm(&ap->link, ATA_LPM_MAX_POWER, ATA_LPM_WAKE_ONLY)) { in ahci_stop_engine()
708 dev_err(ap->host->dev, "Failed to wake up port before engine stop\n"); in ahci_stop_engine()
724 dev_err(ap->host->dev, "AHCI controller unavailable!\n"); in ahci_stop_engine()
733 tmp = ata_wait_register(ap, port_mmio + PORT_CMD, in ahci_stop_engine()
742 void ahci_start_fis_rx(struct ata_port *ap) in ahci_start_fis_rx() argument
744 void __iomem *port_mmio = ahci_port_base(ap); in ahci_start_fis_rx()
745 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_start_fis_rx()
746 struct ahci_port_priv *pp = ap->private_data; in ahci_start_fis_rx()
770 static int ahci_stop_fis_rx(struct ata_port *ap) in ahci_stop_fis_rx() argument
772 void __iomem *port_mmio = ahci_port_base(ap); in ahci_stop_fis_rx()
781 tmp = ata_wait_register(ap, port_mmio + PORT_CMD, PORT_CMD_FIS_ON, in ahci_stop_fis_rx()
789 static void ahci_power_up(struct ata_port *ap) in ahci_power_up() argument
791 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_power_up()
792 void __iomem *port_mmio = ahci_port_base(ap); in ahci_power_up()
810 struct ata_port *ap = link->ap; in ahci_set_lpm() local
811 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_set_lpm()
812 struct ahci_port_priv *pp = ap->private_data; in ahci_set_lpm()
813 void __iomem *port_mmio = ahci_port_base(ap); in ahci_set_lpm()
842 ata_msleep(ap, 10); in ahci_set_lpm()
864 ahci_set_aggressive_devslp(ap, true); in ahci_set_lpm()
866 ahci_set_aggressive_devslp(ap, false); in ahci_set_lpm()
881 static void ahci_power_down(struct ata_port *ap) in ahci_power_down() argument
883 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_power_down()
884 void __iomem *port_mmio = ahci_port_base(ap); in ahci_power_down()
902 static void ahci_start_port(struct ata_port *ap) in ahci_start_port() argument
904 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_start_port()
905 struct ahci_port_priv *pp = ap->private_data; in ahci_start_port()
912 ahci_start_fis_rx(ap); in ahci_start_port()
916 hpriv->start_engine(ap); in ahci_start_port()
919 if (ap->flags & ATA_FLAG_EM) { in ahci_start_port()
920 ata_for_each_link(link, ap, EDGE) { in ahci_start_port()
925 rc = ap->ops->transmit_led_message(ap, in ahci_start_port()
944 if (ap->flags & ATA_FLAG_SW_ACTIVITY) in ahci_start_port()
945 ata_for_each_link(link, ap, EDGE) in ahci_start_port()
950 static int ahci_deinit_port(struct ata_port *ap, const char **emsg) in ahci_deinit_port() argument
953 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_deinit_port()
956 rc = hpriv->stop_engine(ap); in ahci_deinit_port()
963 rc = ahci_stop_fis_rx(ap); in ahci_deinit_port()
1022 struct ata_port *ap = link->ap; in ahci_sw_activity() local
1023 struct ahci_port_priv *pp = ap->private_data; in ahci_sw_activity()
1038 struct ata_port *ap = link->ap; in ahci_sw_activity_blink() local
1045 led_message |= ap->port_no | (link->pmp << 8); in ahci_sw_activity_blink()
1051 spin_lock_irqsave(ap->lock, flags); in ahci_sw_activity_blink()
1074 spin_unlock_irqrestore(ap->lock, flags); in ahci_sw_activity_blink()
1075 ap->ops->transmit_led_message(ap, led_message, 4); in ahci_sw_activity_blink()
1080 struct ata_port *ap = link->ap; in ahci_init_sw_activity() local
1081 struct ahci_port_priv *pp = ap->private_data; in ahci_init_sw_activity()
1109 static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state, in ahci_transmit_led_message() argument
1112 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_transmit_led_message()
1113 struct ahci_port_priv *pp = ap->private_data; in ahci_transmit_led_message()
1128 ahci_rpm_get_port(ap); in ahci_transmit_led_message()
1129 spin_lock_irqsave(ap->lock, flags); in ahci_transmit_led_message()
1137 spin_unlock_irqrestore(ap->lock, flags); in ahci_transmit_led_message()
1138 ahci_rpm_put_port(ap); in ahci_transmit_led_message()
1150 message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no); in ahci_transmit_led_message()
1165 spin_unlock_irqrestore(ap->lock, flags); in ahci_transmit_led_message()
1166 ahci_rpm_put_port(ap); in ahci_transmit_led_message()
1171 static ssize_t ahci_led_show(struct ata_port *ap, char *buf) in ahci_led_show() argument
1173 struct ahci_port_priv *pp = ap->private_data; in ahci_led_show()
1178 ata_for_each_link(link, ap, EDGE) { in ahci_led_show()
1185 static ssize_t ahci_led_store(struct ata_port *ap, const char *buf, in ahci_led_store() argument
1190 struct ahci_port_priv *pp = ap->private_data; in ahci_led_store()
1212 return ap->ops->transmit_led_message(ap, state, size); in ahci_led_store()
1218 struct ata_port *ap = link->ap; in ahci_activity_store() local
1219 struct ahci_port_priv *pp = ap->private_data; in ahci_activity_store()
1230 port_led_state |= (ap->port_no | (link->pmp << 8)); in ahci_activity_store()
1231 ap->ops->transmit_led_message(ap, port_led_state, 4); in ahci_activity_store()
1237 port_led_state |= (ap->port_no | (link->pmp << 8)); in ahci_activity_store()
1239 ap->ops->transmit_led_message(ap, port_led_state, 4); in ahci_activity_store()
1249 struct ata_port *ap = link->ap; in ahci_activity_show() local
1250 struct ahci_port_priv *pp = ap->private_data; in ahci_activity_show()
1259 static void ahci_port_clear_pending_irq(struct ata_port *ap) in ahci_port_clear_pending_irq() argument
1261 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_clear_pending_irq()
1262 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_clear_pending_irq()
1267 dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp); in ahci_port_clear_pending_irq()
1272 dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp); in ahci_port_clear_pending_irq()
1276 writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT); in ahci_port_clear_pending_irq()
1279 static void ahci_port_init(struct device *dev, struct ata_port *ap, in ahci_port_init() argument
1287 rc = ahci_deinit_port(ap, &emsg); in ahci_port_init()
1291 ahci_port_clear_pending_irq(ap); in ahci_port_init()
1303 struct ata_port *ap = host->ports[i]; in ahci_init_controller() local
1305 port_mmio = ahci_port_base(ap); in ahci_init_controller()
1306 if (ata_port_is_dummy(ap)) in ahci_init_controller()
1309 ahci_port_init(host->dev, ap, i, mmio, port_mmio); in ahci_init_controller()
1322 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; in ahci_dev_config()
1331 unsigned int ahci_dev_classify(struct ata_port *ap) in ahci_dev_classify() argument
1333 void __iomem *port_mmio = ahci_port_base(ap); in ahci_dev_classify()
1343 return ata_port_classify(ap, &tf); in ahci_dev_classify()
1361 int ahci_kick_engine(struct ata_port *ap) in ahci_kick_engine() argument
1363 void __iomem *port_mmio = ahci_port_base(ap); in ahci_kick_engine()
1364 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_kick_engine()
1370 rc = hpriv->stop_engine(ap); in ahci_kick_engine()
1378 if (!busy && !sata_pmp_attached(ap)) { in ahci_kick_engine()
1394 tmp = ata_wait_register(ap, port_mmio + PORT_CMD, in ahci_kick_engine()
1401 hpriv->start_engine(ap); in ahci_kick_engine()
1406 static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp, in ahci_exec_polled_cmd() argument
1411 struct ahci_port_priv *pp = ap->private_data; in ahci_exec_polled_cmd()
1412 void __iomem *port_mmio = ahci_port_base(ap); in ahci_exec_polled_cmd()
1433 tmp = ata_wait_register(ap, port_mmio + PORT_CMD_ISSUE, in ahci_exec_polled_cmd()
1436 ahci_kick_engine(ap); in ahci_exec_polled_cmd()
1449 struct ata_port *ap = link->ap; in ahci_do_softreset() local
1450 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_softreset()
1451 struct ahci_port_priv *pp = ap->private_data; in ahci_do_softreset()
1460 rc = ahci_kick_engine(ap); in ahci_do_softreset()
1470 ahci_disable_fbs(ap); in ahci_do_softreset()
1483 if (ahci_exec_polled_cmd(ap, pmp, &tf, 0, in ahci_do_softreset()
1491 ata_msleep(ap, 1); in ahci_do_softreset()
1495 ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0); in ahci_do_softreset()
1512 *class = ahci_dev_classify(ap); in ahci_do_softreset()
1516 ahci_enable_fbs(ap); in ahci_do_softreset()
1527 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_check_ready()
1545 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_bad_pmp_check_ready()
1562 struct ata_port *ap = link->ap; in ahci_pmp_retry_softreset() local
1563 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_retry_softreset()
1594 struct ata_port *ap = link->ap; in ahci_do_hardreset() local
1595 struct ahci_port_priv *pp = ap->private_data; in ahci_do_hardreset()
1596 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_hardreset()
1601 hpriv->stop_engine(ap); in ahci_do_hardreset()
1608 ahci_port_clear_pending_irq(ap); in ahci_do_hardreset()
1613 hpriv->start_engine(ap); in ahci_do_hardreset()
1616 *class = ahci_dev_classify(ap); in ahci_do_hardreset()
1632 struct ata_port *ap = link->ap; in ahci_postreset() local
1633 void __iomem *port_mmio = ahci_port_base(ap); in ahci_postreset()
1673 struct ata_port *ap = qc->ap; in ahci_pmp_qc_defer() local
1674 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_qc_defer()
1676 if (!sata_pmp_attached(ap) || pp->fbs_enabled) in ahci_pmp_qc_defer()
1684 struct ata_port *ap = qc->ap; in ahci_qc_prep() local
1685 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_prep()
1722 static void ahci_fbs_dec_intr(struct ata_port *ap) in ahci_fbs_dec_intr() argument
1724 struct ahci_port_priv *pp = ap->private_data; in ahci_fbs_dec_intr()
1725 void __iomem *port_mmio = ahci_port_base(ap); in ahci_fbs_dec_intr()
1742 dev_err(ap->host->dev, "failed to clear device error\n"); in ahci_fbs_dec_intr()
1745 static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) in ahci_error_intr() argument
1747 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_intr()
1748 struct ahci_port_priv *pp = ap->private_data; in ahci_error_intr()
1749 struct ata_eh_info *host_ehi = &ap->link.eh_info; in ahci_error_intr()
1758 void __iomem *port_mmio = ahci_port_base(ap); in ahci_error_intr()
1762 if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links)) { in ahci_error_intr()
1763 link = &ap->pmp_link[pmp]; in ahci_error_intr()
1768 ata_for_each_link(link, ap, EDGE) in ahci_error_intr()
1773 link = &ap->link; in ahci_error_intr()
1775 active_qc = ata_qc_from_tag(ap, link->active_tag); in ahci_error_intr()
1783 ahci_scr_read(&ap->link, SCR_ERROR, &serror); in ahci_error_intr()
1784 ahci_scr_write(&ap->link, SCR_ERROR, serror); in ahci_error_intr()
1815 if (sata_pmp_attached(ap) && (irq_stat & PORT_IRQ_BAD_PMP)) { in ahci_error_intr()
1848 ata_port_freeze(ap); in ahci_error_intr()
1851 ahci_fbs_dec_intr(ap); in ahci_error_intr()
1853 ata_port_abort(ap); in ahci_error_intr()
1856 static void ahci_qc_complete(struct ata_port *ap, void __iomem *port_mmio) in ahci_qc_complete() argument
1858 struct ata_eh_info *ehi = &ap->link.eh_info; in ahci_qc_complete()
1859 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_complete()
1869 if (ap->qc_active) { in ahci_qc_complete()
1875 if (ap->qc_active && pp->active_link->sactive) in ahci_qc_complete()
1881 rc = ata_qc_complete_multiple(ap, qc_active); in ahci_qc_complete()
1882 if (unlikely(rc < 0 && !(ap->pflags & ATA_PFLAG_RESETTING))) { in ahci_qc_complete()
1885 ata_port_freeze(ap); in ahci_qc_complete()
1889 static void ahci_handle_port_interrupt(struct ata_port *ap, in ahci_handle_port_interrupt() argument
1892 struct ahci_port_priv *pp = ap->private_data; in ahci_handle_port_interrupt()
1893 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_handle_port_interrupt()
1896 if (unlikely(ap->pflags & ATA_PFLAG_RESETTING)) in ahci_handle_port_interrupt()
1899 if (sata_lpm_ignore_phy_events(&ap->link)) { in ahci_handle_port_interrupt()
1901 ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG); in ahci_handle_port_interrupt()
1910 ahci_qc_complete(ap, port_mmio); in ahci_handle_port_interrupt()
1911 ahci_error_intr(ap, status); in ahci_handle_port_interrupt()
1926 sata_async_notification(ap); in ahci_handle_port_interrupt()
1942 sata_async_notification(ap); in ahci_handle_port_interrupt()
1948 ahci_qc_complete(ap, port_mmio); in ahci_handle_port_interrupt()
1951 static void ahci_port_intr(struct ata_port *ap) in ahci_port_intr() argument
1953 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_intr()
1959 ahci_handle_port_interrupt(ap, port_mmio, status); in ahci_port_intr()
1964 struct ata_port *ap = dev_instance; in ahci_multi_irqs_intr_hard() local
1965 void __iomem *port_mmio = ahci_port_base(ap); in ahci_multi_irqs_intr_hard()
1971 spin_lock(ap->lock); in ahci_multi_irqs_intr_hard()
1972 ahci_handle_port_interrupt(ap, port_mmio, status); in ahci_multi_irqs_intr_hard()
1973 spin_unlock(ap->lock); in ahci_multi_irqs_intr_hard()
1983 struct ata_port *ap; in ahci_handle_port_intr() local
1988 ap = host->ports[i]; in ahci_handle_port_intr()
1989 if (ap) { in ahci_handle_port_intr()
1990 ahci_port_intr(ap); in ahci_handle_port_intr()
2044 struct ata_port *ap = qc->ap; in ahci_qc_issue() local
2045 void __iomem *port_mmio = ahci_port_base(ap); in ahci_qc_issue()
2046 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_issue()
2075 struct ahci_port_priv *pp = qc->ap->private_data; in ahci_qc_fill_rtf()
2119 static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask) in ahci_qc_ncq_fill_rtf() argument
2121 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_ncq_fill_rtf()
2125 if (!ap->qc_active) in ahci_qc_ncq_fill_rtf()
2147 qc = ata_qc_from_tag(ap, tag); in ahci_qc_ncq_fill_rtf()
2169 qc = ata_qc_from_tag(ap, tag); in ahci_qc_ncq_fill_rtf()
2183 static void ahci_freeze(struct ata_port *ap) in ahci_freeze() argument
2185 void __iomem *port_mmio = ahci_port_base(ap); in ahci_freeze()
2191 static void ahci_thaw(struct ata_port *ap) in ahci_thaw() argument
2193 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_thaw()
2195 void __iomem *port_mmio = ahci_port_base(ap); in ahci_thaw()
2197 struct ahci_port_priv *pp = ap->private_data; in ahci_thaw()
2202 writel(1 << ap->port_no, mmio + HOST_IRQ_STAT); in ahci_thaw()
2208 void ahci_error_handler(struct ata_port *ap) in ahci_error_handler() argument
2210 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_handler()
2212 if (!ata_port_is_frozen(ap)) { in ahci_error_handler()
2214 hpriv->stop_engine(ap); in ahci_error_handler()
2215 hpriv->start_engine(ap); in ahci_error_handler()
2218 sata_pmp_error_handler(ap); in ahci_error_handler()
2220 if (!ata_dev_enabled(ap->link.device)) in ahci_error_handler()
2221 hpriv->stop_engine(ap); in ahci_error_handler()
2227 struct ata_port *ap = qc->ap; in ahci_post_internal_cmd() local
2231 ahci_kick_engine(ap); in ahci_post_internal_cmd()
2234 static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) in ahci_set_aggressive_devslp() argument
2236 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_set_aggressive_devslp()
2237 void __iomem *port_mmio = ahci_port_base(ap); in ahci_set_aggressive_devslp()
2238 struct ata_device *dev = ap->link.device; in ahci_set_aggressive_devslp()
2245 dev_info(ap->host->dev, "port does not support device sleep\n"); in ahci_set_aggressive_devslp()
2275 rc = hpriv->stop_engine(ap); in ahci_set_aggressive_devslp()
2304 hpriv->start_engine(ap); in ahci_set_aggressive_devslp()
2314 static void ahci_enable_fbs(struct ata_port *ap) in ahci_enable_fbs() argument
2316 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_enable_fbs()
2317 struct ahci_port_priv *pp = ap->private_data; in ahci_enable_fbs()
2318 void __iomem *port_mmio = ahci_port_base(ap); in ahci_enable_fbs()
2332 rc = hpriv->stop_engine(ap); in ahci_enable_fbs()
2339 dev_info(ap->host->dev, "FBS is enabled\n"); in ahci_enable_fbs()
2343 dev_err(ap->host->dev, "Failed to enable FBS\n"); in ahci_enable_fbs()
2345 hpriv->start_engine(ap); in ahci_enable_fbs()
2348 static void ahci_disable_fbs(struct ata_port *ap) in ahci_disable_fbs() argument
2350 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_disable_fbs()
2351 struct ahci_port_priv *pp = ap->private_data; in ahci_disable_fbs()
2352 void __iomem *port_mmio = ahci_port_base(ap); in ahci_disable_fbs()
2365 rc = hpriv->stop_engine(ap); in ahci_disable_fbs()
2372 dev_err(ap->host->dev, "Failed to disable FBS\n"); in ahci_disable_fbs()
2374 dev_info(ap->host->dev, "FBS is disabled\n"); in ahci_disable_fbs()
2378 hpriv->start_engine(ap); in ahci_disable_fbs()
2381 static void ahci_pmp_attach(struct ata_port *ap) in ahci_pmp_attach() argument
2383 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_attach()
2384 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_attach()
2391 ahci_enable_fbs(ap); in ahci_pmp_attach()
2403 if (!ata_port_is_frozen(ap)) in ahci_pmp_attach()
2407 static void ahci_pmp_detach(struct ata_port *ap) in ahci_pmp_detach() argument
2409 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_detach()
2410 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_detach()
2413 ahci_disable_fbs(ap); in ahci_pmp_detach()
2422 if (!ata_port_is_frozen(ap)) in ahci_pmp_detach()
2426 int ahci_port_resume(struct ata_port *ap) in ahci_port_resume() argument
2428 ahci_rpm_get_port(ap); in ahci_port_resume()
2430 ahci_power_up(ap); in ahci_port_resume()
2431 ahci_start_port(ap); in ahci_port_resume()
2433 if (sata_pmp_attached(ap)) in ahci_port_resume()
2434 ahci_pmp_attach(ap); in ahci_port_resume()
2436 ahci_pmp_detach(ap); in ahci_port_resume()
2443 static void ahci_handle_s2idle(struct ata_port *ap) in ahci_handle_s2idle() argument
2445 void __iomem *port_mmio = ahci_port_base(ap); in ahci_handle_s2idle()
2452 ata_msleep(ap, devslp_idle_timeout); in ahci_handle_s2idle()
2455 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg) in ahci_port_suspend() argument
2460 rc = ahci_deinit_port(ap, &emsg); in ahci_port_suspend()
2462 ahci_power_down(ap); in ahci_port_suspend()
2464 ata_port_err(ap, "%s (%d)\n", emsg, rc); in ahci_port_suspend()
2465 ata_port_freeze(ap); in ahci_port_suspend()
2468 if (acpi_storage_d3(ap->host->dev)) in ahci_port_suspend()
2469 ahci_handle_s2idle(ap); in ahci_port_suspend()
2471 ahci_rpm_put_port(ap); in ahci_port_suspend()
2476 static int ahci_port_start(struct ata_port *ap) in ahci_port_start() argument
2478 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_start()
2479 struct device *dev = ap->host->dev; in ahci_port_start()
2489 if (ap->host->n_ports > 1) { in ahci_port_start()
2496 "%s%d", dev_driver_string(dev), ap->port_no); in ahci_port_start()
2500 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) { in ahci_port_start()
2501 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_start()
2507 ap->port_no); in ahci_port_start()
2511 ap->port_no); in ahci_port_start()
2563 ap->lock = &pp->lock; in ahci_port_start()
2566 ap->private_data = pp; in ahci_port_start()
2569 return ahci_port_resume(ap); in ahci_port_start()
2572 static void ahci_port_stop(struct ata_port *ap) in ahci_port_stop() argument
2575 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_stop()
2580 rc = ahci_deinit_port(ap, &emsg); in ahci_port_stop()
2582 ata_port_warn(ap, "%s (%d)\n", emsg, rc); in ahci_port_stop()
2588 writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT); in ahci_port_stop()
2590 ahci_rpm_put_port(ap); in ahci_port_stop()