Lines Matching +full:axi +full:- +full:apb

1 // SPDX-License-Identifier: GPL-2.0+
19 #include <dt-bindings/power/imx8mm-power.h>
20 #include <dt-bindings/power/imx8mn-power.h>
21 #include <dt-bindings/power/imx8mp-power.h>
22 #include <dt-bindings/power/imx8mq-power.h>
53 * an if-statement should be used before setting and clearing this
88 const struct imx8m_blk_ctrl_domain_data *data = domain->data; in imx8m_blk_ctrl_power_on()
89 struct imx8m_blk_ctrl *bc = domain->bc; in imx8m_blk_ctrl_power_on()
93 ret = pm_runtime_get_sync(bc->bus_power_dev); in imx8m_blk_ctrl_power_on()
95 pm_runtime_put_noidle(bc->bus_power_dev); in imx8m_blk_ctrl_power_on()
96 dev_err(bc->dev, "failed to power up bus domain\n"); in imx8m_blk_ctrl_power_on()
101 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx8m_blk_ctrl_power_on()
102 if (data->mipi_phy_rst_mask) in imx8m_blk_ctrl_power_on()
103 regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask); in imx8m_blk_ctrl_power_on()
105 /* enable upstream and blk-ctrl clocks to allow reset to propagate */ in imx8m_blk_ctrl_power_on()
106 ret = clk_bulk_prepare_enable(data->num_clks, domain->clks); in imx8m_blk_ctrl_power_on()
108 dev_err(bc->dev, "failed to enable clocks\n"); in imx8m_blk_ctrl_power_on()
111 regmap_set_bits(bc->regmap, BLK_CLK_EN, data->clk_mask); in imx8m_blk_ctrl_power_on()
114 ret = pm_runtime_get_sync(domain->power_dev); in imx8m_blk_ctrl_power_on()
116 dev_err(bc->dev, "failed to power up peripheral domain\n"); in imx8m_blk_ctrl_power_on()
124 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx8m_blk_ctrl_power_on()
125 if (data->mipi_phy_rst_mask) in imx8m_blk_ctrl_power_on()
126 regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask); in imx8m_blk_ctrl_power_on()
128 ret = icc_bulk_set_bw(domain->num_paths, domain->paths); in imx8m_blk_ctrl_power_on()
130 dev_err(bc->dev, "failed to set icc bw\n"); in imx8m_blk_ctrl_power_on()
133 clk_bulk_disable_unprepare(data->num_clks, domain->clks); in imx8m_blk_ctrl_power_on()
138 clk_bulk_disable_unprepare(data->num_clks, domain->clks); in imx8m_blk_ctrl_power_on()
140 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_power_on()
148 const struct imx8m_blk_ctrl_domain_data *data = domain->data; in imx8m_blk_ctrl_power_off()
149 struct imx8m_blk_ctrl *bc = domain->bc; in imx8m_blk_ctrl_power_off()
152 if (data->mipi_phy_rst_mask) in imx8m_blk_ctrl_power_off()
153 regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask); in imx8m_blk_ctrl_power_off()
155 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx8m_blk_ctrl_power_off()
156 regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask); in imx8m_blk_ctrl_power_off()
159 pm_runtime_put(domain->power_dev); in imx8m_blk_ctrl_power_off()
162 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_power_off()
172 struct device *dev = &pdev->dev; in imx8m_blk_ctrl_probe()
185 return -ENOMEM; in imx8m_blk_ctrl_probe()
187 bc->dev = dev; in imx8m_blk_ctrl_probe()
195 regmap_config.max_register = bc_data->max_reg; in imx8m_blk_ctrl_probe()
196 bc->regmap = devm_regmap_init_mmio(dev, base, &regmap_config); in imx8m_blk_ctrl_probe()
197 if (IS_ERR(bc->regmap)) in imx8m_blk_ctrl_probe()
198 return dev_err_probe(dev, PTR_ERR(bc->regmap), in imx8m_blk_ctrl_probe()
201 bc->domains = devm_kcalloc(dev, bc_data->num_domains, in imx8m_blk_ctrl_probe()
204 if (!bc->domains) in imx8m_blk_ctrl_probe()
205 return -ENOMEM; in imx8m_blk_ctrl_probe()
207 bc->onecell_data.num_domains = bc_data->num_domains; in imx8m_blk_ctrl_probe()
208 bc->onecell_data.domains = in imx8m_blk_ctrl_probe()
209 devm_kcalloc(dev, bc_data->num_domains, in imx8m_blk_ctrl_probe()
211 if (!bc->onecell_data.domains) in imx8m_blk_ctrl_probe()
212 return -ENOMEM; in imx8m_blk_ctrl_probe()
214 bc->bus_power_dev = dev_pm_domain_attach_by_name(dev, "bus"); in imx8m_blk_ctrl_probe()
215 if (IS_ERR(bc->bus_power_dev)) { in imx8m_blk_ctrl_probe()
216 if (PTR_ERR(bc->bus_power_dev) == -ENODEV) in imx8m_blk_ctrl_probe()
217 return dev_err_probe(dev, -EPROBE_DEFER, in imx8m_blk_ctrl_probe()
220 return dev_err_probe(dev, PTR_ERR(bc->bus_power_dev), in imx8m_blk_ctrl_probe()
224 for (i = 0; i < bc_data->num_domains; i++) { in imx8m_blk_ctrl_probe()
225 const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i]; in imx8m_blk_ctrl_probe()
226 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; in imx8m_blk_ctrl_probe()
229 domain->data = data; in imx8m_blk_ctrl_probe()
230 domain->num_paths = data->num_paths; in imx8m_blk_ctrl_probe()
232 for (j = 0; j < data->num_clks; j++) in imx8m_blk_ctrl_probe()
233 domain->clks[j].id = data->clk_names[j]; in imx8m_blk_ctrl_probe()
235 for (j = 0; j < data->num_paths; j++) { in imx8m_blk_ctrl_probe()
236 domain->paths[j].name = data->path_names[j]; in imx8m_blk_ctrl_probe()
238 domain->paths[j].avg_bw = 1; in imx8m_blk_ctrl_probe()
239 domain->paths[j].peak_bw = 1; in imx8m_blk_ctrl_probe()
242 ret = devm_of_icc_bulk_get(dev, data->num_paths, domain->paths); in imx8m_blk_ctrl_probe()
244 if (ret != -EPROBE_DEFER) { in imx8m_blk_ctrl_probe()
246 domain->num_paths = 0; in imx8m_blk_ctrl_probe()
253 ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks); in imx8m_blk_ctrl_probe()
259 domain->power_dev = in imx8m_blk_ctrl_probe()
260 dev_pm_domain_attach_by_name(dev, data->gpc_name); in imx8m_blk_ctrl_probe()
261 if (IS_ERR(domain->power_dev)) { in imx8m_blk_ctrl_probe()
262 dev_err_probe(dev, PTR_ERR(domain->power_dev), in imx8m_blk_ctrl_probe()
264 data->gpc_name); in imx8m_blk_ctrl_probe()
265 ret = PTR_ERR(domain->power_dev); in imx8m_blk_ctrl_probe()
269 domain->genpd.name = data->name; in imx8m_blk_ctrl_probe()
270 domain->genpd.power_on = imx8m_blk_ctrl_power_on; in imx8m_blk_ctrl_probe()
271 domain->genpd.power_off = imx8m_blk_ctrl_power_off; in imx8m_blk_ctrl_probe()
272 domain->bc = bc; in imx8m_blk_ctrl_probe()
274 ret = pm_genpd_init(&domain->genpd, NULL, true); in imx8m_blk_ctrl_probe()
278 data->gpc_name); in imx8m_blk_ctrl_probe()
279 dev_pm_domain_detach(domain->power_dev, true); in imx8m_blk_ctrl_probe()
291 * self-deadlock. in imx8m_blk_ctrl_probe()
293 lockdep_set_class(&domain->genpd.mlock, in imx8m_blk_ctrl_probe()
296 bc->onecell_data.domains[i] = &domain->genpd; in imx8m_blk_ctrl_probe()
299 ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data); in imx8m_blk_ctrl_probe()
305 bc->power_nb.notifier_call = bc_data->power_notifier_fn; in imx8m_blk_ctrl_probe()
306 ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb); in imx8m_blk_ctrl_probe()
321 of_genpd_del_provider(dev->of_node); in imx8m_blk_ctrl_probe()
323 for (i--; i >= 0; i--) { in imx8m_blk_ctrl_probe()
324 pm_genpd_remove(&bc->domains[i].genpd); in imx8m_blk_ctrl_probe()
325 dev_pm_domain_detach(bc->domains[i].power_dev, true); in imx8m_blk_ctrl_probe()
328 dev_pm_domain_detach(bc->bus_power_dev, true); in imx8m_blk_ctrl_probe()
335 struct imx8m_blk_ctrl *bc = dev_get_drvdata(&pdev->dev); in imx8m_blk_ctrl_remove()
338 of_genpd_del_provider(pdev->dev.of_node); in imx8m_blk_ctrl_remove()
340 for (i = 0; bc->onecell_data.num_domains; i++) { in imx8m_blk_ctrl_remove()
341 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; in imx8m_blk_ctrl_remove()
343 pm_genpd_remove(&domain->genpd); in imx8m_blk_ctrl_remove()
344 dev_pm_domain_detach(domain->power_dev, true); in imx8m_blk_ctrl_remove()
347 dev_pm_genpd_remove_notifier(bc->bus_power_dev); in imx8m_blk_ctrl_remove()
349 dev_pm_domain_detach(bc->bus_power_dev, true); in imx8m_blk_ctrl_remove()
368 ret = pm_runtime_get_sync(bc->bus_power_dev); in imx8m_blk_ctrl_suspend()
370 pm_runtime_put_noidle(bc->bus_power_dev); in imx8m_blk_ctrl_suspend()
374 for (i = 0; i < bc->onecell_data.num_domains; i++) { in imx8m_blk_ctrl_suspend()
375 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; in imx8m_blk_ctrl_suspend()
377 ret = pm_runtime_get_sync(domain->power_dev); in imx8m_blk_ctrl_suspend()
379 pm_runtime_put_noidle(domain->power_dev); in imx8m_blk_ctrl_suspend()
387 for (i--; i >= 0; i--) in imx8m_blk_ctrl_suspend()
388 pm_runtime_put(bc->domains[i].power_dev); in imx8m_blk_ctrl_suspend()
390 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_suspend()
400 for (i = 0; i < bc->onecell_data.num_domains; i++) in imx8m_blk_ctrl_resume()
401 pm_runtime_put(bc->domains[i].power_dev); in imx8m_blk_ctrl_resume()
403 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_resume()
428 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, BIT(0) | BIT(1) | BIT(2)); in imx8mm_vpu_power_notifier()
429 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(0) | BIT(1) | BIT(2)); in imx8mm_vpu_power_notifier()
440 regmap_set_bits(bc->regmap, 0x8, 0xffffffff); in imx8mm_vpu_power_notifier()
441 regmap_set_bits(bc->regmap, 0xc, 0xffffffff); in imx8mm_vpu_power_notifier()
442 regmap_set_bits(bc->regmap, 0x10, 0xffffffff); in imx8mm_vpu_power_notifier()
443 regmap_set_bits(bc->regmap, 0x14, 0xffffffff); in imx8mm_vpu_power_notifier()
451 .name = "vpublk-g1",
459 .name = "vpublk-g2",
467 .name = "vpublk-h1",
485 .name = "vpublk-g1",
495 .name = "vpublk-g2",
505 .name = "vpublk-vc8000e",
533 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(12)); in imx8mm_disp_power_notifier()
534 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(6)); in imx8mm_disp_power_notifier()
550 .name = "dispblk-csi-bridge",
551 .clk_names = (const char *[]){ "csi-bridge-axi", "csi-bridge-apb",
552 "csi-bridge-core", },
554 .gpc_name = "csi-bridge",
559 .name = "dispblk-lcdif",
560 .clk_names = (const char *[]){ "lcdif-axi", "lcdif-apb", "lcdif-pix", },
566 .name = "dispblk-mipi-dsi",
567 .clk_names = (const char *[]){ "dsi-pclk", "dsi-ref", },
569 .gpc_name = "mipi-dsi",
575 .name = "dispblk-mipi-csi",
576 .clk_names = (const char *[]){ "csi-aclk", "csi-pclk" },
578 .gpc_name = "mipi-csi",
603 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8)); in imx8mn_disp_power_notifier()
604 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8)); in imx8mn_disp_power_notifier()
620 .name = "dispblk-mipi-dsi",
621 .clk_names = (const char *[]){ "dsi-pclk", "dsi-ref", },
623 .gpc_name = "mipi-dsi",
629 .name = "dispblk-mipi-csi",
630 .clk_names = (const char *[]){ "csi-aclk", "csi-pclk" },
632 .gpc_name = "mipi-csi",
638 .name = "dispblk-lcdif",
639 .clk_names = (const char *[]){ "lcdif-axi", "lcdif-apb", "lcdif-pix", },
646 .name = "dispblk-isi",
677 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8)); in imx8mp_media_power_notifier()
678 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8)); in imx8mp_media_power_notifier()
693 regmap_set_bits(bc->regmap, LCDIF_ARCACHE_CTRL, in imx8mp_media_power_notifier()
704 * isp-ahb and dwe are not in Figure 13-5. Media BLK_CTRL Clocks
708 .name = "mediablk-mipi-dsi-1",
709 .clk_names = (const char *[]){ "apb", "phy", },
711 .gpc_name = "mipi-dsi1",
717 .name = "mediablk-mipi-csi2-1",
718 .clk_names = (const char *[]){ "apb", "cam1" },
720 .gpc_name = "mipi-csi1",
726 .name = "mediablk-lcdif-1",
727 .clk_names = (const char *[]){ "disp1", "apb", "axi", },
732 .path_names = (const char *[]){"lcdif-rd", "lcdif-wr"},
736 .name = "mediablk-isi",
737 .clk_names = (const char *[]){ "axi", "apb" },
746 .name = "mediablk-mipi-csi2-2",
747 .clk_names = (const char *[]){ "apb", "cam2" },
749 .gpc_name = "mipi-csi2",
755 .name = "mediablk-lcdif-2",
756 .clk_names = (const char *[]){ "disp2", "apb", "axi", },
761 .path_names = (const char *[]){"lcdif-rd", "lcdif-wr"},
765 .name = "mediablk-isp",
766 .clk_names = (const char *[]){ "isp", "axi", "apb" },
775 .name = "mediablk-dwe",
776 .clk_names = (const char *[]){ "axi", "apb" },
785 .name = "mediablk-mipi-dsi-2",
788 .gpc_name = "mipi-dsi2",
818 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(0) | BIT(1)); in imx8mq_vpu_power_notifier()
819 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(0) | BIT(1)); in imx8mq_vpu_power_notifier()
830 regmap_set_bits(bc->regmap, 0x8, 0xffffffff); in imx8mq_vpu_power_notifier()
831 regmap_set_bits(bc->regmap, 0xc, 0xffffffff); in imx8mq_vpu_power_notifier()
832 regmap_set_bits(bc->regmap, 0x10, 0xffffffff); in imx8mq_vpu_power_notifier()
840 .name = "vpublk-g1",
848 .name = "vpublk-g2",
866 .compatible = "fsl,imx8mm-vpu-blk-ctrl",
869 .compatible = "fsl,imx8mm-disp-blk-ctrl",
872 .compatible = "fsl,imx8mn-disp-blk-ctrl",
875 .compatible = "fsl,imx8mp-media-blk-ctrl",
878 .compatible = "fsl,imx8mq-vpu-blk-ctrl",
881 .compatible = "fsl,imx8mp-vpu-blk-ctrl",
893 .name = "imx8m-blk-ctrl",