From patchwork Sun Jan 30 18:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538600 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 570AEC433FE for ; Sun, 30 Jan 2022 18:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355119AbiA3Sl5 (ORCPT ); Sun, 30 Jan 2022 13:41:57 -0500 Received: from mail-bn1nam07on2072.outbound.protection.outlook.com ([40.107.212.72]:36462 "EHLO NAM02-BN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1354973AbiA3Slu (ORCPT ); Sun, 30 Jan 2022 13:41:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EglupFkOqorpWisx0u2OP7rReze2TfNF1iFFBV6XsquV99dRwapRCINxcFz7Sugrt7myZqLqaj+3R1gKC4GIKpP+SEt0ET4yI9gc7hFmaMUdCI69NRxaHeAePIznNLp70cv33o/oZiR7mZ0HD39aBqMzCa0ahk9JWolFieRr/+0MRJ12h1TKtvFAdHtQUWAN/1mKhhwnUr0UKPINsJxmC2Inc2mu9R2yrBhiZ+bsU02lchGLLYrWm2B0B+QO8MC6majcOrNGubqdQt3ZClvhiT0H53WBMdNvbtwqOtTBBeJC4mPdpt6FEI6mwiwB8jec7JSwzftJ52gzNWPI1c10Ag== 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=19JLUt6bJpGtuAkGLDWExZMhbU1X8lsFCDnG1/8nrmo=; b=PRWcuWhA0S7zj/umIhAfs/PIuyIiQo2tknSsevItqEpKqJdbk7AKjepBR3vr8BZSgSxYiT9YCQ6xkGj4cBm/bZXZtShv9cOgYt9UCMICE6Z35juQnaUt12SPDTx59b21wH4I0qycRJHkyq7Gtp5XnQ/XgCUBXeABmseAQ++86NqV5mjX2G5l+e8xJiPB9iHGRTgcVTkujl3F29MnuePrCyUdDsdAUjvIvUCNkQ9OL9zniLc2aDbFBFmX/kM/Gdx2kyw2Ln7JzFKEFDahCJBsp9l1GVbKVRLvnNF1hQmYHKht1j14Ugz7bsVjyg1tL6zsvCXfdLSSHPMaZchrEG8pyw== 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=19JLUt6bJpGtuAkGLDWExZMhbU1X8lsFCDnG1/8nrmo=; b=ZP04JFbaRcvuzlBsLLsNl7Y9A/JWDyT0SafVMBFbj6lFp8AJoho51seVaxPcP965/OheJWTa2Muso/jRwJA1FYT32HecgvDPZxXY85+y72SWdblOS4zksunEMkMyP9N8KAOid0wEuvFTcrIVJeaKQ+7F9e0lMXTaK6qnBtaUEzs= Received: from BN9PR03CA0305.namprd03.prod.outlook.com (2603:10b6:408:112::10) by CY4PR12MB1223.namprd12.prod.outlook.com (2603:10b6:903:38::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20; Sun, 30 Jan 2022 18:41:48 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::3) by BN9PR03CA0305.outlook.office365.com (2603:10b6:408:112::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Sun, 30 Jan 2022 18:41:48 +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 BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) 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 18:41:47 +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 12:41:46 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 1/9] kernel/resource: Introduce request_mem_region_muxed() Date: Sun, 30 Jan 2022 12:41:22 -0600 Message-ID: <20220130184130.176646-2-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: 3e9956f3-be09-4f0b-5aff-08d9e4202c1c X-MS-TrafficTypeDiagnostic: CY4PR12MB1223:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FNgHIy+UaEDWcMB49rQxWscaV47JaHCyRZg/wBQvD+C91KhKD1pWUOyhs7D0u2Edi3sAM7V4BbEMcDZf5dYEkEo4RG5vi/OefExDP/2fput5xHqhR/IfGPKpzEfR7yXvZ6aTs4MpRLvcxB8rSxPkcXawRz1vl1MFPq59szPrRQfr22l1Jsh9wOW9naIklcA4poGLBu88scDG/j8gpaJ1w58ZEjj6hehxkzfPjVxnVw4CXZTQp0s4mRyYY9jxpMIepyqcVkTVk/4zmk+aO1lKSZ6WYxy8XUqUFm2kgDKEmMinF2kCZ7/ACdcOSZ3vnUFdl4Z+cAf3e2DH7HTOLdwE5VAsGJH2y3/WRgX4lljizEIFLKLLNtg8Mgh7Ps57nNnB79CF/VFyi8dQSbF5yySDgrVHSnHLRZvwjlb+3RQ/z/ykklNFkAQwrMQv+Gn2xqBxkH/ReEKYxEzSWGXzl4awavHEE/N+Fu8jDwx56/f7iWOBONTkhDlPNRNIJyENSAsb8ihC/gfinOMB3Cme2cBHa11uLs196zsM29pavypvbUsIgloDNulSC3izuRF4jKa+DOQbkizHYnYQQM5vXNdGlO26SFBt25MVY5M78MsfcD5qQ0mtKc4EMdvgdzANYZXCugUO+ZVy9wCg3HQL7Cvhjijem+U+CmNiatVNRsT/E5KZiLCx2fwyaV5EmwPJXgbFk6tvBOeXgC046puC+Khzw5Ol/FE4DDSUuDbXRmc2Qx4= 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)(40470700004)(36840700001)(46966006)(186003)(2616005)(36756003)(6666004)(40460700003)(47076005)(336012)(426003)(86362001)(16526019)(1076003)(26005)(36860700001)(44832011)(2906002)(5660300002)(356005)(81166007)(54906003)(110136005)(70206006)(4326008)(8676002)(8936002)(70586007)(83380400001)(7696005)(82310400004)(316002)(508600001)(36900700001)(2101003)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:41:47.9153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e9956f3-be09-4f0b-5aff-08d9e4202c1c 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: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1223 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Support for requesting muxed memory region is implemented but not currently callable as a macro. Add the request muxed memory region macro. MMIO memory accesses can be synchronized using request_mem_region() which is already available. This call will return failure if the resource is busy. The 'muxed' version of this macro will handle a busy resource by using a wait queue to retry until the resource is available. Reviewed-by: Andy Shevchenko Signed-off-by: Terry Bowman --- include/linux/ioport.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 8359c50f9988..ec5f71f7135b 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -262,6 +262,8 @@ resource_union(struct resource *r1, struct resource *r2, struct resource *r) #define request_muxed_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name), IORESOURCE_MUXED) #define __request_mem_region(start,n,name, excl) __request_region(&iomem_resource, (start), (n), (name), excl) #define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name), 0) +#define request_mem_region_muxed(start, n, name) \ + __request_region(&iomem_resource, (start), (n), (name), IORESOURCE_MUXED) #define request_mem_region_exclusive(start,n,name) \ __request_region(&iomem_resource, (start), (n), (name), IORESOURCE_EXCLUSIVE) #define rename_region(region, newname) do { (region)->name = (newname); } while (0) From patchwork Sun Jan 30 18:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538340 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 13C11C433EF for ; Sun, 30 Jan 2022 18:42:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355000AbiA3SmC (ORCPT ); Sun, 30 Jan 2022 13:42:02 -0500 Received: from mail-mw2nam10on2053.outbound.protection.outlook.com ([40.107.94.53]:14882 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355006AbiA3SmB (ORCPT ); Sun, 30 Jan 2022 13:42:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fmz1EghJxKLG1DIoX2SAXNSfN+R/kjiNUBOySfmSdoJERUmvdZq2atidGIgww1lt+fSSUhEIwscIzddK55yNTSjlZ8pIoxMpQe3EZ6gXSFmik5R1kyXvCPGodAPMjzK/mlNXbePhMJK0FIQHZYqvjSWjuc+Mk/0CCyQ0AFgWhF/GE6/CqPkCp4EOe4/KDHuW+eKxVg57yYt46kNYU2Y5b6qxiHql21/SyLMiEvTDBAb5zHWUvFEucqGfq/vBbFkr32wwkfGXCF7WIzpasfueEvqnbHwLFQae3eNUwdj+ilZ2J3ZslaHE+EKXffL9o1MTelelptPUdd/veWnUg283aw== 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=2Dk20itXYKSkXBCrkUDRMnZ/etXP2JPAl0fxTsqnrM8=; b=EZG6sakByrE/2/fAtx62Kr5AIlgaZDdew7ye1uF3f6Go6FOuUEAEXAJVCH7UWAI4S4MrXvvfLGPgoT/irdRoyFsZlUdlMXHtfP82hGHtlueyv6qW+gEbcYrrv356wZ0HY5FzNore6UPICGYBP6pW+AhUkNoBI6OgQS3y2hmZHlvJ9gevL/i+7BXfZtmB+Ejn0ZLVLHY4d00ia3+6rnliUI82g2rTDmVBUUzV4xOlq42mc8spBAy+ZB+mJ/3UjeKEdvB8MfrfPaXENtYJerBVtNNsJkypRDoqJg83Vsa6B+CKEcymFl0xE5XsPUfTnQ9vD65Ka3RuOEa5JOxKQDa6Mg== 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=2Dk20itXYKSkXBCrkUDRMnZ/etXP2JPAl0fxTsqnrM8=; b=ZJKQ9IHadBhSsU03oK2m2QLi0veNr5NHWli4KTttRzfobQsxVGcC8HgRpR8vJOIOo3i63YXxIvkrU/WbL/kpCHGXcPt6B2oSl8/ZenIiREPhZKb60pjPpqRz7hObwoOetsOZAGYoJUUMf2fKMonTrOe54Nv9KQzaUdiXQ6C2vwI= Received: from BN9PR03CA0295.namprd03.prod.outlook.com (2603:10b6:408:f5::30) by DM5PR12MB1177.namprd12.prod.outlook.com (2603:10b6:3:6d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.18; Sun, 30 Jan 2022 18:41:59 +0000 Received: from BN8NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::7c) by BN9PR03CA0295.outlook.office365.com (2603:10b6:408:f5::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Sun, 30 Jan 2022 18:41:59 +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 BN8NAM11FT055.mail.protection.outlook.com (10.13.177.62) 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 18:41:59 +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 12:41:57 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 2/9] i2c: piix4: Replace hardcoded memory map size with a #define Date: Sun, 30 Jan 2022 12:41:23 -0600 Message-ID: <20220130184130.176646-3-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: b3195738-8985-4bf4-eb22-08d9e42032c5 X-MS-TrafficTypeDiagnostic: DM5PR12MB1177:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k0Z2i2cuEd5XaUndPed/GdQkuu/96IS/AMZR/BL7sQh2lfeSH5fbB8ZwK3dIeXxMJ9lRg0C8PUPIEqLxqdzzPbbR2y+FbUaa9AvjPTEJKCRkgY+BDHPGxGy8OrS6168QgQFHXGSLaPsNex0QOQfcjwzObQ3F2Nw8b2ltiqOhf2o4YAEVd0SBppoRPIXsFt/V1YCPAV9ta+HIoVhdM4sEzslJ9FrH1NAuloNmOineLpRT1lOH+N9UT1TyNonUmIsLrDwDsI8bWxjZwIWJ1b9jZg73vPS7qDnr5fQACAYUVO6p23lSB9KruLPvvajNH0ZLNOl94GsVgHcJUMhQeXSnCgRrHf7Cks1PMF9F0NNzTISBlcQS3h/kMmBwWuhJ4ddQmzgJPgY+NJ0ZT8HNyQVpH8rWxdM3EIToIqcR6F30yqgBkDAOZikFyqVAf1yCJOJ8RfGyucXABydoTYvZh1SokSy1d37fI0H+iWZJ+0tTwLB2VQH4uX396eGupemZCxZWwK90xrRB/ufOewUc59o+5NCihYkOM4tFOEvde7aSVjAZ5lgn42pphdQvc2+IqbjsaCfX0VvBs5aUBx4gjgRKItekTSMDejRy7MPghqq8o5g30ru90I1B3HrUyoQWvUyaAOiXRH2uHjOS8MIdWtidMUCNh57fNaqYqYy7N2ahjMmQT3X3j6iRCkC+fTi+UmhekUqjcB7+UnO3yevJxhCy7rjlTGD4KsbmnflGOMx8XF0= 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)(36840700001)(46966006)(40470700004)(54906003)(5660300002)(110136005)(426003)(336012)(6666004)(83380400001)(82310400004)(186003)(1076003)(26005)(81166007)(508600001)(16526019)(356005)(8676002)(8936002)(70206006)(7696005)(47076005)(70586007)(2906002)(36756003)(316002)(36860700001)(86362001)(44832011)(2616005)(4326008)(40460700003)(2101003)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:41:59.0772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3195738-8985-4bf4-eb22-08d9e42032c5 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: BN8NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1177 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Replace number constant with #define to improve readability and maintainability. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 8c1b31ed0c42..3ff68967034e 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -77,6 +77,7 @@ /* SB800 constants */ #define SB800_PIIX4_SMB_IDX 0xcd6 +#define SB800_PIIX4_SMB_MAP_SIZE 2 #define KERNCZ_IMC_IDX 0x3e #define KERNCZ_IMC_DATA 0x3f @@ -290,7 +291,8 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, else smb_en = (aux) ? 0x28 : 0x2c; - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, 2, "sb800_piix4_smb")) { + if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, + "sb800_piix4_smb")) { dev_err(&PIIX4_dev->dev, "SMB base address index region 0x%x already in use.\n", SB800_PIIX4_SMB_IDX); @@ -302,7 +304,7 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); - release_region(SB800_PIIX4_SMB_IDX, 2); + release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); if (!smb_en) { smb_en_status = smba_en_lo & 0x10; @@ -371,7 +373,8 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT; } } else { - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, 2, + if (!request_muxed_region(SB800_PIIX4_SMB_IDX, + SB800_PIIX4_SMB_MAP_SIZE, "sb800_piix4_smb")) { release_region(piix4_smba, SMBIOSIZE); return -EBUSY; @@ -384,7 +387,7 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, SB800_PIIX4_PORT_IDX; piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK; piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT; - release_region(SB800_PIIX4_SMB_IDX, 2); + release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); } dev_info(&PIIX4_dev->dev, @@ -682,7 +685,8 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, u8 port; int retval; - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, 2, "sb800_piix4_smb")) + if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, + "sb800_piix4_smb")) return -EBUSY; /* Request the SMBUS semaphore, avoid conflicts with the IMC */ @@ -758,7 +762,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, piix4_imc_wakeup(); release: - release_region(SB800_PIIX4_SMB_IDX, 2); + release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); return retval; } From patchwork Sun Jan 30 18:41:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538599 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 612A1C433FE for ; Sun, 30 Jan 2022 18:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355036AbiA3SmQ (ORCPT ); Sun, 30 Jan 2022 13:42:16 -0500 Received: from mail-bn1nam07on2058.outbound.protection.outlook.com ([40.107.212.58]:20734 "EHLO NAM02-BN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355085AbiA3SmN (ORCPT ); Sun, 30 Jan 2022 13:42:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDyqKEN1o6vpusYHgXnSFCJJas0JNh817eGRFwB6AaDIh84paNe7F+bWTiBNN4E2mQ/PqV23dclGudWzvjyqQkaNnnsfaRirxhAoIl9ow7dPvzb60CIk3wYDNx8ioLdr7u5IuNNhlUvIiQ4podoVHmK+dGH7Awq4yw4cj87tuv+Pq1gHwOEYvWVwe2qJpCzH8vyjJ0ue4CzXp6kN0qMGaTUNixSzzOoYZihohTtMGPvTqHxrkrK/BAc2rODfjfZbgTQJ8/tL2hektpGFHaO5coVLtDWR8LXYzAx7SeJpH7cgjyjKP5B2KdlD9UFqLmLUvbdNqMxjiL5hcR1vNxjANg== 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=EpVTpBG/qy065xnijxZfmolQK93glF0YL8OshJVQgmg=; b=hbTvk6IdmebKG8Vi7qKNhmJZgwvkTjr5M0scYW0km0hm+hUhqF2fopGML+n4V2k6wGz+T1oaf77sfp0rGAI11ft37e+lrytCPefEwSTFKa0luxPObjJMUWp4n236AMHFKdIU93jOoM5f9H5GUVVpBe7lAHj56ufIl89ufQMb0ac8VEayG7N7Qv/7rlyyGPB2/pHaDkrpo5k+80d4WFGS2BkGxYagSashukBP51pstUdRLpEX54SoMTsW7tbpYCJBgszPpUE22mv9ixDzLBE6ZFfUsBZGwfFqWGBPR9D0Vg3Tpgwh3GuOV9Et1Kl+2MYTcnmauByiVP/j95yWIJaDgg== 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=EpVTpBG/qy065xnijxZfmolQK93glF0YL8OshJVQgmg=; b=uCNGJPvQvC4ac/dm0mo89pZ7TzN+Mx4EZobf54lOBmKkFtwOOxeIfuwjP5i/0Ssf7xZTQaF1rex6zhglGFCA5CgomY/HVxH4f7UPCJoLEFQctiNkiMRhlOZgEyYEsaZq87yRDdnxjMbyTQ4jbtHgH7VkeoJx1wVHFPBIoxXpbBU= Received: from BN9PR03CA0247.namprd03.prod.outlook.com (2603:10b6:408:ff::12) by CH2PR12MB3976.namprd12.prod.outlook.com (2603:10b6:610:28::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.18; Sun, 30 Jan 2022 18:42:10 +0000 Received: from BN8NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::a6) by BN9PR03CA0247.outlook.office365.com (2603:10b6:408:ff::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.18 via Frontend Transport; Sun, 30 Jan 2022 18:42:10 +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 BN8NAM11FT012.mail.protection.outlook.com (10.13.177.55) 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 18:42:10 +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 12:42:09 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 3/9] i2c: piix4: Move port I/O region request/release code into functions Date: Sun, 30 Jan 2022 12:41:24 -0600 Message-ID: <20220130184130.176646-4-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: d452cfe6-bbd3-4a7d-764e-08d9e420395f X-MS-TrafficTypeDiagnostic: CH2PR12MB3976:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VB9eB9qk6pmVE4aMaIlMesxys+bVF9Vlg/Vi7IM3ziWicuQzT6SKM2Fmm2DzVcn4gqpIgDZX3sOczwwx/u0dLC0FOSegpdtzEjsj51W/ilELFSE6yVZtdT4tHZT1c6/51PHadKohTYOatfQ/z3NHqAGYtb/2L7VVUuAfIf/so/BeWJf/PMFCrHerOUYUNQiLrJ2t5MSiXBJEJC3aWQTZ5L1CbHb8Sl8/XzA11ArnuzXk03pR8CY9w1gFN+d2cppht/nhfv7KtC5z1bIWmfPKANyyMWVA9VUYQB+uFbG+ioVBf1Bsb6mbx/jbpeKLZSDjXIErh/L8CZuAet/bhPNUZjNZLJMho1ike/r0HJtqUONyt8dXw5hYVRo9G8S0GLlkBa96uF0Pfh/Oow+L0xqFq9fcEcREbMuPnfSG0MCtA+iOc8QeH98lw5UnYE+irsvAsZOxf0SRObQVSP65MT1QxeBUuf2TS1EJHrn9S1R86Gg0Kkjj9bGpVzsTRnXxvRJfG5z4hrH91ltRt+d0w//dx8dzFVi1RnbsEHD3x3UpztJc51/JYemh0VqH8L8I4IEck/mYALbyZbOpf1kIlfCQA8AW8TNo1+ycKeKyOD670gs8Lc/gEabieBXqZPSaaMYRgk0Pt0Gaj+JWO/wqifX+Qlk9GZcz808/BEeQWO1ITrcciLpGgWfp+HGoUFBeU7SCwczUcM+u+4+KLr3N4C59GyKuIkI69SKVtadMCgq+5D0= 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)(40470700004)(36840700001)(46966006)(54906003)(110136005)(5660300002)(336012)(426003)(83380400001)(6666004)(82310400004)(186003)(1076003)(26005)(81166007)(508600001)(16526019)(356005)(8676002)(8936002)(70206006)(7696005)(47076005)(70586007)(2906002)(36756003)(86362001)(316002)(36860700001)(44832011)(2616005)(4326008)(40460700003)(2101003)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:42:10.1654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d452cfe6-bbd3-4a7d-764e-08d9e420395f 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: BN8NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3976 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Move duplicated region request and release code into a function. Move is in preparation for following MMIO changes. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 39 +++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 3ff68967034e..5a98970ac60a 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -165,6 +165,24 @@ struct i2c_piix4_adapdata { u8 port; /* Port number, shifted */ }; +static int piix4_sb800_region_request(struct device *dev) +{ + if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, + "sb800_piix4_smb")) { + dev_err(dev, + "SMBus base address index region 0x%x already in use.\n", + SB800_PIIX4_SMB_IDX); + return -EBUSY; + } + + return 0; +} + +static void piix4_sb800_region_release(struct device *dev) +{ + release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); +} + static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id) { @@ -270,6 +288,7 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, unsigned short piix4_smba; u8 smba_en_lo, smba_en_hi, smb_en, smb_en_status, port_sel; u8 i2ccfg, i2ccfg_offset = 0x10; + int retval; /* SB800 and later SMBus does not support forcing address */ if (force || force_addr) { @@ -291,20 +310,16 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, else smb_en = (aux) ? 0x28 : 0x2c; - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, - "sb800_piix4_smb")) { - dev_err(&PIIX4_dev->dev, - "SMB base address index region 0x%x already in use.\n", - SB800_PIIX4_SMB_IDX); - return -EBUSY; - } + retval = piix4_sb800_region_request(&PIIX4_dev->dev); + if (retval) + return retval; outb_p(smb_en, SB800_PIIX4_SMB_IDX); smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); - release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); + piix4_sb800_region_release(&PIIX4_dev->dev); if (!smb_en) { smb_en_status = smba_en_lo & 0x10; @@ -685,9 +700,9 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, u8 port; int retval; - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, - "sb800_piix4_smb")) - return -EBUSY; + retval = piix4_sb800_region_request(&adap->dev); + if (retval) + return retval; /* Request the SMBUS semaphore, avoid conflicts with the IMC */ smbslvcnt = inb_p(SMBSLVCNT); @@ -762,7 +777,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, piix4_imc_wakeup(); release: - release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); + piix4_sb800_region_release(&adap->dev); return retval; } From patchwork Sun Jan 30 18:41:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538339 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 3BFDCC433EF for ; Sun, 30 Jan 2022 18:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243158AbiA3SnB (ORCPT ); Sun, 30 Jan 2022 13:43:01 -0500 Received: from mail-bn8nam11on2048.outbound.protection.outlook.com ([40.107.236.48]:63586 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355322AbiA3SmY (ORCPT ); Sun, 30 Jan 2022 13:42:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BI+C4Gv/Pm73D6npXpoCIeJqTuxFtHj6F4Dx5MwrC6o9t5AN70dBgIqNnJrdzhMM8qEE3c5+LtLN/4iYHueQOD8oddgt70f0LrI/m2xOjuO+U3OPRqdMLn34xQr0UWSWlLdBc0ctrm1lmDhoNTn2rUW07zeOcYLa0Z7UJbA/fn48JrRbALeK7+z8+3iheDKMPeNBC7TWe6/kPWfciWz3UWhArEjYbEZu2oGHLS3AF1HnaqIK5ctPRg74yLhh4N3bZ7bTFumwi4iZF0gA7j/yEs21oTKhxR+mUJzgI36kjiqnnKcYyWd+32DLD+VzFbA+LvhiVAMOMLASxEKqsee1gw== 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=dlzceb784wvwVXiQ6p9qRRakEeFMzbe41uJ7F3CpsOg=; b=PpA6MBu7ycWLVoFS2QrIibHVydGTH7D9pdu++oFGiSFIeqxRTV+qa8IpSnrCU0pFF5aamIc7oDZ3b+FICijeDdL6jhAzRLMxbx0mv8gvPjtIJjL49QEsUa8HZmzqV1P4VD4ay2qJfL6q/mw4ZK96hpBTdDdDWfl1tLlbcYRLim4Z3zC95B1SrktHWyI3jfqnk5pFirxaMjJps4XRD7+GpSaUdBcLuoZqUT585KWeh1mYuJwwyB6Av3bAuK1OfDH7QoOAx8+6mJCRCCfyXLo3ndquewuy68bYNRzvzUWxXGyu3CRBFR1O3ajuDRMY6R1r3vxg5v9XgEyq5J7G303AKg== 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=dlzceb784wvwVXiQ6p9qRRakEeFMzbe41uJ7F3CpsOg=; b=gP1FIhMrkYbCWoVOoq16/mmj6asCR7ZY50tsoflubXZEYzt9eNWPSj5IbGC3u5FEUnO+3fECqJd9f2b8vmHG3G9lDqXygiiY09rY2KwG9qObTFXaxbFXWeB7ObR+1lV0f+AffrvbOLmE/4MSKJVkaw/eJXLKBfiJ9N1yXcv+fuc= Received: from BN6PR14CA0002.namprd14.prod.outlook.com (2603:10b6:404:79::12) by CH2PR12MB3767.namprd12.prod.outlook.com (2603:10b6:610:26::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Sun, 30 Jan 2022 18:42:21 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:404:79:cafe::5e) by BN6PR14CA0002.outlook.office365.com (2603:10b6:404:79::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21 via Frontend Transport; Sun, 30 Jan 2022 18:42:21 +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 BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) 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 18:42:21 +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 12:42:20 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 4/9] i2c: piix4: Move SMBus controller base address detect into function Date: Sun, 30 Jan 2022 12:41:25 -0600 Message-ID: <20220130184130.176646-5-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: 6e8c4655-5853-4f4c-8ee8-08d9e4203ff7 X-MS-TrafficTypeDiagnostic: CH2PR12MB3767:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M+IljGm+JCa/RlfqeIuA7cjfPct6dwtNBDstl73y1z7UBS1kSWrHdtdpyn4IAEXipVRbJToxYJsjeBksM4ADL5F2ZFJT63o0jFX5iptFXeDeCFNKqWlglzEYSpVZzVjPYWQkyA5zHsRewn/1iy1m++nq9Kvea1xfygZ/vYEGAnuz71yK0ryxyK4Dso+J0+cOkUm/5O3fxgdnMg4BO1qWIfiU/4M0Nj17H/7OurzXJFhYVN68MoxE2scP4USpBoFAz11iUCiePZS4zLBSO6PVyuHRLf8Ew505eex9Rj2tjdgX6Kap5eZCs56VbgAHnozMFTBVHirfc1D6PsHcFDXpK4KUu9P85xuWtgOHvUGz5c6l6/KTIKPJXez3/OJfZkmCnBhdg/o4ue0p2Od2y3XjNPQM1VZNt+tszAOUsBnC/OtWnmqatYrr1O45vlL3a8nKa30zL/uiEAcb2JPOOOxvQxOf5Dtkr3zF+UOoYSYn/IPiphUooc2VcO/i3ru4gHcElJiyfELqEeJpuE5dMerPN3bV7pe02RYWGSqaxnr4RRR0IqBrdscbC13RHDPlntP6p2i3v4BrNjTN3bQQ4+iG0o27jXlgfWDtiNDUHL5IL3hdxz2E+xvGtsQvBEpbgaZVPqsqZ75SF1330GE+3TdUn9I82Fg1T+tkYF6h0K9Q7eEv5Jnk6iXYaKOcDwKXcOaLa+9kDvNU8iVDvwk/lnmQdzEXoJ7zTEFJMQxyvRPV9CM= 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)(40470700004)(36840700001)(8676002)(4326008)(8936002)(508600001)(356005)(86362001)(70206006)(40460700003)(70586007)(81166007)(54906003)(110136005)(82310400004)(316002)(47076005)(44832011)(5660300002)(36756003)(426003)(336012)(16526019)(26005)(186003)(1076003)(2906002)(7696005)(36860700001)(83380400001)(2616005)(2101003)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:42:21.2285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e8c4655-5853-4f4c-8ee8-08d9e4203ff7 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: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3767 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Move SMBus controller base address detection into function. Refactor is in preparation for following MMIO changes. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 71 +++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 5a98970ac60a..eab06e9e5fdf 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -282,12 +282,52 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, return piix4_smba; } +static int piix4_setup_sb800_smba(struct pci_dev *PIIX4_dev, + u8 smb_en, + u8 aux, + u8 *smb_en_status, + unsigned short *piix4_smba) +{ + u8 smba_en_lo; + u8 smba_en_hi; + int retval; + + retval = piix4_sb800_region_request(&PIIX4_dev->dev); + if (retval) + return retval; + + outb_p(smb_en, SB800_PIIX4_SMB_IDX); + smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); + outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); + smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); + + piix4_sb800_region_release(&PIIX4_dev->dev); + + if (!smb_en) { + *smb_en_status = smba_en_lo & 0x10; + *piix4_smba = smba_en_hi << 8; + if (aux) + *piix4_smba |= 0x20; + } else { + *smb_en_status = smba_en_lo & 0x01; + *piix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0; + } + + if (!*smb_en_status) { + dev_err(&PIIX4_dev->dev, + "SMBus Host Controller not enabled!\n"); + return -ENODEV; + } + + return 0; +} + static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, const struct pci_device_id *id, u8 aux) { - unsigned short piix4_smba; - u8 smba_en_lo, smba_en_hi, smb_en, smb_en_status, port_sel; + u8 smb_en, smb_en_status, port_sel; u8 i2ccfg, i2ccfg_offset = 0x10; + unsigned short piix4_smba; int retval; /* SB800 and later SMBus does not support forcing address */ @@ -310,33 +350,12 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, else smb_en = (aux) ? 0x28 : 0x2c; - retval = piix4_sb800_region_request(&PIIX4_dev->dev); + retval = piix4_setup_sb800_smba(PIIX4_dev, smb_en, aux, &smb_en_status, + &piix4_smba); + if (retval) return retval; - outb_p(smb_en, SB800_PIIX4_SMB_IDX); - smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); - outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); - smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); - - piix4_sb800_region_release(&PIIX4_dev->dev); - - if (!smb_en) { - smb_en_status = smba_en_lo & 0x10; - piix4_smba = smba_en_hi << 8; - if (aux) - piix4_smba |= 0x20; - } else { - smb_en_status = smba_en_lo & 0x01; - piix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0; - } - - if (!smb_en_status) { - dev_err(&PIIX4_dev->dev, - "SMBus Host Controller not enabled!\n"); - return -ENODEV; - } - if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) return -ENODEV; From patchwork Sun Jan 30 18:41:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538598 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 B6B63C433F5 for ; Sun, 30 Jan 2022 18:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347062AbiA3SnE (ORCPT ); Sun, 30 Jan 2022 13:43:04 -0500 Received: from mail-dm6nam10on2056.outbound.protection.outlook.com ([40.107.93.56]:44512 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355405AbiA3Smg (ORCPT ); Sun, 30 Jan 2022 13:42:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y3in9xfURWe2FSYZ0ZpEcr7TAc+O08hyjep8N+8k/p1MoETFfAz6bG3e4xZpK7qn7M4eSJOIcPjNqep++sJArS2ZfQpZkVP7zlu2qvCadebK5eK9HzwPZXA6XwPXo9G2QhA3KOM68bE+CDWVx9ARX6gQX0t/8UxfIlcHBI3Arm0eRxyL5jEE2DY+JoFtNd0k+3enI7NJGiNgWVJUsxqxyGcTKj341njcGKCzTMQuEfwG0xDXVBgoq2uA9qXkpWBlNJ9UBR33V7tvWaT7bTFO1aRO7SaEAn8ouGtbhmx7q8LDHityPPIlrQRV9tE0VYiB8kVZ5JbajnOnzLSykV0s2A== 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=Kaeqvj0ieVhZRvgKFiIDCSaGfERuMbMXUjROaXySCFQ=; b=faCv1XGPNJYHsMB89+4JBeqckAn/owhwDTA2HEI9ZeUfMhmwB990yii4SiX+TJJW2qbFuCHgdUEl7qwuHY9oTZuDfzGterOLnoZCMfTiZG9JVC0JmwrYdiw2YTRZRItJ42cp+y0cJaXTyL1UlQv6pSQd6GIYfhuJUc+ta3l4pwn11DlSoHeZwVt79YPjwg5n0jBaH0uHEh3M2aNCAfzphgoWAWV7NO29uKALR/Hfd7fOBl5x+uQtSoJbG+yaVoqwCiGAREVVVpcQCXXj3BxB59VHU34wg3jPtwfNAK3oDQo6ngPOnNgLzN53bsGtpsWfMgXw/15lzYHVDTuMr1DRZg== 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=Kaeqvj0ieVhZRvgKFiIDCSaGfERuMbMXUjROaXySCFQ=; b=EAZB71lBtBpd9PJoInar42lJI7Algs8i/mMkb3lL5yhj1WHlKLtbWsGNcn04deKRe0Wgla18aTUKyZh1v3adsNG9JXKKf83vGczapl33MpDtu5C9VskxvGBye1qSciOrfq2npL9BtPb8nasecVW4HszVnY6AEMGyCiw7lr/dED8= Received: from BN9PR03CA0495.namprd03.prod.outlook.com (2603:10b6:408:130::20) by MWHPR1201MB0141.namprd12.prod.outlook.com (2603:10b6:301:56::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Sun, 30 Jan 2022 18:42:33 +0000 Received: from BN8NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:408:130:cafe::f4) by BN9PR03CA0495.outlook.office365.com (2603:10b6:408:130::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Sun, 30 Jan 2022 18:42:32 +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 BN8NAM11FT017.mail.protection.outlook.com (10.13.177.93) 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 18:42:32 +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 12:42:31 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 5/9] i2c: piix4: Move SMBus port selection into function Date: Sun, 30 Jan 2022 12:41:26 -0600 Message-ID: <20220130184130.176646-6-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: 6e30f360-c368-4dee-a47a-08d9e4204695 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0141:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qM2PTj3I0xNB1n1hUUW88yfeOsDJUepkxIFLBgTD4HF/ODe68GoLcUbWB+seUARar2yIkO3iYY8CPUeWubl83LZr5m/Feb2yIiOOK20zTbRGnE2ffzVpE6x1JwgG7UIpCAgDLiNMIeXj30E9pAKyzz+Xk9KKLmnTsAUmFsmXxC2FV0veZxP9yShylXiA5Gsoje/QTgl8axnqbs7RXuM7ZM3sKU88Y8+1FfmeX2LQepzWsv9C2AOH5WR4BRaaKJCriZpEmmxcFSsSPfAW87NQR/MDPww2EYXQfKidheAx/6w/nSFn29nOTECzXec/BoUxL47aB2LVIze0/nfKyu8QCdoOiboHCsYPbCW3K+M2HSHgRVEq2QNbt/WRWPgzWYYctpUoZhr8iORxDjfEhTSPxG7tzz1/g44uYD5mbAFzm/iMnEwpJffvnRx7nZrlmNYriwSDTu4+Y33v6UNScU+wwxVwPVTc7jrp5uaFiqpqY9lxEycpBfh+bQfjMDkj97Aou++fg1RuYnrfT21A5w8ZG+iQ3zmYUMq9hi6H9M0+mPL06lJxM+2klbbOz6V2TeaYI8VJJqUCeSmH2/5LJlbXaqTzAB8zqZEAdsQwL44O5eHBEVWbB0iCMXx7G4yfzHPrLubStteSWZ8zR7DOx96XMbQkLWYrW0MCLB3Wka2K3k02+tAigEeGfcqu6JUgnwMyQBBro+7Vta4W6x+h+leH36oW3B7RMrpkODZHZMrpMOc= 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)(36840700001)(46966006)(40470700004)(70586007)(426003)(336012)(4326008)(70206006)(356005)(8936002)(8676002)(81166007)(26005)(86362001)(5660300002)(186003)(2906002)(1076003)(16526019)(44832011)(2616005)(316002)(82310400004)(36860700001)(54906003)(83380400001)(36756003)(7696005)(47076005)(110136005)(508600001)(40460700003)(6666004)(2101003)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:42:32.3309 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e30f360-c368-4dee-a47a-08d9e4204695 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: BN8NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0141 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Move port selection code into a separate function. Refactor is in preparation for following MMIO changes. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index eab06e9e5fdf..32a30af5778a 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -699,6 +699,19 @@ static void piix4_imc_wakeup(void) release_region(KERNCZ_IMC_IDX, 2); } +static int piix4_sb800_port_sel(u8 port) +{ + u8 smba_en_lo, val; + + outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX); + smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); + + val = (smba_en_lo & ~piix4_port_mask_sb800) | port; + if (smba_en_lo != val) + outb_p(val, SB800_PIIX4_SMB_IDX + 1); + + return (smba_en_lo & piix4_port_mask_sb800); +} /* * Handles access to multiple SMBus ports on the SB800. * The port is selected by bits 2:1 of the smb_en register (0x2c). @@ -715,8 +728,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, unsigned short piix4_smba = adapdata->smba; int retries = MAX_TIMEOUT; int smbslvcnt; - u8 smba_en_lo; - u8 port; + u8 prev_port; int retval; retval = piix4_sb800_region_request(&adap->dev); @@ -776,18 +788,12 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, } } - outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX); - smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); - - port = adapdata->port; - if ((smba_en_lo & piix4_port_mask_sb800) != port) - outb_p((smba_en_lo & ~piix4_port_mask_sb800) | port, - SB800_PIIX4_SMB_IDX + 1); + prev_port = piix4_sb800_port_sel(adapdata->port); retval = piix4_access(adap, addr, flags, read_write, command, size, data); - outb_p(smba_en_lo, SB800_PIIX4_SMB_IDX + 1); + piix4_sb800_port_sel(prev_port); /* Release the semaphore */ outb_p(smbslvcnt | 0x20, SMBSLVCNT); From patchwork Sun Jan 30 18:41:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538338 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 21198C433FE for ; Sun, 30 Jan 2022 18:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355314AbiA3SnI (ORCPT ); Sun, 30 Jan 2022 13:43:08 -0500 Received: from mail-dm6nam11on2041.outbound.protection.outlook.com ([40.107.223.41]:27841 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355421AbiA3Smq (ORCPT ); Sun, 30 Jan 2022 13:42:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ewMUbjt++Z/mTT/iaqOyi3Z9W7cDVOnObpIxhRqzWvOxUASUmBdcLPToixJlULxM8XJGO3yMUa0J28fFMe1sq6fk1tg0CpoTxo0ann9fUYAixkb8FrXqmj7C59qwuieVafM6Lh/V6f+TxFy5BakftsR/5L+bztf+3VI3apazMqN6yx1IpD/hRwhJUgP9xOrD4XmkRhJObgc22bj65fbw8keAu7q/y5piHz8aa1lnflcf7Hwpgjld2vEczJy7eHj7IhYxWMz7LTwp+JNnQ5ZkjuxfLxpG+7yJ527cbdPJ9OE/3WHXNoYAj2flf1LUX0rd0LKqnd3rvGDMk06nblLRtg== 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=yhIcO2LYawnQbbJQtIDwDviGc92Hn4zI7IXf+SlefrM=; b=hXo5Au+JjhK+/BzZT/p1MXKt7PudKphg4e7JkXZ2D+EfK+EMXSNkINVrxILyRLfNNiwRxpGIiR3yqOocckMTmT52QbMb+sqcG1AI3D7JL21c4nmQl8MSUeYEHRHSuFbTY/gKjoc7ZdIloU/5pedr1pB3SdNxattXcIcJPFffLDygSi/jVwc4le69VV4YugeYwXJXtkva2AIuD8Amq+vfLisYIujsNw0W/VwYXFlu6UmGSXejCodLXQ6avWmWJpAaohDupSkJ9N0trsC/06+CjILbD0EXuY7mpuwza1vWih5l+dXMAQczXyEqeLzPM6kCcwlbGjpl6EoZmlXFXIfDYg== 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=yhIcO2LYawnQbbJQtIDwDviGc92Hn4zI7IXf+SlefrM=; b=AU7a1x2JJFIr0jGY3Prmv/eYsgeroN/eDHi0koXa5IlLo7A4GERYnPCBzBgfibTEy3pVJ/xO6UF+dNGdqks/kS+cvsbc22T+Yt4pY2yYStADuAWYNluwpY/6gNpBNkROH0jwNFyNbfzIOIgMjiyxFchOA64U8WUqtfDD0rhtJvc= Received: from BN9PR03CA0291.namprd03.prod.outlook.com (2603:10b6:408:f5::26) by CY4PR1201MB0023.namprd12.prod.outlook.com (2603:10b6:910:1f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20; Sun, 30 Jan 2022 18:42:44 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::cd) by BN9PR03CA0291.outlook.office365.com (2603:10b6:408:f5::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Sun, 30 Jan 2022 18:42: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 BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) 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 18:42:43 +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 12:42:42 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 6/9] i2c: piix4: Add EFCH MMIO support to region request and release Date: Sun, 30 Jan 2022 12:41:27 -0600 Message-ID: <20220130184130.176646-7-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: 58f16609-7511-432a-1258-08d9e4204d2f X-MS-TrafficTypeDiagnostic: CY4PR1201MB0023:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cfUbbL0qD3MzCu9Efz2t1yj6PQ/5SCg1tI/nk3CMiy5BO2lsOpGwWQ40QwaOfHfaKM0OWysOUkHUqQyQuIzCko26dY+FsAbbgf8HkV8csBYxVvuXxr5ngVgLBMDIxO467HxPZoQAqPi+l4VSZar6LTP1bjGcHoPbpLq05KxorjSlN7lpOVlaEthAXjpPkAdM2xFtD1V35D0+oh6qnSoraOCT+8GBfWQBzeaXDIqShbVWoQRt0wD1OzyOJDZ5fjfU0VsABXOMN7kGmw9g8TLSOeC2SN68/addUYpNnWnXZUT8XtvhkM01PJ4xtOoH1+tMjkfPnFsUbCNjZkt8sLM1NtuxH7wE3kwDltKHafXM9YRtC8YCGpQYTZ5z8RpNTzXVqmyXx5nlK9rxYuPJxEx7JJb7yKMXjJxKq+1dBBOZnrHGLR5Y1plylUkOdvIpv9hnNtT6fBav40AYjtFuaGsoTUhw12Qda45BNLkyZBk5JESqeBUB38te//i9K9r1RtQxesGRmub02qokbfFqu2gifz8/UPHmzZ3RrY0LcqEw7jqlzWA+nVYtKbMl90rUNyddzhfz6IeHoLHmUuhib5tpst/pECSgMSMqwLxxkw4kJ1XqTEsezRRTPQEb2tSh80o5vDGRfo66P0hkwmTIsLUC4fn3SJ0vHw7vihZroDdngY+8jLOQQYT/61u3h+vtN6INb9LVaxsI6T3SOqVgK0voWSsdZ3sMiUYnjFYH2JTvS5Y= 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)(36840700001)(46966006)(40470700004)(186003)(26005)(336012)(426003)(47076005)(2616005)(4326008)(16526019)(1076003)(44832011)(5660300002)(86362001)(2906002)(70586007)(70206006)(7696005)(6666004)(8936002)(8676002)(83380400001)(508600001)(82310400004)(356005)(40460700003)(81166007)(36860700001)(316002)(54906003)(110136005)(36756003)(36900700001)(2101003)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:42:43.3871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58f16609-7511-432a-1258-08d9e4204d2f 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: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0023 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org EFCH cd6h/cd7h port I/O may no longer be available on later AMD processors and it is recommended to use MMIO instead. Update the request and release functions to support MMIO. MMIO request/release and mmapping require details during cleanup. Add a MMIO configuration structure containing resource and vaddress details for mapping the region, accessing the region, and releasing the region. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 61 ++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 32a30af5778a..7defa0c5f1f9 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -98,6 +98,9 @@ #define SB800_PIIX4_PORT_IDX_MASK_KERNCZ 0x18 #define SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ 3 +#define SB800_PIIX4_FCH_PM_ADDR 0xFED80300 +#define SB800_PIIX4_FCH_PM_SIZE 8 + /* insmod parameters */ /* If force is set to anything different from 0, we forcibly enable the @@ -156,6 +159,12 @@ static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = { }; static const char *piix4_aux_port_name_sb800 = " port 1"; +struct sb800_mmio_cfg { + void __iomem *addr; + struct resource *res; + bool use_mmio; +}; + struct i2c_piix4_adapdata { unsigned short smba; @@ -163,10 +172,40 @@ struct i2c_piix4_adapdata { bool sb800_main; bool notify_imc; u8 port; /* Port number, shifted */ + struct sb800_mmio_cfg mmio_cfg; }; -static int piix4_sb800_region_request(struct device *dev) +static int piix4_sb800_region_request(struct device *dev, + struct sb800_mmio_cfg *mmio_cfg) { + if (mmio_cfg->use_mmio) { + struct resource *res; + void __iomem *addr; + + res = request_mem_region_muxed(SB800_PIIX4_FCH_PM_ADDR, + SB800_PIIX4_FCH_PM_SIZE, + "sb800_piix4_smb"); + if (!res) { + dev_err(dev, + "SMBus base address memory region 0x%x already in use.\n", + SB800_PIIX4_FCH_PM_ADDR); + return -EBUSY; + } + + addr = ioremap(SB800_PIIX4_FCH_PM_ADDR, + SB800_PIIX4_FCH_PM_SIZE); + if (!addr) { + release_resource(res); + dev_err(dev, "SMBus base address mapping failed.\n"); + return -ENOMEM; + } + + mmio_cfg->res = res; + mmio_cfg->addr = addr; + + return 0; + } + if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, "sb800_piix4_smb")) { dev_err(dev, @@ -178,8 +217,15 @@ static int piix4_sb800_region_request(struct device *dev) return 0; } -static void piix4_sb800_region_release(struct device *dev) +static void piix4_sb800_region_release(struct device *dev, + struct sb800_mmio_cfg *mmio_cfg) { + if (mmio_cfg->use_mmio) { + iounmap(mmio_cfg->addr); + release_resource(mmio_cfg->res); + return; + } + release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); } @@ -288,11 +334,13 @@ static int piix4_setup_sb800_smba(struct pci_dev *PIIX4_dev, u8 *smb_en_status, unsigned short *piix4_smba) { + struct sb800_mmio_cfg mmio_cfg; u8 smba_en_lo; u8 smba_en_hi; int retval; - retval = piix4_sb800_region_request(&PIIX4_dev->dev); + mmio_cfg.use_mmio = 0; + retval = piix4_sb800_region_request(&PIIX4_dev->dev, &mmio_cfg); if (retval) return retval; @@ -301,7 +349,7 @@ static int piix4_setup_sb800_smba(struct pci_dev *PIIX4_dev, outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); - piix4_sb800_region_release(&PIIX4_dev->dev); + piix4_sb800_region_release(&PIIX4_dev->dev, &mmio_cfg); if (!smb_en) { *smb_en_status = smba_en_lo & 0x10; @@ -731,7 +779,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, u8 prev_port; int retval; - retval = piix4_sb800_region_request(&adap->dev); + retval = piix4_sb800_region_request(&adap->dev, &adapdata->mmio_cfg); if (retval) return retval; @@ -802,7 +850,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, piix4_imc_wakeup(); release: - piix4_sb800_region_release(&adap->dev); + piix4_sb800_region_release(&adap->dev, &adapdata->mmio_cfg); return retval; } @@ -880,6 +928,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, return -ENOMEM; } + adapdata->mmio_cfg.use_mmio = 0; adapdata->smba = smba; adapdata->sb800_main = sb800_main; adapdata->port = port << piix4_port_shift_sb800; From patchwork Sun Jan 30 18:41:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538597 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 8AB7BC433F5 for ; Sun, 30 Jan 2022 18:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355370AbiA3SnK (ORCPT ); Sun, 30 Jan 2022 13:43:10 -0500 Received: from mail-bn8nam11on2059.outbound.protection.outlook.com ([40.107.236.59]:61696 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355543AbiA3Sm7 (ORCPT ); Sun, 30 Jan 2022 13:42:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z5Jh++2WTAPo93o4hccz+bEKM91RxrsvPIKyV2mWXjtA8iYIwRGytlkQnYvzV0mt1UavOeyuNqGo+ldexbCKWt36x13TQ4J4o0qs+Ky7eL2r1fEpYYiFVYo0vj37jBLWvKo8bBHWt3zQz7EGqqR/0fhUSlhle3HuOPjL76d318RMqTql9vUqxGtwH3Bhd/48G4M/JEEWZvoj4u29FfCS+KDkrHAsivMjqLl8ERsKDgHgyCKxRfo7x+WMTomJN+RUihNDxO4sr22zqKtShUZxB79wEGWSv4U+J4OcgLi+tq+A5iOeCJRjHeStFG4Q6P/R+hRKYppKR6xrgF/++KgOtQ== 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=UgTFlXo7NHNu1ByWNxcXZi9d+Hvh9yPQDXbwuZiHutM=; b=MzTXtqxcC0LNRzPANvpE172CJ+QOL5ux22SrTgNNSDUEmE2uhiRY0DT9TQUz4g+rnkn7aLRi6XYqFTIUpXbOH0VyxiauX73ly/nb0fjuIx2LgNWydFPrUKoaSi2wH7L4bjo17vH/V2uD0GJLtLPVNckou767M1X9so4WxDv5GuuWIz0H+wo3xRyWy+Iq3bqwAi/t1HZ1eLbeda1gvN4/i1O/PV8uynmUuia767if4JZFgU8YqXFV3ttsREFSJoRy1EYiv8p4TLRo2yOnfRWtLbrHTwcwg0tgeIZ07YdMhtNH/y3nph533qg8HMop5BClUgG68u/rNW8I7TBS7v68Ig== 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=UgTFlXo7NHNu1ByWNxcXZi9d+Hvh9yPQDXbwuZiHutM=; b=4RAw+OKsQzOzxOvzkunxZ8N7jACwIVUIYoxgnxepSbsDYU6p0/YPcykZKQ60DdDGO5A1uSoG6rcS+uauLEPF5TZyFX+BDBHW9MoC74cHFlPU/QAXCa40DDiXMoHD46TCHeqg6CEB+VnSprV9RlQVxT6Eriu4sineUEO/n0pr6q8= Received: from BN6PR17CA0027.namprd17.prod.outlook.com (2603:10b6:405:75::16) by MW4PR12MB5667.namprd12.prod.outlook.com (2603:10b6:303:18a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Sun, 30 Jan 2022 18:42:55 +0000 Received: from BN8NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:405:75:cafe::c5) by BN6PR17CA0027.outlook.office365.com (2603:10b6:405:75::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20 via Frontend Transport; Sun, 30 Jan 2022 18:42:54 +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 BN8NAM11FT018.mail.protection.outlook.com (10.13.176.89) 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 18:42:54 +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 12:42:53 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 7/9] i2c: piix4: Add EFCH MMIO support to SMBus base address detect Date: Sun, 30 Jan 2022 12:41:28 -0600 Message-ID: <20220130184130.176646-8-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: a7e9af14-0e7f-4f69-b644-08d9e42053cd X-MS-TrafficTypeDiagnostic: MW4PR12MB5667:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o1e3nyxlGQOxP74WteAGzRE37cId+rU58PtGhxWuWkVQisPQ+pblupwoVfCHFKZPhSIo4Ur6wr8g3XsCUQ/ac7up0nfS5WKxNp1/R69HJZP5m+5FgBMayYKHZo+ucNjZcmvzf5+ogA++cl58/gIrV/X3BkCGlrYQ/fhXVAnMtRiEwIR+9E5SHYGiWuhT+OYhM8vrbaSvAGjKhSsZWjwziezg09UBmEHYqfiC0LGzbFCMXgVxtWNAo0TU3sR6LvzpzPpaXXGA2B3/IIsUC4ES78f9T1dVbkUVp8uLsv/NDS/IVZYWyf945rAtWp4UICY/oSKzUxeeLFp3UyL+TuBfoH0Oj60iqkdvsI3mBsi5+jTzFh9Z/CJCUETT8xooa/mqpWO5IuFK+4VzgVH80gOibixEFsfT4I0K6ERcgeqjq/sfD4Fp4eVjgghoh1MPPzqSLI9FxrteZeC7VIqbPL4yWSG1yowA5GOvuc2ZlMhcJ9nSUGGEjB5yKi74+swmgOkFy6snBOE+uktif7Uq9xX9JBJ4Fwksjv48ltn1lu/S8RBguA6Fr9e5pxlsI4WGsy9cku7EiMPeLT5ODOXOrtNvkQQ/ONXd2OCS+7x2PNmj9LTgwZliyB8GwCerMqkNtgaMhx4BqtGNrHVfeh7icYHgPPwzsRUlyrItbCZhCqgOk+BixmpDK9U0ssViAsMqTfGCpFk1VEqSDsvIkUV5EVpDASJ8dKBpVgFEPCDcfiqUvkqEDJvg79XAVl7H1f7lyeWEwFKZxoy610Ca4avXinuJXjNr9a0N/uDlAIUr6ruxkUeUJ/BQzhSgEPdNWJuuWrAH 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)(40470700004)(36840700001)(46966006)(7696005)(1076003)(40460700003)(316002)(508600001)(81166007)(44832011)(70586007)(2616005)(47076005)(83380400001)(36860700001)(5660300002)(2906002)(356005)(16526019)(186003)(26005)(110136005)(36756003)(6666004)(336012)(82310400004)(86362001)(4326008)(54906003)(8936002)(70206006)(426003)(8676002)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:42:54.4931 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7e9af14-0e7f-4f69-b644-08d9e42053cd 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: BN8NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5667 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The EFCH SMBus controller's base address is determined using details in FCH::PM::DECODEEN[smbusasfiobase] and FCH::PM::DECODEEN[smbusasfioen].These register fields were accessed using cd6h/cd7h port I/O. cd6h/cd7h port I/O is no longer available in later AMD processors. Change base address detection to use MMIO instead of port I/O cd6h/cd7h. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 7defa0c5f1f9..a23c0327e1f6 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -344,10 +344,15 @@ static int piix4_setup_sb800_smba(struct pci_dev *PIIX4_dev, if (retval) return retval; - outb_p(smb_en, SB800_PIIX4_SMB_IDX); - smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); - outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); - smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); + if (mmio_cfg.use_mmio) { + smba_en_lo = ioread8(mmio_cfg.addr); + smba_en_hi = ioread8(mmio_cfg.addr + 1); + } else { + outb_p(smb_en, SB800_PIIX4_SMB_IDX); + smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); + outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); + smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); + } piix4_sb800_region_release(&PIIX4_dev->dev, &mmio_cfg); From patchwork Sun Jan 30 18:41:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538337 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 8EDBCC43217 for ; Sun, 30 Jan 2022 18:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355387AbiA3SnM (ORCPT ); Sun, 30 Jan 2022 13:43:12 -0500 Received: from mail-bn8nam08on2052.outbound.protection.outlook.com ([40.107.100.52]:3424 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355240AbiA3SnH (ORCPT ); Sun, 30 Jan 2022 13:43:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TwFg1DXau1jH28j090WhOSe370QXJ30KPuV0Z8depCMl7pQa1GszGhi8/2DCQoIbt6OwTA0gDV9N41NTVWsA1+zYIxCiUV+80RAAJ+SE1xRgnP1ybVx/624Hf7oZlToR0xPhSGDodsZN5NKOrm6jDwy+KvjSC0MmYAyhyYKPHA7B2nbOVJLqd8Oy4jViTvG3z57ra880y7TVXUnnFAdF9j+++TyZOGLzlb5U7/SDQMxSrSfdE7NgUKMy97YJ3yrIkXhM0x0BE/jc0wdkWi2bwL5fzoGF5G49r5s1n/RzUTjHYBmhEEI5rOlrvZFxqpDyhcbWcFp9h32zEtzLjPODQA== 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=zqsqqnocdATKu4oo2WhkFwRf1vE3PAO06wWTWKXuHbo=; b=Nk77IdIvAOiU9OcFwAkE/aCWirM4YZ0dmLhvliC+tE6cmfTyFj84KgggKiHJMXcFMNg31BwXLSuwHEmOViColrH6wLrUKG9JkbROuSibL8ZReZ65L4hc6E3BsyUIOvScjl+4dE9x8XmrziFTRxFbAMEkueVJ3ZYw3lP7ebv1PXonjubiHMc+pjS7tXQeOZf6nj+A5Cjefj6XrjUWSjIoaAYOOXSESFHFGrkEJbeP22f883kk3oRPW+84+5ux8PZVE9+hvzYR9Tj3koHBP8JpIboxH0EbhydqaEf2c9/29Yp0SoC4ckRhX4cFDo1hYc+8mLJrOZW9f9xjU+B6A5+3Bg== 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=zqsqqnocdATKu4oo2WhkFwRf1vE3PAO06wWTWKXuHbo=; b=PQktqaoo4pdO6vDlqHEquJcBN+J04pasFHAGAN4aHhBCG5yIZvVbmlyErvInukMgfbkNSxLu2rviTP4liZI+xosBvNgDgZj+MeNlg4WhY+FaGGcZXfTVQjEhBriZOhXv8yOeFrck/co2tH0Dst7CEonbwdYL/wS3R5NdD1TTYBA= Received: from BN9PR03CA0547.namprd03.prod.outlook.com (2603:10b6:408:138::12) by BN6PR1201MB2547.namprd12.prod.outlook.com (2603:10b6:404:aa::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 18:43:05 +0000 Received: from BN8NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::67) by BN9PR03CA0547.outlook.office365.com (2603:10b6:408:138::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Sun, 30 Jan 2022 18:43: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 BN8NAM11FT022.mail.protection.outlook.com (10.13.176.112) 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 18:43: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; Sun, 30 Jan 2022 12:43:04 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 8/9] i2c: piix4: Add EFCH MMIO support for SMBus port select Date: Sun, 30 Jan 2022 12:41:29 -0600 Message-ID: <20220130184130.176646-9-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: 67047805-a989-4e59-8876-08d9e4205a65 X-MS-TrafficTypeDiagnostic: BN6PR1201MB2547:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qyrdqHZkHVFXoMBcsOb74dfvuoQmznTOOkmEMzOtg7slvHukFEcgsD58qgee8qql/Rd7KFv1ad0xUc8ZMvtZayYmt9fc7h+H05NLE3VPqlJeHiTP6+aOmvAjPeBNNY9c5cfYQSJ79vtcf+dDKxBNgJ8O0sNNnt6TBaelgYd/ibpEfsvgSY28nL1UmcE5Kas1zaNQr8/KeaMGukJWWkCfwGvcO7YzaBKh/vi3FcEp2j4KbMZCtLMLSigD7emS+bZJjVQhJFeFJyl9O782kiqSf0nCX4N5nsCQA9t75WQ0C+MMrAqR+Y8vD+lLJDSwl81Y905Dwnp+a1gMh1VgnJUx9v3WTvAxTacQilCdW89we5hT71dgx0U1/DN8dqQXky08lt373UM75zR9t8WzWnJfawRcItdcLIanVJXnOQ8Z/9NA64V2GfcpSlzl+V3b01c4+5vLCTIIpsKnvuwNY6mi5SHzihSWlZl3yGglVsyPDzFXbt96tCdkVQ9aWX6FDfy1g+Yaus2Ke+zNpavrX+E644/pY0/w3JAJEHwR/upDgFX/Zqo6MSnFeiW9o4f4Ml0vI+M/abBr7ryNh1iWLxCYKh4vQTHEGVyqkKh+fCnEA8WTzhIMN3pp5WLcsD5tFRwuxdfTZ3/ifbNy4O8zExIHmQR09a56cqRN/VwwEh8zYRHlnTNxsvI7V3I3H6Q1XckFoSr230fonr/27YsHlEBQhYzCpW2T8cYTBCWfU8akaR8= 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)(36840700001)(40470700004)(46966006)(47076005)(356005)(81166007)(86362001)(83380400001)(40460700003)(508600001)(4326008)(36860700001)(36756003)(316002)(70206006)(70586007)(110136005)(8936002)(8676002)(54906003)(6666004)(5660300002)(44832011)(82310400004)(7696005)(336012)(426003)(16526019)(2616005)(2906002)(186003)(26005)(1076003)(2101003)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:43:05.5700 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67047805-a989-4e59-8876-08d9e4205a65 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: BN8NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB2547 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org AMD processors include registers capable of selecting between 2 SMBus ports. Port selection is made during each user access by writing to FCH::PM::DECODEEN[smbus0sel]. Change the driver to use MMIO during SMBus port selection because cd6h/cd7h port I/O is not available on later AMD processors. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index a23c0327e1f6..c5325cadaf55 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -752,10 +752,19 @@ static void piix4_imc_wakeup(void) release_region(KERNCZ_IMC_IDX, 2); } -static int piix4_sb800_port_sel(u8 port) +static int piix4_sb800_port_sel(u8 port, struct sb800_mmio_cfg *mmio_cfg) { u8 smba_en_lo, val; + if (mmio_cfg->use_mmio) { + smba_en_lo = ioread8(mmio_cfg->addr + piix4_port_sel_sb800); + val = (smba_en_lo & ~piix4_port_mask_sb800) | port; + if (smba_en_lo != val) + iowrite8(val, mmio_cfg->addr + piix4_port_sel_sb800); + + return (smba_en_lo & piix4_port_mask_sb800); + } + outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX); smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); @@ -765,6 +774,7 @@ static int piix4_sb800_port_sel(u8 port) return (smba_en_lo & piix4_port_mask_sb800); } + /* * Handles access to multiple SMBus ports on the SB800. * The port is selected by bits 2:1 of the smb_en register (0x2c). @@ -841,12 +851,12 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, } } - prev_port = piix4_sb800_port_sel(adapdata->port); + prev_port = piix4_sb800_port_sel(adapdata->port, &adapdata->mmio_cfg); retval = piix4_access(adap, addr, flags, read_write, command, size, data); - piix4_sb800_port_sel(prev_port); + piix4_sb800_port_sel(prev_port, &adapdata->mmio_cfg); /* Release the semaphore */ outb_p(smbslvcnt | 0x20, SMBSLVCNT); From patchwork Sun Jan 30 18:41:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 538596 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 842C1C433FE for ; Sun, 30 Jan 2022 18:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347395AbiA3Snf (ORCPT ); Sun, 30 Jan 2022 13:43:35 -0500 Received: from mail-bn8nam08on2049.outbound.protection.outlook.com ([40.107.100.49]:62753 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1355240AbiA3SnW (ORCPT ); Sun, 30 Jan 2022 13:43:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RujLxaqX7UEejVhMO9iLrH67H8jCLwoPei7TiD7goL37GP4bXeldTww+nzA/mqnFBile/JzHfCAQxB4M8DYOJLHMosw4F2ckwQ+Kdh9wKSlaggWlI1upjkNG2QXd9ve4m+cDrP4rYqx9uCAuEEzKFLQ/NTd54dD/0DlKfx1NQPXvxwAXGgOwr6lsmtOR9K/xb9vb5OSIbndmfpWIZNgd62hGtakdPEX33tAgKOqVwIdiNYdI8pxurK6SR4zfDifSrzaESxqv14BVo++wHYeOgW1N/g5vh2psnR/nkEWeD0QaYC+WdZBfQq6ST4oBJigMnRhWfgSg1inuCPgej31sig== 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=WwjNVYOLjkNznwfFhqDbrqa6aY5Lhnesw+yLCV7E/GA=; b=WW2mZkH5/T0scEY1wjOVgnL43iU6dpd4G7OCih7M5XTmecGZhRi4m1CoO2zl6Y4Fhu4U8lYDBTt9nmEmn3y878+zNUclXJtEzTLToyKp3a7BnFPs64vOo2jkmLFjejooCoe8vL6aQ9KZEUJfEf5XPYq/in+nBoXCdB4/fiybFhzw+W9u2LLNYds3lnS0vaMeuETbwMAqoDRshMvxwhkRLjzJOseYIg3CUL5erMjLH1YvOvHIkGlBrqprXiQA+o+G5JmUCh1WdMl4MrkWS2Fbes4C1URq0SPDyDQNS+HW7BXchAoFw1uFZkrj3NYdTkimPeRYRxvxBA8qdtQB6aqJkw== 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=WwjNVYOLjkNznwfFhqDbrqa6aY5Lhnesw+yLCV7E/GA=; b=MkZLsI11kx+d77tnY+Evx6vL2yGa+S4CxF4nWQNVgO1rEH32KRSzDIuDBVCYe4sEAxD180IT5gb12/BOJLgZoKoMO+bTmsYEC9Gk/g7rfdVJVLaHqt03+LmZEqNP3OGyOMx6FahwawyMc1gfQGNbDBSjsFv3WKFMXl6Cp8eVlSA= Received: from BN6PR19CA0110.namprd19.prod.outlook.com (2603:10b6:404:a0::24) by MWHPR1201MB0064.namprd12.prod.outlook.com (2603:10b6:301:58::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.19; Sun, 30 Jan 2022 18:43:17 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:404:a0:cafe::60) by BN6PR19CA0110.outlook.office365.com (2603:10b6:404:a0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.21 via Frontend Transport; Sun, 30 Jan 2022 18:43:16 +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 BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) 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 18:43:16 +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 12:43:15 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 9/9] i2c: piix4: Enable EFCH MMIO for Family 17h+ Date: Sun, 30 Jan 2022 12:41:30 -0600 Message-ID: <20220130184130.176646-10-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220130184130.176646-1-terry.bowman@amd.com> References: <20220130184130.176646-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: 744a8fb3-da0e-43c1-1f30-08d9e42060fc X-MS-TrafficTypeDiagnostic: MWHPR1201MB0064:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bo9z4QJImKDfacAik2Q8rMWygGesSq+pXrTUdFjNRJV3U1g/GCG2apYk/7KVFKfH2fvrSAjiNU1jKitO/FYB2YflLYBUJ4IpnFU41wI9JRhZZcKpDeGUOyUAa/kv0e/WudqFXrLHI4LQG9p+LQWgIRJQqKaqlUGxogoOiABTTSLldcl+f8spNFCs+mnkbmXXpE4RYyyzXLFkVGCq6wX9EL4OAsZGJDkQEtcm6Kwce6aAhV4aGJCjhaBxSRk3CKCj96Ppk0Gvlhqt+u8XWxrSpiVnavKQs5wAu6TRQXxRvI4jtJ5bMITEUIgpxjLJ/5i+4FhCwlMbDuMjtWHqFCw+CAl11eQ7WcpsPGrqCmxDEcKg3abLq0Peygty8Sdzn9eOsP7SiSkEFjF8qYjhME8Rcp8eqTGEktbv/IApt8BSlRFpP1v4z34JYAO9jsfnKc+74DvGFaiL1vPl6GiX8M7vsTJMXpT8WeOLs/9zy7SyFYF2rNkyo5o+Xi9vNniPdTCiuziMt0YSqujh3sGs/75Vq0N04MR9bJyrhepk+qfnPKcy2K9DidrytyrWqn2szcIuCDBArdYIe1SoGI2MoJsnovPmKDbh1VNn8FZ7R1IVJP/33g7sIbImNgUTpZ8Owu/KzLsKiPRdsHP0p+wBFgPZBChUcB8dvyUThqLvZs0CCcXZc65NkMHCDDkqSo7x6BWQuRnw7FEwLznlq4RzJlAMTgEBh5V05pKo33lpf2bN+I8= 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)(40470700004)(36840700001)(46966006)(54906003)(110136005)(5660300002)(336012)(426003)(83380400001)(6666004)(82310400004)(186003)(1076003)(26005)(81166007)(508600001)(16526019)(356005)(8676002)(8936002)(70206006)(7696005)(47076005)(70586007)(2906002)(36756003)(86362001)(316002)(36860700001)(44832011)(2616005)(4326008)(40460700003)(2101003)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 18:43:16.6233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 744a8fb3-da0e-43c1-1f30-08d9e42060fc 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: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0064 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Enable EFCH MMIO using check for SMBus PCI revision ID value 0x51 or greater. SMBus PCI revision ID 0x51 is first used by family 17h. This PCI revision ID check will also enable future AMD processors with the same EFCH SMBus controller HW. Signed-off-by: Terry Bowman --- drivers/i2c/busses/i2c-piix4.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index c5325cadaf55..6a9495d994bc 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -101,6 +101,8 @@ #define SB800_PIIX4_FCH_PM_ADDR 0xFED80300 #define SB800_PIIX4_FCH_PM_SIZE 8 +#define AMD_PCI_SMBUS_REVISION_MMIO 0x51 + /* insmod parameters */ /* If force is set to anything different from 0, we forcibly enable the @@ -229,6 +231,13 @@ static void piix4_sb800_region_release(struct device *dev, release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); } +static bool piix4_sb800_use_mmio(struct pci_dev *PIIX4_dev) +{ + return (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD && + PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && + PIIX4_dev->revision >= AMD_PCI_SMBUS_REVISION_MMIO); +} + static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id) { @@ -339,7 +348,7 @@ static int piix4_setup_sb800_smba(struct pci_dev *PIIX4_dev, u8 smba_en_hi; int retval; - mmio_cfg.use_mmio = 0; + mmio_cfg.use_mmio = piix4_sb800_use_mmio(PIIX4_dev); retval = piix4_sb800_region_request(&PIIX4_dev->dev, &mmio_cfg); if (retval) return retval; @@ -943,7 +952,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, return -ENOMEM; } - adapdata->mmio_cfg.use_mmio = 0; + adapdata->mmio_cfg.use_mmio = piix4_sb800_use_mmio(dev); adapdata->smba = smba; adapdata->sb800_main = sb800_main; adapdata->port = port << piix4_port_shift_sb800;