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 };
52