From patchwork Sun Oct 31 12:22:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12595119 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 92117C433F5 for ; Sun, 31 Oct 2021 12:29:13 +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 6084C60551 for ; Sun, 31 Oct 2021 12:29:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6084C60551 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4XLg6SQsoY5dyR5gY5+9/OH5K3VBuIYpa00b1xmd9UI=; b=DPmMU0B8n6Ne/K vWj/ba6MykzB+5WFrGlAACevbpiGXsgfpDNCnW+Dop7FsTmcZMrWd0ecdyRhRdqAU+P4Oah/yrVhj Y5YSz1ETWLRoBG7INbBdHEeke+YhEoum63WpdBkaIHirD33mr3lLkOIfnyxoGfmvDE5Is1lmcAiPD sGNxoTsfhr9ztruZw83fF+hOflrowtDfAXG2YksqS1GFJW2XhgriX+1H3B7LSLKRv9IJybLaWS/45 CI5rACEm4x183ZqupYh3Z6m9Pl7kRXJSzMsyILm5OvpxgHn5XgH7iDxpeTmviz/jMxCblEG6ghVF8 bhGWfQxHXoa34TW+ecyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mh9vu-00E0vu-R4; Sun, 31 Oct 2021 12:27:31 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mh9rC-00Dyde-1r for linux-arm-kernel@lists.infradead.org; Sun, 31 Oct 2021 12:22:39 +0000 Received: by mail-ed1-x52e.google.com with SMTP id r12so55178183edt.6 for ; Sun, 31 Oct 2021 05:22:37 -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=3iEY6GQYQz83dpV+fT6R+J5oU7g9/XFul1oWQ/m49lI=; b=paMNXcWgNsqVxxXLElooVUCI5zgF9Hx8RgxZ2SqhdtT64USC0+p7vplys9LI42Uk+1 XcU4l37vhiQcoRIWt5azDuYrnmh5IDKVqJc2xo/tk8KjqUUnlgSmmo4z9NkvrcU3SSX5 QoN4cEBdqEFK6lU+VVqu6DYrBL1qV2xiY1ny52WZRRYLeQpL/MYhO+j/03383iBqwu8P RmzESNsirHGqn4jcwi801Dial2eRQkEliy84+LkWS1TprmKj0oHbrNH75HxsPQuJlhEl SX9IMToBjQAihJR4aIzFvGGKsjBCXpjLOVv2nMhhF/Rn7p+nTy2kDV30CrexMJ0fbxfK B+YQ== 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=3iEY6GQYQz83dpV+fT6R+J5oU7g9/XFul1oWQ/m49lI=; b=lHqVK7sF7GXGPN9xnx7QQoEhut3ZCW9kVIsEyxb0EcJpEIjty11YwO/E5C+7yn9r/C SV4h4kLJ22j8FiXpc8Ussrygyt+B3vQX9BPqtkl6of52gbI/7Nlb8qE7BaTjzc2ew/sW ptzlPfP7UiQ5ElTvdphwFommG/Odo/JBwcYjtLKSJCPy74hA5R2xDH7Cg7lPSk+sCa8/ q/BI5StpojIuIZ3rT8k6i6S3lp0wbO6pAcfu4fF6m3GSZRYRwrh4W77urtLIPFRLtyfd OXHsCueZa0sdGo4Eg0MGqctAS2FVHwdulrwgwmj03U2cDT0y/EEE3V6shl6aJbR+axcX 4jxQ== X-Gm-Message-State: AOAM532iDR0/STDaRHi77FazxfCHK/M/kEkgplJrRwdBwNGG/87VHKWX H8Sxi3DtXNHoTai+5AwscNdESfdNWTNcAHLO X-Google-Smtp-Source: ABdhPJxPnAd54K37gzIe2vTLOeK3l83domUTd7RNcjPhHCG0f0Gc1/AJpu51uIXA6chLbUgrUG730g== X-Received: by 2002:aa7:da10:: with SMTP id r16mr9332682eds.56.1635682956847; Sun, 31 Oct 2021 05:22:36 -0700 (PDT) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id eg33sm4316607edb.77.2021.10.31.05.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 05:22: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 v2 12/12] watchdog: s3c2410: Add Exynos850 support Date: Sun, 31 Oct 2021 14:22:16 +0200 Message-Id: <20211031122216.30212-13-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211031122216.30212-1-semen.protsenko@linaro.org> References: <20211031122216.30212-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211031_052238_164161_B7DA07F1 X-CRM114-Status: GOOD ( 23.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Different PMU registers and bits are used for each cluster. So driver data is now modified in probe, adding needed info depending on cluster index passed from device tree. Signed-off-by: Sam Protsenko Reported-by: kernel test robot Reported-by: kernel test robot --- Changes in v2: - Used single compatible for Exynos850, populating missing driver data in probe - Added "index" property to specify CPU cluster index drivers/watchdog/s3c2410_wdt.c | 68 +++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 8fdda2ede1c3..457b725c30ac 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -56,6 +56,14 @@ #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 EXYNOS850_CLUSTER0_WDTRESET_BIT 24 +#define EXYNOS850_CLUSTER1_WDTRESET_BIT 23 + #define QUIRK_HAS_WTCLRINT_REG (1 << 0) #define QUIRK_HAS_PMU_MASK_RESET (1 << 1) #define QUIRK_HAS_PMU_RST_STAT (1 << 2) @@ -171,6 +179,21 @@ static const struct s3c2410_wdt_variant drv_data_exynos7 = { QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_AUTO_DISABLE, }; +static const struct s3c2410_wdt_variant drv_data_exynos850 = { + /* + * Next fields will be set in probe(), based on cluster index: + * - .mask_reset_reg + * - .rst_stat_bit + * - .cnt_en_reg + */ + .mask_reset_inv = true, + .mask_bit = 2, + .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET, + .cnt_en_bit = 7, + .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | \ + QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN, +}; + static const struct of_device_id s3c2410_wdt_match[] = { { .compatible = "samsung,s3c2410-wdt", .data = &drv_data_s3c2410 }, @@ -182,6 +205,8 @@ static const struct of_device_id s3c2410_wdt_match[] = { .data = &drv_data_exynos5420 }, { .compatible = "samsung,exynos7-wdt", .data = &drv_data_exynos7 }, + { .compatible = "samsung,exynos850-wdt", + .data = &drv_data_exynos850 }, {}, }; MODULE_DEVICE_TABLE(of, s3c2410_wdt_match); @@ -548,15 +573,51 @@ static inline const struct s3c2410_wdt_variant * s3c2410_get_wdt_drv_data(struct platform_device *pdev) { const struct s3c2410_wdt_variant *variant; + struct s3c2410_wdt_variant *data; + struct device *dev = &pdev->dev; - variant = of_device_get_match_data(&pdev->dev); + variant = of_device_get_match_data(dev); if (!variant) { /* Device matched by platform_device_id */ variant = (struct s3c2410_wdt_variant *) platform_get_device_id(pdev)->driver_data; } - return variant; + /* Have to copy driver data over to keep its const qualifier intact */ + data = devm_kmemdup(dev, variant, sizeof(*variant), GFP_KERNEL); + if (!data) + return NULL; + + /* Populate missing fields for Exynos850 w.r.t. cluster index */ + if (variant == &drv_data_exynos850) { + u32 index; + int err; + + err = of_property_read_u32(dev->of_node, "samsung,index", + &index); + if (err) { + dev_err(dev, "failed to get cluster index\n"); + return NULL; + } + + switch (index) { + case 0: + data->mask_reset_reg = EXYNOS850_CLUSTER0_NONCPU_INT_EN; + data->rst_stat_bit = EXYNOS850_CLUSTER0_WDTRESET_BIT; + data->cnt_en_reg = EXYNOS850_CLUSTER0_NONCPU_OUT; + break; + case 1: + data->mask_reset_reg = EXYNOS850_CLUSTER1_NONCPU_INT_EN; + data->rst_stat_bit = EXYNOS850_CLUSTER1_WDTRESET_BIT; + data->cnt_en_reg = EXYNOS850_CLUSTER1_NONCPU_OUT; + break; + default: + dev_err(dev, "wrong cluster index: %u\n", index); + return NULL; + } + } + + return data; } static int s3c2410wdt_probe(struct platform_device *pdev) @@ -576,6 +637,9 @@ static int s3c2410wdt_probe(struct platform_device *pdev) wdt->wdt_device = s3c2410_wdd; wdt->drv_data = s3c2410_get_wdt_drv_data(pdev); + if (!wdt->drv_data) + return -EINVAL; + if (wdt->drv_data->quirks & QUIRKS_HAVE_PMUREG) { wdt->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node, "samsung,syscon-phandle");