Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp608783pxb; Tue, 1 Feb 2022 06:57:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJd3vver9UIEWmwxD0nFVWMV5spnrm1hHx2SB+wvSCldye88YnPhOl3wMkDgGnpkdgMWmX X-Received: by 2002:a63:8543:: with SMTP id u64mr17098412pgd.624.1643727426043; Tue, 01 Feb 2022 06:57:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643727426; cv=pass; d=google.com; s=arc-20160816; b=Ur15PKJ2ADENhIjW8KENwB5adpotsdgsoPAQJR8ATZjnD49V0hyZJobKnH5BJWDjBg nE6OVcCPMp00gvDbBVQdrufoUu8fHGtbKNS4OcmZRdCNquuif+BEnEKmL7E2guB30mSm SlvHeSOFxReu2Qv6aVMI1ys4HgfHBc9v69cPkEOls/GzWJo3RocB1QDdyY3omkXA+4+V DMRhcKjx4ZPH4ZE0X6hr7EvkDgQtzEb7ly0RDftK5n2vI2Wt7PnYXchuE4ULPZh4Q5iL H2XQXNqbgwWxUoUJ5bz2EabWGJh/xQUs5LUkz/6LhxNkrxL7Iwaad8hM5r/l1RyhqRiu 6xOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e5fQV3G+KAPhyTJUpb2BuUgBzXO8OTaQ5aaB0Jis1Mk=; b=MdjHrDRKSIeTYzC/QvpaMrTGbnuQZBQbwHKnbSoZGI2PH8r585uz4gM5GwjbIHAbKy 6N9smHbqRT0y7QxuwR1QAFFXyRTGj0r8SoLDGAil6wut44+5XkFAMD6fnW99aQVJFJCS 73WgwRaIw//VlRwzBh7/e+Y5PUQF7R/K3u+s/QpTtS5anJ6n+fGUcMKGBfIccgGmpCzT GYQNYs8g1NlQAgHSArRiKaiR4WpEchQrSH6QyFPICzCEHurw3STms1tkYdM6XMX/ePpX V2E2XtZdfp9z97LtkI6riYw8r04gsVYoNnGDI5IFT+pFtPL1dFJfiT08ctQymh4kg55w CMHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BihDOv0y; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mi3si2797998pjb.134.2022.02.01.06.56.53; Tue, 01 Feb 2022 06:57:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BihDOv0y; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355714AbiA3TM4 (ORCPT + 99 others); Sun, 30 Jan 2022 14:12:56 -0500 Received: from mail-dm6nam10on2049.outbound.protection.outlook.com ([40.107.93.49]:30540 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355834AbiA3TMp (ORCPT ); Sun, 30 Jan 2022 14:12:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MV+baaTNmrLvBAPvIgaMDYU7rCDl931bbmQrxlFOyuZWQb2KwDjSE0NygOfObRp/sMk+qAJQz7nKnTDRm61yqdUhEov43QzSM4wI++mzP2hpu2/eOHmVTCsOKUwLuQsutYWsOljcfBCrcdw0BymVKsslwVu2I5l8qsaMJ0fSBOLb27Vr/Z8q6+vHi2ppgxyAtLEdW5IJJadrcdeDLDzWdZGLFF3VJ8IDNowexLLQjgauntvr1QOASOcT/M2YEAbfs24FjnKpWyVM2jmZu2rRAJt/QJqhYz/N0gD+1Y5PcHev9Lew+74/YE5rxyTk5pOZECMFg6KfpgJtxe4KbYsJLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e5fQV3G+KAPhyTJUpb2BuUgBzXO8OTaQ5aaB0Jis1Mk=; b=imT4YZ3nM8yyne1t+ayzHw1DA8V669J0Yl265OncDMgSow8p2BsNYNAWRgpHrljliHcMc/oSZx/lORtHFAgiQYiw/zAkkVO2udNRuZds06dwCXyR0csSx/P3RE/Z5DPLjKut1pzSS273O41Cy5w3PROt3tgU41rXDac6Tu+ZzDTUaKJpjlfbq2PIwOQAHz1Ni+B+9MFvaWjvrEdcImUiKzWrLkxOKMZUXfIGwtoYgDkvP6NyVR9lPdNOjlxZpAQkbOQhaNgJJT4OV9DST4p86AIgLikEiLAglOYfTXEBxJ2GD3ofUjOGKOvSaVYL9NtqopAXPXzAjHFv6TO4YXvW9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=roeck-us.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e5fQV3G+KAPhyTJUpb2BuUgBzXO8OTaQ5aaB0Jis1Mk=; b=BihDOv0yTvwwPkrFyANgjDXZ5BDXg4e/BWE6+HDXfujQwqh/nLydB2Q0xfrkBzsoyjEBBHIJKi0jUHqdvDi85yYiJJFj0JNdUp/Gud+CU35CcHiRivUXc5BfRd4IWV4vparMYmuUgjtX0bFG0EAY3amOz1e1RNtWAFNm+SEAxn4= Received: from DM6PR21CA0007.namprd21.prod.outlook.com (2603:10b6:5:174::17) by BY5PR12MB4323.namprd12.prod.outlook.com (2603:10b6:a03:211::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sun, 30 Jan 2022 19:12:43 +0000 Received: from DM6NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::3c) by DM6PR21CA0007.outlook.office365.com (2603:10b6:5:174::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.3 via Frontend Transport; Sun, 30 Jan 2022 19:12:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT055.mail.protection.outlook.com (10.13.173.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Sun, 30 Jan 2022 19:12:42 +0000 Received: from ethanolx7ea3host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Sun, 30 Jan 2022 13:12:41 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 1/4] Watchdog: sp5100_tco: Move timer initialization into function Date: Sun, 30 Jan 2022 13:12:22 -0600 Message-ID: <20220130191225.303115-2-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130191225.303115-1-terry.bowman@amd.com> References: <20220130191225.303115-1-terry.bowman@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63dc721d-9ab9-4a84-53fd-08d9e4247dc8 X-MS-TrafficTypeDiagnostic: BY5PR12MB4323:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:962; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: da0mx0yuYC8b8s0IHhU6yaKuSxE3nqQjVj9SGFxRkwkZXInlgAaB2ktBbVPEXNpUTJo3Ji2Fot6MrK9Nz5/nHaVpTx7UTxYrCsf5F8uklGqkoNSfkB16PgGIROxtQonnR0tMSo/ZzfuxRtLQpSt4qh8JIgHcp+peTi9//KeokB+cDIDHKtNrlGNE+1c50SkOVaGFzOZJuZi4eb4AQ+XIP95J43disWC13IheE+AjDLp5kX1nrSfRlJFl8YwH0A5ZBPXZOXhaT+R4CNM3s3SSyJFzA+lTndSa2dXSE86zov9YmnBp6z62JVzV8LJrWLNoMG37u2MMVvNgNGdmt2PROF+LkTACVT+VDY+SsXXF+i4r+EN+vFFWtppxSTAnxx0RU7bkiVlxMYGv+0G79uIbr2d3wW14V8BuC61pQSFw1f1lt/1peFF7HCWtwqPVJCxBcStJIsmbmLUqze3QlL9Iy2h6axfsSCrXD3LpnAtKq90f7dPLhr5k+bkV/cUnb3zFqThK/Dw6JILyMrqKVK2tsg46PPMwRb6mOYDNO5BNxNcfbi8CqhVWOamHjBOxFC5Fk9/tiydho+Sijeh1fiTU9Gn/IZO4W4PS77x4PzSM8KkYMevQ4ke1vD7JUyklJimIqnSHMucE63OhSyMqIybczryddu1LVGLWF9GQLrYvhs2COIR23UX61gwSizvI06d9ODfR34miR40eWf51EguoZjyBMuaZrj3ORx1FVKUhpaQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(2616005)(40460700003)(1076003)(336012)(426003)(186003)(16526019)(86362001)(26005)(82310400004)(47076005)(83380400001)(5660300002)(44832011)(70586007)(70206006)(36756003)(36860700001)(356005)(81166007)(8936002)(8676002)(508600001)(2906002)(6666004)(7696005)(54906003)(110136005)(316002)(4326008)(2101003)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 19:12:42.8778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63dc721d-9ab9-4a84-53fd-08d9e4247dc8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4323 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor driver's timer initialization into new function. This is needed inorder to support adding new device layouts while using common timer initialization. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Tested-by: Jean Delvare Reviewed-by: Jean Delvare --- drivers/watchdog/sp5100_tco.c | 65 +++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c index dd9a744f82f8..b365bbc9ac36 100644 --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -223,6 +223,41 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) return val; } +static int sp5100_tco_timer_init(struct sp5100_tco *tco) +{ + struct watchdog_device *wdd = &tco->wdd; + struct device *dev = wdd->parent; + u32 val; + + val = readl(SP5100_WDT_CONTROL(tco->tcobase)); + if (val & SP5100_WDT_DISABLED) { + dev_err(dev, "Watchdog hardware is disabled\n"); + return -ENODEV; + } + + /* + * Save WatchDogFired status, because WatchDogFired flag is + * cleared here. + */ + if (val & SP5100_WDT_FIRED) + wdd->bootstatus = WDIOF_CARDRESET; + + /* Set watchdog action to reset the system */ + val &= ~SP5100_WDT_ACTION_RESET; + writel(val, SP5100_WDT_CONTROL(tco->tcobase)); + + /* Set a reasonable heartbeat before we stop the timer */ + tco_timer_set_timeout(wdd, wdd->timeout); + + /* + * Stop the TCO before we change anything so we don't race with + * a zeroed timer. + */ + tco_timer_stop(wdd); + + return 0; +} + static int sp5100_tco_setupdevice(struct device *dev, struct watchdog_device *wdd) { @@ -348,35 +383,7 @@ static int sp5100_tco_setupdevice(struct device *dev, /* Setup the watchdog timer */ tco_timer_enable(tco); - val = readl(SP5100_WDT_CONTROL(tco->tcobase)); - if (val & SP5100_WDT_DISABLED) { - dev_err(dev, "Watchdog hardware is disabled\n"); - ret = -ENODEV; - goto unreg_region; - } - - /* - * Save WatchDogFired status, because WatchDogFired flag is - * cleared here. - */ - if (val & SP5100_WDT_FIRED) - wdd->bootstatus = WDIOF_CARDRESET; - /* Set watchdog action to reset the system */ - val &= ~SP5100_WDT_ACTION_RESET; - writel(val, SP5100_WDT_CONTROL(tco->tcobase)); - - /* Set a reasonable heartbeat before we stop the timer */ - tco_timer_set_timeout(wdd, wdd->timeout); - - /* - * Stop the TCO before we change anything so we don't race with - * a zeroed timer. - */ - tco_timer_stop(wdd); - - release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE); - - return 0; + ret = sp5100_tco_timer_init(tco); unreg_region: release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE); -- 2.30.2