From patchwork Fri Jul 5 11:46:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11032513 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 47226912 for ; Fri, 5 Jul 2019 11:46:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3678828A51 for ; Fri, 5 Jul 2019 11:46:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B0B528A5A; Fri, 5 Jul 2019 11:46:08 +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 B909D28A51 for ; Fri, 5 Jul 2019 11:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbfGELqH (ORCPT ); Fri, 5 Jul 2019 07:46:07 -0400 Received: from mail-eopbgr150055.outbound.protection.outlook.com ([40.107.15.55]:29927 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727700AbfGELqH (ORCPT ); Fri, 5 Jul 2019 07:46:07 -0400 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=WHUQjpCcgi1RopfW+MOLGOMmv6mrsXmN+FmTxSirEDY=; b=KmFmVRSVc2B4O/kZCC+k626csv229qSJez/LdXFrVOjIU9uWbl5VQRalcQS19cz5kWMAODpmRStw6fLo1dLUnRKavhmUPIYc3mo0VtdnD/VVxC4HhwevR7sJjit2jcyj0/Nx5/InK5jzc3LFyCFE6DDeFG6fRUtTcc48rdlPYgY= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB5891.eurprd06.prod.outlook.com (20.178.112.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.19; Fri, 5 Jul 2019 11:46:02 +0000 Received: from AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9]) by AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9%7]) with mapi id 15.20.2052.010; Fri, 5 Jul 2019 11:46:02 +0000 From: Melin Tomas To: "wim@linux-watchdog.org" , "linux@roeck-us.net" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v2 1/4] watchdog: cadence_wdt: Move clock detection eariler in probe Thread-Topic: [PATCH v2 1/4] watchdog: cadence_wdt: Move clock detection eariler in probe Thread-Index: AQHVMyc4gSC92280O0OBonrHi42XTQ== Date: Fri, 5 Jul 2019 11:46:02 +0000 Message-ID: <20190705114522.42565-2-tomas.melin@vaisala.com> References: <20190705114522.42565-1-tomas.melin@vaisala.com> In-Reply-To: <20190705114522.42565-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0901CA0051.eurprd09.prod.outlook.com (2603:10a6:3:45::19) 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: ce7f0d50-907b-41b1-1acd-08d7013e5ad9 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB5891; x-ms-traffictypediagnostic: AM0PR06MB5891: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:2201; x-forefront-prvs: 008960E8EC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(136003)(346002)(376002)(39850400004)(366004)(199004)(189003)(52116002)(53936002)(6512007)(6436002)(66066001)(6506007)(25786009)(386003)(6486002)(478600001)(3846002)(6116002)(2501003)(68736007)(50226002)(76176011)(99286004)(107886003)(36756003)(26005)(316002)(4326008)(102836004)(54906003)(110136005)(186003)(71190400001)(71200400001)(5660300002)(2906002)(7736002)(305945005)(14444005)(476003)(446003)(11346002)(2616005)(1076003)(8936002)(66476007)(66556008)(64756008)(66446008)(86362001)(8676002)(256004)(486006)(73956011)(66946007)(81166006)(14454004)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB5891;H:AM0PR06MB4066.eurprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: oc3DYPA6NrlVgL0PJ6forV0hwFwGZmE8hKfHUtgb/oF7gf4BSfb+p8wOT4DPBBWuTNzazO46HV1iXfl/mZU8RMaJ7Et/t+879Rmkf+OB+4GLhyVDMLiNkkrwi8T+32rGkNraO+6YHc1gail4a7cR/wTQ/6rpJuHQ7tLUHc1LGtnourG/i22RDffonqMEB6DxLiHnFs9ATDbwTwRZ6YO9hzFUBirF7d+DvaAmL6hhqyy3a/30t5rj4rVCX92K0Kegzdg7GwG/XRRmVcwEt2TP70VkRk1HTzAXwsP4CHSBkqGmXBh06jAwPQSlFzYxqPBu6LFhGjJCOHbPh4jd8cVUng1bZGP9//G0LgcZY0xYlK98Nius6HPgowHd2wOGcbHjAxmrLD/iY+Ha94V3vvFGx4Y8GFnyXDVttdGla7MXbJY= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce7f0d50-907b-41b1-1acd-08d7013e5ad9 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2019 11:46:02.2690 (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: AM0PR06MB5891 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 Timeout calculation needs clock frequency, so init clock and calculate prescaler value eariler in the probe. Preparational step for calculating maximum and minimum timeout values for driver. Signed-off-by: Tomas Melin --- drivers/watchdog/cadence_wdt.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index c3924356d173..415bd6dd1edb 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -295,6 +295,22 @@ static int cdns_wdt_probe(struct platform_device *pdev) if (!wdt) return -ENOMEM; + wdt->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(wdt->clk)) { + dev_err(&pdev->dev, "input clock not found\n"); + ret = PTR_ERR(wdt->clk); + return ret; + } + + clock_f = clk_get_rate(wdt->clk); + if (clock_f <= CDNS_WDT_CLK_75MHZ) { + wdt->prescaler = CDNS_WDT_PRESCALE_512; + wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_512; + } else { + wdt->prescaler = CDNS_WDT_PRESCALE_4096; + wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_4096; + } + cdns_wdt_device = &wdt->cdns_wdt_device; cdns_wdt_device->info = &cdns_wdt_info; cdns_wdt_device->ops = &cdns_wdt_ops; @@ -334,28 +350,12 @@ static int cdns_wdt_probe(struct platform_device *pdev) watchdog_stop_on_reboot(cdns_wdt_device); watchdog_set_drvdata(cdns_wdt_device, wdt); - wdt->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(wdt->clk)) { - dev_err(&pdev->dev, "input clock not found\n"); - ret = PTR_ERR(wdt->clk); - return ret; - } - ret = clk_prepare_enable(wdt->clk); if (ret) { dev_err(&pdev->dev, "unable to enable clock\n"); return ret; } - clock_f = clk_get_rate(wdt->clk); - if (clock_f <= CDNS_WDT_CLK_75MHZ) { - wdt->prescaler = CDNS_WDT_PRESCALE_512; - wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_512; - } else { - wdt->prescaler = CDNS_WDT_PRESCALE_4096; - wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_4096; - } - spin_lock_init(&wdt->io_lock); ret = watchdog_register_device(cdns_wdt_device); From patchwork Fri Jul 5 11:46:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11032515 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 4BBE813A4 for ; Fri, 5 Jul 2019 11:46:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B0A628A51 for ; Fri, 5 Jul 2019 11:46:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F9D328A5A; Fri, 5 Jul 2019 11:46:10 +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 BA21028A51 for ; Fri, 5 Jul 2019 11:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727700AbfGELqJ (ORCPT ); Fri, 5 Jul 2019 07:46:09 -0400 Received: from mail-eopbgr150055.outbound.protection.outlook.com ([40.107.15.55]:29927 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727609AbfGELqJ (ORCPT ); Fri, 5 Jul 2019 07:46:09 -0400 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=uTzahOHq/NqXUCkLDoF5CaLbd+QskdjZUpZa5DrZlDI=; b=bqEJ22inTuAlZRJg98692w298per/bKn8VE+X6p8NQnQHgYfh9js6t0/OY9728GwjbVZrTo1Yn/EEY8y5SHFvcpu9XwFh7NY1cxANnRMS4+Daw00YQNDlHA4ZVJ9E3TNYVdVdJUgcI8UWI8HAaJ3FZpBRSNKEO/z0TIV0ym1Wd4= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB5891.eurprd06.prod.outlook.com (20.178.112.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.19; Fri, 5 Jul 2019 11:46:03 +0000 Received: from AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9]) by AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9%7]) with mapi id 15.20.2052.010; Fri, 5 Jul 2019 11:46:03 +0000 From: Melin Tomas To: "wim@linux-watchdog.org" , "linux@roeck-us.net" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v2 2/4] watchdog: cadence_wdt: Calculate actual timeout limits Thread-Topic: [PATCH v2 2/4] watchdog: cadence_wdt: Calculate actual timeout limits Thread-Index: AQHVMyc4zOw3U4QqV0S153oSVaSoDg== Date: Fri, 5 Jul 2019 11:46:02 +0000 Message-ID: <20190705114522.42565-3-tomas.melin@vaisala.com> References: <20190705114522.42565-1-tomas.melin@vaisala.com> In-Reply-To: <20190705114522.42565-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0901CA0051.eurprd09.prod.outlook.com (2603:10a6:3:45::19) 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: 736a108b-14b6-4357-b267-08d7013e5b55 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB5891; x-ms-traffictypediagnostic: AM0PR06MB5891: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:751; x-forefront-prvs: 008960E8EC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(136003)(346002)(376002)(39850400004)(366004)(199004)(189003)(52116002)(53936002)(6512007)(6436002)(66066001)(6506007)(25786009)(386003)(6486002)(478600001)(3846002)(6116002)(2501003)(68736007)(50226002)(76176011)(99286004)(107886003)(36756003)(26005)(316002)(4326008)(102836004)(54906003)(110136005)(186003)(71190400001)(71200400001)(5660300002)(2906002)(7736002)(305945005)(14444005)(476003)(446003)(11346002)(2616005)(1076003)(8936002)(66476007)(66556008)(64756008)(66446008)(86362001)(8676002)(256004)(486006)(73956011)(66946007)(81166006)(14454004)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB5891;H:AM0PR06MB4066.eurprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: jrFg6l1Ci0tWRrpp36CvMb1jsIsh7z8IUOWKSRMxj9/09NW0SA2sNtvOJK8Y94Jqr7zGyy6dqbZ5FOn/TfyupKD1kpT3EqMeTC7ocRnf9lSCWEe9QFApOQlKoZsa2ooMBjUtxZx0TDszgMGrrTZ4CoUl7lNznAINY4txBtdXIGLkj9fDv750kTQtzoiSaW0EQU62IinSd87gmARxULgkDy/77KoofG1QstD/J5rwtAG3E8J+PR6SAHZfHZnJLTaOPgi/NtEQ/Q4AreQ6nWByTq/x8Eg/7DogoTKEdmjw/OakQRStqAkWZ7+J2yoy/RYHyDZiudBMsAiuoVrEonds93xYcC8vDZuJ744xmc34dxotjVXTiDiqeP3Iub3vHOs+fjRVZa7Pa5vBE44X/Jck3vknBBrqpZnkEg5QOCqzzeg= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: 736a108b-14b6-4357-b267-08d7013e5b55 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2019 11:46:03.0106 (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: AM0PR06MB5891 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 Maximum and minimum timeout values depend on the actual input clock frequency and prescaler selection. Signed-off-by: Tomas Melin --- drivers/watchdog/cadence_wdt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index 415bd6dd1edb..87b767c87bb6 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -18,9 +18,6 @@ #include #define CDNS_WDT_DEFAULT_TIMEOUT 10 -/* Supports 1 - 516 sec */ -#define CDNS_WDT_MIN_TIMEOUT 1 -#define CDNS_WDT_MAX_TIMEOUT 516 /* Restart key */ #define CDNS_WDT_RESTART_KEY 0x00001999 @@ -28,6 +25,10 @@ /* Counter register access key */ #define CDNS_WDT_REGISTER_ACCESS_KEY 0x00920000 +/* Counter control register, counter restart values */ +#define CDNS_WDT_CCR_CRV_MIN 0xFFF +#define CDNS_WDT_CCR_CRV_MAX 0xFFFFFF + /* Counter value divisor */ #define CDNS_WDT_COUNTER_VALUE_DIVISOR 0x1000 @@ -315,8 +316,10 @@ static int cdns_wdt_probe(struct platform_device *pdev) cdns_wdt_device->info = &cdns_wdt_info; cdns_wdt_device->ops = &cdns_wdt_ops; cdns_wdt_device->timeout = CDNS_WDT_DEFAULT_TIMEOUT; - cdns_wdt_device->min_timeout = CDNS_WDT_MIN_TIMEOUT; - cdns_wdt_device->max_timeout = CDNS_WDT_MAX_TIMEOUT; + cdns_wdt_device->min_timeout = + CDNS_WDT_CCR_CRV_MIN * wdt->prescaler / clock_f; + cdns_wdt_device->max_timeout = + CDNS_WDT_CCR_CRV_MAX * wdt->prescaler / clock_f; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt->regs = devm_ioremap_resource(&pdev->dev, res); From patchwork Fri Jul 5 11:46:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11032517 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 6BEA713A4 for ; Fri, 5 Jul 2019 11:46:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B9A028A51 for ; Fri, 5 Jul 2019 11:46:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DA2A28A5A; Fri, 5 Jul 2019 11:46:12 +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 E8DF928A51 for ; Fri, 5 Jul 2019 11:46:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728335AbfGELqL (ORCPT ); Fri, 5 Jul 2019 07:46:11 -0400 Received: from mail-eopbgr150055.outbound.protection.outlook.com ([40.107.15.55]:29927 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728316AbfGELqL (ORCPT ); Fri, 5 Jul 2019 07:46:11 -0400 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=dxjB5Wjz2sV5mgc+b8NEo1VhJIiEXAeq5/sMajeS/m4=; b=il8ZZAbLeH5zy+ZA0ATEjqBMKxWcTYsQ1TJzMH6qdP3F0dh3kdYgmLgALRoTpEbQxyDq/bqLfvx2cZtr15tdi0FjZLVHMKuNcDaBViDZ+gsZnIgcGRRzxAe8icielitlXYU0hCNXmFEKcpYnOdqzoliDnWaQ7hm06KkpA/KVZ3U= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB5891.eurprd06.prod.outlook.com (20.178.112.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.19; Fri, 5 Jul 2019 11:46:03 +0000 Received: from AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9]) by AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9%7]) with mapi id 15.20.2052.010; Fri, 5 Jul 2019 11:46:03 +0000 From: Melin Tomas To: "wim@linux-watchdog.org" , "linux@roeck-us.net" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v2 3/4] watchdog: cadence_wdt: Group struct member init statements Thread-Topic: [PATCH v2 3/4] watchdog: cadence_wdt: Group struct member init statements Thread-Index: AQHVMyc5PRGnNzbVgEWwh9EA9v6D5A== Date: Fri, 5 Jul 2019 11:46:03 +0000 Message-ID: <20190705114522.42565-4-tomas.melin@vaisala.com> References: <20190705114522.42565-1-tomas.melin@vaisala.com> In-Reply-To: <20190705114522.42565-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0901CA0051.eurprd09.prod.outlook.com (2603:10a6:3:45::19) 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: 9a28a724-45db-470b-b774-08d7013e5bc4 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB5891; x-ms-traffictypediagnostic: AM0PR06MB5891: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:1148; x-forefront-prvs: 008960E8EC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(136003)(346002)(376002)(39850400004)(366004)(199004)(189003)(52116002)(53936002)(6512007)(6436002)(66066001)(6506007)(25786009)(386003)(6486002)(478600001)(3846002)(6116002)(2501003)(68736007)(50226002)(76176011)(99286004)(107886003)(36756003)(26005)(316002)(4326008)(102836004)(54906003)(110136005)(186003)(71190400001)(71200400001)(5660300002)(2906002)(7736002)(4744005)(305945005)(476003)(446003)(11346002)(2616005)(1076003)(8936002)(66476007)(66556008)(64756008)(66446008)(86362001)(8676002)(256004)(486006)(73956011)(66946007)(81166006)(14454004)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB5891;H:AM0PR06MB4066.eurprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: IuBr70im2TAfVAZazJbARmfazTzEhqaGmHez3D5F6rM0zQFkxMbaw18Vd950R6ZYUEkrD/1QQhEBW4O0EZk/GH5JiaSxtQTr6XLh3xJq5ewLFBiERXQuJZdUV5KYsLG1Ekxx8iw3vo7j86QL539tU1zhZu6Slg+bYFn6ij8PFY5Kpx/fKQM4PeeU7HhOdXntBdl5V+1cb2GvWfZ3p+o3MkjJwXPePq69IyjDnffsh87XjcdbnluMRGh7ve/EXgbCA4euGRpETotLJoHV+CUzxbrZ/e14aidZEge5EJWvrjELbYUNraolxVSgr7zdLJvY623+i3M1xrQDq7JNva/yGQc0idqhaRlp79y2XLixjciYGDIGyEad06eE8YjzKg5/NpUBBAE/ABdsetRyZhENr3lDNrRRhRgEZtUcDgu7KRw= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a28a724-45db-470b-b774-08d7013e5bc4 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2019 11:46:03.8031 (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: AM0PR06MB5891 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 Move init statement and remove stray comment. Signed-off-by: Tomas Melin --- drivers/watchdog/cadence_wdt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index 87b767c87bb6..4657800d9d8e 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -313,6 +313,7 @@ static int cdns_wdt_probe(struct platform_device *pdev) } cdns_wdt_device = &wdt->cdns_wdt_device; + cdns_wdt_device->parent = &pdev->dev; cdns_wdt_device->info = &cdns_wdt_info; cdns_wdt_device->ops = &cdns_wdt_ops; cdns_wdt_device->timeout = CDNS_WDT_DEFAULT_TIMEOUT; @@ -340,9 +341,6 @@ static int cdns_wdt_probe(struct platform_device *pdev) } } - /* Initialize the members of cdns_wdt structure */ - cdns_wdt_device->parent = &pdev->dev; - ret = watchdog_init_timeout(cdns_wdt_device, wdt_timeout, &pdev->dev); if (ret) { dev_err(&pdev->dev, "unable to set timeout value\n"); From patchwork Fri Jul 5 11:46:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11032519 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 03F8F912 for ; Fri, 5 Jul 2019 11:46:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5F4D28A51 for ; Fri, 5 Jul 2019 11:46:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7D1A28A56; Fri, 5 Jul 2019 11:46:26 +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 740A028A51 for ; Fri, 5 Jul 2019 11:46:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728316AbfGELq0 (ORCPT ); Fri, 5 Jul 2019 07:46:26 -0400 Received: from mail-eopbgr150055.outbound.protection.outlook.com ([40.107.15.55]:29927 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727609AbfGELqZ (ORCPT ); Fri, 5 Jul 2019 07:46:25 -0400 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=ZR6FRZXAQuDPlH1cBhx5w0i7Uy56UvledOjFXT9by2o=; b=uv47vAEjz2/Z6xga9trjYhJkjEbStw5QDa8tAni6ZvHCWmaBCj3Gh3LPe0IXnygNp5K2GM/t8M8d5CNIHx3GrSAZ7WEu0jQl+z0MnvMHf4c7L+P89dybonyaS3goVh91lMbEGqa1G5WsIFan4KxLqU3FnO7+xGukaBiJtqDkrQg= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB5891.eurprd06.prod.outlook.com (20.178.112.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.19; Fri, 5 Jul 2019 11:46:04 +0000 Received: from AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9]) by AM0PR06MB4066.eurprd06.prod.outlook.com ([fe80::141f:c11a:799e:97f9%7]) with mapi id 15.20.2052.010; Fri, 5 Jul 2019 11:46:04 +0000 From: Melin Tomas To: "wim@linux-watchdog.org" , "linux@roeck-us.net" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v2 4/4] watchdog: cadence_wdt: Support all available prescaler values Thread-Topic: [PATCH v2 4/4] watchdog: cadence_wdt: Support all available prescaler values Thread-Index: AQHVMyc5XfCsE+9knUOMmMD97S+BMw== Date: Fri, 5 Jul 2019 11:46:04 +0000 Message-ID: <20190705114522.42565-5-tomas.melin@vaisala.com> References: <20190705114522.42565-1-tomas.melin@vaisala.com> In-Reply-To: <20190705114522.42565-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0901CA0051.eurprd09.prod.outlook.com (2603:10a6:3:45::19) 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: ac173b10-eada-4bdc-82e0-08d7013e5c44 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB5891; x-ms-traffictypediagnostic: AM0PR06MB5891: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:2582; x-forefront-prvs: 008960E8EC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(136003)(346002)(376002)(39850400004)(366004)(199004)(189003)(52116002)(53936002)(6512007)(6436002)(66066001)(6506007)(25786009)(386003)(6486002)(478600001)(3846002)(6116002)(2501003)(68736007)(50226002)(76176011)(99286004)(107886003)(36756003)(26005)(316002)(4326008)(102836004)(54906003)(110136005)(186003)(71190400001)(71200400001)(5660300002)(2906002)(7736002)(305945005)(476003)(446003)(11346002)(2616005)(1076003)(8936002)(66476007)(66556008)(64756008)(66446008)(86362001)(8676002)(256004)(486006)(73956011)(66946007)(81166006)(14454004)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB5891;H:AM0PR06MB4066.eurprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: c1HHGDu1b0ZdGzTR20qnJWz9J7VeHWVxayXSzyZ6tiYDDWeJQXwttK7NG/PkTjBGAS48Mg2ktcGcevZ4+Gb/sH0nUCAMgsGeyik/EIRwnBe7jxYbB4NPnrRAAX/LFun1Ljk15kP1vmzpHa4bEI0VrJoyry/Ecwb2edwidy6bvuMueFuH6vCZl55BZrDTZIJbiUivd11XSYWFYwx7wFr9shRYDrufBhFrCxBz/J75GBaO5+1vWDI42aEtil6g31C9ZXpBwGKCyUvj0esTPrbwNjX1Y6Ai9boQ6/14yivC5Gs3SQT7ZQrnmX111k4USjpcTpfLVg+Af3V2f8GJgUE85UhWhtOwcC2/4vBg9wuIIVxVfjaFliN121c4PMiGn71cACmVVbMdscBZznI+HNA8Fms7M/4tmcgnQ82JdsicfIE= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac173b10-eada-4bdc-82e0-08d7013e5c44 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2019 11:46:04.5547 (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: AM0PR06MB5891 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. Add support to select prescaler values of 8 and 64 for lower input clock frequencies. Prescaler value is selected to keep timeout resolution of 1 second. For clock frequencies below 32kHz, 1 second resolution does no longer hold, thereby returning an error. Signed-off-by: Tomas Melin --- drivers/watchdog/cadence_wdt.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index 4657800d9d8e..39109b5721c1 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -33,16 +33,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 @@ -304,7 +305,16 @@ 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) { + dev_err(&pdev->dev, "cannot find suitable clock prescaler\n"); + return -ERANGE; + } else if (clock_f <= CDNS_WDT_CLK_32KHZ * CDNS_WDT_PRESCALE_8) { + 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_64) { + 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_512) { wdt->prescaler = CDNS_WDT_PRESCALE_512; wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_512; } else {