From patchwork Wed Feb 26 17:15:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giulio Benetti X-Patchwork-Id: 1245204 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aruba.it header.i=@aruba.it header.a=rsa-sha256 header.s=a1 header.b=DGRo9gXM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48SMtg0Q2yz9sP7 for ; Thu, 27 Feb 2020 04:17:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2D81980561; Wed, 26 Feb 2020 18:16:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=aruba.it header.i=@aruba.it header.b="DGRo9gXM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D3DE080D3F; Wed, 26 Feb 2020 18:16:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, URIBL_BLOCKED, URIBL_RHS_DOB autolearn=no autolearn_force=no version=3.4.2 Received: from smtpcmd11116.aruba.it (smtpcmd11116.aruba.it [62.149.156.116]) by phobos.denx.de (Postfix) with ESMTP id 72F2380396 for ; Wed, 26 Feb 2020 18:16:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=giulio.benetti@benettiengineering.com Received: from ubuntu.localdomain ([212.103.203.10]) by smtpcmd11.ad.aruba.it with bizsmtp id 7VG12203j0DySFo01VG4iy; Wed, 26 Feb 2020 18:16:04 +0100 From: Giulio Benetti To: u-boot@lists.denx.de Cc: Stefano Babic , Lukasz Majewski , Fabio Estevam , uboot-imx@nxp.com, Anatolij Gustschin , Simon Glass , Daniel Schwierzeck , Giulio Benetti Subject: [PATCH 06/18] video: mxsfb: add support for DM CLK Date: Wed, 26 Feb 2020 18:15:49 +0100 Message-Id: <20200226171601.31142-7-giulio.benetti@benettiengineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200226171601.31142-1-giulio.benetti@benettiengineering.com> References: <20200226171601.31142-1-giulio.benetti@benettiengineering.com> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aruba.it; s=a1; t=1582737364; bh=EYbr9qIvRYJ3JN5B4PG1v15Yuj77/dd9uk3IhBjOYfs=; h=From:To:Subject:Date:MIME-Version; b=DGRo9gXMUve6BS3+AYtZoLPh88AaWYKGjNoYxJymXyY0woggFVKaXXD823TwaPQRu blH27axv8OFBvdkZc2rg7/rHxR2FR8f1A+SOVqfeO63PK0mHMyYXGuG1CvJE/qdmxT NCM4MFoXtbp/RAnb366eDUYGrbWL4GY3DgvERXdt5DTFEcbtUDjqjIWhKC8dK8df6H grnvBVZRiBkttUO/gO3iUQfPIGl9YFyFLG7lrX1er2WTQ/k5dLfQv/3o6AjVNQ8i34 pDBnVzMpTcc9/QaEL+0GdxWdEE10E0jSdao8cVfyc6wyxztH5bdkhdoMB2hQa0bAXU kenBk0guCBeLQ== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean 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 --- 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 */ #include +#include #include #include #include @@ -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(®s->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, ®s->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;