All of lore.kernel.org
 help / color / mirror / Atom feed
From: Giulio Benetti <giulio.benetti@benettiengineering.com>
To: u-boot@lists.denx.de
Subject: [PATCH 06/18] video: mxsfb: add support for DM CLK
Date: Wed, 26 Feb 2020 18:15:49 +0100	[thread overview]
Message-ID: <20200226171601.31142-7-giulio.benetti@benettiengineering.com> (raw)
In-Reply-To: <20200226171601.31142-1-giulio.benetti@benettiengineering.com>

Allow using DM CLK instead of mxs_set_lcdclk() so we can avoid to
implement a special function to set lcd clock on i.MXRT.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 drivers/video/mxsfb.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 585af3d571..f21f8247d9 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2011-2013 Marek Vasut <marex@denx.de>
  */
 #include <common.h>
+#include <clk.h>
 #include <dm.h>
 #include <env.h>
 #include <dm/device_compat.h>
@@ -52,14 +53,32 @@ __weak void mxsfb_system_setup(void)
  * 	 le:89,ri:164,up:23,lo:10,hs:10,vs:10,sync:0,vmode:0
  */
 
-static void mxs_lcd_init(u32 fb_addr, struct ctfb_res_modes *mode, int bpp)
+static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
+			 struct ctfb_res_modes *mode, int bpp)
 {
 	struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
 	uint32_t word_len = 0, bus_width = 0;
 	uint8_t valid_data = 0;
 
+#if CONFIG_IS_ENABLED(CLK)
+	struct clk per_clk;
+	int ret;
+
+	ret = clk_get_by_name(dev, "per", &per_clk);
+	if (ret) {
+		dev_err(dev, "Failed to get mxs clk: %d\n", ret);
+		return;
+	}
+
+	ret = clk_set_rate(&per_clk, PS2KHZ(mode->pixclock) * 1000);
+	if (ret < 0) {
+		dev_err(dev, "Failed to set mxs clk: %d\n", ret);
+		return;
+	}
+#else
 	/* Kick in the LCDIF clock */
 	mxs_set_lcdclk(MXS_LCDIF_BASE, PS2KHZ(mode->pixclock));
+#endif
 
 	/* Restart the LCDIF block */
 	mxs_reset_block(&regs->hw_lcdif_ctrl_reg);
@@ -135,10 +154,11 @@ static void mxs_lcd_init(u32 fb_addr, struct ctfb_res_modes *mode, int bpp)
 	writel(LCDIF_CTRL_RUN, &regs->hw_lcdif_ctrl_set);
 }
 
-static int mxs_probe_common(struct ctfb_res_modes *mode, int bpp, u32 fb)
+static int mxs_probe_common(struct udevice *dev, struct ctfb_res_modes *mode,
+			    int bpp, u32 fb)
 {
 	/* Start framebuffer */
-	mxs_lcd_init(fb, mode, bpp);
+	mxs_lcd_init(dev, fb, mode, bpp);
 
 #ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM
 	/*
@@ -260,7 +280,7 @@ void *video_hw_init(void)
 
 	printf("%s\n", panel.modeIdent);
 
-	ret = mxs_probe_common(&mode, bpp, (u32)fb);
+	ret = mxs_probe_common(NULL, &mode, bpp, (u32)fb);
 	if (ret)
 		goto dealloc_fb;
 
@@ -337,7 +357,7 @@ static int mxs_video_probe(struct udevice *dev)
 	mode.vsync_len = timings.vsync_len.typ;
 	mode.pixclock = HZ2PS(timings.pixelclock.typ);
 
-	ret = mxs_probe_common(&mode, bpp, plat->base);
+	ret = mxs_probe_common(dev, &mode, bpp, plat->base);
 	if (ret)
 		return ret;
 
-- 
2.20.1

  parent reply	other threads:[~2020-02-26 17:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 17:15 [PATCH 00/18] i.MXRT1050 add LCDIF support Giulio Benetti
2020-02-26 17:15 ` [PATCH 01/18] clk: imx: pllv3: add enable_bit Giulio Benetti
2020-03-08 20:27   ` Lukasz Majewski
2020-02-26 17:15 ` [PATCH 02/18] clk: imx: imxrt1050-clk: fix typo in clock name "video:" Giulio Benetti
2020-03-08 20:27   ` Lukasz Majewski
2020-02-26 17:15 ` [PATCH 03/18] clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL Giulio Benetti
2020-02-26 17:37   ` Fabio Estevam
2020-02-26 17:54     ` Giulio Benetti
2020-02-26 17:59       ` Fabio Estevam
2020-02-26 18:16         ` Giulio Benetti
2020-02-27 18:31           ` Fabio Estevam
2020-03-08 20:27   ` Lukasz Majewski
2020-03-08 21:05     ` Giulio Benetti
2020-03-09  9:11       ` Lukasz Majewski
2020-03-22 18:25         ` Giulio Benetti
2020-02-26 17:15 ` [PATCH 04/18] videomodes: add helper function to convert from ctfb to display_timing Giulio Benetti
2020-02-26 17:15 ` [PATCH 05/18] sunxi: display: use common video_ctfb_mode_to_display_timing() Giulio Benetti
2020-02-26 17:15 ` Giulio Benetti [this message]
2020-02-26 17:15 ` [PATCH 07/18] video: mxsfb: add support for i.MXRT Giulio Benetti
2020-02-26 17:15 ` [PATCH 08/18] video: mxsfb: refactor for using display_timings Giulio Benetti
2020-02-26 17:15 ` [PATCH 09/18] video: mxsfb: enable setting HSYNC negative polarity Giulio Benetti
2020-02-26 17:15 ` [PATCH 10/18] video: mxsfb: enable setting VSYNC " Giulio Benetti
2020-02-26 17:15 ` [PATCH 11/18] video: mxsfb: enable setting PIXDATA on negative edge Giulio Benetti
2020-02-26 17:15 ` [PATCH 12/18] video: mxsfb: enable setting ENABLE negative polarity Giulio Benetti
2020-02-26 17:15 ` [PATCH 13/18] imxrt1050_evk: add 16bpp video support if video layer enabled Giulio Benetti
2020-02-26 17:15 ` [PATCH 14/18] ARM: dts: i.mxrt1050: add lcdif node Giulio Benetti
2020-02-26 17:15 ` [PATCH 15/18] ARM: dts: imxrt1050: allow this dtsi file to be compiled in Linux Giulio Benetti
2020-02-26 17:39 ` [PATCH 00/18] i.MXRT1050 add LCDIF support Giulio Benetti
2020-03-22 18:27 ` Giulio Benetti

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=20200226171601.31142-7-giulio.benetti@benettiengineering.com \
    --to=giulio.benetti@benettiengineering.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.