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 104F5C433F5 for ; Fri, 18 Mar 2022 13:26:52 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 003B78363B; Fri, 18 Mar 2022 14:26:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="CtWikcEO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 99B788393B; Fri, 18 Mar 2022 14:26:49 +0100 (CET) Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4DFEB81D6A for ; Fri, 18 Mar 2022 14:26:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qv1-xf36.google.com with SMTP id kc20so2604038qvb.3 for ; Fri, 18 Mar 2022 06:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aAbw2wzfH6ZS0XnNQn2+bubcisfz/tP4Q0NYwAOXOEw=; b=CtWikcEOe8nyneLMd9cQxh/gjH7hY6IIfO/RlAlY9suViAt171rr7SHcuQRXFHx5WF nswYUvo/4e32sxj4Y5bPKUgksCrGpKkJ4TaI8QvTcyMAAZDm5R2BDHLqZTlFaxr6K/XK YwuTcdfy72XrLdeVB4XsawsLVEfGEEotqtbhGiR67gEyUVzRNJa9e6MWteyXVQnxcA1m HLzf50BxJQd+2tj6bbd0yLuziaUV9ExnI/Z6E2wfCaytRc3ZvZDdlWrtTXv769VXx+ic z0Ga52cOr+3N2WHA3/dnKmr01fmYPu2d5LGahvl2i4GXt7LtVcVaDAw0D7OZ/Ld+E39p YDFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aAbw2wzfH6ZS0XnNQn2+bubcisfz/tP4Q0NYwAOXOEw=; b=5GDH2pSJweX6l3fzicZTN/cu+9BvRyvh0jHNHAHk9DYQe1SxxJbFNOlgWoTTh0prfV 3Y+ObHd9MPtcyDufUIMlk9uMsp3hvvQhjrLXsE/9Omse6fL/ioDgnigFlKC4CBv9vAo5 oSo2Tl9VCxReK18xB8DuzzPIQ9zz6KlKUMdrMFYE2s71MzFI197jFEH6COsQUsOFFOWR bt7oYqFpwd1lNVn9kVpNgMKakyFkj3XBXVuDjqDMQv1UFk9VdMRITZaXecLktrICFsD6 N1twa+onsEEkFdw+IthxjzCWGUvB/eI+sfX/XnAmtiFS9Y0PIQSLBU6hpHcX1zwoEqIV fkkg== X-Gm-Message-State: AOAM532M0IV5jewK2tid51ptc/dbilumSTk+040t//HPRhtTHsHfn9nN qvVuTLEIx0p4TCOuqOvk7S/Y1hXIXFQ= X-Google-Smtp-Source: ABdhPJz9IN3WtBJkxrqQmHDw149OoRT6wRuvCllLgJ/8cLws6eaJzet3NVxMYoJd0BFXiXmOcZYV1w== X-Received: by 2002:ad4:5c8b:0:b0:440:cc89:d57d with SMTP id o11-20020ad45c8b000000b00440cc89d57dmr6996340qvh.80.1647610005076; Fri, 18 Mar 2022 06:26:45 -0700 (PDT) Received: from [192.168.1.201] (pool-108-18-137-133.washdc.fios.verizon.net. [108.18.137.133]) by smtp.googlemail.com with ESMTPSA id y196-20020a3764cd000000b0067d51bbacdfsm3926378qkb.107.2022.03.18.06.26.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Mar 2022 06:26:44 -0700 (PDT) Subject: Re: [RFC] serial: mxc: get the clock frequency from the used clock for the device To: Heiko Thiery Cc: u-boot@lists.denx.de, Marek Vasut , Michale Walle , Angus Ainslie , Angus Ainslie , lukma@denx.de, sbabic@denx.de, festevam@gmail.com, uboot-imx@nxp.com, peng.fan@nxp.com References: <20220317124127.1783768-1-heiko.thiery@gmail.com> <99e5643a-ade5-655d-937f-ee6ce711a99d@gmail.com> <513bb930-59b5-d42d-70dc-f3e0d57801d8@gmail.com> From: Sean Anderson Message-ID: Date: Fri, 18 Mar 2022 09:26:43 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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 On 3/18/22 4:05 AM, Heiko Thiery wrote: > Hi Sean, >=20 > Am Fr., 18. M=C3=A4rz 2022 um 03:19 Uhr schrieb Sean Anderson : >> >> On 3/17/22 3:14 PM, Heiko Thiery wrote: >>> Hi Sean, >>> >>> Am Do., 17. M=C3=A4rz 2022 um 15:38 Uhr schrieb Sean Anderson : >>>> >>>> Hi Heiko, >>>> >>>> On 3/17/22 8:41 AM, Heiko Thiery wrote: >>>>> With the clock driver enabled for the imx8mq, it was noticed that t= he >>>>> 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 con= sole >>>>> and the settings are different from UART1. The result is that the c= onsole >>>>> 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 cl= ock >>>>> 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_mx= c.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_co= nsole(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)) { >>>> >>>> CONFIG_IS_ENABLED? >>> >>> This should be correct. The CONFIG_IS_ENABLED is a preprocessor macro= >>> and the IS_ENABLED can be used in c code. Or do you mean something >>> else? >> >> I mean you should be using CONFIG_IS_ENABLED(CLK) so that this code is= >> correct for both SPL and U-Boot proper. But it is also fine to "try an= d >> fail" (making this check unnecessary). >> >>>> >>>> mx6ull at least does not have CONFIG_SPL_CLK enabled. >>> >>> I expect that in that case it will fallback to the old behavior ... n= ot? >> >> Yes, if you handle -ENOSYS correctly. >> >>>> >>>>> + struct clk clk; >>>>> + if(!clk_get_by_name(dev, "ipg", &clk)) >>>>> + rate =3D clk_get_rate(&clk); >> >> You may also need to enable this clock. >=20 > What would be the right place to enable the clock? in mxc_serial_probe(= )? Yes. --Sean