From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.404.1645122256065704225 for ; Thu, 17 Feb 2022 10:24:16 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=h48j6cFX; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: maurice.ma@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645122256; x=1676658256; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=qZCwyErn76/wCR+btA3jdNpxa4vgHszt4ygiRf86ukc=; b=h48j6cFXTEjo+dmRar2IChvZQkSklZ+6fY0jrG3OZOr7JWXGoMwc6nng 48qFcHOmlNbUethfPsi0iSM12qQyeV1IEw5vfWXria6298wqEUNr/5vg6 lVVt2e63QtGRyyKukMSA1pa2s+7nGVB+a1dwBMlc/7JFzQIFhp9+9WS46 J8ihNoqywMQgbsWazfl1JKlbld6pUYFdR7yjocahqwK+hbH99NuKt7oCn igphu8zjFQMlEogbF7jpBsghX5xnDb04v5STY94BM9ok+ltLAAoCOdPn9 Hn88bdbmYxQlQbpSwKwPt3XZ6gEb7Mu+Ji1cQHnyF+Hj2X1lk6g4tFR0n g==; X-IronPort-AV: E=McAfee;i="6200,9189,10261"; a="311685304" X-IronPort-AV: E=Sophos;i="5.88,376,1635231600"; d="scan'208";a="311685304" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 10:24:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,376,1635231600"; d="scan'208";a="530418736" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga007.jf.intel.com with ESMTP; 17 Feb 2022 10:24:15 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 17 Feb 2022 10:24:14 -0800 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 17 Feb 2022 10:24:14 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Thu, 17 Feb 2022 10:24:14 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.170) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Thu, 17 Feb 2022 10:24:13 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EYKI/cnVFfwN8MGQlLfeV1iVBlnIQpNv+0pB4ecVqeQCFFdayz3rXAV7FLhOpuqwsZaszGeQIvwKP29iQcqL7J6gdK/Bsem1fJ/rF+hhXQmv9wC33lJkJB9eZ6OLneo+bRq3da/LQK+3I98F13T9C8b2SAGCjkZggS/OZ1Gq1SPffBgdkwjZt1iqMsTZlP8D/K6yb+VtvlTnut762meeWgUhI3nfTyStq1VLMhcYkHDClhXJxkJqI4u1nk9F3oOeh7DOvgMK+sA+eaW7eFoqVN6bBdtC0yh7rrhXYq++WtDJOTDfjIoHdC38/3gOgnMX9xLy6GfXzGBqJSVyK9CmOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oSypo3NGPHW+GviparxSl5f68tMbAG+/a5p7lw1WF8o=; b=krZ4KMflsct3QAhHSDsBv41sR4ln/Sm94clOMv5+okxZTdLus0sv6O0oCpS2j3XJUgUaBFX/VbqR/rlhDVjB79AWL5tmfSQI4yvGrR+VTnEq1yJe8f0ofAPTyASGGhcsodl9s5tkjOLcGGBFl8wOPYQ8UpD98F08NrXZpEvN6lW8NduktMcZrPnUq65bzqWw+2KoiABxeq2KqKg8Pu0FmqQBDYXCDIGSWW7pCa+P4/QIH6TFY8vpFxXmPTh5Arcz1volj1VFpjCxbXsZHARzp2+I6+KhtQaCxB700xkPTPXvxbGcyu12VP73aqZO93UZG8vRCEhMJo7yiM4xYJZhAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from CO1PR11MB4945.namprd11.prod.outlook.com (2603:10b6:303:9c::8) by SN6PR11MB3181.namprd11.prod.outlook.com (2603:10b6:805:c3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.17; Thu, 17 Feb 2022 18:24:10 +0000 Received: from CO1PR11MB4945.namprd11.prod.outlook.com ([fe80::c9d4:be7:7abc:48c0]) by CO1PR11MB4945.namprd11.prod.outlook.com ([fe80::c9d4:be7:7abc:48c0%4]) with mapi id 15.20.4995.014; Thu, 17 Feb 2022 18:24:10 +0000 From: "Ma, Maurice" To: "devel@edk2.groups.io" , "Rhodes, Sean" CC: "Dong, Guo" , Patrick Rudolph , "Ni, Ray" , "You, Benjamin" Subject: Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller DXE Thread-Topic: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller DXE Thread-Index: AQHYJCcJ6tT0C0eSe0OMixcajM8TdayYC9sg Date: Thu, 17 Feb 2022 18:24:10 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.200.16 dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e520be0a-ab61-41b9-3f11-08d9f242b126 x-ms-traffictypediagnostic: SN6PR11MB3181:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:549; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UdXXAvVOVziHWIBUcNTEJmXNp1Oj8S0nR/q498mHUaR+A74Bex/1sNjcoaL2ZZ7TkzILvzhWJzXByDKVJK1QiKprXvrmAnL7S0iwjQMeHQTF3QQWWvZ0rEo9L2K1+8EMYXlPgiv/Vi18ILc3Oht9r/wiCqGO/q0cPj54L/A+qiR4eRKGVY5TNJGlW9tAvMqWAi3GO3/VYoRC/NIUd9+ci9JF+j/gWkklHaatR88lwjRT3Pp/t8cCz5tJIJpjJdGUHn7XQcV3zw84H1ksVPC/vYu7RHxjnVzfJGinuj62+SeJ7LA6qWPSp6I6HxqXFYZG2HHQ2cLDMF2cgrmRG2NTZ4UqIaoF7BEQq2TTUjOdIY88haIDIQjC210htpRj+xWsnBxP8KP19F5BmTaUzUGF35/dn6vKdCVrJMNplSQZkYKMTHzObbmcEtXEglDt9fyDZqRxBsJ0evGijWhq8GW4NyOJTgdL2JfpdTaXrtmZFtPdE0pzuP8fPsgVNgrw3sBQqEdbXxxU/kUNIpW5dFlnnBgVSC+Kf44U9HeKkQkyJbHMS78K+J3PTvKviejjp9IjrBN0WQwxvA1xPIxC9lruccdO3BjU1jQJL/9wjRhuofv/I8xnsQjtkj52LScYJ+vvrb1EEsC0ODhdn/S8YDnFW7LvLGX6n7XVLyVmO+6yYTl4+83X9CaB7feKKyYrdx7HFjIXMTrsF+bNbUbxNJdG3VLGm4+49mvtbitAENSxKGh5gpQVOWefjOCY3HZe6RtS+fJWbNq3/vT8qXuxhTRv3Tkit+9RT/566N/A1zRtvg+bAJ3I4/4IVqSaBs3idlFgOJ7QhIGWbkl8W30tTUbrgA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4945.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(6506007)(4326008)(53546011)(71200400001)(66446008)(8676002)(66476007)(5660300002)(66946007)(76116006)(64756008)(83380400001)(66556008)(7696005)(30864003)(33656002)(8936002)(52536014)(38070700005)(9686003)(38100700002)(508600001)(2906002)(54906003)(26005)(55016003)(122000001)(110136005)(316002)(82960400001)(19627235002)(186003)(966005)(107886003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Zm9Asf1Dwe47amNlVKHXdV+vi29pTvQUaywrfjVcjVkolqfUHrtz4kht4zjb?= =?us-ascii?Q?mAWSBXLGK4D7IgvFWZNMjL4u5UbxqJ1qlByEQOP3+gwwkt81nzVdFOX3uqaT?= =?us-ascii?Q?Chzph7wDMmegv43s8eIV66vfQJEsdSbTImrobwiS77/XfIBslfzjrdwfzNZh?= =?us-ascii?Q?FdwfmmgDxhJFeLq0wAOJ7l0vESLLPbs5ekxWM+U5rs0X6lxaZF6qpsUtICI/?= =?us-ascii?Q?3HXTAo5ZHUmGa4oRMJd8CtN4SF8I1dErhn2aMcd3zUkamFLsPb6WJ12xxGra?= =?us-ascii?Q?MpQ2i8sY98h/28UnDFMxcZUt5Q8Hf7ZvG67WTDPW4Y8Xh/t7voAOXpAEDDhm?= =?us-ascii?Q?6hMzWeqs8Nn0X4BOpTBDNr2bdV1tXcx2BkzQ1d4PKR42U9eoDj6z/ydOn6J+?= =?us-ascii?Q?L8kiElzfJqs2DkSfQQBGF+xiJ5C02NsrrCzFfnqqa4ivqW+j8dA3bKwFPMGU?= =?us-ascii?Q?yzVUIo+5iXgIKyQvOuzjJ1uCDtcycq+rQcCLCoXJc36IXQOcXN9WVlexoKal?= =?us-ascii?Q?xqulIeo6zYkj8vzdg9c9/PVxD8SC0xdmGR6N3hqexCPMJxvewtf/67X4B9FI?= =?us-ascii?Q?qf+QKxIO/fPqyKFzFusHgAi+33S2rf5EgVMQW6Vsi8gdPKDRGtCBYYx1f+Ml?= =?us-ascii?Q?4anPJ44dPTFGpCnh2xGMjLqi4T0qlXW/0vCzJc/GTWnMRk0NL53bJgrjMT/v?= =?us-ascii?Q?rn/nhLk+pV4WWmeTxDZUigrFV/BUejbgwOtRNRDV/gaT4ZddXxXBupTyYTae?= =?us-ascii?Q?1KdgG06W1GdHByMMjdxz07HPCXwXh5nAcBS9ERX+TpPuvxhdQqlBN9RN9wKU?= =?us-ascii?Q?5wf68MqppHMssKTF9G36wec2kQIV8Wn9ve/cVLN5VbXKTx8UEu5IDT2DcAOV?= =?us-ascii?Q?YtVrJYlc8/18sWzYrWwnbugyjlCoHG2Q+0n1cxYPnteFO7udQtP0ibNta292?= =?us-ascii?Q?YNeK1xYodu95ljiE+9EyEDBoe2GtFWtBNT6a+UTkGIpH3p8V9Kc5SBA1emtp?= =?us-ascii?Q?7KHh0WpWY3vyke6kC2v6hnwqP7pSbmvbeBiqULSJX00ySEM+mGG6bvc9+kVv?= =?us-ascii?Q?YLel1VA3fYMdf0rPyNc9ogh+mA8UwRocn6MD7dGQ++fGoV5htogaaxFMK5EY?= =?us-ascii?Q?WnaApzZTBVIQHCY6Ny/qJsP10qAEkzwGZ/EY3XQBww4jfnPKPLGwk2+xTTJ4?= =?us-ascii?Q?DNSos0f1xNUjRL9eArvzxXKCWFw6DDtQ+SXJw1qjFKjMOrvJRsJTWSg3LEBH?= =?us-ascii?Q?D+XxCvZKF1b1mGzo2xx8gU4tPagDo5/CM8NHrY451ZrgXe6dYNh9teWOCuw1?= =?us-ascii?Q?O533c5j2UTnf9O+zcq1DcHLtj06KKpNND9sg2tY5kd3+W1szU55CkU2QGgR7?= =?us-ascii?Q?KHCkhRH427AlSAQ5EJgb1MezSqyZfI+hhXH2WlJH20CDQDXklYk9gHHaLvtA?= =?us-ascii?Q?WUY5DOh8mwbaVAp/UeXI4rj4CWCl+6day2C/mJabyI5UCA3yB8HqcbqiTU4a?= =?us-ascii?Q?fUqxskjUNg2B8xnQHsOEILK1TLSICcZ+xXKgfQICrsLQJIYzGdVadWfnVguB?= =?us-ascii?Q?sRN2qyUnUvd5MZxN0xVjHqXYVeE8mewwlE/D7XyBSRDu3Vnuz73vugHep8ZA?= =?us-ascii?Q?1nrWsbzJ8CFvPVrE/jcXwbw=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4945.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e520be0a-ab61-41b9-3f11-08d9f242b126 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Feb 2022 18:24:10.2690 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: R27VvMcuiSD59Jtwe0cDkqinkEjEwr5Ruj5xSNLXLQ37yNgzli6vQY0KNYCGsTD72zoIBK4Wj/wFsrxCeTGsQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3181 Return-Path: maurice.ma@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This vendor specific device driver implementation does not seem to fit into= UEFI payload package scope well. =20 Do you think https://github.com/tianocore/edk2-platforms/tree/master/Silico= n could be a better location ? Thanks Maurice > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Sean > Rhodes > Sent: Thursday, February 17, 2022 9:51 > To: devel@edk2.groups.io > Cc: Dong, Guo ; Patrick Rudolph > ; Ni, Ray ; Ma, > Maurice ; You, Benjamin > > Subject: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus > controller DXE >=20 > From: Patrick Rudolph >=20 > Implement a subset of the gEfiSmbusHcProtocolGuid using a generic PCI i80= 1 > SMBus controller. >=20 > Cc: Guo Dong > Cc: Ray Ni > Cc: Maurice Ma > Cc: Benjamin You > Signed-off-by: Patrick Rudolph > --- > .../Library/BrotliCustomDecompressLib/brotli | 2 +- > UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.c | 556 > ++++++++++++++++++ > UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.h | 17 + > UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.inf | 45 ++ > UefiPayloadPkg/UefiPayloadPkg.dsc | 7 + > UefiPayloadPkg/UefiPayloadPkg.fdf | 5 + > 6 files changed, 631 insertions(+), 1 deletion(-) create mode 100644 > UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.c > create mode 100644 UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.h > create mode 100644 UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.inf >=20 > diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli > b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli > index f4153a09f8..666c3280cc 160000 > --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli > +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli > @@ -1 +1 @@ > -Subproject commit f4153a09f87cbb9c826d8fc12c74642bb2d879ea > +Subproject commit 666c3280cc11dc433c303d79a83d4ffbdd12cc8d > diff --git a/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.c > b/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.c > new file mode 100644 > index 0000000000..7bf7b893ad > --- /dev/null > +++ b/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.c > @@ -0,0 +1,556 @@ > +/** @file+ Implementation for a generic i801 SMBus driver.++Copyright (= c) > 2016, Intel Corporation. All rights reserved.
+SPDX-License-Identifier= : > BSD-2-Clause-Patent+++**/++#include "SMBusi801Dxe.h"+#include > +#include +#include > +#include +#include > +#include > ++EFI_HANDLE mDriverHandle =3D > NULL;+UINT32 PciDevice =3D 0;++/* SMBus register offsets. */+#de= fine > SMBHSTSTAT 0x0+#define SMBHSTCTL 0x2+#define SMBHSTCMD > 0x3+#define SMBXMITADD 0x4+#define SMBHSTDAT0 0x5+#define > SMBHSTDAT1 0x6+#define SMBBLKDAT 0x7+#define SMBTRNSADD > 0x9+#define SMBSLVDATA 0xa+#define SMLINK_PIN_CTL 0xe+#define > SMBUS_PIN_CTL 0xf+#define SMBSLVCMD 0x11++/* I801 command > constants */+#define I801_QUICK (0 << 2)+#define I801_BYTE = (1 > << 2)+#define I801_BYTE_DATA (2 << 2)+#define I801_WORD_DATA = (3 > << 2)+#define I801_PROCESS_CALL (4 << 2)+#define I801_BLOCK_DATA > (5 << 2)+#define I801_I2C_BLOCK_DATA (6 << 2) /* ICH5 and later */++= /* > I801 Host Control register bits */+#define SMBHSTCNT_INTREN (1 << > 0)+#define SMBHSTCNT_KILL (1 << 1)+#define SMBHSTCNT_LAST_BYTE > (1 << 5)+#define SMBHSTCNT_START (1 << 6)+#define > SMBHSTCNT_PEC_EN (1 << 7) /* ICH3 and later */++/* I801 Hosts Stat= us > register bits */+#define SMBHSTSTS_BYTE_DONE (1 << 7)+#define > SMBHSTSTS_INUSE_STS (1 << 6)+#define SMBHSTSTS_SMBALERT_STS (1 > << 5)+#define SMBHSTSTS_FAILED (1 << 4)+#define > SMBHSTSTS_BUS_ERR (1 << 3)+#define SMBHSTSTS_DEV_ERR (1 << > 2)+#define SMBHSTSTS_INTR (1 << 1)+#define SMBHSTSTS_HOST_BUSY > (1 << 0)++/* For SMBXMITADD register. */+#define XMIT_WRITE(dev) > (((dev) << 1) | 0)+#define XMIT_READ(dev) (((dev) << 1) | > 1)++STATIC+UINT16+EFIAPI+SmbusGetSMBaseAddress (+ IN VOID+ )+{+ > UINT16 Cmd;+ UINT32 Reg32;+ UINT16 IoBase;++ IoBase =3D 0;+ //+ /= / Test > if I/O decoding is enabled+ //+ Cmd =3D PciRead16 (PciDevice + 0x4);+ = if > (!(Cmd & 1)) {+ goto CloseAndReturn;+ }++ //+ // Test if BAR0 is I/= O bar > and enabled+ //+ Reg32 =3D PciRead16 (PciDevice + 0x20);+ if (!(Reg32 = & 1) > || !(Reg32 & 0xfffc) || ((Reg32 & 0xfffc) =3D=3D 0xfffc)) {+ goto > CloseAndReturn;+ }++ IoBase =3D Reg32 & 0xfffc;++CloseAndReturn:+ retu= rn > IoBase;+}++STATIC+EFI_STATUS+SmbusSetupCommand (+ IN UINT16 > IoBase,+ IN UINT8 Ctrl,+ IN UINT8 Xmitadd+ )+{+ UINTN Loops =3D = 10000;+ > UINT8 host_busy;++ do {+ MicroSecondDelay (100);+ host_busy =3D > IoRead8 (IoBase + SMBHSTSTAT) & SMBHSTSTS_HOST_BUSY;+ } while (-- > Loops && host_busy);++ if (Loops =3D=3D 0) {+ return EFI_TIMEOUT;+ }= ++ /* > Clear any lingering errors, so the transaction will run. */+ IoWrite8 (I= oBase + > SMBHSTSTAT, IoRead8 (IoBase + SMBHSTSTAT));++ /* Set up transaction */+ > /* Disable interrupts */+ IoWrite8 (IoBase + SMBHSTCTL, Ctrl);++ /* Set= the > device I'm talking to. */+ IoWrite8 (IoBase + SMBXMITADD, Xmitadd);++ > return EFI_SUCCESS;+}++STATIC+EFI_STATUS+SmbusExecuteCommand (+ > IN UINT16 IoBase+ )+{+ UINTN Loops =3D 10000;+ UINT8 Status;++ /* = Start > the command. */+ IoWrite8 (IoBase + SMBHSTCTL, IoRead8 (IoBase + > SMBHSTCTL) | SMBHSTCNT_START);+ Status =3D IoRead8 (IoBase + > SMBHSTSTAT);++ /* Poll for it to start. */+ do {+ MicroSecondDelay > (100);++ /* If we poll too slow, we could miss HOST_BUSY flag+ * s= et and > detect INTR or x_ERR flags instead here.+ */+ Status =3D IoRead8 (= IoBase + > SMBHSTSTAT);++ Status &=3D ~(SMBHSTSTS_SMBALERT_STS | > SMBHSTSTS_INUSE_STS);+ } while (--Loops && Status =3D=3D 0);++ if (Loop= s =3D=3D 0) > {+ return EFI_TIMEOUT;+ }++ return > EFI_SUCCESS;+}++STATIC+BOOLEAN+SmbusHostCompleted (+ IN UINT8 > Status+ )+{+ if (Status & SMBHSTSTS_HOST_BUSY) {+ return FALSE;+ }+= + > /* These status bits do not imply completion of transaction. */+ Status = &=3D > ~(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INUSE_STS | > SMBHSTSTS_SMBALERT_STS);+ return Status !=3D > 0;+}++STATIC+EFI_STATUS+SmbusCompleteCommand (+ IN UINT16 > IoBase+ )+{+ UINTN Loops =3D 10000;+ UINT8 Status;++ do {+ > MicroSecondDelay (100);+ Status =3D IoRead8 (IoBase + SMBHSTSTAT);+ } > while (--Loops && !SmbusHostCompleted (Status));++ if (Loops =3D=3D 0) {= + > return EFI_TIMEOUT;+ }++ /* These status bits do not imply errors. */+ > Status &=3D ~(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INUSE_STS | > SMBHSTSTS_SMBALERT_STS);++ if (Status =3D=3D SMBHSTSTS_INTR) {+ retur= n > EFI_SUCCESS;+ }++ return > EFI_NO_RESPONSE;+}++STATIC+EFI_STATUS+EFIAPI+SmbusProcessCallOper > ation (+ IN CONST UINT16 IoBase,+ IN CONST > EFI_SMBUS_HC_PROTOCOL *This,+ IN EFI_SMBUS_DEVICE_ADDRESS > SlaveAddress,+ IN EFI_SMBUS_DEVICE_COMMAND Command,+ IN > BOOLEAN PecCheck,+ IN OUT UINTN = *Length,+ IN OUT > VOID *Buffer+ )+{+ EFI_STATUS Status;+ UINT16 > ResultBuffer;+ UINT16 AddrBuffer;++ if (!Buffer || !Length) {+ = return > RETURN_INVALID_PARAMETER;+ }++ if (*Length !=3D 2) {+ return > RETURN_INVALID_PARAMETER;+ }++ CopyMem (&AddrBuffer, Buffer, > sizeof (AddrBuffer));++ /* Set up for process call */+ Status =3D > SmbusSetupCommand (IoBase, I801_PROCESS_CALL, XMIT_WRITE > (SlaveAddress.SmbusDeviceAddress));+ if (EFI_ERROR (Status)) {+ retur= n > Status;+ }++ /* cmd will only be send if I2C_EN is zero */+ IoWrite8 (= IoBase > + SMBHSTCMD, Command);++ IoWrite8 (IoBase + SMBHSTDAT0, AddrBuffer > & 0x00ff);+ IoWrite8 (IoBase + SMBHSTDAT1, (AddrBuffer & 0xff00) >> 8);+= + > /* Start the command */+ Status =3D SmbusExecuteCommand (IoBase);+ if > (EFI_ERROR (Status)) {+ return Status;+ }++ /* Poll for transaction > completion */+ Status =3D SmbusCompleteCommand (IoBase);+ if > (EFI_ERROR (Status)) {+ return Status;+ }++ /* Read results of trans= action > */+ ResultBuffer =3D IoRead8 (IoBase + SMBHSTDAT0);+ ResultBuffer |=3D > (IoRead8 (IoBase + SMBHSTDAT1) << 8);++ CopyMem (Buffer, > &ResultBuffer, sizeof (ResultBuffer));+ *Length =3D sizeof (ResultBuffer= );++ > return EFI_SUCCESS;+}++STATIC+EFI_STATUS+EFIAPI+SmbusReadOperation > (+ IN CONST UINT16 IoBase,+ IN CONST > EFI_SMBUS_HC_PROTOCOL *This,+ IN EFI_SMBUS_DEVICE_ADDRESS > SlaveAddress,+ IN EFI_SMBUS_DEVICE_COMMAND Command,+ IN > BOOLEAN PecCheck,+ IN OUT UINTN = *Length,+ IN OUT > VOID *Buffer+ )+{+ EFI_STATUS Status;+ UINT8 > ResultBuffer;++ if (!Buffer || !Length) {+ return > RETURN_INVALID_PARAMETER;+ }++ /* Set up for a byte data read. */+ > Status =3D SmbusSetupCommand (IoBase, I801_BYTE_DATA, XMIT_READ > (SlaveAddress.SmbusDeviceAddress));+ if (EFI_ERROR (Status)) {+ retur= n > Status;+ }++ IoWrite8 (IoBase + SMBHSTCMD, Command);++ IoWrite8 > (IoBase + SMBHSTDAT0, 0);+ IoWrite8 (IoBase + SMBHSTDAT1, 0);++ /* Star= t > the command */+ Status =3D SmbusExecuteCommand (IoBase);+ if > (EFI_ERROR (Status)) {+ return Status;+ }++ /* Poll for transaction > completion */+ Status =3D SmbusCompleteCommand (IoBase);+ if > (EFI_ERROR (Status)) {+ return Status;+ }++ /* Read results of trans= action > */+ ResultBuffer =3D IoRead8 (IoBase + SMBHSTDAT0);++ CopyMem (Buffer, > &ResultBuffer, sizeof (ResultBuffer));+ *Length =3D sizeof (ResultBuffer= );++ > return EFI_SUCCESS;+}++STATIC+EFI_STATUS+EFIAPI+SmbusWriteOperation > (+ IN CONST UINT16 IoBase,+ IN CONST > EFI_SMBUS_HC_PROTOCOL *This,+ IN EFI_SMBUS_DEVICE_ADDRESS > SlaveAddress,+ IN EFI_SMBUS_DEVICE_COMMAND Command,+ IN > BOOLEAN PecCheck,+ IN OUT UINTN = *Length,+ IN OUT > VOID *Buffer+ )+{+ EFI_STATUS Status;+ UINT8 > InputBuffer;++ if (!Buffer || !Length) {+ return > RETURN_INVALID_PARAMETER;+ }++ if (*Length !=3D 1) {+ return > RETURN_INVALID_PARAMETER;+ }++ CopyMem (&InputBuffer, Buffer, > sizeof (InputBuffer));++ /* Set up for a byte data read. */+ Status =3D > SmbusSetupCommand (IoBase, I801_BYTE_DATA, XMIT_WRITE > (SlaveAddress.SmbusDeviceAddress));+ if (EFI_ERROR (Status)) {+ retur= n > Status;+ }++ IoWrite8 (IoBase + SMBHSTCMD, Command);++ IoWrite8 > (IoBase + SMBHSTDAT0, InputBuffer);++ /* Start the command */+ Status = =3D > SmbusExecuteCommand (IoBase);+ if (EFI_ERROR (Status)) {+ return > Status;+ }++ /* Poll for transaction completion */+ Status =3D > SmbusCompleteCommand (IoBase);+ if (EFI_ERROR (Status)) {+ return > Status;+ }++ return > EFI_SUCCESS;+}++STATIC+EFI_STATUS+EFIAPI+SmbusExecuteOperation (+ > 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+ )+{+ UINT16 IoBase;++ IoBase =3D SmbusGetSMBaseAddress ();+ = if > (!IoBase) {+ return EFI_UNSUPPORTED;+ }++ if (Operation =3D=3D > EfiSmbusProcessCall) {+ return SmbusProcessCallOperation (+ > IoBase,+ This,+ SlaveAddress,+ Comman= d,+ > PecCheck,+ Length,+ Buffer+ );+ } el= se if (Operation =3D=3D > EfiSmbusReadByte) {+ return SmbusReadOperation (+ IoBase,+ > This,+ SlaveAddress,+ Command,+ PecCh= eck,+ > Length,+ Buffer+ );+ } else if (Operation =3D=3D= EfiSmbusWriteByte) > {+ return SmbusWriteOperation (+ IoBase,+ This= ,+ > SlaveAddress,+ Command,+ PecCheck,+ L= ength,+ > Buffer+ );+ }++ return > EFI_UNSUPPORTED;+}++STATIC+EFI_STATUS+EFIAPI+SmbusHcProtocolArpD > evice (+ IN CONST EFI_SMBUS_HC_PROTOCOL *This,+ IN BOOLEAN > ArpAll,+ IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL+ IN OUT > EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL+ )+{+ return > EFI_UNSUPPORTED;+}++STATIC+EFI_STATUS+EFIAPI+SmbusHcProtocolGetA > rpMap (+ IN CONST EFI_SMBUS_HC_PROTOCOL *This,+ IN OUT UINTN > *Length,+ IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap+ )+{+ > return > EFI_UNSUPPORTED;+}++STATIC+EFI_STATUS+EFIAPI+SmbusHcProtocolNotif > y (+ IN CONST EFI_SMBUS_HC_PROTOCOL *This,+ IN > EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,+ IN UINTN > Data,+ IN EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction+ )+{+ retur= n > EFI_UNSUPPORTED;+}++EFI_SMBUS_HC_PROTOCOL mSmbusProtocol =3D {+ > SmbusExecuteOperation,+ SmbusHcProtocolArpDevice,+ > SmbusHcProtocolGetArpMap,+ SmbusHcProtocolNotify+};++/**+ The Entry > Point for SMBUS driver.++ It installs DriverBinding.++ @retval EFI_SUCC= ESS > The entry point is executed successfully.+ @retval other Som= e error > occurs when executing this entry > point.++**/+EFI_STATUS+EFIAPI+InstallSmbusProtocol (+ IN EFI_HANDLE > ImageHandle,+ IN EFI_SYSTEM_TABLE *SystemTable+ )+{+ EFI_STATUS > Status;+ UINT16 IoBase;+ UINT8 Device;+ UINT8 Functio= n;+ > BOOLEAN BreakLoop;+ UINT8 BaseClass;+ UINT8 SubClass;++ > BreakLoop =3D FALSE;+ Status =3D EFI_SUCCESS;++ //+ // Search for S= MBus > Controller within PCI Devices on root bus+ //+ for (Device =3D 0; Devic= e <=3D > PCI_MAX_DEVICE; Device++) {+ for (Function =3D 0; Function <=3D > PCI_MAX_FUNC; Function++) {+ if (PciRead16 (PCI_LIB_ADDRESS (0, > Device, Function, 0x00)) !=3D 0x8086) {+ continue;+ }++ = BaseClass =3D > PciRead8 (PCI_LIB_ADDRESS (0, Device, Function, 0x0B));++ if (BaseCl= ass > =3D=3D PCI_CLASS_SERIAL) {+ SubClass =3D PciRead8 (PCI_LIB_ADDRESS= (0, > Device, Function, 0xA));++ if (SubClass =3D=3D PCI_CLASS_SERIAL_SM= B) {+ > BreakLoop =3D TRUE;+ PciDevice =3D PCI_LIB_ADDRESS (0, Device, F= unction, > 0x00);+ break;+ }+ }+ }++ if (BreakLoop) {+ = break;+ }+ }++ if > (!BreakLoop) {+ DEBUG ((EFI_D_INFO, "No PCI SMBUS controller > found.\n"));+ return EFI_UNSUPPORTED;+ }++ DEBUG ((EFI_D_INFO, "PCI > Device found on 0-%x-%x\n", Device, Function));++ IoBase =3D > SmbusGetSMBaseAddress ();+ if (!IoBase) {+ return > EFI_UNSUPPORTED;+ }++ DEBUG ((+ EFI_D_INFO,+ "%a: Detected i801 > SMBus controller with SMBASE 0x%x\n",+ __FUNCTION__,+ > IoBase+ ));++ Status =3D gBS->InstallProtocolInterface (+ > &mDriverHandle,+ &gEfiSmbusHcProtocolGuid,+ > EFI_NATIVE_INTERFACE,+ &mSmbusProtocol+ = );++ if > (EFI_ERROR (Status)) {+ return Status;+ }++ return EFI_SUCCESS;+}dif= f --git > a/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.h > b/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.h > new file mode 100644 > index 0000000000..e88823da31 > --- /dev/null > +++ b/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.h > @@ -0,0 +1,17 @@ > +/** @file+ Header file for a generic i801 SMBUS driver.++Copyright (c) > +2016, Intel Corporation. All rights > +reserved.
+SPDX-License-Identifier: > +BSD-2-Clause-Patent+++**/+#ifndef _PCI_PLATFORM_DXE_H_+#define > +_PCI_PLATFORM_DXE_H_+#include ++#include > ++#include +#include > +++#endifdiff --git > +a/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.inf > +b/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.inf > new file mode 100644 > index 0000000000..7d13c446ef > --- /dev/null > +++ b/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.inf > @@ -0,0 +1,45 @@ > +## @file+# This driver produces gEfiSmbusHcProtocolGuid protocol to load > access SMBUS devices+#+# Copyright (c) 2020, 9elements Agency > GmbH+#+# SPDX-License-Identifier: BSD-2-Clause- > Patent+#+#+##++[Defines]+ INF_VERSION =3D 0x00010005+ > BASE_NAME =3D SMBusi801Dxe+ FILE_GUID = =3D 390208DA- > 8E6F-4957-90D6-421737FEA9BF+ MODULE_TYPE =3D DXE_DRIV= ER+ > VERSION_STRING =3D 1.0+ ENTRY_POINT = =3D > InstallSmbusProtocol++#+# The following information is for reference only > and not required by the build tools.+#+# VALID_ARCHITECTURES = =3D IA32 > X64+#++[Sources.common]+ SMBusi801Dxe.h+ > SMBusi801Dxe.c++[Packages]+ MdePkg/MdePkg.dec+ > MdeModulePkg/MdeModulePkg.dec++[LibraryClasses]+ > UefiDriverEntryPoint+ DebugLib+ IoLib+ UefiLib+ TimerLib+ > PciLib++[Protocols]+ gEfiSmbusHcProtocolGuid ## > PRODUCES++[Depex]+ TRUEdiff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc > b/UefiPayloadPkg/UefiPayloadPkg.dsc > index 1ce96a51c1..54543b7623 100644 > --- a/UefiPayloadPkg/UefiPayloadPkg.dsc > +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc > @@ -290,6 +290,7 @@ > !if $(PERFORMANCE_MEASUREMENT_ENABLE) > PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCore > PerformanceLib.inf !endif+ > SmbusLib|MdePkg/Library/DxeSmbusLib/DxeSmbusLib.inf > [LibraryClasses.common.DXE_DRIVER] > PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf@@ -304,6 +305,7 @@ > !if $(PERFORMANCE_MEASUREMENT_ENABLE) > PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerforma > nceLib.inf !endif+ > SmbusLib|MdePkg/Library/DxeSmbusLib/DxeSmbusLib.inf > [LibraryClasses.common.DXE_RUNTIME_DRIVER] > PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf@@ -657,6 +659,11 @@ > !endif MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf + #+ # > SMBUS Support+ #+ UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.inf+ # # > Console Support #diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf > b/UefiPayloadPkg/UefiPayloadPkg.fdf > index c7b04978ad..8861d29162 100644 > --- a/UefiPayloadPkg/UefiPayloadPkg.fdf > +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf > @@ -178,6 +178,11 @@ INF > MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf > !endif INF MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf +#+# > SMBUS Support+#+INF UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.inf+ # # > Console Support #-- > 2.32.0 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#86730): https://edk2.groups.io/g/devel/message/86730 > Mute This Topic: https://groups.io/mt/89214991/1773972 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [maurice.ma@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D >=20