From: <xinlei.lee@mediatek.com>
To: <chunkuang.hu@kernel.org>, <p.zabel@pengutronix.de>,
<airlied@linux.ie>, <daniel@ffwll.ch>, <matthias.bgg@gmail.com>
Cc: <dri-devel@lists.freedesktop.org>,
<linux-mediatek@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
<jitao.shi@mediatek.com>, <allen-kh.cheng@mediatek.com>,
<rex-bc.chen@mediatek.com>, Xinlei Lee <xinlei.lee@mediatek.com>
Subject: [PATCH v1,2/3] drm/mediatek: Add TOPCKGEN select mux control dpi_clk
Date: Fri, 25 Feb 2022 17:53:52 +0800 [thread overview]
Message-ID: <1645782833-27875-3-git-send-email-xinlei.lee@mediatek.com> (raw)
In-Reply-To: <1645782833-27875-1-git-send-email-xinlei.lee@mediatek.com>
From: Xinlei Lee <xinlei.lee@mediatek.com>
Dpi_clk is controlled by the mux selected
by TOPCKGEN and APMIXEDSYS can support small resolution.
Signed-off-by: Xinlei Lee <xinlei.lee@mediatek.com>
---
drivers/gpu/drm/mediatek/mtk_dpi.c | 38 ++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
index 4554e2de1430..bad686817e29 100644
--- a/drivers/gpu/drm/mediatek/mtk_dpi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -63,6 +63,14 @@ enum mtk_dpi_out_color_format {
MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL
};
+enum TVDPLL_CLK {
+ TVDPLL_PLL = 0,
+ TVDPLL_D2 = 2,
+ TVDPLL_D4 = 4,
+ TVDPLL_D8 = 8,
+ TVDPLL_D16 = 16,
+};
+
struct mtk_dpi {
struct drm_encoder encoder;
struct drm_bridge bridge;
@@ -73,6 +81,7 @@ struct mtk_dpi {
struct clk *engine_clk;
struct clk *pixel_clk;
struct clk *tvd_clk;
+ struct clk *pclk_src[5];
int irq;
struct drm_display_mode mode;
const struct mtk_dpi_conf *conf;
@@ -459,6 +468,7 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
struct videomode vm = { 0 };
unsigned long pll_rate;
unsigned int factor;
+ struct clk *clksrc = NULL;
/* let pll_rate can fix the valid range of tvdpll (1G~2GHz) */
factor = dpi->conf->cal_factor(mode->clock);
@@ -473,11 +483,26 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
vm.pixelclock = pll_rate / factor;
if ((dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_LE) ||
- (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE))
- clk_set_rate(dpi->pixel_clk, vm.pixelclock * 2);
- else
- clk_set_rate(dpi->pixel_clk, vm.pixelclock);
+ (dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE)) {
+ if (factor == 8)
+ clksrc = dpi->pclk_src[2];
+ else if (factor == 4)
+ clksrc = dpi->pclk_src[1];
+ else
+ clksrc = dpi->pclk_src[1];
+ }
+ else {
+ if (factor == 8)
+ clksrc = dpi->pclk_src[3];
+ else if (factor == 4)
+ clksrc = dpi->pclk_src[2];
+ else
+ clksrc = dpi->pclk_src[2];
+ }
+ clk_prepare_enable(dpi->pixel_clk);
+ clk_set_parent(dpi->pixel_clk, clksrc);
+ clk_disable_unprepare(dpi->pixel_clk);
vm.pixelclock = clk_get_rate(dpi->pixel_clk);
@@ -893,6 +918,11 @@ static int mtk_dpi_probe(struct platform_device *pdev)
return ret;
}
+ dpi->pclk_src[1] = devm_clk_get_optional(dev, "tvdpll_d2");
+ dpi->pclk_src[2] = devm_clk_get_optional(dev, "tvdpll_d4");
+ dpi->pclk_src[3] = devm_clk_get_optional(dev, "tvdpll_d8");
+ dpi->pclk_src[4] = devm_clk_get_optional(dev, "tvdpll_d16");
+
dpi->irq = platform_get_irq(pdev, 0);
if (dpi->irq <= 0)
return -EINVAL;
--
2.18.0
next prev parent reply other threads:[~2022-02-25 9:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-25 9:53 [PATCH v1,0/3] Add TOPCKGEN control dpi_clk and mt8186 dpi xinlei.lee
2022-02-25 9:53 ` [PATCH v1,1/3] dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8186 xinlei.lee
2022-02-25 9:53 ` xinlei.lee [this message]
2022-03-02 9:07 ` [PATCH v1,2/3] drm/mediatek: Add TOPCKGEN select mux control dpi_clk AngeloGioacchino Del Regno
2022-02-25 9:53 ` [PATCH v1,3/3] drm/mediatek: Add mt8186 dpi compatible to mtk_dpi.c xinlei.lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1645782833-27875-3-git-send-email-xinlei.lee@mediatek.com \
--to=xinlei.lee@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=airlied@linux.ie \
--cc=allen-kh.cheng@mediatek.com \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jitao.shi@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=rex-bc.chen@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®