From patchwork Tue Jan 18 22:11:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533174 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 004B1C433EF for ; Tue, 18 Jan 2022 22:12:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349740AbiARWMT (ORCPT ); Tue, 18 Jan 2022 17:12:19 -0500 Received: from mail-sn1anam02on2052.outbound.protection.outlook.com ([40.107.96.52]:63630 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236714AbiARWMS (ORCPT ); Tue, 18 Jan 2022 17:12:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MO11j4jgg2xU0K2WHI6cYWo3o1LxH/3X0aoRPF1U46R6nb6dZxAozy1OCwTm/dd1pFm7JztyuEFxkLVcpoxLJZvN4RSc2raMJMbwnyYP0fzqDbsWOAN4zF3CKGHIUxnvn7uyZnbQgMCKfITkibrRjBSgfhX1Kv3jtsVD6jgrCz4bu7GCNiuS1LQEgtj2izub2D7MvMJZ9LKJcrglOLHc6rB84SuVLMh/lyhuNB2zMjZ2KBFLFNduefKKu/jaSLx9zuem821CLv0IELHld252wxDMjQYI9ryWWh2mYv9wnkP2srxbikyJDhLBYPhJaZ670CizW971qKe2f8r0OuOUVw== 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=4Wtfc54efYNA9nEnF2dYPhy1KrzguVJ5X3X2r1WYN2I=; b=k9KA1AmE2Qpmcqr7CzvJvSZQA2KAjqwHs8SRIBoGGzEalzXNdyazVVaXaeEhp+PvUX/ETu24gGJEnX82uN0U5F7HGmw/5/AJltpb3AFlSzuIgQs+34EFjP++dmWGoyc83RVRp1lhvL/Al/gCVccVEt2iOFUA828SMZ/uNzGJPb/QgVCU+1P32WfEp+ScCN+j2nG30xRiGuaVj1/2K7w4Mv9S5IgkugW+ckfRdIQtWrze2R8udJZW/TFNfXkSgiZUdaIGWL4pOcExD/8+if8BvL99i6Q5UmWBHEhs/OG40jxts5d5jJOnYtYySdpRweVyPAK9zC0rDj5C4aDGuHUy3w== 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=4Wtfc54efYNA9nEnF2dYPhy1KrzguVJ5X3X2r1WYN2I=; b=JknXz+5FbLr/viO4AhjmOgfMT9pHVcHHvAOX62XH7/HOq7gEeC+wr/oD9BRxTS+dAZgw+RN0YUm9iMst3ndSSumsX+Mb3We0Y/I1gt1l3WedwVvC5IoNj2O0g2/0AmGniRglLgxWWfIKFDpHQaBZgS5pbL8GN+94WrObyA70Gq4= Received: from BN9PR03CA0037.namprd03.prod.outlook.com (2603:10b6:408:fb::12) by CH2PR12MB3800.namprd12.prod.outlook.com (2603:10b6:610:2d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Tue, 18 Jan 2022 22:12:15 +0000 Received: from BN8NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::bb) by BN9PR03CA0037.outlook.office365.com (2603:10b6:408:fb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9 via Frontend Transport; Tue, 18 Jan 2022 22:12:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by 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:12:14 +0000 Received: from ethanolx7ea3host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 16:12:08 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 1/8] i2c: piix4: Replace hardcoded memory map size with a #define Date: Tue, 18 Jan 2022 16:11:45 -0600 Message-ID: <20220118221152.300444-2-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: b6f9a502-167c-4c77-2769-08d9dacf956e X-MS-TrafficTypeDiagnostic: CH2PR12MB3800: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: iCsYBPkek8Lcc36VIc3+PDk7+8hNYRFBIVSVyUC3lBFBC93XQQDM+NGwZDTIh3Z3JsZc6HtkL38+o2jenIF68sECbhDEgwrNxOtGvyU/S0f2PsN2Q6nHbJIWMFncAs+a/o4jM/uS1WTy29j4nQXSX62jsjEc3mNLUrRS5frzCC8jNjD6Pdfrt+KPFcJYJCa6s7UTHUiOMifhWdBXTooQ5z3GLXj5Irn+62G7cj4u6OxSgUrv2v4VeN8zXPqRE4GmuQrWy/VizqKHqLHM7kE4P2SvaBUacj1lw+KcY3+zCOS0ipDXeMXjp6mXhzgq8qTTamg1xWv3r8ZuwYbHIygG7q7bovr1BuzWEWdhQ6F7RkhN6fZyYF40I3nE178wD24I0jUr1RCdI4i/796pgvtCQlyUw145cawu6lyv3YBvAiEFxAwBk5N6SdUlrwKGGFqPPeJiCBWuMGvHDVAQOm/ysk9tpr3u6eG8maOo6r7T2Yjzkjz73aQTffESgHJJmzlTODd2TqQWh4WkyM6lYONbgv7W+QZVJEtx6540DV2xBuJBjHb0n2n5YTIwhKJOuZliNSRee88fq78m58lbLe/5/0juLX93E0n6yCj1uwzeUr95zflPZhe3vwQPF8wgtQFJf3u+wPp3w5YY1lL3OWQlsQXDj8NTA5g+C14l6Dc72b9IRZNEPZM+j4HnIFm9QUVjTEz9jhXGYeZuLaJz9iU6ks9xwERwE8D5FKU5XgaIn2cX75jFpC8sw9CkE1A59eaNq2J69f1+mA6oIb5Rs7QoFO6a6ZpnDNjYiB/EA5dET0flbmufOEOTy5x+DwvsmUY+ X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(40470700002)(36840700001)(46966006)(86362001)(356005)(7696005)(36756003)(4326008)(26005)(70206006)(70586007)(8936002)(426003)(336012)(2906002)(508600001)(8676002)(5660300002)(316002)(6666004)(186003)(16526019)(1076003)(44832011)(36860700001)(110136005)(54906003)(81166007)(47076005)(83380400001)(40460700001)(2616005)(82310400004)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:12:14.9433 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6f9a502-167c-4c77-2769-08d9dacf956e 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: CH2PR12MB3800 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Replace number constant with #define to improve readability and maintainability. 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 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 8c1b31ed0c42..b88d990b013f 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,9 @@ 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 +305,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 +374,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 +388,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 +686,9 @@ 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 +764,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 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: 533459 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 35055C4332F for ; Tue, 18 Jan 2022 22:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349813AbiARWMc (ORCPT ); Tue, 18 Jan 2022 17:12:32 -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-watchdog@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:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533172 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 A8A65C433FE for ; Tue, 18 Jan 2022 22:12:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349843AbiARWMs (ORCPT ); Tue, 18 Jan 2022 17:12:48 -0500 Received: from mail-bn8nam12on2076.outbound.protection.outlook.com ([40.107.237.76]:28033 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1349850AbiARWMl (ORCPT ); Tue, 18 Jan 2022 17:12:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ck5/W7EIShBR9uXOLklDfSaoZO9DmEY+VBiZIt8Al+xNYZAufUNvEqZ8bNsJKRBU6ARG1UxeKErt6njNvqJ2HEwt4iuJSc5788HzasQRI39o66WHG6SouwqJqV/VxdsjXSugObGLaDemGC6fgUdiPlCOTYtqMUZzrq0QaxGthf3cbvazZDWpMyHu7qorHMpUSjlxrtbvw8mgYfGKOcML8BKff2DMPlZYcHLcnQQnZY3oGyE20nqI4aEpq6PwFtI6PJQmlkeG9CUMegj69WYbzstk/rP3CmCluOotQD+u/wyDIOcMRohriN5is+q782MmWuEv4qC2VrorrovKRnnIhQ== 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=45gnCz1tFKw4oAkzO76LGhBYO0bQVrx/SrnnsFYh2UM=; b=c1yD4Uych+VIK0IW7B1gVofPLSsy2/GS6bBtboH3wkC2THeHwE/axID6ltaQwOQKRK4ns0GENbUXjWSbg7wZQdyEFdOXkgYBS0uUjn/uG8NXtUswBKkgKImRf6OUWVBWeMTHeUhczVpryb2VGSG67gcW1NjzdzKQWjiXOskaASyMbE1yYxVuSJ1e9d+FJLtupUFmKtwoNlxyD+Lq7caJZKL6dGO7ZCc/038KrvMpPqqFUHNbIS9c23cWGkuYV+5AOtYF6NNOl0KKDYMjuEDkcMbDyHvAnE+0zXEIgvcgXvKL2c6nP5cjFe0ym30wz4ZXysj7T2EDMe3a8j0mHfPjkQ== 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=45gnCz1tFKw4oAkzO76LGhBYO0bQVrx/SrnnsFYh2UM=; b=1hZv0eN4uurkTCNsix+DsiVoJDYFFi1yQoUx10tKGxRdDEuATggmVaLY2LIBlIPsURpa5cSwA+3+kLqW3QpzAKFXqNLT92HJt/BTQINjGdk/Pb6FVJsoCL1KU0wz453h5qM5OOaIG1BN3Q3CKzcG4FtrSNbnvervwlgqyDkAcsM= Received: from DS7PR03CA0201.namprd03.prod.outlook.com (2603:10b6:5:3b6::26) by MWHPR12MB1440.namprd12.prod.outlook.com (2603:10b6:300:13::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Tue, 18 Jan 2022 22:12:34 +0000 Received: from DM6NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b6:cafe::f7) by DS7PR03CA0201.outlook.office365.com (2603:10b6:5:3b6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9 via Frontend Transport; Tue, 18 Jan 2022 22:12:34 +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 DM6NAM11FT031.mail.protection.outlook.com (10.13.172.203) 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:34 +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:30 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 3/8] i2c: piix4: Move SMBus controller base address detect into function Date: Tue, 18 Jan 2022 16:11:47 -0600 Message-ID: <20220118221152.300444-4-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: 0358e801-36aa-484c-3072-08d9dacfa0ee X-MS-TrafficTypeDiagnostic: MWHPR12MB1440: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: GBFozH1I2vNjV3QnraoEiZj0MuoeUoVnOpTFhBKAArWaGIxn8PxiZxOx9MWeh8XR2lSEPARGtn6ULEbW0pq1Nj0/EOyRogAFeic7X7G7ZXGQvGEn520K+4nM+t3mJIxLff9f9uo8pNfwosJTlBwOIzQEWylD3sU5lbrbh94yEwchaO+c8hTU0h28UlHUrqsvpupSmcB5RvCKFUOilnzU2OyJbOMsTgNexWWJXeeJQebo1dsu1YA9je+XsAXl4lf8cpsp/ccc9DRdNPuIvnK2vO7OZx0rV4GuHgPpWOiALaYKdgR+vX8C2JvKqBrHG+RKJuGcXtyIlfbEimj7o0DhF+rDrfxxqmJQORXFC0TTNgVUeLIoHiR+0WdknBmoC97hHB0NOznxp1YMp0YipNTqZXXXAGrp+2MsdvCSHuBNkhIar3LNuSCtXmU+Xgt+vuU7FpOc0QEjM1koO2TQo4UP92bfh0dCqT0VP7TrGH1xpav2+AibP0nb125GC4egFD3KZV6qZgmrqr+AmWIHZEERfFt3rCfQGop5HKgaUcUwyrEAPI9UHE6vx/hn3PKYebwwWgCCbme23tWroV2VlC6gcjHTdiHL9EMEFuY9S9MzZ4iNB5+SLSygP0mmjyH/STy+Oddoyx7eVRSfVrtQ2wJyyYYSYxu6Rbr3WNl4ip9kI+L3+oPEKh2NV3362WRE5E01icMmMhjCl2jM7LbzgG8wwLLDR9nJNx8tMXmEbyyGDsbNUxL0Dx6BCAFCH85JTW/gpLYsUfMzXYoeJdFqp0a9TSPvkRn2UuHg0Ag/ZA3PGQZ26s2z46kPdPypwusmsxF8 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)(26005)(2616005)(110136005)(82310400004)(36860700001)(8676002)(47076005)(36756003)(54906003)(508600001)(6666004)(86362001)(5660300002)(40460700001)(44832011)(336012)(1076003)(83380400001)(356005)(8936002)(70206006)(7696005)(16526019)(186003)(70586007)(4326008)(316002)(81166007)(2906002)(426003)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:12:34.1748 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0358e801-36aa-484c-3072-08d9dacfa0ee 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: DM6NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1440 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Move SMBus controller base address detection into function. Refactor 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 | 68 +++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 14324e03fe24..35fcb61f4750 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -284,11 +284,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_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); + + 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 retval; +} + 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; @@ -312,33 +352,11 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, else smb_en = (aux) ? 0x28 : 0x2c; - retval = piix4_sb800_region_setup(&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 Tue Jan 18 22:11:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533458 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 072CFC43219 for ; Tue, 18 Jan 2022 22:12:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349849AbiARWMt (ORCPT ); Tue, 18 Jan 2022 17:12:49 -0500 Received: from mail-dm6nam11on2044.outbound.protection.outlook.com ([40.107.223.44]:58913 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1349755AbiARWMp (ORCPT ); Tue, 18 Jan 2022 17:12:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0YHkjAgJlnhzeCu6ApRlnthopjrpJ0+Ar49SAgXhVO80XjR2eMiapo5yKaA0wyFhsTHhtiZ0apkvpg0DXK2RJp5s4H8oEZebwiI3c2kkUGs7ySwFDi9s/MSrAw8qjSezCHSGFvgU98SyHQPDet1qhF/lftFPR3BOzDlzfpXNndtYdsN7svJ+rmxu890KIed3l/Gohlw5xTV2Y6AkpAJ3aKRQ3fNbJxLMyROxrLS5xYSkkI7f+qVz6/hZZkIbNAVwK0PSxt4KzNfgLfVhM448un1rnE7oVn4qGl7nzq2N3HcKRsWv9SntL17O6ROs0Z/xTmvAz+Zd1LFiJIsZ82uOA== 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=+DHprV6rk/9wU5uihe/1Vy4jQBWf5H38YBmCfHk8qCM=; b=odc542AjN8loHvX7GK6UUIhVHWHfi8b9BYJLJUXolTIF5FW32AF8FXoEK+UVE3VpM69Aao2uSJnIl0AI70q594TN4xJHwHUeBh92XUpvJcFlbJRNYXomPLNwN5RupKzUMYhwgcWXQIewFeRHCQDODvLWY0Fy6WWhJOL3PuOEHxZ1CDuEnrgdoCJ6hzDyt97ra0bI9yvIQ+NITXYczFSyZ7llw2ANseQTIxnit20x8Olk3C0DUyUKsf7CBL6dydelZmk2CzYU4wmrZgoj99mXok8rtzFNATR4zpGSsmsn4IybHCaNVNVab9AB+1AvFBzvQMfOfnmzgzNa143YSDQTuQ== 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=+DHprV6rk/9wU5uihe/1Vy4jQBWf5H38YBmCfHk8qCM=; b=jNsrE0RdwuDDRUEdYIvngn7NXNKxJf3yBXty7XtCK3GdYyAePVB/6rPVux9sg1lzUhVkI3rFHfr+pyeyKr1cRlpRd6JBEsMz7W0VRNcL4PJAQj+ukMjQCciySPNt0Z9CpoahE2cC4rgkn4nvD4C4hMCKS9C4oHYvj1Uq1tsFxic= Received: from BN9PR03CA0855.namprd03.prod.outlook.com (2603:10b6:408:13d::20) by BN9PR12MB5211.namprd12.prod.outlook.com (2603:10b6:408:11c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Tue, 18 Jan 2022 22:12:43 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::28) by BN9PR03CA0855.outlook.office365.com (2603:10b6:408:13d::20) 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:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) 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:43 +0000 Received: from ethanolx7ea3host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 16:12:41 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 4/8] i2c: piix4: Move SMBus port selection into function Date: Tue, 18 Jan 2022 16:11:48 -0600 Message-ID: <20220118221152.300444-5-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: 340adffd-3a9d-45e5-bf44-08d9dacfa660 X-MS-TrafficTypeDiagnostic: BN9PR12MB5211: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: 9vCxI9o3ylYstioHNxUpGiWOWsq9rNrTW/UruMQVaYoctpxn+7nzl852NBWJLinOBhSUdy6Da5kurdeyBdFjVshZTeeummlRnjTvcwRU/bx7lwgQAbO7/tOf51jh267d0po8GSb2XZaKIgjeWcWMCUr1Q0nJJXGzPnN8z8S2VAjA5xRl6yUF4tqxno4BhJYB13/IwHUCB2eEcizw903TYn21vPz2q03VHcA32Mksq2ZO/Rg3UazmOB5BXvVwXeFBx+NKVaianBFx7VmmQcmuXD//U2AiKd0CijpAzGk6dKo2j3JggYtUuuQUMFgE/Hfdd097WdHGaJuTOtxCm0oJkufN0LkfGqfa74kH+c8h7PVERqEGMT+g7O7aKDehhCAwZrLxF+iYwoW7SvXizLwId+zIxQrAiKfQd6N0kOClXDN20OBhWM2FlRJIk2KKoQ7O5mQwFCZUVglXw8qP/s8Rpc11FUXhrrA0ElzDJKCYEEV2hHsJjxG40LzHmYobfLoBxK5STySUI8gbvCJ5fiursXEIWVLht31R50Iu6NKd7eKG8qL4lVNbLilJFsIKDOu4Kb7FfhXnuVaU1KHtcjrCNyY1tjQDIYP9yZyiSvqN2q4ByAd/7asBXlRRbWwaF52i5BKh+v90btD6yzhic7l41/dOWgpJQvOA0zE4bLG7N5b7QMwSaLCwyu5rQTRy16qSJvKjyV2K6mB3UiuWkhk7B6qsJb5NZIW2B8uH7OkPC9mlEBZ5UeHkFODen/fAkqqwouDO4TY0OjrTTGjVc5hG8VHTmegk4aozp0T6HaExzW8b+3WIK2p6rxSIsDJukEzS 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)(26005)(356005)(4326008)(186003)(110136005)(16526019)(81166007)(83380400001)(2906002)(8676002)(54906003)(8936002)(316002)(86362001)(336012)(70206006)(36860700001)(7696005)(40460700001)(5660300002)(426003)(47076005)(36756003)(2616005)(508600001)(1076003)(70586007)(82310400004)(44832011)(36900700001)(2101003); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:12:43.3610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 340adffd-3a9d-45e5-bf44-08d9dacfa660 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: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5211 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Move port selection code into a separate function. Refactor 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 | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 35fcb61f4750..58b613b78c97 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -700,6 +700,19 @@ static void piix4_imc_wakeup(void) release_region(KERNCZ_IMC_IDX, 2); } +static int piix4_sb800_port_sel(u8 port) +{ + u8 smba_en_lo; + + 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); + + 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). @@ -716,8 +729,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_setup(&adap->dev); @@ -777,18 +789,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 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: 533457 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 53E40C433EF for ; Tue, 18 Jan 2022 22:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349844AbiARWM7 (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-watchdog@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:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533171 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 17C11C433FE for ; Tue, 18 Jan 2022 22:13:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349771AbiARWNP (ORCPT ); Tue, 18 Jan 2022 17:13:15 -0500 Received: from mail-bn7nam10on2075.outbound.protection.outlook.com ([40.107.92.75]:18368 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234388AbiARWNJ (ORCPT ); Tue, 18 Jan 2022 17:13:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ASSODMmQ5QnzleWTNinalTx/lZkKn8mMjK5BRDj/ghm2tvkVCWoKMbPPHzOOeYSXH6TOelP/W7hwxqtnf3Os1zp+yO17qeuv5hsC5njZDmagwlApXnJwJVA7dfh25/n+J/phhpdc8ltHsVUZySVP3FUxqtgvF9ppEJLcirVTLx1VLBlYm6p+4B08EY3eQnRTbC/xH53rkuFTYP4b98tj21ag1oO5WvFiSPJZWTUjbBJUqzuZEVOXxdlEEt9+qKJMlj0bNVcJkaPutFvNeg9uJ7SmjEqzvgcN4qqdCCzewevhtgOv/RC/+8CfFldjFNGwwApDPsUVL0MlMTctuVWVQQ== 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=HPwRuTUMdOIYd6TaU50MwAZLZb8EHndtlyNKgz9xwY4=; b=RJeaHUFZm/ZMVb535zolSKm6OknQdBhXhO9GrAL/KGSbYRhApaK/dKSXwAi5rJjImfV2w0z85xqOB3FnyEjH35lj/TyGnxnKHjdBml1YzFTtjeErVsB8GQFcBFvr+mqYVSE0/bsJ2Miz3GMCvViYdSiZzYEtaQ8Rj14S4FwBSkbGLaoRNlAry7HonW0ULHky11xIWScaYpmkcbi3yHLUXs0c9rH411PgMDyjJL56VPNvPdyOQyVR8BA/lbb0i0CTMtTma3H1RUq2GNZgmBQivbWCk6ooQTBCxdFJRj1N7Sqhr2pSOhXYlwvTAQxZuqo/GoNZXRf1k6A3uH+/Wl9i3Q== 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=HPwRuTUMdOIYd6TaU50MwAZLZb8EHndtlyNKgz9xwY4=; b=DMe6ForudIV/f7oAB4+lQgwC4hridMi9t8tdUowPzjsfWkq80Dm8JAvOL4hV02kB/V6+FS7YvIr1Pd+2yH9nCwcrDzrlAWQREvncLXyiWP0f2tOj8GhJq37RYUBRibtecXg5m8EseX9aEqfVOKkFFF6MV5rzm1ZbRc2M/JmQoTE= Received: from BN6PR11CA0017.namprd11.prod.outlook.com (2603:10b6:405:2::27) by BN8PR12MB3250.namprd12.prod.outlook.com (2603:10b6:408:99::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Tue, 18 Jan 2022 22:13:05 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:405:2:cafe::be) by BN6PR11CA0017.outlook.office365.com (2603:10b6:405:2::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:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT013.mail.protection.outlook.com (10.13.176.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:05 +0000 Received: from ethanolx7ea3host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Tue, 18 Jan 2022 16:13:04 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 6/8] i2c: piix4: Add EFCH MMIO support to SMBus base address detect Date: Tue, 18 Jan 2022 16:11:50 -0600 Message-ID: <20220118221152.300444-7-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: 6f7e6d0d-90d2-4d05-926c-08d9dacfb3a1 X-MS-TrafficTypeDiagnostic: BN8PR12MB3250:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dslWlQXeh57zEWj5xc/JBpXjTJF/W0vov4x6Rant5o3CxmP5+0GLRfrbN59I0TwhLVPt04UBrzs8Euz95b4vWuGXEEcb2XyAblRIM6oHkJtchbS6RZUaan8EMeq4tXU7VtOui5zOG9LH2H4BiMgHdPqU18PJpWl+YcVuqbrdYQBQtZUqwHVIQF03yz0oX/DPokpNi4hBVGQxVOJa4T7K0f/NGWv5cMJBKLoiQJ7dVS0q8NXC9VDT8tS8ImzmNbOqHuVlxvZpe9NZx0+a42dLR2FCUJT85LSHuPt8hKEzN5Q2RLktQ0SiB7o6e1YcPsnhPBYgDWsSqCKnPQN1KSwg8bL1IywMj3coTXkGiTKrSPar0WXvd7RBSX1Ubd/Xtr6cshilw9IrjBB0z2IGmzTpFuTg57yuQn6CvjFa0vmzM7XTtPphq8ft708/21GQDkeXFfvOmB4OyFGvhJL/wg1rfi4Ts/Q3IyPMv48i51XAboLb+1ReZdAfDosfJTDv9vIGrvt6qBW6d0P0ldOGAXTvtREXT9Bg3zcL9q+jE4TVslUlqXfxvJvRQ64g5yzBWPIEl3kCzTMsj0u6UUDMvKIgZdQBb7nEGOUSqlduDx6/ef/XZd3cEtRlTI4ycRuKjMTeXR4rb74zQQ6oKHjmP+Ab/SgNPxHiNaLUEpC5mOCC0z8ZMBfU+l1Xfz+uEZ3KJ+c7L3TYXF7XLhR5bovxfngrxNawhF8/vlOJd9B7ILv2ii9ane/YHqosGQTvFzG8rJtdDCe983NVGjlBPUhlQgL04Kn9l2mHDvKoJjnYceNbUd5s7Farw7roeQNHdkbxg0+r X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(40470700002)(46966006)(36840700001)(83380400001)(70206006)(81166007)(426003)(70586007)(356005)(2906002)(40460700001)(1076003)(86362001)(7696005)(82310400004)(54906003)(316002)(110136005)(36756003)(5660300002)(2616005)(47076005)(508600001)(186003)(44832011)(4326008)(8936002)(6666004)(26005)(336012)(16526019)(36860700001)(8676002)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:13:05.5963 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f7e6d0d-90d2-4d05-926c-08d9dacfb3a1 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: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3250 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The EFCH SMBus controller's base address is determined using details in FCH::PM::DECODEEN[smbusasfiobase] and FCH::PM::DECODEEN[smbusasfioen]. This code also writes to FCH::PM::ISACONTROL[mmioen] to enable MMIO decoding. 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 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 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index ffb1367dd852..2937f3254c31 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -98,6 +98,7 @@ #define SB800_PIIX4_PORT_IDX_MASK_KERNCZ 0x18 #define SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ 3 +#define SB800_PIIX4_FCH_PM_DECODEEN_MMIO BIT(1) #define SB800_PIIX4_FCH_PM_ADDR 0xFED80300 #define SB800_PIIX4_FCH_PM_SIZE 8 @@ -344,10 +345,18 @@ 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) { + iowrite32(ioread32(mmio_cfg.addr + 4) | SB800_PIIX4_FCH_PM_DECODEEN_MMIO, + mmio_cfg.addr + 4); + + 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 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: 533456 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 566FEC433F5 for ; Tue, 18 Jan 2022 22:13:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343845AbiARWNX (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-watchdog@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); From patchwork Tue Jan 18 22:11:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Bowman X-Patchwork-Id: 533170 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 D2B6BC433F5 for ; Tue, 18 Jan 2022 22:13:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344350AbiARWNe (ORCPT ); Tue, 18 Jan 2022 17:13:34 -0500 Received: from mail-sn1anam02on2081.outbound.protection.outlook.com ([40.107.96.81]:37895 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1343839AbiARWNc (ORCPT ); Tue, 18 Jan 2022 17:13:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M2mXO7qxKZp1/e9YZ10LUAKOxJF6X9h/qebCrXoaZrQSnLGGghqa4F6lsrMXBg8cW9BtcaxvrJGzJ0DX8+9dizV9KmmGPIZ/3Iw9twbERy1KG8OyC4LkbxkNfypkXIW1eIj0zQ9eODQcBVwvxyYrhTYJTEbVJ1jyy3x7TPq/NeSPcDmlIE+65vFmn+vGzcUD9pdjxUMNMIHeAjkgFGWZFJlnGAwDRgxBNe1CaHuRlhFwnl/LP0s933v7qsUtVJ1Ip6+O1zS9SlbQu9ONo4e7jYIVLXRV1QloISCaql8xg3RZog2AmTfxYQVE1lyrFaRpN+ZHCrIJkLoJfqKzIlWImw== 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=aEHpWreIkfKhWip+XqIwMQiNqSz6IwsSk9dHCz3ZAQA=; b=HTgM3U0WGSL/EGjYri7Lvzo2uhN48xB80/XfBfQlTvXTj3VQ65Q5/vRPOeW10y7IZLg+k3xt1WX6IHGyWe1hdJVZbatqIzDYotueECMEKzJ8oQe6Pi4FBvH5CqX5HkBNYXRaatoZMSP2NGXp33yMLHK0Yh+ciNmpRj9JM18BGkl2E57PsAB+GwJ2sVCkFAJN6MBZGMXXk3A8SQp3KSp421klAy+ID72RdD0JcVPFQVaP5JV5aUI5K0wQ1pnFG6el67IUa8Znrm9f79M2YoyUOKZGaWxoYemkRjiiWTKKqGr5Shy3CXmNMriBZa5BxJDA+YHVGMCNKEVzFIQT9Wnwmg== 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=aEHpWreIkfKhWip+XqIwMQiNqSz6IwsSk9dHCz3ZAQA=; b=wueVBJTg4RRxTCQgOAeZgSla+LU6Hwr6tRkO2rNLJFnXw5K2QN5IxBzQV/AIDnIqdOnld1YgKwEIAP2N4Thq6iJHUjEAWNNv0vKBq2R+7EH5q52DeZkBR74yTcOoNyyJmiUyAkkCkq5CARgID+t3NNihXYArX82Mrvf8IPscXok= Received: from BN9PR03CA0499.namprd03.prod.outlook.com (2603:10b6:408:130::24) by BN6PR1201MB2547.namprd12.prod.outlook.com (2603:10b6:404:aa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Tue, 18 Jan 2022 22:13:27 +0000 Received: from BN8NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:408:130:cafe::20) by BN9PR03CA0499.outlook.office365.com (2603:10b6:408:130::24) 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:27 +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 BN8NAM11FT008.mail.protection.outlook.com (10.13.177.95) 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:27 +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:26 -0600 From: Terry Bowman To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v2 8/8] i2c: piix4: Enable EFCH MMIO for Family 17h+ Date: Tue, 18 Jan 2022 16:11:52 -0600 Message-ID: <20220118221152.300444-9-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: b050a68e-c947-4bca-0a57-08d9dacfc0c4 X-MS-TrafficTypeDiagnostic: BN6PR1201MB2547:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d6KY5m6ZFVKn0hq2RiW+3Qp2E6I8on3hGqNsQU0YRGHpLn4FAgPpFKDZEGE683keQgPGbgnsiNlqB6avubt7djGng4r7OtvKjDAvHBNBNrHhwtcWgM1NHjlmOthQT3Fq9I1xqhOTbzmJ/FIVlK8reQ5pfdgpePYgnJfSLBdvehF4qoxciasqd09HOypa+2JKjVtqLgYTTUDqDfghjkZbiZBEHzrrMBLHtjeNNEArqP8dx0Xxic/AMhAz26pCrdyl9Lc1UBSm4sDFJOfasK51Pxv1A9oEZfOxPU9xO/FvYlOlicJv4iLVW3MN2UA7zpcp2cVkU9YHZ622HYushkb2t053JitGH90dchfZ+4OtinAz+Qt0OCL3DubEGbz07SfftVnswYa7W6G0fAAIyF4sBjuHcLmeF4j/AqMNBdc5cYiQEX6mVr4HXJLAiWX1CJ4iCgkb5ICNRFm60PEeYrsOoZN2UXCqC7SQ7PCi9tEPJPpsVQODFom34GFSmfQ2dt9tu7OlGJpwQ6+cwUcTWrN2y4QaiU6lG80OimwlwyK8Isil6tjhOPvEBiyNt6hnBmrRTEVWBTm4Q5YVO5i2vlcRFacg1nyrZTAn8fEg7jAdVzmX82DPNEgSxIt76w0kg2m65yeswM+QsY1i+TJI0jhq3980OgxX3vBOEDncs7rTjHc0TsZKBVzbObBcw60jhPwd8jJrL+3cbLYD5a1cQBNPGsJ9OTWCqWsiyt4kfQRDa4KR9z/Gpfm45EGScHlqto/3iJS35V/qBuHUn95kVyQY2N7T0q5aZYdXM+AjGJCNnOsEjhCoiUQZ34QK1IfcmoiC X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(40470700002)(46966006)(36840700001)(81166007)(70206006)(26005)(356005)(2906002)(2616005)(82310400004)(8936002)(44832011)(316002)(336012)(110136005)(4326008)(40460700001)(6666004)(8676002)(70586007)(47076005)(426003)(5660300002)(1076003)(54906003)(7696005)(86362001)(16526019)(36756003)(36860700001)(508600001)(186003)(83380400001)(2101003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2022 22:13:27.6481 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b050a68e-c947-4bca-0a57-08d9dacfc0c4 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: BN8NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB2547 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Enable EFCH MMIO using check for SMBus PCI revision ID value 0x51 or greater. SMBus PCI revision ID 0x51 is first used by family 17h. This PCI revision ID check will also enable future AMD processors with the same EFCH SMBus controller HW. Signed-off-by: Terry Bowman 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index b59d2c74abf6..f5533a7d8a13 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -102,6 +102,8 @@ #define SB800_PIIX4_FCH_PM_ADDR 0xFED80300 #define SB800_PIIX4_FCH_PM_SIZE 8 +#define AMD_PCI_SMBUS_REVISION_MMIO 0x51 + /* insmod parameters */ /* If force is set to anything different from 0, we forcibly enable the @@ -229,6 +231,13 @@ static void piix4_sb800_region_release(struct device *dev, } } +static bool piix4_sb800_use_mmio(struct pci_dev *PIIX4_dev) +{ + return (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD && + PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && + PIIX4_dev->revision >= AMD_PCI_SMBUS_REVISION_MMIO); +} + static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id) { @@ -339,7 +348,7 @@ static int piix4_setup_sb800_smba(struct pci_dev *PIIX4_dev, u8 smba_en_hi; int retval; - mmio_cfg.use_mmio = 0; + mmio_cfg.use_mmio = piix4_sb800_use_mmio(PIIX4_dev); retval = piix4_sb800_region_setup(&PIIX4_dev->dev, &mmio_cfg); if (retval)