From patchwork Tue Jan 18 20:22:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDB3CC433FE for ; Tue, 18 Jan 2022 20:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245513AbiARUW6 (ORCPT ); Tue, 18 Jan 2022 15:22:58 -0500 Received: from mail-bn8nam12on2052.outbound.protection.outlook.com ([40.107.237.52]:46866 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233125AbiARUW6 (ORCPT ); Tue, 18 Jan 2022 15:22:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kx0tTQaFmmFSNiTjYZLiO1YCoZf3KwnhIi2gDGnsTtYM8WgrkBSt8+u6d2zhHfpzzo+sgPCQOTL65V9zrVf+VwZaLIywgUOIMzrLZYRxbOzmaSHuZYmoJnUYCTKxdzW6r4het38cGn9eSIM+ICjeqZxZeV3pDfHTfOcKR5YzHBvYAdr9sf/YgWoXs6+JF2zUUWxvtjVDsgfW5VuVyMGt1ouUZwFLwngDCkuFV4741ru8JUrbrIkK0onJ++TX8E/7svWKjwKP7tCt970tqrl84tLbxTJafA7l5eX/ER4OJ3FiObbWxYzm9TtuXwSbypMHY4rCYikLKm5BglsCPmYM1g== 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=0u+9Y9m8fSv6D25aUl7S7KP60Wbqdphuh1JnIPNaDFA=; b=GHhqmzrxfbuCOjCdd2Xk4NRvRM4AoekIIHPdL2vpIXm8XqcoBycNFpF+WtAkgnJgTS4ptrVJhBnlfwN3r43OB8zugXkQXxQkDchquPT+PCk32RdYYGAOGn41jqykjOzd8bCaa3grW10DVtmoBRBt6jXK3tMnSJH793gs4BnA36PZxurvaoMufbVlyMrtAgMqUatt72ON7B1AIFvN4COLh98+2WF6HvNxwt9bvD7UZ8HFjvJ9oIGRc6LcPg5UFzFOnhb28fHTphZQZAPD8L8yOTUiShZRsJnol4E+Adw1FfjJWHhCELzMmxGYwQhKaLC5Oc2+7t/l7dKx9alTH+JX2A== 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=0u+9Y9m8fSv6D25aUl7S7KP60Wbqdphuh1JnIPNaDFA=; b=UIxn6miGFwXKmsvxqqlqK8FYWxu+4+fZk2/MDhU5VyuB27q1gzwS4hj2QpajNieV6r6UNBowKGCrZAqhFmdGnozQNLR6nb4K+GiLzQew0dvR1RpbQjXGd5iF9Id0kMeLAtT8aZpCQJlt9iJrk6BXT5kOD1RRzoVJLZgEsvagaKU= Received: from MWHPR02CA0019.namprd02.prod.outlook.com (2603:10b6:300:4b::29) by BN6PR12MB1345.namprd12.prod.outlook.com (2603:10b6:404:18::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Tue, 18 Jan 2022 20:22:55 +0000 Received: from CO1NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:300:4b:cafe::33) by MWHPR02CA0019.outlook.office365.com (2603:10b6:300:4b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 20:22:52 +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 CO1NAM11FT039.mail.protection.outlook.com (10.13.174.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Tue, 18 Jan 2022 20:22:52 +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; Tue, 18 Jan 2022 14:22:50 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 1/4] Watchdog: sp5100_tco: Move timer initialization into function Date: Tue, 18 Jan 2022 14:22:31 -0600 Message-ID: <20220118202234.410555-2-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118202234.410555-1-terry.bowman@amd.com> References: <20220118202234.410555-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b9f66f6-6b75-44f4-15da-08d9dac04df9 X-MS-TrafficTypeDiagnostic: BN6PR12MB1345: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: YD+PUaVbkLb8gD8j0nctc5ch1EQtr1P8G/uoWCtPqFQ5SseiVG2E5ve6wqdnIs+/36svpd1LzWteJde6WDb1l6loOPLAk1GBi8ugLWX1dXgzs13/4azDMqJGFn/anqgIFfZkQhF/RHw+/b8CUGfq5HZWTA5vcOvnh5OLw7mJ571o/6p8VtE8JQnnDd9McLKSj8WVb19sPdrQXihR494v9FM0Cd43puLe6l3MGl09QV5uWSp13c5kRRY3tdU6ogNLAA3nDQutp67KdcdRGqH8OYPNm6QFXW6cJNrMvABv05NgtIuzadCkIRlKjBcDD939uMMof/PhVtBcOU2N9BPsR/5sajXtQJBZVh8hzpS06oYLQG/H6/ke0xTYT8rPZxqssK6VLEOYcT727/RzZodmkPrBfjOQvkpu3aZY0XMYKrXc9ttxmis5ZmNvwln41JG63dWkhcXrluscCkx3MF356jiHAwPq4dLMikGWyHL+gKWPj7jsYbie+B5BQ2VOXn5Z1V7RRz7LYX+rnzGln1mVieyOibC0+rBi/fOAeWqo/XL3EAZEFp4fif80lg0AXMiP7CyiS0Km9fnECGvy2F6Q6obW1h+Np5FymAO5LvGTaCJ+x/mVFu9yyfAcST8RfN8x7RmU1vt912b4D05DtUG2QQHkay3EywF5EbBRSyMWoT7VvTdvfRq4W/Kz+I+AodVCqxirRb/OpbZ7Xu/QyHo4bAqlxdcqtry+bNz9SuL4VWgko+Z3tVyMOYbc/8ACj9mppXwe/XQTQWK9STcPd57IsAyNDqeqXRNzQfUCn9wwZdUsT9KXR66BfG/mvERfbb7u 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:(4636009)(40470700002)(46966006)(36840700001)(83380400001)(70206006)(4326008)(2906002)(86362001)(7696005)(356005)(36756003)(81166007)(70586007)(5660300002)(16526019)(186003)(47076005)(2616005)(26005)(44832011)(1076003)(8936002)(336012)(6666004)(426003)(54906003)(316002)(110136005)(40460700001)(8676002)(36860700001)(82310400004)(508600001)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 20:22:52.4819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b9f66f6-6b75-44f4-15da-08d9dac04df9 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: CO1NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1345 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@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 To: Guenter Roeck To: linux-watchdog@vger.kernel.org To: Jean Delvare To: linux-i2c@vger.kernel.org To: Wolfram Sang To: Andy Shevchenko To: Rafael J. Wysocki Cc: linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck Cc: Robert Richter Cc: Thomas Lendacky 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..ecc273b9b17f 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); From patchwork Tue Jan 18 20:22:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5E2EC433F5 for ; Tue, 18 Jan 2022 20:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245175AbiARUXJ (ORCPT ); Tue, 18 Jan 2022 15:23:09 -0500 Received: from mail-dm6nam10on2084.outbound.protection.outlook.com ([40.107.93.84]:63841 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1344128AbiARUXI (ORCPT ); Tue, 18 Jan 2022 15:23:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cGzZdxu7ZIVt8PFoSrKZOotbUwPyunoiJup7FoVlnP5POeVR1izLUs8TVVn8rZo0QCGEXwb4st5Mxieb0vJruL1yAeF/f6hPDw/mWXmgsH2NqZ7J010JOEY2GrAuUohaaxqIu9qa0wNRcwlZFm3BTjAZSIumG3y0QhRMdtWmk6oKKChZxGXbO2tAHubLgvyQFUo1d0uZepL7nypHyycvg0d0/65yl4tx7JetIiqlxk8B+dc2aC8iY2ntBWrcaduKvLmO38fs6kGk3Q/kqxaohFZTtl/cbrw3wZlLmPjgmT4lqa9r4pAzo3SWlcTyPgWtM2I6s2ws17KeiVTFG53cVg== 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=Q2aYsVE73z8a8p3uFFxhv7wPUUbk80t4pULiXTgteLs=; b=l2u20sIGhKRGAxxdWXi+KRCEWh5gL22BCs0QrE1+hwNn29e7CjVHsw24jiDMtF6zHixXjz+6uClb+/7PzFc/VqdZtHuwHysEKTzfxAay/vEPiTKOV/Amj6tnmW85poJi/YHs7gbs/MTtzYVCVqRmn0pu58PWXw7Na83yrufIjLaVM32PEBGE7nQkwTFN1SF6etOXxYf9lYWstnrbQnMnCpgnN8nK8FsOJMpndWgLUvX2G3CSfLQG6kzooe/m4M2tUQIMmGz1nBSpzRPM3VjFBGRc8fN74+joDHRLid7r54/V2mBOhTmHFORpUe9Qi6Z+Eg6B+UdJQzQRYoRwuf6CdA== 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=Q2aYsVE73z8a8p3uFFxhv7wPUUbk80t4pULiXTgteLs=; b=4YnxspsfADkRAMzn+USiiA3Duo6LfDj1ueb5O8QT4/Q8Vz3dRBtUuz66zQiQTOuSSYtuaJloJ4JVkhyxpmgQpKtGF5NXw7LJ2FKD0rPss9uOrbBGYKK+GcojCeXRa1a+uzJDPTiYW4MMkqk8ZD/5NVdbPqHP5p28joSi1ASbENQ= Received: from MW4PR03CA0251.namprd03.prod.outlook.com (2603:10b6:303:b4::16) by CH2PR12MB4069.namprd12.prod.outlook.com (2603:10b6:610:ac::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Tue, 18 Jan 2022 20:23:06 +0000 Received: from CO1NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::66) by MW4PR03CA0251.outlook.office365.com (2603:10b6:303:b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 20:23:05 +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 CO1NAM11FT004.mail.protection.outlook.com (10.13.175.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Tue, 18 Jan 2022 20:23:05 +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; Tue, 18 Jan 2022 14:23:02 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization Date: Tue, 18 Jan 2022 14:22:32 -0600 Message-ID: <20220118202234.410555-3-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118202234.410555-1-terry.bowman@amd.com> References: <20220118202234.410555-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b13d468f-8852-461f-b7b0-08d9dac05593 X-MS-TrafficTypeDiagnostic: CH2PR12MB4069:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TGyDvfrOPW9TNzQev7IGmuQsyskWW98yEBtRpE6qmZcbF8QQu6oN3nZm4rWYmwiHrPLoo4O+/TeEsfBMk+q5PO/2t8ZsfhN3vE3hK0V9DO15rNv7KS+pqxyp+Hp2M4Ka1VcH3wWXBK/t3mET8NjTkAenbMDfebVbUReStkpId7GBUMvqu9luXRz8GCcy9H+teHwqtB3MlJwfbOKcyoY7rk0iYUS/5GkzP2tij89Lc+hGT/2uSCzp7a9h0RCROyssO0Gtk0cfvCnOR168Z7xA6hT9rOtPEFv1VTGrmV5VCcytB6GOffRd4amQWlbyGaiWI+636JNmIcDWVMOhgkmPBzvO8YxmO7l04gZV2KjYY9BwNGALC8Fu18IsZT6yhgNGa9ghafKqXOLgk9bdbJ55U4CDBgE1OdUse3VqlDVt92dDvN+HZzu9gfxiTn7ajAVCCPieLPoA4JxnxdcsxLKnn07+HZOtFBZbBs9lXL9oIvmAuQ7a4xxHajKuChLWuF5Sbt3/bIL1+MNB6Un+U1eDU4Lk012bZ8/iUXtPt2vmKSRki4moRDFdR0m+0Xm3wXaSXSIgiE2Q1TvkOWBT6stdAy68jqBDxEBpzwVsHjrRHtKSeoUJ4+mYOEQvSEcupjyG2qApZnGB9DqAHfxPGmAY7d7KvFLwQkYIvIsarAsc2JNLLs6oDfAl2WFYSM7xBovM47mounR5ZMclVqMTJiybNpvXZlw/Tn2CQoEkVEjGwBbeWZsxIuptmIu0YhOgHnQpUP5qXNXGOXbfAKxUSP4cq+hD3CcsDRGyMjgfofrlmkn42F+pk4NAngkZs61W6VIr 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:(4636009)(40470700002)(36840700001)(46966006)(70586007)(356005)(1076003)(40460700001)(70206006)(44832011)(5660300002)(2616005)(83380400001)(316002)(54906003)(336012)(110136005)(2906002)(426003)(8936002)(8676002)(82310400004)(81166007)(36756003)(47076005)(508600001)(16526019)(26005)(186003)(7696005)(4326008)(36860700001)(6666004)(86362001)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 20:23:05.2237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b13d468f-8852-461f-b7b0-08d9dac05593 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: CO1NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4069 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Combine MMIO base address and alternate base address detection. Combine based on layout type. This will simplify the function by eliminating a switch case. Move existing request/release code into functions. This currently only supports port I/O request/release. The move into a separate function will make it ready for adding MMIO region support. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman To: Guenter Roeck To: linux-watchdog@vger.kernel.org To: Jean Delvare To: linux-i2c@vger.kernel.org To: Wolfram Sang To: Andy Shevchenko To: Rafael J. Wysocki Cc: linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck Cc: Robert Richter Cc: Thomas Lendacky --- drivers/watchdog/sp5100_tco.c | 168 +++++++++++++++++++--------------- 1 file changed, 95 insertions(+), 73 deletions(-) diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c index ecc273b9b17f..64ecebd93403 100644 --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -223,6 +223,66 @@ static u32 sp5100_tco_read_pm_reg32(u8 index) return val; } +static int __sp5100_tco_prepare_base(struct sp5100_tco *tco, + u32 mmio_addr, + const char *dev_name) +{ + struct device *dev = tco->wdd.parent; + int ret = 0; + + if (!mmio_addr) + return -ENOMEM; + + if (!devm_request_mem_region(dev, mmio_addr, + SP5100_WDT_MEM_MAP_SIZE, + dev_name)) { + dev_dbg(dev, "MMIO address 0x%08x already in use\n", + mmio_addr); + return -EBUSY; + } + + tco->tcobase = devm_ioremap(dev, mmio_addr, + SP5100_WDT_MEM_MAP_SIZE); + if (!tco->tcobase) { + dev_dbg(dev, "MMIO address 0x%08x failed mapping.\n", + mmio_addr); + devm_release_mem_region(dev, mmio_addr, + SP5100_WDT_MEM_MAP_SIZE); + return -ENOMEM; + } + + dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", + mmio_addr); + + return ret; +} + +static int sp5100_tco_prepare_base(struct sp5100_tco *tco, + u32 mmio_addr, + u32 alt_mmio_addr, + const char *dev_name) +{ + struct device *dev = tco->wdd.parent; + int ret = 0; + + dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", + mmio_addr); + + /* Check MMIO address conflict */ + ret = __sp5100_tco_prepare_base(tco, mmio_addr, dev_name); + + /* Check alternate MMIO address conflict */ + if (ret) + ret = __sp5100_tco_prepare_base(tco, alt_mmio_addr, + dev_name); + + if (ret) + dev_err(dev, "Failed to reserve-map MMIO (%X) and alternate MMIO (%X) regions. ret=%X", + mmio_addr, alt_mmio_addr, ret); + + return ret; +} + static int sp5100_tco_timer_init(struct sp5100_tco *tco) { struct watchdog_device *wdd = &tco->wdd; @@ -264,6 +324,7 @@ static int sp5100_tco_setupdevice(struct device *dev, struct sp5100_tco *tco = watchdog_get_drvdata(wdd); const char *dev_name; u32 mmio_addr = 0, val; + u32 alt_mmio_addr = 0; int ret; /* Request the IO ports used by this driver */ @@ -282,11 +343,35 @@ static int sp5100_tco_setupdevice(struct device *dev, dev_name = SP5100_DEVNAME; mmio_addr = sp5100_tco_read_pm_reg32(SP5100_PM_WATCHDOG_BASE) & 0xfffffff8; + + /* + * Secondly, Find the watchdog timer MMIO address + * from SBResource_MMIO register. + */ + /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */ + pci_read_config_dword(sp5100_tco_pci, + SP5100_SB_RESOURCE_MMIO_BASE, + &alt_mmio_addr); + if (alt_mmio_addr & ((SB800_ACPI_MMIO_DECODE_EN | + SB800_ACPI_MMIO_SEL) != + SB800_ACPI_MMIO_DECODE_EN)) { + alt_mmio_addr &= ~0xFFF; + alt_mmio_addr += SB800_PM_WDT_MMIO_OFFSET; + } break; case sb800: dev_name = SB800_DEVNAME; mmio_addr = sp5100_tco_read_pm_reg32(SB800_PM_WATCHDOG_BASE) & 0xfffffff8; + /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */ + alt_mmio_addr = + sp5100_tco_read_pm_reg32(SB800_PM_ACPI_MMIO_EN); + if (!(alt_mmio_addr & (((SB800_ACPI_MMIO_DECODE_EN | + SB800_ACPI_MMIO_SEL)) != + SB800_ACPI_MMIO_DECODE_EN))) { + alt_mmio_addr &= ~0xFFF; + alt_mmio_addr += SB800_PM_WDT_MMIO_OFFSET; + } break; case efch: dev_name = SB800_DEVNAME; @@ -305,87 +390,24 @@ static int sp5100_tco_setupdevice(struct device *dev, val = sp5100_tco_read_pm_reg8(EFCH_PM_DECODEEN); if (val & EFCH_PM_DECODEEN_WDT_TMREN) mmio_addr = EFCH_PM_WDT_ADDR; + + val = sp5100_tco_read_pm_reg8(EFCH_PM_ISACONTROL); + if (val & EFCH_PM_ISACONTROL_MMIOEN) + alt_mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + + EFCH_PM_ACPI_MMIO_WDT_OFFSET; break; default: return -ENODEV; } - /* Check MMIO address conflict */ - if (!mmio_addr || - !devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, - dev_name)) { - if (mmio_addr) - dev_dbg(dev, "MMIO address 0x%08x already in use\n", - mmio_addr); - switch (tco->tco_reg_layout) { - case sp5100: - /* - * Secondly, Find the watchdog timer MMIO address - * from SBResource_MMIO register. - */ - /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */ - pci_read_config_dword(sp5100_tco_pci, - SP5100_SB_RESOURCE_MMIO_BASE, - &mmio_addr); - if ((mmio_addr & (SB800_ACPI_MMIO_DECODE_EN | - SB800_ACPI_MMIO_SEL)) != - SB800_ACPI_MMIO_DECODE_EN) { - ret = -ENODEV; - goto unreg_region; - } - mmio_addr &= ~0xFFF; - mmio_addr += SB800_PM_WDT_MMIO_OFFSET; - break; - case sb800: - /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */ - mmio_addr = - sp5100_tco_read_pm_reg32(SB800_PM_ACPI_MMIO_EN); - if ((mmio_addr & (SB800_ACPI_MMIO_DECODE_EN | - SB800_ACPI_MMIO_SEL)) != - SB800_ACPI_MMIO_DECODE_EN) { - ret = -ENODEV; - goto unreg_region; - } - mmio_addr &= ~0xFFF; - mmio_addr += SB800_PM_WDT_MMIO_OFFSET; - break; - case efch: - val = sp5100_tco_read_pm_reg8(EFCH_PM_ISACONTROL); - if (!(val & EFCH_PM_ISACONTROL_MMIOEN)) { - ret = -ENODEV; - goto unreg_region; - } - mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + - EFCH_PM_ACPI_MMIO_WDT_OFFSET; - break; - } - dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", - mmio_addr); - if (!devm_request_mem_region(dev, mmio_addr, - SP5100_WDT_MEM_MAP_SIZE, - dev_name)) { - dev_dbg(dev, "MMIO address 0x%08x already in use\n", - mmio_addr); - ret = -EBUSY; - goto unreg_region; - } - } + ret = sp5100_tco_prepare_base(tco, mmio_addr, alt_mmio_addr, dev_name); + if (!ret) { + /* Setup the watchdog timer */ + tco_timer_enable(tco); - tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); - if (!tco->tcobase) { - dev_err(dev, "failed to get tcobase address\n"); - ret = -ENOMEM; - goto unreg_region; + ret = sp5100_tco_timer_init(tco); } - dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); - - /* Setup the watchdog timer */ - tco_timer_enable(tco); - - ret = sp5100_tco_timer_init(tco); - -unreg_region: release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE); return ret; } From patchwork Tue Jan 18 20:22:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BA8AC433EF for ; Tue, 18 Jan 2022 20:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344024AbiARUXS (ORCPT ); Tue, 18 Jan 2022 15:23:18 -0500 Received: from mail-bn8nam11on2057.outbound.protection.outlook.com ([40.107.236.57]:28768 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1349205AbiARUXS (ORCPT ); Tue, 18 Jan 2022 15:23:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m6LxbIM9gA7p35xUW5b0lJew9ZKsz7o7otTxFeeJMh/UX43NC7txxucCVGheJ6JIBt775gEgc6LOxH6KuBGoXb1CqPYAHV64uczbNsrKD8nFBM9i1Z15IzyaffaR3HMB7i6Hvt4OmFFN0ag5jwy8JpkIp+XjtkQEAg6Pag+mYbzrz3vZ/pwKoWHCduM7hUqvRHlx20b1D/PcUfFQ/35qQPlwRJmtm7YdVpgSXGCZNw+OsIQn/2d4EQo0fydGprRNhO81F7IVkFUw3cR6JKrGtFxiPBs7i6KZMhOf6uZBacE6tfQb+qtFYmY87AtEoOhTjZalfJWRB3jP00ORYI0OqQ== 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=vTmUlHQWt9OwKjE8b4UnMf3H2eWISzjS86dCFJlVsVM=; b=E3q/oMwjsuSd00qxNdf+pIMJD2rxKG0YMdQZPd9W0/IbLXCw/o8kDpstSfqwPvJftWwA+Sz3FdFukl0F+bGCmv4BwkekZEi0y6OkRhyErCVvCtAahWhyktwDlRRZSbG0Bs4oAnYY55/h9se/YBx5AMk2bPzmPoF6eQX8MP0oNgLsgR095O9zaQ5OqBNsNtQ1RkW+5zbFYqMrsvlzJ3Mbx3AVNNUoJsEZPlD/UapVcnNvehq02Y+4DOYTEztctnqun8BUA/oVwuTKR/GVbjJ25qziAzV+OMdtLR5WmIk+MyIoKDeTE1Q9gEnydHtK4iFb8QoBbIVcTxYsAXdCoNep2Q== 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=vTmUlHQWt9OwKjE8b4UnMf3H2eWISzjS86dCFJlVsVM=; b=5cSnPJvXl0cQf77A6AemINLde+A3FxfWQg8cUwWEscXNk0An0/JbvFG0DUAAcEzv0qecxU1JNdX0qc+4pe/IC51qVzeiTa3pzUuuyq3pIRM+yrW+1qADCDeWakYih+Syf6H77va7JVoNJ+iE6HrbeKu5fADi3L2ZZBkdGyXDsjs= Received: from MWHPR21CA0052.namprd21.prod.outlook.com (2603:10b6:300:db::14) by DM6PR12MB2826.namprd12.prod.outlook.com (2603:10b6:5:76::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.13; Tue, 18 Jan 2022 20:23:15 +0000 Received: from CO1NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:300:db:cafe::9c) by MWHPR21CA0052.outlook.office365.com (2603:10b6:300:db::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.3 via Frontend Transport; Tue, 18 Jan 2022 20:23:15 +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 CO1NAM11FT015.mail.protection.outlook.com (10.13.175.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 20:23:14 +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; Tue, 18 Jan 2022 14:23:13 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 3/4] Watchdog: sp5100_tco: Add initialization using EFCH MMIO Date: Tue, 18 Jan 2022 14:22:33 -0600 Message-ID: <20220118202234.410555-4-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118202234.410555-1-terry.bowman@amd.com> References: <20220118202234.410555-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0eb39a66-2d47-4535-c3c0-08d9dac05b2a X-MS-TrafficTypeDiagnostic: DM6PR12MB2826:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: APQRqSqfyoYheuqqxTG6/Xrwuzej3EnnA28jdso15GxecIZ/vKro6xa0ExGn5idjWAqW2Ydr37lgAnrl6RSimYVvcLoFhNkkn04qrE6kbc2Gw/qwX0b43VmB5fzGsSMjhnlrn7njxUC0dA8Eg7huHpGLJoSCVGec2Ggyojr3280Kdh5gr5U/DzVu3GEehsZ2wALI3kn1KxVRBgA0P9swDVFvxywP08gDR8NUi+c1+RgeVC4kFk3HJNjE9ywP3jP5nEkGHfeEOmYU68KivjQYNhFjbNSCH3naPHRFLYH9DJy+cqno42tkfHHj5dwXkJfjD+xL6k2OlhvKKEYd3QTZkg3qKEEYRmlrTqKPLJHLWlrIsMW51XSObWf1W0t/mWpWrxnjWbmu7Vqi2uMoWT0tMAkT5dj1bP16BYrAkfr88+sQfF4paV/zON5iYTQ/jA+YSzAyDYnvdaSkA94rWaTW5WFY8dMxgl3ZL5rN79WNZsKQplXyzTLlUtTNkhd+RlAUjk5FS7h9ZB2bgNjrAi/2RH4vxQ7rxvXR053MMXYpU9nD4MlqinIS6ZpQZjXqhmgPmJBybIBR/CgjQICI/VEcJN+n8OW+yYQpZssTERfLcytX7s0pV38T6bFr2JBNjKaNaiMz1SIFQElAp198jXm6LEM5BwOicICB+VKpmypT6wJfqiWCuT+IMpRvvJqarxo2dxcw4MlvUrXaiCZ1gPZtwdSG1RGz7w5xOGdfbRI9lwmtsIxiIAC+VFgX1bTVMYcOEn/oQDWFrrR385pm7c94Y/c0MJtXfm8Bt6syzolAY+WfSc5B0SjiPMkSp1kiXi0N 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:(4636009)(40470700002)(46966006)(36840700001)(186003)(16526019)(47076005)(336012)(426003)(44832011)(26005)(2616005)(2906002)(36860700001)(82310400004)(81166007)(356005)(40460700001)(83380400001)(316002)(1076003)(70206006)(70586007)(54906003)(36756003)(110136005)(6666004)(86362001)(7696005)(8676002)(5660300002)(4326008)(8936002)(508600001)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 20:23:14.2897 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0eb39a66-2d47-4535-c3c0-08d9dac05b2a 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: CO1NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2826 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org cd6h/cd7h port I/O can be disabled on recent AMD hardware. Read accesses to disabled cd6h/cd7h port I/O will return F's and written data is dropped. It is recommended to replace the cd6h/cd7h port I/O with MMIO. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman To: Guenter Roeck To: linux-watchdog@vger.kernel.org To: Jean Delvare To: linux-i2c@vger.kernel.org To: Wolfram Sang To: Andy Shevchenko To: Rafael J. Wysocki Cc: linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck Cc: Robert Richter Cc: Thomas Lendacky Tested-by: Jean Delvare --- drivers/watchdog/sp5100_tco.c | 88 ++++++++++++++++++++++++++++++++++- drivers/watchdog/sp5100_tco.h | 5 ++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c index 64ecebd93403..36519a992ca1 100644 --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -49,7 +49,7 @@ /* internal variables */ enum tco_reg_layout { - sp5100, sb800, efch + sp5100, sb800, efch, efch_mmio }; struct sp5100_tco { @@ -209,6 +209,8 @@ static void tco_timer_enable(struct sp5100_tco *tco) ~EFCH_PM_WATCHDOG_DISABLE, EFCH_PM_DECODEEN_SECOND_RES); break; + default: + break; } } @@ -318,6 +320,87 @@ static int sp5100_tco_timer_init(struct sp5100_tco *tco) return 0; } +static u8 efch_read_pm_reg8(void __iomem *addr, u8 index) +{ + return readb(addr + index); +} + +static void efch_update_pm_reg8(void __iomem *addr, u8 index, u8 reset, u8 set) +{ + u8 val; + + val = readb(addr + index); + val &= reset; + val |= set; + writeb(val, addr + index); +} + +static void tco_timer_enable_mmio(void __iomem *addr) +{ + efch_update_pm_reg8(addr, EFCH_PM_DECODEEN3, + ~EFCH_PM_WATCHDOG_DISABLE, + EFCH_PM_DECODEEN_SECOND_RES); +} + +static int sp5100_tco_setupdevice_mmio(struct device *dev, + struct watchdog_device *wdd) +{ + struct sp5100_tco *tco = watchdog_get_drvdata(wdd); + const char *dev_name = SB800_DEVNAME; + u32 mmio_addr = 0, alt_mmio_addr = 0; + struct resource *res; + void __iomem *addr; + int ret; + + res = request_mem_region(EFCH_PM_ACPI_MMIO_PM_ADDR, + EFCH_PM_ACPI_MMIO_PM_SIZE, + "sp5100_tco"); + + if (!res) { + dev_err(dev, + "SMB base address memory region 0x%x already in use.\n", + EFCH_PM_ACPI_MMIO_PM_ADDR); + return -EBUSY; + } + + addr = ioremap(EFCH_PM_ACPI_MMIO_PM_ADDR, + EFCH_PM_ACPI_MMIO_PM_SIZE); + if (!addr) { + release_resource(res); + dev_err(dev, "SMB base address mapping failed.\n"); + return -ENOMEM; + } + + if (!(efch_read_pm_reg8(addr, EFCH_PM_DECODEEN) & + EFCH_PM_DECODEEN_WDT_TMREN)) { + efch_update_pm_reg8(addr, EFCH_PM_DECODEEN, + 0xff, + EFCH_PM_DECODEEN_WDT_TMREN); + } + + /* Determine MMIO base address */ + if (efch_read_pm_reg8(addr, EFCH_PM_DECODEEN) & + EFCH_PM_DECODEEN_WDT_TMREN) + mmio_addr = EFCH_PM_WDT_ADDR; + + /* Determine alternate MMIO base address */ + if (efch_read_pm_reg8(addr, EFCH_PM_ISACONTROL) & + EFCH_PM_ISACONTROL_MMIOEN) + alt_mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + + EFCH_PM_ACPI_MMIO_WDT_OFFSET; + + ret = sp5100_tco_prepare_base(tco, mmio_addr, alt_mmio_addr, dev_name); + if (!ret) { + tco_timer_enable_mmio(addr); + ret = sp5100_tco_timer_init(tco); + } + + iounmap(addr); + release_resource(res); + + return ret; +} + static int sp5100_tco_setupdevice(struct device *dev, struct watchdog_device *wdd) { @@ -327,6 +410,9 @@ static int sp5100_tco_setupdevice(struct device *dev, u32 alt_mmio_addr = 0; int ret; + if (tco->tco_reg_layout == efch_mmio) + return sp5100_tco_setupdevice_mmio(dev, wdd); + /* Request the IO ports used by this driver */ if (!request_muxed_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE, "sp5100_tco")) { diff --git a/drivers/watchdog/sp5100_tco.h b/drivers/watchdog/sp5100_tco.h index adf015aa4126..2df8f8b2c55b 100644 --- a/drivers/watchdog/sp5100_tco.h +++ b/drivers/watchdog/sp5100_tco.h @@ -83,3 +83,8 @@ #define EFCH_PM_ACPI_MMIO_ADDR 0xfed80000 #define EFCH_PM_ACPI_MMIO_WDT_OFFSET 0x00000b00 +#define EFCH_PM_ACPI_MMIO_PM_OFFSET 0x00000300 + +#define EFCH_PM_ACPI_MMIO_PM_ADDR (EFCH_PM_ACPI_MMIO_ADDR + \ + EFCH_PM_ACPI_MMIO_PM_OFFSET) +#define EFCH_PM_ACPI_MMIO_PM_SIZE 8 From patchwork Tue Jan 18 20:22:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 064AEC433EF for ; Tue, 18 Jan 2022 20:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344128AbiARUX3 (ORCPT ); Tue, 18 Jan 2022 15:23:29 -0500 Received: from mail-bn7nam10on2049.outbound.protection.outlook.com ([40.107.92.49]:55041 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239708AbiARUX2 (ORCPT ); Tue, 18 Jan 2022 15:23:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P2qizqIDA18anrtePwkQdRdgk9/ARsdc/Q6GQUlQaE/6ro8dbQnGeoRiu1TEqpO3Lw2KDRS1+fBgbDjNf6rb+wSUaHJmMUEEpguacAQm8aj3xBUz1glA0QF2lnNjV1WyO2EjIa+kcq+BV2QaeX8vpedUpLG5Xw/rnivwbEuQPBNcrRYgVoxBN84QGcds87hyzS8Bab6bpEjKoDqz9M7Mc68a1IpwZreQSFeq6vxl2IWvC6KpC4jHDK/gXBLxxqM5C7dFy8tV5mIEAsEz+5an7CcAWfzVb36CMjmyp3Pl20PNGVvGawGD7bw0P5PQO49f7KSGBnCOWPgNgy/zjCIHXg== 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=SbIvtPC0slPnXr9HdZTmd6gK6ENtB91sMYXUzm2ay6E=; b=SmqWvvbI5SVSrg6pJGiXzxt2EXMJs39/vAquoRBA/wDCHvWaGD38UihOpBL8VsEATTRIGF6/GAyl9ngFBs0otuQLIISPCkEeUJ4KPvofR2SgEjjJMug0QM0y1l0uPx7VrL8KAGDJK5V3MwnTUq41sNyGrBWMdw27VZUfsXTEGX2dW5Zaa6kVhw0hrZO2oLZ8Rkv2ZnR8m517W7JwfY5ORVnprWQyNq02IeF0GvjwQ9/AATHdpdYR9MQZFtoOGOdO7h2e+kBFPnJCcxmAZA8nkfEAi8v6IZSFRrK5FmEH/qdaH/T0TgSyknq0IVLbACbbP7Mf9WNvJVJRd11zKNYBpQ== 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=SbIvtPC0slPnXr9HdZTmd6gK6ENtB91sMYXUzm2ay6E=; b=bRJIm1VKql7cqAkD8BW/vObWcSkcYMy0s49hMpEhMk37sFjW34hVahLV7GApN2NRyxc6+wNb5m8xWlScmFbbVysT1xFvYXL/yYwo5ntCfgfEr6Fl+bT9oP3BtVZBBMc6ncY5Sor5N3BPvAGvNmP/xvXxuzFJCq6PdUtm9I/ElF0= Received: from MW2PR16CA0041.namprd16.prod.outlook.com (2603:10b6:907:1::18) by CY4PR12MB1429.namprd12.prod.outlook.com (2603:10b6:903:42::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.12; Tue, 18 Jan 2022 20:23:26 +0000 Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:907:1:cafe::c0) by MW2PR16CA0041.outlook.office365.com (2603:10b6:907:1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11 via Frontend Transport; Tue, 18 Jan 2022 20:23:25 +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 CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 20:23:25 +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; Tue, 18 Jan 2022 14:23:24 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , Subject: [PATCH v3 4/4] Watchdog: sp5100_tco: Enable Family 17h+ CPUs Date: Tue, 18 Jan 2022 14:22:34 -0600 Message-ID: <20220118202234.410555-5-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118202234.410555-1-terry.bowman@amd.com> References: <20220118202234.410555-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d34794b-cda2-48a2-6324-08d9dac0619a X-MS-TrafficTypeDiagnostic: CY4PR12MB1429:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T+z/ruVCkLvSosEKIvh0P6PlrxvhblyWfqe5O1F5yjCoDsnBIMNeRYcH8xjKN+KyO8aoTZeIBDC7dnAkN8a28M7uOy4RAAw+RTdjfuAK3CrCyFWlGg6ANN3h0oyE6orDYTsnpVB3bnmFdvvOFjt4pw/llBgWBbtuIqGbygTopWK3wn1jWhYB2Uwi0WrmEFWSyCtyiKIOIVxqFEB3oPUmvvATUs0Lj/W8QH4/JX8E3ZgqhkTrXcWqY3wuI74x66iDqis26Wmu0kPXWkiOmQFkF9qyMu3+AUoa1VWZ3mMP8pL2IXGP1mtcTaqV5CnoMd4w8aw8PUmz41+LkRTBM4fvTCzFleEM1Ta7Pm59/TZ7NnMrmqN4FW5wrLyzzpNdc6eCO/fkz5nTWH5BBIq9CcMIzSD99pRVYzePoJq4kOKhzNFYRm7YrWNxRS0hYKfZFs2vvDmLKWcFTam+dIZ1Z2rMFjjzKb4M+7S1OsSkqILpJa+Z/fKLTF9jvB2sSgDcJVLfq919vF/TGj1F3or2QOOVTipSM+NY/jo/OgXcg9i/9mwBUnczsE45M4mw8yLmENa4SYXR8hnwPna20xPXj2oDyMQfxYYqOxV9UH8ZTeQMV4IhlSTALiC7WzsWJkkUwXwJMg7juaV/ftuCs5Ylnj5OxICcGAYI1iDGh410AFeGqjoCY29YE7/bJ8G/WR1Fq2eweSTWWMchUglx1F+H2aGH8gZ3Bbsg8OJn3qf1Gw8hrq7QRPM4Ib/gRXesjTe+OsjZM6/CiZ1mD2lV6/56NaI1OfnRzxvKk7i19Tl5hyCS2pYyt/VujQXGtDuHkaWE3J8X 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:(4636009)(36840700001)(40470700002)(46966006)(36860700001)(26005)(8676002)(70586007)(508600001)(86362001)(8936002)(356005)(110136005)(1076003)(81166007)(7696005)(82310400004)(2616005)(47076005)(36756003)(40460700001)(6666004)(54906003)(426003)(44832011)(2906002)(316002)(336012)(186003)(4326008)(16526019)(83380400001)(5660300002)(70206006)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 20:23:25.4001 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d34794b-cda2-48a2-6324-08d9dac0619a 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: CO1NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1429 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The driver currently uses a CPU family match of 17h to determine EFCH_PM_DECODEEN_WDT_TMREN register support. This family check will not support future AMD CPUs and instead will require driver updates to add support. Remove the family 17h family check and add a check for SMBus PCI revision ID 0x51 or greater. The MMIO access method has been available since at least SMBus controllers using PCI revision 0x51. This revision check will support family 17h and future AMD processors including EFCH functionality without requiring driver changes. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman To: Guenter Roeck To: linux-watchdog@vger.kernel.org To: Jean Delvare To: linux-i2c@vger.kernel.org To: Wolfram Sang To: Andy Shevchenko To: Rafael J. Wysocki Cc: linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck Cc: Robert Richter Cc: Thomas Lendacky Reviewed-by: Jean Delvare --- drivers/watchdog/sp5100_tco.c | 16 ++++------------ drivers/watchdog/sp5100_tco.h | 1 + 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c index 36519a992ca1..b949dcd9f780 100644 --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -86,6 +86,10 @@ static enum tco_reg_layout tco_reg_layout(struct pci_dev *dev) dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && dev->revision < 0x40) { return sp5100; + } else if (dev->vendor == PCI_VENDOR_ID_AMD && + sp5100_tco_pci->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && + sp5100_tco_pci->revision >= AMD_ZEN_SMBUS_PCI_REV) { + return efch_mmio; } else if (dev->vendor == PCI_VENDOR_ID_AMD && ((dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS && dev->revision >= 0x41) || @@ -461,18 +465,6 @@ static int sp5100_tco_setupdevice(struct device *dev, break; case efch: dev_name = SB800_DEVNAME; - /* - * On Family 17h devices, the EFCH_PM_DECODEEN_WDT_TMREN bit of - * EFCH_PM_DECODEEN not only enables the EFCH_PM_WDT_ADDR memory - * region, it also enables the watchdog itself. - */ - if (boot_cpu_data.x86 == 0x17) { - val = sp5100_tco_read_pm_reg8(EFCH_PM_DECODEEN); - if (!(val & EFCH_PM_DECODEEN_WDT_TMREN)) { - sp5100_tco_update_pm_reg8(EFCH_PM_DECODEEN, 0xff, - EFCH_PM_DECODEEN_WDT_TMREN); - } - } val = sp5100_tco_read_pm_reg8(EFCH_PM_DECODEEN); if (val & EFCH_PM_DECODEEN_WDT_TMREN) mmio_addr = EFCH_PM_WDT_ADDR; diff --git a/drivers/watchdog/sp5100_tco.h b/drivers/watchdog/sp5100_tco.h index 2df8f8b2c55b..4fac39a2f12f 100644 --- a/drivers/watchdog/sp5100_tco.h +++ b/drivers/watchdog/sp5100_tco.h @@ -88,3 +88,4 @@ #define EFCH_PM_ACPI_MMIO_PM_ADDR (EFCH_PM_ACPI_MMIO_ADDR + \ EFCH_PM_ACPI_MMIO_PM_OFFSET) #define EFCH_PM_ACPI_MMIO_PM_SIZE 8 +#define AMD_ZEN_SMBUS_PCI_REV 0x51