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 42C5FAC1DC9 for ; Thu, 2 May 2024 04:25:36 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=jVT5+Zl5LaruFsuom4j0UwInmqqzODV5K6zTZJXEREI=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels: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-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1714623934; v=1; b=s5nPa7O8w1O3bShIHBqXOhEHj+johAp2cXD+HRDJhisJDT3GXX+TK8EudvqOE2hNX1B0fOyD YtSE46sQsDEkz6bH7QLhv9B2uFjSLkqOCtejEdO78n39zc7wXZ/H7UPmavovS1GewV2zN8t7fTV eq/s6YZyRDupdxVhM/sZTOLNZ1vjlYF6COMR+rHgkTFfrD5pp6E2R/HWq0EO6IH9kE1ex8DM0hJ WKQcw5kHe2Nl8oMRU0XGnMkZtYwkTg08tWXbfFSkPa4lAVsYB0EpgM8zUBVPeSZHIQriaTWCVBx 5VigHJdFWw5E+vGtdAgaFx6kuXd8ERQ0Xsf7zSuS7PJ+g== X-Received: by 127.0.0.2 with SMTP id D1ItYY7687511xHdA9VEuWtR; Wed, 01 May 2024 21:25:34 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.80]) by mx.groups.io with SMTP id smtpd.web11.5806.1714623933843709391 for ; Wed, 01 May 2024 21:25:34 -0700 X-Received: from LV8PR12MB9452.namprd12.prod.outlook.com (2603:10b6:408:200::8) by PH8PR12MB7279.namprd12.prod.outlook.com (2603:10b6:510:221::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.40; Thu, 2 May 2024 04:25:31 +0000 X-Received: from LV8PR12MB9452.namprd12.prod.outlook.com ([fe80::e006:4173:de2c:aca0]) by LV8PR12MB9452.namprd12.prod.outlook.com ([fe80::e006:4173:de2c:aca0%5]) with mapi id 15.20.7519.031; Thu, 2 May 2024 04:25:31 +0000 From: "Chang, Abner via groups.io" To: "Chesley, Brit" , "devel@edk2.groups.io" CC: "Attar, AbdulLateef (Abdul Lateef)" Subject: Re: [edk2-devel] [PATCH v1 5/6] MdeModulePkg: SpiHc: SpiHc Drivers Thread-Topic: [PATCH v1 5/6] MdeModulePkg: SpiHc: SpiHc Drivers Thread-Index: AQHam/qY4F344ven8k20XU4AANTBLbGDWYaA Date: Thu, 2 May 2024 04:25:30 +0000 Message-ID: References: <20240501190527.200937-1-brit.chesley@amd.com> <20240501190527.200937-6-brit.chesley@amd.com> In-Reply-To: <20240501190527.200937-6-brit.chesley@amd.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=144f2040-23d5-4dda-aef6-051e6c1ced8e;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2024-05-02T04:25:19Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: LV8PR12MB9452:EE_|PH8PR12MB7279:EE_ x-ms-office365-filtering-correlation-id: 7b0cbe10-05c9-42e6-62ba-08dc6a5fe704 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?b3U+YigD9MQd+hm1srSwch/wJzLjELPrWfIv7Nf6DqkqCpcwZIHxo3cv9rVN?= =?us-ascii?Q?r5r6l+R0pwGL2iE5BHA4xx24kLb+tetUOthiyCSSqbS5Ea+n474HiEpryseR?= =?us-ascii?Q?bKR2sul4RaLWhqE6Hb7w7V9NfbGnk5rDDAJ5pAQNq828DXngwbHzVoIEwZjC?= =?us-ascii?Q?HVjQELZK1kOKDRW7feyGtMn39R2bBoMvhiwCMON9HuWHvDTKfKgtxbs05iZ8?= =?us-ascii?Q?j5BPE2M2bV0LFBAW0DPs2u0QHFkCu3hWBKwiMMR58Pa7KlaEesTFD+PwHk6M?= =?us-ascii?Q?zOqUqgm+dZ5dFaFDdT9wjCj4sUv/K1Xai8t+TPkoA5Ifu6RqPogB9dQ5T1A2?= =?us-ascii?Q?inrNTBKXN5yhBd4H5e/OzM9ToBcNcyH94lW+UUWH/KedMT8HugglHkElKqVs?= =?us-ascii?Q?///1g1yP0+pLmSYntg2eC6crq1DCeQHlMAnJPzu0sppOs+t+K133CrIQRT6A?= =?us-ascii?Q?ODspVQ+C19mBnMYi0p/h9VP1zCwkzQGjKtbFlMzxtBctbcMB3Ug3i9c/uSZ2?= =?us-ascii?Q?IBzywk7Ndne/MLRf+CqbOU+jVWIgmWTzqrt4r9pcb3LLfBlJOn6kgWjxuVk9?= =?us-ascii?Q?oeoZjI/WY4o5OG7u+M49WKxY8gAKrL7E6LAQDH8tw4sl8295rOLOZSqKhQ+f?= =?us-ascii?Q?KkF0iM8d8elcL9zW6ywfOP0s5DYhJoaPxdvrt3GYIpKOGyBYlp3W3MzwVmMY?= =?us-ascii?Q?eJiCydSg+A/zJSNdwTivZ0ch3FSsCT3ovIAU0PnMGw3oSLXf/GYfyvSHYDPT?= =?us-ascii?Q?9sEHJk1JF6aHa5ISC423fKVQdmwBM9PRojuz2GjRHYyyUuFv4Yb4ErNzkdl1?= =?us-ascii?Q?gkDkP1YWNdRVWLlCQKqj9YdvxYjcTDwQfO64GjX1csedWSy3RRRNcg/KGkn4?= =?us-ascii?Q?f8xYcMQiZ+22Z2wQW//4cSOEuawEL8iUzmMZBZenJ9/20DhL0jebi05Lys0u?= =?us-ascii?Q?moVyBpk5dL5CTIzcs+TfjODCu4ehU81AGjTglPyu97Zd1KhV0PKs8j96flnj?= =?us-ascii?Q?HZYQsYRj+igIGSe0IQIuadO4NXTT5UZ7kl2Y5pbcGr0vvVQnQ0T47XTpkOny?= =?us-ascii?Q?4VnHLowyxGgWxamXFiTetyt62c+Tfo2vGQop2Ow++JJy1r7kQUAG3jbMwBME?= =?us-ascii?Q?7iIr99xnSZl2MMaFlHHhO18uoasWn69sc+1NpOdtQi4OZj5zv6JU0HHDSjge?= =?us-ascii?Q?s4ET0a+HUD3KSYjzIxTirV95BLQulo1JPjxmSsWo4ATHoVXV/GYUZNlPuh+Z?= =?us-ascii?Q?UmNE9YOGHrxXQYSuOuunb8B7GTxrGcdBu4iIILgcRkd5hbF2gR17IEsZkJIv?= =?us-ascii?Q?jiYwHJN4ArhQY1tYYBcuZ9D8AqB7jxEQ5qFEcvHKMU3mzQ=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?bAde+Pd8r2LUxyyCd66srk1wAnTcjPUawZ26yQ+MVnFWMWBnWsR3aItxPCzI?= =?us-ascii?Q?ftLV2ExmzszBWcYPXZKlqs4Q1Fd3q4ZQtxvOLhjct9tKwK+T0UvSToTcDUSS?= =?us-ascii?Q?RArga5qug7JWeKE+fsv5QRafgBfm1jdBdJsCcAIPAMuDZF340/+YIwtxbdZ6?= =?us-ascii?Q?Z8RmqwyrrCV3Fwe6ngi4z3kUYoG85MSXhP5mbBYNCFB+T+6NyrefYbsOhh4P?= =?us-ascii?Q?9uwGbnd8zd2Q3HE0aS9Mt6irHm/9R5URN9JxgQveBAOqJIdZCfOHX4LVBmvF?= =?us-ascii?Q?hqDsQAQNzv69HlLvS/6jcnVvPwXgSftTqDbEwU13iAz/S6lcqV2ezJ3HaPpL?= =?us-ascii?Q?iQ5vNrJaMAlcUcKskqO8qLnRstAaXYOqYgS+HOpIm1EqPg0WUtP5VZt0PZxT?= =?us-ascii?Q?vL1Rgg5qSHYfk3F34iQMjivQUL/3ELw4rzVojMc1FKAYcIPVsb294jztJN/Z?= =?us-ascii?Q?aGYdliM8ebBWem7Jtgw0EmcI2GIvRWKlele14D2g57UUQuqflS0ojm5thTDW?= =?us-ascii?Q?mNl/ChO0vn3iFFFXkxIXRPqlZUXcrXrO/nW7YiGrmgfqa24E7h5zderBoV49?= =?us-ascii?Q?JkC20Pp0o5R8ap0N56whGAtGFGBMKxOrVH+RMeif+nQT0tF0BsUohtRkkEWJ?= =?us-ascii?Q?NSnn2Rl2zQDZiemyd26FQwrYjFi/CIWkcPHVWmiY2jzRIKImEScNbnprWQSK?= =?us-ascii?Q?PHt9vnYDSjaKQu08EnWdi/d8e9lr7QEl3WHZ0nokZm53Tt83BKy1WvW9/RUJ?= =?us-ascii?Q?3GPihJE8ol25VeHF0Q0Yeoa5Vb52EqzfehugC4KYsDeV8SK7kSzTJ9OU6sWV?= =?us-ascii?Q?zt4gk6SVFkFOfxfdCjD8eQtMVC6+QmMpqH01l9mE0mDFdLwztb3vxXkBJbfL?= =?us-ascii?Q?Bec+lwXo3PrNjeVMcXnewzZxzWZd5JV+CPi4PT3LRYS58AEIP5FjGxPo9XDb?= =?us-ascii?Q?AKAwDFV+Daqg5Oaa+61rxHGtRJWF1F4tNVxpfWVGevVd5fPKSzJIrKj6Tg5K?= =?us-ascii?Q?LleOQjLP7na5owSYg5ewO8cYChr/BTAPWCPN2lCWKNHZMEYWsQtNQmLaiShS?= =?us-ascii?Q?1enBu8on0lzydbKXJcgRBv/Z/CHeicI6jJKDCnVCGeg1z455TArLLnzFXpdD?= =?us-ascii?Q?U31K2foUXye/B+A1Y/bEbbduDMzmfQp5PytX5sU77fCg9gtNEcvfXQO22C7e?= =?us-ascii?Q?Hyi8kOuVQLOaGWKodTuYE1oZl2tRDknKybxCmRVzNFXFS3RpDNDXEzeFKEbJ?= =?us-ascii?Q?D7TqKSPktst1GlxnTYFw2CjXwoYDza1xdAk3CbvGxLe2jyrW9is4qoe76ei1?= =?us-ascii?Q?XOI4o3ifQ9DXohu5Zy+WSGB+EOiD+7v46YymQQMJDmIUuXcd16Nxh6yFgToI?= =?us-ascii?Q?pClGx/y9BwQmRC2YB7BEoIgz2Ixd+p6bEVoEbpqgYxjf7XWlsTrYX/+fPZG4?= =?us-ascii?Q?8xL7IpNIQLUHiG9ANvMT8MERD7fCIvSo5+fF39g1bm5iZzDf8u3ZUKtgvUFF?= =?us-ascii?Q?Nq9DIhSKZIzV+c2CIHcrPczqzIpfqFRcAntL9Ll/RVeooQ6Q4qwK8oLySWio?= =?us-ascii?Q?tMrr51rGvJin4GTICcs=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: LV8PR12MB9452.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b0cbe10-05c9-42e6-62ba-08dc6a5fe704 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 May 2024 04:25:30.9416 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: F6hG20Zd71lpUuirz42My7bRzmIIlsZtbNtfyUWPaUtX7hfKhc+v2bM3vmP9KndyVoS1v3jVwHfP6rfjEEyB3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7279 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: Wed, 01 May 2024 21:25:34 -0700 Resent-From: abner.chang@amd.com Reply-To: devel@edk2.groups.io,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: idgBroGeRBPQ8Ps2QcxRNKiwx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=s5nPa7O8; 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 [AMD Official Use Only - General] We had reviewed this patch internally before sending this to community. Reviewed-by: Abner Chang > -----Original Message----- > From: Chesley, Brit > Sent: Thursday, May 2, 2024 3:05 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Attar, AbdulLateef (Abdul > Lateef) > Subject: [PATCH v1 5/6] MdeModulePkg: SpiHc: SpiHc Drivers > > From: Brit Chesley > > Added SpiHc DXE and SMM drivers. This code receives bus transactions > from the SpiBus layer and passes them onto the SpiHcPlatformLib > > Platform Initialization Spec 1.7 volume 5 section 18.1.7 > > Bugzilla #4753 > > Cc: Abner Chang > Cc: Abdul Lateef Attar > Signed-off-by: Brit Chesley > --- > MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.inf | 47 ++++++++++ > MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.inf | 45 +++++++++ > MdeModulePkg/Bus/Spi/SpiHc/SpiHc.h | 117 > ++++++++++++++++++++++++ > MdeModulePkg/Bus/Spi/SpiHc/SpiHc.c | 115 > +++++++++++++++++++++++ > MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.c | 101 ++++++++++++++++++++ > MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.c | 79 ++++++++++++++++ > MdeModulePkg/Bus/Spi/SpiHc/SpiHc.uni | 10 ++ > 7 files changed, 514 insertions(+) > create mode 100644 MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.inf > create mode 100644 MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.inf > create mode 100644 MdeModulePkg/Bus/Spi/SpiHc/SpiHc.h > create mode 100644 MdeModulePkg/Bus/Spi/SpiHc/SpiHc.c > create mode 100644 MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.c > create mode 100644 MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.c > create mode 100644 MdeModulePkg/Bus/Spi/SpiHc/SpiHc.uni > > diff --git a/MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.inf > b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.inf > new file mode 100644 > index 000000000000..b71f1535cd46 > --- /dev/null > +++ b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.inf > @@ -0,0 +1,47 @@ > +## @file > +# The SPI Host Controller Module DXE driver INF file > +# > +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 1.27 > + BASE_NAME =3D SpiHcDxe > + FILE_GUID =3D 95D148FF-5A23-43B9-9FC4-80AE0DD48D32 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 0.1 > + PI_SPECIFICATION_VERSION =3D 0x0001000A > + ENTRY_POINT =3D SpiHcProtocolEntry > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + DevicePathLib > + MemoryAllocationLib > + SpiHcPlatformLib > + UefiBootServicesTableLib > + UefiDriverEntryPoint > + UefiLib > + UefiRuntimeServicesTableLib > + > +[Sources] > + SpiHc.h > + SpiHc.c > + SpiHcDxe.c > + > +[Protocols] > + gEfiSpiHcProtocolGuid > + > +[Depex] > + TRUE > + > +[UserExtensions.TianoCore."ExtraFiles"] > + SpiHc.uni > diff --git a/MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.inf > b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.inf > new file mode 100644 > index 000000000000..95d5466d904b > --- /dev/null > +++ b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.inf > @@ -0,0 +1,45 @@ > +## @file > +# The SPI Host Controller Module SMM driver INF file > +# > +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 1.27 > + BASE_NAME =3D SpiHcSmm > + FILE_GUID =3D 0CDAE298-CB3B-480A-BDC4-A6840FFE1F5E > + MODULE_TYPE =3D DXE_SMM_DRIVER > + VERSION_STRING =3D 0.1 > + PI_SPECIFICATION_VERSION =3D 0x0001000A > + ENTRY_POINT =3D SpiHcProtocolEntry > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + MemoryAllocationLib > + MmServicesTableLib > + SpiHcPlatformLib > + UefiDriverEntryPoint > + UefiLib > + > +[Sources] > + SpiHc.h > + SpiHc.c > + SpiHcSmm.c > + > +[Protocols] > + gEfiSpiSmmHcProtocolGuid > + > +[Depex] > + TRUE > + > +[UserExtensions.TianoCore."ExtraFiles"] > + SpiHc.uni > diff --git a/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.h > b/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.h > new file mode 100644 > index 000000000000..c6e4c5893d53 > --- /dev/null > +++ b/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.h > @@ -0,0 +1,117 @@ > +/** @file > + > + SPI Host Controller function declarations > + > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef SPI_HC_H_ > +#define SPI_HC_H_ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** > + Assert or deassert the SPI chip select. > + > + This routine is called at TPL_NOTIFY. > + Update the value of the chip select line for a SPI peripheral. The SPI= bus > + layer calls this routine either in the board layer or in the SPI contr= oller > + to manipulate the chip select pin at the start and end of a SPI transa= ction. > + > + @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure. > + @param[in] SpiPeripheral The address of an EFI_SPI_PERIPHERAL data > structure > + describing the SPI peripheral whose chip sel= ect pin > + is to be manipulated. The routine may access= the > + ChipSelectParameter field to gain sufficient > + context to complete the operati on. > + @param[in] PinValue The value to be applied to the chip select l= ine of > + the SPI peripheral. > + > + @retval EFI_SUCCESS The chip select was set as requested > + @retval EFI_NOT_READY Support for the chip select is not prop= erly > + initialized > + @retval EFI_INVALID_PARAMETER The ChipSeLect value or its contents ar= e > + invalid > + > +**/ > +EFI_STATUS > +EFIAPI > +ChipSelect ( > + IN CONST EFI_SPI_HC_PROTOCOL *This, > + IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral, > + IN BOOLEAN PinValue > + ); > + > +/** > + Set up the clock generator to produce the correct clock frequency, pha= se > and > + polarity for a SPI chip. > + > + This routine is called at TPL_NOTIFY. > + This routine updates the clock generator to generate the correct frequ= ency > + and polarity for the SPI clock. > + > + @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure. > + @param[in] SpiPeripheral Pointer to a EFI_SPI_PERIPHERAL data structu= re > from > + which the routine can access the ClockParame= ter, > + ClockPhase and ClockPolarity fields. The rou= tine > + also has access to the names for the SPI bus= and > + chip which can be used during debugging. > + @param[in] ClockHz Pointer to the requested clock frequency. Th= e SPI > + host controller will choose a supported cloc= k > + frequency which is less then or equal to thi= s > + value. Specify zero to turn the clock genera= tor > + off. The actual clock frequency supported by= the > + SPI host controller will be returned. > + > + @retval EFI_SUCCESS The clock was set up successfully > + @retval EFI_UNSUPPORTED The SPI controller was not able to support th= e > + frequency requested by ClockHz > + > +**/ > +EFI_STATUS > +EFIAPI > +Clock ( > + IN CONST EFI_SPI_HC_PROTOCOL *This, > + IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral, > + IN UINT32 *ClockHz > + ); > + > +/** > + Perform the SPI transaction on the SPI peripheral using the SPI host > + controller. > + > + This routine is called at TPL_NOTIFY. > + This routine synchronously returns EFI_SUCCESS indicating that the > + asynchronous SPI transaction was started. The routine then waits for > + completion of the SPI transaction prior to returning the final transac= tion > + status. > + > + @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure= . > + @param[in] BusTransaction Pointer to a EFI_SPI_BUS_ TRANSACTION > containing > + the description of the SPI transaction to p= erform. > + > + @retval EFI_SUCCESS The transaction completed successfully > + @retval EFI_BAD_BUFFER_SIZE The BusTransaction->WriteBytes value is > invalid, > + or the BusTransaction->ReadinBytes value i= s > + invalid > + @retval EFI_UNSUPPORTED The BusTransaction-> Transaction Type is > + unsupported > + @retval EFI_DEVICE_ERROR SPI Host Controller failed transaction > + > +**/ > +EFI_STATUS > +EFIAPI > +Transaction ( > + IN CONST EFI_SPI_HC_PROTOCOL *This, > + IN EFI_SPI_BUS_TRANSACTION *BusTransaction > + ); > + > +#endif //SPI_HC_H_ > diff --git a/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.c > b/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.c > new file mode 100644 > index 000000000000..9d7bf9f542ef > --- /dev/null > +++ b/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.c > @@ -0,0 +1,115 @@ > +/** @file > + > + SPI Host Controller shell implementation, as host controller code is p= latform > + specfic. > + > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#include "SpiHc.h" > + > +/** > + Assert or deassert the SPI chip select. > + > + This routine is called at TPL_NOTIFY. > + Update the value of the chip select line for a SPI peripheral. The SPI= bus > + layer calls this routine either in the board layer or in the SPI contr= oller > + to manipulate the chip select pin at the start and end of a SPI transa= ction. > + > + @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure. > + @param[in] SpiPeripheral The address of an EFI_SPI_PERIPHERAL data > structure > + describing the SPI peripheral whose chip sel= ect pin > + is to be manipulated. The routine may access= the > + ChipSelectParameter field to gain sufficient > + context to complete the operati on. > + @param[in] PinValue The value to be applied to the chip select l= ine of > + the SPI peripheral. > + > + @retval EFI_SUCCESS The chip select was set as requested > + @retval EFI_NOT_READY Support for the chip select is not prop= erly > + initialized > + @retval EFI_INVALID_PARAMETER The ChipSeLect value or its contents ar= e > + invalid > + > +**/ > +EFI_STATUS > +EFIAPI > +ChipSelect ( > + IN CONST EFI_SPI_HC_PROTOCOL *This, > + IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral, > + IN BOOLEAN PinValue > + ) > +{ > + return PlatformSpiHcChipSelect (This, SpiPeripheral, PinValue); > +} > + > +/** > + Set up the clock generator to produce the correct clock frequency, pha= se > and > + polarity for a SPI chip. > + > + This routine is called at TPL_NOTIFY. > + This routine updates the clock generator to generate the correct frequ= ency > + and polarity for the SPI clock. > + > + @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure. > + @param[in] SpiPeripheral Pointer to a EFI_SPI_PERIPHERAL data structu= re > from > + which the routine can access the ClockParame= ter, > + ClockPhase and ClockPolarity fields. The rou= tine > + also has access to the names for the SPI bus= and > + chip which can be used during debugging. > + @param[in] ClockHz Pointer to the requested clock frequency. Th= e SPI > + host controller will choose a supported cloc= k > + frequency which is less then or equal to thi= s > + value. Specify zero to turn the clock genera= tor > + off. The actual clock frequency supported by= the > + SPI host controller will be returned. > + > + @retval EFI_SUCCESS The clock was set up successfully > + @retval EFI_UNSUPPORTED The SPI controller was not able to support th= e > + frequency requested by ClockHz > + > +**/ > +EFI_STATUS > +EFIAPI > +Clock ( > + IN CONST EFI_SPI_HC_PROTOCOL *This, > + IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral, > + IN UINT32 *ClockHz > + ) > +{ > + return PlatformSpiHcClock (This, SpiPeripheral, ClockHz); > +} > + > +/** > + Perform the SPI transaction on the SPI peripheral using the SPI host > + controller. > + > + This routine is called at TPL_NOTIFY. > + This routine synchronously returns EFI_SUCCESS indicating that the > + asynchronous SPI transaction was started. The routine then waits for > + completion of the SPI transaction prior to returning the final transac= tion > + status. > + > + @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure= . > + @param[in] BusTransaction Pointer to a EFI_SPI_BUS_ TRANSACTION > containing > + the description of the SPI transaction to p= erform. > + > + @retval EFI_SUCCESS The transaction completed successfully > + @retval EFI_BAD_BUFFER_SIZE The BusTransaction->WriteBytes value is > invalid, > + or the BusTransaction->ReadinBytes value i= s > + invalid > + @retval EFI_UNSUPPORTED The BusTransaction-> Transaction Type is > + unsupported > + @retval EFI_DEVICE_ERROR SPI Host Controller failed transaction > + > +**/ > +EFI_STATUS > +EFIAPI > +Transaction ( > + IN CONST EFI_SPI_HC_PROTOCOL *This, > + IN EFI_SPI_BUS_TRANSACTION *BusTransaction > + ) > +{ > + return PlatformSpiHcTransaction (This, BusTransaction); > +} > diff --git a/MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.c > b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.c > new file mode 100644 > index 000000000000..d0e9827eb67c > --- /dev/null > +++ b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcDxe.c > @@ -0,0 +1,101 @@ > +/** @file > + > + SPI Host controller entry point for DXE > + > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "SpiHc.h" > + > +EFI_HANDLE mSpiHcHandle =3D 0; > + > +/** > + Entry point of the SPI Host Controller driver. Installs the > EFI_SPI_HC_PROTOCOL on mSpiHcHandle. > + Also installs the EFI_DEVICE_PATH_PROTOCOL corresponding to the SPI > Host controller on the same > + mSpiHcHandle. > + > + @param[in] ImageHandle Image handle of this driver. > + @param[in] SystemTable Pointer to standard EFI system table. > + > + @retval EFI_SUCCESS Succeed. > + @retval EFI_OUT_RESOURCES If the system has run out of memory > +**/ > +EFI_STATUS > +EFIAPI > +SpiHcProtocolEntry ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_SPI_HC_PROTOCOL *HcProtocol; > + EFI_DEVICE_PATH_PROTOCOL *HcDevicePath; > + > + DEBUG ((DEBUG_VERBOSE, "%a - ENTRY\n", __func__)); > + > + // Allocate the SPI Host Controller protocol > + HcProtocol =3D AllocateZeroPool (sizeof (EFI_SPI_HC_PROTOCOL)); > + ASSERT (HcProtocol !=3D NULL); > + if (HcProtocol =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + // Fill in the SPI Host Controller Protocol > + Status =3D GetPlatformSpiHcDetails ( > + &HcProtocol->Attributes, > + &HcProtocol->FrameSizeSupportMask, > + &HcProtocol->MaximumTransferBytes > + ); > + > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_VERBOSE, "Error, no Platform SPI HC details\n")); > + return Status; > + } > + > + HcProtocol->ChipSelect =3D ChipSelect; > + HcProtocol->Clock =3D Clock; > + HcProtocol->Transaction =3D Transaction; > + > + // Install Host Controller protocol > + Status =3D gBS->InstallProtocolInterface ( > + &mSpiHcHandle, > + &gEfiSpiHcProtocolGuid, > + EFI_NATIVE_INTERFACE, > + HcProtocol > + ); > + > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_VERBOSE, "Error installing gEfiSpiHcProtocolGuid\n")); > + return Status; > + } > + > + Status =3D GetSpiHcDevicePath (&HcDevicePath); > + > + // Install HC device path here on this handle as well > + Status =3D gBS->InstallProtocolInterface ( > + &mSpiHcHandle, > + &gEfiDevicePathProtocolGuid, > + EFI_NATIVE_INTERFACE, > + HcDevicePath > + ); > + > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_VERBOSE, "Error installing > gEfiDevicePathProtocolGuid\n")); > + } > + > + DEBUG ((DEBUG_VERBOSE, "%a - EXIT Status=3D%r\n", __func__, Status)); > + > + return Status; > +} > diff --git a/MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.c > b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.c > new file mode 100644 > index 000000000000..adebff97631a > --- /dev/null > +++ b/MdeModulePkg/Bus/Spi/SpiHc/SpiHcSmm.c > @@ -0,0 +1,79 @@ > +/** @file > + > + SPI Host controller entry point for SMM > + > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "SpiHc.h" > + > +EFI_HANDLE mSpiHcHandle =3D 0; > + > +/** > + Entry point of the SPI Host Controller driver. Installs the > EFI_SPI_HC_PROTOCOL on mSpiHcHandle. > + Also installs the EFI_DEVICE_PATH_PROTOCOL corresponding to the SPI > Host controller on the same > + mSpiHcHandle. > + > + @param[in] ImageHandle Image handle of this driver. > + @param[in] SystemTable Pointer to standard EFI system table. > + > + @retval EFI_SUCCESS Succeed. > + @retval EFI_OUT_RESOURCES If the system has run out of memory > +**/ > +EFI_STATUS > +EFIAPI > +SpiHcProtocolEntry ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_SPI_HC_PROTOCOL *HcProtocol; > + > + DEBUG ((DEBUG_VERBOSE, "%a - ENTRY\n", __func__)); > + > + // Allocate the SPI Host Controller protocol > + HcProtocol =3D AllocateZeroPool (sizeof (EFI_SPI_HC_PROTOCOL)); > + ASSERT (HcProtocol !=3D NULL); > + if (HcProtocol =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + // Fill in the SPI Host Controller Protocol > + Status =3D GetPlatformSpiHcDetails ( > + &HcProtocol->Attributes, > + &HcProtocol->FrameSizeSupportMask, > + &HcProtocol->MaximumTransferBytes > + ); > + > + HcProtocol->ChipSelect =3D ChipSelect; > + HcProtocol->Clock =3D Clock; > + HcProtocol->Transaction =3D Transaction; > + > + Status =3D gMmst->MmInstallProtocolInterface ( > + &mSpiHcHandle, > + &gEfiSpiSmmHcProtocolGuid, > + EFI_NATIVE_INTERFACE, > + HcProtocol > + ); > + > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_VERBOSE, "Error installing > gEfiSpiSmmHcProtocolGuid\n")); > + } > + > + DEBUG ((DEBUG_VERBOSE, "%a - EXIT Status=3D%r\n", __func__, Status)); > + > + return Status; > +} > diff --git a/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.uni > b/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.uni > new file mode 100644 > index 000000000000..9fab0a7433c5 > --- /dev/null > +++ b/MdeModulePkg/Bus/Spi/SpiHc/SpiHc.uni > @@ -0,0 +1,10 @@ > +// /** @file > +// > +// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<= BR> > +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// **/ > + > +#string STR_PROPERTIES_MODULE_NAME > +#language en-US "SPI host controller driver" > -- > 2.42.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 (#118496): https://edk2.groups.io/g/devel/message/118496 Mute This Topic: https://groups.io/mt/105849138/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-