Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1593723imd; Sun, 4 Nov 2018 06:01:22 -0800 (PST) X-Google-Smtp-Source: AJdET5czyZhWlzicULyCUi+HKpqQgm2HpkqLTq/aC4ihLwJRdetViYLi5xwL/eVeIL0nKlp4PlVB X-Received: by 2002:a63:78cd:: with SMTP id t196mr14496148pgc.62.1541340082322; Sun, 04 Nov 2018 06:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340082; cv=none; d=google.com; s=arc-20160816; b=Zyu4CXnVpmYMakmPgGHiT7y1wUChRerqALSGWQcH/bqcffuaihpQ6U9uzDT+y0KyGR UpgwwieJooQzDbD1/94Hldc8FCIngWChXJQ9KL/TaplMJUSuXaMPWyvINIjX4b56g1Hd gTd2Ql7QaKiZPKdl9hvUOwD4e+sDqNS56h/uvKqm9sWRV023ToONmxLjcXp9fP1SIaSE ACcpyJ2xG4RiB2bnFajXWfliF3rHkBXZN0E3x7aDSfYytHAzibrZslrRRq6gnvD2+J1B Y9wl0adtRjPIaxlNaqpt9uv+YmLqKAAjNUR0qswlfvEVodwwfrDIgl5VIHgkK4GDlPdH CWpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=70k4LOkBBcZMOMNQXvX14quu71VJ3PtQvvLEoHVHZsY=; b=XM5w46QP2lkyJF71KAYVCbFhqkT8lgH5ncnyu8Z/2UIihMeTkeKF1WKfSAuM1wD6yu Qmi+W7dNFcOtOj3LibAqsEulVcUEzmjlvL8s7vrC0nl1DEvUMAkm/9ykgzjSo07u4y2L HJaHM2U96dNGdyIRzKp/GRigM6FbyPDhjKv10gXVVDDVYMA1jas01ZIzQo2vIAgLWTI9 pewFWP+03gW+hbb/GpCbVYi9IBuFtqS1tsGAjm4MIvvQKNStM4D8tGob2IfgiP8yHWqG zbg5y0GxuhUMPS7+UvccpgQYQIRk55ytCcG5nYSZzwYSWPhCMLLmXJJgSFmp81k6SJb6 TIjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BlSz8jwV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9-v6si43809767plb.400.2018.11.04.06.01.07; Sun, 04 Nov 2018 06:01:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BlSz8jwV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731274AbeKDXIp (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:47746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731258AbeKDXIo (ORCPT ); Sun, 4 Nov 2018 18:08:44 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B1C8020869; Sun, 4 Nov 2018 13:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339619; bh=d7d+/b8KEYKbeSobYIn85OkLPF9eczPbkR8HZZApMcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlSz8jwVt8Ji2NGbMFv79DRPE5OqYDxySzWO8PfjCcqAgFazpY06oEfcGDSeB+p/6 3bB8Nxz4MZMpJw6YT6mF2TZzkT+uxJKp3ZHK8TSEuoMSTmTWLfHXqHDmh8tipO/G5L IRLT5xtiujEMVMeZkFIpxdcFdFCONn2/GKCDAjps= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hauke Mehrtens , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH AUTOSEL 4.14 13/30] watchdog: lantiq: update register names to better match spec Date: Sun, 4 Nov 2018 08:53:08 -0500 Message-Id: <20181104135325.88524-13-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hauke Mehrtens [ Upstream commit 1f59f8aff98f200af7a6882184add7b85f5da741 ] Some of the names of the bits were confusing to me. Now the bits share the same prefix as the register they are set on. The LTQ_WDT_CR_PWL register (bits 26:25) is the pre warning limit and it does not turn anything on. It has 4 possible divers 1/2, 1/4, 1/8 and 1/16, this drivers only uses 1/16. The LTQ_WDT_CR_CLKDIV register bits(25:24) is only configuring a clock divers and do not turn any thing on too, all possible values are valid dividers. Using the LTQ_WDT_SR prefix is also wrong these bits are used in the LTQ_WDT_CR registers, SR is the status register which is read only. This uses GENMASK where it is a mask and it uses shifts when a value is written to some bits. Signed-off-by: Hauke Mehrtens Reviewed-by: Guenter Roeck Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- drivers/watchdog/lantiq_wdt.c | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/watchdog/lantiq_wdt.c b/drivers/watchdog/lantiq_wdt.c index 7f43cefa0eae..a086005fbaac 100644 --- a/drivers/watchdog/lantiq_wdt.c +++ b/drivers/watchdog/lantiq_wdt.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -40,18 +41,19 @@ * essentially the following two magic passwords need to be written to allow * IO access to the WDT core */ -#define LTQ_WDT_PW1 0x00BE0000 -#define LTQ_WDT_PW2 0x00DC0000 +#define LTQ_WDT_CR_PW1 0x00BE0000 +#define LTQ_WDT_CR_PW2 0x00DC0000 + +#define LTQ_WDT_CR 0x0 /* watchdog control register */ +#define LTQ_WDT_CR_GEN BIT(31) /* enable bit */ +/* Pre-warning limit set to 1/16 of max WDT period */ +#define LTQ_WDT_CR_PWL (0x3 << 26) +/* set clock divider to 0x40000 */ +#define LTQ_WDT_CR_CLKDIV (0x3 << 24) +#define LTQ_WDT_CR_PW_MASK GENMASK(23, 16) /* Password field */ +#define LTQ_WDT_CR_MAX_TIMEOUT ((1 << 16) - 1) /* The reload field is 16 bit */ -#define LTQ_WDT_CR 0x0 /* watchdog control register */ -#define LTQ_WDT_SR 0x8 /* watchdog status register */ - -#define LTQ_WDT_SR_EN (0x1 << 31) /* enable bit */ -#define LTQ_WDT_SR_PWD (0x3 << 26) /* turn on power */ -#define LTQ_WDT_SR_CLKDIV (0x3 << 24) /* turn on clock and set */ - /* divider to 0x40000 */ #define LTQ_WDT_DIVIDER 0x40000 -#define LTQ_MAX_TIMEOUT ((1 << 16) - 1) /* the reload field is 16 bit */ static bool nowayout = WATCHDOG_NOWAYOUT; @@ -68,26 +70,26 @@ ltq_wdt_enable(void) { unsigned long int timeout = ltq_wdt_timeout * (ltq_io_region_clk_rate / LTQ_WDT_DIVIDER) + 0x1000; - if (timeout > LTQ_MAX_TIMEOUT) - timeout = LTQ_MAX_TIMEOUT; + if (timeout > LTQ_WDT_CR_MAX_TIMEOUT) + timeout = LTQ_WDT_CR_MAX_TIMEOUT; /* write the first password magic */ - ltq_w32(LTQ_WDT_PW1, ltq_wdt_membase + LTQ_WDT_CR); + ltq_w32(LTQ_WDT_CR_PW1, ltq_wdt_membase + LTQ_WDT_CR); /* write the second magic plus the configuration and new timeout */ - ltq_w32(LTQ_WDT_SR_EN | LTQ_WDT_SR_PWD | LTQ_WDT_SR_CLKDIV | - LTQ_WDT_PW2 | timeout, ltq_wdt_membase + LTQ_WDT_CR); + ltq_w32(LTQ_WDT_CR_GEN | LTQ_WDT_CR_PWL | LTQ_WDT_CR_CLKDIV | + LTQ_WDT_CR_PW2 | timeout, ltq_wdt_membase + LTQ_WDT_CR); } static void ltq_wdt_disable(void) { /* write the first password magic */ - ltq_w32(LTQ_WDT_PW1, ltq_wdt_membase + LTQ_WDT_CR); + ltq_w32(LTQ_WDT_CR_PW1, ltq_wdt_membase + LTQ_WDT_CR); /* * write the second password magic with no config * this turns the watchdog off */ - ltq_w32(LTQ_WDT_PW2, ltq_wdt_membase + LTQ_WDT_CR); + ltq_w32(LTQ_WDT_CR_PW2, ltq_wdt_membase + LTQ_WDT_CR); } static ssize_t -- 2.17.1