From patchwork Tue Jan 18 22:11:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533061 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 687A2C43217 for ; Tue, 18 Jan 2022 22:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349760AbiARWMd (ORCPT ); Tue, 18 Jan 2022 17:12:33 -0500 Received: from mail-co1nam11on2046.outbound.protection.outlook.com ([40.107.220.46]:35947 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236714AbiARWM2 (ORCPT ); Tue, 18 Jan 2022 17:12:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MA23vk64KfN845Z3paTzF40KpYlX41+m5dkb0TjjimQ6cklfze7RxMKrkuidrFBY9Cgzi1tO5rzzYPZVrZmniyi5/EFpvOMnap5u/afmw2P3kVy9kHPpOJ4uTVuIWtlZOY5d+kIzCK1gO2kLK1k6E0il7MWooQfUddNHoSlS+ucHPSsj2sWweGHH/sy0V62+8TUDoX6sVups/37aPRAzk+MTpJuqOH+ePoJdX2d8hjNuHf+3uaebjLEZZnBIIu0qgOzhgoLgtFF6LzBlvTTfACkJr19uJF1c+FIGno5VcCQ/EzbZQqey/+QDWk22hknLXV0VQF7IfoD45RWqO2ngtA== 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=gVfZ7d8Ux/jadxdYvaRc3FTfw23PWDvbFj80PL37e4c=; b=GpL3BSnY+lnbIR97SWDvQlAcSCuYmyK0KIhSm+n240jDDLx7bvdPz5+q3+nHpo2ZW/xJU+TsU1WhlMEUK4fPjeHDHUIPoi0grro0Fr5lgixxk08XSsddAvVaOmMKrfVVwl5RlGv/FKyWDVQFnsUxrPmV8cGM7P/qm2qHVvnlHO6jyYayScSabYa/DBn/2cDG1e2gxvBsEwo8THGwEIHensChoLMfaWUurBGRReN3LOf6Su18sZUZ3Bd+tsFBep13BfP4Lv+q8iIGu9TZMaUc/fqWpZYxQSBX+OGNVNBEwjvTIi0NzTZlAlXGP+MFbheCitqYhAcXE+Lyji09allkjA== 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=gVfZ7d8Ux/jadxdYvaRc3FTfw23PWDvbFj80PL37e4c=; b=bzE2CjERHCh5AXckZmO6IGzBaZY1Pc7aYRQ01R0uRMoCYcKMiyIgsvuSBEeNQXk/QVPqeBkr0IDXAwEiNLza+evQCP5S3BWyR8H8U/gJ5KL3Inl+BjjfMoGJFV0Mk5uUN5YvXCvUZn8TUJBeCwajELc+oXs6s8kZ9mr6cJDzfEw= Received: from BN6PR17CA0036.namprd17.prod.outlook.com (2603:10b6:405:75::25) by MN2PR12MB4301.namprd12.prod.outlook.com (2603:10b6:208:1d4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Tue, 18 Jan 2022 22:12:25 +0000 Received: from BN8NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:405:75:cafe::4d) by BN6PR17CA0036.outlook.office365.com (2603:10b6:405:75::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11 via Frontend Transport; Tue, 18 Jan 2022 22:12:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT061.mail.protection.outlook.com (10.13.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 22:12:24 +0000 Received: from ethanolx7ea3host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 16:12:19 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 2/8] i2c: piix4: Move port I/O region request/release code into functions Date: Tue, 18 Jan 2022 16:11:46 -0600 Message-ID: <20220118221152.300444-3-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118221152.300444-1-terry.bowman@amd.com> References: <20220118221152.300444-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: 0cb20d7b-ef55-4be6-55c3-08d9dacf9b5f X-MS-TrafficTypeDiagnostic: MN2PR12MB4301: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: e79KM0OItckz31V0UMFtSVEDhgm6+b+0EyALiUEnmbjzbUn7yMI81khEJ2bsuwtqSVxmgecLw+gqV7Kq7UuNX3R9NUBA0o/gTrYVmvGjJpn/SjrebyqpTufKwiflMWmg5f9vwgj24q6ak1uB8/6ULayS5wKKjlMnKNjlAhi0JsJ0cKrF3UQAMfzlbZoyhWC/wwIw46r4EmvHXb0miVqmtJEQPHoNf9Ri7NxjvDM4XLDyuDgltVSuI4mhNaNEg/EymqSVjEp2UfbS9fjNoWPusqqyEt9km82/0U0FIz3lvn4ZI7KfjoG0OhJ2JrYUN5ziB3q3bTNHrZ5uMdrou0LHfxQx+PYsSUYf02+JItB6VHsgp5PFHaav1iTNy0jK7bOqY51BK5UsI3FtZxi+aw1DEi2faJkptF/VTrZXXNS4Y+X/DWKua039QzB4I6qblfzvew0RlIEZECns0wJOWXsRApAfqr/38EkWTgS6NnrUXy2VNCFlLORHr0gnA5kvBcG89Llaad8f94IXgASlQemH5efA2R3xthqpLiireAhViLubQwqrDf1kV6UUryA0D5FpdUepYD0KMbisPK+2bJ2v2EOaVWbDmHobQ1USnG9rJf6e76MyQUYu0a6KWKk9rRAMT97m/rX/R85Td5wn1LxetExfD15DHQp0udNAeoRjbCzLd8aFN0OsLBL3VW8RZ4D5MAVwIEKY2WkmkmdSnKgvMlDYmRvms71nPSyCabVxp5gA11GrwQ7eOEEgy6WjQzbjFTvOei5m1VHDjSBl5Gq18FBrkE/30H9DrrZbidTszyb0yMR4OGODCdwb89ZWLmI2 X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(40470700002)(46966006)(7696005)(86362001)(426003)(47076005)(70586007)(54906003)(5660300002)(1076003)(16526019)(508600001)(83380400001)(186003)(36756003)(36860700001)(356005)(70206006)(26005)(2616005)(82310400004)(2906002)(81166007)(336012)(110136005)(4326008)(40460700001)(8676002)(6666004)(8936002)(44832011)(316002)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:12:24.8968 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0cb20d7b-ef55-4be6-55c3-08d9dacf9b5f 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: BN8NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4301 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 To: Guenter Roeck To: linux-watchdog@vger.kernel.org To: Jean Delvare To: linux-i2c@vger.kernel.org To: Wolfram Sang To: Andy Shevchenko To: Rafael J. Wysocki Cc: linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck Cc: Robert Richter Cc: Thomas Lendacky --- drivers/i2c/busses/i2c-piix4.c | 43 +++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index b88d990b013f..14324e03fe24 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -165,6 +165,26 @@ struct i2c_piix4_adapdata { u8 port; /* Port number, shifted */ }; +static int piix4_sb800_region_setup(struct device *dev) +{ + if (!request_muxed_region(SB800_PIIX4_SMB_IDX, + SB800_PIIX4_SMB_MAP_SIZE, + "sb800_piix4_smb")) { + dev_err(dev, + "SMB 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 +290,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,21 +312,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_setup(&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; @@ -686,10 +702,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_setup(&adap->dev); + if (retval) + return retval; /* Request the SMBUS semaphore, avoid conflicts with the IMC */ smbslvcnt = inb_p(SMBSLVCNT); @@ -764,7 +779,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 Tue Jan 18 22:11:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533059 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 AA419C433F5 for ; Tue, 18 Jan 2022 22:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349858AbiARWM7 (ORCPT ); Tue, 18 Jan 2022 17:12:59 -0500 Received: from mail-dm6nam08on2047.outbound.protection.outlook.com ([40.107.102.47]:10046 "EHLO NAM04-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1349879AbiARWM5 (ORCPT ); Tue, 18 Jan 2022 17:12:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DorTFth/jMCtzOZdd0JGfHHtF5hAXYy0akU5uBUirpzKY01rNJIdMzHPrLPAjNil1uCTqAPsm6pmeB+MPpvtToxoMd0D89nLZKr1NVSnTrkresxa+PFRFIKOt40ZA4cxkAzQQti61hEQjbsMeVNt1bMM3sctujvZR6r/G/nTgLGKb3LB/CSfar+S0PC8Ztg+25w2eUgzuQ7Fx1Vd88mPcE00XEmN+Fga7yRQfV3s/Z3SEjUbuEuIE+qX6SHUZbqNUML5vasbcC40lEiRi21rwQrGFtEYIdHnLs0+zuRZ9AwnboLs765SKqCuYtMNMthPCMxb5BrML8u3XcPIX7GweA== 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=YPgtwqX+LPB3P6hOmy6wodB5OmG9L9Mkt+cGk4zPQK4=; b=kX442TPHmi/A3kOKO60jogBVFnbUQC+S+h0d/KdOV1jysOr5K4u6jplH9Jj4gQK/3jxeCFnfI10kwWc1ZtFz0sICVProqHq2YSWNZ7V8NJYm1BLsobJsMrjnnNfUNqEmGymkz8IpeJMnZK2Ozh9IGpcR8zmcf3e+Wzw1EgpidzXt2GSHSyBqI5wIlG5ErLMW9CrFlCWy8r7M/iP5g2AFRRWd0J22ucJxqj9jm7SF/4fO5EjRRvBaVRdn3lT75k5KAip0ptTrGP5HmpWHuU2x6KDBjd/e8O2aWBixbjnolXSC1DFFGD1Ese9YoYMc4pqQSjz0z4neB7cLDqoqU1fT8w== 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=YPgtwqX+LPB3P6hOmy6wodB5OmG9L9Mkt+cGk4zPQK4=; b=IP+rXgp/gd43dw9FiLCpq34VZEwWQYy+NA4lGH8P+zddraHeJQjXVFxb5G7uHF1rPmNr87MxCrS27aif6RHnq4lBIsCwBJPs1D/iqvziT5e7xx1GU29ivO8zruuFvmJybu0KzlGowhufTA1ze1N/RLWxIcTlvrq+Oh1gJ1aWi4o= Received: from BN9PR03CA0250.namprd03.prod.outlook.com (2603:10b6:408:ff::15) by MN2PR12MB2862.namprd12.prod.outlook.com (2603:10b6:208:a9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Tue, 18 Jan 2022 22:12:54 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::9d) by BN9PR03CA0250.outlook.office365.com (2603:10b6:408:ff::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10 via Frontend Transport; Tue, 18 Jan 2022 22:12: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 BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 22:12: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; Tue, 18 Jan 2022 16:12:53 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 5/8] i2c: piix4: Add EFCH MMIO support to region request and release Date: Tue, 18 Jan 2022 16:11:49 -0600 Message-ID: <20220118221152.300444-6-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118221152.300444-1-terry.bowman@amd.com> References: <20220118221152.300444-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: 81212426-764e-429f-d226-08d9dacfacf1 X-MS-TrafficTypeDiagnostic: MN2PR12MB2862: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: H7cpP+zb/dlEpxx/mA6Abu2DYfqbPwqAnv1oh1b/0TkgmMn469gY52MGjRx9UlX4GJEjB/3n4XRVmEQfPAz+79yw15FMnQ5Es6ZW2nkGOGS9x5fVwStIv3u5+voomowqrt39r+/vccT341fIA6b+ht6L3CktaxcGqgv5FNb6QUdSKeFU0iu6u+Bip/piC3AsS4xF8/t/zK/LcRsqbkTfbc+Ja+us38p0gca7adVt3Vv2jCPbHQ1L7S8PrO4/RitlZ+u4wppH6pKGBZPGbvZ0nW4fpEJCNuHSPAhiiKHxj2dP/0VC+/G25GivPZcfVNRtSz1uKWd0gxns0g6kVLkiMzSfOz1v/zKkiPxRK1cq/+AH7i37MIJT9NQTQdkvr8Lxl42dwRJuu8jRmWAdriv9Q72GiGp8W/xUD3dSZYnNaIlRd69fmTv9JIjTDc5JKtdVLr/xJumj2L/b2MTTk6NbVEHOv6gFsHosSi34quqXRAFsD5uGg5bMEmvWfZo+1zon7tZBiCXhJq3Ja1+Ss7BdRxjZh19ff+jug1kI2odQRE6V1NwL++XwfYsfhvxdV1uqdWs09/iq2Y54aFYffSwVjtFnYnUH2fole3NF27wr2Ho/SSoL8jgvv4a6w5dKa6do3glF3gLDpDuaXijby1wzJSyQltmsyPw5WhDAyxHh8Z05LTCUhfW9vyEmRxe71LtvY4ezpNRExfvY0EujS19XvjDj7Wo5AKYlQmDg6qVslZt5cx4RRGYCEsfPx2aU20iQywvkJtxVWUeNAyYQAk/AXhO2OCDjof9uTJC8iXLb06AZZSSUrps/TibdWVpC6Rnj 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)(46966006)(36840700001)(40470700002)(70206006)(16526019)(4326008)(54906003)(336012)(26005)(40460700001)(44832011)(426003)(86362001)(82310400004)(6666004)(186003)(110136005)(316002)(2616005)(70586007)(1076003)(5660300002)(36860700001)(356005)(508600001)(81166007)(83380400001)(7696005)(2906002)(36756003)(8676002)(8936002)(47076005)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:12:54.3937 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81212426-764e-429f-d226-08d9dacfacf1 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: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2862 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 To: Guenter Roeck To: linux-watchdog@vger.kernel.org To: Jean Delvare To: linux-i2c@vger.kernel.org To: Wolfram Sang To: Andy Shevchenko To: Rafael J. Wysocki Cc: linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck Cc: Robert Richter Cc: Thomas Lendacky --- drivers/i2c/busses/i2c-piix4.c | 76 +++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 58b613b78c97..ffb1367dd852 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,26 +172,60 @@ 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_setup(struct device *dev) +static int piix4_sb800_region_setup(struct device *dev, + struct sb800_mmio_cfg *mmio_cfg) { - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, - SB800_PIIX4_SMB_MAP_SIZE, - "sb800_piix4_smb")) { - dev_err(dev, - "SMB base address index region 0x%x already in use.\n", - SB800_PIIX4_SMB_IDX); - return -EBUSY; + if (mmio_cfg->use_mmio) { + struct resource *res; + void __iomem *addr; + + res = request_mem_region(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; + } else { + 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) +static void piix4_sb800_region_release(struct device *dev, + struct sb800_mmio_cfg *mmio_cfg) { - release_region(SB800_PIIX4_SMB_IDX, - SB800_PIIX4_SMB_MAP_SIZE); + if (mmio_cfg->use_mmio) { + iounmap(mmio_cfg->addr); + release_resource(mmio_cfg->res); + } else { + release_region(SB800_PIIX4_SMB_IDX, + SB800_PIIX4_SMB_MAP_SIZE); + } } static int piix4_setup(struct pci_dev *PIIX4_dev, @@ -290,11 +333,14 @@ 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_setup(&PIIX4_dev->dev); + mmio_cfg.use_mmio = 0; + + retval = piix4_sb800_region_setup(&PIIX4_dev->dev, &mmio_cfg); if (retval) return retval; @@ -303,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; @@ -732,7 +778,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, u8 prev_port; int retval; - retval = piix4_sb800_region_setup(&adap->dev); + retval = piix4_sb800_region_setup(&adap->dev, &adapdata->mmio_cfg); if (retval) return retval; @@ -803,7 +849,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 Tue Jan 18 22:11:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533058 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 9CAC5C433EF for ; Tue, 18 Jan 2022 22:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344299AbiARWNX (ORCPT ); Tue, 18 Jan 2022 17:13:23 -0500 Received: from mail-co1nam11on2073.outbound.protection.outlook.com ([40.107.220.73]:42401 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1349909AbiARWNT (ORCPT ); Tue, 18 Jan 2022 17:13:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b1vzeeKRB+bEqm66Lr8FvAVnQQgiL0PRNh34qrrX/1oRaCxs1MopcNie788K29nnSSIB7GMlM/4ZfOUUKyHIsgpy9B3ZDrL73ETaTPqK6fHoK1m5iuqSxfg2I12AZnTbF01HaIfVpEsV+baJLSeggWyEM8tO06vMu+Ha/TmJ7wnjQHcUalByX9GEXXCAZBAGQY2i7yC83IQlSCvQZ+bMj8qVxjBdh1DfWfJeHMwYQkPi7BwHzAuMG2dnA41hfrMV58tJ67SK8v/1xciT7hZH4av6utM46OlyksXqiy4ZvnCezu39vz5y0GWedtSrVLS5ilQK8ZLAPw5Zevfic7mvSw== 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=KlD9/B59mwzOsdsKJ70bFcth4ckKO81uMo11he+Eqr4=; b=PWwqIiRDf66GWz2RAwcGXk6cjk1SGMhTRHGG9QlCctswjsZz8e5yt7fhnDREmy0k5WxKDgv0af9BjoubN/ysgdEIesLeWSHgRu4MQxhz5v0NXYpggGw3Yp62/wgD923j9McPwgDJE717pY0SF4H9SJHHjvTrEWtx2zpIyEd7i+pfKQqbvWbDid8Y6u0e1f5KQFq9USfKRZIzK1tUKDTVm+l+LePPatWfmnexdwHr0i6o4TvxORZbn4h7kTTdN00K7J42Su4D3skH4X9PkyZkRAXl3NmlOECk8ZQMnsncemAosuxlRZzWnr33JqRX0xiw78Bc6XSv0NzFPKzPE/Enww== 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=KlD9/B59mwzOsdsKJ70bFcth4ckKO81uMo11he+Eqr4=; b=XaCa5eY6Ea7b1plouKcVic+OE0rd+BVruumWLbvQUcZQl9sx0Gs0V1uTRP4KZi4jNx2tBdRjClroEblcDxSoH3+KTet4olnuEuM9NlpKousBA1LIe2ffGqkIL81DbicT9kYDBTWLrr8WM0txapiy4wLxaBHtixcIiVRKFxxh4yY= Received: from BN9PR03CA0052.namprd03.prod.outlook.com (2603:10b6:408:fb::27) by MW3PR12MB4571.namprd12.prod.outlook.com (2603:10b6:303:5c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Tue, 18 Jan 2022 22:13:17 +0000 Received: from BN8NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::33) by BN9PR03CA0052.outlook.office365.com (2603:10b6:408:fb::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 18 Jan 2022 22:13: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 BN8NAM11FT037.mail.protection.outlook.com (10.13.177.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Tue, 18 Jan 2022 22:13: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; Tue, 18 Jan 2022 16:13:15 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 7/8] i2c: piix4: Add EFCH MMIO support for SMBus port select Date: Tue, 18 Jan 2022 16:11:51 -0600 Message-ID: <20220118221152.300444-8-terry.bowman@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118221152.300444-1-terry.bowman@amd.com> References: <20220118221152.300444-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: 3036f66b-bc20-4bfe-cf4f-08d9dacfba38 X-MS-TrafficTypeDiagnostic: MW3PR12MB4571: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: tXhd37nWy1jboA62dWTWkZR2e7cXqAiVHS/yp5h3wvYgMP9ZxBLf+Mczb9mYoobYPb9CMUjzafwZiJ3KCrBfoo+P5LTud9BR964VexIYNvzX7cyZVLXzp+F4wZ0WJPMbhFXe/Zy4OV9AF6n0MKrBFa+4J0Rd/JzxKOYCTayLzDgRiqYpaS2456lHuqyrsFoLxCN9+EkxAdVqxEcaQiblvtBX6u5ICVO24Vfybh+P8JTLq98OOwOEn0NPLTgdz4KRtJ4XAHNuJ5ZJyCBqYU5Hqgs0w9f+xSwGJv92YzwezOKbUBdKqSJB6GioAXghBIPLjQoEcMemSJYdKt7b2kl60PQL7GhU3GsjeJvWOdsCMp12ncrWDiUhffkfjTcfPvUYRUb/TmvYysiLsBunBfgkdua94C/TZIZ0477uLYFcfo1grUWwOQ7n6Ktyx61NWwcOB5lI1avJAaw24Q+jifGzd6mkJRWUo08XEWvji04ryKIW0VdTTf0IysieZLWAx89fWhj4IGn0nl3x0M4V6SoccdY0W/Hr/w77TvbGyiEsHx6dJyP2WcfOHpQbrTYryW8Eosvc8t7OziBfx/PjTbAu/e636WP/yxetWwkOSQcJOna4EbKN9Gu6pHGRFr8BDrYonX2GjqOdvTUApsPjaiWJBt6PJCboH75XKjnsbBwKLQZx58ZzLUP0X+PFsoWvEUVXj/a/gTPE9Qa3xx6ck6aRWlIW7BYKT2EhpJnzcyOi9ValiBsVja57SALSkYh4TGOlIUz0TkwJi4chvF7Cntf1EJ0e6ShiIidgZNP1hFVx2e2+04DRfzimGpehx52opmnZ 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)(46966006)(40470700002)(36840700001)(316002)(110136005)(2616005)(1076003)(426003)(5660300002)(7696005)(86362001)(336012)(8936002)(54906003)(8676002)(70206006)(82310400004)(40460700001)(4326008)(70586007)(356005)(2906002)(47076005)(36756003)(16526019)(508600001)(81166007)(83380400001)(44832011)(186003)(26005)(36860700001)(6666004)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:13:16.6537 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3036f66b-bc20-4bfe-cf4f-08d9dacfba38 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: BN8NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4571 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 To: Guenter Roeck To: linux-watchdog@vger.kernel.org To: Jean Delvare To: linux-i2c@vger.kernel.org To: Wolfram Sang To: Andy Shevchenko To: Rafael J. Wysocki Cc: linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck Cc: Robert Richter Cc: Thomas Lendacky --- drivers/i2c/busses/i2c-piix4.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 2937f3254c31..b59d2c74abf6 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -755,19 +755,28 @@ 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; - outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX); - smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); + if (mmio_cfg->use_mmio) { + smba_en_lo = ioread8(mmio_cfg->addr + piix4_port_sel_sb800); + + if ((smba_en_lo & piix4_port_mask_sb800) != port) + iowrite8((smba_en_lo & ~piix4_port_mask_sb800) | port, + mmio_cfg->addr + piix4_port_sel_sb800); + } else { + outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX); + smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); - if ((smba_en_lo & piix4_port_mask_sb800) != port) - outb_p((smba_en_lo & ~piix4_port_mask_sb800) | port, - SB800_PIIX4_SMB_IDX + 1); + if ((smba_en_lo & piix4_port_mask_sb800) != port) + outb_p((smba_en_lo & ~piix4_port_mask_sb800) | port, + 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). @@ -844,12 +853,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);