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 CA6E0C4332F for ; Tue, 20 Dec 2022 08:49:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 443C9851E4; Tue, 20 Dec 2022 09:49: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="eOod0bAy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF98685358; Tue, 20 Dec 2022 09:49:47 +0100 (CET) Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (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 A05BB852A2 for ; Tue, 20 Dec 2022 09:49:42 +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=jim.t90615@gmail.com Received: by mail-pg1-x531.google.com with SMTP id r18so7873122pgr.12 for ; Tue, 20 Dec 2022 00:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lLPJBIbN/JqaAGOIu+cGkk7pDyX6uo8pTzJT+o5HW/U=; b=eOod0bAyq8PzZ10oHMAaFWrWOlb+MYWgHBc2IBP0mrLLh9VwTMJJlBq5J5KQNJtPrc tyFHSsDc9DaR8rPJFK8/ScO/kYDkAKVN6x07ae2nDFZtrwvgZeJIe0C30+LdmoZAWfm9 6yyK51leK6B3OydSLXII3CNDSHq+VVOyZ2SID5iw7JnuX1aetlyvQ2uhATcwRRezIsVY odrEgmoOXO1ROl8bzO9Pggat9O1PWuBNC2EmW1zVO9G0C+jvoDouj8J2JSSLqbKPSqTc li291L5fmTVJyeyPCyOHCQsGSSMd/4E7IZ5Hy0+gXMQWrTEt2MqLE/l4O9FSj6NS4IHB XNtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lLPJBIbN/JqaAGOIu+cGkk7pDyX6uo8pTzJT+o5HW/U=; b=vDjA2Yg+uW3tGd4LvIxOFDaKTY0lMypl+pyrPEzk90c11H+wWjOMM39QhEoGxpk4Ak TVxbAWAV3oAk231DlQtcb8mXGN2Jh/ZZANuhvCm2/BDzNyjyadgC80y5n7Qhc0CY9qTc jKjuvXqonTIIN0zQV9pC4blz+IS/8b8XOumx5GzUAqYY1TS1URZ9jKNYsAYdv22tWc5y pvr4PqR57SJQoHRwlmM2DXAoX0WRFLVAaCVgS46CeY5zYoC6WjZ9klYSQOZb9FxPEawl eePvcbUmhOfTH9+rGWDYrOXdUdLK0prfR54U5KqsB2LvbNG0TrYMJPKi7DR9H5ATA1QU 0N9g== X-Gm-Message-State: ANoB5pmukJDSQa34xJAnDGcSADBUXw8Hu121cw5Thtw+8Xj7xwfdc1di blqEFcOAOffquqs9qIohhBg= X-Google-Smtp-Source: AA0mqf53QhciJM1L5CvjZxLeMaii6ee+VaFXNiZYOHvPGupS509dV64BekT9gnH9AWl5b/NhoI/y1w== X-Received: by 2002:a05:6a00:1411:b0:574:a541:574a with SMTP id l17-20020a056a00141100b00574a541574amr52061929pfu.0.1671526180883; Tue, 20 Dec 2022 00:49:40 -0800 (PST) Received: from localhost.localdomain ([180.217.146.214]) by smtp.gmail.com with ESMTPSA id q9-20020aa78429000000b0057716769289sm8050297pfn.196.2022.12.20.00.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 00:49:40 -0800 (PST) From: Jim Liu X-Google-Original-From: Jim Liu To: JJLIU0@nuvoton.com, YSCHU@nuvoton.com, KWLIU@nuvoton.com, trini@konsulko.com, jim.t90615@gmail.com Cc: u-boot@lists.denx.de Subject: [PATCH v1] pinctrl: nuvoton: add NPCM7xx/NPCM8xx reset type detect Date: Tue, 20 Dec 2022 16:49:31 +0800 Message-Id: <20221220084931.29645-1-JJLIU0@nuvoton.com> X-Mailer: git-send-email 2.17.1 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 add reset type detect and persist setting. Signed-off-by: Jim Liu --- arch/arm/include/asm/arch-npcm8xx/rst.h | 2 +- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 20 ++++++++++++++++++++ drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 22 +++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/arch-npcm8xx/rst.h b/arch/arm/include/asm/arch-npcm8xx/rst.h index 379e841fca..09e1485063 100644 --- a/arch/arm/include/asm/arch-npcm8xx/rst.h +++ b/arch/arm/include/asm/arch-npcm8xx/rst.h @@ -16,7 +16,7 @@ #define SW1RST BIT(28) #define SW2RST BIT(27) #define SW3RST BIT(26) -#define SW4RST BIT(25) +#define TIPRST BIT(25) #define WD1RST BIT(24) #define WD2RST BIT(23) #define RST_STS_MASK GENMASK(31, 23) diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c index 31678f5537..1ad8bfbd88 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c @@ -47,6 +47,10 @@ #define WD0RST BIT(29) #define WD1RST BIT(24) #define WD2RST BIT(23) +#define SWRST1 BIT(28) +#define SWRST2 BIT(27) +#define SWRST3 BIT(26) +#define SW4RST BIT(25) #define GPIOX_MODULE_RESET 16 #define CA9C_RESET BIT(0) @@ -1374,6 +1378,14 @@ static bool is_gpio_persist(struct udevice *dev, u8 bank) regmap_read(priv->rst_regmap, NPCM7XX_RST_WD1RCR, &tmp); else if (value & WD2RST) regmap_read(priv->rst_regmap, NPCM7XX_RST_WD2RCR, &tmp); + else if (value & SWRST1) + regmap_read(priv->rst_regmap, NPCM7XX_RST_SWRSTC1, &tmp); + else if (value & SWRST2) + regmap_read(priv->rst_regmap, NPCM7XX_RST_SWRSTC2, &tmp); + else if (value & SWRST3) + regmap_read(priv->rst_regmap, NPCM7XX_RST_SWRSTC3, &tmp); + else if (value & SW4RST) + regmap_read(priv->rst_regmap, NPCM7XX_RST_SWRSTC4, &tmp); else return false; @@ -1392,11 +1404,19 @@ static int npcm7xx_gpio_reset_persist(struct udevice *dev, unsigned int banknum, regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD1RCR, BIT(num), 0); regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD2RCR, BIT(num), 0); regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_CORSTC, BIT(num), 0); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC1, BIT(num), 0); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC2, BIT(num), 0); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC3, BIT(num), 0); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC4, BIT(num), 0); } else { regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD0RCR, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD1RCR, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_WD2RCR, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_CORSTC, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC1, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC2, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC3, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); + regmap_update_bits(priv->rst_regmap, NPCM7XX_RST_SWRSTC4, BIT(num) | CA9C_RESET, BIT(num) | CA9C_RESET); } return 0; diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c index c6ffa89f77..0ec47e9577 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c @@ -20,7 +20,7 @@ #define SWRSTC1 0x44 #define SWRSTC2 0x48 #define SWRSTC3 0x4c -#define SWRSTC4 0x50 +#define TIPRSTC 0x50 #define CORSTC 0x5c #define FLOCKR1 0x74 #define INTCR4 0xc0 @@ -772,6 +772,10 @@ static int npcm8xx_gpio_reset_persist(struct udevice *dev, uint bank, regmap_update_bits(priv->rst_regmap, WD1RCR, BIT(offset), 0); regmap_update_bits(priv->rst_regmap, WD2RCR, BIT(offset), 0); regmap_update_bits(priv->rst_regmap, CORSTC, BIT(offset), 0); + regmap_update_bits(priv->rst_regmap, SWRSTC1, BIT(offset), 0); + regmap_update_bits(priv->rst_regmap, SWRSTC2, BIT(offset), 0); + regmap_update_bits(priv->rst_regmap, SWRSTC3, BIT(offset), 0); + regmap_update_bits(priv->rst_regmap, TIPRSTC, BIT(offset), 0); } else { regmap_update_bits(priv->rst_regmap, WD0RCR, BIT(offset), BIT(offset)); @@ -781,6 +785,14 @@ static int npcm8xx_gpio_reset_persist(struct udevice *dev, uint bank, BIT(offset)); regmap_update_bits(priv->rst_regmap, CORSTC, BIT(offset), BIT(offset)); + regmap_update_bits(priv->rst_regmap, SWRSTC1, BIT(offset), + BIT(offset)); + regmap_update_bits(priv->rst_regmap, SWRSTC2, BIT(offset), + BIT(offset)); + regmap_update_bits(priv->rst_regmap, SWRSTC3, BIT(offset), + BIT(offset)); + regmap_update_bits(priv->rst_regmap, TIPRSTC, BIT(offset), + BIT(offset)); } return 0; @@ -804,6 +816,14 @@ static bool is_gpio_persist(struct udevice *dev, uint bank) regmap_read(priv->rst_regmap, WD1RCR, &val); else if (status & WD2RST) regmap_read(priv->rst_regmap, WD2RCR, &val); + else if (status & SW1RST) + regmap_read(priv->rst_regmap, SWRSTC1, &val); + else if (status & SW2RST) + regmap_read(priv->rst_regmap, SWRSTC2, &val); + else if (status & SW3RST) + regmap_read(priv->rst_regmap, SWRSTC3, &val); + else if (status & TIPRST) + regmap_read(priv->rst_regmap, TIPRSTC, &val); else return false; -- 2.17.1