Lines Matching refs: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);
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()
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
1283 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_init()
1289 rc = ahci_deinit_port(ap, &emsg); in ahci_port_init()
1293 ahci_port_clear_pending_irq(ap); in ahci_port_init()
1298 ap->pflags |= ATA_PFLAG_EXTERNAL; in ahci_port_init()
1310 struct ata_port *ap = host->ports[i]; in ahci_init_controller() local
1312 port_mmio = ahci_port_base(ap); in ahci_init_controller()
1313 if (ata_port_is_dummy(ap)) in ahci_init_controller()
1316 ahci_port_init(host->dev, ap, i, mmio, port_mmio); in ahci_init_controller()
1329 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; in ahci_dev_config()
1338 unsigned int ahci_dev_classify(struct ata_port *ap) in ahci_dev_classify() argument
1340 void __iomem *port_mmio = ahci_port_base(ap); in ahci_dev_classify()
1350 return ata_port_classify(ap, &tf); in ahci_dev_classify()
1368 int ahci_kick_engine(struct ata_port *ap) in ahci_kick_engine() argument
1370 void __iomem *port_mmio = ahci_port_base(ap); in ahci_kick_engine()
1371 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_kick_engine()
1377 rc = hpriv->stop_engine(ap); in ahci_kick_engine()
1385 if (!busy && !sata_pmp_attached(ap)) { in ahci_kick_engine()
1401 tmp = ata_wait_register(ap, port_mmio + PORT_CMD, in ahci_kick_engine()
1408 hpriv->start_engine(ap); in ahci_kick_engine()
1413 static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp, in ahci_exec_polled_cmd() argument
1418 struct ahci_port_priv *pp = ap->private_data; in ahci_exec_polled_cmd()
1419 void __iomem *port_mmio = ahci_port_base(ap); in ahci_exec_polled_cmd()
1440 tmp = ata_wait_register(ap, port_mmio + PORT_CMD_ISSUE, in ahci_exec_polled_cmd()
1443 ahci_kick_engine(ap); in ahci_exec_polled_cmd()
1456 struct ata_port *ap = link->ap; in ahci_do_softreset() local
1457 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_softreset()
1458 struct ahci_port_priv *pp = ap->private_data; in ahci_do_softreset()
1467 rc = ahci_kick_engine(ap); in ahci_do_softreset()
1477 ahci_disable_fbs(ap); in ahci_do_softreset()
1490 if (ahci_exec_polled_cmd(ap, pmp, &tf, 0, in ahci_do_softreset()
1498 ata_msleep(ap, 1); in ahci_do_softreset()
1502 ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0); in ahci_do_softreset()
1519 *class = ahci_dev_classify(ap); in ahci_do_softreset()
1523 ahci_enable_fbs(ap); in ahci_do_softreset()
1534 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_check_ready()
1552 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_bad_pmp_check_ready()
1569 struct ata_port *ap = link->ap; in ahci_pmp_retry_softreset() local
1570 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_retry_softreset()
1601 struct ata_port *ap = link->ap; in ahci_do_hardreset() local
1602 struct ahci_port_priv *pp = ap->private_data; in ahci_do_hardreset()
1603 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_hardreset()
1608 hpriv->stop_engine(ap); in ahci_do_hardreset()
1615 ahci_port_clear_pending_irq(ap); in ahci_do_hardreset()
1620 hpriv->start_engine(ap); in ahci_do_hardreset()
1623 *class = ahci_dev_classify(ap); in ahci_do_hardreset()
1639 struct ata_port *ap = link->ap; in ahci_postreset() local
1640 void __iomem *port_mmio = ahci_port_base(ap); in ahci_postreset()
1680 struct ata_port *ap = qc->ap; in ahci_pmp_qc_defer() local
1681 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_qc_defer()
1683 if (!sata_pmp_attached(ap) || pp->fbs_enabled) in ahci_pmp_qc_defer()
1691 struct ata_port *ap = qc->ap; in ahci_qc_prep() local
1692 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_prep()
1729 static void ahci_fbs_dec_intr(struct ata_port *ap) in ahci_fbs_dec_intr() argument
1731 struct ahci_port_priv *pp = ap->private_data; in ahci_fbs_dec_intr()
1732 void __iomem *port_mmio = ahci_port_base(ap); in ahci_fbs_dec_intr()
1749 dev_err(ap->host->dev, "failed to clear device error\n"); in ahci_fbs_dec_intr()
1752 static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) in ahci_error_intr() argument
1754 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_intr()
1755 struct ahci_port_priv *pp = ap->private_data; in ahci_error_intr()
1756 struct ata_eh_info *host_ehi = &ap->link.eh_info; in ahci_error_intr()
1765 void __iomem *port_mmio = ahci_port_base(ap); in ahci_error_intr()
1769 if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links)) { in ahci_error_intr()
1770 link = &ap->pmp_link[pmp]; in ahci_error_intr()
1775 ata_for_each_link(link, ap, EDGE) in ahci_error_intr()
1780 link = &ap->link; in ahci_error_intr()
1782 active_qc = ata_qc_from_tag(ap, link->active_tag); in ahci_error_intr()
1790 ahci_scr_read(&ap->link, SCR_ERROR, &serror); in ahci_error_intr()
1791 ahci_scr_write(&ap->link, SCR_ERROR, serror); in ahci_error_intr()
1822 if (sata_pmp_attached(ap) && (irq_stat & PORT_IRQ_BAD_PMP)) { in ahci_error_intr()
1855 ata_port_freeze(ap); in ahci_error_intr()
1858 ahci_fbs_dec_intr(ap); in ahci_error_intr()
1860 ata_port_abort(ap); in ahci_error_intr()
1863 static void ahci_qc_complete(struct ata_port *ap, void __iomem *port_mmio) in ahci_qc_complete() argument
1865 struct ata_eh_info *ehi = &ap->link.eh_info; in ahci_qc_complete()
1866 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_complete()
1876 if (ap->qc_active) { in ahci_qc_complete()
1882 if (ap->qc_active && pp->active_link->sactive) in ahci_qc_complete()
1888 rc = ata_qc_complete_multiple(ap, qc_active); in ahci_qc_complete()
1889 if (unlikely(rc < 0 && !(ap->pflags & ATA_PFLAG_RESETTING))) { in ahci_qc_complete()
1892 ata_port_freeze(ap); in ahci_qc_complete()
1896 static void ahci_handle_port_interrupt(struct ata_port *ap, in ahci_handle_port_interrupt() argument
1899 struct ahci_port_priv *pp = ap->private_data; in ahci_handle_port_interrupt()
1900 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_handle_port_interrupt()
1903 if (unlikely(ap->pflags & ATA_PFLAG_RESETTING)) in ahci_handle_port_interrupt()
1906 if (sata_lpm_ignore_phy_events(&ap->link)) { in ahci_handle_port_interrupt()
1908 ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG); in ahci_handle_port_interrupt()
1917 ahci_qc_complete(ap, port_mmio); in ahci_handle_port_interrupt()
1918 ahci_error_intr(ap, status); in ahci_handle_port_interrupt()
1933 sata_async_notification(ap); in ahci_handle_port_interrupt()
1949 sata_async_notification(ap); in ahci_handle_port_interrupt()
1955 ahci_qc_complete(ap, port_mmio); in ahci_handle_port_interrupt()
1958 static void ahci_port_intr(struct ata_port *ap) in ahci_port_intr() argument
1960 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_intr()
1966 ahci_handle_port_interrupt(ap, port_mmio, status); in ahci_port_intr()
1971 struct ata_port *ap = dev_instance; in ahci_multi_irqs_intr_hard() local
1972 void __iomem *port_mmio = ahci_port_base(ap); in ahci_multi_irqs_intr_hard()
1978 spin_lock(ap->lock); in ahci_multi_irqs_intr_hard()
1979 ahci_handle_port_interrupt(ap, port_mmio, status); in ahci_multi_irqs_intr_hard()
1980 spin_unlock(ap->lock); in ahci_multi_irqs_intr_hard()
1990 struct ata_port *ap; in ahci_handle_port_intr() local
1995 ap = host->ports[i]; in ahci_handle_port_intr()
1996 if (ap) { in ahci_handle_port_intr()
1997 ahci_port_intr(ap); in ahci_handle_port_intr()
2051 struct ata_port *ap = qc->ap; in ahci_qc_issue() local
2052 void __iomem *port_mmio = ahci_port_base(ap); in ahci_qc_issue()
2053 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_issue()
2082 struct ahci_port_priv *pp = qc->ap->private_data; in ahci_qc_fill_rtf()
2126 static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask) in ahci_qc_ncq_fill_rtf() argument
2128 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_ncq_fill_rtf()
2132 if (!ap->qc_active) in ahci_qc_ncq_fill_rtf()
2154 qc = ata_qc_from_tag(ap, tag); in ahci_qc_ncq_fill_rtf()
2176 qc = ata_qc_from_tag(ap, tag); in ahci_qc_ncq_fill_rtf()
2190 static void ahci_freeze(struct ata_port *ap) in ahci_freeze() argument
2192 void __iomem *port_mmio = ahci_port_base(ap); in ahci_freeze()
2198 static void ahci_thaw(struct ata_port *ap) in ahci_thaw() argument
2200 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_thaw()
2202 void __iomem *port_mmio = ahci_port_base(ap); in ahci_thaw()
2204 struct ahci_port_priv *pp = ap->private_data; in ahci_thaw()
2209 writel(1 << ap->port_no, mmio + HOST_IRQ_STAT); in ahci_thaw()
2215 void ahci_error_handler(struct ata_port *ap) in ahci_error_handler() argument
2217 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_handler()
2219 if (!ata_port_is_frozen(ap)) { in ahci_error_handler()
2221 hpriv->stop_engine(ap); in ahci_error_handler()
2222 hpriv->start_engine(ap); in ahci_error_handler()
2225 sata_pmp_error_handler(ap); in ahci_error_handler()
2227 if (!ata_dev_enabled(ap->link.device)) in ahci_error_handler()
2228 hpriv->stop_engine(ap); in ahci_error_handler()
2234 struct ata_port *ap = qc->ap; in ahci_post_internal_cmd() local
2238 ahci_kick_engine(ap); in ahci_post_internal_cmd()
2241 static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) in ahci_set_aggressive_devslp() argument
2243 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_set_aggressive_devslp()
2244 void __iomem *port_mmio = ahci_port_base(ap); in ahci_set_aggressive_devslp()
2245 struct ata_device *dev = ap->link.device; in ahci_set_aggressive_devslp()
2252 dev_info(ap->host->dev, "port does not support device sleep\n"); in ahci_set_aggressive_devslp()
2282 rc = hpriv->stop_engine(ap); in ahci_set_aggressive_devslp()
2311 hpriv->start_engine(ap); in ahci_set_aggressive_devslp()
2321 static void ahci_enable_fbs(struct ata_port *ap) in ahci_enable_fbs() argument
2323 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_enable_fbs()
2324 struct ahci_port_priv *pp = ap->private_data; in ahci_enable_fbs()
2325 void __iomem *port_mmio = ahci_port_base(ap); in ahci_enable_fbs()
2339 rc = hpriv->stop_engine(ap); in ahci_enable_fbs()
2346 dev_info(ap->host->dev, "FBS is enabled\n"); in ahci_enable_fbs()
2350 dev_err(ap->host->dev, "Failed to enable FBS\n"); in ahci_enable_fbs()
2352 hpriv->start_engine(ap); in ahci_enable_fbs()
2355 static void ahci_disable_fbs(struct ata_port *ap) in ahci_disable_fbs() argument
2357 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_disable_fbs()
2358 struct ahci_port_priv *pp = ap->private_data; in ahci_disable_fbs()
2359 void __iomem *port_mmio = ahci_port_base(ap); in ahci_disable_fbs()
2372 rc = hpriv->stop_engine(ap); in ahci_disable_fbs()
2379 dev_err(ap->host->dev, "Failed to disable FBS\n"); in ahci_disable_fbs()
2381 dev_info(ap->host->dev, "FBS is disabled\n"); in ahci_disable_fbs()
2385 hpriv->start_engine(ap); in ahci_disable_fbs()
2388 static void ahci_pmp_attach(struct ata_port *ap) in ahci_pmp_attach() argument
2390 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_attach()
2391 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_attach()
2398 ahci_enable_fbs(ap); in ahci_pmp_attach()
2410 if (!ata_port_is_frozen(ap)) in ahci_pmp_attach()
2414 static void ahci_pmp_detach(struct ata_port *ap) in ahci_pmp_detach() argument
2416 void __iomem *port_mmio = ahci_port_base(ap); in ahci_pmp_detach()
2417 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_detach()
2420 ahci_disable_fbs(ap); in ahci_pmp_detach()
2429 if (!ata_port_is_frozen(ap)) in ahci_pmp_detach()
2433 int ahci_port_resume(struct ata_port *ap) in ahci_port_resume() argument
2435 ahci_rpm_get_port(ap); in ahci_port_resume()
2437 ahci_power_up(ap); in ahci_port_resume()
2438 ahci_start_port(ap); in ahci_port_resume()
2440 if (sata_pmp_attached(ap)) in ahci_port_resume()
2441 ahci_pmp_attach(ap); in ahci_port_resume()
2443 ahci_pmp_detach(ap); in ahci_port_resume()
2450 static void ahci_handle_s2idle(struct ata_port *ap) in ahci_handle_s2idle() argument
2452 void __iomem *port_mmio = ahci_port_base(ap); in ahci_handle_s2idle()
2459 ata_msleep(ap, devslp_idle_timeout); in ahci_handle_s2idle()
2462 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg) in ahci_port_suspend() argument
2467 rc = ahci_deinit_port(ap, &emsg); in ahci_port_suspend()
2469 ahci_power_down(ap); in ahci_port_suspend()
2471 ata_port_err(ap, "%s (%d)\n", emsg, rc); in ahci_port_suspend()
2472 ata_port_freeze(ap); in ahci_port_suspend()
2475 if (acpi_storage_d3(ap->host->dev)) in ahci_port_suspend()
2476 ahci_handle_s2idle(ap); in ahci_port_suspend()
2478 ahci_rpm_put_port(ap); in ahci_port_suspend()
2483 static int ahci_port_start(struct ata_port *ap) in ahci_port_start() argument
2485 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_start()
2486 struct device *dev = ap->host->dev; in ahci_port_start()
2496 if (ap->host->n_ports > 1) { in ahci_port_start()
2503 "%s%d", dev_driver_string(dev), ap->port_no); in ahci_port_start()
2507 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) { in ahci_port_start()
2508 void __iomem *port_mmio = ahci_port_base(ap); in ahci_port_start()
2514 ap->port_no); in ahci_port_start()
2518 ap->port_no); in ahci_port_start()
2570 ap->lock = &pp->lock; in ahci_port_start()
2573 ap->private_data = pp; in ahci_port_start()
2576 return ahci_port_resume(ap); in ahci_port_start()
2579 static void ahci_port_stop(struct ata_port *ap) in ahci_port_stop() argument
2582 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_stop()
2587 rc = ahci_deinit_port(ap, &emsg); in ahci_port_stop()
2589 ata_port_warn(ap, "%s (%d)\n", emsg, rc); in ahci_port_stop()
2595 writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT); in ahci_port_stop()
2597 ahci_rpm_put_port(ap); in ahci_port_stop()