{
int i, ret;
- if (comp->comp_dev) {
+ /* Only DMA capable components need the pm control */
+ if (comp->comp_dev && is_dma_capable(comp->type)) {
ret = pm_runtime_resume_and_get(comp->comp_dev);
if (ret < 0) {
dev_err(dev,
}
}
- for (i = 0; i < ARRAY_SIZE(comp->clks); i++) {
+ for (i = 0; i < comp->clk_num; i++) {
if (IS_ERR_OR_NULL(comp->clks[i]))
continue;
ret = clk_prepare_enable(comp->clks[i]);
continue;
clk_disable_unprepare(comp->clks[i]);
}
- if (comp->comp_dev)
+ if (comp->comp_dev && is_dma_capable(comp->type))
pm_runtime_put_sync(comp->comp_dev);
return ret;
{
int i;
- for (i = 0; i < ARRAY_SIZE(comp->clks); i++) {
+ for (i = 0; i < comp->clk_num; i++) {
if (IS_ERR_OR_NULL(comp->clks[i]))
continue;
clk_disable_unprepare(comp->clks[i]);
}
- if (comp->comp_dev)
+ if (comp->comp_dev && is_dma_capable(comp->type))
pm_runtime_put(comp->comp_dev);
}
struct mdp_comp *comp, enum mtk_mdp_comp_id id)
{
struct device *dev = &mdp->pdev->dev;
- int clk_num;
+ struct platform_device *pdev_c;
int clk_ofst;
int i;
s32 event;
return -EINVAL;
}
+ pdev_c = of_find_device_by_node(node);
+ if (!pdev_c) {
+ dev_warn(dev, "can't find platform device of node:%s\n",
+ node->name);
+ return -ENODEV;
+ }
+
+ comp->comp_dev = &pdev_c->dev;
comp->public_id = id;
comp->type = mdp->mdp_data->comp_data[id].match.type;
comp->inner_id = mdp->mdp_data->comp_data[id].match.inner_id;
comp->ops = mdp_comp_ops[comp->type];
__mdp_comp_init(mdp, node, comp);
- clk_num = mdp->mdp_data->comp_data[id].info.clk_num;
+ comp->clk_num = mdp->mdp_data->comp_data[id].info.clk_num;
+ comp->clks = devm_kzalloc(dev, sizeof(struct clk *) * comp->clk_num,
+ GFP_KERNEL);
+ if (!comp->clks)
+ return -ENOMEM;
+
clk_ofst = mdp->mdp_data->comp_data[id].info.clk_ofst;
- for (i = 0; i < clk_num; i++) {
+ for (i = 0; i < comp->clk_num; i++) {
comp->clks[i] = of_clk_get(node, i + clk_ofst);
if (IS_ERR(comp->clks[i]))
break;
if (!comp)
return;
+ if (comp->comp_dev && comp->clks) {
+ devm_kfree(&comp->mdp_dev->pdev->dev, comp->clks);
+ comp->clks = NULL;
+ }
+
if (comp->regs)
iounmap(comp->regs);
}
for (i = 0; i < ARRAY_SIZE(mdp->comp); i++) {
if (mdp->comp[i]) {
- pm_runtime_disable(mdp->comp[i]->comp_dev);
+ if (is_dma_capable(mdp->comp[i]->type))
+ pm_runtime_disable(mdp->comp[i]->comp_dev);
mdp_comp_deinit(mdp->comp[i]);
devm_kfree(mdp->comp[i]->comp_dev, mdp->comp[i]);
mdp->comp[i] = NULL;
{
struct device *dev = &mdp->pdev->dev;
struct device_node *node, *parent;
- struct platform_device *pdev;
int ret;
memset(mdp_comp_alias_id, 0, sizeof(mdp_comp_alias_id));
}
/* Only DMA capable components need the pm control */
- comp->comp_dev = NULL;
if (!is_dma_capable(comp->type))
continue;
-
- pdev = of_find_device_by_node(node);
- if (!pdev) {
- dev_warn(dev, "can't find platform device of node:%s\n",
- node->name);
- ret = -ENODEV;
- goto err_init_comps;
- }
-
- comp->comp_dev = &pdev->dev;
pm_runtime_enable(comp->comp_dev);
}