From patchwork Fri Oct 29 15:00:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12592927 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 A857DC433EF for ; Fri, 29 Oct 2021 15:01:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84BF6610C7 for ; Fri, 29 Oct 2021 15:01:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbhJ2PDy (ORCPT ); Fri, 29 Oct 2021 11:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhJ2PDy (ORCPT ); Fri, 29 Oct 2021 11:03:54 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B506C061570; Fri, 29 Oct 2021 08:01:25 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id c28so21527242lfv.13; Fri, 29 Oct 2021 08:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EIMZ7pbSFB4v6PfIZ9phtnUvHe3NBf2JaKS4zkLAeYk=; b=PmRCir877CmYrnGpp7JJOnwVJrrB2MVpKB1X5QDJkhPzKsHbApM/QhNMkUEXe6kJVq 604s0kSdPuBBOKjp8Mq43bczETrjUugeShs7zLzYG894BsDUMWReiKADs/xMM5Tee+lr dtChxFNoCPGHupGxKJmSFumnB3ervj3Eze4CyukaCLn7nFyWmH7GHKHQWec2IAUrow0c s+U/Evjn7Tkpk0ee2hQXgZcN5RJb9LnvFtzU31seFC8gt/M9ernV/PmgnzZxznnTKoCB 1s5JPzaNGgTClOOr0wgrXIxl0od2mcXgpLUaqM4DD6Ue6PdDZ493wZqBrvEvLK+s/F36 L+kA== 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:mime-version :content-transfer-encoding; bh=EIMZ7pbSFB4v6PfIZ9phtnUvHe3NBf2JaKS4zkLAeYk=; b=0oy806fNHR0x5ynYcHvRhzBhRad8uk7lyjNjRWxt5FXHvo0cVRVgz+b9TZ+wObr+bQ pLR9fc8kdJsRYwpRDffN58DZg4mI4zkVfPOqjFhJEj7yBByw3MiLJEgc5id49x5elZWq 8gaggSxz2MEzy9cMnXPjsJ/R843TMWo5cC7edR37e4x0pk3w8pT5/+1codu+Npi93LNE U5HZlFBxliQRlMwChVPemvF3E9Sr8kEKH9nDzFjZHPygPZLH9MOwDJ/0tmnP6rCxV/Ok bMZP39cgqaBaVAeelxQ+VJKz3JeXdQ+3bl4uT4tqM7XZR4Mk3xGa5yNbocNRfvta/jr2 Wpcw== X-Gm-Message-State: AOAM5334Eya0nPAbLSlr652Mr7zYAaF2BP4iFIaXH5P/PAviCinOxUEM JnoodYGiplGnnf/zCmNs7ro= X-Google-Smtp-Source: ABdhPJxuH8Hus+kWGh9Ip1HJ0R5uZgd0JzbwBTrjSlXXw7zQ2P/NUMlv8JTd5gY53aQKRH91ke0IRQ== X-Received: by 2002:a05:6512:22cb:: with SMTP id g11mr10856273lfu.417.1635519682183; Fri, 29 Oct 2021 08:01:22 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id s13sm90358ljo.56.2021.10.29.08.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 08:01:21 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 1/3] dt-bindings: watchdog: convert Broadcom's WDT to the json-schema Date: Fri, 29 Oct 2021 17:00:49 +0200 Message-Id: <20211029150051.3955-1-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Rafał Miłecki This helps validating DTS files. Signed-off-by: Rafał Miłecki --- V2: Don't rename to bcm63xx Add driver authors as maintainers --- .../bindings/watchdog/brcm,bcm7038-wdt.txt | 19 --------- .../bindings/watchdog/brcm,bcm7038-wdt.yaml | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 19 deletions(-) delete mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt deleted file mode 100644 index 84122270be8f..000000000000 --- a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt +++ /dev/null @@ -1,19 +0,0 @@ -BCM7038 Watchdog timer - -Required properties: - -- compatible : should be "brcm,bcm7038-wdt" -- reg : Specifies base physical address and size of the registers. - -Optional properties: - -- clocks: The clock running the watchdog. If no clock is found the - driver will default to 27000000 Hz. - -Example: - -watchdog@f040a7e8 { - compatible = "brcm,bcm7038-wdt"; - clocks = <&upg_fixed>; - reg = <0xf040a7e8 0x16>; -}; diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml new file mode 100644 index 000000000000..69e5a1ef6a1f --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/watchdog/brcm,bcm63xx-wdt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: BCM7038 watchdog timer + +allOf: + - $ref: "watchdog.yaml#" + +maintainers: + - Florian Fainelli + - Justin Chen + - Rafał Miłecki + +properties: + compatible: + const: brcm,bcm7038-wdt + + reg: + maxItems: 1 + + clocks: + description: > + The clock running the watchdog. If no clock is found the driver will + default to 27000000 Hz. + +unevaluatedProperties: false + +required: + - reg + +examples: + - | + watchdog@f040a7e8 { + compatible = "brcm,bcm7038-wdt"; + reg = <0xf040a7e8 0x16>; + clocks = <&upg_fixed>; + }; From patchwork Fri Oct 29 15:00:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12592929 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 A1F54C433F5 for ; Fri, 29 Oct 2021 15:01:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80F96610C7 for ; Fri, 29 Oct 2021 15:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbhJ2PEA (ORCPT ); Fri, 29 Oct 2021 11:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbhJ2PD7 (ORCPT ); Fri, 29 Oct 2021 11:03:59 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00D6C061570; Fri, 29 Oct 2021 08:01:30 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id bi35so21576537lfb.9; Fri, 29 Oct 2021 08:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/b6PWU4w9zfHkPuFekl03q6QFFhlLfi6J3e36CAbEU4=; b=KiT99wrnLwyighneCh50CJxR2QlXoeyAf0CiTbvF2rxvr4PHwzVHZLvBnKZIo9Qbc7 qMB07U5lvDCWWzZELItjPJn/jznnGiC3XLlW/3vOjanNsZZ55BnBNnAEDqv5MbMcw30m ppIQThDvg5JAmYSEr01nTIyH9H0Dip5/3YeDks7brGrwkMJt5uFqM0hFFbqucPk72z0l tZKfZ68byHRm/AdbXwrGclfYhHmCBN0fzHDm/mKdTavVHKVFB0/yvic14SddtkncHM14 wJMl/0F3QalbG8poR0NOJS8UEiHsFsNQaQ0ylO9VigEsxqsbcJLVzd2wViJwqZoeh7vA thuQ== 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=/b6PWU4w9zfHkPuFekl03q6QFFhlLfi6J3e36CAbEU4=; b=qBLWXoGWYUqvSDQ16zJvkpLbDVm/PLdWB66J2y8FtCg784aE13P3UX0Y2jQsFsOX4/ WUScNM8Ssqg2QstY1wxU2jlPaNHU13QTtjJngr3Ah1oFLixy+TJXo2nSqFdFNmguaXDE JlSG/fgMSZpwXySnScaia7wDTGObskCXdiI/MjwzVe1URdQbEIeAGWspkkcyCNrVRK/j 6aw6M1wrAtrLvIhPJ+bbRquR97eNKPdrwpuWKe0ta7ssJWqjL95uyFdtZdKJ9vRW2v3T KpvtZJl/snsVelocSJcr+kLcTcEl+jHBrFLxdpc4mecofEQkCwAsERrOLRwQc5++0piV aPQA== X-Gm-Message-State: AOAM530viK1m5ncoAD+7PRhMEm0QJQ//ZPqWSaXB57B9ttiwVujEZViK PkL0EZvLBEGDe/ktk3oNktg= X-Google-Smtp-Source: ABdhPJyXAHxrcnvcJx8j3JPa3hhAhyTW05c9/UTEe6lOkHKwFqt7867BHDPZLafVJJ2huDGHKh/vvQ== X-Received: by 2002:a05:6512:38c4:: with SMTP id p4mr10654504lft.27.1635519687844; Fri, 29 Oct 2021 08:01:27 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id s13sm90358ljo.56.2021.10.29.08.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 08:01:27 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 2/3] dt-bindings: watchdog: brcm,bcm63xx-wdt: add BCM4908 compatibility Date: Fri, 29 Oct 2021 17:00:50 +0200 Message-Id: <20211029150051.3955-2-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211029150051.3955-1-zajec5@gmail.com> References: <20211029150051.3955-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Rafał Miłecki BCM4908 is another SoC with the same hardware block. It just uses a slightly different registers layout. Signed-off-by: Rafał Miłecki --- V2: Update title --- .../devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml index 69e5a1ef6a1f..5e37bf47efe8 100644 --- a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/watchdog/brcm,bcm63xx-wdt.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: BCM7038 watchdog timer +title: BCM4908 and BCM7038 watchdog timer allOf: - $ref: "watchdog.yaml#" @@ -16,7 +16,9 @@ maintainers: properties: compatible: - const: brcm,bcm7038-wdt + enum: + - brcm,bcm4908-wdt + - brcm,bcm7038-wdt reg: maxItems: 1 From patchwork Fri Oct 29 15:00:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12592931 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 DF912C433F5 for ; Fri, 29 Oct 2021 15:01:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C428261175 for ; Fri, 29 Oct 2021 15:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbhJ2PED (ORCPT ); Fri, 29 Oct 2021 11:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbhJ2PEC (ORCPT ); Fri, 29 Oct 2021 11:04:02 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03943C061570; Fri, 29 Oct 2021 08:01:34 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id bi35so21576907lfb.9; Fri, 29 Oct 2021 08:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=POI671egV+JT5DmVV8hgnUJu1/BtlTBpN4RvR23Avbk=; b=R9hkJSJqC5/XUnefXE3XpzDh/dqHF69SgarQlekH0rRN5WOscJGEzaLu/GrLOhdxwj 721cvHU++LHvac/9Yzt0JM/RLvuTHUqMyH5+ErOVqjKwj2dinKME8ipEOXZmtgcH1vuY xUMnglbOzPkgb/VV3LDP/+I2sZ6SvD7Mo10dJEUOCivyZuNQmvsN2ASmAAqY8jU0JpWJ lwtPywBFGfzAheL0fzd41VEB3CPSeKbiutt0SmxHVQ3vQWymEmkAn5GXthSrfQAlb6gq khE98iDNtmukSfCJ+9RWURkiMg1VYxbYxQ1mvRiMrPH7CLe60xB9Dru8vSJIikPTczya Vaeg== 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=POI671egV+JT5DmVV8hgnUJu1/BtlTBpN4RvR23Avbk=; b=PlOsNuJd/Oxfq6WXZp2/eM/P3Hd2Zq0ZvZQvrk3nd2JphahlpbTSzwlfAYXq2iWwEZ UKY3ttZgTN3mtsWys4t05mbgM3q90OPx4j5aPZIzKMFDCdAbLcLeB8Gmy350ihNuyim5 wISHHmUJzzfGmHU4SLzKeMjDjUw2MP4iLIELQPTKVRlKoIqvTFX0ruhzm6SsQjarhcTB N+XU3udG40pm4NqOjwFZF+6O/N7uGxFk1Tyrl2hYtoSRULhPlmEnHrjFNuReEqvgpgcG Qt9oa26qrx1jo28EFtuJ61G6CG7/d1ph5jiCIT8+JAW8k7pBxV8cYTaUIkneUdZhsqsW YfCQ== X-Gm-Message-State: AOAM532i8YkOto74B85r0lLtVq8auXRg4VP+PQGrouF5r9qO3WcXNjbi IH8PsV3DhvdtpkcjnP2+Avw= X-Google-Smtp-Source: ABdhPJyU/Il6ZM3I3exBvsbI2kvDQMEoGYkRXwj9DMjl5HtnA7skrG0r9o4wpOqzZWBKaGJ0JIgYAg== X-Received: by 2002:ac2:562c:: with SMTP id b12mr10495475lff.422.1635519690700; Fri, 29 Oct 2021 08:01:30 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id s13sm90358ljo.56.2021.10.29.08.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 08:01:30 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Wim Van Sebroeck , Guenter Roeck , Rob Herring Cc: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 3/3] watchdog: bcm7038_wdt: support BCM4908 SoC Date: Fri, 29 Oct 2021 17:00:51 +0200 Message-Id: <20211029150051.3955-3-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211029150051.3955-1-zajec5@gmail.com> References: <20211029150051.3955-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Rafał Miłecki Hardware supported by this driver goes back to the old bcm63xx days. It was then reused in BCM7038 and later also in BCM4908. Depending on SoC model registers layout differs a bit. This commit introduces support for per-chipset registers offsets & adds BCM4908 layout. Signed-off-by: Rafał Miłecki --- V2: Simplify commit message Use registers names matching Broadcom's SDK / docs --- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/bcm7038_wdt.c | 89 ++++++++++++++++++++++++++-------- 2 files changed, 69 insertions(+), 22 deletions(-) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 0fab8230b663..ca600e6d21be 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1743,7 +1743,7 @@ config BCM7038_WDT tristate "BCM7038 Watchdog" select WATCHDOG_CORE depends on HAS_IOMEM - depends on ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST + depends on ARCH_BCM4908 || ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST help Watchdog driver for the built-in hardware in Broadcom 7038 and later SoCs used in set-top boxes. BCM7038 was made public diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c index acaaa0005d5b..79408c4f2615 100644 --- a/drivers/watchdog/bcm7038_wdt.c +++ b/drivers/watchdog/bcm7038_wdt.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -18,14 +19,17 @@ #define WDT_STOP_1 0xee00 #define WDT_STOP_2 0x00ee -#define WDT_TIMEOUT_REG 0x0 -#define WDT_CMD_REG 0x4 - #define WDT_MIN_TIMEOUT 1 /* seconds */ #define WDT_DEFAULT_TIMEOUT 30 /* seconds */ #define WDT_DEFAULT_RATE 27000000 +enum bcm7038_wdt_soc { + BCM7038_WDT_SOC_BCM4908, + BCM7038_WDT_SOC_BCM7038, +}; + struct bcm7038_watchdog { + enum bcm7038_wdt_soc soc; void __iomem *base; struct watchdog_device wdd; u32 rate; @@ -34,8 +38,52 @@ struct bcm7038_watchdog { static bool nowayout = WATCHDOG_NOWAYOUT; -static inline void bcm7038_wdt_write(u32 value, void __iomem *addr) +static const struct of_device_id bcm7038_wdt_match[] = { + { .compatible = "brcm,bcm4908-wdt", .data = (const void *)BCM7038_WDT_SOC_BCM4908, }, + { .compatible = "brcm,bcm7038-wdt", .data = (const void *)BCM7038_WDT_SOC_BCM7038, }, + {}, +}; +MODULE_DEVICE_TABLE(of, bcm7038_wdt_match); + +enum bcm7038_wdt_regs { + BCM7038_WDT_REG_DEF_COUNT = 0, + BCM7038_WDT_REG_CTL, + BCM7038_WDT_REG_SOFT_RST, +}; + +static const u16 bcm7038_wdt_regs_bcm4908[] = { + [BCM7038_WDT_REG_DEF_COUNT] = 0x28, + [BCM7038_WDT_REG_CTL] = 0x2c, + [BCM7038_WDT_REG_SOFT_RST] = 0x34, +}; + +static const u16 bcm7038_wdt_regs_bcm7038[] = { + [BCM7038_WDT_REG_DEF_COUNT] = 0x00, + [BCM7038_WDT_REG_CTL] = 0x04, +}; + +static void __iomem *bcm7038_wdt_reg_addr(struct watchdog_device *wdog, + enum bcm7038_wdt_regs reg) { + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + void __iomem *addr = wdt->base; + + switch (wdt->soc) { + case BCM7038_WDT_SOC_BCM4908: + return addr + bcm7038_wdt_regs_bcm4908[reg]; + case BCM7038_WDT_SOC_BCM7038: + return addr + bcm7038_wdt_regs_bcm7038[reg]; + default: + WARN_ON(1); + return NULL; + } +} + +static void bcm7038_wdt_write(struct watchdog_device *wdog, + enum bcm7038_wdt_regs reg, u32 value) +{ + void __iomem *addr = bcm7038_wdt_reg_addr(wdog, reg); + /* MIPS chips strapped for BE will automagically configure the * peripheral registers for CPU-native byte order. */ @@ -45,8 +93,11 @@ static inline void bcm7038_wdt_write(u32 value, void __iomem *addr) writel_relaxed(value, addr); } -static inline u32 bcm7038_wdt_read(void __iomem *addr) +static inline u32 bcm7038_wdt_read(struct watchdog_device *wdog, + enum bcm7038_wdt_regs reg) { + void __iomem *addr = bcm7038_wdt_reg_addr(wdog, reg); + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) return __raw_readl(addr); else @@ -60,15 +111,13 @@ static void bcm7038_wdt_set_timeout_reg(struct watchdog_device *wdog) timeout = wdt->rate * wdog->timeout; - bcm7038_wdt_write(timeout, wdt->base + WDT_TIMEOUT_REG); + bcm7038_wdt_write(wdog, BCM7038_WDT_REG_DEF_COUNT, timeout); } static int bcm7038_wdt_ping(struct watchdog_device *wdog) { - struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); - - bcm7038_wdt_write(WDT_START_1, wdt->base + WDT_CMD_REG); - bcm7038_wdt_write(WDT_START_2, wdt->base + WDT_CMD_REG); + bcm7038_wdt_write(wdog, BCM7038_WDT_REG_CTL, WDT_START_1); + bcm7038_wdt_write(wdog, BCM7038_WDT_REG_CTL, WDT_START_2); return 0; } @@ -83,10 +132,8 @@ static int bcm7038_wdt_start(struct watchdog_device *wdog) static int bcm7038_wdt_stop(struct watchdog_device *wdog) { - struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); - - bcm7038_wdt_write(WDT_STOP_1, wdt->base + WDT_CMD_REG); - bcm7038_wdt_write(WDT_STOP_2, wdt->base + WDT_CMD_REG); + bcm7038_wdt_write(wdog, BCM7038_WDT_REG_CTL, WDT_STOP_1); + bcm7038_wdt_write(wdog, BCM7038_WDT_REG_CTL, WDT_STOP_2); return 0; } @@ -107,7 +154,7 @@ static unsigned int bcm7038_wdt_get_timeleft(struct watchdog_device *wdog) struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); u32 time_left; - time_left = bcm7038_wdt_read(wdt->base + WDT_CMD_REG); + time_left = bcm7038_wdt_read(wdog, BCM7038_WDT_REG_CTL); return time_left / wdt->rate; } @@ -134,6 +181,7 @@ static void bcm7038_clk_disable_unprepare(void *data) static int bcm7038_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct of_device_id *of_id; struct bcm7038_watchdog *wdt; int err; @@ -143,6 +191,11 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, wdt); + of_id = of_match_device(bcm7038_wdt_match, dev); + if (!of_id) + return -EINVAL; + wdt->soc = (enum bcm7038_wdt_soc)of_id->data; + wdt->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); @@ -211,12 +264,6 @@ static int bcm7038_wdt_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(bcm7038_wdt_pm_ops, bcm7038_wdt_suspend, bcm7038_wdt_resume); -static const struct of_device_id bcm7038_wdt_match[] = { - { .compatible = "brcm,bcm7038-wdt" }, - {}, -}; -MODULE_DEVICE_TABLE(of, bcm7038_wdt_match); - static struct platform_driver bcm7038_wdt_driver = { .probe = bcm7038_wdt_probe, .driver = {