1 From 06e912bd821b21d9360a75cde2d78b03f17a5872 Mon Sep 17 00:00:00 2001
2 From: Wen He <wen.he_1@nxp.com>
3 Date: Tue, 17 Sep 2019 15:35:52 +0800
4 Subject: [PATCH] drm: ls1028a: Add DP driver support for LS1028A
6 Add Display Port driver support for NXP Layerscape LS1028A platform.
8 Signed-off-by: Wen He <wen.he_1@nxp.com>
10 drivers/gpu/drm/bridge/cadence/cdns-dp-core.c | 1 +
11 drivers/gpu/drm/imx/Makefile | 2 +-
12 drivers/gpu/drm/imx/cdn-mhdp-imxdrv.c | 13 +++
13 drivers/gpu/drm/imx/cdn-mhdp-ls1028a.c | 110 ++++++++++++++++++++++++++
14 drivers/gpu/drm/imx/cdns-mhdp-imx.h | 2 +
15 5 files changed, 127 insertions(+), 1 deletion(-)
16 create mode 100644 drivers/gpu/drm/imx/cdn-mhdp-ls1028a.c
18 --- a/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
19 +++ b/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c
20 @@ -275,6 +275,7 @@ static int cdns_dp_bridge_attach(struct
21 struct drm_connector *connector = &mhdp->connector.base;
23 connector->interlace_allowed = 1;
25 connector->polled = DRM_CONNECTOR_POLL_HPD;
27 drm_connector_helper_add(connector, &cdns_dp_connector_helper_funcs);
28 --- a/drivers/gpu/drm/imx/Makefile
29 +++ b/drivers/gpu/drm/imx/Makefile
30 @@ -9,4 +9,4 @@ obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o
31 obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
33 obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o
34 -obj-$(CONFIG_DRM_IMX_CDNS_MHDP) += cdn-mhdp-imxdrv.o cdn-mhdp-dp-phy.o cdn-mhdp-hdmi-phy.o cdn-mhdp-imx8qm.o
35 +obj-$(CONFIG_DRM_IMX_CDNS_MHDP) += cdn-mhdp-imxdrv.o cdn-mhdp-dp-phy.o cdn-mhdp-hdmi-phy.o cdn-mhdp-imx8qm.o cdn-mhdp-ls1028a.o
36 --- a/drivers/gpu/drm/imx/cdn-mhdp-imxdrv.c
37 +++ b/drivers/gpu/drm/imx/cdn-mhdp-imxdrv.c
38 @@ -94,6 +94,16 @@ static struct cdns_plat_data imx8qm_dp_d
42 +static struct cdns_plat_data ls1028a_dp_drv_data = {
43 + .bind = cdns_dp_bind,
44 + .unbind = cdns_dp_unbind,
45 + .phy_set = cdns_dp_phy_set_imx8mq,
46 + .power_on = cdns_mhdp_power_on_ls1028a,
47 + .firmware_init = cdns_mhdp_firmware_init_imx8qm,
48 + .pclk_rate = cdns_mhdp_pclk_rate_ls1028a,
49 + .bus_type = BUS_TYPE_NORMAL_APB,
52 static const struct of_device_id cdns_mhdp_imx_dt_ids[] = {
53 { .compatible = "cdn,imx8mq-hdmi",
54 .data = &imx8mq_hdmi_drv_data
55 @@ -107,6 +117,9 @@ static const struct of_device_id cdns_mh
56 { .compatible = "cdn,imx8qm-dp",
57 .data = &imx8qm_dp_drv_data
59 + { .compatible = "cdn,ls1028a-dp",
60 + .data = &ls1028a_dp_drv_data
64 MODULE_DEVICE_TABLE(of, cdns_mhdp_imx_dt_ids);
66 +++ b/drivers/gpu/drm/imx/cdn-mhdp-ls1028a.c
68 +// SPDX-License-Identifier: GPL-2.0
70 + * Copyright 2019 NXP
73 +#include <linux/clk.h>
74 +#include <drm/drmP.h>
75 +#include <linux/of.h>
76 +#include <linux/of_address.h>
77 +#include <linux/of_device.h>
79 +#include "cdns-mhdp-imx.h"
81 +static const struct of_device_id scfg_device_ids[] = {
82 + { .compatible = "fsl,ls1028a-scfg", },
86 +static void ls1028a_phy_reset(u8 reset)
88 + struct device_node *scfg_node;
89 + void __iomem *scfg_base = NULL;
91 + scfg_node = of_find_matching_node(NULL, scfg_device_ids);
93 + scfg_base = of_iomap(scfg_node, 0);
95 + iowrite32(reset, scfg_base + 0x230);
98 +int ls1028a_clocks_init(struct imx_mhdp_device *imx_mhdp)
100 + struct device *dev = imx_mhdp->mhdp.dev;
101 + struct imx_hdp_clks *clks = &imx_mhdp->clks;
103 + clks->clk_core = devm_clk_get(dev, "clk_core");
104 + if (IS_ERR(clks->clk_core)) {
105 + dev_warn(dev, "failed to get hdp core clk\n");
106 + return PTR_ERR(clks->clk_core);
109 + clks->clk_pxl = devm_clk_get(dev, "clk_pxl");
110 + if (IS_ERR(clks->clk_pxl)) {
111 + dev_warn(dev, "failed to get pxl clk\n");
112 + return PTR_ERR(clks->clk_pxl);
118 +static int ls1028a_pixel_clk_enable(struct imx_mhdp_device *imx_mhdp)
120 + struct imx_hdp_clks *clks = &imx_mhdp->clks;
121 + struct device *dev = imx_mhdp->mhdp.dev;
124 + ret = clk_prepare_enable(clks->clk_pxl);
126 + dev_err(dev, "%s, pre clk pxl error\n", __func__);
133 +static void ls1028a_pixel_clk_disable(struct imx_mhdp_device *imx_mhdp)
135 + struct imx_hdp_clks *clks = &imx_mhdp->clks;
137 + clk_disable_unprepare(clks->clk_pxl);
140 +static void ls1028a_pixel_clk_set_rate(struct imx_mhdp_device *imx_mhdp,
143 + struct imx_hdp_clks *clks = &imx_mhdp->clks;
145 + clk_set_rate(clks->clk_pxl, pclock);
148 +int cdns_mhdp_power_on_ls1028a(struct cdns_mhdp_device *mhdp)
150 + struct imx_mhdp_device *imx_mhdp = container_of
151 + (mhdp, struct imx_mhdp_device, mhdp);
153 + /* clock init and rate set */
154 + ls1028a_clocks_init(imx_mhdp);
156 + ls1028a_pixel_clk_enable(imx_mhdp);
158 + /* Init pixel clock with 148.5MHz before FW init */
159 + ls1028a_pixel_clk_set_rate(imx_mhdp, 148500000);
161 + ls1028a_phy_reset(1);
166 +void cdns_mhdp_pclk_rate_ls1028a(struct cdns_mhdp_device *mhdp)
168 + struct imx_mhdp_device *imx_mhdp = container_of
169 + (mhdp, struct imx_mhdp_device, mhdp);
171 + /* set pixel clock before video mode setup */
172 + ls1028a_pixel_clk_disable(imx_mhdp);
174 + ls1028a_pixel_clk_set_rate(imx_mhdp, imx_mhdp->mhdp.mode.clock * 1000);
176 + ls1028a_pixel_clk_enable(imx_mhdp);
178 --- a/drivers/gpu/drm/imx/cdns-mhdp-imx.h
179 +++ b/drivers/gpu/drm/imx/cdns-mhdp-imx.h
180 @@ -78,4 +78,6 @@ void cdns_mhdp_plat_deinit_imx8qm(struct
181 void cdns_mhdp_pclk_rate_imx8qm(struct cdns_mhdp_device *mhdp);
182 int cdns_mhdp_firmware_init_imx8qm(struct cdns_mhdp_device *mhdp);
183 int cdns_mhdp_power_on_imx8qm(struct cdns_mhdp_device *mhdp);
184 +int cdns_mhdp_power_on_ls1028a(struct cdns_mhdp_device *mhdp);
185 +void cdns_mhdp_pclk_rate_ls1028a(struct cdns_mhdp_device *mhdp);
186 #endif /* CDNS_MHDP_IMX_H_ */