Lines Matching refs:hpriv
46 int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) in ahci_platform_enable_phys() argument
50 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_enable_phys()
51 rc = phy_init(hpriv->phys[i]); in ahci_platform_enable_phys()
55 rc = phy_set_mode(hpriv->phys[i], PHY_MODE_SATA); in ahci_platform_enable_phys()
57 phy_exit(hpriv->phys[i]); in ahci_platform_enable_phys()
61 rc = phy_power_on(hpriv->phys[i]); in ahci_platform_enable_phys()
62 if (rc && !(rc == -EOPNOTSUPP && (hpriv->flags & AHCI_HFLAG_IGN_NOTSUPP_POWER_ON))) { in ahci_platform_enable_phys()
63 phy_exit(hpriv->phys[i]); in ahci_platform_enable_phys()
72 phy_power_off(hpriv->phys[i]); in ahci_platform_enable_phys()
73 phy_exit(hpriv->phys[i]); in ahci_platform_enable_phys()
85 void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) in ahci_platform_disable_phys() argument
89 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_phys()
90 phy_power_off(hpriv->phys[i]); in ahci_platform_disable_phys()
91 phy_exit(hpriv->phys[i]); in ahci_platform_disable_phys()
107 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv) in ahci_platform_enable_clks() argument
111 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) { in ahci_platform_enable_clks()
112 rc = clk_prepare_enable(hpriv->clks[c]); in ahci_platform_enable_clks()
120 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_enable_clks()
132 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv) in ahci_platform_disable_clks() argument
137 if (hpriv->clks[c]) in ahci_platform_disable_clks()
138 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_disable_clks()
154 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_enable_regulators() argument
158 rc = regulator_enable(hpriv->ahci_regulator); in ahci_platform_enable_regulators()
162 rc = regulator_enable(hpriv->phy_regulator); in ahci_platform_enable_regulators()
166 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_enable_regulators()
167 if (!hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
170 rc = regulator_enable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
179 if (hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
180 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
182 regulator_disable(hpriv->phy_regulator); in ahci_platform_enable_regulators()
184 regulator_disable(hpriv->ahci_regulator); in ahci_platform_enable_regulators()
196 void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_disable_regulators() argument
200 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_regulators()
201 if (!hpriv->target_pwrs[i]) in ahci_platform_disable_regulators()
203 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_disable_regulators()
206 regulator_disable(hpriv->ahci_regulator); in ahci_platform_disable_regulators()
207 regulator_disable(hpriv->phy_regulator); in ahci_platform_disable_regulators()
227 int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) in ahci_platform_enable_resources() argument
231 rc = ahci_platform_enable_regulators(hpriv); in ahci_platform_enable_resources()
235 rc = ahci_platform_enable_clks(hpriv); in ahci_platform_enable_resources()
239 rc = reset_control_deassert(hpriv->rsts); in ahci_platform_enable_resources()
243 rc = ahci_platform_enable_phys(hpriv); in ahci_platform_enable_resources()
250 reset_control_assert(hpriv->rsts); in ahci_platform_enable_resources()
253 ahci_platform_disable_clks(hpriv); in ahci_platform_enable_resources()
256 ahci_platform_disable_regulators(hpriv); in ahci_platform_enable_resources()
273 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) in ahci_platform_disable_resources() argument
275 ahci_platform_disable_phys(hpriv); in ahci_platform_disable_resources()
277 reset_control_assert(hpriv->rsts); in ahci_platform_disable_resources()
279 ahci_platform_disable_clks(hpriv); in ahci_platform_disable_resources()
281 ahci_platform_disable_regulators(hpriv); in ahci_platform_disable_resources()
287 struct ahci_host_priv *hpriv = res; in ahci_platform_put_resources() local
290 if (hpriv->got_runtime_pm) { in ahci_platform_put_resources()
295 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) in ahci_platform_put_resources()
296 clk_put(hpriv->clks[c]); in ahci_platform_put_resources()
302 for (c = 0; c < hpriv->nports; c++) in ahci_platform_put_resources()
303 if (hpriv->target_pwrs && hpriv->target_pwrs[c]) in ahci_platform_put_resources()
304 regulator_put(hpriv->target_pwrs[c]); in ahci_platform_put_resources()
306 kfree(hpriv->target_pwrs); in ahci_platform_put_resources()
309 static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_phy() argument
314 hpriv->phys[port] = devm_of_phy_get(dev, node, NULL); in ahci_platform_get_phy()
316 if (!IS_ERR(hpriv->phys[port])) in ahci_platform_get_phy()
319 rc = PTR_ERR(hpriv->phys[port]); in ahci_platform_get_phy()
332 hpriv->phys[port] = NULL; in ahci_platform_get_phy()
350 static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_regulator() argument
359 hpriv->target_pwrs[port] = target_pwr; in ahci_platform_get_regulator()
389 struct ahci_host_priv *hpriv; in ahci_platform_get_resources() local
398 hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv), in ahci_platform_get_resources()
400 if (!hpriv) in ahci_platform_get_resources()
403 devres_add(dev, hpriv); in ahci_platform_get_resources()
405 hpriv->mmio = devm_ioremap_resource(dev, in ahci_platform_get_resources()
407 if (IS_ERR(hpriv->mmio)) { in ahci_platform_get_resources()
408 rc = PTR_ERR(hpriv->mmio); in ahci_platform_get_resources()
430 hpriv->clks[i] = clk; in ahci_platform_get_resources()
433 hpriv->ahci_regulator = devm_regulator_get(dev, "ahci"); in ahci_platform_get_resources()
434 if (IS_ERR(hpriv->ahci_regulator)) { in ahci_platform_get_resources()
435 rc = PTR_ERR(hpriv->ahci_regulator); in ahci_platform_get_resources()
440 hpriv->phy_regulator = devm_regulator_get(dev, "phy"); in ahci_platform_get_resources()
441 if (IS_ERR(hpriv->phy_regulator)) { in ahci_platform_get_resources()
442 rc = PTR_ERR(hpriv->phy_regulator); in ahci_platform_get_resources()
447 hpriv->rsts = devm_reset_control_array_get_optional_shared(dev); in ahci_platform_get_resources()
448 if (IS_ERR(hpriv->rsts)) { in ahci_platform_get_resources()
449 rc = PTR_ERR(hpriv->rsts); in ahci_platform_get_resources()
454 hpriv->nports = child_nodes = of_get_child_count(dev->of_node); in ahci_platform_get_resources()
462 hpriv->nports = 1; in ahci_platform_get_resources()
464 hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL); in ahci_platform_get_resources()
465 if (!hpriv->phys) { in ahci_platform_get_resources()
473 hpriv->target_pwrs = kcalloc(hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL); in ahci_platform_get_resources()
474 if (!hpriv->target_pwrs) { in ahci_platform_get_resources()
493 if (port >= hpriv->nports) { in ahci_platform_get_resources()
505 rc = ahci_platform_get_regulator(hpriv, port, in ahci_platform_get_resources()
514 rc = ahci_platform_get_phy(hpriv, port, dev, child); in ahci_platform_get_resources()
528 if (!hpriv->mask_port_map) in ahci_platform_get_resources()
529 hpriv->mask_port_map = mask_port_map; in ahci_platform_get_resources()
535 rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node); in ahci_platform_get_resources()
539 rc = ahci_platform_get_regulator(hpriv, 0, dev); in ahci_platform_get_resources()
545 hpriv->got_runtime_pm = true; in ahci_platform_get_resources()
548 return hpriv; in ahci_platform_get_resources()
571 struct ahci_host_priv *hpriv, in ahci_platform_init_host() argument
590 hpriv->irq = irq; in ahci_platform_init_host()
593 pi.private_data = (void *)(unsigned long)hpriv->flags; in ahci_platform_init_host()
595 ahci_save_initial_config(dev, hpriv); in ahci_platform_init_host()
597 if (hpriv->cap & HOST_CAP_NCQ) in ahci_platform_init_host()
600 if (hpriv->cap & HOST_CAP_PMP) in ahci_platform_init_host()
603 ahci_set_em_messages(hpriv, &pi); in ahci_platform_init_host()
610 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); in ahci_platform_init_host()
616 host->private_data = hpriv; in ahci_platform_init_host()
618 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) in ahci_platform_init_host()
635 ap->em_message_type = hpriv->em_msg_type; in ahci_platform_init_host()
638 if (!(hpriv->port_map & (1 << i))) in ahci_platform_init_host()
642 if (hpriv->cap & HOST_CAP_64) { in ahci_platform_init_host()
668 struct ahci_host_priv *hpriv = host->private_data; in ahci_host_stop() local
670 ahci_platform_disable_resources(hpriv); in ahci_host_stop()
684 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_shutdown() local
685 void __iomem *mmio = hpriv->mmio; in ahci_platform_shutdown()
722 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend_host() local
723 void __iomem *mmio = hpriv->mmio; in ahci_platform_suspend_host()
726 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { in ahci_platform_suspend_host()
741 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS) in ahci_platform_suspend_host()
742 ahci_platform_disable_phys(hpriv); in ahci_platform_suspend_host()
762 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_resume_host() local
773 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS) in ahci_platform_resume_host()
774 ahci_platform_enable_phys(hpriv); in ahci_platform_resume_host()
795 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend() local
802 ahci_platform_disable_resources(hpriv); in ahci_platform_suspend()
821 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_resume() local
824 rc = ahci_platform_enable_resources(hpriv); in ahci_platform_resume()
840 ahci_platform_disable_resources(hpriv); in ahci_platform_resume()