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 96F13C433FE for ; Tue, 18 Oct 2022 06:17:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD61484E8B; Tue, 18 Oct 2022 08:17:13 +0200 (CEST) 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=1666073834; bh=koqw5NJx4/t6ucw+k4qvWduTy7mOmp1jkCIXit40+w4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RB7eg/0qKTTfz6HDfRfc9wk4d1ahX84GcnMAw+ihrxiRgtMrhZMUoAgQv8Ct3drGD 4HkbHhV8UEc0s8uQPSfn2XwWpArM5sP63UK35zUA6/xrporWkti5NHF4MCyGvY8BnX HfdMcyL2AUuy5AuwFTJSdvShLkvVUeoW1aSzVqMfH8ArhkX95Eu3N9EkMjgFN15es+ 1AtJd6Snz7uLa5G6UQfVEB5L313Ba/4lBoZRBEBZs69IdWzfMbcZAZvS4QqZvQzkGd SHN5zJG6zBf+J2FrU/LgJOgZl+FPvOhBNhSb9FB2CGyZok+gXai1/PXD3qSyqWSWFi rFIRno/cRsbrg== Received: by phobos.denx.de (Postfix, from userid 109) id 5EEE084E8B; Tue, 18 Oct 2022 08:17:12 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [80.241.59.207]) (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 721B684E79 for ; Tue, 18 Oct 2022 08:17:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4Ms3YH33p2z9sPp; Tue, 18 Oct 2022 08:17:07 +0200 (CEST) Message-ID: <14904d2b-cc37-b898-c798-5e84241ac625@denx.de> Date: Tue, 18 Oct 2022 08:17:06 +0200 MIME-Version: 1.0 Subject: Re: [PATCH v1 1/4] ulp_wdog: Update ulp wdog driver for 32bits command Content-Language: en-US To: "Alice Guo (OSS)" , sbabic@denx.de, festevam@gmail.com, sjg@chromium.org Cc: uboot-imx@nxp.com, u-boot@lists.denx.de References: <20221009080100.6821-1-alice.guo@oss.nxp.com> <20221009080100.6821-2-alice.guo@oss.nxp.com> From: Stefan Roese In-Reply-To: <20221009080100.6821-2-alice.guo@oss.nxp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean On 09.10.22 10:00, Alice Guo (OSS) wrote: > From: Ye Li > > To use 32bits refresh and unlock command as default, check the CMD32EN > bit to select the corresponding commands. > > Signed-off-by: Ye Li > Signed-off-by: Alice Guo > Reviewed-by: Peng Fan > --- > drivers/watchdog/ulp_wdog.c | 52 +++++++++++++++++++++++++------------ > 1 file changed, 36 insertions(+), 16 deletions(-) > > diff --git a/drivers/watchdog/ulp_wdog.c b/drivers/watchdog/ulp_wdog.c > index ecd35ef22a..c40e785d0a 100644 > --- a/drivers/watchdog/ulp_wdog.c > +++ b/drivers/watchdog/ulp_wdog.c > @@ -28,11 +28,15 @@ struct wdog_regs { > #define UNLOCK_WORD0 0xC520 /* 1st unlock word */ > #define UNLOCK_WORD1 0xD928 /* 2nd unlock word */ > > +#define UNLOCK_WORD 0xD928C520 /* unlock word */ > +#define REFRESH_WORD 0xB480A602 /* refresh word */ > + > #define WDGCS_WDGE BIT(7) > #define WDGCS_WDGUPDATE BIT(5) > > #define WDGCS_RCS BIT(10) > #define WDGCS_ULK BIT(11) > +#define WDGCS_CMD32EN BIT(13) > #define WDGCS_FLG BIT(14) > > #define WDG_BUS_CLK (0x0) > @@ -52,20 +56,30 @@ void hw_watchdog_reset(void) > { > struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR; > > - dmb(); > - __raw_writel(REFRESH_WORD0, &wdog->cnt); > - __raw_writel(REFRESH_WORD1, &wdog->cnt); > - dmb(); > + if (readl(&wdog->cs) & WDGCS_CMD32EN) { > + writel(REFRESH_WORD, &wdog->cnt); > + } else { > + dmb(); > + __raw_writel(REFRESH_WORD0, &wdog->cnt); > + __raw_writel(REFRESH_WORD1, &wdog->cnt); > + dmb(); > + } > } > > void hw_watchdog_init(void) > { > struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR; > - > - dmb(); > - __raw_writel(UNLOCK_WORD0, &wdog->cnt); > - __raw_writel(UNLOCK_WORD1, &wdog->cnt); > - dmb(); > + u32 cmd32 = 0; > + > + if (readl(&wdog->cs) & WDGCS_CMD32EN) { > + writel(UNLOCK_WORD, &wdog->cnt); > + cmd32 = WDGCS_CMD32EN; > + } else { > + dmb(); > + __raw_writel(UNLOCK_WORD0, &wdog->cnt); > + __raw_writel(UNLOCK_WORD1, &wdog->cnt); > + dmb(); > + } > > /* Wait WDOG Unlock */ > while (!(readl(&wdog->cs) & WDGCS_ULK)) > @@ -75,7 +89,7 @@ void hw_watchdog_init(void) > writel(0, &wdog->win); > > /* setting 1-kHz clock source, enable counter running, and clear interrupt */ > - writel((WDGCS_WDGE | WDGCS_WDGUPDATE |(WDG_LPO_CLK << 8) | WDGCS_FLG), &wdog->cs); > + writel((cmd32 | WDGCS_WDGE | WDGCS_WDGUPDATE |(WDG_LPO_CLK << 8) | WDGCS_FLG), &wdog->cs); I know you're just copying / re-structuring old code here, but could you please also change this minor coding style issue: WDGCS_WDGUPDATE |(WDG_LPO_CLK << 8) -> WDGCS_WDGUPDATE | (WDG_LPO_CLK << 8) Other than this: Reviewed-by: Stefan Roese Thanks, Stefan > > /* Wait WDOG reconfiguration */ > while (!(readl(&wdog->cs) & WDGCS_RCS)) > @@ -87,11 +101,17 @@ void hw_watchdog_init(void) > void reset_cpu(void) > { > struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR; > - > - dmb(); > - __raw_writel(UNLOCK_WORD0, &wdog->cnt); > - __raw_writel(UNLOCK_WORD1, &wdog->cnt); > - dmb(); > + u32 cmd32 = 0; > + > + if (readl(&wdog->cs) & WDGCS_CMD32EN) { > + writel(UNLOCK_WORD, &wdog->cnt); > + cmd32 = WDGCS_CMD32EN; > + } else { > + dmb(); > + __raw_writel(UNLOCK_WORD0, &wdog->cnt); > + __raw_writel(UNLOCK_WORD1, &wdog->cnt); > + dmb(); > + } > > /* Wait WDOG Unlock */ > while (!(readl(&wdog->cs) & WDGCS_ULK)) > @@ -101,7 +121,7 @@ void reset_cpu(void) > writel(0, &wdog->win); > > /* enable counter running */ > - writel((WDGCS_WDGE | (WDG_LPO_CLK << 8)), &wdog->cs); > + writel((cmd32 | WDGCS_WDGE | (WDG_LPO_CLK << 8)), &wdog->cs); > > /* Wait WDOG reconfiguration */ > while (!(readl(&wdog->cs) & WDGCS_RCS)) Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de