Skip to content

Commit f97a1b6

Browse files
committed
Merge tag 'mediatek-drm-next-5.15' of https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux into drm-next
Mediatek DRM Next for Linux 5.15 1. MT8133 AAL support, adjust rdma fifo threshold formula. 2. Implement mmap as GEM object function. 3. Add support for MT8167. 4. Test component initialization earlier in the function mtk_drm_crtc_create. 5. CMDQ refinement. Signed-off-by: Dave Airlie <[email protected]> From: Chun-Kuang Hu <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 2819cf0 + 9efb16c commit f97a1b6

File tree

11 files changed

+386
-123
lines changed

11 files changed

+386
-123
lines changed

Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ channel output.
77

88
Required properties:
99
- compatible: "mediatek,<chip>-dsi"
10-
- the supported chips are mt2701, mt7623, mt8173 and mt8183.
10+
- the supported chips are mt2701, mt7623, mt8167, mt8173 and mt8183.
1111
- reg: Physical base address and length of the controller's registers
1212
- interrupts: The interrupt signal from the function block.
1313
- clocks: device clocks

drivers/gpu/drm/mediatek/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3-
mediatek-drm-y := mtk_disp_ccorr.o \
3+
mediatek-drm-y := mtk_disp_aal.o \
4+
mtk_disp_ccorr.o \
45
mtk_disp_color.o \
56
mtk_disp_gamma.o \
67
mtk_disp_ovl.o \
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (c) 2021 MediaTek Inc.
4+
*/
5+
6+
#include <linux/clk.h>
7+
#include <linux/component.h>
8+
#include <linux/module.h>
9+
#include <linux/of_device.h>
10+
#include <linux/of_irq.h>
11+
#include <linux/platform_device.h>
12+
#include <linux/soc/mediatek/mtk-cmdq.h>
13+
14+
#include "mtk_disp_drv.h"
15+
#include "mtk_drm_crtc.h"
16+
#include "mtk_drm_ddp_comp.h"
17+
18+
#define DISP_AAL_EN 0x0000
19+
#define AAL_EN BIT(0)
20+
#define DISP_AAL_SIZE 0x0030
21+
22+
23+
struct mtk_disp_aal_data {
24+
bool has_gamma;
25+
};
26+
27+
/**
28+
* struct mtk_disp_aal - DISP_AAL driver structure
29+
* @ddp_comp - structure containing type enum and hardware resources
30+
* @crtc - associated crtc to report irq events to
31+
*/
32+
struct mtk_disp_aal {
33+
struct clk *clk;
34+
void __iomem *regs;
35+
struct cmdq_client_reg cmdq_reg;
36+
const struct mtk_disp_aal_data *data;
37+
};
38+
39+
int mtk_aal_clk_enable(struct device *dev)
40+
{
41+
struct mtk_disp_aal *aal = dev_get_drvdata(dev);
42+
43+
return clk_prepare_enable(aal->clk);
44+
}
45+
46+
void mtk_aal_clk_disable(struct device *dev)
47+
{
48+
struct mtk_disp_aal *aal = dev_get_drvdata(dev);
49+
50+
clk_disable_unprepare(aal->clk);
51+
}
52+
53+
void mtk_aal_config(struct device *dev, unsigned int w,
54+
unsigned int h, unsigned int vrefresh,
55+
unsigned int bpc, struct cmdq_pkt *cmdq_pkt)
56+
{
57+
struct mtk_disp_aal *aal = dev_get_drvdata(dev);
58+
59+
mtk_ddp_write(cmdq_pkt, w << 16 | h, &aal->cmdq_reg, aal->regs, DISP_AAL_SIZE);
60+
}
61+
62+
void mtk_aal_gamma_set(struct device *dev, struct drm_crtc_state *state)
63+
{
64+
struct mtk_disp_aal *aal = dev_get_drvdata(dev);
65+
66+
if (aal->data && aal->data->has_gamma)
67+
mtk_gamma_set_common(aal->regs, state);
68+
}
69+
70+
void mtk_aal_start(struct device *dev)
71+
{
72+
struct mtk_disp_aal *aal = dev_get_drvdata(dev);
73+
74+
writel(AAL_EN, aal->regs + DISP_AAL_EN);
75+
}
76+
77+
void mtk_aal_stop(struct device *dev)
78+
{
79+
struct mtk_disp_aal *aal = dev_get_drvdata(dev);
80+
81+
writel_relaxed(0x0, aal->regs + DISP_AAL_EN);
82+
}
83+
84+
static int mtk_disp_aal_bind(struct device *dev, struct device *master,
85+
void *data)
86+
{
87+
return 0;
88+
}
89+
90+
static void mtk_disp_aal_unbind(struct device *dev, struct device *master,
91+
void *data)
92+
{
93+
}
94+
95+
static const struct component_ops mtk_disp_aal_component_ops = {
96+
.bind = mtk_disp_aal_bind,
97+
.unbind = mtk_disp_aal_unbind,
98+
};
99+
100+
static int mtk_disp_aal_probe(struct platform_device *pdev)
101+
{
102+
struct device *dev = &pdev->dev;
103+
struct mtk_disp_aal *priv;
104+
struct resource *res;
105+
int ret;
106+
107+
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
108+
if (!priv)
109+
return -ENOMEM;
110+
111+
priv->clk = devm_clk_get(dev, NULL);
112+
if (IS_ERR(priv->clk)) {
113+
dev_err(dev, "failed to get aal clk\n");
114+
return PTR_ERR(priv->clk);
115+
}
116+
117+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
118+
priv->regs = devm_ioremap_resource(dev, res);
119+
if (IS_ERR(priv->regs)) {
120+
dev_err(dev, "failed to ioremap aal\n");
121+
return PTR_ERR(priv->regs);
122+
}
123+
124+
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
125+
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
126+
if (ret)
127+
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
128+
#endif
129+
130+
priv->data = of_device_get_match_data(dev);
131+
platform_set_drvdata(pdev, priv);
132+
133+
ret = component_add(dev, &mtk_disp_aal_component_ops);
134+
if (ret)
135+
dev_err(dev, "Failed to add component: %d\n", ret);
136+
137+
return ret;
138+
}
139+
140+
static int mtk_disp_aal_remove(struct platform_device *pdev)
141+
{
142+
component_del(&pdev->dev, &mtk_disp_aal_component_ops);
143+
144+
return 0;
145+
}
146+
147+
static const struct mtk_disp_aal_data mt8173_aal_driver_data = {
148+
.has_gamma = true,
149+
};
150+
151+
static const struct of_device_id mtk_disp_aal_driver_dt_match[] = {
152+
{ .compatible = "mediatek,mt8173-disp-aal",
153+
.data = &mt8173_aal_driver_data},
154+
{ .compatible = "mediatek,mt8183-disp-aal"},
155+
{},
156+
};
157+
MODULE_DEVICE_TABLE(of, mtk_disp_aal_driver_dt_match);
158+
159+
struct platform_driver mtk_disp_aal_driver = {
160+
.probe = mtk_disp_aal_probe,
161+
.remove = mtk_disp_aal_remove,
162+
.driver = {
163+
.name = "mediatek-disp-aal",
164+
.owner = THIS_MODULE,
165+
.of_match_table = mtk_disp_aal_driver_dt_match,
166+
},
167+
};

