From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E781C54E8A for ; Sun, 10 May 2020 10:58:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89D3A214DB for ; Sun, 10 May 2020 10:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726629AbgEJK6c (ORCPT ); Sun, 10 May 2020 06:58:32 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:46516 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgEJK6b (ORCPT ); Sun, 10 May 2020 06:58:31 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 569BC8030802; Sun, 10 May 2020 10:58:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4ZvitKkdah1v; Sun, 10 May 2020 13:58:25 +0300 (MSK) From: Serge Semin To: Wim Van Sebroeck , Guenter Roeck CC: Serge Semin , Serge Semin , Alexey Malahov , Maxim Kaurkin , Pavel Parkhomenko , Ramil Zaripov , Ekaterina Skachko , Vadim Vlasov , Alexey Kolotnikov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , Arnd Bergmann , Philipp Zabel , Rob Herring , , , , Subject: [PATCH v2 0/7] watchdog: dw_wdt: Take Baikal-T1 DW WDT peculiarities into account Date: Sun, 10 May 2020 13:58:00 +0300 Message-ID: <20200510105807.880-1-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200306132758.703FC8030704@mail.baikalelectronics.ru> References: <20200306132758.703FC8030704@mail.baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org There were a few features enabled at the time of the Baikal-T1 SoC DW WDT IP synthesis, which weren't taken into account in the DW WDT driver available in the kernel. First of all the SoC engineers synthesized the watchdog core with WDT_USE_FIX_TOP set to false (don't really know why, but they did). Due to this the timer reset values weren't fixed as the driver expected but were initialized with a pre-defined values selected by the engineers. Secondly the driver expected that the watchdog APB bus and the timer had synchronous reference clocks, while Baikal-T1 SoC DW WDT was created with asynchronous ones. So the driver should enable two clock devices: APB bus clocks and a separate timer reference clock. Finally DW Watchdog Timer is capable of generating a pre-timeout interrupt if corresponding config is enabled. The problem was that the pre-timeout IRQ happens when the set timeout elapses, while the actual WDT expiration and subsequent reboot take place in the next timeout. This makes the pre-timeout functionality implementation a bit tricky, since in this case we would have to find a WDT timeout twice smaller the requested timeout. All of the changes described above are provided by the patches in this patchset. In addition traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one and added the controller registers dump DebugFS node to ease the driver debug procedure. This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4: base-commit: 0e698dfa2822 ("Linux 5.7-rc4") tag: v5.7-rc4 Changelog v2: - Rearrange SoBs. - Discard BE copyright header from the binding file. - Replace "additionalProperties: false" with "unevaluatedProperties: false" property in the binding. - Move the APB3 clocks support declared in the dt binding file into a dedicated patch. - Move $ref to the root level of the "snps,watchdog-tops" property so does the constraints. - Make Pre-timeout IRQs support being optional. - Add "ms" suffix to the methods returning msec and convert the methods with no "ms" suffix to return a timeout in sec. - Make sure minimum timeout is at least 1 sec. - Refactor the timeouts calculation procedure to to retain the timeouts in the ascending order. - Make sure there is no integer overflow in milliseconds calculation. It is saved in a dedicated uint field of the timeout structure. - Discard timeout/pretimeout/ping/enable DebugFS nodes. Registers state dump node is only left. Signed-off-by: Serge Semin Cc: Alexey Malahov Cc: Maxim Kaurkin Cc: Pavel Parkhomenko Cc: Ramil Zaripov Cc: Ekaterina Skachko Cc: Vadim Vlasov Cc: Alexey Kolotnikov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle Cc: Arnd Bergmann Cc: Philipp Zabel Cc: Rob Herring Cc: linux-mips@vger.kernel.org Cc: linux-watchdog@vger.kernel.org Cc: devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org Serge Semin (7): dt-bindings: watchdog: Convert DW WDT binding to DT schema dt-bindings: watchdog: dw-wdt: Support devices with asynch clocks dt-bindings: watchdog: dw-wdt: Add watchdog TOPs array property watchdog: dw_wdt: Support devices with non-fixed TOP values watchdog: dw_wdt: Support devices with asynch clocks watchdog: dw_wdt: Add pre-timeouts support watchdog: dw_wdt: Add DebugFS files .../devicetree/bindings/watchdog/dw_wdt.txt | 24 - .../bindings/watchdog/snps,dw-wdt.yaml | 91 ++++ drivers/watchdog/dw_wdt.c | 437 ++++++++++++++++-- 3 files changed, 495 insertions(+), 57 deletions(-) delete mode 100644 Documentation/devicetree/bindings/watchdog/dw_wdt.txt create mode 100644 Documentation/devicetree/bindings/watchdog/snps,dw-wdt.yaml -- 2.25.1