Lines Matching refs:hpriv

50 static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)  in ahci_platform_enable_phys()  argument
54 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_enable_phys()
55 rc = phy_init(hpriv->phys[i]); in ahci_platform_enable_phys()
59 rc = phy_power_on(hpriv->phys[i]); in ahci_platform_enable_phys()
61 phy_exit(hpriv->phys[i]); in ahci_platform_enable_phys()
70 phy_power_off(hpriv->phys[i]); in ahci_platform_enable_phys()
71 phy_exit(hpriv->phys[i]); in ahci_platform_enable_phys()
82 static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) in ahci_platform_disable_phys() argument
86 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_phys()
87 phy_power_off(hpriv->phys[i]); in ahci_platform_disable_phys()
88 phy_exit(hpriv->phys[i]); in ahci_platform_disable_phys()
103 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv) in ahci_platform_enable_clks() argument
107 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) { in ahci_platform_enable_clks()
108 rc = clk_prepare_enable(hpriv->clks[c]); in ahci_platform_enable_clks()
116 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_enable_clks()
128 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv) in ahci_platform_disable_clks() argument
133 if (hpriv->clks[c]) in ahci_platform_disable_clks()
134 clk_disable_unprepare(hpriv->clks[c]); in ahci_platform_disable_clks()
150 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_enable_regulators() argument
154 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_enable_regulators()
155 if (!hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
158 rc = regulator_enable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
167 if (hpriv->target_pwrs[i]) in ahci_platform_enable_regulators()
168 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_enable_regulators()
180 void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv) in ahci_platform_disable_regulators() argument
184 for (i = 0; i < hpriv->nports; i++) { in ahci_platform_disable_regulators()
185 if (!hpriv->target_pwrs[i]) in ahci_platform_disable_regulators()
187 regulator_disable(hpriv->target_pwrs[i]); in ahci_platform_disable_regulators()
208 int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) in ahci_platform_enable_resources() argument
212 rc = ahci_platform_enable_regulators(hpriv); in ahci_platform_enable_resources()
216 rc = ahci_platform_enable_clks(hpriv); in ahci_platform_enable_resources()
220 rc = reset_control_deassert(hpriv->rsts); in ahci_platform_enable_resources()
224 rc = ahci_platform_enable_phys(hpriv); in ahci_platform_enable_resources()
231 reset_control_assert(hpriv->rsts); in ahci_platform_enable_resources()
234 ahci_platform_disable_clks(hpriv); in ahci_platform_enable_resources()
237 ahci_platform_disable_regulators(hpriv); in ahci_platform_enable_resources()
254 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) in ahci_platform_disable_resources() argument
256 ahci_platform_disable_phys(hpriv); in ahci_platform_disable_resources()
258 reset_control_assert(hpriv->rsts); in ahci_platform_disable_resources()
260 ahci_platform_disable_clks(hpriv); in ahci_platform_disable_resources()
262 ahci_platform_disable_regulators(hpriv); in ahci_platform_disable_resources()
268 struct ahci_host_priv *hpriv = res; in ahci_platform_put_resources() local
271 if (hpriv->got_runtime_pm) { in ahci_platform_put_resources()
276 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) in ahci_platform_put_resources()
277 clk_put(hpriv->clks[c]); in ahci_platform_put_resources()
283 for (c = 0; c < hpriv->nports; c++) in ahci_platform_put_resources()
284 if (hpriv->target_pwrs && hpriv->target_pwrs[c]) in ahci_platform_put_resources()
285 regulator_put(hpriv->target_pwrs[c]); in ahci_platform_put_resources()
287 kfree(hpriv->target_pwrs); in ahci_platform_put_resources()
290 static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_phy() argument
295 hpriv->phys[port] = devm_of_phy_get(dev, node, NULL); in ahci_platform_get_phy()
297 if (!IS_ERR(hpriv->phys[port])) in ahci_platform_get_phy()
300 rc = PTR_ERR(hpriv->phys[port]); in ahci_platform_get_phy()
313 hpriv->phys[port] = NULL; in ahci_platform_get_phy()
328 static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, in ahci_platform_get_regulator() argument
337 hpriv->target_pwrs[port] = target_pwr; in ahci_platform_get_regulator()
366 struct ahci_host_priv *hpriv; in ahci_platform_get_resources() local
375 hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv), in ahci_platform_get_resources()
377 if (!hpriv) in ahci_platform_get_resources()
380 devres_add(dev, hpriv); in ahci_platform_get_resources()
382 hpriv->mmio = devm_ioremap_resource(dev, in ahci_platform_get_resources()
384 if (IS_ERR(hpriv->mmio)) { in ahci_platform_get_resources()
386 rc = PTR_ERR(hpriv->mmio); in ahci_platform_get_resources()
408 hpriv->clks[i] = clk; in ahci_platform_get_resources()
412 hpriv->rsts = devm_reset_control_array_get_optional_shared(dev); in ahci_platform_get_resources()
413 if (IS_ERR(hpriv->rsts)) { in ahci_platform_get_resources()
414 rc = PTR_ERR(hpriv->rsts); in ahci_platform_get_resources()
419 hpriv->nports = child_nodes = of_get_child_count(dev->of_node); in ahci_platform_get_resources()
427 hpriv->nports = 1; in ahci_platform_get_resources()
429 hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL); in ahci_platform_get_resources()
430 if (!hpriv->phys) { in ahci_platform_get_resources()
438 hpriv->target_pwrs = kcalloc(hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL); in ahci_platform_get_resources()
439 if (!hpriv->target_pwrs) { in ahci_platform_get_resources()
457 if (port >= hpriv->nports) { in ahci_platform_get_resources()
469 rc = ahci_platform_get_regulator(hpriv, port, in ahci_platform_get_resources()
476 rc = ahci_platform_get_phy(hpriv, port, dev, child); in ahci_platform_get_resources()
488 if (!hpriv->mask_port_map) in ahci_platform_get_resources()
489 hpriv->mask_port_map = mask_port_map; in ahci_platform_get_resources()
495 rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node); in ahci_platform_get_resources()
499 rc = ahci_platform_get_regulator(hpriv, 0, dev); in ahci_platform_get_resources()
505 hpriv->got_runtime_pm = true; in ahci_platform_get_resources()
508 return hpriv; in ahci_platform_get_resources()
531 struct ahci_host_priv *hpriv, in ahci_platform_init_host() argument
548 hpriv->irq = irq; in ahci_platform_init_host()
551 pi.private_data = (void *)(unsigned long)hpriv->flags; in ahci_platform_init_host()
553 ahci_save_initial_config(dev, hpriv); in ahci_platform_init_host()
555 if (hpriv->cap & HOST_CAP_NCQ) in ahci_platform_init_host()
558 if (hpriv->cap & HOST_CAP_PMP) in ahci_platform_init_host()
561 ahci_set_em_messages(hpriv, &pi); in ahci_platform_init_host()
568 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); in ahci_platform_init_host()
574 host->private_data = hpriv; in ahci_platform_init_host()
576 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) in ahci_platform_init_host()
593 ap->em_message_type = hpriv->em_msg_type; in ahci_platform_init_host()
596 if (!(hpriv->port_map & (1 << i))) in ahci_platform_init_host()
600 if (hpriv->cap & HOST_CAP_64) { in ahci_platform_init_host()
626 struct ahci_host_priv *hpriv = host->private_data; in ahci_host_stop() local
628 ahci_platform_disable_resources(hpriv); in ahci_host_stop()
642 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_shutdown() local
643 void __iomem *mmio = hpriv->mmio; in ahci_platform_shutdown()
680 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend_host() local
681 void __iomem *mmio = hpriv->mmio; in ahci_platform_suspend_host()
684 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { in ahci_platform_suspend_host()
746 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_suspend() local
753 ahci_platform_disable_resources(hpriv); in ahci_platform_suspend()
772 struct ahci_host_priv *hpriv = host->private_data; in ahci_platform_resume() local
775 rc = ahci_platform_enable_resources(hpriv); in ahci_platform_resume()
791 ahci_platform_disable_resources(hpriv); in ahci_platform_resume()