From patchwork Tue Jun 25 14:11:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11015631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5086114BB for ; Tue, 25 Jun 2019 14:11:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40E6E28515 for ; Tue, 25 Jun 2019 14:11:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3512828672; Tue, 25 Jun 2019 14:11:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F2C728515 for ; Tue, 25 Jun 2019 14:11:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728155AbfFYOLQ (ORCPT ); Tue, 25 Jun 2019 10:11:16 -0400 Received: from mail-eopbgr30071.outbound.protection.outlook.com ([40.107.3.71]:54798 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726532AbfFYOLP (ORCPT ); Tue, 25 Jun 2019 10:11:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=testarcselector01; d=microsoft.com; cv=none; b=ZTnUaj7tnqHpWsIyRs8y/yXSArDjwxyKHFFQURwoYPWsDFCJ8BA0bORgvWetDL3SU4PQQGI1gV7OdJKjd0092uF8jnfl6O9u4F8Uwq8tg3V3/l3CpfDX1iykqBH0+t7YwRPGW6MAzCULkixFbIOe3lJXMU5pTfMupE3zp22YBMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=testarcselector01; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=licgEvuWqSKKRsnZwwdFp8zA58TFSt8Dggk/QNsUy8g=; b=ezCvpK9wkAVG62h8elUScqIby7hPrje4v5TN1ods3V28fCKf2vQDXfT2jmwbhB90S/4/V5mCE9m+7Ov86eclUUZo4mBgHTCZm20ZSU3jihaXQ6EF2q/K8TgPBVi/7/nB66zKSRtCyxBOuy/l7NV/HMDQibKugaYiX/P6Eb+sLpw= ARC-Authentication-Results: i=1; test.office365.com 1;spf=none;dmarc=none;dkim=none;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vaisala.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=licgEvuWqSKKRsnZwwdFp8zA58TFSt8Dggk/QNsUy8g=; b=fTv1c/bkqBVgGsejLn1mE6yEI1zud1aleBJIJ5bxQinVCGW8X0uDTD5r3wdK1HTDiAhGTRUTu89yuvuv4cFmPmqmi59pZj9fUwCD1YVIK0rY1uyJm61IXSzJdMuh38wpakX8XzUmqmH9yZxRdBZ66ZKoTFMc0LolEmXHgVKlPR0= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB6001.eurprd06.prod.outlook.com (20.178.112.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Tue, 25 Jun 2019 14:11:12 +0000 Received: from AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::5590:e3b3:5416:e9eb]) by AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::5590:e3b3:5416:e9eb%5]) with mapi id 15.20.2008.014; Tue, 25 Jun 2019 14:11:11 +0000 From: Melin Tomas To: "wim@linux-watchdog.org" , "linux@roeck-us.net" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH] watchdog: cadence: Support all available prescaler values Thread-Topic: [PATCH] watchdog: cadence: Support all available prescaler values Thread-Index: AQHVK1/XA87KPv3AR0aVKfsrVv0YIA== Date: Tue, 25 Jun 2019 14:11:11 +0000 Message-ID: <20190625141048.99479-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0202CA0007.eurprd02.prod.outlook.com (2603:10a6:3:8c::17) To AM0PR06MB4066.eurprd06.prod.outlook.com (2603:10a6:208:b8::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=tomas.melin@vaisala.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.2 x-originating-ip: [193.143.230.131] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 18dd0b3c-04e6-473d-7168-08d6f976fa05 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB6001; x-ms-traffictypediagnostic: AM0PR06MB6001: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2276; x-forefront-prvs: 0079056367 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(39850400004)(366004)(346002)(376002)(136003)(189003)(199004)(66066001)(71190400001)(71200400001)(99286004)(52116002)(2906002)(5660300002)(36756003)(14454004)(256004)(305945005)(7736002)(2501003)(316002)(107886003)(50226002)(66946007)(478600001)(8936002)(81156014)(81166006)(3846002)(68736007)(25786009)(2616005)(66556008)(4326008)(66476007)(64756008)(110136005)(66446008)(54906003)(6486002)(73956011)(53936002)(102836004)(8676002)(486006)(26005)(1076003)(386003)(6506007)(186003)(86362001)(476003)(6436002)(6116002)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB6001;H:AM0PR06MB4066.eurprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: vaisala.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 3ld5uJMaokSprDQnNPL8/MHuXE85vgIP3RaX+glWnwWOnoK3RVVO37hBO1QOSljBe0Efz2DySf1j6+GccT8fFBsa+Yrfv4CESXCaGuArcwvfdQSNOhdaWDnxmeC3JPx5X8EycfsoeBDox2LQExeAfHYL3tgC1CuNBB+jXLUARf2OQQrAFH0PNdnLMXe1JNyDKmQxdEZSbD4bvjAgnaTDRGFey2E7SPHO5csIw3ldPK1Q2lBRTWjsXSXbOs9zhjR7fKRrKt06VWJ+j7O2JUc7wltGfB4uNuRHFdJRCKOW4wBtuGTWxnmGE+DSNrmM7Aq+PF+9udv13Z4HR+iQRSlJDaIr6awzStM3nWexFDSIOFH446p8DQCp93eVXi4hlZ9bV1lOocZ/WJJzyw3C+t+Pg9fRzhfJ5G+Pt9kkrlPGsco= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18dd0b3c-04e6-473d-7168-08d6f976fa05 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2019 14:11:11.9229 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: tomas.melin@vaisala.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR06MB6001 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cadence watchdog HW supports prescaler values of 8, 64, 512 and 4096. For low frequency input clocks, the smaller prescaler values are preferrable to improve the granularity and extend the timeout range towards the lower end. Prescaler logic is extended to support timeout values [1s - 4095s], with prescaler selected based on input clock frequency. For clock frequencies higher than ~2 MHz, the largest prescaler value is used. Signed-off-by: Tomas Melin --- drivers/watchdog/cadence_wdt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index c3924356d173..65191183ecd8 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -32,16 +32,17 @@ #define CDNS_WDT_COUNTER_VALUE_DIVISOR 0x1000 /* Clock prescaler value and selection */ +#define CDNS_WDT_PRESCALE_8 8 #define CDNS_WDT_PRESCALE_64 64 #define CDNS_WDT_PRESCALE_512 512 #define CDNS_WDT_PRESCALE_4096 4096 +#define CDNS_WDT_PRESCALE_SELECT_8 0 #define CDNS_WDT_PRESCALE_SELECT_64 1 #define CDNS_WDT_PRESCALE_SELECT_512 2 #define CDNS_WDT_PRESCALE_SELECT_4096 3 -/* Input clock frequency */ -#define CDNS_WDT_CLK_10MHZ 10000000 -#define CDNS_WDT_CLK_75MHZ 75000000 +/* Base input clock frequency */ +#define CDNS_WDT_CLK_32KHZ 32768 /* Counter maximum value */ #define CDNS_WDT_COUNTER_MAX 0xFFF @@ -348,7 +349,13 @@ static int cdns_wdt_probe(struct platform_device *pdev) } clock_f = clk_get_rate(wdt->clk); - if (clock_f <= CDNS_WDT_CLK_75MHZ) { + if (clock_f <= CDNS_WDT_CLK_32KHZ) { + wdt->prescaler = CDNS_WDT_PRESCALE_8; + wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_8; + } else if (clock_f <= CDNS_WDT_CLK_32KHZ * CDNS_WDT_PRESCALE_8) { + wdt->prescaler = CDNS_WDT_PRESCALE_64; + wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_64; + } else if (clock_f <= CDNS_WDT_CLK_32KHZ * CDNS_WDT_PRESCALE_64) { wdt->prescaler = CDNS_WDT_PRESCALE_512; wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_512; } else {