Lines Matching +full:imx93 +full:- +full:media +full:- +full:blk +full:- +full:ctrl
1 // SPDX-License-Identifier: GPL-2.0
16 #include <dt-bindings/power/fsl,imx93-power.h>
103 const struct imx93_blk_ctrl_domain_data *data = domain->data; in imx93_blk_ctrl_set_qos()
104 struct imx93_blk_ctrl *bc = domain->bc; in imx93_blk_ctrl_set_qos()
109 for (i = 0; i < data->num_qos; i++) { in imx93_blk_ctrl_set_qos()
110 qos = &data->qos[i]; in imx93_blk_ctrl_set_qos()
112 mask = PRIO_MASK << qos->cfg_off; in imx93_blk_ctrl_set_qos()
113 mask |= PRIO_MASK << (qos->cfg_off + 4); in imx93_blk_ctrl_set_qos()
114 val = qos->cfg_prio << qos->cfg_off; in imx93_blk_ctrl_set_qos()
115 val |= qos->default_prio << (qos->cfg_off + 4); in imx93_blk_ctrl_set_qos()
117 regmap_write_bits(bc->regmap, qos->reg, mask, val); in imx93_blk_ctrl_set_qos()
119 dev_dbg(bc->dev, "data->qos[i].reg 0x%x 0x%x\n", qos->reg, val); in imx93_blk_ctrl_set_qos()
128 const struct imx93_blk_ctrl_domain_data *data = domain->data; in imx93_blk_ctrl_power_on()
129 struct imx93_blk_ctrl *bc = domain->bc; in imx93_blk_ctrl_power_on()
132 ret = clk_bulk_prepare_enable(bc->num_clks, bc->clks); in imx93_blk_ctrl_power_on()
134 dev_err(bc->dev, "failed to enable bus clocks\n"); in imx93_blk_ctrl_power_on()
138 ret = clk_bulk_prepare_enable(data->num_clks, domain->clks); in imx93_blk_ctrl_power_on()
140 clk_bulk_disable_unprepare(bc->num_clks, bc->clks); in imx93_blk_ctrl_power_on()
141 dev_err(bc->dev, "failed to enable clocks\n"); in imx93_blk_ctrl_power_on()
145 ret = pm_runtime_get_sync(bc->dev); in imx93_blk_ctrl_power_on()
147 pm_runtime_put_noidle(bc->dev); in imx93_blk_ctrl_power_on()
148 dev_err(bc->dev, "failed to power up domain\n"); in imx93_blk_ctrl_power_on()
153 regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask); in imx93_blk_ctrl_power_on()
156 regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx93_blk_ctrl_power_on()
158 dev_dbg(bc->dev, "pd_on: name: %s\n", genpd->name); in imx93_blk_ctrl_power_on()
163 clk_bulk_disable_unprepare(data->num_clks, domain->clks); in imx93_blk_ctrl_power_on()
165 clk_bulk_disable_unprepare(bc->num_clks, bc->clks); in imx93_blk_ctrl_power_on()
173 const struct imx93_blk_ctrl_domain_data *data = domain->data; in imx93_blk_ctrl_power_off()
174 struct imx93_blk_ctrl *bc = domain->bc; in imx93_blk_ctrl_power_off()
176 dev_dbg(bc->dev, "pd_off: name: %s\n", genpd->name); in imx93_blk_ctrl_power_off()
178 regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask); in imx93_blk_ctrl_power_off()
179 regmap_set_bits(bc->regmap, BLK_CLK_EN, data->clk_mask); in imx93_blk_ctrl_power_off()
181 pm_runtime_put(bc->dev); in imx93_blk_ctrl_power_off()
183 clk_bulk_disable_unprepare(data->num_clks, domain->clks); in imx93_blk_ctrl_power_off()
185 clk_bulk_disable_unprepare(bc->num_clks, bc->clks); in imx93_blk_ctrl_power_off()
194 struct device *dev = &pdev->dev; in imx93_blk_ctrl_probe()
204 .rd_table = bc_data->reg_access_table, in imx93_blk_ctrl_probe()
205 .wr_table = bc_data->reg_access_table, in imx93_blk_ctrl_probe()
211 return -ENOMEM; in imx93_blk_ctrl_probe()
213 bc->dev = dev; in imx93_blk_ctrl_probe()
219 bc->regmap = devm_regmap_init_mmio(dev, base, ®map_config); in imx93_blk_ctrl_probe()
220 if (IS_ERR(bc->regmap)) in imx93_blk_ctrl_probe()
221 return dev_err_probe(dev, PTR_ERR(bc->regmap), in imx93_blk_ctrl_probe()
224 bc->domains = devm_kcalloc(dev, bc_data->num_domains, in imx93_blk_ctrl_probe()
227 if (!bc->domains) in imx93_blk_ctrl_probe()
228 return -ENOMEM; in imx93_blk_ctrl_probe()
230 bc->onecell_data.num_domains = bc_data->num_domains; in imx93_blk_ctrl_probe()
231 bc->onecell_data.domains = in imx93_blk_ctrl_probe()
232 devm_kcalloc(dev, bc_data->num_domains, in imx93_blk_ctrl_probe()
234 if (!bc->onecell_data.domains) in imx93_blk_ctrl_probe()
235 return -ENOMEM; in imx93_blk_ctrl_probe()
237 for (i = 0; i < bc_data->num_clks; i++) in imx93_blk_ctrl_probe()
238 bc->clks[i].id = bc_data->clk_names[i]; in imx93_blk_ctrl_probe()
239 bc->num_clks = bc_data->num_clks; in imx93_blk_ctrl_probe()
241 ret = devm_clk_bulk_get(dev, bc->num_clks, bc->clks); in imx93_blk_ctrl_probe()
247 for (i = 0; i < bc_data->num_domains; i++) { in imx93_blk_ctrl_probe()
248 const struct imx93_blk_ctrl_domain_data *data = &bc_data->domains[i]; in imx93_blk_ctrl_probe()
249 struct imx93_blk_ctrl_domain *domain = &bc->domains[i]; in imx93_blk_ctrl_probe()
252 domain->data = data; in imx93_blk_ctrl_probe()
254 for (j = 0; j < data->num_clks; j++) in imx93_blk_ctrl_probe()
255 domain->clks[j].id = data->clk_names[j]; in imx93_blk_ctrl_probe()
257 ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks); in imx93_blk_ctrl_probe()
263 domain->genpd.name = data->name; in imx93_blk_ctrl_probe()
264 domain->genpd.power_on = imx93_blk_ctrl_power_on; in imx93_blk_ctrl_probe()
265 domain->genpd.power_off = imx93_blk_ctrl_power_off; in imx93_blk_ctrl_probe()
266 domain->bc = bc; in imx93_blk_ctrl_probe()
268 ret = pm_genpd_init(&domain->genpd, NULL, true); in imx93_blk_ctrl_probe()
282 * self-deadlock. in imx93_blk_ctrl_probe()
284 lockdep_set_class(&domain->genpd.mlock, in imx93_blk_ctrl_probe()
287 bc->onecell_data.domains[i] = &domain->genpd; in imx93_blk_ctrl_probe()
292 ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data); in imx93_blk_ctrl_probe()
303 for (i--; i >= 0; i--) in imx93_blk_ctrl_probe()
304 pm_genpd_remove(&bc->domains[i].genpd); in imx93_blk_ctrl_probe()
311 struct imx93_blk_ctrl *bc = dev_get_drvdata(&pdev->dev); in imx93_blk_ctrl_remove()
314 of_genpd_del_provider(pdev->dev.of_node); in imx93_blk_ctrl_remove()
316 pm_runtime_disable(&pdev->dev); in imx93_blk_ctrl_remove()
318 for (i = 0; i < bc->onecell_data.num_domains; i++) { in imx93_blk_ctrl_remove()
319 struct imx93_blk_ctrl_domain *domain = &bc->domains[i]; in imx93_blk_ctrl_remove()
321 pm_genpd_remove(&domain->genpd); in imx93_blk_ctrl_remove()
327 .name = "mediablk-mipi-dsi",
334 .name = "mediablk-mipi-csi",
341 .name = "mediablk-pxp",
362 .name = "mediablk-lcdif",
378 .name = "mediablk-isi",
431 .compatible = "fsl,imx93-media-blk-ctrl",
443 .name = "imx93-blk-ctrl",
450 MODULE_DESCRIPTION("i.MX93 BLK CTRL driver");