[PATCH] drm/exynos: fimc: Add support for S5PV210 variant

From: Jonathan Bakker
Date: Sat May 09 2020 - 13:46:24 EST


S5PV210 can be trivially supported by this driver. Only one of
its FIMC devices (#2) supports the same scaling values as Exynos4, and
it is marked by mainscaler-ext in the DTS (as it is for all of the
Exynos4 devices). It's limits are the same as that of id's 0-2 of
Exynos4 so we don't even need to change the device id check.

It has been tested with a modified libdrm's test from
https://github.com/tobiasjakobi/libdrm/tree/ippv2

Signed-off-by: Jonathan Bakker <xc-racer2@xxxxxxx>
---
drivers/gpu/drm/exynos/exynos_drm_fimc.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index 29ab8be8604c..63e1b8ccb8e9 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -89,6 +89,7 @@ struct fimc_scaler {
* @regs: memory mapped io registers.
* @lock: locking of operations.
* @clocks: fimc clocks.
+ * @num_clocks: number of fimc clocks
* @sc: scaler infomations.
* @pol: porarity of writeback.
* @id: fimc id.
@@ -107,6 +108,7 @@ struct fimc_context {
void __iomem *regs;
spinlock_t lock;
struct clk *clocks[FIMC_CLKS_MAX];
+ int num_clocks;
struct fimc_scaler sc;
int id;
int irq;
@@ -1183,7 +1185,7 @@ static int fimc_setup_clocks(struct fimc_context *ctx)
for (i = 0; i < FIMC_CLKS_MAX; i++)
ctx->clocks[i] = ERR_PTR(-EINVAL);

- for (i = 0; i < FIMC_CLKS_MAX; i++) {
+ for (i = 0; i < ctx->num_clocks; i++) {
if (i == FIMC_CLK_WB_A || i == FIMC_CLK_WB_B)
dev = fimc_dev->parent;
else
@@ -1210,6 +1212,9 @@ int exynos_drm_check_fimc_device(struct device *dev)
{
int id = of_alias_get_id(dev->of_node, "fimc");

+ if (!of_property_read_bool(dev->of_node, "samsung,mainscaler-ext"))
+ return -ENODEV;
+
if (id >= 0 && (BIT(id) & fimc_mask))
return 0;
return -ENODEV;
@@ -1277,6 +1282,11 @@ static int fimc_probe(struct platform_device *pdev)
ctx->dev = dev;
ctx->id = of_alias_get_id(dev->of_node, "fimc");

+ if (of_device_is_compatible(dev->of_node, "samsung,s5pv210-fimc"))
+ ctx->num_clocks = 2;
+ else
+ ctx->num_clocks = FIMC_CLKS_MAX;
+
/* construct formats/limits array */
num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats);
formats = devm_kcalloc(dev, num_formats, sizeof(*formats),
@@ -1409,6 +1419,7 @@ static const struct dev_pm_ops fimc_pm_ops = {
static const struct of_device_id fimc_of_match[] = {
{ .compatible = "samsung,exynos4210-fimc" },
{ .compatible = "samsung,exynos4212-fimc" },
+ { .compatible = "samsung,s5pv210-fimc" },
{ },
};
MODULE_DEVICE_TABLE(of, fimc_of_match);
--
2.20.1