Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/bridge: cdns-dsi: Add support for J721E wrapper

Add support for wrapper settings for DSI bridge on j721e. Also enable
DPI0

--------------- -----------------------
| -------| |------- |
| DSS | DPI2 |----->| DPI0 | DSI Wrapper |
| -------| |------- |
--------------- -----------------------

As shown above DPI2 output of DSS is connected to DPI0 input of DSI
Wrapper, DSI wrapper gives control wheather to enable/disable DPI0
input. In j721e above is the only configuration supported

Signed-off-by: Rahul T R <r-ravikumar@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230103101951.10963-6-r-ravikumar@ti.com

authored by

Rahul T R and committed by
Tomi Valkeinen
6b9748f8 6184e01f

+132 -1
+10
drivers/gpu/drm/bridge/cadence/Kconfig
··· 10 10 Support Cadence DPI to DSI bridge. This is an internal 11 11 bridge and is meant to be directly embedded in a SoC. 12 12 13 + if DRM_CDNS_DSI 14 + 15 + config DRM_CDNS_DSI_J721E 16 + bool "J721E Cadence DSI wrapper support" 17 + default y 18 + help 19 + Support J721E Cadence DSI wrapper. The wrapper manages 20 + the routing of the DSS DPI signal to the Cadence DSI. 21 + endif 22 + 13 23 config DRM_CDNS_MHDP8546 14 24 tristate "Cadence DPI/DP bridge" 15 25 select DRM_DISPLAY_DP_HELPER
+1
drivers/gpu/drm/bridge/cadence/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o 3 3 cdns-dsi-y := cdns-dsi-core.o 4 + cdns-dsi-$(CONFIG_DRM_CDNS_DSI_J721E) += cdns-dsi-j721e.o 4 5 obj-$(CONFIG_DRM_CDNS_MHDP8546) += cdns-mhdp8546.o 5 6 cdns-mhdp8546-y := cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o 6 7 cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) += cdns-mhdp8546-j721e.o
+34 -1
drivers/gpu/drm/bridge/cadence/cdns-dsi-core.c
··· 15 15 #include <linux/iopoll.h> 16 16 #include <linux/module.h> 17 17 #include <linux/of_address.h> 18 + #include <linux/of_device.h> 18 19 #include <linux/of_graph.h> 19 20 #include <linux/platform_device.h> 20 21 #include <linux/pm_runtime.h> ··· 24 23 #include <linux/phy/phy-mipi-dphy.h> 25 24 26 25 #include "cdns-dsi-core.h" 26 + #ifdef CONFIG_DRM_CDNS_DSI_J721E 27 + #include "cdns-dsi-j721e.h" 28 + #endif 27 29 28 30 #define IP_CONF 0x0 29 31 #define SP_HS_FIFO_DEPTH(x) (((x) & GENMASK(30, 26)) >> 26) ··· 669 665 670 666 val = readl(dsi->regs + MCTL_MAIN_EN) & ~IF_EN(input->id); 671 667 writel(val, dsi->regs + MCTL_MAIN_EN); 668 + 669 + if (dsi->platform_ops && dsi->platform_ops->disable) 670 + dsi->platform_ops->disable(dsi); 671 + 672 672 pm_runtime_put(dsi->base.dev); 673 673 } 674 674 ··· 767 759 768 760 if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0)) 769 761 return; 762 + 763 + if (dsi->platform_ops && dsi->platform_ops->enable) 764 + dsi->platform_ops->enable(dsi); 770 765 771 766 mode = &bridge->encoder->crtc->state->adjusted_mode; 772 767 nlanes = output->dev->lanes; ··· 1211 1200 goto err_disable_pclk; 1212 1201 } 1213 1202 1203 + dsi->platform_ops = of_device_get_match_data(&pdev->dev); 1204 + 1214 1205 val = readl(dsi->regs + IP_CONF); 1215 1206 dsi->direct_cmd_fifo_depth = 1 << (DIRCMD_FIFO_DEPTH(val) + 2); 1216 1207 dsi->rx_fifo_depth = RX_FIFO_DEPTH(val); ··· 1248 1235 dsi->base.dev = &pdev->dev; 1249 1236 dsi->base.ops = &cdns_dsi_ops; 1250 1237 1238 + if (dsi->platform_ops && dsi->platform_ops->init) { 1239 + ret = dsi->platform_ops->init(dsi); 1240 + if (ret != 0) { 1241 + dev_err(&pdev->dev, "platform initialization failed: %d\n", 1242 + ret); 1243 + goto err_disable_runtime_pm; 1244 + } 1245 + } 1246 + 1251 1247 ret = mipi_dsi_host_register(&dsi->base); 1252 1248 if (ret) 1253 - goto err_disable_runtime_pm; 1249 + goto err_deinit_platform; 1254 1250 1255 1251 clk_disable_unprepare(dsi->dsi_p_clk); 1256 1252 1257 1253 return 0; 1254 + 1255 + err_deinit_platform: 1256 + if (dsi->platform_ops && dsi->platform_ops->deinit) 1257 + dsi->platform_ops->deinit(dsi); 1258 1258 1259 1259 err_disable_runtime_pm: 1260 1260 pm_runtime_disable(&pdev->dev); ··· 1283 1257 struct cdns_dsi *dsi = platform_get_drvdata(pdev); 1284 1258 1285 1259 mipi_dsi_host_unregister(&dsi->base); 1260 + 1261 + if (dsi->platform_ops && dsi->platform_ops->deinit) 1262 + dsi->platform_ops->deinit(dsi); 1263 + 1286 1264 pm_runtime_disable(&pdev->dev); 1287 1265 1288 1266 return 0; ··· 1294 1264 1295 1265 static const struct of_device_id cdns_dsi_of_match[] = { 1296 1266 { .compatible = "cdns,dsi" }, 1267 + #ifdef CONFIG_DRM_CDNS_DSI_J721E 1268 + { .compatible = "ti,j721e-dsi", .data = &dsi_ti_j721e_ops, }, 1269 + #endif 1297 1270 { }, 1298 1271 }; 1299 1272 MODULE_DEVICE_TABLE(of, cdns_dsi_of_match);
+20
drivers/gpu/drm/bridge/cadence/cdns-dsi-core.h
··· 45 45 struct drm_bridge bridge; 46 46 }; 47 47 48 + struct cdns_dsi; 49 + 50 + /** 51 + * struct cdns_dsi_platform_ops - CDNS DSI Platform operations 52 + * @init: Called in the CDNS DSI probe 53 + * @deinit: Called in the CDNS DSI remove 54 + * @enable: Called at the beginning of CDNS DSI bridge enable 55 + * @disable: Called at the end of CDNS DSI bridge disable 56 + */ 57 + struct cdns_dsi_platform_ops { 58 + int (*init)(struct cdns_dsi *dsi); 59 + void (*deinit)(struct cdns_dsi *dsi); 60 + void (*enable)(struct cdns_dsi *dsi); 61 + void (*disable)(struct cdns_dsi *dsi); 62 + }; 63 + 48 64 struct cdns_dsi { 49 65 struct mipi_dsi_host base; 50 66 void __iomem *regs; 67 + #ifdef CONFIG_DRM_CDNS_DSI_J721E 68 + void __iomem *j721e_regs; 69 + #endif 70 + const struct cdns_dsi_platform_ops *platform_ops; 51 71 struct cdns_dsi_input input; 52 72 struct cdns_dsi_output output; 53 73 unsigned int direct_cmd_fifo_depth;
+51
drivers/gpu/drm/bridge/cadence/cdns-dsi-j721e.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * TI j721e Cadence DSI wrapper 4 + * 5 + * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/ 6 + * Author: Rahul T R <r-ravikumar@ti.com> 7 + */ 8 + 9 + #include <linux/io.h> 10 + #include <linux/platform_device.h> 11 + 12 + #include "cdns-dsi-j721e.h" 13 + 14 + #define DSI_WRAP_REVISION 0x0 15 + #define DSI_WRAP_DPI_CONTROL 0x4 16 + #define DSI_WRAP_DSC_CONTROL 0x8 17 + #define DSI_WRAP_DPI_SECURE 0xc 18 + #define DSI_WRAP_DSI_0_ASF_STATUS 0x10 19 + 20 + #define DSI_WRAP_DPI_0_EN BIT(0) 21 + #define DSI_WRAP_DSI2_MUX_SEL BIT(4) 22 + 23 + static int cdns_dsi_j721e_init(struct cdns_dsi *dsi) 24 + { 25 + struct platform_device *pdev = to_platform_device(dsi->base.dev); 26 + 27 + dsi->j721e_regs = devm_platform_ioremap_resource(pdev, 1); 28 + return PTR_ERR_OR_ZERO(dsi->j721e_regs); 29 + } 30 + 31 + static void cdns_dsi_j721e_enable(struct cdns_dsi *dsi) 32 + { 33 + /* 34 + * Enable DPI0 as its input. DSS0 DPI2 is connected 35 + * to DSI DPI0. This is the only supported configuration on 36 + * J721E. 37 + */ 38 + writel(DSI_WRAP_DPI_0_EN, dsi->j721e_regs + DSI_WRAP_DPI_CONTROL); 39 + } 40 + 41 + static void cdns_dsi_j721e_disable(struct cdns_dsi *dsi) 42 + { 43 + /* Put everything to defaults */ 44 + writel(0, dsi->j721e_regs + DSI_WRAP_DPI_CONTROL); 45 + } 46 + 47 + const struct cdns_dsi_platform_ops dsi_ti_j721e_ops = { 48 + .init = cdns_dsi_j721e_init, 49 + .enable = cdns_dsi_j721e_enable, 50 + .disable = cdns_dsi_j721e_disable, 51 + };
+16
drivers/gpu/drm/bridge/cadence/cdns-dsi-j721e.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * TI j721e Cadence DSI wrapper 4 + * 5 + * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/ 6 + * Author: Rahul T R <r-ravikumar@ti.com> 7 + */ 8 + 9 + #ifndef __CDNS_DSI_J721E_H__ 10 + #define __CDNS_DSI_J721E_H__ 11 + 12 + #include "cdns-dsi-core.h" 13 + 14 + extern const struct cdns_dsi_platform_ops dsi_ti_j721e_ops; 15 + 16 + #endif /* !__CDNS_DSI_J721E_H__ */