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 X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_2 autolearn=unavailable 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 61F77C2D0DA for ; Thu, 26 Dec 2019 07:43:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 340982075E for ; Thu, 26 Dec 2019 07:43:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="geiE3nhy"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="LZdR0xLr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 340982075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/AVIg57L2Qb0UI0LnCgK6Ha/vRkkOAN5tokLyUC9Jvw=; b=geiE3nhypOxpow nu/fmwUrePwTh3pCMLJdwhLCrvZMpc/rDod0nkuqTvMFkWI5Jh0EfhNt98lDVyytDQjqI+Ohm3Y2B rU7QzP+i/yFdEvafp19T2CI2IgNyqdVmt4X0d3P7E5m5Ps4SbNrIVf9ZWEqcPWZWKSmc0cAsr/BM8 kGv9a9nVhdgLAmYkCY71/DTuN0iGhU5H0K4y55JG247UELQ1Y2tlAebmps5M24M+xVhXa0tZTxM0U tAaNJuo3RfguaveQ4n44DSN0vti8HNmBbeakibgd9CD2Nfb57moZhgzZEemefi5dF/OeDm0rGr2eq 0SmWWa9WvpgXaYZ2CUHg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ikNnI-0003mE-GS; Thu, 26 Dec 2019 07:42:52 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ikNnD-0003ld-Ox; Thu, 26 Dec 2019 07:42:50 +0000 X-UUID: e88a83898ede4aa48abeeb6d3b494270-20191225 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=B8FgD3ZrjisgjSkL3JaHceiILrlLNx2yrKhwr8RakCI=; b=LZdR0xLrEYvhQJGiDA3Mue8i2JMovgNzQ6JSwmdkVunNdVu5g16UY4b002ZkDZrKeOkDIil+AgRb4p9gyjb4yRweZJYwQQhzqVfr6SJAMeTSH6gQTYr+0iKQ9X097YLztJtWKa+9Qoon34gxo9W8ZOM2vSqo23WQrLiHgKFSRio=; X-UUID: e88a83898ede4aa48abeeb6d3b494270-20191225 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 995227162; Wed, 25 Dec 2019 23:42:40 -0800 Received: from MTKMBS31DR.mediatek.inc (172.27.6.102) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 25 Dec 2019 23:43:03 -0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 26 Dec 2019 15:42:07 +0800 Received: from [10.17.3.153] (172.27.4.253) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 26 Dec 2019 15:42:28 +0800 Message-ID: <1577346109.20923.3.camel@mhfsdcap03> Subject: Re: [PATCH v6 2/2] watchdog: mtk_wdt: mt8183: Add reset controller From: Yong Liang To: Philipp Zabel Date: Thu, 26 Dec 2019 15:41:49 +0800 In-Reply-To: References: <1576081356-18298-1-git-send-email-jiaxin.yu@mediatek.com> <1576081356-18298-3-git-send-email-jiaxin.yu@mediatek.com> X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-TM-SNTS-SMTP: 8574F099F3B0AD104410C800107372672A0E4739F5A4B188550EFA2C7F63128E2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191225_234247_820980_AA4289DE X-CRM114-Status: GOOD ( 23.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , "linux-watchdog@vger.kernel.org" , "sboyd@kernel.org" , "linux-kernel@vger.kernel.org" , Jiaxin Yu =?UTF-8?Q?=28=E4=BF=9E=E5=AE=B6=E9=91=AB=29?= , "linux-mediatek@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , "matthias.bgg@gmail.com" , Yingjoe Chen =?UTF-8?Q?=28=E9=99=B3=E8=8B=B1=E6=B4=B2=29?= , "wim@linux-watchdog.org" , "linux@roeck-us.net" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 2019-12-12 at 00:44 +0800, Philipp Zabel wrote: > Hi, > > On Thu, 2019-12-12 at 00:22 +0800, Jiaxin Yu wrote: > > From: "yong.liang" > > > > Add reset controller API in watchdog driver. > > Besides watchdog, MTK toprgu module alsa provide sub-system (eg, audio, > > camera, codec and connectivity) software reset functionality. > > Do any of the listed sub-systems use the reset_control_reset() > functionality? Is there no delay requirement between assert and > deassert? Otherwise it would be safer not to implement the .reset() > operation at all. > > > Audio use this reset API to reset audio, and it works well. It is no need to add delay between assert and deassert. > > Signed-off-by: yong.liang > > --- > > drivers/watchdog/Kconfig | 1 + > > drivers/watchdog/mtk_wdt.c | 109 ++++++++++++++++++++++++++++++++++++- > > 2 files changed, 109 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig > > index 2e07caab9db2..629249fe5305 100644 > > --- a/drivers/watchdog/Kconfig > > +++ b/drivers/watchdog/Kconfig > > @@ -717,6 +717,7 @@ config MEDIATEK_WATCHDOG > > tristate "Mediatek SoCs watchdog support" > > depends on ARCH_MEDIATEK || COMPILE_TEST > > select WATCHDOG_CORE > > + select RESET_CONTROLLER > > help > > Say Y here to include support for the watchdog timer > > in Mediatek SoCs. > > diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c > > index 9c3d0033260d..667380031dfd 100644 > > --- a/drivers/watchdog/mtk_wdt.c > > +++ b/drivers/watchdog/mtk_wdt.c > > @@ -9,6 +9,9 @@ > > * Based on sunxi_wdt.c > > */ > > > > +#include > > +#include > > +#include > > #include > > #include > > #include > > @@ -16,10 +19,12 @@ > > #include > > #include > > #include > > +#include > > #include > > +#include > > +#include > > What is this required for? It is no use. I will remove it. > > > #include > > #include > > -#include > > > > #define WDT_MAX_TIMEOUT 31 > > #define WDT_MIN_TIMEOUT 1 > > @@ -44,6 +49,9 @@ > > #define WDT_SWRST 0x14 > > #define WDT_SWRST_KEY 0x1209 > > > > +#define WDT_SWSYSRST 0x18U > > +#define WDT_SWSYS_RST_KEY 0x88000000 > > + > > #define DRV_NAME "mtk-wdt" > > #define DRV_VERSION "1.0" > > > > @@ -53,8 +61,97 @@ static unsigned int timeout; > > struct mtk_wdt_dev { > > struct watchdog_device wdt_dev; > > void __iomem *wdt_base; > > + spinlock_t lock; /* protects WDT_SWSYSRST reg */ > > + struct reset_controller_dev rcdev; > > +}; > > + > > +struct mtk_wdt_data { > > + int infracfg_sw_rst_num; > > This is not used at all, better remove it. I will remove it. > > > + int toprgu_sw_rst_num; > > +}; > > + > > +static const struct mtk_wdt_data mt2712_data = { > > + .toprgu_sw_rst_num = MT2712_TOPRGU_SW_RST_NUM, > > +}; > > + > > +static const struct mtk_wdt_data mt8183_data = { > > + .infracfg_sw_rst_num = MT8183_INFRACFG_SW_RST_NUM, > > Same as above. I will remove it. > > > + .toprgu_sw_rst_num = MT8183_TOPRGU_SW_RST_NUM, > > +}; > > + > > +static int toprgu_reset_update(struct reset_controller_dev *rcdev, > > + unsigned long id, bool assert) > > +{ > > + unsigned int tmp; > > + unsigned long flags; > > + > > This empty line can be removed. I will remove it. > > > + struct mtk_wdt_dev *data = > > + container_of(rcdev, struct mtk_wdt_dev, rcdev); > > + > > + spin_lock_irqsave(&data->lock, flags); > > + > > + tmp = readl(data->wdt_base + WDT_SWSYSRST); > > + if (assert) > > + tmp |= BIT(id); > > + else > > + tmp &= ~BIT(id); > > + tmp |= WDT_SWSYS_RST_KEY; > > + writel(tmp, data->wdt_base + WDT_SWSYSRST); > > + > > + spin_unlock_irqrestore(&data->lock, flags); > > + > > + return 0; > > +} > > + > > +static int toprgu_reset_assert(struct reset_controller_dev *rcdev, > > + unsigned long id) > > +{ > > + return toprgu_reset_update(rcdev, id, true); > > +} > > + > > +static int toprgu_reset_deassert(struct reset_controller_dev *rcdev, > > + unsigned long id) > > +{ > > + return toprgu_reset_update(rcdev, id, false); > > +} > > + > > +static int toprgu_reset(struct reset_controller_dev *rcdev, > > + unsigned long id) > > +{ > > + int ret; > > + > > + ret = toprgu_reset_assert(rcdev, id); > > + if (ret) > > + return ret; > > + > > + return toprgu_reset_deassert(rcdev, id); > > +} > > As mentioned above, is this needed? Does this work for all modules? > Only implement this if you are sure both are true. I think it's safe. Many modules has used it in MTK inside. > > regards > Philipp > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel