From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id A623874003D for ; Wed, 7 Aug 2024 06:50:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=hJDcUWrxqvm1PB48hMNOAn52sM+4EHmSNAdy4x9+YnY=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1723013430; v=1; b=E/l+f3yXrHLkC5eK98tpL0j3qI9BbXchH8Mx34j5KSjpCD2ynCmxariijjs1qSN69rztgiOT GV1Rgf2PwxZZ54LziCFNYEVoGdIMAXA+TE2+RvewFW1n/6C+Nr3fKUSBGG3BD83etoHqSIBqHAl t/MStAvq2sCoUT2xqVXFANGsIZNKT5j4SdhOLBp+4bLYqwB8+NXm9EWBPIhTlce4MeQPEwW4ZI8 MC0tcWshQ4Dkmu1/eUta0tDVDdAz20rsFGLropXo/uC3hv/qETVnWYJa3rBE9+qpKxh6t0Nf18J vZthAJRaOm1acKX+bmmRAdH7E1HODD1aRQdEJmYbEVrhQ== X-Received: by 127.0.0.2 with SMTP id 3yyXYY7687511xvrgRGU5EaN; Tue, 06 Aug 2024 23:50:29 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.111]) by mx.groups.io with SMTP id smtpd.web10.27551.1723013428617532124 for ; Tue, 06 Aug 2024 23:50:28 -0700 X-Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by DS7PR01MB7664.prod.exchangelabs.com (2603:10b6:8:7b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.13; Wed, 7 Aug 2024 06:50:24 +0000 X-Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::fc79:e629:93aa:8b8f]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::fc79:e629:93aa:8b8f%3]) with mapi id 15.20.7807.026; Wed, 7 Aug 2024 06:50:24 +0000 From: "Nhi Pham via groups.io" To: devel@edk2.groups.io CC: quic_llindhol@quicinc.com, chuong@os.amperecomputing.com, rebecca@os.amperecomputing.com, nhi@os.amperecomputing.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 3/5] AmpereAltraPkg: Add SmbusHc PEI and DXE drivers Date: Wed, 7 Aug 2024 13:47:29 +0700 Message-ID: <20240807064731.4049764-4-nhi@os.amperecomputing.com> In-Reply-To: <20240807064731.4049764-1-nhi@os.amperecomputing.com> References: <20240807064731.4049764-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: SG3P274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::22) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7287:EE_|DS7PR01MB7664:EE_ X-MS-Office365-Filtering-Correlation-Id: ae1f97ef-918e-4ffa-1ffd-08dcb6ad36e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ybny3RI7xsbHMt+aLR3DWgQwmKDZmJnL8PpfrboVWl4EqGlZhIHHewmZKdZN?= =?us-ascii?Q?nOluP/QjgNiY1K3oX3ksEajYQdcCPE6KgIqBwz2L013U81aAmAOiMyfiQZI+?= =?us-ascii?Q?yBUDDRiLiRb7bqMv2lScJmYOo81MpKtfpO4Ky+zQ8/BsTkqa/cxCCpvRSOsj?= =?us-ascii?Q?H6aK//9pX4GDy9NdKELJUhg5YhSiCXviYDmLfOgIYz58X1tRRSxMJsGxrkxU?= =?us-ascii?Q?DbhrLvp39MeGxMQsI7miEOnvfieuCdQmm66W2LbQ9+AAXL+oZwt9llybiOHr?= =?us-ascii?Q?RoeUNsJY8Cw0OoWcW5/yTYmh8aVEIEc2m4cQYrblSfr6hBRcFdGy97FNWtuQ?= =?us-ascii?Q?LFHi35EOIZaP27gxYpPPeV1YOg+J1qF9xP7eCTzetM+QmyMh4nYW/WBpd3Q/?= =?us-ascii?Q?Fuk3INrNjlJvZtguUWzZ+9SS+mfUOuoYn93PvqsEKyAyTpHdL+l1mXYnq6kk?= =?us-ascii?Q?UV/s3QzmssecbJtRjYZEF4ucOrzJm6yCsOOVFy0ftiEq/FwYSpMp5lsw8KlX?= =?us-ascii?Q?a1mn+eFYqa9vvL+2gWHuHU3GW20bO3jhTni5hPQXrZK0CIfLta4AmUh8rUik?= =?us-ascii?Q?gvj3hhtM9zuq/ufoOjBj2J6xNm0v/rZmCRv7nm8rHDH4mrCqJNLlnzOfalTn?= =?us-ascii?Q?tfq6oHb1+MplTlEa0G1hsqdcbSY5llFwshG6e4DTMOt2hj65JZxmiLzbAGAW?= =?us-ascii?Q?cEo55xH3oyFAWiaKxjJhcxyRXNiKahT8cVPT2oM1WjBHWQ9Ly5iKpsJa0vPp?= =?us-ascii?Q?uGZuwlQ1FHuLdQctiZuwaUtv0+hpLuPFGUMKe/7qYJNgXCbLSzZOaVt017S2?= =?us-ascii?Q?iEdGTTEUkzSpN4xzEI7J5sQuZ5oEQ/AXIj7ll7EUoqa5UI9gS6R4T4PuVf3+?= =?us-ascii?Q?HxwBqGHkoJlAPRr6nBmfkj1LBRNDL+HBaWvIS4Pi59m9D1XmtYGXDMo/agQb?= =?us-ascii?Q?HFIa43Mt9XaSdmOY25CZoR0nx53gzTnA61sROQN8fS/4SfNHu4KyLUO+45kV?= =?us-ascii?Q?iMt0/jeHJJK+2a9oqgmbitQIiaNwMI3CgfEWem8jpSyneCu5D57v1+PtVYZ2?= =?us-ascii?Q?e54l3KePSviu7rjsE5XYQPsx3eGNxGG4kc6K631lg46pnfHBe3BSNzU7aWtG?= =?us-ascii?Q?rcoG01czyaX6KWrVRhglzUqGwlbR2y6Mei4m5gHzEhrDcjjkwUC2uD04XHDt?= =?us-ascii?Q?hiQymnXrOZ+KhDbb6APZb564IvtqVGUETz4DuFVuDvwN5R809r9LIgvwbFU3?= =?us-ascii?Q?nDWRHUgVUzCgLON/JiQ+kn+M+f7DIHmYySy0eewXtL0Y0W65fO3hgMzeyweB?= =?us-ascii?Q?7o/izdwuPzKkRMXJC5OPlVUVB5u07gQNail6Qa6plxdEKfDU0d/I1jv7BXxU?= =?us-ascii?Q?krSjozCo62LbhbfvCSrMcHhpt5ktGrXGdRAGjATNQ+RGTrjPkg=3D=3D?= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?R78sc2JTUklFcq/boBbR7GNenqIr5TZ7I6VgAMs5sOz28dJ+d3GMJqN+iuVP?= =?us-ascii?Q?bpof/2Of9ao59Uct0vaDsH6DKO9lrgpsQr6E9dsMyQ0jR7djgqftzYrahx5y?= =?us-ascii?Q?4eTOaUxpHmIcGfe4Dgw/8Hfoq5in9eh9iOisoxQ+SbxuZ1vUj335vHb1i7vp?= =?us-ascii?Q?olh+Y1EZA4DLEJ9nMwXvosu14ZkBTZdtPPVr5IxHYcoE5agJHHtlXlai4OEm?= =?us-ascii?Q?RM91ysuCDV5+fpiC6bl4j9vdLhHJvzEo37C9YwIJiO1eZxhxhANrlKZwqmjM?= =?us-ascii?Q?h5ZOcv2R03JXcH7X+0DAhNUujuJhQhICzgtSkXgV0gYLoLWOiQ0XvVOO3jMs?= =?us-ascii?Q?ylsfZ6bdU4+4aOUa052IAHX/kJ3dQv1pFWJ0v4bL6tMLtnQrbO24mrE1eW2q?= =?us-ascii?Q?+8wbTi0lFL7ViWs8/lJNBQ38X0jChFSov6uEN7H/NYeDnFKbqiQtSnQR4Bry?= =?us-ascii?Q?aaLDEuYp+m/CJwgk7+n6G7drYLYxe8fdm3cNI8K9DurDGS2pjLMVhZEHwIIN?= =?us-ascii?Q?YKgLJsCft+bqpz36wy2wg/jm3uuhXSuSw4h/sGmjcRVDjgELS7B1EhwKXGHE?= =?us-ascii?Q?sPdjW6vI5uLb1v2BP0sjxx7l/3qowc/4ahmghX+H50IJZ44D0IU3O5gyTHd5?= =?us-ascii?Q?TyzfzXdaGIvVYNAuQxY2Aj9YNmSMAzkQg+NnL4mt9aS7I16rrAmnwi/MrWaE?= =?us-ascii?Q?bgBlYoM1dgn+mHwO9JUAH8swsPWBg7KdRfAiUE6RjK7G/tw1VUNRxZpTYLGL?= =?us-ascii?Q?bdBWP0Pksm9/1Fq2dT1nguYSq/2eoj3JhLEtKwZxfwOumVILqJP+CpgF5OTA?= =?us-ascii?Q?pqn/72e2bmAhq1xW/0zWF43PA1XfOQMErodMJGmBnvqxaKYdW4fyaRM+j0cn?= =?us-ascii?Q?ECioyunocBxG92lAJDAEd4LYFDBmPx28F2aOWNp37LMabCKTD8DYjKzJgero?= =?us-ascii?Q?d7xiok1rIUKnB0UZk6DsQ6wESB3VjhILzbVPtdi9SeOVl6dqztTf5ePSt9/l?= =?us-ascii?Q?udvVex9Tp5pKSXoFuEOdgQvG2IRoePB97V/vwKK74pU8Fip19oeI/LCShxN3?= =?us-ascii?Q?lKHRsgLxlAQK53QB1nhG3TaVoIKiDPCHkNbRGXis0viKe5pLuopJ6IAEjrWr?= =?us-ascii?Q?eTbxFmDpnvJwCgMkYgQer6zNlL0wG0FtRvQi9bnh1D6dOgzS+XbS0CL8Tm0L?= =?us-ascii?Q?VUkezJSKxqpjuj51zrbXilHfq3oaM8SciENQxX0bImrVKs1vrkb1b8r1C152?= =?us-ascii?Q?v0qra1hdzf0+4V0aTFy4FVhwwwhXyXMQ+WDbV7k25tYFWJWhd9YOo6BMOiov?= =?us-ascii?Q?MMDbVp73USOocmArf4V5AzdMZL6Sz+HP1qkTj2VgvMG62PXRw4kmLpOWnrZi?= =?us-ascii?Q?HEkJRSq5xDCxh0uYjhLrmhiCoa3+ALcAzEpokYVUiN4hzl3dO5i9MZ/rSfDx?= =?us-ascii?Q?nYia3ZFjndb4cjj77BQ8RdEo7zO5yMB75C6WxWM9MmpORIzWBIM1PgmCIDM0?= =?us-ascii?Q?DjBfibhCxDnixtiqeAqPeNkh5U1dR3yz8Alhuw9MK0r9QhEpa7oJOYx9D9Zg?= =?us-ascii?Q?1UobUOOb1hvfO6WF2DO8/SIuGAVaQs5KMSpdltZG0tETWRp1cFSyF5gGhbkl?= =?us-ascii?Q?xhQLCF8IL3wavYNG7ye230E=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae1f97ef-918e-4ffa-1ffd-08dcb6ad36e7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2024 06:50:24.8996 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dnU1IYDqT7dB4/6eZRsQLksE7g/aBsfjq50jIfKuvy833IVVoLLTscWfv/ImPiMWtAdA0rNnCiKbnvS6lDUHIkUe8Q8ewQDU433l8KcXFI0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR01MB7664 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 06 Aug 2024 23:50:28 -0700 Resent-From: nhi@os.amperecomputing.com Reply-To: devel@edk2.groups.io,nhi@os.amperecomputing.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ZnfPcXAxzHwI84j2H2ExuIr3x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="E/l+f3yX"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io This adds the implementation of SMBUS PPI and Protocol to produce SMBUS interface in both PEI and DXE phases for use by IPMI SSIF. Signed-off-by: Nhi Pham --- Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.inf | 43 +++ Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.inf | 43 +++ Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.h | 95 ++++++= + Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.c | 261 ++++++= ++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.c | 277 ++++++= ++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.c | 263 ++++++= +++++++++++++ 6 files changed, 982 insertions(+) diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.inf b= /Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.inf new file mode 100644 index 000000000000..7e8c8176658e --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.inf @@ -0,0 +1,43 @@ +## @file +# +# Copyright (c) 2024, Ampere Computing LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SmbusHcDxe + FILE_GUID =3D A92C6874-B59E-49A7-957D-8511C9D8520E + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeSmbus + +[Sources] + SmbusHcCommon.c + SmbusHcDxe.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + GpioLib + I2cLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Protocols] + gEfiSmbusHcProtocolGuid # PRODUCES + +[Pcd] + gAmpereTokenSpaceGuid.PcdSmbusI2cBusNumber + gAmpereTokenSpaceGuid.PcdSmbusI2cBusSpeed + +[Depex] + TRUE diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.inf b= /Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.inf new file mode 100644 index 000000000000..810a583feab3 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.inf @@ -0,0 +1,43 @@ +## @file +# +# Copyright (c) 2024, Ampere Computing LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SmbusHcPeim + FILE_GUID =3D 1D770ACE-36E9-4B74-B548-4F423B60A26C + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeSmbusPeim + +[Sources] + SmbusHcCommon.c + SmbusHcPei.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + GpioLib + I2cLib + PeimEntryPoint + PeiServicesLib + +[Ppis] + gEfiPeiSmbus2PpiGuid # PRODUCES + +[Pcd] + gAmpereTokenSpaceGuid.PcdSmbusI2cBusNumber + gAmpereTokenSpaceGuid.PcdSmbusI2cBusSpeed + +[Depex] + TRUE diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.h = b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.h new file mode 100644 index 000000000000..db19d50b0f2a --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.h @@ -0,0 +1,95 @@ +/** @file + + Copyright (c) 2024, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef SMBUS_HC_COMMON_LIB_H_ +#define SMBUS_HC_COMMON_LIB_H_ + +#include +#include +#include + +// +// I2C Based SMBus info +// +#define I2C_BUS_NUMBER (FixedPcdGet8 (PcdSmbusI2cBusNumber)) +#define I2C_BUS_SPEED (FixedPcdGet32 (PcdSmbusI2cBusSpeed)) +#define I2C_WRITE_ADDRESS(Addr) ((Addr) << 1 | 0) +#define I2C_READ_ADDRESS(Addr) ((Addr) << 1 | 1) + +// +// SMBus 2.0 +// +#define SMBUS_MAX_BLOCK_LENGTH 0x20 +#define SMBUS_READ_TEMP_LENGTH (SMBUS_MAX_BLOCK_LENGTH + 2) // Length += 32 Bytes + PEC +#define SMBUS_WRITE_TEMP_LENGTH (SMBUS_MAX_BLOCK_LENGTH + 3) // CMD + Le= ngth + 32 Bytes + PEC + +// +// SMBus PEC +// +#define CRC8_POLYNOMINAL_KEY 0x107 // X^8 + X^2 + X + 1 + +/** + Executes an SMBus operation to an SMBus controller. Returns when either = the command has been + executed or an error is encountered in doing the operation. + + The Execute() function provides a standard way to execute an operation a= s defined in the System + Management Bus (SMBus) Specification. The resulting transaction will be = either that the SMBus + slave devices accept this transaction or that this function returns with= error. + + @param This A pointer to the EFI_SMBUS_HC_PROTOCOL i= nstance. + @param SlaveAddress The SMBus slave address of the device wi= th which to communicate. + @param Command This command is transmitted by the SMBus= host controller to the + SMBus slave device and the interpretatio= n is SMBus slave device + specific. It can mean the offset to a li= st of functions inside an + SMBus slave device. Not all operations o= r slave devices support + this command's registers. + @param Operation Signifies which particular SMBus hardwar= e protocol instance that + it will use to execute the SMBus transac= tions. This SMBus + hardware protocol is defined by the SMBu= s Specification and is + not related to EFI. + @param PecCheck Defines if Packet Error Code (PEC) check= ing is required for this + operation. + @param Length Signifies the number of bytes that this = operation will do. The + maximum number of bytes can be revision = specific and operation + specific. This field will contain the ac= tual number of bytes that + are executed for this operation. Not all= operations require this + argument. + @param Buffer Contains the value of data to execute to= the SMBus slave device. + Not all operations require this argument= . The length of this + buffer is identified by Length. + + @retval EFI_SUCCESS The last data that was returned from the= access matched the poll + exit criteria. + @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrec= t). + @retval EFI_TIMEOUT Timeout expired before the operation was= completed. Timeout is + determined by the SMBus host controller = device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due t= o a lack of resources. + @retval EFI_DEVICE_ERROR The request was not completed because a = failure that was + reflected in the Host Status Register bi= t. Device errors are a + result of a transaction collision, illeg= al command field, + unclaimed cycle (host initiated), or bus= errors (collisions). + @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OP= ERATION. + @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations exc= ept for EfiSmbusQuickRead + and EfiSmbusQuickWrite. Length is outsid= e the range of valid + values. + @retval EFI_UNSUPPORTED The SMBus operation or PEC is not suppor= ted. + @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operat= ion. + +**/ +EFI_STATUS +EFIAPI +SmbusHcCommonExecute ( + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ); + +#endif /* SMBUS_HC_COMMON_LIB_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.c = b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.c new file mode 100644 index 000000000000..adce5c02cf95 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcCommon.c @@ -0,0 +1,261 @@ +/** @file + SmbusHcCommon implement common api for SmbusHc + + Copyright (c) 2024, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include "SmbusHcCommon.h" + +/** + Incremental calculate Pec base on previous Pec value and CRC8 of data ar= ray + pointed to by Buffer + + @param Pec Previous Pec + @param Buffer Pointer to data array + @param Length Array count + + @retval Pec + +**/ +UINT8 +CalculatePec ( + UINT8 Pec, + UINT8 *Buffer, + UINT32 Length + ) +{ + UINT8 Offset, Index; + + for (Offset =3D 0; Offset < Length; Offset++) { + Pec ^=3D Buffer[Offset]; + for (Index =3D 0; Index < 8; Index++) { + if ((Pec & 0x80) !=3D 0) { + Pec =3D (UINT8)((Pec << 1) ^ CRC8_POLYNOMINAL_KEY); + } else { + Pec <<=3D 1; + } + } + } + + return Pec & 0xFF; +} + +/** + Executes an SMBus operation to an SMBus controller. Returns when either = the command has been + executed or an error is encountered in doing the operation. + + The Execute() function provides a standard way to execute an operation a= s defined in the System + Management Bus (SMBus) Specification. The resulting transaction will be = either that the SMBus + slave devices accept this transaction or that this function returns with= error. + + @param SlaveAddress The SMBus slave address of the device wi= th which to communicate. + @param Command This command is transmitted by the SMBus= host controller to the + SMBus slave device and the interpretatio= n is SMBus slave device + specific. It can mean the offset to a li= st of functions inside an + SMBus slave device. Not all operations o= r slave devices support + this command's registers. + @param Operation Signifies which particular SMBus hardwar= e protocol instance that + it will use to execute the SMBus transac= tions. This SMBus + hardware protocol is defined by the SMBu= s Specification and is + not related to EFI. + @param PecCheck Defines if Packet Error Code (PEC) check= ing is required for this + operation. + @param Length Signifies the number of bytes that this = operation will do. The + maximum number of bytes can be revision = specific and operation + specific. This field will contain the ac= tual number of bytes that + are executed for this operation. Not all= operations require this + argument. + @param Buffer Contains the value of data to execute to= the SMBus slave device. + Not all operations require this argument= . The length of this + buffer is identified by Length. + + @retval EFI_SUCCESS The last data that was returned from the= access matched the poll + exit criteria. + @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrec= t). + @retval EFI_TIMEOUT Timeout expired before the operation was= completed. Timeout is + determined by the SMBus host controller = device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due t= o a lack of resources. + @retval EFI_DEVICE_ERROR The request was not completed because a = failure that was + reflected in the Host Status Register bi= t. Device errors are a + result of a transaction collision, illeg= al command field, + unclaimed cycle (host initiated), or bus= errors (collisions). + @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OP= ERATION. + @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations exc= ept for EfiSmbusQuickRead + and EfiSmbusQuickWrite. Length is outsid= e the range of valid + values. + @retval EFI_UNSUPPORTED The SMBus operation or PEC is not suppor= ted. + @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operat= ion. + +**/ +EFI_STATUS +EFIAPI +SmbusHcCommonExecute ( + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINTN DataLen, Idx; + UINT8 ReadTemp[SMBUS_READ_TEMP_LENGTH]; + UINT8 WriteTemp[SMBUS_WRITE_TEMP_LENGTH]; + UINT8 CrcTemp[10]; + UINT8 Pec; + + if ( ((Operation !=3D EfiSmbusQuickRead) && (Operation !=3D EfiSmbusQui= ckWrite)) + && ((Length =3D=3D NULL) || (Buffer =3D=3D NULL))) + { + return EFI_INVALID_PARAMETER; + } + + // + // Switch to correct I2C bus and speed + // + Status =3D I2cProbe (I2C_BUS_NUMBER, I2C_BUS_SPEED, TRUE, PecCheck); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + // + // Process Operation + // + switch (Operation) { + case EfiSmbusWriteBlock: + if (*Length > SMBUS_MAX_BLOCK_LENGTH) { + return EFI_INVALID_PARAMETER; + } + + WriteTemp[0] =3D Command; + WriteTemp[1] =3D *Length; + CopyMem (&WriteTemp[2], Buffer, *Length); + DataLen =3D *Length + 2; + + // + // PEC handling + // + if (PecCheck) { + CrcTemp[0] =3D I2C_WRITE_ADDRESS (SlaveAddress.SmbusDeviceAddress)= ; + Pec =3D CalculatePec (0, &CrcTemp[0], 1); + Pec =3D CalculatePec (Pec, WriteTemp, DataLen); + DEBUG ((DEBUG_VERBOSE, "\nWriteBlock PEC =3D 0x%x \n", Pec)); + WriteTemp[DataLen] =3D Pec; + DataLen +=3D 1; + } + + DEBUG ((DEBUG_VERBOSE, "W %d: ", DataLen)); + for (Idx =3D 0; Idx < DataLen; Idx++) { + DEBUG ((DEBUG_VERBOSE, "0x%x ", WriteTemp[Idx])); + } + + DEBUG ((DEBUG_VERBOSE, "\n")); + + Status =3D I2cWrite ( + I2C_BUS_NUMBER, + SlaveAddress.SmbusDeviceAddress, + WriteTemp, + (UINT32 *)&DataLen + ); + if (EFI_ERROR (Status)) { + if (Status !=3D EFI_TIMEOUT) { + Status =3D EFI_DEVICE_ERROR; + } + } + + break; + + case EfiSmbusReadBlock: + WriteTemp[0] =3D Command; + DataLen =3D *Length + 2; // +1 byte for Data Length +1 byte for= PEC + Status =3D I2cRead ( + I2C_BUS_NUMBER, + SlaveAddress.SmbusDeviceAddress, + WriteTemp, + 1, + ReadTemp, + (UINT32 *)&DataLen + ); + if (EFI_ERROR (Status)) { + if (Status !=3D EFI_TIMEOUT) { + Status =3D EFI_DEVICE_ERROR; + } + + *Length =3D 0; + break; + } + + DEBUG ((DEBUG_VERBOSE, "R %d: ", DataLen)); + for (Idx =3D 0; Idx < DataLen; Idx++) { + DEBUG ((DEBUG_VERBOSE, "0x%x ", ReadTemp[Idx])); + } + + DEBUG ((DEBUG_VERBOSE, "\n")); + + DataLen =3D ReadTemp[0]; + + // + // PEC handling + // + if (PecCheck) { + CrcTemp[0] =3D I2C_WRITE_ADDRESS (SlaveAddress.SmbusDeviceAddress)= ; + CrcTemp[1] =3D Command; + CrcTemp[2] =3D I2C_READ_ADDRESS (SlaveAddress.SmbusDeviceAddress); + + Pec =3D CalculatePec (0, &CrcTemp[0], 3); + Pec =3D CalculatePec (Pec, ReadTemp, DataLen + 1); + + if (Pec !=3D ReadTemp[DataLen + 1]) { + DEBUG ((DEBUG_ERROR, "ReadBlock PEC cal =3D 0x%x !=3D 0x%x\n", P= ec, ReadTemp[DataLen + 1])); + return EFI_CRC_ERROR; + } else { + DEBUG ((DEBUG_VERBOSE, "ReadBlock PEC 0x%x\n", ReadTemp[DataLen = + 1])); + } + } + + if ((DataLen =3D=3D 0) || (DataLen > SMBUS_MAX_BLOCK_LENGTH)) { + DEBUG ((DEBUG_ERROR, "%a: Invalid length =3D %d\n", __func__, Data= Len)); + *Length =3D 0; + Status =3D EFI_INVALID_PARAMETER; + } else if (DataLen > *Length) { + DEBUG ((DEBUG_ERROR, "%a: Buffer too small\n", __func__)); + *Length =3D 0; + Status =3D EFI_BUFFER_TOO_SMALL; + } else { + *Length =3D DataLen; + CopyMem (Buffer, &ReadTemp[1], DataLen); + } + + break; + + case EfiSmbusQuickRead: + case EfiSmbusQuickWrite: + case EfiSmbusReceiveByte: + case EfiSmbusSendByte: + case EfiSmbusReadByte: + case EfiSmbusWriteByte: + case EfiSmbusReadWord: + case EfiSmbusWriteWord: + case EfiSmbusProcessCall: + case EfiSmbusBWBRProcessCall: + DEBUG ((DEBUG_ERROR, "%a: Unsupported command\n", __func__)); + Status =3D EFI_UNSUPPORTED; + break; + + default: + Status =3D EFI_INVALID_PARAMETER; + } + + return Status; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.c b/S= ilicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.c new file mode 100644 index 000000000000..49a16a2c3d7e --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcDxe.c @@ -0,0 +1,277 @@ +/** SmbusHc protocol implementation follows SMBus 2.0 specification. + + Copyright (c) 2024, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include "SmbusHcCommon.h" + +// +// Handle to install SMBus Host Controller protocol. +// +EFI_HANDLE mSmbusHcHandle =3D NULL; + +/** + Executes an SMBus operation to an SMBus controller. Returns when either = the command has been + executed or an error is encountered in doing the operation. + + The Execute() function provides a standard way to execute an operation a= s defined in the System + Management Bus (SMBus) Specification. The resulting transaction will be = either that the SMBus + slave devices accept this transaction or that this function returns with= error. + + @param This A pointer to the EFI_SMBUS_HC_PROTOCOL i= nstance. + @param SlaveAddress The SMBus slave address of the device wi= th which to communicate. + @param Command This command is transmitted by the SMBus= host controller to the + SMBus slave device and the interpretatio= n is SMBus slave device + specific. It can mean the offset to a li= st of functions inside an + SMBus slave device. Not all operations o= r slave devices support + this command's registers. + @param Operation Signifies which particular SMBus hardwar= e protocol instance that + it will use to execute the SMBus transac= tions. This SMBus + hardware protocol is defined by the SMBu= s Specification and is + not related to EFI. + @param PecCheck Defines if Packet Error Code (PEC) check= ing is required for this + operation. + @param Length Signifies the number of bytes that this = operation will do. The + maximum number of bytes can be revision = specific and operation + specific. This field will contain the ac= tual number of bytes that + are executed for this operation. Not all= operations require this + argument. + @param Buffer Contains the value of data to execute to= the SMBus slave device. + Not all operations require this argument= . The length of this + buffer is identified by Length. + + @retval EFI_SUCCESS The last data that was returned from the= access matched the poll + exit criteria. + @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrec= t). + @retval EFI_TIMEOUT Timeout expired before the operation was= completed. Timeout is + determined by the SMBus host controller = device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due t= o a lack of resources. + @retval EFI_DEVICE_ERROR The request was not completed because a = failure that was + reflected in the Host Status Register bi= t. Device errors are a + result of a transaction collision, illeg= al command field, + unclaimed cycle (host initiated), or bus= errors (collisions). + @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OP= ERATION. + @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations exc= ept for EfiSmbusQuickRead + and EfiSmbusQuickWrite. Length is outsid= e the range of valid + values. + @retval EFI_UNSUPPORTED The SMBus operation or PEC is not suppor= ted. + @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operat= ion. + +**/ +EFI_STATUS +EFIAPI +SmbusHcExecute ( + IN CONST EFI_SMBUS_HC_PROTOCOL *This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + EFI_TPL OldTpl; + + ASSERT (This !=3D NULL); + + OldTpl =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); + + Status =3D SmbusHcCommonExecute (SlaveAddress, Command, Operation, PecCh= eck, Length, Buffer); + + gBS->RestoreTPL (OldTpl); + + return Status; +} + +/** + + The SmbusHcArpDevice() function provides a standard way for a device dri= ver to + enumerate the entire SMBus or specific devices on the bus. + + @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance. + + @param ArpAll A Boolean expression that indicates if the + host drivers need to enumerate all the devices + or enumerate only the device that is + identified by SmbusUdid. If ArpAll is TRUE, + SmbusUdid and SlaveAddress are optional. If + ArpAll is FALSE, ArpDevice will enumerate + SmbusUdid and the address will be at + SlaveAddress. + + @param SmbusUdid The Unique Device Identifier (UDID) that is + associated with this device. Type + EFI_SMBUS_UDID is defined in + EFI_PEI_SMBUS_PPI.ArpDevice() in the + Platform Initialization SMBus PPI + Specification. + + @param SlaveAddress The SMBus slave address that is + associated with an SMBus UDID. + + @retval EFI_SUCCESS The last data that was returned from the + access matched the poll exit criteria. + + @retval EFI_CRC_ERROR Checksum is not correct (PEC is + incorrect). + + @retval EFI_TIMEOUT Timeout expired before the operation was + completed. Timeout is determined by the + SMBus host controller device. + + @retval EFI_OUT_OF_RESOURCES The request could not be + completed due to a lack of + resources. + + @retval EFI_DEVICE_ERROR The request was not completed + because a failure was reflected in + the Host Status Register bit. Device + Errors are a result of a transaction + collision, illegal command field, + unclaimed cycle (host initiated), or + bus errors (collisions). + + @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are + not implemented by this driver. + +**/ +EFI_STATUS +EFIAPI +SmbusHcArpDevice ( + IN CONST EFI_SMBUS_HC_PROTOCOL *This, + IN BOOLEAN ArpAll, + IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL + IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL + ) +{ + // + // Not supported + // + return EFI_UNSUPPORTED; +} + +/** + The SmbusHcGetArpMap() function returns the mapping of all the SMBus dev= ices + that were enumerated by the SMBus host driver. + + @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance. + + @param Length Size of the buffer that contains the SMBus + device map. + + @param SmbusDeviceMap The pointer to the device map as + enumerated by the SMBus controller + driver. + + @retval EFI_SUCCESS The SMBus returned the current device map. + + @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are + not implemented by this driver. + +**/ +EFI_STATUS +EFIAPI +SmbusHcGetArpMap ( + IN CONST EFI_SMBUS_HC_PROTOCOL *This, + IN OUT UINTN *Length, + IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap + ) +{ + // + // Not supported + // + return EFI_UNSUPPORTED; +} + +/** + + The SmbusHcNotify() function registers all the callback functions to + allow the bus driver to call these functions when the + SlaveAddress/Data pair happens. + + @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance. + + @param SlaveAddress Address that the host controller detects + as sending a message and calls all the registere= d function. + + @param Data Data that the host controller detects as sending + message and calls all the registered function. + + + @param NotifyFunction The function to call when the bus + driver detects the SlaveAddress and + Data pair. + + @retval EFI_SUCCESS NotifyFunction was registered. + + @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are + not implemented by this driver. + +**/ +EFI_STATUS +EFIAPI +SmbusHcNotify ( + IN CONST EFI_SMBUS_HC_PROTOCOL *This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data, + IN EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction + ) +{ + // + // Not supported + // + return EFI_UNSUPPORTED; +} + +// +// Interface defintion of SMBUS Host Controller Protocol. +// +EFI_SMBUS_HC_PROTOCOL mSmbusHcProtocol =3D { + SmbusHcExecute, + SmbusHcArpDevice, + SmbusHcGetArpMap, + SmbusHcNotify +}; + +/** + SmbusHc driver entry point + + @param[in] ImageHandle ImageHandle of this module + @param[in] SystemTable EFI System Table + + @retval EFI_SUCCESS Driver initializes successfully + @retval Other values Some error occurred +**/ +EFI_STATUS +InitializeSmbus ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Install Smbus protocol + // + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &mSmbusHcHandle, + &gEfiSmbusHcProtocolGuid, + &mSmbusHcProtocol, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.c b/S= ilicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.c new file mode 100644 index 000000000000..39483a2a602a --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/SmbusHc/SmbusHcPei.c @@ -0,0 +1,263 @@ +/** @file + SmbusHc protocol implementation follows SMBus 2.0 specification. + + Copyright (c) 2024, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +#include "SmbusHcCommon.h" + +/** + Executes an SMBus operation to an SMBus controller. Returns when either = the command has been + executed or an error is encountered in doing the operation. + + The Execute() function provides a standard way to execute an operation a= s defined in the System + Management Bus (SMBus) Specification. The resulting transaction will be = either that the SMBus + slave devices accept this transaction or that this function returns with= error. + + @param This A pointer to the EFI_PEI_SMBUS2_PPI inst= ance. + @param SlaveAddress The SMBus slave address of the device wi= th which to communicate. + @param Command This command is transmitted by the SMBus= host controller to the + SMBus slave device and the interpretatio= n is SMBus slave device + specific. It can mean the offset to a li= st of functions inside an + SMBus slave device. Not all operations o= r slave devices support + this command's registers. + @param Operation Signifies which particular SMBus hardwar= e protocol instance that + it will use to execute the SMBus transac= tions. This SMBus + hardware protocol is defined by the SMBu= s Specification and is + not related to EFI. + @param PecCheck Defines if Packet Error Code (PEC) check= ing is required for this + operation. + @param Length Signifies the number of bytes that this = operation will do. The + maximum number of bytes can be revision = specific and operation + specific. This field will contain the ac= tual number of bytes that + are executed for this operation. Not all= operations require this + argument. + @param Buffer Contains the value of data to execute to= the SMBus slave device. + Not all operations require this argument= . The length of this + buffer is identified by Length. + + @retval EFI_SUCCESS The last data that was returned from the= access matched the poll + exit criteria. + @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrec= t). + @retval EFI_TIMEOUT Timeout expired before the operation was= completed. Timeout is + determined by the SMBus host controller = device. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due t= o a lack of resources. + @retval EFI_DEVICE_ERROR The request was not completed because a = failure that was + reflected in the Host Status Register bi= t. Device errors are a + result of a transaction collision, illeg= al command field, + unclaimed cycle (host initiated), or bus= errors (collisions). + @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OP= ERATION. + @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations exc= ept for EfiSmbusQuickRead + and EfiSmbusQuickWrite. Length is outsid= e the range of valid + values. + @retval EFI_UNSUPPORTED The SMBus operation or PEC is not suppor= ted. + @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operat= ion. + +**/ +EFI_STATUS +EFIAPI +SmbusHcExecute ( + IN CONST EFI_PEI_SMBUS2_PPI *This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ) +{ + ASSERT (This !=3D NULL); + return SmbusHcCommonExecute (SlaveAddress, Command, Operation, PecCheck,= Length, Buffer); +} + +/** + + The SmbusHcArpDevice() function provides a standard way for a device dri= ver to + enumerate the entire SMBus or specific devices on the bus. + + @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. + + @param ArpAll A Boolean expression that indicates if the + host drivers need to enumerate all the devices + or enumerate only the device that is + identified by SmbusUdid. If ArpAll is TRUE, + SmbusUdid and SlaveAddress are optional. If + ArpAll is FALSE, ArpDevice will enumerate + SmbusUdid and the address will be at + SlaveAddress. + + @param SmbusUdid The Unique Device Identifier (UDID) that is + associated with this device. Type + EFI_SMBUS_UDID is defined in + EFI_PEI_SMBUS_PPI.ArpDevice() in the + Platform Initialization SMBus PPI + Specification. + + @param SlaveAddress The SMBus slave address that is + associated with an SMBus UDID. + + @retval EFI_SUCCESS The last data that was returned from the + access matched the poll exit criteria. + + @retval EFI_CRC_ERROR Checksum is not correct (PEC is + incorrect). + + @retval EFI_TIMEOUT Timeout expired before the operation was + completed. Timeout is determined by the + SMBus host controller device. + + @retval EFI_OUT_OF_RESOURCES The request could not be + completed due to a lack of + resources. + + @retval EFI_DEVICE_ERROR The request was not completed + because a failure was reflected in + the Host Status Register bit. Device + Errors are a result of a transaction + collision, illegal command field, + unclaimed cycle (host initiated), or + bus errors (collisions). + + @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are + not implemented by this driver. + +**/ +EFI_STATUS +EFIAPI +SmbusHcArpDevice ( + IN CONST EFI_PEI_SMBUS2_PPI *This, + IN BOOLEAN ArpAll, + IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL + IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL + ) +{ + // + // Not supported + // + return EFI_UNSUPPORTED; +} + +/** + The SmbusHcGetArpMap() function returns the mapping of all the SMBus dev= ices + that were enumerated by the SMBus host driver. + + @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. + + @param Length Size of the buffer that contains the SMBus + device map. + + @param SmbusDeviceMap The pointer to the device map as + enumerated by the SMBus controller + driver. + + @retval EFI_SUCCESS The SMBus returned the current device map. + + @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are + not implemented by this driver. + +**/ +EFI_STATUS +EFIAPI +SmbusHcGetArpMap ( + IN CONST EFI_PEI_SMBUS2_PPI *This, + IN OUT UINTN *Length, + IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap + ) +{ + // + // Not supported + // + return EFI_UNSUPPORTED; +} + +/** + + The SmbusHcNotify() function registers all the callback functions to + allow the bus driver to call these functions when the + SlaveAddress/Data pair happens. + + @param This A pointer to the EFI_PEI_SMBUS2_PPI instance. + + @param SlaveAddress Address that the host controller detects + as sending a message and calls all the registere= d function. + + @param Data Data that the host controller detects as sending + message and calls all the registered function. + + + @param NotifyFunction The function to call when the bus + driver detects the SlaveAddress and + Data pair. + + @retval EFI_SUCCESS NotifyFunction was registered. + + @retval EFI_UNSUPPORTED ArpDevice, GetArpMap, and Notify are + not implemented by this driver. + +**/ +EFI_STATUS +EFIAPI +SmbusHcNotify ( + IN CONST EFI_PEI_SMBUS2_PPI *This, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN UINTN Data, + IN EFI_PEI_SMBUS_NOTIFY2_FUNCTION NotifyFunction + ) +{ + // + // Not supported + // + return EFI_UNSUPPORTED; +} + +// +// Interface defintion of SMBUS Host Controller Protocol. +// +EFI_PEI_SMBUS2_PPI mSmbusHcPpi =3D { + SmbusHcExecute, + SmbusHcArpDevice, + SmbusHcGetArpMap, + SmbusHcNotify +}; + +EFI_PEI_PPI_DESCRIPTOR gPpiSmbusHcPpiList =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiSmbus2PpiGuid, + &mSmbusHcPpi +}; + +/** + SmbusHc driver entry point + + @param[in] ImageHandle ImageHandle of this module + @param[in] PeiServices An indirect pointer to the PEI Services = Table + published by the PEI Foundation. + + @retval EFI_SUCCESS Driver initializes successfully + @retval Other values Some error occurred +**/ +EFI_STATUS +EFIAPI +InitializeSmbusPeim ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + + // + // Install Smbus Ppi + // + Status =3D PeiServicesInstallPpi (&gPpiSmbusHcPpiList); + ASSERT_EFI_ERROR (Status); + + return Status; +} --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120264): https://edk2.groups.io/g/devel/message/120264 Mute This Topic: https://groups.io/mt/107765355/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-