@@ -119,11 +119,9 @@ static int mtk_disp_aal_probe(struct platform_device *pdev)
if (IS_ERR(priv->regs))
return dev_err_probe(dev, PTR_ERR(priv->regs), "failed to ioremap aal\n");
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
priv->data = of_device_get_match_data(dev);
platform_set_drvdata(pdev, priv);
@@ -174,11 +174,9 @@ static int mtk_disp_ccorr_probe(struct platform_device *pdev)
if (IS_ERR(priv->regs))
return dev_err_probe(dev, PTR_ERR(priv->regs), "failed to ioremap ccorr\n");
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
priv->data = of_device_get_match_data(dev);
platform_set_drvdata(pdev, priv);
@@ -112,11 +112,9 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
if (IS_ERR(priv->regs))
return dev_err_probe(dev, PTR_ERR(priv->regs), "failed to ioremap color\n");
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
priv->data = of_device_get_match_data(dev);
platform_set_drvdata(pdev, priv);
@@ -278,11 +278,9 @@ static int mtk_disp_gamma_probe(struct platform_device *pdev)
if (IS_ERR(priv->regs))
return dev_err_probe(dev, PTR_ERR(priv->regs), "failed to ioremap gamma\n");
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
priv->data = of_device_get_match_data(dev);
platform_set_drvdata(pdev, priv);
@@ -269,11 +269,9 @@ static int mtk_disp_merge_probe(struct platform_device *pdev)
return PTR_ERR(priv->reset_ctl);
}
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
priv->fifo_en = of_property_read_bool(dev->of_node,
"mediatek,merge-fifo-en");
@@ -531,11 +531,9 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
if (IS_ERR(priv->regs))
return dev_err_probe(dev, PTR_ERR(priv->regs), "failed to ioremap ovl\n");
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
priv->data = of_device_get_match_data(dev);
platform_set_drvdata(pdev, priv);
@@ -334,11 +334,9 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
if (IS_ERR(priv->regs))
return dev_err_probe(dev, PTR_ERR(priv->regs), "failed to ioremap rdma\n");
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
if (of_find_property(dev->of_node, "mediatek,rdma-fifo-size", &ret)) {
ret = of_property_read_u32(dev->of_node,
@@ -49,13 +49,11 @@ struct mtk_drm_crtc {
bool pending_planes;
bool pending_async_planes;
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
struct cmdq_client *cmdq_client;
struct cmdq_pkt *cmdq_handle;
u32 cmdq_event;
u32 cmdq_vblank_cnt;
wait_queue_head_t cb_blocking_queue;
-#endif
struct device *mmsys_dev;
struct device *dma_dev;
@@ -114,11 +112,9 @@ static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
int i;
mtk_mutex_put(mtk_crtc->mutex);
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
cmdq_pkt_destroy(mtk_crtc->cmdq_handle);
cmdq_mbox_destroy(mtk_crtc->cmdq_client);
mtk_crtc->cmdq_client = NULL;
-#endif
for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
struct mtk_ddp_comp *comp;
@@ -239,7 +235,6 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
return NULL;
}
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
{
struct cmdq_cb_data *data = mssg;
@@ -282,7 +277,6 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
mtk_crtc->cmdq_vblank_cnt = 0;
wake_up(&mtk_crtc->cb_blocking_queue);
}
-#endif
static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc)
{
@@ -501,9 +495,7 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
bool needs_vblank)
{
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
struct cmdq_pkt *cmdq_handle = mtk_crtc->cmdq_handle;
-#endif
struct drm_crtc *crtc = &mtk_crtc->base;
struct mtk_drm_private *priv = crtc->dev->dev_private;
unsigned int pending_planes = 0, pending_async_planes = 0;
@@ -539,7 +531,6 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
mtk_crtc_ddp_config(crtc, NULL);
mtk_mutex_release(mtk_crtc->mutex);
}
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (mtk_crtc->cmdq_client) {
mbox_flush(mtk_crtc->cmdq_client->chan, 2000);
cmdq_handle->cmd_buf_size = 0;
@@ -563,7 +554,6 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
mbox_send_message(mtk_crtc->cmdq_client->chan, cmdq_handle);
mbox_client_txdone(mtk_crtc->cmdq_client->chan, 0);
}
-#endif
mtk_crtc->config_updating = false;
mutex_unlock(&mtk_crtc->hw_lock);
}
@@ -574,16 +564,12 @@ static void mtk_crtc_ddp_irq(void *data)
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
struct mtk_drm_private *priv = crtc->dev->dev_private;
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (!priv->data->shadow_register && !mtk_crtc->cmdq_client)
mtk_crtc_ddp_config(crtc, NULL);
else if (mtk_crtc->cmdq_vblank_cnt > 0 && --mtk_crtc->cmdq_vblank_cnt == 0)
DRM_ERROR("mtk_crtc %d CMDQ execute command timeout!\n",
drm_crtc_index(&mtk_crtc->base));
-#else
- if (!priv->data->shadow_register)
- mtk_crtc_ddp_config(crtc, NULL);
-#endif
+
mtk_drm_finish_page_flip(mtk_crtc);
}
@@ -676,13 +662,13 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
mtk_crtc->pending_planes = true;
mtk_drm_crtc_update_config(mtk_crtc, false);
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
+
/* Wait for planes to be disabled by cmdq */
if (mtk_crtc->cmdq_client)
wait_event_timeout(mtk_crtc->cb_blocking_queue,
mtk_crtc->cmdq_vblank_cnt == 0,
msecs_to_jiffies(500));
-#endif
+
/* Wait for planes to be disabled */
drm_crtc_wait_one_vblank(crtc);
@@ -956,7 +942,6 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, has_ctm, gamma_lut_size);
mutex_init(&mtk_crtc->hw_lock);
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
i = priv->mbox_index++;
mtk_crtc->cmdq_client = cmdq_mbox_create(mtk_crtc->mmsys_dev, i);
@@ -994,6 +979,5 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
/* for sending blocking cmd in crtc disable */
init_waitqueue_head(&mtk_crtc->cb_blocking_queue);
}
-#endif
return 0;
}
@@ -70,12 +70,10 @@ void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
unsigned int offset)
{
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (cmdq_pkt)
cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
cmdq_reg->offset + offset, value);
else
-#endif
writel(value, regs + offset);
}
@@ -83,12 +81,10 @@ void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value,
struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
unsigned int offset)
{
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (cmdq_pkt)
cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
cmdq_reg->offset + offset, value);
else
-#endif
writel_relaxed(value, regs + offset);
}
@@ -96,19 +92,15 @@ void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
unsigned int offset, unsigned int mask)
{
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (cmdq_pkt) {
cmdq_pkt_write_mask(cmdq_pkt, cmdq_reg->subsys,
cmdq_reg->offset + offset, value, mask);
} else {
-#endif
u32 tmp = readl(regs + offset);
tmp = (tmp & ~mask) | (value & mask);
writel(tmp, regs + offset);
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
}
-#endif
}
static int mtk_ddp_clk_enable(struct device *dev)
@@ -550,9 +542,7 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
struct platform_device *comp_pdev;
enum mtk_ddp_comp_type type;
struct mtk_ddp_comp_dev *priv;
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
int ret;
-#endif
if (comp_id < 0 || comp_id >= DDP_COMPONENT_DRM_ID_MAX)
return -EINVAL;
@@ -598,11 +588,9 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(comp->dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(comp->dev, "get mediatek,gce-client-reg fail!\n");
-#endif
platform_set_drvdata(comp_pdev, priv);
@@ -303,12 +303,10 @@ static int mtk_ethdr_probe(struct platform_device *pdev)
for (i = 0; i < ETHDR_ID_MAX; i++) {
priv->ethdr_comp[i].dev = dev;
priv->ethdr_comp[i].regs = of_iomap(dev->of_node, i);
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
- ret = cmdq_dev_get_client_reg(dev,
- &priv->ethdr_comp[i].cmdq_base, i);
+ ret = cmdq_dev_get_client_reg(dev, &priv->ethdr_comp[i].cmdq_base, i);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
+
dev_dbg(dev, "[DRM]regs:0x%p, node:%d\n", priv->ethdr_comp[i].regs, i);
}
@@ -293,11 +293,10 @@ static int mtk_mdp_rdma_probe(struct platform_device *pdev)
if (IS_ERR(priv->clk))
return dev_err_probe(dev, PTR_ERR(priv->clk), "failed to get rdma clk\n");
-#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
-#endif
+
platform_set_drvdata(pdev, priv);
ret = devm_pm_runtime_enable(dev);
Since this driver was migrated to use the MediaTek CMDQ helpers, it's not anymore necessary to exclude CMDQ related code with preprocessor if branches, as CMDQ is optional and the helpers are providing the necessary inline functions to manage the case in which CONFIG_MTK_CMDQ is not set. Clean up all instances of `#if IS_REACHABLE(CONFIG_MTK_CMDQ)` from all drivers in drm/mediatek. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> --- drivers/gpu/drm/mediatek/mtk_disp_aal.c | 2 -- drivers/gpu/drm/mediatek/mtk_disp_ccorr.c | 2 -- drivers/gpu/drm/mediatek/mtk_disp_color.c | 2 -- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 2 -- drivers/gpu/drm/mediatek/mtk_disp_merge.c | 2 -- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 -- drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 2 -- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 22 +++------------------ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 12 ----------- drivers/gpu/drm/mediatek/mtk_ethdr.c | 6 ++---- drivers/gpu/drm/mediatek/mtk_mdp_rdma.c | 3 +-- 11 files changed, 6 insertions(+), 51 deletions(-)