From patchwork Thu Oct 28 18:35:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12590807 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C04F4C4167B for ; Thu, 28 Oct 2021 18:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6482610EA for ; Thu, 28 Oct 2021 18:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbhJ1SiA (ORCPT ); Thu, 28 Oct 2021 14:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231210AbhJ1Sh7 (ORCPT ); Thu, 28 Oct 2021 14:37:59 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B79D5C061745 for ; Thu, 28 Oct 2021 11:35:31 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 188so12310766ljj.4 for ; Thu, 28 Oct 2021 11:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0h9MI5+nWpL7nv3kn46aEjYMVGjl4934m5PO+DJKiLI=; b=MKEq0geXa1eT2tQFBS/WYl3gwCPfOmg2L0DmJjAS75wUxFQaLny2BqlgQqgc67JX8T 1eU7Wo7elUOYI5w08gD3ujyLzYlT74MOXokrkpIJa3HLZiW8cVqXWM5wNjU2lfLhkLoI TIKI3YVP4DAws7hoQGvLzFOJqLhnG+mGZKyrMxjOt2lddr1jFBEIhgnXREPdMIDT+T31 verhiIhT6LNatzJB3wZGR/qostXudLyIli6eDJiV0Fx6Q8yxhqKjjeDGQRt0C8169sdQ UbzsDpDwLlZt2GoI3GEuLPz4Tb+qDIrJsNkcK6Q0LHC8HEjEzaAXwPJrcC9w34NYfJhK 2U9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0h9MI5+nWpL7nv3kn46aEjYMVGjl4934m5PO+DJKiLI=; b=OTkBHyTwPqXPXCPUVTlSnMVmsNNYZgste4gC/gpsS5vFfef0F9MPeq0P+q1Pwr4Mry amtzuotxn32joOO2qs3vPZ1iDdaOZjwGVBbY9bKGx1jAIqbAY9cXBSZUnaUmR9IhSUmZ 2qHAnl6q0uT5WdIFLCAX+6V3nUT2QGYsbFuNpun/8M3GDbgUk+XxtHZQqpHzwfn1nFBD Y1pXO3CEN1uell/us/7Wl5D2/DN9GWyiwLho0gvUNlN8LkCxb/GB+nlDWvgqw5HjeXFI SuVh/LqwZyOnTJAZg7CR4ods6uo0gnmNee1GGV9mTpLkSYZWeyolcnHTWXDLQCWEQQNG 3F/g== X-Gm-Message-State: AOAM53245btwyJrbK/pEpKTGPiqhzjGn4kt6pMaCo+7dXj7IIkJ4sFrP jfVlxQ00x4XP2El2vtd82KNeqw== X-Google-Smtp-Source: ABdhPJwxy/T1TXHAOSTfUZChLQnwHDSBgFoC2mGqdGsqWUdVRmYvf9KqsTRArBLOPGpZRJYiCdK+lQ== X-Received: by 2002:a2e:a40f:: with SMTP id p15mr6597055ljn.497.1635446130085; Thu, 28 Oct 2021 11:35:30 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id r127sm389488lff.62.2021.10.28.11.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:29 -0700 (PDT) From: Sam Protsenko To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/7] dt-bindings: watchdog: Require samsung,syscon-phandle for Exynos7 Date: Thu, 28 Oct 2021 21:35:21 +0300 Message-Id: <20211028183527.3050-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028183527.3050-1-semen.protsenko@linaro.org> References: <20211028183527.3050-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Exynos7 watchdog driver is clearly indicating that its dts node must define syscon phandle property. That was probably forgotten, so add it. Signed-off-by: Sam Protsenko Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml b/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml index 76cb9586ee00..93cd77a6e92c 100644 --- a/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml +++ b/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml @@ -39,8 +39,8 @@ properties: samsung,syscon-phandle: $ref: /schemas/types.yaml#/definitions/phandle description: - Phandle to the PMU system controller node (in case of Exynos5250 - and Exynos5420). + Phandle to the PMU system controller node (in case of Exynos5250, + Exynos5420 and Exynos7). required: - compatible @@ -58,6 +58,7 @@ allOf: enum: - samsung,exynos5250-wdt - samsung,exynos5420-wdt + - samsung,exynos7-wdt then: required: - samsung,syscon-phandle From patchwork Thu Oct 28 18:35:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12590811 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 523FAC4167D for ; Thu, 28 Oct 2021 18:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4108E610C8 for ; Thu, 28 Oct 2021 18:35:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231208AbhJ1SiB (ORCPT ); Thu, 28 Oct 2021 14:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231221AbhJ1SiA (ORCPT ); Thu, 28 Oct 2021 14:38:00 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63C77C061570 for ; Thu, 28 Oct 2021 11:35:33 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 1so6369558ljv.2 for ; Thu, 28 Oct 2021 11:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qxGj8ruYQXbdMlsDQaWiFHYINmJfNHh4ixIh1XClyl0=; b=ckofLK7Sa+sucC0aMZYSqjyi1MWCkTqu39gaJTKlg3UW5Et83dm1pTloYpabd0qeuV ZJ+tqbCJu0vO2+Fw4Pkq7IkUzSiE8I/NxYRfzGC61o3MnnT6v3h4FKIQE6tYaBzdUP+p 4A6YFe4YwWDQmbGBb5cOE1+uUIo4wFmvRWLHq1ZfNEuwUDR5/a/SWSyO3CvKEUymFAA7 P1y6oYXgilnjfYt7HfIrbwv2tYvY3m4d5eIW+VRC1+N9OPZw3eVO76HYFfQi7bGaWKAG GfHt8GNfYj8N7AfOI4ZEsebO2ZvgJXHlQW2iuH9lDz1+cRflpxU0VMFhSrqG+9TecA0K yYXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qxGj8ruYQXbdMlsDQaWiFHYINmJfNHh4ixIh1XClyl0=; b=mmHDjsDU9oyairZGFGyh2WMHgb+q22xys6CFkueVHyneE6IkUZ3mYIm7LpYiSSLWbR LCd+xaO+Zpf4G3nyO0m00/xiFeAtW130e4/9M6596hqjfiJxfU+EqhBIoxsrkA7wRwOH ts/NGpIDoqUxNA8wIyU0hZ6vdjzF3Y6F5ioeC7yGQM8JOgo7DcvtR0/lG+cVkQc8b8sW ShuFMNsaSGVz1/peMhwmcTU8pGNLFBd6NICy9aDRqy04LNN7MRUWv+N+0pRlLu7704we 9KMvzHOUjniP0zGxN3Q/AlL6LtYyedwXvRwD9pdX2DSaUjqQrUPIAqlKed7G81rDqWzY AkeA== X-Gm-Message-State: AOAM5310OuW7A85MCYmMhOy2hAOTtmtmPfuFHRsbUcF1ly7Q9attCULX TRfUkx/1mxU86JyzBT3SAHJprg== X-Google-Smtp-Source: ABdhPJwWl2cWkn/oMEy+9pMPff1K5svaTl8d+C7T6biY14aKQY1iB58MomSenBJbmQsXLkO7Gv9ZfA== X-Received: by 2002:a2e:a58f:: with SMTP id m15mr6315368ljp.449.1635446131729; Thu, 28 Oct 2021 11:35:31 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id w40sm389589lfu.48.2021.10.28.11.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:31 -0700 (PDT) From: Sam Protsenko To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 2/7] dt-bindings: watchdog: Document Exynos850 watchdog bindings Date: Thu, 28 Oct 2021 21:35:22 +0300 Message-Id: <20211028183527.3050-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028183527.3050-1-semen.protsenko@linaro.org> References: <20211028183527.3050-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Exynos850 SoC has two CPU clusters: - cluster 0: contains CPUs #0, #1, #2, #3 - cluster 1: contains CPUs #4, #5, #6, #7 Each cluster has its own dedicater watchdog timer. Those WDT instances are controlled using different bits in PMU registers, so there should be two different compatible strings (for each cluster), to tell the driver which bits to use for each WDT instance. Also on Exynos850 the peripheral clock and the source clock are two different clocks. Provide a way to specify two clocks in watchdog device tree node. Signed-off-by: Sam Protsenko --- .../devicetree/bindings/watchdog/samsung-wdt.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml b/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml index 93cd77a6e92c..19c7f7767559 100644 --- a/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml +++ b/Documentation/devicetree/bindings/watchdog/samsung-wdt.yaml @@ -22,16 +22,24 @@ properties: - samsung,exynos5250-wdt # for Exynos5250 - samsung,exynos5420-wdt # for Exynos5420 - samsung,exynos7-wdt # for Exynos7 + - samsung,exynos850-cl0-wdt # for Exynos850 (CPU cluster 0) + - samsung,exynos850-cl1-wdt # for Exynos850 (CPU cluster 1) reg: maxItems: 1 clocks: - maxItems: 1 + minItems: 1 + items: + - description: Peripheral clock used for register interface; if it's the + only clock, it's also a source clock + - description: Source clock (optional) clock-names: + minItems: 1 items: - const: watchdog + - const: watchdog_src interrupts: maxItems: 1 @@ -40,7 +48,7 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: Phandle to the PMU system controller node (in case of Exynos5250, - Exynos5420 and Exynos7). + Exynos5420, Exynos7 and Exynos850). required: - compatible @@ -59,6 +67,8 @@ allOf: - samsung,exynos5250-wdt - samsung,exynos5420-wdt - samsung,exynos7-wdt + - samsung,exynos850-cl0-wdt + - samsung,exynos850-cl1-wdt then: required: - samsung,syscon-phandle From patchwork Thu Oct 28 18:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12590813 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C552BC43217 for ; Thu, 28 Oct 2021 18:35:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3CED610C8 for ; Thu, 28 Oct 2021 18:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231231AbhJ1SiE (ORCPT ); Thu, 28 Oct 2021 14:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbhJ1SiC (ORCPT ); Thu, 28 Oct 2021 14:38:02 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03326C061570 for ; Thu, 28 Oct 2021 11:35:35 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id s19so12231791ljj.11 for ; Thu, 28 Oct 2021 11:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mR7X/IRD55/2aUJkOcwQinPxIZP7fj14y1hJFj2Tov8=; b=oVkXietcdHlzO8yulojwUbd/x80sHG/nhtTKAc6pmjYT27sY4wCda/6vpvlHObluDd ykDgLQW6UCEwJ8VGPSdgfTWkA3Adr12Dpjr/IpmbN7d7WdUniwR5WAB2r2e54r5rwfb7 bt2ppMzQgd5sB1j5f9T44WLkEsaiz/Dk5D/jDpuG+8rP/ZomDZj9jn0D9K3D4QoDxL3q /MIInomGW1Bu41RWYk11/ytEjSZYN1ECtvRDNi6X8OXUgoKOSoHCK/jbWhSmdHSXslc0 ZY2cENK5q34i3ZBcOsI/yZam4UcJh9W92COXkAgaux95iZng7vewGbDybDum2uh6Vj8t aqNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mR7X/IRD55/2aUJkOcwQinPxIZP7fj14y1hJFj2Tov8=; b=aGckZHl2Ay4psAS0pb5mEziCipdNFffXREe+qS4QW2FXctpmVV5cGtjHWUk7XL74Bv 8S53n7g5J3wG2tVgpEsB2Tx+Go/qZyGD0ZzI0jCoftYc/ytTeEsKdkiYNo/AUJ/8TRPh DyPQRX8/kd8m8FGQCPRTx9Soklw9AHiYgiLAN7USo0aIrkGe1uQGLmH3s4PibVmREmFu XQOSZCOpn6CRBRVNoecOibMCvTNf83bTE4D60MJNiXI0Sen9K5d2pfjsoIllr5M3GZFs S83lFnCg+8E/kvfWwAN/oIdbXwZheB1KbYlH+bHiI/TLu2EAlE5pwnyBE6uFft0Ukplp jizw== X-Gm-Message-State: AOAM533zYpfEW+LKKyX17EoshQg+LA3d9itkFSK/PEMOc1Bgs84WzBxg 8/g2hEOBCoG+cjcXfcsorZePMQ== X-Google-Smtp-Source: ABdhPJzcZmQk867wp52X0ImV5pDUvY+SDQshuWhs0SWpOCbNBmz9aPC3FxYi4n1W1qZBmYa7ffVXgQ== X-Received: by 2002:a2e:891a:: with SMTP id d26mr6530702lji.91.1635446133295; Thu, 28 Oct 2021 11:35:33 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id f8sm390614lfu.5.2021.10.28.11.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:32 -0700 (PDT) From: Sam Protsenko To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 3/7] watchdog: s3c2410: Make reset disable optional Date: Thu, 28 Oct 2021 21:35:23 +0300 Message-Id: <20211028183527.3050-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028183527.3050-1-semen.protsenko@linaro.org> References: <20211028183527.3050-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Not all SoCs have AUTOMATIC_WDT_RESET_DISABLE register, examples are Exynos850 and Exynos9. On such chips reset disable register shouldn't be accessed. Provide a way to avoid handling that register. This is done by introducing separate callbacks to driver data structure: one for reset disable register, and one for mask reset register. Now those callbacks can be checked and called only when those were set in driver data. This commit doesn't bring any functional change to existing devices, but merely provides an infrastructure for upcoming chips support. Signed-off-by: Sam Protsenko --- drivers/watchdog/s3c2410_wdt.c | 81 ++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 2395f353e52d..7c163a257d3c 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -83,6 +83,8 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to reboot (default 0)"); +struct s3c2410_wdt; + /** * struct s3c2410_wdt_variant - Per-variant config data * @@ -96,6 +98,11 @@ MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, 0 to * @rst_stat_bit: Bit number in the rst_stat register indicating a watchdog * reset. * @quirks: A bitfield of quirks. + * @disable_auto_reset: If set, this function will be called to disable + * automatic setting the WDT as a reset reason in RST_STAT on CPU reset; uses + * disable_reg field. + * @mask_reset: If set, this function will be called to mask WDT reset request; + * uses mask_reset_reg and mask_bit fields. */ struct s3c2410_wdt_variant { @@ -105,6 +112,8 @@ struct s3c2410_wdt_variant { int rst_stat_reg; int rst_stat_bit; u32 quirks; + int (*disable_auto_reset)(struct s3c2410_wdt *wdt, bool mask); + int (*mask_reset)(struct s3c2410_wdt *wdt, bool mask); }; struct s3c2410_wdt { @@ -121,6 +130,9 @@ struct s3c2410_wdt { struct regmap *pmureg; }; +static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask); +static int s3c2410wdt_mask_wdt_reset(struct s3c2410_wdt *wdt, bool mask); + static const struct s3c2410_wdt_variant drv_data_s3c2410 = { .quirks = 0 }; @@ -138,6 +150,8 @@ static const struct s3c2410_wdt_variant drv_data_exynos5250 = { .rst_stat_bit = 20, .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT \ | QUIRK_HAS_WTCLRINT_REG, + .disable_auto_reset = s3c2410wdt_disable_wdt_reset, + .mask_reset = s3c2410wdt_mask_wdt_reset, }; static const struct s3c2410_wdt_variant drv_data_exynos5420 = { @@ -148,6 +162,8 @@ static const struct s3c2410_wdt_variant drv_data_exynos5420 = { .rst_stat_bit = 9, .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT \ | QUIRK_HAS_WTCLRINT_REG, + .disable_auto_reset = s3c2410wdt_disable_wdt_reset, + .mask_reset = s3c2410wdt_mask_wdt_reset, }; static const struct s3c2410_wdt_variant drv_data_exynos7 = { @@ -158,6 +174,8 @@ static const struct s3c2410_wdt_variant drv_data_exynos7 = { .rst_stat_bit = 23, /* A57 WDTRESET */ .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT \ | QUIRK_HAS_WTCLRINT_REG, + .disable_auto_reset = s3c2410wdt_disable_wdt_reset, + .mask_reset = s3c2410wdt_mask_wdt_reset, }; static const struct of_device_id s3c2410_wdt_match[] = { @@ -200,35 +218,53 @@ static inline struct s3c2410_wdt *freq_to_wdt(struct notifier_block *nb) return container_of(nb, struct s3c2410_wdt, freq_transition); } -static int s3c2410wdt_mask_and_disable_reset(struct s3c2410_wdt *wdt, bool mask) +static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask) { + const u32 mask_val = 1 << wdt->drv_data->mask_bit; + const u32 val = mask ? mask_val : 0; int ret; - u32 mask_val = 1 << wdt->drv_data->mask_bit; - u32 val = 0; - /* No need to do anything if no PMU CONFIG needed */ - if (!(wdt->drv_data->quirks & QUIRK_HAS_PMU_CONFIG)) - return 0; + ret = regmap_update_bits(wdt->pmureg, wdt->drv_data->disable_reg, + mask_val, val); + if (ret < 0) + dev_err(wdt->dev, "failed to update reg(%d)\n", ret); - if (mask) - val = mask_val; + return ret; +} - ret = regmap_update_bits(wdt->pmureg, - wdt->drv_data->disable_reg, - mask_val, val); - if (ret < 0) - goto error; +static int s3c2410wdt_mask_wdt_reset(struct s3c2410_wdt *wdt, bool mask) +{ + const u32 mask_val = 1 << wdt->drv_data->mask_bit; + const u32 val = mask ? mask_val : 0; + int ret; - ret = regmap_update_bits(wdt->pmureg, - wdt->drv_data->mask_reset_reg, - mask_val, val); - error: + ret = regmap_update_bits(wdt->pmureg, wdt->drv_data->mask_reset_reg, + mask_val, val); if (ret < 0) dev_err(wdt->dev, "failed to update reg(%d)\n", ret); return ret; } +static int s3c2410wdt_enable(struct s3c2410_wdt *wdt, bool en) +{ + int ret; + + if (wdt->drv_data->disable_auto_reset) { + ret = wdt->drv_data->disable_auto_reset(wdt, !en); + if (ret < 0) + return ret; + } + + if (wdt->drv_data->mask_reset) { + ret = wdt->drv_data->mask_reset(wdt, !en); + if (ret < 0) + return ret; + } + + return 0; +} + static int s3c2410wdt_keepalive(struct watchdog_device *wdd) { struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd); @@ -609,7 +645,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) if (ret) goto err_cpufreq; - ret = s3c2410wdt_mask_and_disable_reset(wdt, false); + ret = s3c2410wdt_enable(wdt, true); if (ret < 0) goto err_unregister; @@ -655,7 +691,7 @@ static int s3c2410wdt_remove(struct platform_device *dev) int ret; struct s3c2410_wdt *wdt = platform_get_drvdata(dev); - ret = s3c2410wdt_mask_and_disable_reset(wdt, true); + ret = s3c2410wdt_enable(wdt, false); if (ret < 0) return ret; @@ -672,8 +708,7 @@ static void s3c2410wdt_shutdown(struct platform_device *dev) { struct s3c2410_wdt *wdt = platform_get_drvdata(dev); - s3c2410wdt_mask_and_disable_reset(wdt, true); - + s3c2410wdt_enable(wdt, false); s3c2410wdt_stop(&wdt->wdt_device); } @@ -688,7 +723,7 @@ static int s3c2410wdt_suspend(struct device *dev) wdt->wtcon_save = readl(wdt->reg_base + S3C2410_WTCON); wdt->wtdat_save = readl(wdt->reg_base + S3C2410_WTDAT); - ret = s3c2410wdt_mask_and_disable_reset(wdt, true); + ret = s3c2410wdt_enable(wdt, false); if (ret < 0) return ret; @@ -708,7 +743,7 @@ static int s3c2410wdt_resume(struct device *dev) writel(wdt->wtdat_save, wdt->reg_base + S3C2410_WTCNT);/* Reset count */ writel(wdt->wtcon_save, wdt->reg_base + S3C2410_WTCON); - ret = s3c2410wdt_mask_and_disable_reset(wdt, false); + ret = s3c2410wdt_enable(wdt, true); if (ret < 0) return ret; From patchwork Thu Oct 28 18:35:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12590815 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13482C433F5 for ; Thu, 28 Oct 2021 18:35:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDD7161040 for ; Thu, 28 Oct 2021 18:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231258AbhJ1SiF (ORCPT ); Thu, 28 Oct 2021 14:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbhJ1SiE (ORCPT ); Thu, 28 Oct 2021 14:38:04 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED43C061224 for ; Thu, 28 Oct 2021 11:35:36 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id y26so15452969lfa.11 for ; Thu, 28 Oct 2021 11:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kJm4UDkAbEJvQh9HALOCQ6tEN9zC09iwiQ+sFyCLYgE=; b=awFZuQDoz3AdUzy8hAHB8H14qF4LsV6ic436GNJqxRmGWXrfvunMJPcZfysKVQNoBI oM0jjE5poX7G/9DppOduxmQsGS1cMHhlPgGWpmEopYnq6Gb99R22SkW11wyD9jW3/F6F 5wMWMnvbY4vX3Z6QUxhdjw47aFy/LdsDnXfBCxRDpVDnnD0LBw/+ODSXl0PWY40o0mhv x3o5vVu89AZ5uyEtWt7a3dU79Lr9f+CirtGMc43SGhQLOw4W28ilcLLOGK7V14eO5V/L nC+Xdk9WJ8J4xwinHsxOF02IUgRArvWdhsaXAEecuHVblStD+bRreIcjYD8DRbzo4Xlu OGpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kJm4UDkAbEJvQh9HALOCQ6tEN9zC09iwiQ+sFyCLYgE=; b=KUyOCkdZX3hWO/jDGcHKtKhKV39xKXkAjkyl4m1O3gpcnJK44nyLk+xDY+HyqWOK1C 6sqkbHEziTvXo3b0WdSUkaLdjfyxipq/EC/ZiHNXovevpdfSdWS5lorMow05xc6bvgkk J640vWv0Hh5FuksQkZ9/1Nnlzc7a8EENlxT46U1yd1ibw+3AvJryjybv1yDirUZ8w88N dEVag3tnddW9SOAdxj9kPlc8uGuTe1uV7W5K3RIHR6dlOGQ4KDEiSjZ7A2QIziodHxrq jUd5F8qJ6Rk9AfNkSFnbgxzk+pr9aPNQOFkxiZTAtFpRa5mr+jIJiwl/G8g0Tf9QArmp YKfA== X-Gm-Message-State: AOAM5337lYh7OEq0Ui87m8xGRFl6BoMamoiLL+YS85r1G9+fiihSBVzE Rt+xnDuFbo0TG7NvhYvs/QnODg== X-Google-Smtp-Source: ABdhPJyicTgTmaeYWegOiAj36uy8bc/j7jLBVHfsBaeWirYLWUIvqClf7XZ2wk9dVOhwTeZC3BIB7Q== X-Received: by 2002:a05:6512:3a89:: with SMTP id q9mr5812095lfu.172.1635446134819; Thu, 28 Oct 2021 11:35:34 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id h1sm239725ljb.121.2021.10.28.11.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:34 -0700 (PDT) From: Sam Protsenko To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 4/7] watchdog: s3c2410: Add support for WDT counter enable Date: Thu, 28 Oct 2021 21:35:24 +0300 Message-Id: <20211028183527.3050-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028183527.3050-1-semen.protsenko@linaro.org> References: <20211028183527.3050-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org On new Exynos chips (like Exynos850) WDT counter must be enabled to make WDT functional. It's done via CLUSTERx_NONCPU_OUT register, in CNT_EN_WDT bit. Add infrastructure needed to enable that counter. Signed-off-by: Sam Protsenko --- drivers/watchdog/s3c2410_wdt.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 7c163a257d3c..a5ef7171a90e 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -97,12 +97,16 @@ struct s3c2410_wdt; * @rst_stat_reg: Offset in pmureg for the register that has the reset status. * @rst_stat_bit: Bit number in the rst_stat register indicating a watchdog * reset. + * @cnt_en_reg: Offset in pmureg for the register that enables WDT counter. + * @cnt_en_bit: Bit number for "watchdog counter enable" in cnt_en register. * @quirks: A bitfield of quirks. * @disable_auto_reset: If set, this function will be called to disable * automatic setting the WDT as a reset reason in RST_STAT on CPU reset; uses * disable_reg field. * @mask_reset: If set, this function will be called to mask WDT reset request; * uses mask_reset_reg and mask_bit fields. + * @enable_counter: If set, this function will be called to enable WDT counter; + * uses cnt_en_reg and cnt_en_bit fields. */ struct s3c2410_wdt_variant { @@ -111,9 +115,12 @@ struct s3c2410_wdt_variant { int mask_bit; int rst_stat_reg; int rst_stat_bit; + int cnt_en_reg; + int cnt_en_bit; u32 quirks; int (*disable_auto_reset)(struct s3c2410_wdt *wdt, bool mask); int (*mask_reset)(struct s3c2410_wdt *wdt, bool mask); + int (*enable_counter)(struct s3c2410_wdt *wdt, bool mask); }; struct s3c2410_wdt { @@ -132,6 +139,7 @@ struct s3c2410_wdt { static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask); static int s3c2410wdt_mask_wdt_reset(struct s3c2410_wdt *wdt, bool mask); +static int s3c2410wdt_enable_counter(struct s3c2410_wdt *wdt, bool en); static const struct s3c2410_wdt_variant drv_data_s3c2410 = { .quirks = 0 @@ -246,6 +254,20 @@ static int s3c2410wdt_mask_wdt_reset(struct s3c2410_wdt *wdt, bool mask) return ret; } +static int s3c2410wdt_enable_counter(struct s3c2410_wdt *wdt, bool en) +{ + const u32 mask_val = 1 << wdt->drv_data->cnt_en_bit; + const u32 val = en ? mask_val : 0; + int ret; + + ret = regmap_update_bits(wdt->pmureg, wdt->drv_data->cnt_en_reg, + mask_val, val); + if (ret < 0) + dev_err(wdt->dev, "failed to update reg(%d)\n", ret); + + return ret; +} + static int s3c2410wdt_enable(struct s3c2410_wdt *wdt, bool en) { int ret; @@ -262,6 +284,12 @@ static int s3c2410wdt_enable(struct s3c2410_wdt *wdt, bool en) return ret; } + if (wdt->drv_data->enable_counter) { + ret = wdt->drv_data->enable_counter(wdt, en); + if (ret < 0) + return ret; + } + return 0; } From patchwork Thu Oct 28 18:35:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12590817 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B93CC433EF for ; Thu, 28 Oct 2021 18:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB2D6610D2 for ; Thu, 28 Oct 2021 18:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231344AbhJ1SiI (ORCPT ); Thu, 28 Oct 2021 14:38:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231298AbhJ1SiF (ORCPT ); Thu, 28 Oct 2021 14:38:05 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D455C061745 for ; Thu, 28 Oct 2021 11:35:38 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id l13so15529890lfg.6 for ; Thu, 28 Oct 2021 11:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xUHzXfSH6odzUwHjMxG39dfwoppvALDIvwNfLlmnrkU=; b=wJRcnTKnS0oB3tuyMNi3MchugAm1UQkIqMWn7RLhGZz7lxsCJMRud0nZnZBTKA6ukH GVcd2zcrzdpEWR6TJn14ufk+EP/jAHQEYsBKURSmUhvWztsYlD40qN+xIGlvH9Yzryi3 /LygQtXCq1fJ29IjxjPuaP3ZjR9Uctkiq2r+539sZULG2UTyGkNWB4GFqWLpUMkMdxcu r4TUoL+A5eoSBtrbd7hOOv2VhxeS9f7BSEf+T3FhWJ7XB87DzU9pazOOEoZQl8A7vDpe XW2AupDG+sspfNbfqckQ/QhAzGxMMRw0ADWFLvp7y9EHaF12GtYPxqd6pQlyTQcki55i lMrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xUHzXfSH6odzUwHjMxG39dfwoppvALDIvwNfLlmnrkU=; b=YSOQC9NrX9plFZnyuK5LqmWeQhmMWZVy7tq1M6KT/dduzxKVSh9OaVw5WCBNLBLcMo /VmcnZE/B9BzCykIxw5v3KW1jRSFvDg2QIqPQvZLvggukz/Vfq8L5ahFhlP9jDcbSY6B I5PMdi4ODbCrYvGZOtLThF/WrU0fY9O/Uy3k2XXQ+rUE+gwF1RzZ37vWufFwlBUrpf6A 4jFyRBzY3wF0UpLi8kkmie3yxr8u81FX0rXkEAyPIWtZ+zk6Ztye6xFKB+7uqHnlwPkU VcDXl9QWle7+MrbYa4zKcPqCKirFHOKcYY3S4RmBggSZrnMROj2MM8xtzKSw9m3d2P/Z NF2A== X-Gm-Message-State: AOAM530hHJOvBMvRcwzSGRqkjv52wKBydrdLZvrOcEl2iogfMT7nOERp E6NewXjIcm8gQdEyYmbnpLJoAw== X-Google-Smtp-Source: ABdhPJxvOfUnubHbOQBtOfqnhkAp5qCfbvmGIdv2MB6mRaKsShfIi0eO9rlvaJpR0LCa7PBU/1K19Q== X-Received: by 2002:ac2:4bc2:: with SMTP id o2mr5615126lfq.307.1635446136411; Thu, 28 Oct 2021 11:35:36 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id g18sm434306lfr.120.2021.10.28.11.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:36 -0700 (PDT) From: Sam Protsenko To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 5/7] watchdog: s3c2410: Introduce separate source clock Date: Thu, 28 Oct 2021 21:35:25 +0300 Message-Id: <20211028183527.3050-6-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028183527.3050-1-semen.protsenko@linaro.org> References: <20211028183527.3050-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Some Exynos chips (like Exynos850) have dedicated source clock. That clock is provided from device tree as "watchdog_src" clock. In such case, "watchdog" clock is just a peripheral clock used for register interface. If "watchdog_src" is present, use its rate instead of "watchdog" for all timer related calculations. Signed-off-by: Sam Protsenko --- drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index a5ef7171a90e..bfc5872ca497 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -126,6 +126,8 @@ struct s3c2410_wdt_variant { struct s3c2410_wdt { struct device *dev; struct clk *clock; + struct clk *clock_src; + unsigned long freq_src; void __iomem *reg_base; unsigned int count; spinlock_t lock; @@ -213,10 +215,8 @@ MODULE_DEVICE_TABLE(platform, s3c2410_wdt_ids); /* functions */ -static inline unsigned int s3c2410wdt_max_timeout(struct clk *clock) +static inline unsigned int s3c2410wdt_max_timeout(unsigned long freq) { - unsigned long freq = clk_get_rate(clock); - return S3C2410_WTCNT_MAXCNT / (freq / (S3C2410_WTCON_PRESCALE_MAX + 1) / S3C2410_WTCON_MAXDIV); } @@ -364,7 +364,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, unsigned int timeout) { struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd); - unsigned long freq = clk_get_rate(wdt->clock); + unsigned long freq = wdt->freq_src; unsigned int count; unsigned int divisor = 1; unsigned long wtcon; @@ -627,13 +627,27 @@ static int s3c2410wdt_probe(struct platform_device *pdev) return ret; } + /* "watchdog_src" clock is optional; if it's not present -- just skip */ + wdt->clock_src = devm_clk_get(dev, "watchdog_src"); + if (!IS_ERR(wdt->clock_src)) { + ret = clk_prepare_enable(wdt->clock_src); + if (ret < 0) { + dev_err(dev, "failed to enable source clock\n"); + ret = PTR_ERR(wdt->clock_src); + goto err_clk; + } + wdt->freq_src = clk_get_rate(wdt->clock_src); + } else { + wdt->freq_src = clk_get_rate(wdt->clock); + } + wdt->wdt_device.min_timeout = 1; - wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt->clock); + wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt->freq_src); ret = s3c2410wdt_cpufreq_register(wdt); if (ret < 0) { dev_err(dev, "failed to register cpufreq\n"); - goto err_clk; + goto err_clk_src; } watchdog_set_drvdata(&wdt->wdt_device, wdt); @@ -707,6 +721,10 @@ static int s3c2410wdt_probe(struct platform_device *pdev) err_cpufreq: s3c2410wdt_cpufreq_deregister(wdt); + err_clk_src: + if (!IS_ERR(wdt->clock_src)) + clk_disable_unprepare(wdt->clock_src); + err_clk: clk_disable_unprepare(wdt->clock); @@ -727,6 +745,9 @@ static int s3c2410wdt_remove(struct platform_device *dev) s3c2410wdt_cpufreq_deregister(wdt); + if (!IS_ERR(wdt->clock_src)) + clk_disable_unprepare(wdt->clock_src); + clk_disable_unprepare(wdt->clock); return 0; From patchwork Thu Oct 28 18:35:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12590819 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CBABC433FE for ; Thu, 28 Oct 2021 18:35:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3781361040 for ; Thu, 28 Oct 2021 18:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbhJ1SiU (ORCPT ); Thu, 28 Oct 2021 14:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231332AbhJ1SiH (ORCPT ); Thu, 28 Oct 2021 14:38:07 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7360C061767 for ; Thu, 28 Oct 2021 11:35:39 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id x27so15537948lfu.5 for ; Thu, 28 Oct 2021 11:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hU+RESS0IujZsBqyvNbXzNXQg4dk7Tku3/T9o6vZEbg=; b=BzN19lpvtma2rZrB8dHRsCmLFHLw3Q8UqeKtIRqq8a8tZwUmTFISby5BY9xmHjC8Ri 0RDJssEdcb10bZjtMgUakEJkgN4pZ1N+QztRcNkb9dWeCIwu51glf2rzzo2sGyfXo1V9 wfKpod2owpglL0XlPNb14G4Y6v31eG02KWGpMJVOeP/DkOQc8asHrFDvdQ/FzYb3iH2N CmTcIyG5NmIyz/1MsNQAnrfJ4asMrUqkfb4SBDCBStJswGJVAlQDv2G7mniiD4goSGiT lxAsI0ow8uhx4g3/4Eym/XU7Y5TtPqi+tflaGnNJwXvjuDJawgz7GvgZ6/nEv00nyjNa qy/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hU+RESS0IujZsBqyvNbXzNXQg4dk7Tku3/T9o6vZEbg=; b=mVgvViQGJfHzmIxRSi3T80zSvSRhd79HeBUV23biI0GCGGLlonsyg+K5o4JGPdlrRG YjrTvaGp1A6C59RRA2MTZUUssxY/3E6HYt8LmVeno1MD+jD6AMcLovUIRrWsk41pghs4 91q6Gc0x+VJ7u7EetNKoosP6eNEKnVbPQptOABaUNmFUysi5zhhl+ue5ZaLsmhvcV68X 6fSNalJld/fldTbuF/jNP1Nmgy5guOu7NlED/DfCTc8E8FrQ1djkceQx1taVWfQF9j5s jdM/xrrJzA/OJWK8mgE/wIilQ16aD2EDL7vxcWKI7HdVrLA5x4o516kAPER/VL2O6+3j 9axw== X-Gm-Message-State: AOAM532P99FCngnF8tRCDEsEIqNScnJVqpycSUYqXmZOwX/u7UfORc1l XtNcQY9r9ynamhWOXPH8IXfN8w== X-Google-Smtp-Source: ABdhPJxn7K0lBUsJvXWo1vCNTw0mE29EUqOwFLOa38BUdNLv1YQABFsI/jy4gP9ovi7+I7VArZqtcw== X-Received: by 2002:a05:6512:1586:: with SMTP id bp6mr5879988lfb.363.1635446138079; Thu, 28 Oct 2021 11:35:38 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id n17sm165349ljc.124.2021.10.28.11.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:37 -0700 (PDT) From: Sam Protsenko To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 6/7] watchdog: s3c2410: Add Exynos850 support Date: Thu, 28 Oct 2021 21:35:26 +0300 Message-Id: <20211028183527.3050-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028183527.3050-1-semen.protsenko@linaro.org> References: <20211028183527.3050-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Exynos850 is a bit different from SoCs already supported in WDT driver: - AUTOMATIC_WDT_RESET_DISABLE register is removed, so its value is always 0; .disable_auto_reset callback is not set for that reason - MASK_WDT_RESET_REQUEST register is replaced with CLUSTERx_NONCPU_IN_EN register; instead of masking (disabling) WDT reset interrupt it's now enabled with the same value; .mask_reset callback is reused for that functionality though - To make WDT functional, WDT counter needs to be enabled in CLUSTERx_NONCPU_OUT register; it's done using .enable_counter callback Also Exynos850 has two CPU clusters, each has its own dedicated WDT instance. It takes two different driver data structures (and thus two different compatibles), as for each cluster there are different registers and different bits used. Signed-off-by: Sam Protsenko --- drivers/watchdog/s3c2410_wdt.c | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index bfc5872ca497..ca082b1226e3 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -56,6 +56,10 @@ #define EXYNOS5_RST_STAT_REG_OFFSET 0x0404 #define EXYNOS5_WDT_DISABLE_REG_OFFSET 0x0408 #define EXYNOS5_WDT_MASK_RESET_REG_OFFSET 0x040c +#define EXYNOS850_CLUSTER0_NONCPU_OUT 0x1220 +#define EXYNOS850_CLUSTER0_NONCPU_INT_EN 0x1244 +#define EXYNOS850_CLUSTER1_NONCPU_OUT 0x1620 +#define EXYNOS850_CLUSTER1_NONCPU_INT_EN 0x1644 #define QUIRK_HAS_PMU_CONFIG (1 << 0) #define QUIRK_HAS_RST_STAT (1 << 1) #define QUIRK_HAS_WTCLRINT_REG (1 << 2) @@ -141,6 +145,7 @@ struct s3c2410_wdt { static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask); static int s3c2410wdt_mask_wdt_reset(struct s3c2410_wdt *wdt, bool mask); +static int s3c2410wdt_enable_wdt_reset(struct s3c2410_wdt *wdt, bool mask); static int s3c2410wdt_enable_counter(struct s3c2410_wdt *wdt, bool en); static const struct s3c2410_wdt_variant drv_data_s3c2410 = { @@ -188,6 +193,32 @@ static const struct s3c2410_wdt_variant drv_data_exynos7 = { .mask_reset = s3c2410wdt_mask_wdt_reset, }; +static const struct s3c2410_wdt_variant drv_data_exynos850_cl0 = { + .mask_reset_reg = EXYNOS850_CLUSTER0_NONCPU_INT_EN, + .mask_bit = 2, + .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET, + .rst_stat_bit = 24, /* CLUSTER0 WDTRESET */ + .cnt_en_reg = EXYNOS850_CLUSTER0_NONCPU_OUT, + .cnt_en_bit = 7, + .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT \ + | QUIRK_HAS_WTCLRINT_REG, + .mask_reset = s3c2410wdt_enable_wdt_reset, + .enable_counter = s3c2410wdt_enable_counter, +}; + +static const struct s3c2410_wdt_variant drv_data_exynos850_cl1 = { + .mask_reset_reg = EXYNOS850_CLUSTER1_NONCPU_INT_EN, + .mask_bit = 2, + .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET, + .rst_stat_bit = 23, /* CLUSTER1 WDTRESET */ + .cnt_en_reg = EXYNOS850_CLUSTER1_NONCPU_OUT, + .cnt_en_bit = 7, + .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT \ + | QUIRK_HAS_WTCLRINT_REG, + .mask_reset = s3c2410wdt_enable_wdt_reset, + .enable_counter = s3c2410wdt_enable_counter, +}; + static const struct of_device_id s3c2410_wdt_match[] = { { .compatible = "samsung,s3c2410-wdt", .data = &drv_data_s3c2410 }, @@ -199,6 +230,10 @@ static const struct of_device_id s3c2410_wdt_match[] = { .data = &drv_data_exynos5420 }, { .compatible = "samsung,exynos7-wdt", .data = &drv_data_exynos7 }, + { .compatible = "samsung,exynos850-cl0-wdt", + .data = &drv_data_exynos850_cl0 }, + { .compatible = "samsung,exynos850-cl1-wdt", + .data = &drv_data_exynos850_cl1 }, {}, }; MODULE_DEVICE_TABLE(of, s3c2410_wdt_match); @@ -254,6 +289,20 @@ static int s3c2410wdt_mask_wdt_reset(struct s3c2410_wdt *wdt, bool mask) return ret; } +static int s3c2410wdt_enable_wdt_reset(struct s3c2410_wdt *wdt, bool mask) +{ + const u32 mask_val = 1 << wdt->drv_data->mask_bit; + const u32 val = mask ? 0 : mask_val; /* reset interrupt enable value */ + int ret; + + ret = regmap_update_bits(wdt->pmureg, wdt->drv_data->mask_reset_reg, + mask_val, val); + if (ret < 0) + dev_err(wdt->dev, "failed to update reg(%d)\n", ret); + + return ret; +} + static int s3c2410wdt_enable_counter(struct s3c2410_wdt *wdt, bool en) { const u32 mask_val = 1 << wdt->drv_data->cnt_en_bit; From patchwork Thu Oct 28 18:35:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12590821 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9E5DC433F5 for ; Thu, 28 Oct 2021 18:36:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3E4B60D43 for ; Thu, 28 Oct 2021 18:36:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231435AbhJ1Sia (ORCPT ); Thu, 28 Oct 2021 14:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231442AbhJ1SiT (ORCPT ); Thu, 28 Oct 2021 14:38:19 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E8EC061226 for ; Thu, 28 Oct 2021 11:35:41 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id bq11so15501663lfb.10 for ; Thu, 28 Oct 2021 11:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PW+Xu5KR0LGnC5ZiTBKpf+hcc7E/gJL7mbWD5u2IRSI=; b=xuSKeHbbC4nc+EU9CT3wXw3es14n16X3aTlTv7hYY/KFi/EOzkDwotp+e4efrBTknK yoXUrbGpXJzKzCjzaG1j2A3XS7QA6Vkku+P+25hkokJOcLpEg5IgS+CIUUThzgLyOZot ixdiNjWNwZmL59+5KZVYYBlD3pFB6IDde6RQnFqssxwjfOYYhvoqkGqK1FW0UmcvsAro lUJxahpkhEtl55/8fKE6OJjf2oOTWxcLIbh2gZIIHqmPO/st30RnIKXXfNs+U95VwAJ+ 2eOpm/1W5muC8xWhRfJnskHvK66/3RjGJX991wlDnnhdOURT5Bk7nNdLzwNfv6K4ijIh OnUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PW+Xu5KR0LGnC5ZiTBKpf+hcc7E/gJL7mbWD5u2IRSI=; b=moVIrb/CICqPGvfpK0IZsWURbCKhT05Y52qGMfD/WemK9eD9C/2NByQyq3FKUTOWfs DZNGsLG6pI5cGtrKAUf5LeBdOknCoOTei/fjhorGMSSL/c/Iv8piKg5tTmFMJB8ruWQd tVETBi5omqm8HSkrToZgYlKvAjDZd9eiVGK/TLG6yVmGies8XuF8iCg9f0Ik5Sr7IHCe xlntNGJNiiy+GkYeiLBhCgVxPz/uv+98KRTWTRsZDmzyOrkSkmjQZ3ZaKw2IZOdUhCgP wny1xHqZt5xuVfM01BQlnJmic4p91lQnbx5LOfjPdwzL5CCC6U2keBQgOMx2u/fAaeFq ZZnw== X-Gm-Message-State: AOAM531i/S/rEdqHArpTODZFjfvHKNZX3t7LF1N1LcxjJPFR8uq09hHn IhyPJJIZKifp4iAklp3F5vc46g== X-Google-Smtp-Source: ABdhPJwOsTrd35+23hcuPbz+sZ6ig7/NhHcGSWEcNkbNR9PlXij1vTP5BSLOqRqr2hbykWMc+rOx2Q== X-Received: by 2002:a05:6512:1294:: with SMTP id u20mr5634502lfs.218.1635446139796; Thu, 28 Oct 2021 11:35:39 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id d20sm388979lfg.8.2021.10.28.11.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:35:39 -0700 (PDT) From: Sam Protsenko To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Krzysztof Kozlowski Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 7/7] watchdog: s3c2410: Let kernel kick watchdog Date: Thu, 28 Oct 2021 21:35:27 +0300 Message-Id: <20211028183527.3050-8-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211028183527.3050-1-semen.protsenko@linaro.org> References: <20211028183527.3050-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org When "tmr_atboot" module param is set, the watchdog is started in driver's probe. In that case, also set WDOG_HW_RUNNING bit to let watchdog core driver know it's running. This way wathcdog core can kick the watchdog for us (if CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED option is enabled), until user space takes control. Signed-off-by: Sam Protsenko --- drivers/watchdog/s3c2410_wdt.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index ca082b1226e3..9af014ff1468 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -732,6 +732,21 @@ static int s3c2410wdt_probe(struct platform_device *pdev) wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt); wdt->wdt_device.parent = dev; + /* + * If "tmr_atboot" param is non-zero, start the watchdog right now. Also + * set WDOG_HW_RUNNING bit, so that watchdog core can kick the watchdog. + * + * If we're not enabling the watchdog, then ensure it is disabled if it + * has been left running from the bootloader or other source. + */ + if (tmr_atboot && started == 0) { + dev_info(dev, "starting watchdog timer\n"); + s3c2410wdt_start(&wdt->wdt_device); + set_bit(WDOG_HW_RUNNING, &wdt->wdt_device.status); + } else if (!tmr_atboot) { + s3c2410wdt_stop(&wdt->wdt_device); + } + ret = watchdog_register_device(&wdt->wdt_device); if (ret) goto err_cpufreq; @@ -740,17 +755,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) if (ret < 0) goto err_unregister; - if (tmr_atboot && started == 0) { - dev_info(dev, "starting watchdog timer\n"); - s3c2410wdt_start(&wdt->wdt_device); - } else if (!tmr_atboot) { - /* if we're not enabling the watchdog, then ensure it is - * disabled if it has been left running from the bootloader - * or other source */ - - s3c2410wdt_stop(&wdt->wdt_device); - } - platform_set_drvdata(pdev, wdt); /* print out a statement of readiness */