From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 05D3FC433EF for ; Thu, 17 Mar 2022 13:19:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A3C7883CD9; Thu, 17 Mar 2022 14:19:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=akkea.ca header.i=@akkea.ca header.b="gXPrKbme"; dkim=pass (1024-bit key) header.d=akkea.ca header.i=@akkea.ca header.b="XiQqR5Pl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17F5F83CD9; Thu, 17 Mar 2022 14:19:19 +0100 (CET) Received: from node.akkea.ca (li1434-30.members.linode.com [45.33.107.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DFF3883C04 for ; Thu, 17 Mar 2022 14:19:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angus@akkea.ca Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id D34344E2006; Thu, 17 Mar 2022 13:19:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1647523152; bh=5mGPKIRYngelSVdUl8W62DltEDl7XOC7CaDntMBAJ8k=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=gXPrKbmeavpsGTzEYcurruf5TTplHIsZ9q9JoEE2Qxp+Jl9gcLQfLsYglxfDDqXrg Wri7kv/1o30nmY+VPDE6K7Tx7/oFtW1icIyG3VsNdnv/6AUgEJdgWZ3xmIX2DqhCLz 2oYb45TGrE7wj5UEO4clQrbJFGqQt+IZkEmmSe3k= Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XEOED2fsctcM; Thu, 17 Mar 2022 13:19:10 +0000 (UTC) Received: from www.akkea.ca (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id EB2D04E2003; Thu, 17 Mar 2022 13:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1647523150; bh=5mGPKIRYngelSVdUl8W62DltEDl7XOC7CaDntMBAJ8k=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=XiQqR5Pln4y3WaiGAZcvTgNlk1RuFjTzpfPf3AJONUY/CP4GHIDM5kA+K0/xZ+k4t rV+E05FQXMJrC8L4NRONJvJ/fVYMLLm47brrt6OPEpRY22vLmIXULxnwoacvd1rCI4 IKbrm9aHjAMk2hJhonQeH1nA1Opk7Ltzf2OiHVg8= MIME-Version: 1.0 Date: Thu, 17 Mar 2022 06:19:09 -0700 From: Angus Ainslie To: Heiko Thiery Cc: u-boot@lists.denx.de, Marek Vasut , Michale Walle , Angus Ainslie , lukma@denx.de, seanga2@gmail.com, sbabic@denx.de, festevam@gmail.com, uboot-imx@nxp.com, peng.fan@nxp.com Subject: Re: [RFC] serial: mxc: get the clock frequency from the used clock for the device In-Reply-To: <20220317124127.1783768-1-heiko.thiery@gmail.com> References: <20220317124127.1783768-1-heiko.thiery@gmail.com> Message-ID: <775d1b35685c64474efa90ae281726d5@akkea.ca> X-Sender: angus@akkea.ca User-Agent: Roundcube Webmail/1.3.17 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean Hi Heiko, On 2022-03-17 05:41, Heiko Thiery wrote: > With the clock driver enabled for the imx8mq, it was noticed that the > frequency used to calculate the baud rate is always taken from the root > clock of UART1. This can cause problems if UART1 is not used as console > and the settings are different from UART1. The result is that the > console > output is garbage. To do this correctly the UART frequency is taken > from > the used device. For the implementations that don't have the igp clock > frequency written or can't return it the old way is tried. > > Signed-off-by: Heiko Thiery > --- > drivers/serial/serial_mxc.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c > index e4970a169b..6fdb2b2397 100644 > --- a/drivers/serial/serial_mxc.c > +++ b/drivers/serial/serial_mxc.c > @@ -3,6 +3,7 @@ > * (c) 2007 Sascha Hauer > */ > > +#include > #include > #include > #include > @@ -266,9 +267,19 @@ __weak struct serial_device > *default_serial_console(void) > int mxc_serial_setbrg(struct udevice *dev, int baudrate) > { > struct mxc_serial_plat *plat = dev_get_plat(dev); > - u32 clk = imx_get_uartclk(); > + u32 rate = 0; > + > + if (IS_ENABLED(CONFIG_CLK)) { > + struct clk clk; > + if(!clk_get_by_name(dev, "ipg", &clk)) > + rate = clk_get_rate(&clk); Is the "ipg" clock the correct name for all of the imx DM boards ? > + } > + > + /* as fallback we try to get the clk rate that way */ > + if (rate == 0) > + rate = imx_get_uartclk(); Would it be better to re-write imx_get_uartclk so that both the getting and setting of clocks was correct ? With DM clocks enabled I don't even think it makes sense to call those older functions. Angus > > - _mxc_serial_setbrg(plat->reg, clk, baudrate, plat->use_dte); > + _mxc_serial_setbrg(plat->reg, rate, baudrate, plat->use_dte); > > return 0; > }