Lines Matching refs:hpriv

46 static 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()
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()
84 static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) in ahci_platform_disable_phys() argument
88 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_phys()
89 phy_power_off(hpriv->phys[i]); in ahci_platform_disable_phys()
90 phy_exit(hpriv->phys[i]); in ahci_platform_disable_phys()
105 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv) in ahci_platform_enable_clks() argument
109 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) { in ahci_platform_enable_clks()
110 rc = clk_prepare_enable(hpriv->clks[c]); in ahci_platform_enable_clks()
118 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_enable_clks()
130 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv) in ahci_platform_disable_clks() argument
135 if (hpriv->clks[c]) in ahci_platform_disable_clks()
136 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_disable_clks()
152 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_enable_regulators() argument
156 rc = regulator_enable(hpriv->ahci_regulator); in ahci_platform_enable_regulators()
160 rc = regulator_enable(hpriv->phy_regulator); in ahci_platform_enable_regulators()
164 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_enable_regulators()
165 if (!hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
168 rc = regulator_enable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
177 if (hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
178 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
180 regulator_disable(hpriv->phy_regulator); in ahci_platform_enable_regulators()
182 regulator_disable(hpriv->ahci_regulator); in ahci_platform_enable_regulators()
194 void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_disable_regulators() argument
198 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_regulators()
199 if (!hpriv->target_pwrs[i]) in ahci_platform_disable_regulators()
201 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_disable_regulators()
204 regulator_disable(hpriv->ahci_regulator); in ahci_platform_disable_regulators()
205 regulator_disable(hpriv->phy_regulator); in ahci_platform_disable_regulators()
225 int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) in ahci_platform_enable_resources() argument
229 rc = ahci_platform_enable_regulators(hpriv); in ahci_platform_enable_resources()
233 rc = ahci_platform_enable_clks(hpriv); in ahci_platform_enable_resources()
237 rc = reset_control_deassert(hpriv->rsts); in ahci_platform_enable_resources()
241 rc = ahci_platform_enable_phys(hpriv); in ahci_platform_enable_resources()
248 reset_control_assert(hpriv->rsts); in ahci_platform_enable_resources()
251 ahci_platform_disable_clks(hpriv); in ahci_platform_enable_resources()
254 ahci_platform_disable_regulators(hpriv); in ahci_platform_enable_resources()
271 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) in ahci_platform_disable_resources() argument
273 ahci_platform_disable_phys(hpriv); in ahci_platform_disable_resources()
275 reset_control_assert(hpriv->rsts); in ahci_platform_disable_resources()
277 ahci_platform_disable_clks(hpriv); in ahci_platform_disable_resources()
279 ahci_platform_disable_regulators(hpriv); in ahci_platform_disable_resources()
285 struct ahci_host_priv *hpriv = res; in ahci_platform_put_resources() local
288 if (hpriv->got_runtime_pm) { in ahci_platform_put_resources()
293 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) in ahci_platform_put_resources()
294 clk_put(hpriv->clks[c]); in ahci_platform_put_resources()
300 for (c = 0; c < hpriv->nports; c++) in ahci_platform_put_resources()
301 if (hpriv->target_pwrs && hpriv->target_pwrs[c]) in ahci_platform_put_resources()
302 regulator_put(hpriv->target_pwrs[c]); in ahci_platform_put_resources()
304 kfree(hpriv->target_pwrs); in ahci_platform_put_resources()
307 static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_phy() argument
312 hpriv->phys[port] = devm_of_phy_get(dev, node, NULL); in ahci_platform_get_phy()
314 if (!IS_ERR(hpriv->phys[port])) in ahci_platform_get_phy()
317 rc = PTR_ERR(hpriv->phys[port]); in ahci_platform_get_phy()
330 hpriv->phys[port] = NULL; in ahci_platform_get_phy()
348 static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_regulator() argument
357 hpriv->target_pwrs[port] = target_pwr; in ahci_platform_get_regulator()
387 struct ahci_host_priv *hpriv; in ahci_platform_get_resources() local
396 hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv), in ahci_platform_get_resources()
398 if (!hpriv) in ahci_platform_get_resources()
401 devres_add(dev, hpriv); in ahci_platform_get_resources()
403 hpriv->mmio = devm_ioremap_resource(dev, in ahci_platform_get_resources()
405 if (IS_ERR(hpriv->mmio)) { in ahci_platform_get_resources()
406 rc = PTR_ERR(hpriv->mmio); in ahci_platform_get_resources()
428 hpriv->clks[i] = clk; in ahci_platform_get_resources()
431 hpriv->ahci_regulator = devm_regulator_get(dev, "ahci"); in ahci_platform_get_resources()
432 if (IS_ERR(hpriv->ahci_regulator)) { in ahci_platform_get_resources()
433 rc = PTR_ERR(hpriv->ahci_regulator); in ahci_platform_get_resources()
438 hpriv->phy_regulator = devm_regulator_get(dev, "phy"); in ahci_platform_get_resources()
439 if (IS_ERR(hpriv->phy_regulator)) { in ahci_platform_get_resources()
440 rc = PTR_ERR(hpriv->phy_regulator); in ahci_platform_get_resources()
444 hpriv->phy_regulator = NULL; in ahci_platform_get_resources()
448 hpriv->rsts = devm_reset_control_array_get_optional_shared(dev); in ahci_platform_get_resources()
449 if (IS_ERR(hpriv->rsts)) { in ahci_platform_get_resources()
450 rc = PTR_ERR(hpriv->rsts); in ahci_platform_get_resources()
455 hpriv->nports = child_nodes = of_get_child_count(dev->of_node); in ahci_platform_get_resources()
463 hpriv->nports = 1; in ahci_platform_get_resources()
465 hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL); in ahci_platform_get_resources()
466 if (!hpriv->phys) { in ahci_platform_get_resources()
474 hpriv->target_pwrs = kcalloc(hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL); in ahci_platform_get_resources()
475 if (!hpriv->target_pwrs) { in ahci_platform_get_resources()
494 if (port >= hpriv->nports) { in ahci_platform_get_resources()
506 rc = ahci_platform_get_regulator(hpriv, port, in ahci_platform_get_resources()
515 rc = ahci_platform_get_phy(hpriv, port, dev, child); in ahci_platform_get_resources()
529 if (!hpriv->mask_port_map) in ahci_platform_get_resources()
530 hpriv->mask_port_map = mask_port_map; in ahci_platform_get_resources()
536 rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node); in ahci_platform_get_resources()
540 rc = ahci_platform_get_regulator(hpriv, 0, dev); in ahci_platform_get_resources()
546 hpriv->got_runtime_pm = true; in ahci_platform_get_resources()
549 return hpriv; in ahci_platform_get_resources()
572 struct ahci_host_priv *hpriv, in ahci_platform_init_host() argument
589 hpriv->irq = irq; in ahci_platform_init_host()
592 pi.private_data = (void *)(unsigned long)hpriv->flags; in ahci_platform_init_host()
594 ahci_save_initial_config(dev, hpriv); in ahci_platform_init_host()
596 if (hpriv->cap & HOST_CAP_NCQ) in ahci_platform_init_host()
599 if (hpriv->cap & HOST_CAP_PMP) in ahci_platform_init_host()
602 ahci_set_em_messages(hpriv, &pi); in ahci_platform_init_host()
609 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); in ahci_platform_init_host()
615 host->private_data = hpriv; in ahci_platform_init_host()
617 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) in ahci_platform_init_host()
634 ap->em_message_type = hpriv->em_msg_type; in ahci_platform_init_host()
637 if (!(hpriv->port_map & (1 << i))) in ahci_platform_init_host()
641 if (hpriv->cap & HOST_CAP_64) { in ahci_platform_init_host()
667 struct ahci_host_priv *hpriv = host->private_data; in ahci_host_stop() local
669 ahci_platform_disable_resources(hpriv); in ahci_host_stop()
683 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_shutdown() local
684 void __iomem *mmio = hpriv->mmio; in ahci_platform_shutdown()
721 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend_host() local
722 void __iomem *mmio = hpriv->mmio; in ahci_platform_suspend_host()
725 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { in ahci_platform_suspend_host()
740 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS) in ahci_platform_suspend_host()
741 ahci_platform_disable_phys(hpriv); in ahci_platform_suspend_host()
761 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_resume_host() local
772 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS) in ahci_platform_resume_host()
773 ahci_platform_enable_phys(hpriv); in ahci_platform_resume_host()
794 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend() local
801 ahci_platform_disable_resources(hpriv); in ahci_platform_suspend()
820 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_resume() local
823 rc = ahci_platform_enable_resources(hpriv); in ahci_platform_resume()
839 ahci_platform_disable_resources(hpriv); in ahci_platform_resume()