1 // SPDX-License-Identifier: GPL-2.0+
7 #include <linux/bitfield.h>
8 #include <linux/device.h>
9 #include <linux/interconnect.h>
10 #include <linux/module.h>
11 #include <linux/of_device.h>
12 #include <linux/platform_device.h>
13 #include <linux/pm_domain.h>
14 #include <linux/pm_runtime.h>
15 #include <linux/regmap.h>
16 #include <linux/clk.h>
18 #include <dt-bindings/power/imx8mm-power.h>
19 #include <dt-bindings/power/imx8mn-power.h>
20 #include <dt-bindings/power/imx8mp-power.h>
21 #include <dt-bindings/power/imx8mq-power.h>
23 #define BLK_SFT_RSTN 0x0
24 #define BLK_CLK_EN 0x4
25 #define BLK_MIPI_RESET_DIV 0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
27 struct imx8m_blk_ctrl_domain;
29 struct imx8m_blk_ctrl {
31 struct notifier_block power_nb;
32 struct device *bus_power_dev;
33 struct regmap *regmap;
34 struct imx8m_blk_ctrl_domain *domains;
35 struct genpd_onecell_data onecell_data;
38 struct imx8m_blk_ctrl_domain_data {
40 const char * const *clk_names;
41 const char * const *path_names;
49 * i.MX8M Mini, Nano and Plus have a third DISPLAY_BLK_CTRL register
50 * which is used to control the reset for the MIPI Phy.
51 * Since it's only present in certain circumstances,
52 * an if-statement should be used before setting and clearing this
55 u32 mipi_phy_rst_mask;
58 #define DOMAIN_MAX_CLKS 4
59 #define DOMAIN_MAX_PATHS 4
61 struct imx8m_blk_ctrl_domain {
62 struct generic_pm_domain genpd;
63 const struct imx8m_blk_ctrl_domain_data *data;
64 struct clk_bulk_data clks[DOMAIN_MAX_CLKS];
65 struct icc_bulk_data paths[DOMAIN_MAX_PATHS];
66 struct device *power_dev;
67 struct imx8m_blk_ctrl *bc;
71 struct imx8m_blk_ctrl_data {
73 notifier_fn_t power_notifier_fn;
74 const struct imx8m_blk_ctrl_domain_data *domains;
78 static inline struct imx8m_blk_ctrl_domain *
79 to_imx8m_blk_ctrl_domain(struct generic_pm_domain *genpd)
81 return container_of(genpd, struct imx8m_blk_ctrl_domain, genpd);
84 static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
86 struct imx8m_blk_ctrl_domain *domain = to_imx8m_blk_ctrl_domain(genpd);
87 const struct imx8m_blk_ctrl_domain_data *data = domain->data;
88 struct imx8m_blk_ctrl *bc = domain->bc;
91 /* make sure bus domain is awake */
92 ret = pm_runtime_get_sync(bc->bus_power_dev);
94 pm_runtime_put_noidle(bc->bus_power_dev);
95 dev_err(bc->dev, "failed to power up bus domain\n");
99 /* put devices into reset */
100 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
101 if (data->mipi_phy_rst_mask)
102 regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
104 /* enable upstream and blk-ctrl clocks to allow reset to propagate */
105 ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
107 dev_err(bc->dev, "failed to enable clocks\n");
110 regmap_set_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
112 /* power up upstream GPC domain */
113 ret = pm_runtime_get_sync(domain->power_dev);
115 dev_err(bc->dev, "failed to power up peripheral domain\n");
119 /* wait for reset to propagate */
123 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
124 if (data->mipi_phy_rst_mask)
125 regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
127 ret = icc_bulk_set_bw(domain->num_paths, domain->paths);
129 dev_err(bc->dev, "failed to set icc bw\n");
131 /* disable upstream clocks */
132 clk_bulk_disable_unprepare(data->num_clks, domain->clks);
137 clk_bulk_disable_unprepare(data->num_clks, domain->clks);
139 pm_runtime_put(bc->bus_power_dev);
144 static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
146 struct imx8m_blk_ctrl_domain *domain = to_imx8m_blk_ctrl_domain(genpd);
147 const struct imx8m_blk_ctrl_domain_data *data = domain->data;
148 struct imx8m_blk_ctrl *bc = domain->bc;
150 /* put devices into reset and disable clocks */
151 if (data->mipi_phy_rst_mask)
152 regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
154 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
155 regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
157 /* power down upstream GPC domain */
158 pm_runtime_put(domain->power_dev);
160 /* allow bus domain to suspend */
161 pm_runtime_put(bc->bus_power_dev);
166 static struct lock_class_key blk_ctrl_genpd_lock_class;
168 static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
170 const struct imx8m_blk_ctrl_data *bc_data;
171 struct device *dev = &pdev->dev;
172 struct imx8m_blk_ctrl *bc;
176 struct regmap_config regmap_config = {
182 bc = devm_kzalloc(dev, sizeof(*bc), GFP_KERNEL);
188 bc_data = of_device_get_match_data(dev);
190 base = devm_platform_ioremap_resource(pdev, 0);
192 return PTR_ERR(base);
194 regmap_config.max_register = bc_data->max_reg;
195 bc->regmap = devm_regmap_init_mmio(dev, base, ®map_config);
196 if (IS_ERR(bc->regmap))
197 return dev_err_probe(dev, PTR_ERR(bc->regmap),
198 "failed to init regmap\n");
200 bc->domains = devm_kcalloc(dev, bc_data->num_domains,
201 sizeof(struct imx8m_blk_ctrl_domain),
206 bc->onecell_data.num_domains = bc_data->num_domains;
207 bc->onecell_data.domains =
208 devm_kcalloc(dev, bc_data->num_domains,
209 sizeof(struct generic_pm_domain *), GFP_KERNEL);
210 if (!bc->onecell_data.domains)
213 bc->bus_power_dev = dev_pm_domain_attach_by_name(dev, "bus");
214 if (IS_ERR(bc->bus_power_dev)) {
215 if (PTR_ERR(bc->bus_power_dev) == -ENODEV)
216 return dev_err_probe(dev, -EPROBE_DEFER,
217 "failed to attach power domain \"bus\"\n");
219 return dev_err_probe(dev, PTR_ERR(bc->bus_power_dev),
220 "failed to attach power domain \"bus\"\n");
223 for (i = 0; i < bc_data->num_domains; i++) {
224 const struct imx8m_blk_ctrl_domain_data *data = &bc_data->domains[i];
225 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
229 domain->num_paths = data->num_paths;
231 for (j = 0; j < data->num_clks; j++)
232 domain->clks[j].id = data->clk_names[j];
234 for (j = 0; j < data->num_paths; j++) {
235 domain->paths[j].name = data->path_names[j];
236 /* Fake value for now, just let ICC could configure NoC mode/priority */
237 domain->paths[j].avg_bw = 1;
238 domain->paths[j].peak_bw = 1;
241 ret = devm_of_icc_bulk_get(dev, data->num_paths, domain->paths);
243 if (ret != -EPROBE_DEFER) {
244 dev_warn_once(dev, "Could not get interconnect paths, NoC will stay unconfigured!\n");
245 domain->num_paths = 0;
247 dev_err_probe(dev, ret, "failed to get noc entries\n");
252 ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks);
254 dev_err_probe(dev, ret, "failed to get clock\n");
259 dev_pm_domain_attach_by_name(dev, data->gpc_name);
260 if (IS_ERR(domain->power_dev)) {
261 dev_err_probe(dev, PTR_ERR(domain->power_dev),
262 "failed to attach power domain \"%s\"\n",
264 ret = PTR_ERR(domain->power_dev);
268 domain->genpd.name = data->name;
269 domain->genpd.power_on = imx8m_blk_ctrl_power_on;
270 domain->genpd.power_off = imx8m_blk_ctrl_power_off;
273 ret = pm_genpd_init(&domain->genpd, NULL, true);
275 dev_err_probe(dev, ret,
276 "failed to init power domain \"%s\"\n",
278 dev_pm_domain_detach(domain->power_dev, true);
283 * We use runtime PM to trigger power on/off of the upstream GPC
284 * domain, as a strict hierarchical parent/child power domain
285 * setup doesn't allow us to meet the sequencing requirements.
286 * This means we have nested locking of genpd locks, without the
287 * nesting being visible at the genpd level, so we need a
288 * separate lock class to make lockdep aware of the fact that
289 * this are separate domain locks that can be nested without a
292 lockdep_set_class(&domain->genpd.mlock,
293 &blk_ctrl_genpd_lock_class);
295 bc->onecell_data.domains[i] = &domain->genpd;
298 ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
300 dev_err_probe(dev, ret, "failed to add power domain provider\n");
304 bc->power_nb.notifier_call = bc_data->power_notifier_fn;
305 ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
307 dev_err_probe(dev, ret, "failed to add power notifier\n");
308 goto cleanup_provider;
311 dev_set_drvdata(dev, bc);
313 ret = devm_of_platform_populate(dev);
315 goto cleanup_provider;
320 of_genpd_del_provider(dev->of_node);
322 for (i--; i >= 0; i--) {
323 pm_genpd_remove(&bc->domains[i].genpd);
324 dev_pm_domain_detach(bc->domains[i].power_dev, true);
327 dev_pm_domain_detach(bc->bus_power_dev, true);
332 static int imx8m_blk_ctrl_remove(struct platform_device *pdev)
334 struct imx8m_blk_ctrl *bc = dev_get_drvdata(&pdev->dev);
337 of_genpd_del_provider(pdev->dev.of_node);
339 for (i = 0; bc->onecell_data.num_domains; i++) {
340 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
342 pm_genpd_remove(&domain->genpd);
343 dev_pm_domain_detach(domain->power_dev, true);
346 dev_pm_genpd_remove_notifier(bc->bus_power_dev);
348 dev_pm_domain_detach(bc->bus_power_dev, true);
353 #ifdef CONFIG_PM_SLEEP
354 static int imx8m_blk_ctrl_suspend(struct device *dev)
356 struct imx8m_blk_ctrl *bc = dev_get_drvdata(dev);
360 * This may look strange, but is done so the generic PM_SLEEP code
361 * can power down our domains and more importantly power them up again
362 * after resume, without tripping over our usage of runtime PM to
363 * control the upstream GPC domains. Things happen in the right order
364 * in the system suspend/resume paths due to the device parent/child
367 ret = pm_runtime_get_sync(bc->bus_power_dev);
369 pm_runtime_put_noidle(bc->bus_power_dev);
373 for (i = 0; i < bc->onecell_data.num_domains; i++) {
374 struct imx8m_blk_ctrl_domain *domain = &bc->domains[i];
376 ret = pm_runtime_get_sync(domain->power_dev);
378 pm_runtime_put_noidle(domain->power_dev);
386 for (i--; i >= 0; i--)
387 pm_runtime_put(bc->domains[i].power_dev);
389 pm_runtime_put(bc->bus_power_dev);
394 static int imx8m_blk_ctrl_resume(struct device *dev)
396 struct imx8m_blk_ctrl *bc = dev_get_drvdata(dev);
399 for (i = 0; i < bc->onecell_data.num_domains; i++)
400 pm_runtime_put(bc->domains[i].power_dev);
402 pm_runtime_put(bc->bus_power_dev);
408 static const struct dev_pm_ops imx8m_blk_ctrl_pm_ops = {
409 SET_SYSTEM_SLEEP_PM_OPS(imx8m_blk_ctrl_suspend, imx8m_blk_ctrl_resume)
412 static int imx8mm_vpu_power_notifier(struct notifier_block *nb,
413 unsigned long action, void *data)
415 struct imx8m_blk_ctrl *bc = container_of(nb, struct imx8m_blk_ctrl,
418 if (action != GENPD_NOTIFY_ON && action != GENPD_NOTIFY_PRE_OFF)
422 * The ADB in the VPUMIX domain has no separate reset and clock
423 * enable bits, but is ungated together with the VPU clocks. To
424 * allow the handshake with the GPC to progress we put the VPUs
425 * in reset and ungate the clocks.
427 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, BIT(0) | BIT(1) | BIT(2));
428 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(0) | BIT(1) | BIT(2));
430 if (action == GENPD_NOTIFY_ON) {
432 * On power up we have no software backchannel to the GPC to
433 * wait for the ADB handshake to happen, so we just delay for a
434 * bit. On power down the GPC driver waits for the handshake.
438 /* set "fuse" bits to enable the VPUs */
439 regmap_set_bits(bc->regmap, 0x8, 0xffffffff);
440 regmap_set_bits(bc->regmap, 0xc, 0xffffffff);
441 regmap_set_bits(bc->regmap, 0x10, 0xffffffff);
442 regmap_set_bits(bc->regmap, 0x14, 0xffffffff);
448 static const struct imx8m_blk_ctrl_domain_data imx8mm_vpu_blk_ctl_domain_data[] = {
449 [IMX8MM_VPUBLK_PD_G1] = {
451 .clk_names = (const char *[]){ "g1", },
457 [IMX8MM_VPUBLK_PD_G2] = {
459 .clk_names = (const char *[]){ "g2", },
465 [IMX8MM_VPUBLK_PD_H1] = {
467 .clk_names = (const char *[]){ "h1", },
475 static const struct imx8m_blk_ctrl_data imx8mm_vpu_blk_ctl_dev_data = {
477 .power_notifier_fn = imx8mm_vpu_power_notifier,
478 .domains = imx8mm_vpu_blk_ctl_domain_data,
479 .num_domains = ARRAY_SIZE(imx8mm_vpu_blk_ctl_domain_data),
482 static const struct imx8m_blk_ctrl_domain_data imx8mp_vpu_blk_ctl_domain_data[] = {
483 [IMX8MP_VPUBLK_PD_G1] = {
485 .clk_names = (const char *[]){ "g1", },
490 .path_names = (const char *[]){"g1"},
493 [IMX8MP_VPUBLK_PD_G2] = {
495 .clk_names = (const char *[]){ "g2", },
500 .path_names = (const char *[]){"g2"},
503 [IMX8MP_VPUBLK_PD_VC8000E] = {
504 .name = "vpublk-vc8000e",
505 .clk_names = (const char *[]){ "vc8000e", },
507 .gpc_name = "vc8000e",
510 .path_names = (const char *[]){"vc8000e"},
515 static const struct imx8m_blk_ctrl_data imx8mp_vpu_blk_ctl_dev_data = {
517 .power_notifier_fn = imx8mm_vpu_power_notifier,
518 .domains = imx8mp_vpu_blk_ctl_domain_data,
519 .num_domains = ARRAY_SIZE(imx8mp_vpu_blk_ctl_domain_data),
522 static int imx8mm_disp_power_notifier(struct notifier_block *nb,
523 unsigned long action, void *data)
525 struct imx8m_blk_ctrl *bc = container_of(nb, struct imx8m_blk_ctrl,
528 if (action != GENPD_NOTIFY_ON && action != GENPD_NOTIFY_PRE_OFF)
531 /* Enable bus clock and deassert bus reset */
532 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(12));
533 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(6));
536 * On power up we have no software backchannel to the GPC to
537 * wait for the ADB handshake to happen, so we just delay for a
538 * bit. On power down the GPC driver waits for the handshake.
540 if (action == GENPD_NOTIFY_ON)
547 static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[] = {
548 [IMX8MM_DISPBLK_PD_CSI_BRIDGE] = {
549 .name = "dispblk-csi-bridge",
550 .clk_names = (const char *[]){ "csi-bridge-axi", "csi-bridge-apb",
551 "csi-bridge-core", },
553 .gpc_name = "csi-bridge",
554 .rst_mask = BIT(0) | BIT(1) | BIT(2),
555 .clk_mask = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5),
557 [IMX8MM_DISPBLK_PD_LCDIF] = {
558 .name = "dispblk-lcdif",
559 .clk_names = (const char *[]){ "lcdif-axi", "lcdif-apb", "lcdif-pix", },
562 .clk_mask = BIT(6) | BIT(7),
564 [IMX8MM_DISPBLK_PD_MIPI_DSI] = {
565 .name = "dispblk-mipi-dsi",
566 .clk_names = (const char *[]){ "dsi-pclk", "dsi-ref", },
568 .gpc_name = "mipi-dsi",
570 .clk_mask = BIT(8) | BIT(9),
571 .mipi_phy_rst_mask = BIT(17),
573 [IMX8MM_DISPBLK_PD_MIPI_CSI] = {
574 .name = "dispblk-mipi-csi",
575 .clk_names = (const char *[]){ "csi-aclk", "csi-pclk" },
577 .gpc_name = "mipi-csi",
578 .rst_mask = BIT(3) | BIT(4),
579 .clk_mask = BIT(10) | BIT(11),
580 .mipi_phy_rst_mask = BIT(16),
584 static const struct imx8m_blk_ctrl_data imx8mm_disp_blk_ctl_dev_data = {
586 .power_notifier_fn = imx8mm_disp_power_notifier,
587 .domains = imx8mm_disp_blk_ctl_domain_data,
588 .num_domains = ARRAY_SIZE(imx8mm_disp_blk_ctl_domain_data),
592 static int imx8mn_disp_power_notifier(struct notifier_block *nb,
593 unsigned long action, void *data)
595 struct imx8m_blk_ctrl *bc = container_of(nb, struct imx8m_blk_ctrl,
598 if (action != GENPD_NOTIFY_ON && action != GENPD_NOTIFY_PRE_OFF)
601 /* Enable bus clock and deassert bus reset */
602 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8));
603 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8));
606 * On power up we have no software backchannel to the GPC to
607 * wait for the ADB handshake to happen, so we just delay for a
608 * bit. On power down the GPC driver waits for the handshake.
610 if (action == GENPD_NOTIFY_ON)
617 static const struct imx8m_blk_ctrl_domain_data imx8mn_disp_blk_ctl_domain_data[] = {
618 [IMX8MN_DISPBLK_PD_MIPI_DSI] = {
619 .name = "dispblk-mipi-dsi",
620 .clk_names = (const char *[]){ "dsi-pclk", "dsi-ref", },
622 .gpc_name = "mipi-dsi",
623 .rst_mask = BIT(0) | BIT(1),
624 .clk_mask = BIT(0) | BIT(1),
625 .mipi_phy_rst_mask = BIT(17),
627 [IMX8MN_DISPBLK_PD_MIPI_CSI] = {
628 .name = "dispblk-mipi-csi",
629 .clk_names = (const char *[]){ "csi-aclk", "csi-pclk" },
631 .gpc_name = "mipi-csi",
632 .rst_mask = BIT(2) | BIT(3),
633 .clk_mask = BIT(2) | BIT(3),
634 .mipi_phy_rst_mask = BIT(16),
636 [IMX8MN_DISPBLK_PD_LCDIF] = {
637 .name = "dispblk-lcdif",
638 .clk_names = (const char *[]){ "lcdif-axi", "lcdif-apb", "lcdif-pix", },
641 .rst_mask = BIT(4) | BIT(5),
642 .clk_mask = BIT(4) | BIT(5),
644 [IMX8MN_DISPBLK_PD_ISI] = {
645 .name = "dispblk-isi",
646 .clk_names = (const char *[]){ "disp_axi", "disp_apb", "disp_axi_root",
650 .rst_mask = BIT(6) | BIT(7),
651 .clk_mask = BIT(6) | BIT(7),
655 static const struct imx8m_blk_ctrl_data imx8mn_disp_blk_ctl_dev_data = {
657 .power_notifier_fn = imx8mn_disp_power_notifier,
658 .domains = imx8mn_disp_blk_ctl_domain_data,
659 .num_domains = ARRAY_SIZE(imx8mn_disp_blk_ctl_domain_data),
662 #define LCDIF_ARCACHE_CTRL 0x4c
663 #define LCDIF_1_RD_HURRY GENMASK(15, 13)
664 #define LCDIF_0_RD_HURRY GENMASK(12, 10)
666 static int imx8mp_media_power_notifier(struct notifier_block *nb,
667 unsigned long action, void *data)
669 struct imx8m_blk_ctrl *bc = container_of(nb, struct imx8m_blk_ctrl,
672 if (action != GENPD_NOTIFY_ON && action != GENPD_NOTIFY_PRE_OFF)
675 /* Enable bus clock and deassert bus reset */
676 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8));
677 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8));
679 if (action == GENPD_NOTIFY_ON) {
681 * On power up we have no software backchannel to the GPC to
682 * wait for the ADB handshake to happen, so we just delay for a
683 * bit. On power down the GPC driver waits for the handshake.
688 * Set panic read hurry level for both LCDIF interfaces to
689 * maximum priority to minimize chances of display FIFO
692 regmap_set_bits(bc->regmap, LCDIF_ARCACHE_CTRL,
693 FIELD_PREP(LCDIF_1_RD_HURRY, 7) |
694 FIELD_PREP(LCDIF_0_RD_HURRY, 7));
701 * From i.MX 8M Plus Applications Processor Reference Manual, Rev. 1,
702 * section 13.2.2, 13.2.3
703 * isp-ahb and dwe are not in Figure 13-5. Media BLK_CTRL Clocks
705 static const struct imx8m_blk_ctrl_domain_data imx8mp_media_blk_ctl_domain_data[] = {
706 [IMX8MP_MEDIABLK_PD_MIPI_DSI_1] = {
707 .name = "mediablk-mipi-dsi-1",
708 .clk_names = (const char *[]){ "apb", "phy", },
710 .gpc_name = "mipi-dsi1",
711 .rst_mask = BIT(0) | BIT(1),
712 .clk_mask = BIT(0) | BIT(1),
713 .mipi_phy_rst_mask = BIT(17),
715 [IMX8MP_MEDIABLK_PD_MIPI_CSI2_1] = {
716 .name = "mediablk-mipi-csi2-1",
717 .clk_names = (const char *[]){ "apb", "cam1" },
719 .gpc_name = "mipi-csi1",
720 .rst_mask = BIT(2) | BIT(3),
721 .clk_mask = BIT(2) | BIT(3),
722 .mipi_phy_rst_mask = BIT(16),
724 [IMX8MP_MEDIABLK_PD_LCDIF_1] = {
725 .name = "mediablk-lcdif-1",
726 .clk_names = (const char *[]){ "disp1", "apb", "axi", },
728 .gpc_name = "lcdif1",
729 .rst_mask = BIT(4) | BIT(5) | BIT(23),
730 .clk_mask = BIT(4) | BIT(5) | BIT(23),
731 .path_names = (const char *[]){"lcdif-rd", "lcdif-wr"},
734 [IMX8MP_MEDIABLK_PD_ISI] = {
735 .name = "mediablk-isi",
736 .clk_names = (const char *[]){ "axi", "apb" },
739 .rst_mask = BIT(6) | BIT(7),
740 .clk_mask = BIT(6) | BIT(7),
741 .path_names = (const char *[]){"isi0", "isi1", "isi2"},
744 [IMX8MP_MEDIABLK_PD_MIPI_CSI2_2] = {
745 .name = "mediablk-mipi-csi2-2",
746 .clk_names = (const char *[]){ "apb", "cam2" },
748 .gpc_name = "mipi-csi2",
749 .rst_mask = BIT(9) | BIT(10),
750 .clk_mask = BIT(9) | BIT(10),
751 .mipi_phy_rst_mask = BIT(30),
753 [IMX8MP_MEDIABLK_PD_LCDIF_2] = {
754 .name = "mediablk-lcdif-2",
755 .clk_names = (const char *[]){ "disp2", "apb", "axi", },
757 .gpc_name = "lcdif2",
758 .rst_mask = BIT(11) | BIT(12) | BIT(24),
759 .clk_mask = BIT(11) | BIT(12) | BIT(24),
760 .path_names = (const char *[]){"lcdif-rd", "lcdif-wr"},
763 [IMX8MP_MEDIABLK_PD_ISP] = {
764 .name = "mediablk-isp",
765 .clk_names = (const char *[]){ "isp", "axi", "apb" },
768 .rst_mask = BIT(16) | BIT(17) | BIT(18),
769 .clk_mask = BIT(16) | BIT(17) | BIT(18),
770 .path_names = (const char *[]){"isp0", "isp1"},
773 [IMX8MP_MEDIABLK_PD_DWE] = {
774 .name = "mediablk-dwe",
775 .clk_names = (const char *[]){ "axi", "apb" },
778 .rst_mask = BIT(19) | BIT(20) | BIT(21),
779 .clk_mask = BIT(19) | BIT(20) | BIT(21),
780 .path_names = (const char *[]){"dwe"},
783 [IMX8MP_MEDIABLK_PD_MIPI_DSI_2] = {
784 .name = "mediablk-mipi-dsi-2",
785 .clk_names = (const char *[]){ "phy", },
787 .gpc_name = "mipi-dsi2",
790 .mipi_phy_rst_mask = BIT(29),
794 static const struct imx8m_blk_ctrl_data imx8mp_media_blk_ctl_dev_data = {
796 .power_notifier_fn = imx8mp_media_power_notifier,
797 .domains = imx8mp_media_blk_ctl_domain_data,
798 .num_domains = ARRAY_SIZE(imx8mp_media_blk_ctl_domain_data),
801 static int imx8mq_vpu_power_notifier(struct notifier_block *nb,
802 unsigned long action, void *data)
804 struct imx8m_blk_ctrl *bc = container_of(nb, struct imx8m_blk_ctrl,
807 if (action != GENPD_NOTIFY_ON && action != GENPD_NOTIFY_PRE_OFF)
811 * The ADB in the VPUMIX domain has no separate reset and clock
812 * enable bits, but is ungated and reset together with the VPUs. The
813 * reset and clock enable inputs to the ADB is a logical OR of the
814 * VPU bits. In order to set the G2 fuse bits, the G2 clock must
817 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(0) | BIT(1));
818 regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(0) | BIT(1));
820 if (action == GENPD_NOTIFY_ON) {
822 * On power up we have no software backchannel to the GPC to
823 * wait for the ADB handshake to happen, so we just delay for a
824 * bit. On power down the GPC driver waits for the handshake.
828 /* set "fuse" bits to enable the VPUs */
829 regmap_set_bits(bc->regmap, 0x8, 0xffffffff);
830 regmap_set_bits(bc->regmap, 0xc, 0xffffffff);
831 regmap_set_bits(bc->regmap, 0x10, 0xffffffff);
837 static const struct imx8m_blk_ctrl_domain_data imx8mq_vpu_blk_ctl_domain_data[] = {
838 [IMX8MQ_VPUBLK_PD_G1] = {
840 .clk_names = (const char *[]){ "g1", },
846 [IMX8MQ_VPUBLK_PD_G2] = {
848 .clk_names = (const char *[]){ "g2", },
856 static const struct imx8m_blk_ctrl_data imx8mq_vpu_blk_ctl_dev_data = {
858 .power_notifier_fn = imx8mq_vpu_power_notifier,
859 .domains = imx8mq_vpu_blk_ctl_domain_data,
860 .num_domains = ARRAY_SIZE(imx8mq_vpu_blk_ctl_domain_data),
863 static const struct of_device_id imx8m_blk_ctrl_of_match[] = {
865 .compatible = "fsl,imx8mm-vpu-blk-ctrl",
866 .data = &imx8mm_vpu_blk_ctl_dev_data
868 .compatible = "fsl,imx8mm-disp-blk-ctrl",
869 .data = &imx8mm_disp_blk_ctl_dev_data
871 .compatible = "fsl,imx8mn-disp-blk-ctrl",
872 .data = &imx8mn_disp_blk_ctl_dev_data
874 .compatible = "fsl,imx8mp-media-blk-ctrl",
875 .data = &imx8mp_media_blk_ctl_dev_data
877 .compatible = "fsl,imx8mq-vpu-blk-ctrl",
878 .data = &imx8mq_vpu_blk_ctl_dev_data
880 .compatible = "fsl,imx8mp-vpu-blk-ctrl",
881 .data = &imx8mp_vpu_blk_ctl_dev_data
886 MODULE_DEVICE_TABLE(of, imx8m_blk_ctrl_of_match);
888 static struct platform_driver imx8m_blk_ctrl_driver = {
889 .probe = imx8m_blk_ctrl_probe,
890 .remove = imx8m_blk_ctrl_remove,
892 .name = "imx8m-blk-ctrl",
893 .pm = &imx8m_blk_ctrl_pm_ops,
894 .of_match_table = imx8m_blk_ctrl_of_match,
897 module_platform_driver(imx8m_blk_ctrl_driver);
898 MODULE_LICENSE("GPL");