Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6C4EC432BE for ; Wed, 1 Sep 2021 12:33:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 27447610FF for ; Wed, 1 Sep 2021 12:33:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 27447610FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 160F9834C2; Wed, 1 Sep 2021 14:32:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="miT80h5q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C9A882BE5; Wed, 1 Sep 2021 14:32:54 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E43BB834BE for ; Wed, 1 Sep 2021 14:32:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id E49D8610FF; Wed, 1 Sep 2021 12:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630499566; bh=txdFsOf3QPOSZ7113fiyGwl7TcAQuYaMUUh74QKyLxw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=miT80h5qL0jI672l2dN0fiS5Io9AqOVKmeN+c/VWHQCeZAJv+2hGEuMx1dkG7RCqQ FLfgRlYtb6Ae8gdy0b+KEqb+5TyAZqI4yQF2d/KRTrgUg36PlOUzHhuuv2BWkkjFIF +CnKulSt0doFXz6tfHSJTTHw+a7VAvrcsivvMoWtuyUDIrFFSsbhNKVEt4gL2r7xPB I9vssdkVH+kFewAcMOHVmwBekh7zTJt5sdfvTgL8LqH5+H3vQctH9toT5OoE8A6hJg QtByIEwB4xVUgLEIvqrQGETfnOZwthMMOB8D5hQz+TUYIvx0qcbW2/YGDyN4h7JNEm x6emqlLeAVxBw== Received: by pali.im (Postfix) id 971FDA46; Wed, 1 Sep 2021 14:32:43 +0200 (CEST) Date: Wed, 1 Sep 2021 14:32:43 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Tom Rini Cc: Stefan Roese , Marek =?utf-8?B?QmVow7pu?= , u-boot@lists.denx.de Subject: Re: [PATCH v2] arm: mvebu: a37xx: Define CONFIG_SYS_REF_CLK and use it instead of get_ref_clk() Message-ID: <20210901123243.qs5ugus36qkbpd4e@pali> References: <20210811185330.15414-2-pali@kernel.org> <20210816100227.24792-1-pali@kernel.org> <20210901121410.GZ858@bill-the-cat> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210901121410.GZ858@bill-the-cat> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Wednesday 01 September 2021 08:14:10 Tom Rini wrote: > On Wed, Sep 01, 2021 at 11:12:58AM +0200, Stefan Roese wrote: > > > Hi Pali, > > > > On 16.08.21 12:02, Pali Rohár wrote: > > > Like for all other mvebu platforms with CONFIG_SYS_TCLK macro, define > > > CONFIG_SYS_REF_CLK macro for a37xx with base reference clock value which is > > > read from latched reset register. > > > > > > Replace all usages of get_ref_clk() function by this CONFIG_SYS_REF_CLK > > > macro and completely remove get_ref_clk() function. > > > > > > Replace also custom open-coded implementation of determining reference > > > clock by CONFIG_SYS_REF_CLK in a37xx serial driver. > > > > > > The only difference is that macro CONFIG_SYS_REF_CLK returns base reference > > > clock in Hz and old function get_ref_clk() returned it in MHz. > > > > > > Signed-off-by: Pali Rohár > > > > > > --- > > > Changes in v2: > > > * Do not remove MVEBU_TEST_PIN_LATCH_N and MVEBU_XTAL_MODE_MASK macros > > > > This patch does not apply any more, with all the other patches applied. > > Please wait a bit until these patches are included in master and then > > send a new version. > > > > Sorry for the trouble. > > > > Thanks, > > Stefan > > > > > --- > > > arch/arm/mach-mvebu/armada3700/cpu.c | 24 ------------------------ > > > arch/arm/mach-mvebu/include/mach/cpu.h | 7 ------- > > > arch/arm/mach-mvebu/include/mach/soc.h | 6 ++++++ > > > drivers/clk/mvebu/armada-37xx-periph.c | 6 +++--- > > > drivers/clk/mvebu/armada-37xx-tbg.c | 4 ++-- > > > drivers/phy/marvell/comphy_a3700.c | 12 ++++++------ > > > drivers/serial/serial_mvebu_a3700.c | 11 ++++------- > > > drivers/watchdog/armada-37xx-wdt.c | 2 +- > > > 8 files changed, 22 insertions(+), 50 deletions(-) > > > > > > diff --git a/arch/arm/mach-mvebu/armada3700/cpu.c b/arch/arm/mach-mvebu/armada3700/cpu.c > > > index 7702028ba19b..bdf8dc377528 100644 > > > --- a/arch/arm/mach-mvebu/armada3700/cpu.c > > > +++ b/arch/arm/mach-mvebu/armada3700/cpu.c > > > @@ -23,12 +23,6 @@ > > > /* Armada 3700 */ > > > #define MVEBU_GPIO_NB_REG_BASE (MVEBU_REGISTER(0x13800)) > > > -#define MVEBU_TEST_PIN_LATCH_N (MVEBU_GPIO_NB_REG_BASE + 0x8) > > > -#define MVEBU_XTAL_MODE_MASK BIT(9) > > > -#define MVEBU_XTAL_MODE_OFFS 9 > > > -#define MVEBU_XTAL_CLOCK_25MHZ 0x0 > > > -#define MVEBU_XTAL_CLOCK_40MHZ 0x1 > > > - > > > #define MVEBU_NB_WARM_RST_REG (MVEBU_GPIO_NB_REG_BASE + 0x40) > > > #define MVEBU_NB_WARM_RST_MAGIC_NUM 0x1d1e > > > @@ -370,21 +364,3 @@ void reset_cpu(void) > > > */ > > > writel(MVEBU_NB_WARM_RST_MAGIC_NUM, MVEBU_NB_WARM_RST_REG); > > > } > > > - > > > -/* > > > - * get_ref_clk > > > - * > > > - * return: reference clock in MHz (25 or 40) > > > - */ > > > -u32 get_ref_clk(void) > > > -{ > > > - u32 regval; > > > - > > > - regval = (readl(MVEBU_TEST_PIN_LATCH_N) & MVEBU_XTAL_MODE_MASK) >> > > > - MVEBU_XTAL_MODE_OFFS; > > > - > > > - if (regval == MVEBU_XTAL_CLOCK_25MHZ) > > > - return 25; > > > - else > > > - return 40; > > > -} > > > diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h > > > index 79858858c259..9b8907e0fe55 100644 > > > --- a/arch/arm/mach-mvebu/include/mach/cpu.h > > > +++ b/arch/arm/mach-mvebu/include/mach/cpu.h > > > @@ -183,12 +183,5 @@ int a3700_dram_init_banksize(void); > > > /* A3700 PCIe regions fixer for device tree */ > > > int a3700_fdt_fix_pcie_regions(void *blob); > > > -/* > > > - * get_ref_clk > > > - * > > > - * return: reference clock in MHz (25 or 40) > > > - */ > > > -u32 get_ref_clk(void); > > > - > > > #endif /* __ASSEMBLY__ */ > > > #endif /* _MVEBU_CPU_H */ > > > diff --git a/arch/arm/mach-mvebu/include/mach/soc.h b/arch/arm/mach-mvebu/include/mach/soc.h > > > index aab61f7c15cf..b03b6de3c6cd 100644 > > > --- a/arch/arm/mach-mvebu/include/mach/soc.h > > > +++ b/arch/arm/mach-mvebu/include/mach/soc.h > > > @@ -210,6 +210,12 @@ > > > #define BOOT_FROM_SPI 0x3 > > > #define CONFIG_SYS_TCLK 250000000 /* 250MHz */ > > > +#elif defined(CONFIG_ARMADA_3700) > > > +/* SAR values for Armada 3700 */ > > > +#define MVEBU_TEST_PIN_LATCH_N MVEBU_REGISTER(0x13808) > > > +#define MVEBU_XTAL_MODE_MASK BIT(9) > > > +#define CONFIG_SYS_REF_CLK ((readl(MVEBU_TEST_PIN_LATCH_N) & MVEBU_XTAL_MODE_MASK) ? \ > > > + 40000000 : 25000000) > > NAK. CONFIG_xxx which evaluate out to a macro / function are the > hardest to convert to Kconfig. This patch is taking a step backwards. > In fact, wait, how does patch apply and work? There are no > CONFIG_SYS_REF_CLK instances today, so the build should blow up about > adding a new non-Kconfig symbol. So, could you please provide some other solution for this issue which Marek and Stefan pointed?