From patchwork Wed Jul 14 15:33:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 476816 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp680547jao; Wed, 14 Jul 2021 08:35:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvsBX0qjDw5tJFGyKUcQk5RJFXZC5ZntvzyA30mTlzyUgsGzHm4m1t+70JVMRyVgaQqJD/ X-Received: by 2002:a05:6602:146:: with SMTP id v6mr7627929iot.5.1626276920093; Wed, 14 Jul 2021 08:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626276920; cv=none; d=google.com; s=arc-20160816; b=afhuZJCxkWQA1Dl4T22pi+vN6zSSVwn3gFn5ZcdPvNuv+l/ctwQoG1sUZSXDW6o+IO dbBTAMEJ/IwGD7DcIIHfmxZ5gdcAmriToyP+UIws+xTsSmvyQyTHmfZK4eCfdfmWtpd0 U5A/aC/xL8DUGS8zDRmPrYOlROg/xbW9Rt7hKU+eSzO9TA3z7mYZOYzINwM7IYzSIqLV Dy2M8CChhxpApoDYkBDu1Rx8IjjumteuKickoiFJVCsVr2Jo87hLfVJePjTy1gq5RUBM wvCJOPp1dVDBD0InJvFP0wI0D+Y76EoWe4cuUoR4bKlqiv/PDhaAdnRmLxus6wV3Hsdz 9wJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=eJaKL3ISTdN+YsCpp2uZ/iZyyKrQcH2+/HmeVpNKc+k=; b=ef/JjTmwOiXVTST94QT4E8do7Swi+9a+41wjM9bpo8jV36scbyhAq43XwcLmCNaHju eQBMHT7QR+89gybdE9Vj4HeAsQSUZqXgPk3eMkkbz4xa5TIbsK8BD/BwDh6IpHsObbxU 5xD9mKB5JnqlIosDbywisWYZl8YmwQwEdrdo1tlBBn4m+aiL6Byzj9pewKCNe61ftuZa QbhAsZVDjpR3jE24wagMqLeZHWwk5EQkXoktg7qM2RqbAJoD6YTZkLJ7NH6qfPqkon52 5KLFKyuJf3K/CL/68m1tiu+hjopaFYF+Mlq2eju64ixl4IwBq0QNn8xtTTd836CUe6c8 0vmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YNM5znqW; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t11si2951095jal.23.2021.07.14.08.35.20 for ; Wed, 14 Jul 2021 08:35:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YNM5znqW; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239571AbhGNPiL (ORCPT ); Wed, 14 Jul 2021 11:38:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239567AbhGNPiL (ORCPT ); Wed, 14 Jul 2021 11:38:11 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0BEC06175F for ; Wed, 14 Jul 2021 08:35:18 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id i5so4336107lfe.2 for ; Wed, 14 Jul 2021 08:35:18 -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:mime-version :content-transfer-encoding; bh=eJaKL3ISTdN+YsCpp2uZ/iZyyKrQcH2+/HmeVpNKc+k=; b=YNM5znqWLu/ak5ElXJ7+tVvApRP533MCiRC/c9M1ul0cQEDdgq5WTuQoibx/TQarn5 454GxKvs4QRRAGX1iqDJerVBNSlRNgolsmnqmsvTIbX3gAOVhGSNpjH0O7qAMM4S9JzI KhDTJWUZ0DRvOto8XqImUb/rqzjUnPyVVwFR5AnUOpqlCZqXPoTYR9fLkhYerVp63ThE dduGnV7umYqO/iHXGajnR2sk7K+FKKDRAwe0RfV7pP4+MQiXH0FxKtbD1ZlO3lnEYlMv +kBo+/iasD+B8thv91hyORAyslGjWw5lLvJJnCWKR6BaeJ21Gm/I3w5zKCNuJbxJFChI Gs4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eJaKL3ISTdN+YsCpp2uZ/iZyyKrQcH2+/HmeVpNKc+k=; b=iYF8leBdzT05LUKF9VCAL9sH0Vw22faKDGMP9vKo7cLVIZA7PWp3C/rS5kK8FoxKe3 G/2zbvzJe+V9giZO5+TYITwk4rgggCMBpyMulSlSpe+zyIO0Wc6MQCPYv8x4PaovfG6q rDEoPLLgHvKVvuVGXJKMcXz0/4WVd56aZAs66SNx1ABpOsKrg4FIJ7lTewOmeicXQ26t PzJyOUZALYMGtKYYrGAETOWd5Iz229x24JIss1Kp+4jOee2IhhgOOMMKAd60iOtwQ/0I eljR+ULKZ9n3Nf5hySzcv0eQcdQfxq+RQ0yzB/MbDd6EYgcdLrTs6Qv9phW/L9cqjYXq gswg== X-Gm-Message-State: AOAM531t3slRc5T4JkQdhdiKTwkxS2D3Snk0JsBhl/UG/RyHgJnOJ3Yv zj3Uo+vD8vaH6o4x/XWmoQgibg== X-Received: by 2002:a05:6512:714:: with SMTP id b20mr8349664lfs.488.1626276917236; Wed, 14 Jul 2021 08:35:17 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id y3sm269984ljj.121.2021.07.14.08.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 08:35:17 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, Linus Walleij , devicetree@vger.kernel.org, Marc Zyngier Subject: [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Date: Wed, 14 Jul 2021 17:33:13 +0200 Message-Id: <20210714153314.1004147-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This adds devicetree bindings for the Maxim MAX63xx watchdog timers. Cc: devicetree@vger.kernel.org Cc: Marc Zyngier Signed-off-by: Linus Walleij --- .../bindings/watchdog/maxim,max63xx.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml -- 2.31.1 Reviewed-by: Rob Herring Reviewed-by: Guenter Roeck diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml new file mode 100644 index 000000000000..f2105eedac2c --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/watchdog/maxim,max63xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim 63xx Watchdog Timers + +allOf: + - $ref: "watchdog.yaml#" + +maintainers: + - Marc Zyngier + - Linus Walleij + +properties: + compatible: + oneOf: + - const: maxim,max6369 + - const: maxim,max6370 + - const: maxim,max6371 + - const: maxim,max6372 + - const: maxim,max6373 + - const: maxim,max6374 + + reg: + description: This is a 1-byte memory-mapped address + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + wdt: watchdog@50000000 { + compatible = "maxim,max6369"; + reg = <0x50000000 0x1>; + timeout-sec = <10>; + }; + +... From patchwork Wed Jul 14 15:33:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 476817 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp680875jao; Wed, 14 Jul 2021 08:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziu+jtKQ7Ps0/xjoqH52AngaPJZbnpRB12dfry4ToU28+TdYJrHAv6iXpdUjSXlr+KLxbE X-Received: by 2002:a6b:c40d:: with SMTP id y13mr7735870ioa.78.1626276943159; Wed, 14 Jul 2021 08:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626276943; cv=none; d=google.com; s=arc-20160816; b=P5yjPh1QbNkNc4qw5aE8TERD0quXYejrVKsKB2yVXtk8cwka1F57V7AMrcs/kFbIt0 J38KluexNSKv61pu2FXmr+AXpS/W08+XX9L4FPtBsH22IoNXXoUTrKz9oYeKusX0vrbx 13WSMlKlpH1CMVlDb7WmkfLLd9iC+UEo8dPH5xQaUGrfAiGEUeC5m87Im0cbW2RKcKiZ vW27ET/NOEk2O7M1cwq/+elwkiqQ6bMleAWNKZ5habyhbTt47SI9U/sOA6/vEeVuV7wg xlj/PJx5BUaOkFFkyvSj9/r73h2TuCG55xYMkDqCyI/81ETvdEGU4vogOWXFYQqwGa7Z 1EZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rh3lGfHwMJkZvu76gzDf+JL+UpvhGWVQ3c17N4FInmg=; b=J/OP8W3X0P3BZqynmR4/t7XGhCxiLYe6C7WptMy2Z/Fm4LmM3WwzH+eke2i1ttPQ5k CdRpwB0Da+1AU8/2bI5aiy34qEIv7a0WD7PGwpzwMqzKEI/g2361RKQHFIGJwDNL4xhO hKSVAQwC//iNkkp8xnzKqMd8FZoML9B+Q6sU2395bsqqtz/LwNhYIpvnA0imMuzpscsA 1riuPKAgbjiPmWnsHmGYVpvx/1d0/zDJI8cTDCVACnl6kmjJ0+PxKIHVOq55im+f4TsH Z/r1LcsXvyB7pmRSgHZ3KFf03TGryWcFTrIIgmp6nUF+HR2Vrlg+NH7dSQcwQlEMzZZJ mRAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PaaNEtUR; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t11si2951095jal.23.2021.07.14.08.35.43 for ; Wed, 14 Jul 2021 08:35:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PaaNEtUR; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239615AbhGNPie (ORCPT ); Wed, 14 Jul 2021 11:38:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239571AbhGNPid (ORCPT ); Wed, 14 Jul 2021 11:38:33 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96DDC06175F for ; Wed, 14 Jul 2021 08:35:41 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id y7so3624207ljm.1 for ; Wed, 14 Jul 2021 08: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=Rh3lGfHwMJkZvu76gzDf+JL+UpvhGWVQ3c17N4FInmg=; b=PaaNEtURxRHgra3yOhwrjPi6zrrA2/7RkcZfuvN722AEsEjQGnyJu5tJK/b/sPl+0u 7wI8SUSvB1CeTZJlo1UJoOVBpMKamqr4QVUmEaqjKglEcpZJYWa/AbAHZaJX2orgoVXN h9w+uL3b/NczNS9s0EZxuEq9HB9TQNPXGx8rmhhGLDHRyLGncG7ufZx9lzXaY5ZnuGWy lgPTfRSTNoCD0ypRMp5Y5NnXxLhBmqrCEP9QZBAQCYPrf28YbVfgJ5V++5W5MlAXjEVd vpVEJbDLZywUab9Zh0EvpweBCFafmBfmCl2npjjUvxREYd5jHrLT54aOPt7rK+j2JBHU 2ZXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rh3lGfHwMJkZvu76gzDf+JL+UpvhGWVQ3c17N4FInmg=; b=hMpJcmisyL8PWB88XAseA2KKBncdGpivcX1GuPFvR2hSpA4fIg+aicEqBmlJilpYsC C8ANupkp0yFe0rE0e4wx3Hsgk+KuhiwZNlFF1cp1UCZAJ3ZJ+ksyBAFV5HcPzk5s61ew M02vAZoKxl4IQwwau3T5cMurY4xyMUbx0Fr7d46UiCaQSFFeJOLiKy9zEPRlrfHZ8fmf 44jP/cye+hFuofrWl8RetNUK5zE1nqPZrMqCRA/sZimdw+kHIBmNLjgh7HIOdjMCRFtb LCg+KVxctH1QEL3NzW/re24UTQVLr2KsiZPAHJcxBy5l3RJ2mpt8KNj76N9ynAYfJd/D tZNg== X-Gm-Message-State: AOAM530RB2ePy68WJqx0KxGy+L1t2b/Ygk9eQYxFq6nHlpsORJw2Vn7M iyxyhajVVYY9Pjzm7NlN9E6GuXmZkVdt/A== X-Received: by 2002:a2e:8709:: with SMTP id m9mr9826030lji.201.1626276939499; Wed, 14 Jul 2021 08:35:39 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id y3sm269984ljj.121.2021.07.14.08.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 08:35:39 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, Linus Walleij , Marc Zyngier Subject: [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing Date: Wed, 14 Jul 2021 17:33:14 +0200 Message-Id: <20210714153314.1004147-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210714153314.1004147-1-linus.walleij@linaro.org> References: <20210714153314.1004147-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This adds device tree probing to the MAX63xx driver so it can be instantiated from the device tree. We use the generic fwnode-based method to get to the match data and clean up by constifying the functions as the match is indeed a const. Cc: Marc Zyngier Signed-off-by: Linus Walleij --- drivers/watchdog/max63xx_wdt.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) -- 2.31.1 Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c index 3a899628a834..9e1541cfae0d 100644 --- a/drivers/watchdog/max63xx_wdt.c +++ b/drivers/watchdog/max63xx_wdt.c @@ -26,6 +26,7 @@ #include #include #include +#include #define DEFAULT_HEARTBEAT 60 #define MAX_HEARTBEAT 60 @@ -99,8 +100,8 @@ static const struct max63xx_timeout max6373_table[] = { { }, }; -static struct max63xx_timeout * -max63xx_select_timeout(struct max63xx_timeout *table, int value) +static const struct max63xx_timeout * +max63xx_select_timeout(const struct max63xx_timeout *table, int value) { while (table->twd) { if (value <= table->twd) { @@ -202,14 +203,17 @@ static int max63xx_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct max63xx_wdt *wdt; - struct max63xx_timeout *table; + const struct max63xx_timeout *table; int err; wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; - table = (struct max63xx_timeout *)pdev->id_entry->driver_data; + /* Attempt to use fwnode first */ + table = device_get_match_data(dev); + if (!table) + table = (struct max63xx_timeout *)pdev->id_entry->driver_data; if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT; @@ -255,11 +259,23 @@ static const struct platform_device_id max63xx_id_table[] = { }; MODULE_DEVICE_TABLE(platform, max63xx_id_table); +static const struct of_device_id max63xx_dt_id_table[] = { + { .compatible = "maxim,max6369", .data = max6369_table, }, + { .compatible = "maxim,max6370", .data = max6369_table, }, + { .compatible = "maxim,max6371", .data = max6371_table, }, + { .compatible = "maxim,max6372", .data = max6371_table, }, + { .compatible = "maxim,max6373", .data = max6373_table, }, + { .compatible = "maxim,max6374", .data = max6373_table, }, + { } +}; +MODULE_DEVICE_TABLE(of, max63xx_dt_id_table); + static struct platform_driver max63xx_wdt_driver = { .probe = max63xx_wdt_probe, .id_table = max63xx_id_table, .driver = { .name = "max63xx_wdt", + .of_match_table = max63xx_dt_id_table, }, };