From patchwork Wed Sep 4 10:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 1980676 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=pTtG/W9M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6138-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzKHR6N4gz1ygx for ; Wed, 4 Sep 2024 20:58:59 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1B59E1C20B47 for ; Wed, 4 Sep 2024 10:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 967D71CF7A2; Wed, 4 Sep 2024 10:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pTtG/W9M" X-Original-To: linux-i2c@vger.kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2082.outbound.protection.outlook.com [40.107.243.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 955211D0159 for ; Wed, 4 Sep 2024 10:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447495; cv=fail; b=McueiX/BMRk8yR3Q5oHjzqrR//EC4bDT3KLHR7gSPSzCtASwaNpocR4NqLm+YX4WUYjCUTC4HZk9qJvfKKeeBpxb4fKqqiflHwY1qI2nmOBTY2SkzmlQOEBptWGA+Oyuyfgbvkyt7edBMrPGBUraahn3R8xfcRmClA/fvIGtu/I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447495; c=relaxed/simple; bh=rg1lcDXJ8gCAIAR7Y0W2HgJDHt/b7m8jn0l+ll1fUTU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jVa3o01yfz3zHpB9g6fVFQFAfyzMRxAhRMDitx/5PZmz2TGJ7qxMD5D13WuWoqvfwVbc9SCUM48aVZr3QdGfJeC7wKDWkGyu3/aKl+ad7DkO3C8a1jZFL2MAI53pUBswkfk0SOPWzBfusYmRAXu3zTC0TVLa9sHk7wK9E96SQeI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=pTtG/W9M; arc=fail smtp.client-ip=40.107.243.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=laTAmLS76ZoS0nk00vFYQPKR7zim/jee1IMdJ/TsjzRJCQGkKXkuRRaGM8U4GgMgj7bUpzT2D4BFs3svBdmBLEiaMftMelkS1t0K4yydaMOn7D8YJmCnZOXawOeSK0LZVoVyABeVJ06bfq7h2nkovUWUPMOBBKU3H/0E0e/yTlDhL6Z8igU6+KfpMK+DHEjWYC5u8ezGGdB9ux1tklFo43sWngtP3s93/d9a6DoCm/SJCqJ9IR/G4xT2Oe3ITcyfI2sK12qdqkY8jjEKSVRpv5c36/2PFtouQHc+6iPSYEXJPf8FqhLQiFSI/BAjj6zu9bDUqPHkgrqy/Bv7GPH7yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=BtkGnaivglQN8mgA5itO0X+KlrOt/o9MqIsaJToHItk=; b=c8AIIdXXckH9krJpGpiPwRKksWZ9UEC3kzjMfqrL7Tgn1GuaWzO6w3wlCWln+j5iiG2edhsHqQsXGsHc4x2yApPuLigmupsjYD/8MNy9qfVdsGq2hVdCclQwayX5T4zIOviKp5tHQEw5hbI0DNS3Bh8EACIIV5K7ExP5WFUCpmuD74NfpFgFGZYFn0dS89F3peqkQ0JZB0GnN5oBXwsuNDWVHL6jnroFz5GW0drjdI2J0j2gsVrKmgBAJ9x1cgAgJ7Enuir1YlthLnO0awWL3/jvU7TMYTSpyBBbD4gS2WI2qf2FpRVddTts3bLTmOcuU601hiUxwQXHCqoYcIltpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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 (0) 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=BtkGnaivglQN8mgA5itO0X+KlrOt/o9MqIsaJToHItk=; b=pTtG/W9MAiHQciGEeKFahWbnybyzfBOfjKxhZouYktgNHY7s+7afVay5n2ERJP5zV8vMPzedOYwyPW01ncgDATZv90RUQidXZmPWAX+hfAGLOlLHK0dMFreQQEczXQxDGOcfF0JaWFtALlX3BFBlaKuwnHSrG3Gr8FGhKod5CiE= Received: from BN9PR03CA0222.namprd03.prod.outlook.com (2603:10b6:408:f8::17) by CH3PR12MB8657.namprd12.prod.outlook.com (2603:10b6:610:172::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Wed, 4 Sep 2024 10:58:09 +0000 Received: from BL6PEPF0001AB50.namprd04.prod.outlook.com (2603:10b6:408:f8:cafe::6a) by BN9PR03CA0222.outlook.office365.com (2603:10b6:408:f8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Wed, 4 Sep 2024 10:58:09 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB50.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 4 Sep 2024 10:58:09 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 4 Sep 2024 05:58:07 -0500 From: Shyam Sundar S K To: Jean Delvare , Andi Shyti CC: , , Shyam Sundar S K Subject: [PATCH v2 1/5] i2c: piix4: Allow more than two algo selection for SMBus Date: Wed, 4 Sep 2024 16:27:27 +0530 Message-ID: <20240904105731.2246235-2-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> References: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB50:EE_|CH3PR12MB8657:EE_ X-MS-Office365-Filtering-Correlation-Id: 3efa135a-00be-498e-bf04-08dcccd076ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: 19ItOPWiyrsMilfDPjXPZ4kzx9iz84ID74Vi390oBeorBWzMxBowoWNjnKw29gwTE38G5OmmvI8ZCFtcexNmuPOujPISr/Xu0EBm00plHfgURTkMFDsFayWrlHyX0HQxlAqz7OE/sK77o6HQJ/HuRgJXITW0h7Su6brCTDNUai59J0T2zYSpwTmTXAI31XMT/u4Suu9wrrAG2LLEvHupUjdA8S0xm1DK7ILF3CJhMxzbunnxzweBQWzD2ZyT/4IQBm3DuRpgA56NvMlmFBBVd3LCr8ihCBNpns6/9Ab223CauZLU5Z4Nt9GUTxrcFykNy3ohMFqyMu4Ic50MOjSlc46Y8VHyu/4SClUAYNJP9Gf+c2O0p+BZZh2NaDczLQE00tzZzu6vxKiwvp7OpZ2N43AESWLkksS7bMotBqrIhHpqI18nSfUkETfd3X4L3zK+DJ7epgjhabMiGnHeLZZs4vBmknjIracnTmVl0FmXQLPAfeSI+y1ubRFrpNPXCgQQyBCgDC+26jZthD3qdXR0PqZ5/5wcWVgQGsSEdcNhHXkDJpO4SDTFvqDvS2BwP4CcUzZ2FrMHBd3FZgylaXtG8MywZtIw6Mf0R1Gyf3Q0O/eloJcgFr9GG27D/BMy9Gmqyl1WAP8CvD8NWJA0m0ixmej6XWsU9PIAfl19uSoYvt2Wkht8xam8gyBQoehs/Q72HYjpi1bYkNNENJEecfjFDa6hpA3BIDv+zRs4awVawWn25ksl7zH9DsAMr9MEUkGzAifetVvurG4Ut85PT+95tmnkL4V3GInOLMmkxjY64Ozs2NvhvIpP+OlfDLkreLZ0pFoN+a8eokfrBhfn6o0A7W2CeBr971XxLyUkvqUk3JpUXkdWWj1Bd/h2Y/hAi9Fcux5AWcJjY00kEOfTzHnLZwAYTGDXS5CghDXPEMJhAh5GeWrezwG7mV2Lsfg2Ejz9ewvr3/kpsh5gGOHCD7PE4zWdN7RWvonDz453gi8qcz+FAYyHzJHXITb5SQdmyoNZATPfzxvkXxhKaeDxAuvJ9E7XB8RJdYdj3eQAiE0fEVSMaK2XwCMFD5VSu4VJJz9Fne5M5qaS/mWr9PvUkwmaV35cn4IqvYzN5jrQUXd3NPTuEmpHvQqGS/vKzK3w5x0/+JBNBYp0SwcR90HI402K8UwlBEivEJGGi/hmNS5XEAbJPOGlmLcxbFXa4FoITTVIlSmLW4NN8cUBq8Y6foA2MJbDJ8orxFUTOehDCTRiGFCQ+sSCz092aurooK96QkpTnVf37137tpHL0TfoBFvrNum3qv+XlDsmI6vimHElmd1Z3CAvozTY3oViBJm7OAcS3ez9Py16eIotzRGkmFQAfX4tjkaTmbXIUIHbCGPglVwCxQ8I3AqH15gfAbYM2+ISKMWwWpuo60jT2zsz8VCo7skiuFSa1vJC/HTymTZq2LavxUjaUIKQKBel6hXgclS6 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2024 10:58:09.5217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3efa135a-00be-498e-bf04-08dcccd076ab 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB50.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8657 The current implementation of the piix4 driver has a limitation in that it only supports two algorithms for the I2C adapter: - SB800 Algorithm: This is used for newer AMD chipsets. - Legacy PIIX4 Algorithm: This is used for older systems. The selection between these two algorithms is controlled by a boolean parameter in the piix4_add_adapter() function. This means that the driver can only toggle between these two options, which limits its flexibility. AMD's SMBus (System Management Bus) implementation supports additional functionalities, such as ASF (Alert Standard Format). ASF is a protocol used for system management and monitoring, which can be part of the SoC (System on Chip). To support ASF or any other future algorithms, the driver needs to be more flexible in its algorithm selection. The proposed change involves modifying the piix4_add_adapter() function to accommodate more than just two algorithm selections. Instead of using a boolean parameter to select between two algorithms, the function signature will be updated to allow for multiple algorithm options. Co-developed-by: Sanket Goswami Signed-off-by: Sanket Goswami Signed-off-by: Shyam Sundar S K --- drivers/i2c/busses/i2c-piix4.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 4e32d57ae0bf..d56083e58a2d 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -165,6 +165,11 @@ struct sb800_mmio_cfg { bool use_mmio; }; +enum piix4_algo { + PIIX4_SB800, + PIIX4_SMBUS, +}; + struct i2c_piix4_adapdata { unsigned short smba; @@ -173,6 +178,7 @@ struct i2c_piix4_adapdata { bool notify_imc; u8 port; /* Port number, shifted */ struct sb800_mmio_cfg mmio_cfg; + u8 algo_select; }; static int piix4_sb800_region_request(struct device *dev, @@ -929,7 +935,7 @@ static struct i2c_adapter *piix4_aux_adapter; static int piix4_adapter_count; static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, - bool sb800_main, u8 port, bool notify_imc, + enum piix4_algo algo, u8 port, bool notify_imc, u8 hw_port_nr, const char *name, struct i2c_adapter **padap) { @@ -945,8 +951,18 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, adap->owner = THIS_MODULE; adap->class = I2C_CLASS_HWMON; - adap->algo = sb800_main ? &piix4_smbus_algorithm_sb800 - : &smbus_algorithm; + + switch (algo) { + case PIIX4_SMBUS: + adap->algo = &smbus_algorithm; + break; + case PIIX4_SB800: + adap->algo = &piix4_smbus_algorithm_sb800; + break; + default: + dev_err(&dev->dev, "Unsupported SMBus algorithm\n"); + return -EINVAL; + } adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL); if (adapdata == NULL) { @@ -957,7 +973,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, adapdata->mmio_cfg.use_mmio = piix4_sb800_use_mmio(dev); adapdata->smba = smba; - adapdata->sb800_main = sb800_main; + adapdata->algo_select = algo; adapdata->port = port << piix4_port_shift_sb800; adapdata->notify_imc = notify_imc; @@ -1013,7 +1029,7 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba, for (port = 0; port < piix4_adapter_count; port++) { u8 hw_port_nr = port == 0 ? 0 : port + 1; - retval = piix4_add_adapter(dev, smba, true, port, notify_imc, + retval = piix4_add_adapter(dev, smba, PIIX4_SB800, port, notify_imc, hw_port_nr, piix4_main_port_names_sb800[port], &piix4_main_adapters[port]); @@ -1085,7 +1101,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) return retval; /* Try to register main SMBus adapter, give up if we can't */ - retval = piix4_add_adapter(dev, retval, false, 0, false, 0, + retval = piix4_add_adapter(dev, retval, PIIX4_SMBUS, 0, false, 0, "", &piix4_main_adapters[0]); if (retval < 0) return retval; @@ -1114,7 +1130,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) if (retval > 0) { /* Try to add the aux adapter if it exists, * piix4_add_adapter will clean up if this fails */ - piix4_add_adapter(dev, retval, false, 0, false, 1, + piix4_add_adapter(dev, retval, PIIX4_SMBUS, 0, false, 1, is_sb800 ? piix4_aux_port_name_sb800 : "", &piix4_aux_adapter); } From patchwork Wed Sep 4 10:57:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 1980677 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=pS413FFa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6139-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzKHS4JTQz1yg3 for ; Wed, 4 Sep 2024 20:59:00 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3D22D285A27 for ; Wed, 4 Sep 2024 10:58:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C0E01CFECB; Wed, 4 Sep 2024 10:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pS413FFa" X-Original-To: linux-i2c@vger.kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2057.outbound.protection.outlook.com [40.107.93.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D03F1CEEAB for ; Wed, 4 Sep 2024 10:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447497; cv=fail; b=trSP14eX1Lka9eFnxjbMJwaOccWofjDKc7qVFC8Iw/P0mS7yYYDAMEUr/KNzKoVVsM0a094yYGyrQLlSeqdACCAYarfU1ALGTtPW6vNun8+Pr81efnmiUaY+QjhfjTD48rE0WfYKxIVbHBF8zxz7sZrw/hYq5EwnO3gPkQ43JBY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447497; c=relaxed/simple; bh=pmMnWKKXonWbFOWwsCBt6xF+D/X3IGBvv5MgYodIo9w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Gr7gzZMl3fCnFQ6qV8eRCJnXMWd3xo0KmV+q2z2sbWRWRbSEKOqyw0rV8RsIbXIp1HAC5U46NXf8XetM1uB0HdBC+Ivt2A9JYEtKkZhSjQDqKWXdtjAlAeY5SnHRt6DZONPg32IIgvD8qYnk7ZRMmJLm6m49kpu28mMoFIbMw40= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=pS413FFa; arc=fail smtp.client-ip=40.107.93.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lfbiraCGPiF9rcZA2zyA7oZy1KafF3Ny2pj7CNxyt+vtJ+sbXN08zE+vKhcaAqe2EWOC+EdrW1vdC1ncbvi2QQcsTmYOfJmxPeRwFCT+qruqOGCnhSJBIDsPo1XK+6NyMXAcMkiZG4mEHceEpHjLU6jzSnUk0LKxR215Aqym7lO9NTMTOwm2EByPYIOxZTUQ8mg9Yw1xdRYIEirTHYurKktbQGhsAB53cXdQUIMo1ZNYMu9CLSzxSJj/9Gdom04KVxosjt6tmPBErswB83kgSOBxn07iT69EpTd5z5rogVb8qYnog53CVFYhzxmOmgMJ6qw2sYx8HfGBSpdCIp1/5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5vJBEuvfJu5mRKySbWPiUUYyrpOjn+viF9j74iU44eo=; b=GUbbKiamtj2JZ5ZZTnGZ/JBGxgLwE21iwA80lfCeGJ5jUF7jwpEdVy68QJoitOnSuOb4vdcqdmeHRY/5hALshsv75XOi2Hbn535BGTSI+N106GGWt627bG3/RqYUnWx4zJVl5tGhDQJ2yBzCS3AqgKSmP6zkgx9pHHiKiXqsSbGJ1rKAuWL0Rh57B3Wz+wgjFWGasQsvc3FQRlSjrpqmn8hrVAv+lcfwG7Q3uGG5uOxUIb9m/GDIX7zlyeO7UCd31sVwmKkWoJjYgMGkTNGLaV2T08YDmVN/ISxP82ezEVFU+TJr0i9xGhRr9in1uPRHhghPOoZTh68beLn+oRq+hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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 (0) 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=5vJBEuvfJu5mRKySbWPiUUYyrpOjn+viF9j74iU44eo=; b=pS413FFa2zZhFIf2UZ1LTirwKkUKjRixVbUKWv/gT2C9rZ+aCpxWmvp6lYdF5DysbKknqYwMrHBZDaFX09jPCnEYd90OWRcCHDpenW56DpQbq5UoZFvbroZ4gh7hSHYkVjV2jcG7LykcfBja0rdfeYtEl1ATM4Uyrk+T+hXfDww= Received: from BN9PR03CA0527.namprd03.prod.outlook.com (2603:10b6:408:131::22) by CY5PR12MB6057.namprd12.prod.outlook.com (2603:10b6:930:2e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Wed, 4 Sep 2024 10:58:12 +0000 Received: from BL6PEPF0001AB4E.namprd04.prod.outlook.com (2603:10b6:408:131:cafe::c6) by BN9PR03CA0527.outlook.office365.com (2603:10b6:408:131::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Wed, 4 Sep 2024 10:58:11 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB4E.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 4 Sep 2024 10:58:11 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 4 Sep 2024 05:58:09 -0500 From: Shyam Sundar S K To: Jean Delvare , Andi Shyti CC: , , Shyam Sundar S K Subject: [PATCH v2 2/5] i2c: piix4: Add i2c_algorithm operations to support AMD ASF with SMBus Date: Wed, 4 Sep 2024 16:27:28 +0530 Message-ID: <20240904105731.2246235-3-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> References: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4E:EE_|CY5PR12MB6057:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f2f2946-b2e7-43a8-9ff6-08dcccd07800 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: 0Ya29/ECt9pV/ufLUBjMXBtXLRekA0WrNK+5De2OaCORRavB6R+qb6Diu4TlNUhz2nwicxW5OYTiSDXOlZFrjuCnQoy3Rk/fBieAwwrCzu3tnY+e4yt/j/DZChqYiy5F000ODEbZSQH/p8W1s2VUukWpRwMp7wjw94Phu3w3uR1xcikO/fLYxOem2Ub4vUCK2S7KQdtgWSUvl62LAG5+MVL9KbWAJ73gVaK4UfxjhSm0YdV6F9f3WwNhyx7/qUwHodg8y0oLwhUzfTpK4cPs4iiDbONc0lzU0S0BUQJB7plTEgKYHZh3q5AJ85l5DYvsBbVLa0RLP7zb/e8z/jpZs80RL7NebpFRgJyvdCouPcVKiRg/jIMsWIhB7V8xZuSfLNk2fBKAVoKllcDaiuT8Wny+ru5Ft5sHnvUovuWL8kORgXgqwGLXNC4XXDeFVHIjzLJnbA6oGGRkPsJdSidG24MrpXkD81v/bEfArOjAZWzqvWAkhPqk0h3kHpiC+zi8mr674PIWk7ErQKoRKbch4Gqk9zbS8tsO/P0Ps4TR4NthpQzwAa0q+zDc5cSuGFars0FUcPUrbaspZ4pxgsONgQt0SXQTi7GxhVgdPEFw5P3YMdqN+qOu3LCXbDpOTWilRdDO2Bb1zql2/6IoHpderjPhkd7QhKXwgRiwyn6xX/oDVrSaMUiAugWOkN/oIGh6F/mSMqqgQN4G46bUBFP+jhLO7Ca88Jea7XtjnchulskEY9Oc9xumSVMg43UtiUd+nfZ4saDZiLkffMDnO8P4Hlx0INAZmaeV40FVBJW9s2pRlg/VSTuZZ8/2VhKaOCbqNF0exNXFoFrP99oTkGmC+f7RpTsMN4JhjNyCOlsc+lxbbTUSO7Ys+ewcXubXlImLlvfsDTLpxhqEB65+3twl7ouIakpRDwsOInsX6Xg0x7ADem3/FXX7PvigzNrhtWvPPmgBwCZbr+Ogyq4hZBwpWrGWoAAaPQ3zBuzjcf6Vq2i2nyB823upg2CKDQDxsHfFwP8pyAwIGCQuLpeglL467lVc7L/Zh36k0iSgCRwyLvDs35nNiUMT4Bx55tdwhnkbbZPbgi9EnOYMa5nOZ08ndvOHFAchRyW4Zj1fWYxQXDJhiGSFZvB703g9VF8wxxjlRUD9fCi0k4dYNJNNXKRSN6Dpbda6vDAM2wvRhacdUhuxKeFB1/wNVsISCv+cjAhDCqgIUuW3P/LTrkTgHaM877eWT8ALcK3CSEKqlF+52SoTCSTKH+Wy1c22NCzpcj/aDgk8trXkenETWF6fPmHDBVdD+dOYR6BOUuwKUkLtGolzWgtZLovKhs+aOn0pD94eSR1RB36tozSDN5LkqKYcQv0WB5P/l9ydru1yNzGg86qVFFErPJXuUvYh22cudi+6fTtp372MKiEqe5igu7+YFh3e5mX3D1F6x8evVIMrfT2GoVAG0D0CkyfbFcg/L0bY X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2024 10:58:11.7713 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f2f2946-b2e7-43a8-9ff6-08dcccd07800 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6057 Implement the i2c_algorithm operations to enable support for AMD ASF (Alert Standard Format) with SMBus. This enhancement includes: - Adding functionality to identify and select the supported ASF functions. - Implementing mechanisms for registering and deregistering I2C slave devices. - Providing support for data transfer operations over ASF. These changes will extend the piix4 driver to accommodate the additional capabilities provided by AMD's ASF Controller. Additionally, include a 'select' Kconfig entry for CONFIG_I2C_PIIX4, as the current patch utilizes reg_slave and unreg_slave callbacks, which are controlled by IS_ENABLED(CONFIG_I2C_SLAVE). Co-developed-by: Sanket Goswami Signed-off-by: Sanket Goswami Signed-off-by: Shyam Sundar S K --- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-piix4.c | 184 +++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index a22f9125322a..10ad839bf4a2 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -197,6 +197,7 @@ config I2C_PIIX4 tristate "Intel PIIX4 and compatible (ATI/AMD/Serverworks/Broadcom/SMSC)" depends on PCI && HAS_IOPORT select I2C_SMBUS + select I2C_SLAVE help If you say yes to this option, support will be included for the Intel PIIX4 family of mainboard I2C interfaces. Specifically, the following diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index d56083e58a2d..003cb04312cf 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -50,6 +50,22 @@ #define SMBSLVEVT (0xA + piix4_smba) #define SMBSLVDAT (0xC + piix4_smba) +/* SB800 ASF register bits */ +#define SB800_ASF_SLV_LISTN 0 +#define SB800_ASF_SLV_INTR 1 +#define SB800_ASF_SLV_RST 4 +#define SB800_ASF_PEC_SP 5 +#define SB800_ASF_DATA_EN 7 +#define SB800_ASF_MSTR_EN 16 +#define SB800_ASF_CLK_EN 17 + +/* SB800 ASF address offsets */ +#define ASFLISADDR (9 + piix4_smba) +#define ASFSTA (0xA + piix4_smba) +#define ASFSLVSTA (0xD + piix4_smba) +#define ASFDATABNKSEL (0x13 + piix4_smba) +#define ASFSLVEN (0x15 + piix4_smba) + /* count for request_region */ #define SMBIOSIZE 9 @@ -101,6 +117,7 @@ #define SB800_PIIX4_FCH_PM_ADDR 0xFED80300 #define SB800_PIIX4_FCH_PM_SIZE 8 +#define SB800_ASF_BLOCK_MAX_BYTES 72 /* insmod parameters */ @@ -168,6 +185,7 @@ struct sb800_mmio_cfg { enum piix4_algo { PIIX4_SB800, PIIX4_SMBUS, + SMBUS_ASF, }; struct i2c_piix4_adapdata { @@ -179,6 +197,7 @@ struct i2c_piix4_adapdata { u8 port; /* Port number, shifted */ struct sb800_mmio_cfg mmio_cfg; u8 algo_select; + struct i2c_client *slave; }; static int piix4_sb800_region_request(struct device *dev, @@ -887,6 +906,168 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, return retval; } +static void sb800_asf_update_bits(unsigned short piix4_smba, u8 bit, unsigned long offset, bool set) +{ + unsigned long reg; + + reg = inb_p(offset); + if (set) + set_bit(bit, ®); + else + clear_bit(bit, ®); + outb_p(reg, offset); +} + +static void sb800_asf_update_bytes(struct i2c_piix4_adapdata *adap, u8 bit, bool set) +{ + unsigned long reg; + + reg = ioread32(adap->mmio_cfg.addr); + if (set) + set_bit(bit, ®); + else + clear_bit(bit, ®); + iowrite32(reg, adap->mmio_cfg.addr); +} + +static void sb800_asf_setup_slave(struct i2c_piix4_adapdata *adap) +{ + unsigned short piix4_smba = adap->smba; + + /* Reset both host and slave before setting up */ + outb_p(0, SMBHSTSTS); + outb_p(0, ASFSLVSTA); + outb_p(0, ASFSTA); + + /* Update slave address */ + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_LISTN, ASFLISADDR, true); + /* Enable slave and set the clock */ + sb800_asf_update_bytes(adap, SB800_ASF_MSTR_EN, false); + sb800_asf_update_bytes(adap, SB800_ASF_CLK_EN, true); + /* Enable slave interrupt */ + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_INTR, ASFSLVEN, true); + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_RST, ASFSLVEN, false); + /* Enable PEC and PEC append */ + sb800_asf_update_bits(piix4_smba, SB800_ASF_DATA_EN, SMBHSTCNT, true); + sb800_asf_update_bits(piix4_smba, SB800_ASF_PEC_SP, SMBHSTCNT, true); +} + +static s32 sb800_asf_access(struct i2c_adapter *adap, u16 addr, u8 command, u8 *data) +{ + struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(adap); + unsigned short piix4_smba = adapdata->smba; + u8 len; + int i; + + outb_p((addr << 1), SMBHSTADD); + outb_p(command, SMBHSTCMD); + len = data[0]; + if (len == 0 || len > SB800_ASF_BLOCK_MAX_BYTES) + return -EINVAL; + + outb_p(len, SMBHSTDAT0); + inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ + for (i = 1; i <= len; i++) + outb_p(data[i], SMBBLKDAT); + + outb_p(PIIX4_BLOCK_DATA, SMBHSTCNT); + /* Enable PEC and PEC append */ + sb800_asf_update_bits(piix4_smba, SB800_ASF_DATA_EN, SMBHSTCNT, true); + sb800_asf_update_bits(piix4_smba, SB800_ASF_PEC_SP, SMBHSTCNT, true); + + return piix4_transaction(adap); +} + +static int sb800_asf_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) +{ + struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(adap); + unsigned short piix4_smba = adapdata->smba; + u8 asf_data[SB800_ASF_BLOCK_MAX_BYTES]; + struct i2c_msg *dev_msgs = msgs; + u8 prev_port; + int ret; + + if (msgs->flags & I2C_M_RD) { + dev_err(&adap->dev, "Read not supported\n"); + return -EOPNOTSUPP; + } + + /* Exclude the receive header and PEC */ + if (msgs->len > SB800_ASF_BLOCK_MAX_BYTES - 3) { + dev_err(&adap->dev, "ASF max message length exceeded\n"); + return -EOPNOTSUPP; + } + + asf_data[0] = dev_msgs->len; + memcpy(asf_data + 1, dev_msgs[0].buf, dev_msgs->len); + + ret = piix4_sb800_region_request(&adap->dev, &adapdata->mmio_cfg); + if (ret) + return ret; + + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_RST, ASFSLVEN, true); + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_LISTN, ASFLISADDR, false); + /* Clear ASF slave status */ + outb_p(0, ASFSLVSTA); + + /* Enable ASF SMBus master function */ + sb800_asf_update_bytes(adapdata, SB800_ASF_MSTR_EN, true); + prev_port = piix4_sb800_port_sel(adapdata->port, &adapdata->mmio_cfg); + ret = sb800_asf_access(adap, msgs->addr, msgs[0].buf[0], asf_data); + piix4_sb800_port_sel(prev_port, &adapdata->mmio_cfg); + sb800_asf_setup_slave(adapdata); + piix4_sb800_region_release(&adap->dev, &adapdata->mmio_cfg); + return ret; +} + +static int sb800_asf_reg_slave(struct i2c_client *slave) +{ + struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(slave->adapter); + unsigned short piix4_smba = adapdata->smba; + int ret; + u8 reg; + + if (adapdata->slave) + return -EBUSY; + + ret = piix4_sb800_region_request(&slave->dev, &adapdata->mmio_cfg); + if (ret) + return ret; + + reg = (slave->addr << 1) | BIT(0); + outb_p(reg, ASFLISADDR); + + sb800_asf_setup_slave(adapdata); + adapdata->slave = slave; + sb800_asf_update_bits(piix4_smba, SB800_ASF_DATA_EN, ASFDATABNKSEL, false); + piix4_sb800_region_release(&slave->dev, &adapdata->mmio_cfg); + return 0; +} + +static int sb800_asf_unreg_slave(struct i2c_client *slave) +{ + struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(slave->adapter); + unsigned short piix4_smba = adapdata->smba; + + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_INTR, ASFSLVEN, false); + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_RST, ASFSLVEN, true); + adapdata->slave = NULL; + return 0; +} + +static u32 sb800_asf_func(struct i2c_adapter *adapter) +{ + return I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_BYTE | + I2C_FUNC_SLAVE | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | I2C_FUNC_SMBUS_PEC; +} + +static const struct i2c_algorithm sb800_asf_smbus_algorithm = { + .master_xfer = sb800_asf_xfer, + .reg_slave = sb800_asf_reg_slave, + .unreg_slave = sb800_asf_unreg_slave, + .functionality = sb800_asf_func, +}; + static u32 piix4_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | @@ -959,6 +1140,9 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, case PIIX4_SB800: adap->algo = &piix4_smbus_algorithm_sb800; break; + case SMBUS_ASF: + adap->algo = &sb800_asf_smbus_algorithm; + break; default: dev_err(&dev->dev, "Unsupported SMBus algorithm\n"); return -EINVAL; From patchwork Wed Sep 4 10:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 1980679 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=0/tpdrUK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6140-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzKHX0MGcz1ygx for ; Wed, 4 Sep 2024 20:59:04 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BD1351F25546 for ; Wed, 4 Sep 2024 10:59:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D2761D0167; Wed, 4 Sep 2024 10:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0/tpdrUK" X-Original-To: linux-i2c@vger.kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2080.outbound.protection.outlook.com [40.107.92.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6E781CEEB1 for ; Wed, 4 Sep 2024 10:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447500; cv=fail; b=EGQQgc6L0S4tBIMNTP7KxnzcwZcl9+QhhYLskHwwRB+SqFve9fCd18VZUOAZkBPI5jA9YO2kUk4cBThEKuhQq2yBikBye1h/wUxAPQ7yXoKl2k7c0vr7Mm3mdKck2/FAKQWlenHmov/OFQATqo150ccrzM2K+RD0jb2uWfEbGBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447500; c=relaxed/simple; bh=0Sa/N6RqUIxLAHhaPYPNB9CXPyyC59kLP/jMMzNXi5w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z9BSO6M6Wmc9fznkTk0H37hhHSlCIvI2yd4j045eJrB+bxyzUnSpFIV6krDRq+mwPYLJdKjZZIXgOkwQXJ2cKJa/RUtEcw15xocExQsvWfTK8IZ51hL00xZVBpg/qashhWHj0//3t5e3Ckd139uMs/rU3jgbAtezNO9UMxN+jcc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=0/tpdrUK; arc=fail smtp.client-ip=40.107.92.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T9E6l/14hV1phmlVY/hWlpXcnXSDTpVJBlElQvgxS0Ox/NQyCaIFIphFkjhzrksYzSWQBF79VmCTIzmp4+ZMOQ62MXyfIP65BQC+UVPViUxsyOx3x1D2v2MbfxWYmotvagJF9xuHvZO49f7cALmgTmAxUVkl8/DFRrnCG1sbLiW44B8MZ7WioZW2MAQEESTkCDZBmhoiqVImdbFhpQhY18xNikzklu3BSAiipaLD7dKhh004UX51/qbPx03PDSUkaZ1vrOhz9Z8mYi/M3pgIevM59A259A4Zx9dYdmRMXau9W9KX2JHvAVJOuFOqaOpkISG5tIxvrTejdiFXf8Tnsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=CPAjrgBMf77AWZERR0TSqVkwMs2mRmEB4o5NZkoSKBg=; b=UFIpc3VE9z4no2X9ID7ZqU9XyEK2lvCKAGP7U40HA3uzSyTwdP7fLR9hSDVI1mxqR5HcKNJTmmuS33xoeFSWH/nTiRq1Iw2PLLiM7WoezJi4IWIROZ2oM9mAftzzE7YDQqoaibupHMBlQrItV0j65mao08TmJITsAYOaWSOoon3uNC3pf4ykjO/1SEBz2NQQMtPgxOvo4sc8Gz3EcJq5jY8eJUFYaTtql9sgioVrxDst013NyR/KPUBI+oPuWbKzK3DEGH7jn7tVaQPZN1ddw3bHjCp2X0F0RVc00cZQChn2vjG3mk6XCWxqhKeoassnqUfEb6FSiRQys6HYoI6nrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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 (0) 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=CPAjrgBMf77AWZERR0TSqVkwMs2mRmEB4o5NZkoSKBg=; b=0/tpdrUK8qbidiCfVEynDoANulyv0MSUVsRsYk4Pm/ilnD7pZOoAuXErJE2k3Mrh7yDVQ/5EB8y9KidawuGYA2jH9DQxJJOy/PVgsg0pyHHr6z+y4zbiL/Ms0jMypXQJLiqjdBpXcd+CkD6/e1LCopKr67UWjJOaxdqIfeq3Sb0= Received: from BN9PR03CA0527.namprd03.prod.outlook.com (2603:10b6:408:131::22) by SN7PR12MB7980.namprd12.prod.outlook.com (2603:10b6:806:341::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Wed, 4 Sep 2024 10:58:14 +0000 Received: from BL6PEPF0001AB4E.namprd04.prod.outlook.com (2603:10b6:408:131:cafe::32) by BN9PR03CA0527.outlook.office365.com (2603:10b6:408:131::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Wed, 4 Sep 2024 10:58:14 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB4E.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 4 Sep 2024 10:58:14 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 4 Sep 2024 05:58:11 -0500 From: Shyam Sundar S K To: Jean Delvare , Andi Shyti CC: , , Shyam Sundar S K , Andy Shevchenko Subject: [PATCH v2 3/5] i2c: piix4: Add ACPI support for ASF SMBus device Date: Wed, 4 Sep 2024 16:27:29 +0530 Message-ID: <20240904105731.2246235-4-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> References: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4E:EE_|SN7PR12MB7980:EE_ X-MS-Office365-Filtering-Correlation-Id: 154f97be-fd18-44c1-54c9-08dcccd0795a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: qA04y+phU+M6Lsm3thKrynF105UMGdPtjsbTGtRurLPtbiiUsCvLFhbnkD9lWDGrjURkXr6AWQiUZZlCuNpGML+YBjmY5fsWWdIEEq8drG+0Y1aR6AjxCF1dTx5TxQx4znjdNyZNM6lxGmvT6hVaiXSehf53YgGKHtvC1/VmMlLFJm2cTZYJBCLeA6N6Yh5lKJW4gFwMxD0MjfBkKgXgGALeI+iuO5aOcU/AO+d7C0Vr9qg9XOOyYCTBuc264ThZ2AkoYNIQ8brHOcG8KN/UdxZEU9qbs4YZ4oau9pVntFiFdUGoFdfs+NpAEObLwRISPVq1/lHRJUukkfe8f+aXPfmO5/+fY6QO3c5NQ9N0WNaGXB3QCd8O3mUt/GdU681oO3Fd2P9w/Wv3JZj5lcWD/hB3x5i6mkeAeFqa4nOfn0G9aHF2eLQEqjcLRVEC79r4eTlVQxlxEFuyyAO0UAMuGVwA3q1X6R7hpSkJZbIk3pW3gRgsOyrtDNUnHZerObzX3/fs0CCtrmConZIVJzxEEDRn6vp4gVo3s3SQvWUhxmVeCmLquYS972bpuP8lr5yE5pKLQwlBOPwebhFzX8jgrjpOZ1YvOyDHi0p3JNhiSO5S98Lu/KRw1S3GC09iocKgeEEkvVy4dLJwTj0T+6GCTNqZUYTeNTegyWDlLfSsHaY6x0CLkaWWDnbTzWTg1Ga/UUjT4/UOwNSGj5oy4Q5i8pMX4FPpayNWIL6Ph8a6/Zt2NxLF2rlsTKd8sTudpwBcxZreuEensfiAVB4uFrxzu7AK6vqa1n0TmVRAZVCMLlHGu6d6WosRu54yAJnmw6mS2PUf2yu6HjUReQBQpUtMVqPp8fhBAnYu3F38qzgdiFf6V3XoWTtTrJY/QVp/oUCkvY95TUMVPOS4C1i8NETUwNbZmsF/VM5ReTdUzEgyeA6tBjw60TS+3EOa0GmBzMYypGqei7yeOMKN5gPHXTXL8J8z26KXzSXXRKJACJuXmhs0YqKeIypjDGaGgKGJXBxTxHR1pJpG+MoOxmfD/QRgD7qrYh2NGxwytUN6KQwTT9k22C05lbQOXKk3vzKyQ3dEgimwamGQeZ9skqCh71yRLOC7j7T3u3vs230COHhlZlpeyMi1iMt7AqKsghRMCh+ujE+lNZV6RNt7NtVjH+iEqWJmXKVd6gS8EuQRlFPu0zZ5Lic2YSyE0HH9DuceQQVZlFaSwRX2cgIfUYIeOtuYgVnxBw9ItUvLl3b1VzNvvMmeJ0BVvdHv4ZF6pMG4OnMHzYM5rxGpngz1HuBKdmWexXDxiJDx16i6zbj/IyJfneRvIlUYFkQHO+EUVhe6C0JE4KfyBK0MwusYU2L5PmFnDVRY2Hisj3aWHyaeh/NCjyjw8P0bCh1TNw83OAouVaPzFcOkHVBKx1RCCfwRDaah8zuG8YP8nQziWD4YfD0/XKaHicPZuIzsmp90eNQDTz+d X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2024 10:58:14.0370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 154f97be-fd18-44c1-54c9-08dcccd0795a 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7980 The AMD ASF controller is presented to the operating system as an ACPI device. The piix4 driver can obtain the ASF handle through ACPI to retrieve information about the ASF controller's attributes, such as the ASF address space and interrupt number, and to handle ASF interrupts. Currently, the piix4 driver assumes that a specific port address is designated for AUX operations. However, with the introduction of ASF, the same port address may also be used by the ASF controller. Therefore, a check needs to be added to ensure that if ASF is advertised and enabled in ACPI, the AUX port is not set up. Cc: Andy Shevchenko Co-developed-by: Sanket Goswami Signed-off-by: Sanket Goswami Signed-off-by: Shyam Sundar S K --- drivers/i2c/busses/i2c-piix4.c | 166 ++++++++++++++++++++++++++++++++- 1 file changed, 165 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 003cb04312cf..3bcf2e8b24e7 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -60,9 +60,12 @@ #define SB800_ASF_CLK_EN 17 /* SB800 ASF address offsets */ +#define ASFINDEX (7 + piix4_smba) #define ASFLISADDR (9 + piix4_smba) #define ASFSTA (0xA + piix4_smba) #define ASFSLVSTA (0xD + piix4_smba) +#define ASFDATARWPTR (0x11 + piix4_smba) +#define ASFSETDATARDPTR (0x12 + piix4_smba) #define ASFDATABNKSEL (0x13 + piix4_smba) #define ASFSLVEN (0x15 + piix4_smba) @@ -118,6 +121,8 @@ #define SB800_PIIX4_FCH_PM_ADDR 0xFED80300 #define SB800_PIIX4_FCH_PM_SIZE 8 #define SB800_ASF_BLOCK_MAX_BYTES 72 +#define SB800_ASF_ERROR_STATUS 0xE +#define SB800_ASF_ACPI_PATH "\\_SB.ASFC" /* insmod parameters */ @@ -182,6 +187,11 @@ struct sb800_mmio_cfg { bool use_mmio; }; +struct sb800_asf_data { + unsigned short addr; + int irq; +}; + enum piix4_algo { PIIX4_SB800, PIIX4_SMBUS, @@ -198,6 +208,8 @@ struct i2c_piix4_adapdata { struct sb800_mmio_cfg mmio_cfg; u8 algo_select; struct i2c_client *slave; + bool is_asf; + struct delayed_work work_buf; }; static int piix4_sb800_region_request(struct device *dev, @@ -906,6 +918,66 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, return retval; } +static void sb800_asf_process_slave(struct work_struct *work) +{ + struct i2c_piix4_adapdata *adapdata = container_of(work, struct i2c_piix4_adapdata, + work_buf.work); + unsigned short piix4_smba = adapdata->smba; + u8 data[SB800_ASF_BLOCK_MAX_BYTES]; + u8 bank, reg, cmd = 0; + u8 len, val = 0; + int i; + + /* Read slave status register */ + reg = inb_p(ASFSLVSTA); + + /* Check if no error bits are set in slave status register */ + if (!(reg & SB800_ASF_ERROR_STATUS)) { + /* Read data bank */ + reg = inb_p(ASFDATABNKSEL); + bank = (reg & BIT(3)) >> 3; + + /* Set read data bank */ + if (bank) { + reg = reg | BIT(4); + reg = reg & (~BIT(3)); + } else { + reg = reg & (~BIT(4)); + reg = reg & (~BIT(2)); + } + + /* Read command register */ + outb_p(reg, ASFDATABNKSEL); + cmd = inb_p(ASFINDEX); + len = inb_p(ASFDATARWPTR); + for (i = 0; i < len; i++) + data[i] = inb_p(ASFINDEX); + + /* Clear data bank status */ + if (bank) { + reg = reg | BIT(3); + outb_p(reg, ASFDATABNKSEL); + } else { + reg = reg | BIT(2); + outb_p(reg, ASFDATABNKSEL); + } + } else { + /* Set bank as full */ + reg = reg | (BIT(3) | BIT(2)); + outb_p(reg, ASFDATABNKSEL); + } + + outb_p(0, ASFSETDATARDPTR); + if (!(cmd & BIT(0))) { + i2c_slave_event(adapdata->slave, I2C_SLAVE_WRITE_REQUESTED, &val); + for (i = 0; i < len; i++) { + val = data[i]; + i2c_slave_event(adapdata->slave, I2C_SLAVE_WRITE_RECEIVED, &val); + } + i2c_slave_event(adapdata->slave, I2C_SLAVE_STOP, &val); + } +} + static void sb800_asf_update_bits(unsigned short piix4_smba, u8 bit, unsigned long offset, bool set) { unsigned long reg; @@ -1195,6 +1267,88 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, return 0; } +static irqreturn_t sb800_asf_irq_handler(int irq, void *ptr) +{ + struct i2c_piix4_adapdata *adapdata = (struct i2c_piix4_adapdata *)ptr; + unsigned short piix4_smba = adapdata->smba; + u8 slave_int = inb_p(ASFSTA); + + if ((slave_int & BIT(6))) { + /* Slave Interrupt */ + outb_p(slave_int | BIT(6), ASFSTA); + schedule_delayed_work(&adapdata->work_buf, HZ); + } else { + /* Master Interrupt */ + sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_INTR, SMBHSTSTS, true); + } + + return IRQ_HANDLED; +} + +static int sb800_asf_acpi_resource_cb(struct acpi_resource *resource, void *context) +{ + struct sb800_asf_data *data = context; + + switch (resource->type) { + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + data->irq = resource->data.extended_irq.interrupts[0]; + break; + case ACPI_RESOURCE_TYPE_IO: + data->addr = resource->data.io.minimum; + break; + } + + return 0; +} + +static int sb800_asf_add_adap(struct pci_dev *dev) +{ + struct i2c_piix4_adapdata *adapdata; + struct sb800_asf_data data; + struct acpi_device *adev; + LIST_HEAD(res_list); + acpi_status status; + acpi_handle handle; + int ret; + + status = acpi_get_handle(NULL, SB800_ASF_ACPI_PATH, &handle); + if (ACPI_FAILURE(status)) + return -ENODEV; + + adev = acpi_fetch_acpi_dev(handle); + if (!adev) + return -ENODEV; + + ret = acpi_dev_get_resources(adev, &res_list, sb800_asf_acpi_resource_cb, &data); + if (ret < 0) { + dev_err(&dev->dev, "Error getting ASF ACPI resource: %d\n", ret); + return ret; + } + + acpi_dev_free_resource_list(&res_list); + ret = piix4_add_adapter(dev, data.addr, SMBUS_ASF, piix4_adapter_count, false, 0, + piix4_main_port_names_sb800[piix4_adapter_count], + &piix4_main_adapters[piix4_adapter_count]); + if (ret) { + dev_err(&dev->dev, "Failed to add ASF adapter: %d\n", ret); + return -ENODEV; + } + + adapdata = i2c_get_adapdata(piix4_main_adapters[piix4_adapter_count]); + ret = devm_request_irq(&dev->dev, data.irq, sb800_asf_irq_handler, IRQF_SHARED, + "sb800_smbus_asf", adapdata); + if (ret) { + dev_err(&dev->dev, "Unable to request irq: %d for use\n", data.irq); + return ret; + } + + INIT_DELAYED_WORK(&adapdata->work_buf, sb800_asf_process_slave); + adapdata->is_asf = true; + /* Increment the adapter count by 1 as ASF is added to the list */ + piix4_adapter_count += 1; + return 1; +} + static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba, bool notify_imc) { @@ -1243,6 +1397,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) { int retval; bool is_sb800 = false; + bool is_asf = false; if ((dev->vendor == PCI_VENDOR_ID_ATI && dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && @@ -1279,6 +1434,10 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) retval = piix4_add_adapters_sb800(dev, retval, notify_imc); if (retval < 0) return retval; + + /* Check if ASF is enabled in SB800 */ + if (sb800_asf_add_adap(dev)) + is_asf = true; } else { retval = piix4_setup(dev, id); if (retval < 0) @@ -1308,7 +1467,9 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) if (dev->vendor == PCI_VENDOR_ID_AMD && (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS || dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS)) { - retval = piix4_setup_sb800(dev, id, 1); + /* Do not setup AUX port if ASF is enabled */ + if (!is_asf) + retval = piix4_setup_sb800(dev, id, 1); } if (retval > 0) { @@ -1326,6 +1487,9 @@ static void piix4_adap_remove(struct i2c_adapter *adap) { struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(adap); + if (adapdata->is_asf) + cancel_delayed_work_sync(&adapdata->work_buf); + if (adapdata->smba) { i2c_del_adapter(adap); if (adapdata->port == (0 << piix4_port_shift_sb800)) From patchwork Wed Sep 4 10:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 1980678 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=13LgfLc4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6141-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzKHW67SHz1yg3 for ; Wed, 4 Sep 2024 20:59:03 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4177CB20B49 for ; Wed, 4 Sep 2024 10:59:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF4E21D016A; Wed, 4 Sep 2024 10:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="13LgfLc4" X-Original-To: linux-i2c@vger.kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 161361D0148 for ; Wed, 4 Sep 2024 10:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447501; cv=fail; b=pqV4gAsIoOqoDcEp7xzV7IGPypkhY1Ci9ym0QR06ZHjT94A1UtEFfTuuYZNO5mlhYO0gLPxwXp4GyUBxLvecOW8UDnv6pAFQ4/ChEruMJxHQSIsezW+yTCTDr3o7yySrziftmHh/JHtDuWWcUJ+MqY2l2azVWADlOFZoPQEuOCI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447501; c=relaxed/simple; bh=Fyfa6vL4DXYCBKrt/fC6r70fa6h6CTN8lNbvHIqaX5w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=By51vrXDWB+tEbe0WzecH+bq7BVtZjmyJv2mFA9L2394oSBCXiexk+fmp4LeBFAKjkSQWyEy5+OZLAXeHDTieS5lPWumZNkEdxBcE/TTgpnvKuzRM9toDLqPfRPRfRSPNnb9r7eUf16CGXhFgHRH9rRDeXKdX4Xn8AV8s7E10wk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=13LgfLc4; arc=fail smtp.client-ip=40.107.94.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E8QJ8WiU4s2b8ERp7P1hY/bEFNnwYZORiTniLR3oieTeSeYk4vHtKYR8PtDRTNVwgCRD3xJNlTeSINd/bESO8JSISc7cDtXwejDS728yi4J7T0yb/us3e5yWctZ3xAscv5vNFMm2i/PsBvqUwlArk6/OfEHoDp0Ma2knyxr87cbUyal5M8BHPjINv4HlhtndHLNR3C3sDuSh2nXVBLtBH9NHJROU6ogCi4z4BUzSvlT2/Xs5ptOccapoc9AEhE6mOFPm/rjcxcj382x+kfN9xAoVz92jM9ojk2+8Bb+dLLOyHf8Y7tDdUaEgoA4h42kQP95EEQ5WGUiGMlJpqle1FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2InwrH3YSgKOs3ETHFyCu4EWhfh+M1IQA/bs1xzQrOw=; b=ohEsf8grJKMsBwBG6ilW0LQoogKy4tasxlSfqk1zw1CgkpLnBOGR9B83w+W4AI9o0i+W5NE0Gb/GF5glw66jPCYfFS/bQ5ZqvI5uasi5at3pBcUMjjsJQFZKizr7fqmO34BCVX8hXp+SnZWOK7HjY5EQEpYSslbD6y6yxjmW3EeJw/12OEsM68Zd7k5vFcnLwPMAFGdT/HHEEwyvCLPqI4H4zaikQDI2/fJ6Ly8q31NQJdr8ahdwcAJM1E7eXM1wbMCht3zM2ovAmnNHdwEfzBkUaWIone+26++2DVSuWQ3kSPd/vqnSwS5iZMuvoMa0rlVOZRR7U+afz4wVnUHJew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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 (0) 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=2InwrH3YSgKOs3ETHFyCu4EWhfh+M1IQA/bs1xzQrOw=; b=13LgfLc4CJXru0SHwf/M5sFvWOX6cVKo7ufz0gXkbMrEj6uOv8j/Wxiw8c3Nw7faTQM5nVi86szM6JRFYz8CRzfHTWk7v5nCK7VLXArKiNlG2IXK62e75+3Bk7JdLYLhHQMD4THzllnWtDoT8sv/fSsYNGjtsSEVVTAmTa+yiGQ= Received: from BN9PR03CA0923.namprd03.prod.outlook.com (2603:10b6:408:107::28) by SJ2PR12MB9007.namprd12.prod.outlook.com (2603:10b6:a03:541::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Wed, 4 Sep 2024 10:58:16 +0000 Received: from BL6PEPF0001AB51.namprd04.prod.outlook.com (2603:10b6:408:107:cafe::c3) by BN9PR03CA0923.outlook.office365.com (2603:10b6:408:107::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Wed, 4 Sep 2024 10:58: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB51.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 4 Sep 2024 10:58:15 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 4 Sep 2024 05:58:13 -0500 From: Shyam Sundar S K To: Jean Delvare , Andi Shyti CC: , , Shyam Sundar S K Subject: [PATCH v2 4/5] i2c: piix4: Adjust the SMBus debug message Date: Wed, 4 Sep 2024 16:27:30 +0530 Message-ID: <20240904105731.2246235-5-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> References: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB51:EE_|SJ2PR12MB9007:EE_ X-MS-Office365-Filtering-Correlation-Id: 69fc5ff6-25c1-45dd-f2d0-08dcccd07a88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: uf+Rnq+kKd9Tek/VWATe/3Ge/FUCC76UQVU6yPqxaJnb077UnNRG+MC/cV5aqx9GNCWRI5GPpwq9GD78MaKwD/uJNa1gsq6I8yO/V5sPk+k3OgLL/oSbAWasEpPJhRFNnd6hRU2lkVIUgHoIbwTtDqUIMHPPOu56i+W85BmxTOoV9AU9PnlrgN44qYT4SXYGKZnTn6/MQz8rfsgzn5VWTVqK19WlRowDMlbPdsCuPRiF3Epvz3FKWB7EGeFW40l6mGY4/6IwnqVBTNijM43QUjTlLv5n1JR9PNkZrI+aXcP2hJ0g6YNn09agtR1Uk8+XnNeg5QVDOGXrtFL7U/iortVGCe1A3lgVYerUCAL8Y8O2gk22PBIUZJpa4e3xP7CNxdES6Ow/Mi0QLY+V8MeThfCd/ErzK+kYFyucCRVdRXqof/Dup+0jND9qZoD+zHyAckItvEtwGdT5Vaf3mjz2osbFaHX16MYrUsTyByVNr48IGodyOdGI3F0BX5aEgbUhlLjQwmu6X1XttnUtAuQm5uG4DBA6elyDLslZlX4Mud8LFMmxyo88H0IwgqvXDAL3y5G1CYy5JwZaj0Z3vT0sFXo1cBJatr6jPmW68sNZg7OPRjI0IIjsILjPW79CGcFsTolBofcQ0LzhtEu4xyHXZEamzZ3OAsaWkcIsBZ4/4vkvLQ03JE8znyMf5xh0KnPRhWpiW4XhGPWF6f8h5CnWpwXKSVsYIj8nTVVxvfW3iRQBnQ/lnj8sBYoL/0v9JDSOOKtv1PorfqBvC4A4XePt9RNahKUzdaCV5/uuOkS0mfdV+pu6JSw+Ae6Tu0wN++omz0YxJ9QnhoQUqyUDKKkKsgheT+rR0HmL0oLQwBK29yCvJX0XS4K8bdaMaTpzNnR0Q8NMwKTmEgYR3Y5kUWrhmvYI7VF3pxAzEi+2YnzvqnrV6C7Ngla+FasdA3LZaqecBd5NEXEw1COLvm/gmw0Xn0yp8Ff7iqk/hW/+RQjRx4T5/6rknEm3MeWpfHcuztbMNkLY1tjudjWMM/1FiiJ3i7Ph7/e12sTB2tefkwxLHFwOemKPjD+ZbDnTfLAY0is58kbeHmMfOVknEsdzHu+t/XA71CRU6W2t10b/8Fnf6eeCvyHCKbc7SfngfUms6+pM1azQpsNV3DajveCowLcPGnU1+F6nGLzqqhjJy6K0XJ7pjgVbQAFdf4BUc/MJHmkeVq8+leM8phr27/R+TcCk95NA3ed4sXb+jL/8FpNbVktpR4kTxMb6SlLP/Z3BshAHbpbweV8x3TphYDJb//Vp/gfbYzi1Pxva9//AlnprPGiDrW+QmvVMBb9TVTAtuSccEOu1drlE4aRebjFVUNLSbKjoQdRFx0jz1W5RqN8FLY8mGM4QWdVhfyW24EHethRVFSSmEBWOuaYlcK0mLlpt6Oy0VELMC/rLYqzw5aUqO0Li3bxTGCPmojkwAdEnSDTq X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2024 10:58:15.9889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69fc5ff6-25c1-45dd-f2d0-08dcccd07a88 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB51.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9007 With the addition of ASF, the current adapter information must now correctly print the SMBus node details, whether it pertains to PIIX4 or ASF. Update the driver to reflect this change accordingly. Co-developed-by: Sanket Goswami Signed-off-by: Sanket Goswami Signed-off-by: Shyam Sundar S K --- drivers/i2c/busses/i2c-piix4.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 3bcf2e8b24e7..789dbe832012 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -1194,6 +1194,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, { struct i2c_adapter *adap; struct i2c_piix4_adapdata *adapdata; + const char *node = "PIIX4"; int retval; adap = kzalloc(sizeof(*adap), GFP_KERNEL); @@ -1213,6 +1214,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, adap->algo = &piix4_smbus_algorithm_sb800; break; case SMBUS_ASF: + node = "ASF"; adap->algo = &sb800_asf_smbus_algorithm; break; default: @@ -1243,7 +1245,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, } snprintf(adap->name, sizeof(adap->name), - "SMBus PIIX4 adapter%s at %04x", name, smba); + "SMBus %s adapter%s at %04x", node, name, smba); i2c_set_adapdata(adap, adapdata); From patchwork Wed Sep 4 10:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 1980680 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=mGPksO7Z; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6142-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzKHX6p4Xz1yg3 for ; Wed, 4 Sep 2024 20:59:04 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B7490B211D9 for ; Wed, 4 Sep 2024 10:59:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 312391D016D; Wed, 4 Sep 2024 10:58:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mGPksO7Z" X-Original-To: linux-i2c@vger.kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2056.outbound.protection.outlook.com [40.107.223.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 609661CEEB1 for ; Wed, 4 Sep 2024 10:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447502; cv=fail; b=qtz3Ju/sDUArYmBdQPb6X6WATfCRmsn1lPDRbqNR5a6vsa6mRu80UmTBkDT20dCPOY4DySt2Y/iRrPdNeb1nfuk1r0afMJVjmAXVmNV1mgaUzHwoeMAQdBsjxousiWpeA1nAJr8H59+cOorG66ZQLvYR+OpHGfUxf9EwZx6Ovjs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725447502; c=relaxed/simple; bh=8uwZxj/pywjnq5pdG2wPfwzGJk0cW8wGlYHH235EszY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DEz0PXmP9qxB/11Dmj4SU4eZrgi9Ko/RD8M8oagFhUsAJ8Sf7emzmDJBFiplNxxAGcLxciVqpmlRjqjTKSEqhQrl9TEaPCgquut+fPody9Kw8JUdery4qTZlBQSR3UIr7f9CVg5Lm5dipV3SiEGfLmpCPxyOkf2MYVZrw3SZzzI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=mGPksO7Z; arc=fail smtp.client-ip=40.107.223.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Yu5rRHaQTGlNmGkDLqJ0HYLjJfTYwB3YWniU1tikFUKaOiuC8r7ZfzYWKu6+oaQouc2zPNA5Hh9UmCodaUfa4EWOvWGAKQqsQoW8a+dyrz8rCmlJPo8BhPUQX3IlKC4xQjGP4ZYSDCsRcI19bG2I31/wesX+NMokM1pWJ9ArLE1RZL5N0xbxrttOdSXgvJ2j6/woAKr3Q1yY87HBdS8sJPR5GL/psOnELnVNzcJkEQe3hbe69O3UMblULpe4xm5K0+7tWfEyZeosdeYae4qX/MF5p0LNytsSkOyy09MWz0mnFLkdWqa7AwVwH2J53ZqzozzQE1HknASVqxdwLrWphw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=QoKDrPA3j6uFfBH3H2iPplFBOqd/1/JRmhWRxI6t44M=; b=m8INDnEyMJoagRl/4Qm8QOkrBGy8C2o+GRkk5GMhfv6J6pVcLdaFGGZryiEyt/ZhU1aieee0DxM0h4E4BGcmQozGmXDIAz3182SgrhlaWnzsROm/rO4+ZDdr+Tr6O/PulAQ+je++M80iEfAZO7UyzFysq7gd3R6krUp8YzuJh+PLh9rzT6G+0n8VRvcnqy/CtEF7DzLZL8rePgNVfvTgNktBy7tqM1dwpV4iwAYetC5bDGxNCnP12wtdR4kLP+GItadbhtqCHlQ4hv7cmAqeEPSmErwLmfXfSxtXgleUY0bi5rDcwStd/vVkU+1FRpeEUeVwAS8823abwylUvlJZLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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 (0) 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=QoKDrPA3j6uFfBH3H2iPplFBOqd/1/JRmhWRxI6t44M=; b=mGPksO7Z2YcSRtDBwXecC3PUGzN/VlJPnslDQlHeE5gUpxIEymDKIscyNEbM+YMEKJ7fx7llmTr/l6+dIjWcoWnS3/mNtD+RyerVItbpPS4TyP5AJe4vi+zlsF6uPm1xG1tPIc+4sqgX6vYGqv8YBp5quBD3GuYt0lha32qeCrw= Received: from BLAPR03CA0085.namprd03.prod.outlook.com (2603:10b6:208:329::30) by PH8PR12MB6865.namprd12.prod.outlook.com (2603:10b6:510:1c8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Wed, 4 Sep 2024 10:58:18 +0000 Received: from BL6PEPF0001AB4D.namprd04.prod.outlook.com (2603:10b6:208:329:cafe::98) by BLAPR03CA0085.outlook.office365.com (2603:10b6:208:329::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.26 via Frontend Transport; Wed, 4 Sep 2024 10:58:18 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB4D.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 4 Sep 2024 10:58:17 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 4 Sep 2024 05:58:15 -0500 From: Shyam Sundar S K To: Jean Delvare , Andi Shyti CC: , , Shyam Sundar S K Subject: [PATCH v2 5/5] i2c: piix4: Clear remote IRR bit to get successive interrupt Date: Wed, 4 Sep 2024 16:27:31 +0530 Message-ID: <20240904105731.2246235-6-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> References: <20240904105731.2246235-1-Shyam-sundar.S-k@amd.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4D:EE_|PH8PR12MB6865:EE_ X-MS-Office365-Filtering-Correlation-Id: 9312f6e8-41b0-4ded-d541-08dcccd07ba6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: fO0gQ1Y4WOeAYONwr2t2Oco771Qp2VH8Zr/7PZZQEaPud7Hmxu9R3znTKrroatTNEKSt3GJ8CKCCUklzrAgrp1jrVCEp1G041nSJybVbmCQ4C98QfvsYrzckH+jKfUbZfo+g+DazYmyzX2M5049yiNRWr7irazThNOXWn4lvyA32VsAoAYiHNQuhffKl3z2UoiSClJE0yIAWEHwgzzQUYIBAQSYSkScDj2haMhTIMjN4QGIdlRszpnE+q58VZ8IDo0YzROFr0yHh4eaeG23ZLuqbE7Xl0FLkl+BGBZGgQraXQBTupf7LSqSsHYZGL34sJHkSXvYpuu6FLTBrZKdEDo1SMjtqQuNBC0Fd9aNAbvIxsJxBRtUg8/Plfk2zE5YZcsWNpRRujjmOSPxTJMidMdQa99++vOWNVk2QM+erWlJChb2QQBYHFzASsbwieiXHUaMFXCUdRQVWs1HDqsxYkapSnF8GmnWDNr1hgQvxwg7PbnXwbLiuvchc5kQR3l7maUrjOGuvv98ZV09IwdWc12r0Igt9FM4y9/fqyw80LNl8G+4Uuxm/7Hzw4fqZsHzFpikACD2I1G30KFZth5AIQlWScFQ9Ezndg/PLx+q8pzPQd+iYV26N1JBm0UlyDKpjdPHJqqgDAUv8F8Pj0MpJg1AfA6SjmSnzLva2leAitxlyQHZoOEU2GyORhGu+iWn3SBu6BpDECs3wm6rG2y4O4D+WVphaNucmKu0zsd6tVCdcjtXv+iHlIT/dC/BOrh5BKI6zktR4JMHxA4cbuEEM0QKw0QdLuaGGfCx19+sc3a0NoHBcKclUyFggvYHVzJm0jH9vk+iZdfJq+sPAw4YfrZddUkHMO9meJIIjeFIz/7+r6XJW6sQ5ZYbPGPQuB35oA9ndCV/QanddSzfbbbMLB8u7h9B0qWC7IvHmtpVJwgeqaDVnkG4HyNXU9+be8FKv1gP88RZs1LDDSTY/jfb6gOlrtOZ5NQQJOsjvTvUkkcRJk0B5HKKYoZiwW6H9W1nbr+avLhP9Xupm0+v9g5CH3KbB6h9UsmaSUigNFSn8fdkcv4ZJ0kSCzgdiNBPnFcSPgJbfGjFELzDBU24OZGjoRTCk75JAXG27vEBx1UW0aL9eZpBxe2i/c/o1KH4YDGPrY5jKF6qYJu+UAWRefomO+pNic+ta0wO9vKH8gDp+sYwc+qJwa+4hOOOWw8Rc0xFPELO5hFEFAjnaLwKP9A2wYFp3WiWRm+oH3wgebAR9m/WMc1TDuXuIxjKHMVaQUSE6r82zXB1yeJb24zuV+OWw3qqXmvMFYW5wXcL2K2Gz5k1FF8j0P/OjlOLC1kuj3FIUndfmBpt91bYo9l8bVpxBZjFwcNLDoldyeDBL7kY1fpb7Ps3DkiCXh+pF9VRGGjv5QiIvGmDq+zc+l5mp33VfqYuSEKv0vfB4CNPoGlaS8phgjeVw6gWVlhb5No92CZu4 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2024 10:58:17.8937 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9312f6e8-41b0-4ded-d541-08dcccd07ba6 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6865 To ensure successive interrupts upon packet reception, it is necessary to clear the remote IRR bit by writing the interrupt number to the EOI register. The base address for this operation is provided by the BIOS and retrieved by the driver by traversing the ASF object's namespace. Co-developed-by: Sanket Goswami Signed-off-by: Sanket Goswami Signed-off-by: Shyam Sundar S K --- drivers/i2c/busses/i2c-piix4.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 789dbe832012..9337e9899330 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -188,6 +188,8 @@ struct sb800_mmio_cfg { }; struct sb800_asf_data { + resource_size_t eoi_addr; + resource_size_t eoi_sz; unsigned short addr; int irq; }; @@ -199,6 +201,7 @@ enum piix4_algo { }; struct i2c_piix4_adapdata { + void __iomem *eoi_base; unsigned short smba; /* SB800 */ @@ -1284,6 +1287,7 @@ static irqreturn_t sb800_asf_irq_handler(int irq, void *ptr) sb800_asf_update_bits(piix4_smba, SB800_ASF_SLV_INTR, SMBHSTSTS, true); } + iowrite32(irq, adapdata->eoi_base); return IRQ_HANDLED; } @@ -1298,6 +1302,10 @@ static int sb800_asf_acpi_resource_cb(struct acpi_resource *resource, void *cont case ACPI_RESOURCE_TYPE_IO: data->addr = resource->data.io.minimum; break; + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: + data->eoi_addr = resource->data.fixed_memory32.address; + data->eoi_sz = resource->data.fixed_memory32.address_length; + break; } return 0; @@ -1345,6 +1353,9 @@ static int sb800_asf_add_adap(struct pci_dev *dev) } INIT_DELAYED_WORK(&adapdata->work_buf, sb800_asf_process_slave); + adapdata->eoi_base = devm_ioremap(&dev->dev, data.eoi_addr, data.eoi_sz); + if (!adapdata->eoi_base) + return -ENOMEM; adapdata->is_asf = true; /* Increment the adapter count by 1 as ASF is added to the list */ piix4_adapter_count += 1;