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: 825399 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pTtG/W9M" 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/sK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4FoITTVIlSmLW4NN8cUBq8Y6foA2MJbDJ8orxFUTOehDCTRiGFCQ+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); }