From patchwork Tue Jul 9 20:09: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: 11037477 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 BE043912 for ; Tue, 9 Jul 2019 20:09:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFD2027CAF for ; Tue, 9 Jul 2019 20:09:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3E5028814; Tue, 9 Jul 2019 20:09: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 46BDB27CAF for ; Tue, 9 Jul 2019 20:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729165AbfGIUJI (ORCPT ); Tue, 9 Jul 2019 16:09:08 -0400 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81]:12361 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729582AbfGIUJH (ORCPT ); Tue, 9 Jul 2019 16:09: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=2yoL1lQrhZcFRAEExiB/B61+FoCSR+8fAet8GFrFlZY=; b=gONuT/hLhuWUR1NIPIhRZir74SVxuIT5mPyVENeMUc7waHVI4jR9k+dcE/gJolpjz9Xj+1tEb0b/aIM5AN0qjtMJVS/LOpbpkdY4aofwMbwDSY8RzrOm56gd7rLTN3r+mnB6akVPMvoDoBixh82HEugTSBWhFQ/4v4vx4TdBsL8= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB3890.eurprd06.prod.outlook.com (52.133.58.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Tue, 9 Jul 2019 20:09: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.019; Tue, 9 Jul 2019 20:09:04 +0000 From: Melin Tomas To: "linux@roeck-us.net" , "wim@linux-watchdog.org" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v3 1/4] watchdog: cadence_wdt: Move clock detection earlier in probe Thread-Topic: [PATCH v3 1/4] watchdog: cadence_wdt: Move clock detection earlier in probe Thread-Index: AQHVNpIn00nrfFZ3xkCD61CPT/shRQ== Date: Tue, 9 Jul 2019 20:09:03 +0000 Message-ID: <20190709200801.42313-2-tomas.melin@vaisala.com> References: <20190709200801.42313-1-tomas.melin@vaisala.com> In-Reply-To: <20190709200801.42313-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0902CA0006.eurprd09.prod.outlook.com (2603:10a6:3:e5::16) 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: bd62d42d-7340-4fbd-1278-08d704a949c3 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB3890; x-ms-traffictypediagnostic: AM0PR06MB3890: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:2582; x-forefront-prvs: 0093C80C01 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(39850400004)(376002)(136003)(189003)(199004)(53936002)(256004)(2906002)(14444005)(86362001)(50226002)(6512007)(446003)(71190400001)(71200400001)(2616005)(26005)(102836004)(186003)(110136005)(478600001)(6116002)(3846002)(54906003)(476003)(6506007)(386003)(64756008)(36756003)(66446008)(66476007)(107886003)(66556008)(76176011)(4326008)(305945005)(68736007)(52116002)(11346002)(99286004)(1076003)(5660300002)(81166006)(486006)(316002)(25786009)(66066001)(14454004)(8676002)(8936002)(81156014)(2501003)(7736002)(66946007)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB3890;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: UGSOT9gDz5lcoVDOxu0kihYA+66qjUabbQSHpbwBgbBpMrWdcvaQiqFh1LnNwpsHCp7MbCzTDPDnar+n1LD2FxF9YVgUnmI0Qowj6p5/+0+JgquVUElY6pKhoAE3HXMsaphsPVaNl9euDcX/d70kiT2bgRZOXU3+Z7lEnR9jNY927002lTOPDvw4EmDVQtNjOuQAdFUVhVuqwIwEIl2bQBwXPmj/RlOPgpqmqYqsARWGPU93+/3s6JjWTbRoR86JlbRwKmTmwi6Jz5hBaEWsB+hiF08XZUBH9ojYSP9pbJckykUpHm5ccyyvGu9ds2YaXEvPKMuTYMTETvgsIHytBbGlQFYhYeJCETPS+Es38B7tNp6WnYdv4/8f5dhBx27Nw+2FNKfULGYvLsPTPLFMXbMrzoO4Do3HBcESVLgBtYM= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd62d42d-7340-4fbd-1278-08d704a949c3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2019 20:09:04.1282 (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: AM0PR06MB3890 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 earlier in the probe. Preparational step for calculating maximum and minimum timeout values for driver. Signed-off-by: Tomas Melin Reviewed-by: Guenter Roeck --- drivers/watchdog/cadence_wdt.c | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index a22f2d431a35..ddbf602bdc40 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -300,6 +300,31 @@ static int cdns_wdt_probe(struct platform_device *pdev) if (!wdt) return -ENOMEM; + wdt->clk = devm_clk_get(dev, NULL); + if (IS_ERR(wdt->clk)) { + dev_err(dev, "input clock not found\n"); + return PTR_ERR(wdt->clk); + } + + ret = clk_prepare_enable(wdt->clk); + if (ret) { + dev_err(dev, "unable to enable clock\n"); + return ret; + } + ret = devm_add_action_or_reset(dev, cdns_clk_disable_unprepare, + wdt->clk); + if (ret) + 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; @@ -333,31 +358,6 @@ 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(dev, NULL); - if (IS_ERR(wdt->clk)) { - dev_err(dev, "input clock not found\n"); - return PTR_ERR(wdt->clk); - } - - ret = clk_prepare_enable(wdt->clk); - if (ret) { - dev_err(dev, "unable to enable clock\n"); - return ret; - } - ret = devm_add_action_or_reset(dev, cdns_clk_disable_unprepare, - wdt->clk); - if (ret) - 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); watchdog_stop_on_reboot(cdns_wdt_device); From patchwork Tue Jul 9 20:09:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11037479 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 F1551912 for ; Tue, 9 Jul 2019 20:09:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E392D27CAF for ; Tue, 9 Jul 2019 20:09:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D827C28814; Tue, 9 Jul 2019 20:09: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 803B027CAF for ; Tue, 9 Jul 2019 20:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbfGIUJK (ORCPT ); Tue, 9 Jul 2019 16:09:10 -0400 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81]:12361 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729572AbfGIUJK (ORCPT ); Tue, 9 Jul 2019 16:09:10 -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=iJUCy8lECzcYLt2Rt75IlBhCZ6xpR00/fMNi+jregC8=; b=q7yMIs4T8xT3wpt5qj9aTXhPDqvepw/aUpjkUcuihT4IHt/dKIuS8uZdgjy27DUUz5XDqzS3S6vNnPYB6PrAtKZ6a9al5LnzQMSizP3aMr+S/7M3KalMcrpqkMHlpiHu6TFqdPsQaODgnGE9V1X05NZY+Z5MM8F9+WlUDL1G+Gk= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB3890.eurprd06.prod.outlook.com (52.133.58.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Tue, 9 Jul 2019 20:09:05 +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.019; Tue, 9 Jul 2019 20:09:05 +0000 From: Melin Tomas To: "linux@roeck-us.net" , "wim@linux-watchdog.org" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v3 2/4] watchdog: cadence_wdt: Calculate actual timeout limits Thread-Topic: [PATCH v3 2/4] watchdog: cadence_wdt: Calculate actual timeout limits Thread-Index: AQHVNpIoih3T4Xs3REWpMWObvXdxSA== Date: Tue, 9 Jul 2019 20:09:05 +0000 Message-ID: <20190709200801.42313-3-tomas.melin@vaisala.com> References: <20190709200801.42313-1-tomas.melin@vaisala.com> In-Reply-To: <20190709200801.42313-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0902CA0006.eurprd09.prod.outlook.com (2603:10a6:3:e5::16) 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: 6cb58b48-75e0-4ee6-37f7-08d704a94b06 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB3890; x-ms-traffictypediagnostic: AM0PR06MB3890: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:250; x-forefront-prvs: 0093C80C01 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(39850400004)(376002)(136003)(189003)(199004)(53936002)(256004)(2906002)(14444005)(86362001)(50226002)(6512007)(446003)(71190400001)(71200400001)(2616005)(26005)(102836004)(186003)(110136005)(478600001)(6116002)(3846002)(54906003)(476003)(6506007)(386003)(64756008)(36756003)(66446008)(66476007)(107886003)(66556008)(76176011)(4326008)(305945005)(68736007)(52116002)(11346002)(99286004)(1076003)(5660300002)(81166006)(486006)(316002)(25786009)(66066001)(14454004)(8676002)(8936002)(81156014)(2501003)(7736002)(66946007)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB3890;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: AtaWUqDs5EPweDrcFJOm9+eO6JqPr72QQN1jQDq786FaU2IVEyGgj8GF6AN4f1eDj9IiHmuz9iPyYc68X9TiBmza3iQ7TUeS1u1vvHEpu/I5CYpgQUWHaMDQjpwo2AcJigDaZN5yv50OVKzi3TZZarqdMsfG169Nyx3A3CcqHYPYWidzj4Bccyj/Vp4MVlfKcnm23TpOPfAkZZxOGeWGDCmWTeCIppYiqivNQNgfuWYKtgfOBFFrhwaegwZd7RJGCcFJjkXdQEIcPWg2CL+e08HG6SfZ+pdPxPUJwt+7lJ7my6fokBBcOW/1SNukdUybncyVccbUyhImKTZfFNd1Hrq0F20DSVXPmMiCZl7bpGRBFEq1qfWc+EBtYj5sBWwNQQEldhX5xo6Hk0PIMyBraAjCspM1EuxvVo5zJ58wGM8= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cb58b48-75e0-4ee6-37f7-08d704a94b06 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2019 20:09:05.2586 (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: AM0PR06MB3890 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 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index ddbf602bdc40..a0d7666e7d20 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 @@ -317,7 +318,10 @@ static int cdns_wdt_probe(struct platform_device *pdev) return ret; clock_f = clk_get_rate(wdt->clk); - if (clock_f <= CDNS_WDT_CLK_75MHZ) { + if (clock_f == 0) { + dev_err(dev, "invalid clock frequency, (f=%lu)\n", clock_f); + return -EINVAL; + } else if (clock_f <= CDNS_WDT_CLK_75MHZ) { wdt->prescaler = CDNS_WDT_PRESCALE_512; wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_512; } else { @@ -329,8 +333,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; wdt->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->regs)) From patchwork Tue Jul 9 20:09:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11037481 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 552B714F6 for ; Tue, 9 Jul 2019 20:09:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479E227CAF for ; Tue, 9 Jul 2019 20:09:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38E5B28814; Tue, 9 Jul 2019 20:09:14 +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 C85E627CAF for ; Tue, 9 Jul 2019 20:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729582AbfGIUJN (ORCPT ); Tue, 9 Jul 2019 16:09:13 -0400 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81]:12361 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729572AbfGIUJN (ORCPT ); Tue, 9 Jul 2019 16:09:13 -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=DIEJ5/B2PTMnqmkMsYgWIX+lyHlAj5D5EmdfhiIPG3o=; b=s4DzYjd908HpXTpeRBGRXGKI++ooGn69H4kq/83rdWkNVsFV05QkKhs9HFuYQ9C2Soi2+IUGbTbY54/CsOFt/A8kmIDsdW+CinWNNGUFXL5TxxRzuZuA3dnYbx8uezYdNa0tAApgmE2zdSiSUgk+zT3fZiklxfr6GNj402QPgIc= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB3890.eurprd06.prod.outlook.com (52.133.58.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Tue, 9 Jul 2019 20:09:06 +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.019; Tue, 9 Jul 2019 20:09:06 +0000 From: Melin Tomas To: "linux@roeck-us.net" , "wim@linux-watchdog.org" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v3 3/4] watchdog: cadence_wdt: Group struct member init statements Thread-Topic: [PATCH v3 3/4] watchdog: cadence_wdt: Group struct member init statements Thread-Index: AQHVNpIpvQm3jvbrMkGcXgq3YNmLmw== Date: Tue, 9 Jul 2019 20:09:06 +0000 Message-ID: <20190709200801.42313-4-tomas.melin@vaisala.com> References: <20190709200801.42313-1-tomas.melin@vaisala.com> In-Reply-To: <20190709200801.42313-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0902CA0006.eurprd09.prod.outlook.com (2603:10a6:3:e5::16) 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: 55634788-d4c6-4a8d-4f63-08d704a94b86 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB3890; x-ms-traffictypediagnostic: AM0PR06MB3890: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:576; x-forefront-prvs: 0093C80C01 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(39850400004)(376002)(136003)(189003)(199004)(53936002)(256004)(2906002)(86362001)(50226002)(6512007)(446003)(71190400001)(71200400001)(2616005)(26005)(102836004)(186003)(110136005)(478600001)(6116002)(3846002)(54906003)(476003)(6506007)(386003)(64756008)(36756003)(66446008)(66476007)(107886003)(66556008)(76176011)(4326008)(305945005)(68736007)(52116002)(11346002)(99286004)(4744005)(1076003)(5660300002)(81166006)(486006)(316002)(25786009)(66066001)(14454004)(8676002)(8936002)(81156014)(2501003)(7736002)(66946007)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB3890;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: UZFK+/YrD35WqA8IRf77a16caRVrGonve1noJ0tjk78Izthwnh0PNpfKATp1HbTK192oQ3VA0CAZyqeCa0T4Fdo7nnCQczPK67O08+jeV3P7YtWWXsD6bEFCTJoL4l69qiR2byK9WZPgBqyS6Cj6HKMzpuijqwoPPe6SdCKE1nRLPs6tn6h4qSDAoJ2GMoKO5QxPnAfnqGhr8Ojrk81g7d7XCpCGzZ114TQfRSp+TKDFM3GJedETwxCxN2nGQqkjSmBrhLJcmMP1ac25pr7uHkDK/P7w1A7JQkWCRz++ojR7xtlx4N6cGoeWU+OP5b/MxoFg7iiR+BkZiNeGG7DEHrQgCXn/pMuIgdGlkoXwRvFe4r5pupP72RGfTaPtoWDhD9qo4ia5sFbPuPwth+Q/6As/M/bBPt3de3vV/slZXdY= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55634788-d4c6-4a8d-4f63-08d704a94b86 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2019 20:09:06.1760 (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: AM0PR06MB3890 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 Reviewed-by: Guenter Roeck --- 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 a0d7666e7d20..0bdb275d904a 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -330,6 +330,7 @@ static int cdns_wdt_probe(struct platform_device *pdev) } cdns_wdt_device = &wdt->cdns_wdt_device; + cdns_wdt_device->parent = dev; cdns_wdt_device->info = &cdns_wdt_info; cdns_wdt_device->ops = &cdns_wdt_ops; cdns_wdt_device->timeout = CDNS_WDT_DEFAULT_TIMEOUT; @@ -356,9 +357,6 @@ static int cdns_wdt_probe(struct platform_device *pdev) } } - /* Initialize the members of cdns_wdt structure */ - cdns_wdt_device->parent = dev; - watchdog_init_timeout(cdns_wdt_device, wdt_timeout, dev); watchdog_set_nowayout(cdns_wdt_device, nowayout); watchdog_stop_on_reboot(cdns_wdt_device); From patchwork Tue Jul 9 20:09:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Melin X-Patchwork-Id: 11037483 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 EE474912 for ; Tue, 9 Jul 2019 20:09:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC72C27CAF for ; Tue, 9 Jul 2019 20:09:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF07328814; Tue, 9 Jul 2019 20:09:28 +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 749A427CAF for ; Tue, 9 Jul 2019 20:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729051AbfGIUJ2 (ORCPT ); Tue, 9 Jul 2019 16:09:28 -0400 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81]:12361 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729572AbfGIUJ2 (ORCPT ); Tue, 9 Jul 2019 16:09:28 -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=inK4NJv8/GyGod6G6lG1Xc07geZWMzadvGPatFFQuH4=; b=MvMrqCo6gxjwSMDY4h2lFxJk/vEuAftF3OQsMmDqQYisfstnVv9yt3vcucJIGsU+r6l4B1I8fztx/Fxv+z4uQVr/1u3z3YrDg4TpvDBarmbinGE7qSJj3dDyKRyHejJGhqIJYMVatWyVe8o6OLb3MZhhAQdwsLEwyB3vycR6wf4= Received: from AM0PR06MB4066.eurprd06.prod.outlook.com (52.133.60.17) by AM0PR06MB3890.eurprd06.prod.outlook.com (52.133.58.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Tue, 9 Jul 2019 20:09:06 +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.019; Tue, 9 Jul 2019 20:09:06 +0000 From: Melin Tomas To: "linux@roeck-us.net" , "wim@linux-watchdog.org" CC: "linux-watchdog@vger.kernel.org" , Melin Tomas Subject: [PATCH v3 4/4] watchdog: cadence_wdt: Support all available prescaler values Thread-Topic: [PATCH v3 4/4] watchdog: cadence_wdt: Support all available prescaler values Thread-Index: AQHVNpIpwwoCbUKMfU6U33+0Mj8DZw== Date: Tue, 9 Jul 2019 20:09:06 +0000 Message-ID: <20190709200801.42313-5-tomas.melin@vaisala.com> References: <20190709200801.42313-1-tomas.melin@vaisala.com> In-Reply-To: <20190709200801.42313-1-tomas.melin@vaisala.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0902CA0006.eurprd09.prod.outlook.com (2603:10a6:3:e5::16) 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: 4a568963-74c9-45b3-0159-08d704a94bf7 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM0PR06MB3890; x-ms-traffictypediagnostic: AM0PR06MB3890: x-microsoft-antispam-prvs: x-tenant-id: 6d7393e0-41f5-4c2e-9b12-4c2be5da5c57 x-ms-oob-tlc-oobclassifiers: OLM:2582; x-forefront-prvs: 0093C80C01 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(39850400004)(376002)(136003)(189003)(199004)(53936002)(256004)(2906002)(86362001)(50226002)(6512007)(446003)(71190400001)(71200400001)(2616005)(26005)(102836004)(186003)(110136005)(478600001)(6116002)(3846002)(54906003)(476003)(6506007)(386003)(64756008)(36756003)(66446008)(66476007)(107886003)(66556008)(76176011)(4326008)(305945005)(68736007)(52116002)(11346002)(99286004)(1076003)(5660300002)(81166006)(486006)(316002)(25786009)(66066001)(14454004)(8676002)(8936002)(81156014)(2501003)(7736002)(66946007)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR06MB3890;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: uluAqRLv24aSQwt79Q+8XUJ5velDrZGjnfY61iLeahd0Ntu/hnoaPLkz5u9veVitBbcxjE54GgOsOfliutXLWAw1U/meSv1YlaDGGWzTZoPazmk3hXBExNoGrys+5h51W9dLP08F0gLwFhodXUz4QWp8uik1DA2fze4pS79cfuaPxjalXtGkdsHeJb8zrS7NMVVfj1yzX4RdOERImP4ka58Bh19tnlt4rBZ/b5Dh1RhhIfl2p7r7Zd4FKqRheFNnZnqvlnjQwOPC9AqvjvVlnCInVHGqT/i30Q1NLvs0fzW9cMJKdcse0RtRQh7ho2wz3yWl6lF7XUZN/29g+qStijB+BtFeL0DZbQOD6nv9QFd8Xmnn6kO552IoErLDheIIEVEcTdc3N41PtUsjuS67Z0bYkAvx0yAMOPpUBTX3agw= MIME-Version: 1.0 X-OriginatorOrg: vaisala.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a568963-74c9-45b3-0159-08d704a94bf7 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2019 20:09:06.8066 (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: AM0PR06MB3890 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 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index 0bdb275d904a..037faf557f9d 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 @@ -318,10 +319,18 @@ static int cdns_wdt_probe(struct platform_device *pdev) return ret; clock_f = clk_get_rate(wdt->clk); - if (clock_f == 0) { - dev_err(dev, "invalid clock frequency, (f=%lu)\n", clock_f); + if (clock_f < CDNS_WDT_CLK_32KHZ) { + dev_err(dev, + "cannot find suitable clock prescaler, (f=%lu)\n", + clock_f); return -EINVAL; - } else if (clock_f <= CDNS_WDT_CLK_75MHZ) { + } 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 {