Introduce struct dc_tc_subdev_match_data which describes the differences between i.MX8QXP and i.MX95, which in this case need for configuration and address space offsets, and pass it as OF match data into the driver, so the driver can use the match data to optionally configure the TCON. This is a preparatory patch for i.MX95 addition. No functional change.
Signed-off-by: Marek Vasut <[email protected]> --- Cc: Abel Vesa <[email protected]> Cc: Conor Dooley <[email protected]> Cc: Fabio Estevam <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Liu Ying <[email protected]> Cc: Lucas Stach <[email protected]> Cc: Peng Fan <[email protected]> Cc: Pengutronix Kernel Team <[email protected]> Cc: Rob Herring <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] --- drivers/gpu/drm/imx/dc/dc-de.h | 1 + drivers/gpu/drm/imx/dc/dc-tc.c | 40 ++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/imx/dc/dc-de.h b/drivers/gpu/drm/imx/dc/dc-de.h index 797056a09ddb4..e74368aacf553 100644 --- a/drivers/gpu/drm/imx/dc/dc-de.h +++ b/drivers/gpu/drm/imx/dc/dc-de.h @@ -32,6 +32,7 @@ struct dc_fg { struct dc_tc { struct device *dev; struct regmap *reg; + bool need_config; }; struct dc_de { diff --git a/drivers/gpu/drm/imx/dc/dc-tc.c b/drivers/gpu/drm/imx/dc/dc-tc.c index f44b68c0a5e6d..1f287706e8706 100644 --- a/drivers/gpu/drm/imx/dc/dc-tc.c +++ b/drivers/gpu/drm/imx/dc/dc-tc.c @@ -7,6 +7,7 @@ #include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/regmap.h> #include "dc-drv.h" @@ -25,7 +26,12 @@ #define MAPBIT27_24 0x430 #define MAPBIT31_28 0x434 -static const struct dc_subdev_info dc_tc_info[] = { +struct dc_tc_subdev_match_data { + bool need_config; + const struct dc_subdev_info *info; +}; + +static const struct dc_subdev_info dc_tc_info_imx8qxp[] = { { .reg_start = 0x5618c800, .id = 0, }, { .reg_start = 0x5618e400, .id = 1, }, { /* sentinel */ }, @@ -61,8 +67,16 @@ static const u32 dc_tc_mapbit[] = { 0x13121110, 0x03020100, 0x07060504, 0x00000908, }; +static const struct dc_tc_subdev_match_data dc_tc_match_data_imx8qxp = { + .need_config = true, + .info = dc_tc_info_imx8qxp, +}; + void dc_tc_init(struct dc_tc *tc) { + if (!tc->need_config) + return; + /* reset TCON_CTRL to POR default so that TCON works in bypass mode */ regmap_write(tc->reg, TCON_CTRL, CTRL_RST_VAL); @@ -73,6 +87,8 @@ void dc_tc_init(struct dc_tc *tc) static int dc_tc_bind(struct device *dev, struct device *master, void *data) { + const struct dc_tc_subdev_match_data *dc_tc_match_data = device_get_match_data(dev); + const struct dc_subdev_info *dc_tc_info = dc_tc_match_data->info; struct platform_device *pdev = to_platform_device(dev); struct dc_drm_device *dc_drm = data; struct resource *res; @@ -84,13 +100,19 @@ static int dc_tc_bind(struct device *dev, struct device *master, void *data) if (!tc) return -ENOMEM; - base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(base)) - return PTR_ERR(base); - - tc->reg = devm_regmap_init_mmio(dev, base, &dc_tc_regmap_config); - if (IS_ERR(tc->reg)) - return PTR_ERR(tc->reg); + if (dc_tc_match_data->need_config) { + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(base)) + return PTR_ERR(base); + + tc->reg = devm_regmap_init_mmio(dev, base, &dc_tc_regmap_config); + if (IS_ERR(tc->reg)) + return PTR_ERR(tc->reg); + } else { + res = platform_get_resource(to_platform_device(pdev->dev.parent), IORESOURCE_MEM, 0); + if (IS_ERR(res)) + return PTR_ERR(res); + } id = dc_subdev_get_id(dc_tc_info, res); if (id < 0) { @@ -126,7 +148,7 @@ static void dc_tc_remove(struct platform_device *pdev) } static const struct of_device_id dc_tc_dt_ids[] = { - { .compatible = "fsl,imx8qxp-dc-tcon" }, + { .compatible = "fsl,imx8qxp-dc-tcon", .data = &dc_tc_match_data_imx8qxp }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, dc_tc_dt_ids); -- 2.51.0
