Lines Matching refs:hpriv

38  * @hpriv: host private area to store config values
40 * This function enables all the PHYs found in hpriv->phys, if any.
47 int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
51 for (i = 0; i < hpriv->nports; i++) {
52 rc = phy_init(hpriv->phys[i]);
56 rc = phy_set_mode(hpriv->phys[i], PHY_MODE_SATA);
58 phy_exit(hpriv->phys[i]);
62 rc = phy_power_on(hpriv->phys[i]);
64 phy_exit(hpriv->phys[i]);
73 phy_power_off(hpriv->phys[i]);
74 phy_exit(hpriv->phys[i]);
82 * @hpriv: host private area to store config values
84 * This function disables all PHYs found in hpriv->phys.
86 void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
90 for (i = 0; i < hpriv->nports; i++) {
91 phy_power_off(hpriv->phys[i]);
92 phy_exit(hpriv->phys[i]);
99 * @hpriv: host private area to store config values
108 struct clk *ahci_platform_find_clk(struct ahci_host_priv *hpriv, const char *con_id)
112 for (i = 0; i < hpriv->n_clks; i++) {
113 if (hpriv->clks[i].id && !strcmp(hpriv->clks[i].id, con_id))
114 return hpriv->clks[i].clk;
123 * @hpriv: host private area to store config values
130 int ahci_platform_enable_clks(struct ahci_host_priv *hpriv)
132 return clk_bulk_prepare_enable(hpriv->n_clks, hpriv->clks);
138 * @hpriv: host private area to store config values
144 void ahci_platform_disable_clks(struct ahci_host_priv *hpriv)
146 clk_bulk_disable_unprepare(hpriv->n_clks, hpriv->clks);
152 * @hpriv: host private area to store config values
160 int ahci_platform_deassert_rsts(struct ahci_host_priv *hpriv)
162 if (hpriv->f_rsts & AHCI_PLATFORM_RST_TRIGGER)
163 return reset_control_reset(hpriv->rsts);
165 return reset_control_deassert(hpriv->rsts);
171 * @hpriv: host private area to store config values
179 int ahci_platform_assert_rsts(struct ahci_host_priv *hpriv)
181 if (hpriv->f_rsts & AHCI_PLATFORM_RST_TRIGGER)
182 return reset_control_rearm(hpriv->rsts);
184 return reset_control_assert(hpriv->rsts);
190 * @hpriv: host private area to store config values
193 * hpriv->target_pwrs, if any. If a regulator fails to be enabled, it
200 int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)
204 rc = regulator_enable(hpriv->ahci_regulator);
208 rc = regulator_enable(hpriv->phy_regulator);
212 for (i = 0; i < hpriv->nports; i++) {
213 if (!hpriv->target_pwrs[i])
216 rc = regulator_enable(hpriv->target_pwrs[i]);
225 if (hpriv->target_pwrs[i])
226 regulator_disable(hpriv->target_pwrs[i]);
228 regulator_disable(hpriv->phy_regulator);
230 regulator_disable(hpriv->ahci_regulator);
237 * @hpriv: host private area to store config values
239 * This function disables all regulators found in hpriv->target_pwrs and
242 void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv)
246 for (i = 0; i < hpriv->nports; i++) {
247 if (!hpriv->target_pwrs[i])
249 regulator_disable(hpriv->target_pwrs[i]);
252 regulator_disable(hpriv->ahci_regulator);
253 regulator_disable(hpriv->phy_regulator);
258 * @hpriv: host private area to store config values
273 int ahci_platform_enable_resources(struct ahci_host_priv *hpriv)
277 rc = ahci_platform_enable_regulators(hpriv);
281 rc = ahci_platform_enable_clks(hpriv);
285 rc = ahci_platform_deassert_rsts(hpriv);
289 rc = ahci_platform_enable_phys(hpriv);
296 ahci_platform_assert_rsts(hpriv);
299 ahci_platform_disable_clks(hpriv);
302 ahci_platform_disable_regulators(hpriv);
310 * @hpriv: host private area to store config values
319 void ahci_platform_disable_resources(struct ahci_host_priv *hpriv)
321 ahci_platform_disable_phys(hpriv);
323 ahci_platform_assert_rsts(hpriv);
325 ahci_platform_disable_clks(hpriv);
327 ahci_platform_disable_regulators(hpriv);
333 struct ahci_host_priv *hpriv = res;
336 if (hpriv->got_runtime_pm) {
346 for (c = 0; c < hpriv->nports; c++)
347 if (hpriv->target_pwrs && hpriv->target_pwrs[c])
348 regulator_put(hpriv->target_pwrs[c]);
350 kfree(hpriv->target_pwrs);
353 static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port,
358 hpriv->phys[port] = devm_of_phy_get(dev, node, NULL);
360 if (!IS_ERR(hpriv->phys[port]))
363 rc = PTR_ERR(hpriv->phys[port]);
376 hpriv->phys[port] = NULL;
394 static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port,
403 hpriv->target_pwrs[port] = target_pwr;
410 static int ahci_platform_get_firmware(struct ahci_host_priv *hpriv,
416 if (!of_property_read_u32(dev->of_node, "hba-cap", &hpriv->saved_cap))
417 hpriv->saved_cap &= (HOST_CAP_SSS | HOST_CAP_MPS);
420 "ports-implemented", &hpriv->saved_port_map);
431 if (!of_property_read_u32(child, "hba-port-cap", &hpriv->saved_port_cap[port]))
432 hpriv->saved_port_cap[port] &= PORT_CMD_CAP;
462 struct ahci_host_priv *hpriv;
469 hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv),
471 if (!hpriv)
474 devres_add(dev, hpriv);
481 hpriv->mmio = devm_platform_ioremap_resource_byname(pdev, "ahci");
483 hpriv->mmio = devm_platform_ioremap_resource(pdev, 0);
484 if (IS_ERR(hpriv->mmio)) {
485 rc = PTR_ERR(hpriv->mmio);
496 rc = devm_clk_bulk_get_all(dev, &hpriv->clks);
502 hpriv->n_clks = rc;
508 hpriv->clks = devm_kzalloc(dev, sizeof(*hpriv->clks), GFP_KERNEL);
509 if (!hpriv->clks) {
513 hpriv->clks->clk = devm_clk_get_optional(dev, NULL);
514 if (IS_ERR(hpriv->clks->clk)) {
515 rc = PTR_ERR(hpriv->clks->clk);
517 } else if (hpriv->clks->clk) {
518 hpriv->clks->id = "ahci";
519 hpriv->n_clks = 1;
523 hpriv->ahci_regulator = devm_regulator_get(dev, "ahci");
524 if (IS_ERR(hpriv->ahci_regulator)) {
525 rc = PTR_ERR(hpriv->ahci_regulator);
530 hpriv->phy_regulator = devm_regulator_get(dev, "phy");
531 if (IS_ERR(hpriv->phy_regulator)) {
532 rc = PTR_ERR(hpriv->phy_regulator);
537 hpriv->rsts = devm_reset_control_array_get_optional_shared(dev);
538 if (IS_ERR(hpriv->rsts)) {
539 rc = PTR_ERR(hpriv->rsts);
543 hpriv->f_rsts = flags & AHCI_PLATFORM_RST_TRIGGER;
562 hpriv->nports = child_nodes;
564 hpriv->nports = 1;
566 hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL);
567 if (!hpriv->phys) {
575 hpriv->target_pwrs = kcalloc(hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL);
576 if (!hpriv->target_pwrs) {
595 if (port >= hpriv->nports) {
607 rc = ahci_platform_get_regulator(hpriv, port,
616 rc = ahci_platform_get_phy(hpriv, port, dev, child);
630 if (!hpriv->mask_port_map)
631 hpriv->mask_port_map = mask_port_map;
637 rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node);
641 rc = ahci_platform_get_regulator(hpriv, 0, dev);
650 rc = ahci_platform_get_firmware(hpriv, dev);
656 hpriv->got_runtime_pm = true;
659 return hpriv;
670 * @hpriv: ahci-host private data for the host
682 struct ahci_host_priv *hpriv,
698 hpriv->irq = irq;
701 pi.private_data = (void *)(unsigned long)hpriv->flags;
703 ahci_save_initial_config(dev, hpriv);
705 if (hpriv->cap & HOST_CAP_NCQ)
708 if (hpriv->cap & HOST_CAP_PMP)
711 ahci_set_em_messages(hpriv, &pi);
718 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
724 host->private_data = hpriv;
726 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
743 ap->em_message_type = hpriv->em_msg_type;
746 if (!(hpriv->port_map & (1 << i)))
750 if (hpriv->cap & HOST_CAP_64) {
771 struct ahci_host_priv *hpriv = host->private_data;
773 ahci_platform_disable_resources(hpriv);
787 struct ahci_host_priv *hpriv = host->private_data;
788 void __iomem *mmio = hpriv->mmio;
825 struct ahci_host_priv *hpriv = host->private_data;
826 void __iomem *mmio = hpriv->mmio;
829 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
844 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS)
845 ahci_platform_disable_phys(hpriv);
866 struct ahci_host_priv *hpriv = host->private_data;
877 if (hpriv->flags & AHCI_HFLAG_SUSPEND_PHYS)
878 ahci_platform_enable_phys(hpriv);
899 struct ahci_host_priv *hpriv = host->private_data;
906 ahci_platform_disable_resources(hpriv);
925 struct ahci_host_priv *hpriv = host->private_data;
928 rc = ahci_platform_enable_resources(hpriv);
944 ahci_platform_disable_resources(hpriv);