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 6BA66C433EF for ; Thu, 17 Mar 2022 14:38:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D0DC833F1; Thu, 17 Mar 2022 15:38:56 +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="APAb60uR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B103F833ED; Thu, 17 Mar 2022 15:38:53 +0100 (CET) Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) (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 01E48833F1 for ; Thu, 17 Mar 2022 15:38:48 +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-qk1-x733.google.com with SMTP id q194so4470438qke.5 for ; Thu, 17 Mar 2022 07:38:48 -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=v02n751OzgI6hn/7VKYWR5nCtYAkpKyzsKZdiTBv9Fs=; b=APAb60uRo6EDMKvw1qLPvDV0ODSpXt4VWe79yB9OFHU/WlF7OwxYyqDtq8eJ2YWofb uRqDy1hKbnp6zHPrNqv/CPCxy3IJFj010NMgNmWpeJfuzheZ5BNOgp/vuzsNk3GSYToV DxnjFMh+R21MUzqFiO+W1AcaKUeLz2eS8Z8OdoCqBOL2/tP9nWuTy3jMyXycFPYsInaX zh8VcD4LeMPkZ6Zf8zWEdQEPzic6bWSGTTLKJyw/hb8IX1uYLnl/UHsa5s7hWF8ekLGL FpM3cQCZKMJVJTKZXKGTAmdM1yXXBK3TwJTSfbsvnH2idXJ2r3aHcaCEjnxLr48I6a// u1DQ== 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=v02n751OzgI6hn/7VKYWR5nCtYAkpKyzsKZdiTBv9Fs=; b=axPmoxo0sgmf1KNIDtLXWaLQfXu6llDA69cw6kob3SG+BejXvZUEgbm1GOb6fC3Cel GMF68zwlDwJcG+x2jBMLF+4jqaTdZ2197c0tIyRWq25YK8S7L3R4seeHflFaINC7fdMN 0hHAmr6WQgwYjhKdjDzMrxuaOcp88QryXrM0hNJGcq590iPIOe9eB4I+10gcGYfIBLcY MED5+TJgay6zbTdfbqRB40sGkk5vPNIpIkd6IlBJlmKUFkeYqO2zt1yutVAY1l3scq6v MCEr9sjeW32vR6iMBBQChRWRkKITO+nX+15ruvq79CDWF5wBZs+t1sE8dh33l4ngphDI KB3g== X-Gm-Message-State: AOAM532RfVXV4LZIDbebdTE339bD61x8EKmpeVERwe4Ycg4g/c6Eycsc AJ++RAXl0nlPzdj542mo/Gw= X-Google-Smtp-Source: ABdhPJxuFm6MfCRBU6B9Z0yF1qEZUVuBxX/oV5OgR6MswjlIScCLFE+PClHc2A8YQT5XDzOaa7yNwQ== X-Received: by 2002:a37:a709:0:b0:67b:2dcc:d5dd with SMTP id q9-20020a37a709000000b0067b2dccd5ddmr2900157qke.597.1647527927703; Thu, 17 Mar 2022 07:38:47 -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 s5-20020a37a905000000b0067d35f2fdb1sm2462577qke.37.2022.03.17.07.38.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Mar 2022 07:38:47 -0700 (PDT) Subject: Re: [RFC] serial: mxc: get the clock frequency from the used clock for the device To: Heiko Thiery , u-boot@lists.denx.de Cc: 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> From: Sean Anderson Message-ID: <99e5643a-ade5-655d-937f-ee6ce711a99d@gmail.com> Date: Thu, 17 Mar 2022 10:38:45 -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: <20220317124127.1783768-1-heiko.thiery@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US 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 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. > > 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)) { CONFIG_IS_ENABLED? mx6ull at least does not have CONFIG_SPL_CLK enabled. > + struct clk clk; > + if(!clk_get_by_name(dev, "ipg", &clk)) > + rate = clk_get_rate(&clk); > + } > + > + /* as fallback we try to get the clk rate that way */ > + if (rate == 0) !rate || IS_ERR_VALUE(rate) > + rate = imx_get_uartclk(); > > - _mxc_serial_setbrg(plat->reg, clk, baudrate, plat->use_dte); > + _mxc_serial_setbrg(plat->reg, rate, baudrate, plat->use_dte); > > return 0; > } > --Sean