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 9A137C433F5 for ; Thu, 17 Mar 2022 16:31:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E7F4283C2C; Thu, 17 Mar 2022 17:31:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1647534693; bh=0FYSKHXE6zp6SBYIyHO9iOC8vXf3kyfD4ZpK4Njk07o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vW+Cc0CLawaJCIjjm2a8ETiQYsZN5n4V0pdry0PsMrUZhGIcjzHSFtUjGheWdrudf +m19KkUx7fOs7/DqOtCLcXjbBni8r0NZ1tPp5x7pYNydWkO/k1PKXUio45Rtw6hIzx qhtaUZHRJrwvlP+u3XSSfnPxxOg3dSIq3fv1a4UURbICOU3JrKJyk8ucJwMb9GIwg3 Yrw5Q0BI+GoyxHVLbOYs35EgzqdX+UwuQBnnxQFO43UwuZGNPhGBzihadnnuhfxomh LHdNIokrshO+SG68DZ8fsUxWOeTDfN1xxDd48eORYoCo2A0Blu82yUwm0pPveKEeZf YYJWm6Xco/ILA== Received: from ktm (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 9C4D483AE6; Thu, 17 Mar 2022 17:31:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1647534691; bh=0FYSKHXE6zp6SBYIyHO9iOC8vXf3kyfD4ZpK4Njk07o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=thy9zwJoCm9KuBdk8drTaLIVgqBtkcv8Le7/LNVb9K6sQwHdlxaEBjRNfuRGs3e94 4s3GvFZLtsm+b8Ql7U2jjIPeIathUV2Wk4UL/qRUOJUgpaBOilarE6XSDQ47ReTuNs 6rF7c4q70x3RSx88LzieuViGV2BVLtEvBNfXa6Tx0f1Tss9C2Qq3PVbc93on/5deLm YYXtmRUXsyLrZ4bhcPZyYIrkxSXuLAIhIC1cIyH+MdSC9bapoPUgnA7UUP1tnh6m+K L9wIPVh5j/7zGpsOmz/ZIFi4d7aXXG5HRlq13AjIGihtaXtuKs49fj+jPyeJnwBFku nv2IqLSaGUhlw== Date: Thu, 17 Mar 2022 17:31:22 +0100 From: Lukasz Majewski To: Sean Anderson Cc: Heiko Thiery , u-boot@lists.denx.de, Marek Vasut , Michale Walle , Angus Ainslie , Angus Ainslie , 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 Message-ID: <20220317173122.2e49333f@ktm> In-Reply-To: <99e5643a-ade5-655d-937f-ee6ce711a99d@gmail.com> References: <20220317124127.1783768-1-heiko.thiery@gmail.com> <99e5643a-ade5-655d-937f-ee6ce711a99d@gmail.com> Organization: denx.de X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/.sD1ayyyS.Mc0lb4McYPEpq"; protocol="application/pgp-signature" 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 --Sig_/.sD1ayyyS.Mc0lb4McYPEpq Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Sean, > Hi Heiko, >=20 > On 3/17/22 8:41 AM, 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. > >=20 > > Signed-off-by: Heiko Thiery > > --- > > drivers/serial/serial_mxc.c | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > >=20 > > 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 > > */ > > =20 > > +#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 =3D dev_get_plat(dev); > > - u32 clk =3D imx_get_uartclk(); > > + u32 rate =3D 0; > > + > > + if (IS_ENABLED(CONFIG_CLK)) { =20 >=20 > CONFIG_IS_ENABLED? >=20 > mx6ull at least does not have CONFIG_SPL_CLK enabled. The problem with serial is that not all boards support DM clock in SPL. I'm wondering if this patch has passed the CI tests for all boards. >=20 > > + struct clk clk; > > + if(!clk_get_by_name(dev, "ipg", &clk)) > > + rate =3D clk_get_rate(&clk); > > + } > > + > > + /* as fallback we try to get the clk rate that way */ > > + if (rate =3D=3D 0) =20 >=20 > !rate || IS_ERR_VALUE(rate) >=20 > > + rate =3D imx_get_uartclk(); > > =20 > > - _mxc_serial_setbrg(plat->reg, clk, baudrate, > > plat->use_dte); > > + _mxc_serial_setbrg(plat->reg, rate, baudrate, > > plat->use_dte);=20 > > return 0; > > } > > =20 > --Sean Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/.sD1ayyyS.Mc0lb4McYPEpq Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmIzYloACgkQAR8vZIA0 zr3JTgf/Qu/WHoMHhqQDWvcqpsEGgcqquGmSCxzm8/cY7ckPrmv2p4e0249SYV1C P+vpQKhKX0ivgGfBLNlzFHfBjBXhuZd6Suh3/jAbI7nXM2hVyKA8mrGTQfQrfO6v mO8uhkrTIaV9vZR0HuT8nmGlMpRcrIXEpkeZUEh5smtZjMXpPNxyNhoADaV0ald0 79pwv4MHvXgX5bncciS+vbVnJULFbJhnYe5eOMx0KNuy8Bi5RMxEa3W+3a53mpv+ MdG+F9x9xmIaB9kbJyyj1YPkVTxDpDlsG2xrMWcBKitCqG+YQRJ/uyINyNYG/NFB SpZylyaerywgoMF3r3FfyZucm6FzSg== =S1Nl -----END PGP SIGNATURE----- --Sig_/.sD1ayyyS.Mc0lb4McYPEpq--