Lines Matching defs:hpriv

37  * @hpriv: host private area to store config values
39 * This function enables all the PHYs found in hpriv->phys, if any.
46 int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
50 for (i = 0; i < hpriv->nports; i++) {
51 rc = phy_init(hpriv->phys[i]);
55 rc = phy_set_mode(hpriv->phys[i], PHY_MODE_SATA);
57 phy_exit(hpriv->phys[i]);
61 rc = phy_power_on(hpriv->phys[i]);
62 if (rc && !(rc == -EOPNOTSUPP && (hpriv->flags & AHCI_HFLAG_IGN_NOTSUPP_POWER_ON))) {
63 phy_exit(hpriv->phys[i]);
72 phy_power_off(hpriv->phys[i]);
73 phy_exit(hpriv->phys[i]);
81 * @hpriv: host private area to store config values
83 * This function disables all PHYs found in hpriv->phys.
85 void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
89 for (i = 0; i < hpriv->nports; i++) {
90 phy_power_off(hpriv->phys[i]);
91 phy_exit(hpriv->phys[i]);
98 * @hpriv: host private area to store config values
100 * This function enables all the clks found in hpriv->clks, starting at
107 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv)
111 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) {
112 rc = clk_prepare_enable(hpriv->clks[c]);
120 clk_disable_unprepare(hpriv->clks[c]);
127 * @hpriv: host private area to store config values
129 * This function disables all the clks found in hpriv->clks, in reverse
132 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv)
137 if (hpriv->clks[c])
138 clk_disable_unprepare(hpriv->clks[c]);
144 * @hpriv: host private area to store config values
147 * hpriv->target_pwrs, if any. If a regulator fails to be enabled, it
154 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)
158 rc = regulator_enable(hpriv->ahci_regulator);
162 rc = regulator_enable(hpriv->phy_regulator);
166 for (i = 0; i < hpriv->nports; i++) {
167 if (!hpriv->target_pwrs[i])
170 rc = regulator_enable(hpriv->target_pwrs[i]);
179 if (hpriv->target_pwrs[i])
180 regulator_disable(hpriv->target_pwrs[i]);
182 regulator_disable(hpriv->phy_regulator);
184 regulator_disable(hpriv->ahci_regulator);
191 * @hpriv: host private area to store config values
193 * This function disables all regulators found in hpriv->target_pwrs and
196 void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv)
200 for (i = 0; i < hpriv->nports; i++) {
201 if (!hpriv->target_pwrs[i])
203 regulator_disable(hpriv->target_pwrs[i]);
206 regulator_disable(hpriv->ahci_regulator);
207 regulator_disable(hpriv->phy_regulator);
212 * @hpriv: host private area to store config values
227 int ahci_platform_enable_resources(struct ahci_host_priv *hpriv)
231 rc = ahci_platform_enable_regulators(hpriv);
235 rc = ahci_platform_enable_clks(hpriv);
239 rc = reset_control_deassert(hpriv->rsts);
243 rc = ahci_platform_enable_phys(hpriv);
250 reset_control_assert(hpriv->rsts);
253 ahci_platform_disable_clks(hpriv);
256 ahci_platform_disable_regulators(hpriv);
264 * @hpriv: host private area to store config values
273 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv)
275 ahci_platform_disable_phys(hpriv);
277 reset_control_assert(hpriv->rsts);
279 ahci_platform_disable_clks(hpriv);
281 ahci_platform_disable_regulators(hpriv);
287 struct ahci_host_priv *hpriv = res;
290 if (hpriv->got_runtime_pm) {
295 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++)
296 clk_put(hpriv->clks[c]);
302 for (c = 0; c < hpriv->nports; c++)
303 if (hpriv->target_pwrs && hpriv->target_pwrs[c])
304 regulator_put(hpriv->target_pwrs[c]);
306 kfree(hpriv->target_pwrs);
309 static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port,
314 hpriv->phys[port] = devm_of_phy_get(dev, node, NULL);
316 if (!IS_ERR(hpriv->phys[port]))
319 rc = PTR_ERR(hpriv->phys[port]);
332 hpriv->phys[port] = NULL;
350 static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port,
359 hpriv->target_pwrs[port] = target_pwr;
389 struct ahci_host_priv *hpriv;
398 hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv),
400 if (!hpriv)
403 devres_add(dev, hpriv);
405 hpriv->mmio = devm_ioremap_resource(dev,
407 if (IS_ERR(hpriv->mmio)) {
408 rc = PTR_ERR(hpriv->mmio);
430 hpriv->clks[i] = clk;
433 hpriv->ahci_regulator = devm_regulator_get(dev, "ahci");
434 if (IS_ERR(hpriv->ahci_regulator)) {
435 rc = PTR_ERR(hpriv->ahci_regulator);
440 hpriv->phy_regulator = devm_regulator_get(dev, "phy");
441 if (IS_ERR(hpriv->phy_regulator)) {
442 rc = PTR_ERR(hpriv->phy_regulator);
447 hpriv->rsts = devm_reset_control_array_get_optional_shared(dev);
448 if (IS_ERR(hpriv->rsts)) {
449 rc = PTR_ERR(hpriv->rsts);
470 hpriv->nports = child_nodes;
472 hpriv->nports = 1;
474 hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL);
475 if (!hpriv->phys) {
483 hpriv->target_pwrs = kcalloc(hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL);
484 if (!hpriv->target_pwrs) {
503 if (port >= hpriv->nports) {
515 rc = ahci_platform_get_regulator(hpriv, port,
524 rc = ahci_platform_get_phy(hpriv, port, dev, child);
538 if (!hpriv->mask_port_map)
539 hpriv->mask_port_map = mask_port_map;
545 rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node);
549 rc = ahci_platform_get_regulator(hpriv, 0, dev);
555 hpriv->got_runtime_pm = true;
558 return hpriv;
569 * @hpriv: ahci-host private data for the host
581 struct ahci_host_priv *hpriv,
600 hpriv->irq = irq;
603 pi.private_data = (void *)(unsigned long)hpriv->flags;
605 ahci_save_initial_config(dev, hpriv);
607 if (hpriv->cap & HOST_CAP_NCQ)
610 if (hpriv->cap & HOST_CAP_PMP)
613 ahci_set_em_messages(hpriv, &pi);
620 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
626 host->private_data = hpriv;
628 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
645 ap->em_message_type = hpriv->em_msg_type;
648 if (!(hpriv->port_map & (1 << i)))
652 if (hpriv->cap & HOST_CAP_64) {
678 struct ahci_host_priv *hpriv = host->private_data;
680 ahci_platform_disable_resources(hpriv);
694 struct ahci_host_priv *hpriv = host->private_data;
695 void __iomem *mmio = hpriv->mmio;
732 struct ahci_host_priv *hpriv = host->private_data;
733 void __iomem *mmio = hpriv->mmio;
736 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
751 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS)
752 ahci_platform_disable_phys(hpriv);
772 struct ahci_host_priv *hpriv = host->private_data;
783 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS)
784 ahci_platform_enable_phys(hpriv);
805 struct ahci_host_priv *hpriv = host->private_data;
812 ahci_platform_disable_resources(hpriv);
831 struct ahci_host_priv *hpriv = host->private_data;
834 rc = ahci_platform_enable_resources(hpriv);
850 ahci_platform_disable_resources(hpriv);