From patchwork Wed Feb 9 17:27:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541283 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 31DF6C433F5 for ; Wed, 9 Feb 2022 17:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238207AbiBIR1n (ORCPT ); Wed, 9 Feb 2022 12:27:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238226AbiBIR1l (ORCPT ); Wed, 9 Feb 2022 12:27:41 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A1EC05CB9B; Wed, 9 Feb 2022 09:27:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+hXSeBeZXH0GrY0ZBzxrFLeI4Sjy/59/CbtQZY8ck8WJKlz0aaZqnDLmsk7AkoIk+3Ja4OgW5zmzFH97gUlPh2tspl+2CucsQT2N1AgzoaS4isioZwDnDTEKKq/5PK4VYDy6dG5tdcuHoLuUcevq0huTMzmS0XGt8htL4sMsFv+7LUlTec7AGIUkLaqa8vG2Z3ryyneF0b5efNaud7c9NoqK71phfP+miU9DJT6tk6adhpow0cPYWkqD59mfxv5BkD3Vv02vZL6zCpePc5XoN+D1ByimtC+KAAPzdG+/Eo70X3G+oBmIdFj0bwRbDvfeBGRVu76Sq5Wk4zSYIDqOQ== 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=IjxTVIUrUTpIybxsqz0tWcARZDasG3wYPZNCf5YznE4=; b=j79i1ZJzTjm1k3cjABi3MYWUyF7myClwat7IwrhUNadbLLFArTCWDG85eloQIlIT7uAsO27khZLc/aq/5WKaPvuywPh8s6XwyG+y2QfsUbugop8wa6nKLYos+kH8PToijvc49QMp0ob1xUcSZd+qkIV700XlFuh0ihBmXw4TmVK0S3gZSvDG7XrNFu8yCpZ+bnGtuluB3R6yLPAIIm6L5xl6UkIdulPMBtXsSdgU/j9OD/J8fxsmFGupAXK2NHWg07Nx/V+pd0Dr+FjB+naqp9JiPgJdfMh7Wpehp1Tt642iewMyOpCGVO0LevhVRZs1eQPpmCZ6SpBnCApOwSUC2A== 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=IjxTVIUrUTpIybxsqz0tWcARZDasG3wYPZNCf5YznE4=; b=ABXfcfkwMbM/KVGRINXdzjd3Rt5H443pqohypCiHM+Q/TbzLUUBl4OrMYt26/rB4tyc/1YBb8AoOrgoQlJuSJxrA0BwOKhxTMBvqK8uWzFOXSzdjtfT6lLuMuoNTKOxTJH3OcVPmAXS+X0O3Zmr07ebSma3+nJiasto7u6QZSl0= Received: from BN1PR12CA0015.namprd12.prod.outlook.com (2603:10b6:408:e1::20) by SA0PR12MB4445.namprd12.prod.outlook.com (2603:10b6:806:95::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 17:27:35 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::3a) by BN1PR12CA0015.outlook.office365.com (2603:10b6:408:e1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 17:27:35 +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 BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:27:35 +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; Wed, 9 Feb 2022 11:27:34 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 1/9] kernel/resource: Introduce request_mem_region_muxed() Date: Wed, 9 Feb 2022 11:27:09 -0600 Message-ID: <20220209172717.178813-2-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: 3f1e09fe-4eb8-4397-0302-08d9ebf17665 X-MS-TrafficTypeDiagnostic: SA0PR12MB4445: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: c1KbMgXRL+wzgnYfETJMRd2xXw1g46wx0o4i2QJtomyttaZkMSU+kR3sUqnsrDEBXulAlLarR+tsoe1wF6p7KAYlpby/dxL4p3k+JZoRPLMV+zuex7A+hmWgbhgmvQXQhXZvHGnIwUXc2HfZ3h13nQxZKOZCcFiZCRPKx6raS/8VjdqjdPiCG3lYyYy116sViQUmbmmcKB0vdK40jvKGDYQ3mfwcyJLjI9s7fQBogMu71/GnioA4k7Fzsn1N+6YqxVq1vs/kchBn0vi0zeK9KcygnlPcAHBfWD6uWdzp6oLXOEvf9dK2/jE/AtflOhAoxTRlj2JETNV7Y3kqKNlvFoSy4thLWpAF9gzZ1QsLvmhj970KJ7kyQ4RRLr/hSOMFmJBIWIzskdsa8nSeAm/ilbejmYkb2ip0b1YvS/ag7ltvhxQ2umLXZzbUli4s5K7CehfBlWGmlMT/32MQx7MPTkW7Z+ujtfZmWVIGldBXuG2AX2BERUGwBx+BS4B4VA09QUMBEhYpHA+S0wF0/gKatMUBGFTfpdzOiGlwfFmzn9oiXFm5PdUkOXGkePefX7M4rpLUrbOBj8N8KeGjDQuNiND3/0Q3vtYyzqMrPIxrR67+GIcN5Q6xcfQLgelDaF5k7pJyG/QqoayfJwwq/3Ol+ekLJGZeQTbJymUSqpBFBDG03ZrV36zI1RSeJ3KG8uszJgvb5eyXQQ3IustG1BQ5HwPYfaVIb4AS8DmRZN7/L2s= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(8936002)(508600001)(316002)(110136005)(54906003)(82310400004)(5660300002)(83380400001)(44832011)(36756003)(40460700003)(2906002)(70206006)(4326008)(26005)(426003)(186003)(336012)(70586007)(2616005)(47076005)(8676002)(1076003)(6666004)(356005)(86362001)(81166007)(16526019)(7696005)(36860700001)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:27:35.4831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f1e09fe-4eb8-4397-0302-08d9ebf17665 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: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4445 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. Signed-off-by: Terry Bowman Reviewed-by: Andy Shevchenko --- 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 Wed Feb 9 17:27:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541592 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 0F004C43219 for ; Wed, 9 Feb 2022 17:27:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231208AbiBIR1r (ORCPT ); Wed, 9 Feb 2022 12:27:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238216AbiBIR1q (ORCPT ); Wed, 9 Feb 2022 12:27:46 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2062.outbound.protection.outlook.com [40.107.212.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25C48C05CB82; Wed, 9 Feb 2022 09:27:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bmkKMCA3hT3lhSgywONC6+IN8Nf8oHfhCZvbPoTjaVlF0ILl9QKcSPFa+p40GH9XkmISKxDyzSZOt1ok5fhhVTsHIPHZ3bb5yJU9Tp7yJlE8cMHzhlCNFIJ6iYxnTW5vvOmNDHsGwwD1cXIXCQcAbWyn7JnNoZDppq2ZIZJKqG8PFkT5FL0uVSRC0jGiRU7aioQUwdVsI7I09CvhkjUR/MRlB8Zv8mernjdGQ2Vg78k3AcjqR04q3OGOZ8Gg8sFZrPMj67mbk6lJUgYMIobfwfV6IRicOLO+dYqevRKCrXMZDy7C+XmWcE+/bycFNpV5ELo7KcDB8q9YbPGu7pgOJA== 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=SLOLnkmGZQCDDyGQoJIGQ79bpx7EdS73MDK0d6wXNG8=; b=GQ3drloq3J0s5bpvziDBg+36fm3SBKrFuIoOHc1ZYkg+DJjWmbzcdxJVd6nKq5fv91XM8CNCrX80lhFIrN+ZryiOtSUofDmiSW4c1jXwPRwEOkeHFDeDLmFdLhfjXuxeXYPqzJHP9tCqQH8pHtNa6u/ccCWVGGPVkUnMFGBhLj6t0RVax4cM+aVuk6YVeDawYcrSOpBeLYnTQed0CRw0VE9+7FS3sWv7vVx1xBAwW8Y1PHdKulGsnRlpyaKneDf5yOjGzLxVLdBmCanjgrmrWGnadFFK4eIh6SKmP+Z90lHVZSpaG4PKKaz3TZRvjfBfptR67LRTDIOWVDUZAcavUQ== 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=SLOLnkmGZQCDDyGQoJIGQ79bpx7EdS73MDK0d6wXNG8=; b=wKjVg/r6Ucj6zzrdOHLRhOH6j053z5OTeKsI1My0aho0ODPiyNpwQAWWfpr9qD7UmCzGR+SGGG9P5qAXS5LSejMfrf65uCNPOxBAayrJn1b7HGUMJNBkyaxzPiDJsORckkyFimewOGmljZm5JjF69qpDikCMeuW/4xhyLzMVHa8= Received: from BN0PR02CA0054.namprd02.prod.outlook.com (2603:10b6:408:e5::29) by BN8PR12MB3267.namprd12.prod.outlook.com (2603:10b6:408:9e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 17:27:46 +0000 Received: from BN8NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::a5) by BN0PR02CA0054.outlook.office365.com (2603:10b6:408:e5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 17:27:46 +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 BN8NAM11FT011.mail.protection.outlook.com (10.13.176.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:27:46 +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; Wed, 9 Feb 2022 11:27:45 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 2/9] i2c: piix4: Replace hardcoded memory map size with a #define Date: Wed, 9 Feb 2022 11:27:10 -0600 Message-ID: <20220209172717.178813-3-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: 3ca973a6-7a0a-45c8-a76e-08d9ebf17cdc X-MS-TrafficTypeDiagnostic: BN8PR12MB3267: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: fNE2mcBIoQYKr9dJJYiJMiQGOkI18fXmJnVkNdcx9DmH6RszhuWLlaSoDOtBMgFRkWB17730mW+uw3UjzEypNFKVltQy0jzgBqpo0eo1Xmu+AVFZB2fhqroAbFrHs07+SJEOP3zQkNVIIYlW5LqJi7ee8F/nPzQ391ddXI83UPdIRM4vvJ+1QfKuWvPknmLFhvfGwpa9WQHl7DGBDQax/cdnXjD15giTTWcYSRjQ9bQC2PonA1R+8PTqGu8dky6IkmJb04+Cseo8WCs79v4VdnCltV8/t7kNL5iGRTNtzSLozQsOkShFFr2X3Pvamf3pGl0LnbOoInXSwbDfQS+IkcbSHaH4QNZGBJrnd2mg7EyzIJoqasLRpirN2xBH9/1FI9TW4kh8VRsfpCYF27KOqxbMK5eAor75aT5lAvb+0CosdLPaSi0qJAr6PO0kRW4zB4dtHI4M/S4m4E/UzPsBY454FySW4aZDs9e5sUmm+iwGJgTdhYHwtHfNHRf4Hgb517nwVj30bjeIWbEUcq2UeBVPGkv3DtBNNOuueAyfqaKRQCiTEJfUbAuBmIOIp/hjszKWd/sC5v3/5kkPjZdNXwrvyXBV2eiANUClt6gxERWElRLJHqiVBqBRk1u+BDNoQPAhJYCWOKtD4hEmF16EUIaccaeHXbmIn2vx4InvgR6WVdLbSB8obQs5SLBDJPv+kiVU7pViwnFyhBbKTHL9O6yFpkeIN6IXnWnj2I+zloE= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(70586007)(70206006)(6666004)(5660300002)(1076003)(8936002)(82310400004)(16526019)(8676002)(36756003)(7696005)(2906002)(186003)(26005)(336012)(83380400001)(40460700003)(36860700001)(4326008)(86362001)(44832011)(356005)(508600001)(316002)(47076005)(2616005)(110136005)(54906003)(81166007)(426003)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:27:46.3335 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ca973a6-7a0a-45c8-a76e-08d9ebf17cdc 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: BN8NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3267 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- 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 Wed Feb 9 17:27:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541282 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 A00DEC433FE for ; Wed, 9 Feb 2022 17:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238159AbiBIR17 (ORCPT ); Wed, 9 Feb 2022 12:27:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238113AbiBIR16 (ORCPT ); Wed, 9 Feb 2022 12:27:58 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2068.outbound.protection.outlook.com [40.107.212.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16C21C05CB87; Wed, 9 Feb 2022 09:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fhAaqxDVofudT7opzL3vdOvhLGbjUw8U1O5cTJdzImcWPEqmz0niYtAV8H57Xz9HIsZgfOLQ0kG7QEIAOpT81bb0jXiuNg4kV7MsCOyaRNle6stgqq3OAq0NTPzlO7EfvpSoJ1HA/lJMhEIpnLADb5zGsZj3TLu9/57x4ekIqDJXPzhFa8fcAeNnvaLK+xZEu5W9BPH7+J1DuD9udX7EzVJdHKTuGOCq4iQJA49oEhiLgi8W71wNB1gYPaC9bb0y0hVVgc3qK8bVvJxuuSoSAUSVk9wGuJA28xPEbzqkqqKN0DUFBJUp/1G+s662gvY5bPLRaZU+dLVz5UmBg340/w== 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=pVN1fSaPHMHmN5ElK8evG9b+0aU6JalIZPJOQd2ff1o=; b=fozu3aag/2P5VXRkm6qU7zB2q0pWzHGDBSh4iiITzWPpjetRyJMyhg6AyIBFjID7nxp0b5bSNw8pZCntR0i0JSI0OcwNKycouZXRlR6C6/A7N8AFhOTH4LCOBSKD1PS3deKmhdrCEnrpTL2e3Eb7GBS0K4eSECRdnRu7jXqGKvmOaRH7a0QBZGeRDXeX4bifXvfz5tYA3n+fcw/kkHsqfTo8zYEazqFVgDJ1j9Y6zxiUPJNtLVvFjix1DnOvmOZnY7bxz4F97ZRnu51oX3+DSNxBdR/k5qfqWLSPJiwtRp1aj9LelgK/2oIwwXhaKVW1ROW/TXsDcgHTl48dXDIwVA== 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=pVN1fSaPHMHmN5ElK8evG9b+0aU6JalIZPJOQd2ff1o=; b=SPwk6CNWNlYOwdJLuoEq5FV+DyK7BnctP/EaaLyQB8igtthAmDvcIYFwmCLYclPnCOhAuLu+9gOxCrf53lalZUZZY8Rrtbsu0A3HS3jIYzdX4q4qVxLbIO1nxuoL9xomiu8wI4MWTvNze6u0Rf3BiF334V/MzXbR4Na9gec4F7E= Received: from BN9PR03CA0532.namprd03.prod.outlook.com (2603:10b6:408:131::27) by BYAPR12MB4773.namprd12.prod.outlook.com (2603:10b6:a03:109::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 17:27:58 +0000 Received: from BN8NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::5f) by BN9PR03CA0532.outlook.office365.com (2603:10b6:408:131::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 17:27:57 +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 BN8NAM11FT006.mail.protection.outlook.com (10.13.177.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:27:57 +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; Wed, 9 Feb 2022 11:27:56 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 3/9] i2c: piix4: Move port I/O region request/release code into functions Date: Wed, 9 Feb 2022 11:27:11 -0600 Message-ID: <20220209172717.178813-4-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: 2e193998-de87-4845-2c7c-08d9ebf1839c X-MS-TrafficTypeDiagnostic: BYAPR12MB4773: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: 1HqDoWSSlIDA02C8uYnb/S9eauoeVhHmUZluA+ymOaWdebEA6HgBP2b9uvTL7IBHSkWkFmgEHYRJ4FgNMAf/gw6XjePNOJRtSfS8D8CIImCgaJOi9EB10RgXx/vBRqJSfUyOeGZiRLqEiY3i50dbyTheUSvuCPQx5uXoRRR3Q3qF+0oKiA/KSjY3P8Ml7tkYYbf90eDB3jecGrj4zub8AtXt7isBduNO5LzzZyhiqqmoy9vvCm9h2sQFN8kFQkD/o85tJymE82LxGw6uWluajBZmCXeOQMEaGEmTMkORU+8e1MxPpuE7q5SUlVuN7Kw57fDqj0DqHAFQzQIezxedZyVaVv8PsTSUH7rK+lPFGVdo3q2cDToyrYQ7ZrPiG1xr1RkF4HTGMxRaQDrrrv6KjN+tRw0NAwMnMNtyW5xZ56C+CzfRtgMX4pfz+Io/A2TS2nsRWpI1tv7vP8IKFd+V1fSuaRarQV0TPszwnj5qjcIB0FZAfvaUQDkOowpBThvW1MpqGczCR5brI3B/SFTTGDsXY75wPOrmkJOWeCPpFhNExl83UOAIOfqooJsgQxROKmbAuyAxCs9RBEjqwaMNdn3s4YZ1PRDlpt4EQVlDiTP+GFH4Y8FbMCX5uklZQ5Lo9Efy/YvOUkKX79sbfHn1hhm8l5aMDCiQhpqVWLO4xW7gmvl42gMK2KQbTdfurqwuk1lk/CfrqmEqa1ZR0pltQULffdxFxhj1Q3MAKLCnPPg= 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)(4326008)(2616005)(508600001)(70206006)(82310400004)(6666004)(54906003)(110136005)(70586007)(316002)(8676002)(8936002)(5660300002)(44832011)(2906002)(7696005)(426003)(36860700001)(26005)(1076003)(186003)(16526019)(336012)(36756003)(81166007)(40460700003)(86362001)(356005)(47076005)(83380400001)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:27:57.6706 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e193998-de87-4845-2c7c-08d9ebf1839c 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: BN8NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4773 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-piix4.c | 48 ++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 3ff68967034e..cc488b1e92c3 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; @@ -373,11 +388,10 @@ 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, - SB800_PIIX4_SMB_MAP_SIZE, - "sb800_piix4_smb")) { + retval = piix4_sb800_region_request(&PIIX4_dev->dev); + if (retval) release_region(piix4_smba, SMBIOSIZE); - return -EBUSY; + return retval; } outb_p(SB800_PIIX4_PORT_IDX_SEL, SB800_PIIX4_SMB_IDX); @@ -387,7 +401,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, SB800_PIIX4_SMB_MAP_SIZE); + piix4_sb800_region_release(&PIIX4_dev->dev); } dev_info(&PIIX4_dev->dev, @@ -685,9 +699,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 +776,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 Wed Feb 9 17:27:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541591 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 C72A8C433EF for ; Wed, 9 Feb 2022 17:28:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238240AbiBIR2L (ORCPT ); Wed, 9 Feb 2022 12:28:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238177AbiBIR2J (ORCPT ); Wed, 9 Feb 2022 12:28:09 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2073.outbound.protection.outlook.com [40.107.101.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB96C05CB9F; Wed, 9 Feb 2022 09:28:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iArVFX41OdB65wxciC580RJ52bcfuQ4sq8qUtwVTDMNZfNuUrNeVm8WqrGGwyTT8t500uSleqyDdKoLFl986xWQKQ7pv7ybU/+S5YDvcqoNbI8X09nKk+K+mClVrwOL7YM5NkSLr0+cRgyn0UcoIztiGEFKeEczOyiL6W7Q8oUxndRBcIg0rp3vHJQqERkejt8EINwg1hW+cggxCv0urE4dKI1dzsECTf7OtQa8jUlgRpGKFbHq1enoP779EOZQIUbUsmZee1cbmailddUSi8qY01sRZKHvVbjEutHinS4mZrkNhA3/2EFpTDdxRXP3Nr43TZLIuKIVJoMB52jj7Ww== 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=P/KrdumM6sgTU3oSHI68yIAcO9w2D+6EOObmpzWKiX4=; b=ch3bNzbDdsLnvSGFmBjv7RbIrijSam9dRuxqv3WTYjW+P3AoEwf1hpfsVri2Rv4A8ET3n+Dfm9UZvBXQL8ILz2e5tzXX2bBVRv2dZBZexschurbQrU6fwb5YPkiOSTbMlSKkATIjvMVdxpBJFo+tMzUeAmqEmg4Gm98hIBkNtGjMGQHQN/Mhihlh0/2MMqh7qxLt8PGN5MDs3HbU9mKZorCB9ZOI+gHxM1lpcojV1uTN5DFkFQCI5IiDZZbBLtAzITlafZkVt/z7b7xkjcBCFfVeJgTMlAy7IlCkp7yhykreMKEGknmp0w1iTbAdNKukVDILw5tvI5uBQpcegruhLA== 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=P/KrdumM6sgTU3oSHI68yIAcO9w2D+6EOObmpzWKiX4=; b=FsN2dEW6xWVISDTroJeXOYDxydg8uwrNekl5i/zG3K6NI3b1cncc8yT+JrNSP6O2cYJNd/ou/yoPewAiZtdsMAKVpQPcNWy2klvFlBi/5KU70Nr6eCLopkgxjwee7MsqBAUbJERMD//GgcJvJS9sMxlC8gu98p9De8Risk2G75Q= Received: from BN1PR13CA0022.namprd13.prod.outlook.com (2603:10b6:408:e2::27) by BYAPR12MB4616.namprd12.prod.outlook.com (2603:10b6:a03:a2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 17:28:09 +0000 Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::ac) by BN1PR13CA0022.outlook.office365.com (2603:10b6:408:e2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:08 +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 BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:08 +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; Wed, 9 Feb 2022 11:28:07 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 4/9] i2c: piix4: Move SMBus controller base address detect into function Date: Wed, 9 Feb 2022 11:27:12 -0600 Message-ID: <20220209172717.178813-5-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: 57c2cd0f-422a-45a8-b7a3-08d9ebf18a2d X-MS-TrafficTypeDiagnostic: BYAPR12MB4616: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: frLEiUfBwPlTbBSVpVF3b4Do6gyAWhRr+StuXN67j4U4N1bkdQTbeQW6ObTcbUOMERnb+ziulSFABfN7JwTxygCBr+igORbMxjKl5w48NEj5YwHHgZKWgyL2aOZp27m2DxdtFTI+6+fVcyclY/SQpxj9p6gWy1qwd1zPRHrZ2vrhPVKSs9mtscjUOZ8yImqKFvzaXhzUqNTnU4uUJerS9/JqNGd4ULoqKKYi4xWEU4lGq0kmPtXd835msfBu5S9coe4oHTLSVGCFoyOsC+e98Op1ml4gC9Q3hqRs/IKQOLn8ocITrioH6JTxGF1aWk18m7eHlRsGM1b/wDC+rOM0eds7rwyoBukEz1wyrxSfNcrF0pvwQiHnnabaZlUr5vB4x6zfH0DqqdHt3dHsD6TIfEv9aastQPAkdIicrcCCvHh/NpSPMCgnXTIpvZvf5lH/unmq8nAmQMqLzsucPkJG0lpahWjj/ZesOEcWEV7l1i9r6gf/K0zttIH/jUK9Gi3ZBcdAhasdMdv+JUu+FmyudQtLHR4J6CDIohjz123x3p9yIZQ2Bhz50mBUvwV0I4buMEldM/idEtmul9eOWUKGjeiPk0s/0D9BqOZJTLqAx6Ur5KKXhqGGPD0IIGYEcLjIlY5vE548LXU/dnH33U9CGik9R6bQh4Kuv2qNIwmf0eG8J04Jz9Kih2gKahMxIVbSMd6SHS2tGGQnD4Q/L9wWtuH6r/A3MVNbFmyg+Sc6K+Y= 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)(1076003)(508600001)(81166007)(86362001)(356005)(16526019)(54906003)(110136005)(6666004)(186003)(336012)(426003)(316002)(7696005)(26005)(2616005)(8936002)(70206006)(70586007)(8676002)(82310400004)(2906002)(40460700003)(47076005)(5660300002)(44832011)(83380400001)(36860700001)(4326008)(36756003)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:28:08.6908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57c2cd0f-422a-45a8-b7a3-08d9ebf18a2d 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: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4616 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-piix4.c | 69 ++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index cc488b1e92c3..b7998eb44027 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -282,11 +282,51 @@ 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; int retval; @@ -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 Wed Feb 9 17:27:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541281 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 A9BC0C433F5 for ; Wed, 9 Feb 2022 17:28:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238297AbiBIR2b (ORCPT ); Wed, 9 Feb 2022 12:28:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238261AbiBIR2U (ORCPT ); Wed, 9 Feb 2022 12:28:20 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2065.outbound.protection.outlook.com [40.107.102.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 659E9C05CB8A; Wed, 9 Feb 2022 09:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XVEuFpbbmXgIRYsaGO5um7myHiIlTo0TBcmQbsaJ9fwnmoZEaoySX//Di42HH4bR67KkBQoqBx0SjEUlP0gjP1IJRqEDtWF+I1RfIN9axu5y8M1dUU7BUymW2qFvqa7JHF8rb3ChPN8h8qGZU4oZGwQqB5XFcdZR9+D7Ez6UhqChvZJYyxOlzO3MFzYZsjh+mD9wplBw+U+30hENWlkDxPuBbu0ZEzjVuD759K8jWdFgoY2laOX/IVekw1G6FjsJYNm1hJEYM7jf9nSO1gAQiBSPzTKja3ZD7Gt78Mp/TPCsz4cwC779hM+xqiywXr5DJXdGi3qwOFK+bwRMK/eCtA== 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=VV/W6SbKahNwBk6bVt+R0q812ZjuLl+ucHlQlectlSI=; b=mvz9lSbS4Qt1GwjGN/Rkxw+LgSf1TkphipGSZUzPBMb4hd6cTqRpfwVr5/upLIoOgWzvI4Z3Mvg0lvsh9Yg8N8J5uQUeUprDSDsQTjyEXDA3P74D9m/dqk0fK429OvtNXZuZWRMOrH0KAntZiY59QMtI9/gM6kriS7/A8MqTmQJEmbnoCjsFUeLuiMxMrnf28GBYV0tXjBwirvRbX/14o4YrRzqO09JFy4a31ZQDpdb8LoMFj0vwHBAEKTE0uCv9IjqR9v5kACEZEnoKNHPlSjCWdbz/7PPqaLY+voxCF7roAqZmnFyy1NnBEl5k3nZopdWyThipRmfzWyrf+TSMdw== 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=VV/W6SbKahNwBk6bVt+R0q812ZjuLl+ucHlQlectlSI=; b=kaMMxJD6jDs4pNmUluSYA4i+nn4gpCS1tOlAVZR1okfJOrBNmLGOvKeLeIDJcYe5JHzWoWHs47EC1R78C+CgnKhFDfBevJdYDVyr1HpWUxK/94ObyPUxRnpK1C8ozsbDNK0DFKLMLAQpsdd8UiP6gXYCeKdTBABJhnYrk3Ym278= Received: from BN6PR11CA0003.namprd11.prod.outlook.com (2603:10b6:405:2::13) by DM6PR12MB3865.namprd12.prod.outlook.com (2603:10b6:5:1c4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Wed, 9 Feb 2022 17:28:20 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:405:2:cafe::77) by BN6PR11CA0003.outlook.office365.com (2603:10b6:405:2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:19 +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 BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:19 +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; Wed, 9 Feb 2022 11:28:18 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 5/9] i2c: piix4: Move SMBus port selection into function Date: Wed, 9 Feb 2022 11:27:13 -0600 Message-ID: <20220209172717.178813-6-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: 61c926d1-cd11-480f-3276-08d9ebf190c1 X-MS-TrafficTypeDiagnostic: DM6PR12MB3865: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: z8lYTGKuAj6uQ76JQgXfkObtbBuoecTwYiN1Z74e5kJ49drpUqypwHhgqKDdrcj5AiPLogxurIHMoP+R4AKqUNzKuhowe+9FC1AMHmAnI/A/uTrvoTmWf5RLSFqYdj9gyQfKTyZLmDoOe3sH8mfkkLA7gnbRHYhgh534zfR+/zmUlJJnZJX2J+9XElbENcmuegiJKYWGQ4VIfEbL5JBb5OpKIvHvDxhuWbWSqqoHWa+s/L1AflL/LN+oXQXLOVCv1sy0cjI8n4xRsbIzK8z2DfShijIZeqE5dVhu8Ni2u/tpiUO1lh7ybZ/rm0mZG2bUuN8DDkggc7IqQGQbI0WEfnPEXOm/xpKL2/sVg8w8O/x0HEtlr2YS80mdCGWu1b8KDWVlY8Xzpm5te8+k254x8zvZb4cSSt2DqoHRHHA/vcywROBT+jFpkDqGPMjMDb28JZKZjfCkYlVVwivXNgA0y7pLz2JK7LpOs3Z7+fNl+QLeCefRr5LkZQgewIAYZ+CdHgTEKPr9fxzQQoBul1iXss3F+qHgqjFf/Dqrmlkq0F9vVOhOSqvU9xB4P8lgNGlzN6pw1z5T3kIqHnmffsvyfmPwpyj1PZ1Q/9oK4VLcvmOdlJU4/DDDh/lh9LgaXocSAfn7GxZNWflVmgQaMJBNyilUuXDROiEZuSbGy4INIH4jJZoyQ8YiMrrJFwzcGrh0Eu8dWJID6ZhcHfmDdKuIwNnkGmUFxHwyTB2OY8uV0Y4= 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)(46966006)(36840700001)(4326008)(70206006)(83380400001)(2616005)(82310400004)(356005)(508600001)(81166007)(8676002)(36756003)(336012)(426003)(6666004)(70586007)(8936002)(7696005)(44832011)(40460700003)(54906003)(1076003)(16526019)(26005)(110136005)(186003)(36860700001)(2906002)(316002)(86362001)(5660300002)(47076005)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:28:19.7237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61c926d1-cd11-480f-3276-08d9ebf190c1 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: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3865 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-piix4.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index b7998eb44027..f4a262a7d199 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -698,6 +698,20 @@ 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). @@ -714,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); @@ -775,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 Wed Feb 9 17:27:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541590 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 B513CC433EF for ; Wed, 9 Feb 2022 17:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238259AbiBIR2p (ORCPT ); Wed, 9 Feb 2022 12:28:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238303AbiBIR2b (ORCPT ); Wed, 9 Feb 2022 12:28:31 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2089.outbound.protection.outlook.com [40.107.100.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 607F2C05CBB5; Wed, 9 Feb 2022 09:28:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hh36XH8I7NsNYLEfj158MuWbRfhUG6s5lLzQLqCNkjoK3s1zrNtzottFWWL0iZEPTZfZq/Y5bBtQ8FCzSy/pn0vWBStaQndrP5sS3L8iq8kywbPrEZox2kcscsEkWRLgIh8pxhYzP2BgwAQVMF8XQj/Ev58wNqw3AkR7WJWVbpc0qIQpqxSC3EHq/KqncbtjIHTXYhVmalN/B2FiYqoYIVC6pJ++H2CKTi8V8m8hazQgnjqHw5LGo+Ga4sUjWTv265MDu8NkRhfd/8AQi0G/n1aXgJ9Ee3cIvf3GSd3AY2oCTeIfenKWUbJc7dWuJ5UL46g3Wn0ppDQCrUXWbk6OgQ== 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=0X9vGqP/k9Pvz4ZGBkvAU/1ASTotMUP8Q0p+g9Gouj4=; b=Ju7s+yjhTUWw7sbO/snPlP/y7g5crMammMpfWga+5/uPJnEm9Irdaqjldupom0VvTwGVj6ltg3uH59kaPt5PT/73nicV7pqOekt6BWYUv+kHnw6zKag3FYJ06ec65CjbYGX8gwFIF8v+9pTs3hkagXcCO243W15HiSQRyPGuyi8EPgYnNu+XCglJaw6t/pUHfuD0I4Gj7Nxcu5f2kqFVXZMErFgb8tfiiFnzWqG4VRCZuKmculjp2S8VTmKayVTDfkRp0L7znkL1ERuLNLmU8/1tTTXCc7nyChkPOR8lX6M44VtDMaKfZXVJPhK3iejtJDcglPEMW/zuVOjZc+JDHg== 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=0X9vGqP/k9Pvz4ZGBkvAU/1ASTotMUP8Q0p+g9Gouj4=; b=FFRmtL5DfE6uzRxKDcPu3QvPrjjjU26T+3vj6rLmSpxzhpezo9qtfbJJdqCQSUW0gM30Fvo0TisNpw2VwkI+rN4QuWWWdoZ6Jm/B43b12e+8EvQcGR8D/G6e7nW+7Lod4yefsY3eAvcNkYGy9g0ZV15Qrtp4mN8p/hoYDxCqEdY= Received: from BN9P222CA0027.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::32) by PH7PR12MB6000.namprd12.prod.outlook.com (2603:10b6:510:1dc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 17:28:31 +0000 Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::cb) by BN9P222CA0027.outlook.office365.com (2603:10b6:408:10c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 17:28:30 +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 BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:30 +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; Wed, 9 Feb 2022 11:28:29 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 6/9] i2c: piix4: Add EFCH MMIO support to region request and release Date: Wed, 9 Feb 2022 11:27:14 -0600 Message-ID: <20220209172717.178813-7-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: b0dbf829-dbf9-4cf8-3447-08d9ebf19754 X-MS-TrafficTypeDiagnostic: PH7PR12MB6000: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: YuULBMglJTTKlfu8PFMr4vGXIIRJzhqispqdAj9JqtbMZVbyCNqmzl4EzWwkP5JqmXPGrNeSuD9cu+5S3T5XV833PBOiI9sNZCa6Kg3nyIE05h+6WRB6NSh34QiWkpnGbfWRIegXV3FSnHHpeI2WyqA9idW4eUrLe8fWhzVkDyBlppH6qVqQogbiek8m/4KZUB855WNQaVavTxkxB/Lyu55nftHK7yRinM7bBdYyFp0H6eolUbGYuv5rUpBGlF5D89uLINP56CQUeI98cNljJ74RSkhaiTIyb2gmVCbhjwhAGseqmYsgfQ3e0mei1LtLu61/RnOBCiCv8XE+2ah16rYz+hE7hnV5wiEhZ6YFKseW4BVVS/RsG/NJyhyp1Ys/CdFqIPqEsPPWFyO02/xtbq680FrpQTDQu7B0TPzJEWcTiBZhRrQoL9n6CqRADZjL83KsmiSsN1TUyzLN2YYHogFsizteXAbU5btF7RLsc7soaV5tUoSLjnFXWv2/DD3YeOllIfqJW5IqZhhnE7MWhGdOFN1c4/gAeF1piJ+3JLTAabxp+ds43EpOHQkFrzid7Lmo8CwD/xPIBz89Mdp7k0bBlrL9rn0FwmsWvOjPFsieL4F0ywy8olrgwpjluQpiEFVtBk0GoQMq1ZBkP09jzwp6Dm7zQFTBrAf8sNjcQLXXVwnJJ5P4omjY/j/Y+B6gMh+z5ldOIqXMN5yYfUllKeSpWwDHtuuZyYiynAVzm1E= 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)(186003)(47076005)(26005)(1076003)(2616005)(8936002)(36860700001)(8676002)(2906002)(336012)(426003)(4326008)(16526019)(82310400004)(70586007)(83380400001)(70206006)(86362001)(81166007)(44832011)(356005)(5660300002)(316002)(508600001)(110136005)(36756003)(40460700003)(7696005)(6666004)(54906003)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:28:30.7378 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0dbf829-dbf9-4cf8-3447-08d9ebf19754 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: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6000 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-piix4.c | 68 +++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index f4a262a7d199..d06998f7b031 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; @@ -328,6 +376,7 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, unsigned short piix4_smba; u8 smb_en, smb_en_status, port_sel; u8 i2ccfg, i2ccfg_offset = 0x10; + struct sb800_mmio_cfg mmio_cfg; int retval; /* SB800 and later SMBus does not support forcing address */ @@ -407,8 +456,9 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT; } } else { - retval = piix4_sb800_region_request(&PIIX4_dev->dev); - if (retval) + mmio_cfg.use_mmio = 0; + retval = piix4_sb800_region_request(&PIIX4_dev->dev, &mmio_cfg); + if (retval) { release_region(piix4_smba, SMBIOSIZE); return retval; } @@ -420,7 +470,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; - piix4_sb800_region_release(&PIIX4_dev->dev); + piix4_sb800_region_release(&PIIX4_dev->dev, &mmio_cfg); } dev_info(&PIIX4_dev->dev, @@ -731,7 +781,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 +852,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; } From patchwork Wed Feb 9 17:27:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541280 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 9EA9BC433FE for ; Wed, 9 Feb 2022 17:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232034AbiBIR2q (ORCPT ); Wed, 9 Feb 2022 12:28:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238289AbiBIR2n (ORCPT ); Wed, 9 Feb 2022 12:28:43 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48BBFC050CC9; Wed, 9 Feb 2022 09:28:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eEVA3uhbn1QVeP3xjYsbLHbQkOG2sVvxK4n4uG5DeheFCIilf/pjjEFwod/T7FcT+qdhH3y6lckj8kGmMbLid/bJxqB/GJgSzMXpfCdDUXVvAR6zhWNhzBVPu2Z4SG1kb6Nd7bVzVs8FsqvQVFdpT5Ii1t3MmVWZ713YVUZrl8xK6b/D9s7DeVQa0sZknGohjzkyzwREfS4hTXxfZT1Hb7VYy1p7y0YjB6N/ULb3k0e6Q85Toq4od2Sfy4aRKCExZZZ2H8oifFLEqjUvUedCj0OPcAycjBoVrc/BdcTu7KOMo5lakPayi8Xd9M65GgQ0c7zGIBFHrBtINFCVhqhYCQ== 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=KcHTNvXdp1HWM2HEbKsB9/8THIMq8XhGgNOtpNC37J4=; b=akgsfktcepMdJ7kk50HxQETrEqnteCLN0RsusQAkM1PDVJrCnrGicde9scJq5bm9AgDpMi8QSr9z7kjvJ8jCMYc65q1s0v8oOjBm1e+UlprAGVvnKGguTPPpzj6aP5SU1LT8ikG1HAlRwWr/M5B/eplN2xV1FFGMSIbRywax1mT60eV39TfOurjLuC495v9qLzxGV5IezSb1/Ix8jigEb0TMCBLWJp/s6zu8jGY1TZyJwmsU+NROy81kHFQKfIsiUwraYROy0tHUo0pVenGiQaRd0+RhomUH9Va60U7SgsvJAkpt03DOxy4V0x6b2lCztuHL840NUOm5BN7NMJL5Kg== 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=KcHTNvXdp1HWM2HEbKsB9/8THIMq8XhGgNOtpNC37J4=; b=WXiXqI2E5FSpqeHwIaBRgjKvnt2BHEL+RJDE5b7dirShn4ztTr56jEewVAPMnuTzQQveekPv2IUAFXqfWWL0lL7WJSblgFf5jf1qlEFcl8y94HeX+85Ctw/CMMg0mMw7Ood26/2YJRyNl9HX5VIKHSQbU2XpZO2T8XRyYmEImec= Received: from BN6PR2001CA0029.namprd20.prod.outlook.com (2603:10b6:405:16::15) by LV2PR12MB5965.namprd12.prod.outlook.com (2603:10b6:408:172::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 17:28:42 +0000 Received: from BN8NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:405:16:cafe::e8) by BN6PR2001CA0029.outlook.office365.com (2603:10b6:405:16::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:42 +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 BN8NAM11FT051.mail.protection.outlook.com (10.13.177.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:42 +0000 Received: from ethanolx7ea3host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 9 Feb 2022 11:28:40 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 7/9] i2c: piix4: Add EFCH MMIO support to SMBus base address detect Date: Wed, 9 Feb 2022 11:27:15 -0600 Message-ID: <20220209172717.178813-8-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: defbd57e-5cf4-404c-6812-08d9ebf19e44 X-MS-TrafficTypeDiagnostic: LV2PR12MB5965: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: UX/yh9CgCJZdLLB7scuMykC5gR8jPSLm5CIclgQpT2Pu3j84P5RVkR4sJ/76ZpMH1lhlgYeZykpGcH6h1KXNtP5q0biKyq6ZyMILYRhbnuU/b0FKFgqZic8vP2sXTCl7ST1SCmFM/DCFHCS2ZVGKSZtRjPVNk7tXzrt66FfgdFhEoUi6RUcIIr3Jd9HzE5hXeDsvJ3y3bchD8rj9isyRjX2juYUOhYhdThXKf1kduFRY3YCC9HEvOVkCEVTyYXh8Weqn1ov7Qkp+xS0lq7c5xwZdebKrK/wQx6L2BcxqEgaJOz+4s9BxhsLa+KPqOth0wlGe6Hz1BOreOZHrA7B6uU19ehMtc85Srg7c8yvE3TvywSkRYLVR5nhPK6N/EgRxQU8xBA+n8JOG63fVeHwv4sLExAnR7VY7hIxoarKwHYMRb/mSgYER9+vPRAEpgZ5HBFELnpZzo21Xz6DPWr9WoPEtljBvpj/CZHKyRbqkcth5sfhWSuompLQRsowBZwZ5InjX4EFCxHpdvFrUNWbVlFDFzUvlpymbuISvzmgnY9z6LqZy9hgF77/0UAx6KKA+m8Z+ryUj5O3WRjqkFoEFGbeqGT4FWwM8aCpNS4oCqzo++6J2MzCNBVCBzk2rQwbtgRIDARwd0C4M2RHaiJ5JIIqZPUpK5sWcdX0flb+8eXvHujwC4iQG9kh/TVbf8hk/QW7rtjv7My3hGcT9PVW6LkrJ4v5yCgjokLUKvr1PEW4= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(86362001)(36860700001)(2616005)(5660300002)(70586007)(40460700003)(16526019)(7696005)(44832011)(70206006)(36756003)(110136005)(8936002)(4326008)(356005)(1076003)(82310400004)(336012)(81166007)(426003)(26005)(47076005)(316002)(2906002)(8676002)(6666004)(508600001)(186003)(54906003)(83380400001)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:28:42.3939 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: defbd57e-5cf4-404c-6812-08d9ebf19e44 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: BN8NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5965 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- 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 d06998f7b031..7f312177eb27 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 Wed Feb 9 17:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541589 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 44B47C433FE for ; Wed, 9 Feb 2022 17:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235373AbiBIR26 (ORCPT ); Wed, 9 Feb 2022 12:28:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238314AbiBIR24 (ORCPT ); Wed, 9 Feb 2022 12:28:56 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2088.outbound.protection.outlook.com [40.107.94.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BFC9C05CB8A; Wed, 9 Feb 2022 09:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jgiYl0m5btHxSa7PIeGdKiw18y0yWNi9iXyEPSrzY/Gbvuk1k0HXVtv8YHc514G1Pe4NjrMfsaQX0iNstdGiHSjpS2rcTjKp/inG/0zMkGagpZJX+6mge3VEo4bSsOVSNDWdqS0G1wEEzP9dSyUs7jc7ji6CxtPy3JT0SiYkNA3PCJJ8FwNmALXogGuFEi+jEsGhlCDFqrcCqpDKiyRn/UFw9nlTf5jVHhLTk0TR1LX1z1Tocmew39Wq4TRj+AHzREVsvrHjIryjrlwkp4SI7SQjvgaFYh5alZzZ/8xfmNSzuDaJD2M8JDotFECRO9VqDmUayu3rkmC762lnA0HALw== 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=GRlYr0UbBNkv/2qxtTahTYT486tEi1zG10FLVxAf4z8=; b=R7fNcza+NmKUMbd9jAr+XADUgXjeYVVzMW/BQ3iT56lHGqATBzdoKElgNgiy/61l2JjtBfD3YS7kxEMxiI+2cPvhaZ7AG0xTl3UJcWWfH79p2fxDU1MBgK2MUGVhp383RPgkU0yA5Llb7Iahpx1fr7oEY0Kgf60PSXlY/uIV6ZegUE2jSYYNRG6oyeM8+c6K8KBIhhFT3kDZJAJBOP/c3ZfuhK3e3tKxkcobDdkmkG2lrNEoRj379aeDKali0/Ws8LbrDjvJSCP+PlL0X/BnGeHEN8uj8bBo7qHng0yFO0Pm0qeQF1SScbycOURDRmzEFbJIZlJ48m2PzcyVmX3oxQ== 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=GRlYr0UbBNkv/2qxtTahTYT486tEi1zG10FLVxAf4z8=; b=HilQ79JQQxKrvEO+0hNosjxhvl608fp2EaGlHcPggsCXJJ8qI1mucJ2RgAZUm9indVvFHSsgKYjjq6cDmyQ4eqq9GmNbN/5KremtLG9yd/xQApo2z8+ZsHhk03TJGw8Lix6AN5IIG90dbGHC6LoUqgQWuLoNsmOeSd0evFnuS3g= Received: from BN9PR03CA0683.namprd03.prod.outlook.com (2603:10b6:408:10e::28) by MN2PR12MB4125.namprd12.prod.outlook.com (2603:10b6:208:1d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 17:28:53 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10e:cafe::da) by BN9PR03CA0683.outlook.office365.com (2603:10b6:408:10e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:53 +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 BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:28:53 +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; Wed, 9 Feb 2022 11:28:51 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 8/9] i2c: piix4: Add EFCH MMIO support for SMBus port select Date: Wed, 9 Feb 2022 11:27:16 -0600 Message-ID: <20220209172717.178813-9-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: c220af39-d292-4f7b-911d-08d9ebf1a4a0 X-MS-TrafficTypeDiagnostic: MN2PR12MB4125: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: EUa2SkW2Kv+nn/8xjPlfQ9T1P+wuwdJ5MgJqJdMUblvj/0JR/gZK3NjI1kEtI0AEbUv1PFMQkOg4vqhkRdnDKKM2R3jBZ5mBor5MBXtUFjGJLqWgVwjPJ3tF+XjP0RFiUBy5P/0o6OvhMnstQc6kGUBbQv8XAeEXw0s7O81qEo+keZRjfsrI2u/iKlytHIHHBIcykvoChBooXryx/mW7EEC9xXjt7nbMWXR115nkyo/J/VfG734S1rW3Fm4YRRKWDwbVgxVrtFWtx3r5rAs9Ah3/AbFZd/uquzxlEDln23qqzB7jvtmTiUoXA6CRrw0G4iseFNnb/v6Vj2vjXLw080+2J3ryt0EvPPRKazLH55cW5s4HqZLuwY175ycy1fK6Xo+s0JnYU8EbjwwkewZCezzxspgIclK5uI+/8ZT1SWhyZCUs7cX2K4xWTkQwBDj+lxyPOlydT6iZ+VLv9wCG6xUgXDkqLU6D2i7frWOuuaKGGdN4peMUA+kBVLGKIz96Txl6MS4ONYmhV+rJJ9jR7Mwk5N+ienn5urnLDCH8/xr4b0hcx7SS057b4985kUFUB9mJEDK54yMxtuiFoUCu3WjN6XhBKCcsn82KUHs99jsrS17snNaL1jtNoeMAfiLW36mMd431saxXznJXvLXT2Dq6VVePmFOUNMxXt7B0vz9EEx4+GsZ9abikagbrRkz7vGMyDI16qzmlKVz/9hqOPeqQk8FiDj+cQQBr/xq/FnU= 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)(46966006)(36840700001)(336012)(86362001)(426003)(36756003)(316002)(110136005)(54906003)(83380400001)(82310400004)(40460700003)(2906002)(44832011)(6666004)(70586007)(26005)(8676002)(4326008)(356005)(8936002)(7696005)(81166007)(1076003)(16526019)(186003)(47076005)(508600001)(36860700001)(70206006)(5660300002)(2616005)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:28:53.0486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c220af39-d292-4f7b-911d-08d9ebf1a4a0 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: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4125 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 Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-piix4.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 7f312177eb27..4789fc9ad270 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -753,10 +753,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); @@ -843,12 +852,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 Wed Feb 9 17:27:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 541279 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 AEB1EC433F5 for ; Wed, 9 Feb 2022 17:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229807AbiBIR3H (ORCPT ); Wed, 9 Feb 2022 12:29:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238329AbiBIR3H (ORCPT ); Wed, 9 Feb 2022 12:29:07 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A958AC05CB9D; Wed, 9 Feb 2022 09:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oCi1Q6xfhZGqDJY/6ArLHfr/LehDQYEhXaz6XgAlbc+kTe7ZjB7QHou5UsRm/S54rt4bokcXcEcD4XuADKzbBcq8LpZL1D4SiGBBMAas5R/PYs21/A7XJkIJF+IFF84PQ8mMk8wWSreIC8mFHhV3Y8DaLGOaHsjR5Z3Q3U2B0TkpG3JT+DHjjSLrW4oXR0fBLyb8UnGHtPtPy4PrtvDg4rtatqd7LdHnlXMO/mU+UUMCWWIyS9CJ4131zjPU/ehTcS+ggqKHA/3XqY+rybmkKHsqoVFQPuUXK8cuV74AyCGJeTzbXwGuaTGsb/qPtsHedF9PwOuHngMcsKHKYWA3og== 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=6ZYrJ6CUz9M8w1LTs4Wc08HMqqviQwQQiAGIEXadI30=; b=TMt/unZAihjzqRMqWmraj56OHFDUUI96GjMMhnFZMMaqMuZVKnyrtcHiB2NThbSgSglfP/KSTNx/tZs5oC5iHKjhMNjkDS7BXKcrCQpiulNyht0PPY1txkulHcAjq4O0Hu8AJLsTq2bS/d1mYV/mYyN59zSmBGcBxtTFtC8GkVle3JzjCXEwpOtfv+nvzfLJd6kRgGEhE36O2DAOJdxR5ko1Byz9M7yUzkQLSnU+t082J5BmGfuWm5Cie/1qfJN49PLRpVsbowcPQ9pX5a8yL+QYZvV3U4NjbUA48CNLVrdxuBy0roHQEkk1gq36xPTyCpAiNlaNG5b4xZFsIPc18A== 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=6ZYrJ6CUz9M8w1LTs4Wc08HMqqviQwQQiAGIEXadI30=; b=mwHYr2mt7W7TEEXBdWMgGdnpWPuM5Tq5mzHr1r+wxIpwptzgDMk2Kx6QAJNMXFatzvK+M6ul2D3anQZ6JThau4SFrTnKwprUV0dcrYAV2ctXdEHabXKVCmk7X6gjj+erwJk5pSgqasJyodfjbDcKJhUDavQwgDTYHjTrhYw4V6M= Received: from BN9PR03CA0587.namprd03.prod.outlook.com (2603:10b6:408:10d::22) by MN2PR12MB2893.namprd12.prod.outlook.com (2603:10b6:208:107::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Wed, 9 Feb 2022 17:29:04 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::f1) by BN9PR03CA0587.outlook.office365.com (2603:10b6:408:10d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 17:29:04 +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 BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 17:29:04 +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; Wed, 9 Feb 2022 11:29:02 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v5 9/9] i2c: piix4: Enable EFCH MMIO for Family 17h+ Date: Wed, 9 Feb 2022 11:27:17 -0600 Message-ID: <20220209172717.178813-10-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220209172717.178813-1-terry.bowman@amd.com> References: <20220209172717.178813-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: 02d90a2f-4db3-4d96-4a8f-08d9ebf1ab29 X-MS-TrafficTypeDiagnostic: MN2PR12MB2893:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /9P5I6g4nE5QP8dosn+kSNMwYjohHa2VhUJWuaplcgka7c6nSqUuirD2SK4cV7e1J09KMg15RF6lhuL3tAgXuLVOLZzs+WJd9pL35baZgd9V2c7Oepp2ESYMdUUl9FQhcRZ1RBKgX62MaK2mBRNf6eLbc2IG9FYme2GnZUTguFN7FODD3yzroW9TFz8rLehFTerAPwWYQBztl8cpI6klwEozonR3HPmaB8WvdzmYFMH26jfVfFytYLgvMWWNLlXWuvtIuR2THi83q6dGOYiH16rvBSb5xjgFBOXfojH28cewzo+prIRmVdrv8K2oIiMdG4AxpM9SRslfnQ37QuWvZ3BJF1Hr/dOgTeTNo9szViiGoe0s6mKJKCEVxVSiKb3BiUxlj9g9/HIqkAHjK+moWKx6QMbvAh9RLaSdkLi4XVYLkrIqgqrvuNjVYurRwG3AcEpOiKJ9hnkCQwbx30VsCrNoqMmQZhgQlHTEOakC6VYPVRArNeH2Na1z2ZSD+V7P4HuzoCo/b5ZHD9luih4hsFJ2ZA719doUHQT9Y4Jlj2pIMHojDj+jjguUuyKF5AmXf9nY4dQtjHo0cN5tXGK0r/9cQ7ySEts2BXQnKOjKXfdE9qDOF5eQprN4dhMR5MLB71RkF62OMqeDvLPNnYpiFtXlIXxqkCI5lEmu+Hx2DCJ4B10A93kplJBuxYUZsiRHersp/6hIZ4fiof4j263HK1VxiWISyaTqCAblq6Z+8D0= 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)(8936002)(508600001)(70206006)(82310400004)(316002)(4326008)(47076005)(186003)(70586007)(8676002)(81166007)(356005)(54906003)(110136005)(5660300002)(36860700001)(40460700003)(2616005)(26005)(426003)(16526019)(1076003)(86362001)(44832011)(336012)(7696005)(6666004)(83380400001)(36756003)(2906002)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 17:29:04.0110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02d90a2f-4db3-4d96-4a8f-08d9ebf1ab29 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: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2893 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. This PCI revision ID check will enable family 17h and future AMD processors with the same EFCH SMBus controller HW. Signed-off-by: Terry Bowman Reviewed-by: Andy Shevchenko Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-piix4.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 4789fc9ad270..ac8e7d60672a 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -229,6 +229,18 @@ 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) +{ + /* + * cd6h/cd7h port I/O accesses can be disabled on AMD processors + * w/ SMBus PCI revision ID 0x51 or greater. MMIO is supported on + * the same processors and is the recommended access method. + */ + return (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD && + PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && + PIIX4_dev->revision >= 0x51); +} + static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id) { @@ -339,7 +351,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; @@ -461,7 +473,7 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT; } } else { - 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) { release_region(piix4_smba, SMBIOSIZE); @@ -944,6 +956,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, return -ENOMEM; } + 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;