drivers/gpu/drm/mediatek/mtk_disp_drv.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
#include <linux/soc/mediatek/mtk-cmdq.h>
1010
#include "mtk_drm_plane.h"
1111

12+
int mtk_aal_clk_enable(struct device *dev);
13+
void mtk_aal_clk_disable(struct device *dev);
14+
void mtk_aal_config(struct device *dev, unsigned int w,
15+
unsigned int h, unsigned int vrefresh,
16+
unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
17+
void mtk_aal_gamma_set(struct device *dev, struct drm_crtc_state *state);
18+
void mtk_aal_start(struct device *dev);
19+
void mtk_aal_stop(struct device *dev);
20+
1221
void mtk_ccorr_ctm_set(struct device *dev, struct drm_crtc_state *state);
1322
int mtk_ccorr_clk_enable(struct device *dev);
1423
void mtk_ccorr_clk_disable(struct device *dev);

drivers/gpu/drm/mediatek/mtk_disp_rdma.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ void mtk_rdma_config(struct device *dev, unsigned int width,
162162
/*
163163
* Enable FIFO underflow since DSI and DPI can't be blocked.
164164
* Keep the FIFO pseudo size reset default of 8 KiB. Set the
165-
* output threshold to 6 microseconds with 7/6 overhead to
166-
* account for blanking, and with a pixel depth of 4 bytes:
165+
* output threshold to 70% of max fifo size to make sure the
166+
* threhold will not overflow
167167
*/
168-
threshold = width * height * vrefresh * 4 * 7 / 1000000;
168+
threshold = rdma_fifo_size * 7 / 10;
169169
reg = RDMA_FIFO_UNDERFLOW_EN |
170170
RDMA_FIFO_PSEUDO_SIZE(rdma_fifo_size) |
171171
RDMA_OUTPUT_VALID_FIFO_THRESHOLD(threshold);

0 commit comments

Comments
 (0)