Lines Matching +full:csi +full:- +full:bridge +full:- +full:core
1 // SPDX-License-Identifier: GPL-2.0+
17 #include <dt-bindings/power/imx8mm-power.h>
18 #include <dt-bindings/power/imx8mn-power.h>
19 #include <dt-bindings/power/imx8mp-power.h>
20 #include <dt-bindings/power/imx8mq-power.h>
51 * an if-statement should be used before setting and clearing this
86 const struct imx8m_blk_ctrl_domain_data *data = domain->data; in imx8m_blk_ctrl_power_on()
87 struct imx8m_blk_ctrl *bc = domain->bc; in imx8m_blk_ctrl_power_on()
91 ret = pm_runtime_get_sync(bc->bus_power_dev); in imx8m_blk_ctrl_power_on()
93 pm_runtime_put_noidle(bc->bus_power_dev); in imx8m_blk_ctrl_power_on()
94 dev_err(bc->dev, "failed to power up bus domain\n"); in imx8m_blk_ctrl_power_on()
99 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx8m_blk_ctrl_power_on()
100 if (data->mipi_phy_rst_mask) in imx8m_blk_ctrl_power_on()
101 regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask); in imx8m_blk_ctrl_power_on()
103 /* enable upstream and blk-ctrl clocks to allow reset to propagate */ in imx8m_blk_ctrl_power_on()
104 ret = clk_bulk_prepare_enable(data->num_clks, domain->clks); in imx8m_blk_ctrl_power_on()
106 dev_err(bc->dev, "failed to enable clocks\n"); in imx8m_blk_ctrl_power_on()
109 regmap_set_bits(bc->regmap, BLK_CLK_EN, data->clk_mask); in imx8m_blk_ctrl_power_on()
112 ret = pm_runtime_get_sync(domain->power_dev); in imx8m_blk_ctrl_power_on()
114 dev_err(bc->dev, "failed to power up peripheral domain\n"); in imx8m_blk_ctrl_power_on()
122 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx8m_blk_ctrl_power_on()
123 if (data->mipi_phy_rst_mask) in imx8m_blk_ctrl_power_on()
124 regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask); in imx8m_blk_ctrl_power_on()
126 ret = icc_bulk_set_bw(domain->num_paths, domain->paths); in imx8m_blk_ctrl_power_on()
128 dev_err(bc->dev, "failed to set icc bw\n"); in imx8m_blk_ctrl_power_on()
131 clk_bulk_disable_unprepare(data->num_clks, domain->clks); in imx8m_blk_ctrl_power_on()
136 clk_bulk_disable_unprepare(data->num_clks, domain->clks); in imx8m_blk_ctrl_power_on()
138 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_power_on()
146 const struct imx8m_blk_ctrl_domain_data *data = domain->data; in imx8m_blk_ctrl_power_off()
147 struct imx8m_blk_ctrl *bc = domain->bc; in imx8m_blk_ctrl_power_off()
150 if (data->mipi_phy_rst_mask) in imx8m_blk_ctrl_power_off()
151 regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask); in imx8m_blk_ctrl_power_off()
153 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx8m_blk_ctrl_power_off()
154 regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask); in imx8m_blk_ctrl_power_off()
157 pm_runtime_put(domain->power_dev); in imx8m_blk_ctrl_power_off()
160 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_power_off()
170 struct device *dev = &pdev->dev; in imx8m_blk_ctrl_probe()
183 return -ENOMEM; in imx8m_blk_ctrl_probe()
185 bc->dev = dev; in imx8m_blk_ctrl_probe()
193 regmap_config.max_register = bc_data->max_reg; in imx8m_blk_ctrl_probe()
194 bc->regmap = devm_regmap_init_mmio(dev, base, ®map_config); in imx8m_blk_ctrl_probe()
195 if (IS_ERR(bc->regmap)) in imx8m_blk_ctrl_probe()
196 return dev_err_probe(dev, PTR_ERR(bc->regmap), in imx8m_blk_ctrl_probe()
199 bc->domains = devm_kcalloc(dev, bc_data->num_domains, in imx8m_blk_ctrl_probe()
202 if (!bc->domains) in imx8m_blk_ctrl_probe()
203 return -ENOMEM; in imx8m_blk_ctrl_probe()
205 bc->onecell_data.num_domains = bc_data->num_domains; in imx8m_blk_ctrl_probe()
206 bc->onecell_data.domains = in imx8m_blk_ctrl_probe()
207 devm_kcalloc(dev, bc_data->num_domains, in imx8m_blk_ctrl_probe()
209 if (!bc->onecell_data.domains) in imx8m_blk_ctrl_probe()
210 return -ENOMEM; in imx8m_blk_ctrl_probe()
212 bc->bus_power_dev = genpd_dev_pm_attach_by_name(dev, "bus"); in imx8m_blk_ctrl_probe()
213 if (IS_ERR(bc->bus_power_dev)) in imx8m_blk_ctrl_probe()
214 return dev_err_probe(dev, PTR_ERR(bc->bus_power_dev), in imx8m_blk_ctrl_probe()
217 for (i = 0; i < bc_data->num_domains; i++) { in imx8m_blk_ctrl_probe()
218 const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i]; in imx8m_blk_ctrl_probe()
219 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; in imx8m_blk_ctrl_probe()
222 domain->data = data; in imx8m_blk_ctrl_probe()
223 domain->num_paths = data->num_paths; in imx8m_blk_ctrl_probe()
225 for (j = 0; j < data->num_clks; j++) in imx8m_blk_ctrl_probe()
226 domain->clks[j].id = data->clk_names[j]; in imx8m_blk_ctrl_probe()
228 for (j = 0; j < data->num_paths; j++) { in imx8m_blk_ctrl_probe()
229 domain->paths[j].name = data->path_names[j]; in imx8m_blk_ctrl_probe()
231 domain->paths[j].avg_bw = 1; in imx8m_blk_ctrl_probe()
232 domain->paths[j].peak_bw = 1; in imx8m_blk_ctrl_probe()
235 ret = devm_of_icc_bulk_get(dev, data->num_paths, domain->paths); in imx8m_blk_ctrl_probe()
237 if (ret != -EPROBE_DEFER) { in imx8m_blk_ctrl_probe()
239 domain->num_paths = 0; in imx8m_blk_ctrl_probe()
246 ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks); in imx8m_blk_ctrl_probe()
252 domain->power_dev = in imx8m_blk_ctrl_probe()
253 dev_pm_domain_attach_by_name(dev, data->gpc_name); in imx8m_blk_ctrl_probe()
254 if (IS_ERR(domain->power_dev)) { in imx8m_blk_ctrl_probe()
255 dev_err_probe(dev, PTR_ERR(domain->power_dev), in imx8m_blk_ctrl_probe()
257 data->gpc_name); in imx8m_blk_ctrl_probe()
258 ret = PTR_ERR(domain->power_dev); in imx8m_blk_ctrl_probe()
262 domain->genpd.name = data->name; in imx8m_blk_ctrl_probe()
263 domain->genpd.power_on = imx8m_blk_ctrl_power_on; in imx8m_blk_ctrl_probe()
264 domain->genpd.power_off = imx8m_blk_ctrl_power_off; in imx8m_blk_ctrl_probe()
265 domain->bc = bc; in imx8m_blk_ctrl_probe()
267 ret = pm_genpd_init(&domain->genpd, NULL, true); in imx8m_blk_ctrl_probe()
271 data->gpc_name); in imx8m_blk_ctrl_probe()
272 dev_pm_domain_detach(domain->power_dev, true); in imx8m_blk_ctrl_probe()
284 * self-deadlock. in imx8m_blk_ctrl_probe()
286 lockdep_set_class(&domain->genpd.mlock, in imx8m_blk_ctrl_probe()
289 bc->onecell_data.domains[i] = &domain->genpd; in imx8m_blk_ctrl_probe()
292 ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data); in imx8m_blk_ctrl_probe()
298 bc->power_nb.notifier_call = bc_data->power_notifier_fn; in imx8m_blk_ctrl_probe()
299 ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb); in imx8m_blk_ctrl_probe()
310 of_genpd_del_provider(dev->of_node); in imx8m_blk_ctrl_probe()
312 for (i--; i >= 0; i--) { in imx8m_blk_ctrl_probe()
313 pm_genpd_remove(&bc->domains[i].genpd); in imx8m_blk_ctrl_probe()
314 dev_pm_domain_detach(bc->domains[i].power_dev, true); in imx8m_blk_ctrl_probe()
317 dev_pm_domain_detach(bc->bus_power_dev, true); in imx8m_blk_ctrl_probe()
324 struct imx8m_blk_ctrl *bc = dev_get_drvdata(&pdev->dev); in imx8m_blk_ctrl_remove()
327 of_genpd_del_provider(pdev->dev.of_node); in imx8m_blk_ctrl_remove()
329 for (i = 0; bc->onecell_data.num_domains; i++) { in imx8m_blk_ctrl_remove()
330 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; in imx8m_blk_ctrl_remove()
332 pm_genpd_remove(&domain->genpd); in imx8m_blk_ctrl_remove()
333 dev_pm_domain_detach(domain->power_dev, true); in imx8m_blk_ctrl_remove()
336 dev_pm_genpd_remove_notifier(bc->bus_power_dev); in imx8m_blk_ctrl_remove()
338 dev_pm_domain_detach(bc->bus_power_dev, true); in imx8m_blk_ctrl_remove()
357 ret = pm_runtime_get_sync(bc->bus_power_dev); in imx8m_blk_ctrl_suspend()
359 pm_runtime_put_noidle(bc->bus_power_dev); in imx8m_blk_ctrl_suspend()
363 for (i = 0; i < bc->onecell_data.num_domains; i++) { in imx8m_blk_ctrl_suspend()
364 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i]; in imx8m_blk_ctrl_suspend()
366 ret = pm_runtime_get_sync(domain->power_dev); in imx8m_blk_ctrl_suspend()
368 pm_runtime_put_noidle(domain->power_dev); in imx8m_blk_ctrl_suspend()
376 for (i--; i >= 0; i--) in imx8m_blk_ctrl_suspend()
377 pm_runtime_put(bc->domains[i].power_dev); in imx8m_blk_ctrl_suspend()
379 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_suspend()
389 for (i = 0; i < bc->onecell_data.num_domains; i++) in imx8m_blk_ctrl_resume()
390 pm_runtime_put(bc->domains[i].power_dev); in imx8m_blk_ctrl_resume()
392 pm_runtime_put(bc->bus_power_dev); in imx8m_blk_ctrl_resume()
417 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, BIT(0) | BIT(1) | BIT(2)); in imx8mm_vpu_power_notifier()
418 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(0) | BIT(1) | BIT(2)); in imx8mm_vpu_power_notifier()
429 regmap_set_bits(bc->regmap, 0x8, 0xffffffff); in imx8mm_vpu_power_notifier()
430 regmap_set_bits(bc->regmap, 0xc, 0xffffffff); in imx8mm_vpu_power_notifier()
431 regmap_set_bits(bc->regmap, 0x10, 0xffffffff); in imx8mm_vpu_power_notifier()
432 regmap_set_bits(bc->regmap, 0x14, 0xffffffff); in imx8mm_vpu_power_notifier()
440 .name = "vpublk-g1",
448 .name = "vpublk-g2",
456 .name = "vpublk-h1",
474 .name = "vpublk-g1",
484 .name = "vpublk-g2",
494 .name = "vpublk-vc8000e",
522 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(12)); in imx8mm_disp_power_notifier()
523 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(6)); in imx8mm_disp_power_notifier()
539 .name = "dispblk-csi-bridge",
540 .clk_names = (const char *[]){ "csi-bridge-axi", "csi-bridge-apb",
541 "csi-bridge-core", },
543 .gpc_name = "csi-bridge",
548 .name = "dispblk-lcdif",
549 .clk_names = (const char *[]){ "lcdif-axi", "lcdif-apb", "lcdif-pix", },
555 .name = "dispblk-mipi-dsi",
556 .clk_names = (const char *[]){ "dsi-pclk", "dsi-ref", },
558 .gpc_name = "mipi-dsi",
564 .name = "dispblk-mipi-csi",
565 .clk_names = (const char *[]){ "csi-aclk", "csi-pclk" },
567 .gpc_name = "mipi-csi",
592 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8)); in imx8mn_disp_power_notifier()
593 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8)); in imx8mn_disp_power_notifier()
609 .name = "dispblk-mipi-dsi",
610 .clk_names = (const char *[]){ "dsi-pclk", "dsi-ref", },
612 .gpc_name = "mipi-dsi",
618 .name = "dispblk-mipi-csi",
619 .clk_names = (const char *[]){ "csi-aclk", "csi-pclk" },
621 .gpc_name = "mipi-csi",
627 .name = "dispblk-lcdif",
628 .clk_names = (const char *[]){ "lcdif-axi", "lcdif-apb", "lcdif-pix", },
635 .name = "dispblk-isi",
662 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8)); in imx8mp_media_power_notifier()
663 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8)); in imx8mp_media_power_notifier()
679 * isp-ahb and dwe are not in Figure 13-5. Media BLK_CTRL Clocks
683 .name = "mediablk-mipi-dsi-1",
686 .gpc_name = "mipi-dsi1",
692 .name = "mediablk-mipi-csi2-1",
695 .gpc_name = "mipi-csi1",
701 .name = "mediablk-lcdif-1",
707 .path_names = (const char *[]){"lcdif-rd", "lcdif-wr"},
711 .name = "mediablk-isi",
721 .name = "mediablk-mipi-csi2-2",
724 .gpc_name = "mipi-csi2",
730 .name = "mediablk-lcdif-2",
736 .path_names = (const char *[]){"lcdif-rd", "lcdif-wr"},
740 .name = "mediablk-isp",
750 .name = "mediablk-dwe",
760 .name = "mediablk-mipi-dsi-2",
763 .gpc_name = "mipi-dsi2",
793 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(0) | BIT(1)); in imx8mq_vpu_power_notifier()
794 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(0) | BIT(1)); in imx8mq_vpu_power_notifier()
805 regmap_set_bits(bc->regmap, 0x8, 0xffffffff); in imx8mq_vpu_power_notifier()
806 regmap_set_bits(bc->regmap, 0xc, 0xffffffff); in imx8mq_vpu_power_notifier()
807 regmap_set_bits(bc->regmap, 0x10, 0xffffffff); in imx8mq_vpu_power_notifier()
815 .name = "vpublk-g1",
823 .name = "vpublk-g2",
841 .compatible = "fsl,imx8mm-vpu-blk-ctrl",
844 .compatible = "fsl,imx8mm-disp-blk-ctrl",
847 .compatible = "fsl,imx8mn-disp-blk-ctrl",
850 .compatible = "fsl,imx8mp-media-blk-ctrl",
853 .compatible = "fsl,imx8mq-vpu-blk-ctrl",
856 .compatible = "fsl,imx8mp-vpu-blk-ctrl",
868 .name = "imx8m-blk-ctrl",