Lines Matching refs:hpriv

49 static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)  in ahci_platform_enable_phys()  argument
53 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_enable_phys()
54 rc = phy_init(hpriv->phys[i]); in ahci_platform_enable_phys()
58 rc = phy_power_on(hpriv->phys[i]); in ahci_platform_enable_phys()
60 phy_exit(hpriv->phys[i]); in ahci_platform_enable_phys()
69 phy_power_off(hpriv->phys[i]); in ahci_platform_enable_phys()
70 phy_exit(hpriv->phys[i]); in ahci_platform_enable_phys()
81 static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) in ahci_platform_disable_phys() argument
85 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_phys()
86 phy_power_off(hpriv->phys[i]); in ahci_platform_disable_phys()
87 phy_exit(hpriv->phys[i]); in ahci_platform_disable_phys()
102 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv) in ahci_platform_enable_clks() argument
106 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) { in ahci_platform_enable_clks()
107 rc = clk_prepare_enable(hpriv->clks[c]); in ahci_platform_enable_clks()
115 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_enable_clks()
127 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv) in ahci_platform_disable_clks() argument
132 if (hpriv->clks[c]) in ahci_platform_disable_clks()
133 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_disable_clks()
149 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_enable_regulators() argument
153 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_enable_regulators()
154 if (!hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
157 rc = regulator_enable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
166 if (hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
167 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
179 void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_disable_regulators() argument
183 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_regulators()
184 if (!hpriv->target_pwrs[i]) in ahci_platform_disable_regulators()
186 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_disable_regulators()
206 int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) in ahci_platform_enable_resources() argument
210 rc = ahci_platform_enable_regulators(hpriv); in ahci_platform_enable_resources()
214 rc = ahci_platform_enable_clks(hpriv); in ahci_platform_enable_resources()
218 rc = ahci_platform_enable_phys(hpriv); in ahci_platform_enable_resources()
225 ahci_platform_disable_clks(hpriv); in ahci_platform_enable_resources()
228 ahci_platform_disable_regulators(hpriv); in ahci_platform_enable_resources()
244 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) in ahci_platform_disable_resources() argument
246 ahci_platform_disable_phys(hpriv); in ahci_platform_disable_resources()
248 ahci_platform_disable_clks(hpriv); in ahci_platform_disable_resources()
250 ahci_platform_disable_regulators(hpriv); in ahci_platform_disable_resources()
256 struct ahci_host_priv *hpriv = res; in ahci_platform_put_resources() local
259 if (hpriv->got_runtime_pm) { in ahci_platform_put_resources()
264 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) in ahci_platform_put_resources()
265 clk_put(hpriv->clks[c]); in ahci_platform_put_resources()
271 for (c = 0; c < hpriv->nports; c++) in ahci_platform_put_resources()
272 if (hpriv->target_pwrs && hpriv->target_pwrs[c]) in ahci_platform_put_resources()
273 regulator_put(hpriv->target_pwrs[c]); in ahci_platform_put_resources()
275 kfree(hpriv->target_pwrs); in ahci_platform_put_resources()
278 static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_phy() argument
283 hpriv->phys[port] = devm_of_phy_get(dev, node, NULL); in ahci_platform_get_phy()
285 if (!IS_ERR(hpriv->phys[port])) in ahci_platform_get_phy()
288 rc = PTR_ERR(hpriv->phys[port]); in ahci_platform_get_phy()
300 hpriv->phys[port] = NULL; in ahci_platform_get_phy()
315 static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_regulator() argument
324 hpriv->target_pwrs[port] = target_pwr; in ahci_platform_get_regulator()
350 struct ahci_host_priv *hpriv; in ahci_platform_get_resources() local
359 hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv), in ahci_platform_get_resources()
361 if (!hpriv) in ahci_platform_get_resources()
364 devres_add(dev, hpriv); in ahci_platform_get_resources()
366 hpriv->mmio = devm_ioremap_resource(dev, in ahci_platform_get_resources()
368 if (IS_ERR(hpriv->mmio)) { in ahci_platform_get_resources()
370 rc = PTR_ERR(hpriv->mmio); in ahci_platform_get_resources()
392 hpriv->clks[i] = clk; in ahci_platform_get_resources()
395 hpriv->nports = child_nodes = of_get_child_count(dev->of_node); in ahci_platform_get_resources()
403 hpriv->nports = 1; in ahci_platform_get_resources()
405 sz = hpriv->nports * sizeof(*hpriv->phys); in ahci_platform_get_resources()
406 hpriv->phys = devm_kzalloc(dev, sz, GFP_KERNEL); in ahci_platform_get_resources()
407 if (!hpriv->phys) { in ahci_platform_get_resources()
411 sz = hpriv->nports * sizeof(*hpriv->target_pwrs); in ahci_platform_get_resources()
412 hpriv->target_pwrs = kzalloc(sz, GFP_KERNEL); in ahci_platform_get_resources()
413 if (!hpriv->target_pwrs) { in ahci_platform_get_resources()
431 if (port >= hpriv->nports) { in ahci_platform_get_resources()
443 rc = ahci_platform_get_regulator(hpriv, port, in ahci_platform_get_resources()
450 rc = ahci_platform_get_phy(hpriv, port, dev, child); in ahci_platform_get_resources()
462 if (!hpriv->mask_port_map) in ahci_platform_get_resources()
463 hpriv->mask_port_map = mask_port_map; in ahci_platform_get_resources()
469 rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node); in ahci_platform_get_resources()
473 rc = ahci_platform_get_regulator(hpriv, 0, dev); in ahci_platform_get_resources()
479 hpriv->got_runtime_pm = true; in ahci_platform_get_resources()
482 return hpriv; in ahci_platform_get_resources()
505 struct ahci_host_priv *hpriv, in ahci_platform_init_host() argument
522 pi.private_data = (void *)(unsigned long)hpriv->flags; in ahci_platform_init_host()
524 ahci_save_initial_config(dev, hpriv); in ahci_platform_init_host()
526 if (hpriv->cap & HOST_CAP_NCQ) in ahci_platform_init_host()
529 if (hpriv->cap & HOST_CAP_PMP) in ahci_platform_init_host()
532 ahci_set_em_messages(hpriv, &pi); in ahci_platform_init_host()
539 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); in ahci_platform_init_host()
545 host->private_data = hpriv; in ahci_platform_init_host()
547 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) in ahci_platform_init_host()
564 ap->em_message_type = hpriv->em_msg_type; in ahci_platform_init_host()
567 if (!(hpriv->port_map & (1 << i))) in ahci_platform_init_host()
571 if (hpriv->cap & HOST_CAP_64) { in ahci_platform_init_host()
597 struct ahci_host_priv *hpriv = host->private_data; in ahci_host_stop() local
599 ahci_platform_disable_resources(hpriv); in ahci_host_stop()
617 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend_host() local
618 void __iomem *mmio = hpriv->mmio; in ahci_platform_suspend_host()
621 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { in ahci_platform_suspend_host()
683 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend() local
690 ahci_platform_disable_resources(hpriv); in ahci_platform_suspend()
709 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_resume() local
712 rc = ahci_platform_enable_resources(hpriv); in ahci_platform_resume()
728 ahci_platform_disable_resources(hpriv); in ahci_platform_resume()