[edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller DXE

2022-02-17 Thread Sean Rhodes
From: Patrick Rudolph 

Implement a subset of the gEfiSmbusHcProtocolGuid using a generic
PCI i801 SMBus controller.

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

diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli 
b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
index f4153a09f8..666c3280cc 16
--- 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 00..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 = NULL;
+UINT32  PciDevice = 0;
+
+/* SMBus register offsets. */
+#define 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 Status 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 = 0;
+  //
+  // Test if I/O decoding is enabled
+  //
+  Cmd = PciRead16 (PciDevice + 0x4);
+  if (!(Cmd & 1)) {
+goto CloseAndReturn;
+  }
+
+  //
+  // Test if BAR0 is I/O bar and enabled
+  //
+  Reg32 = PciRead16 (PciDevice + 0x20);
+  if (!(Reg32 & 1) || !(Reg32 & 0xfffc) || ((Reg32 & 0xfffc) == 0xfffc)) {
+goto CloseAndReturn;
+  }
+
+  IoBase = Reg32 & 0xfffc;
+
+CloseAndReturn:
+  return IoBase;
+}
+
+STATIC
+EFI_STATUS
+SmbusSetupCommand (
+  IN UINT16  IoBase,
+  IN UINT8   Ctrl,
+  IN UINT8   Xmitadd
+  )
+{
+  UINTN  Loops = 1;
+  UINT8  host_busy;
+
+  do {
+MicroSecondDelay (100);
+host_busy = IoRead8 (IoBase + SMBHSTSTAT) & SMBHSTSTS_HOST_BUSY;
+  } while (--Loops && host_busy);
+
+  if (Loops == 0) {
+return EFI_TIMEOUT;
+  }
+
+  /* Clear any lingering errors, so the transaction will run. */
+  IoWrite8 (IoBase + 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 = 1;
+  UINT8  Status;
+
+  /* Start the command. */
+  IoWrite8 (IoBase + SMBHSTCTL, IoRead8 (IoBase + SMBHSTCTL) | 
SMBHSTCNT_START);
+  Status = IoRead8 (IoBase + SMBHSTSTAT);
+
+  /* Poll for it to start. */
+  do {
+MicroSecondDelay (100);
+
+/* If we poll too slow, we could miss HOST_BUSY flag
+ * set and detect INTR or x_ERR flags instead here.
+ */
+Status = IoRead8 (IoBas

Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller DXE

2022-02-17 Thread Ma, Maurice
This vendor specific device driver implementation does not seem to fit into 
UEFI payload package scope well.   

Do you think https://github.com/tianocore/edk2-platforms/tree/master/Silicon 
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
> 
> From: Patrick Rudolph 
> 
> Implement a subset of the gEfiSmbusHcProtocolGuid using a generic PCI i801
> SMBus controller.
> 
> 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
> 
> diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> index f4153a09f8..666c3280cc 16
> --- 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 00..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 =
> NULL;+UINT32  PciDevice = 0;++/* SMBus register offsets. */+#define
> 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 Status
> 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 = 0;+  //+  // Test
> if I/O decoding is enabled+  //+  Cmd = PciRead16 (PciDevice + 0x4);+  if
> (!(Cmd & 1)) {+goto CloseAndReturn;+  }++  //+  // Test if BAR0 is I/O bar
> and enabled+  //+  Reg32 = PciRead16 (PciDevice + 0x20);+  if (!(Reg32 & 1)
> || !(Reg32 & 0xfffc) || ((Reg32 & 0xfffc) == 0xfffc)) {+goto
> CloseAndReturn;+  }++  IoBase = Reg32 & 0xfffc;++CloseAndReturn:+  return
> IoBase;+}++STATIC+EFI_STATUS+SmbusSetupCommand (+  IN UINT16
> IoBase,+  IN UINT8   Ctrl,+  IN UINT8   Xmitadd+  )+{+  UINTN  Loops = 1;+
> UINT8  host_busy;++  do {+MicroSecond

Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller DXE

2022-02-24 Thread Patrick Rudolph
Hi Maurice,
I agree that edk2-platforms is the right place.
How should it be used to build UefiPlayloadPkg? Should it be hooked up
as git submodule?

Just wondering why you added vendor (or platform) specific code in
UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf ?
Please clarify.

Regards,
Patrick Rudolph

On Thu, Feb 17, 2022 at 7:24 PM Ma, Maurice  wrote:
>
> This vendor specific device driver implementation does not seem to fit into 
> UEFI payload package scope well.
>
> Do you think https://github.com/tianocore/edk2-platforms/tree/master/Silicon 
> 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
> >
> > From: Patrick Rudolph 
> >
> > Implement a subset of the gEfiSmbusHcProtocolGuid using a generic PCI i801
> > SMBus controller.
> >
> > 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
> >
> > diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> > b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> > index f4153a09f8..666c3280cc 16
> > --- 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 00..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 =
> > NULL;+UINT32  PciDevice = 0;++/* SMBus register offsets. */+#define
> > 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 Status
> > 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(

Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller DXE

2022-02-24 Thread Guo Dong

Hi Patrick,

UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf is a common module as the 
commit message mentioned as below:

* UefiPayloadPkg: Add SpiFlashLib

This is a common SPI Flash library used for the Intel platform that
supports SPI hardware sequence. This library provides actual SPI flash
operation via Intel PCH SPI controller.

Thanks,
Guo

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Patrick Rudolph
Sent: Thursday, February 24, 2022 3:46 AM
To: devel@edk2.groups.io; Ma, Maurice 
Cc: Rhodes, Sean ; Dong, Guo ; Ni, 
Ray ; You, Benjamin 
Subject: Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller 
DXE

Hi Maurice,
I agree that edk2-platforms is the right place.
How should it be used to build UefiPlayloadPkg? Should it be hooked up as git 
submodule?

Just wondering why you added vendor (or platform) specific code in 
UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf ?
Please clarify.

Regards,
Patrick Rudolph

On Thu, Feb 17, 2022 at 7:24 PM Ma, Maurice  wrote:
>
> This vendor specific device driver implementation does not seem to fit into 
> UEFI payload package scope well.
>
> Do you think https://github.com/tianocore/edk2-platforms/tree/master/Silicon 
> 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
> >
> > From: Patrick Rudolph 
> >
> > Implement a subset of the gEfiSmbusHcProtocolGuid using a generic 
> > PCI i801 SMBus controller.
> >
> > 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
> >
> > diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> > b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> > index f4153a09f8..666c3280cc 16
> > --- 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 00..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 =
> > NULL;+UINT32  PciDevice = 0;++/* SMBus register offsets. */+#define
> > 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 SMBHSTCN

Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller DXE

2022-02-24 Thread Guo Dong

Hi Patrick,

You could refer this page https://github.com/tianocore/edk2-platforms on how to 
build platform with EDK2 and edk2-platform repo.

I had thought you added a SMbus driver that could only work on a particular 
device.  I agree with Maurice to put this kind of modules to Edk2-platform repo.
For SpiFlashLib it is library specific for Intel PCH SPI, we ever discussed to 
put to edk2-platform before.  But we temporarily put to EDK2 with other SMM 
modules for convenience since there is only few this kind of modules.
Let me explore a solution to move PCH specific modules to edk2-platform. Maybe 
create PayloadPlatformPkg under edk2-platforms\Platform\Intel to build 
universal UEFI payload from Edk2 repo, and build a separate FV to include PCH 
specific modules from edk2-platform repo. The build script could add the FV 
into the universal payload as a section of universal payload defined by the 
universal payload specification. This way the UEFI payload in EDK2 could be 
generic enough without platform specific modules.

Thanks,
Guo

-Original Message-
From: Dong, Guo 
Sent: Thursday, February 24, 2022 8:54 AM
To: devel@edk2.groups.io; patrick.rudo...@9elements.com; Ma, Maurice 

Cc: Rhodes, Sean ; Ni, Ray ; You, 
Benjamin 
Subject: RE: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller 
DXE


Hi Patrick,

UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf is a common module as the 
commit message mentioned as below:

* UefiPayloadPkg: Add SpiFlashLib

This is a common SPI Flash library used for the Intel platform that supports 
SPI hardware sequence. This library provides actual SPI flash operation via 
Intel PCH SPI controller.

Thanks,
Guo

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Patrick Rudolph
Sent: Thursday, February 24, 2022 3:46 AM
To: devel@edk2.groups.io; Ma, Maurice 
Cc: Rhodes, Sean ; Dong, Guo ; Ni, 
Ray ; You, Benjamin 
Subject: Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add i801 SMBus controller 
DXE

Hi Maurice,
I agree that edk2-platforms is the right place.
How should it be used to build UefiPlayloadPkg? Should it be hooked up as git 
submodule?

Just wondering why you added vendor (or platform) specific code in 
UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf ?
Please clarify.

Regards,
Patrick Rudolph

On Thu, Feb 17, 2022 at 7:24 PM Ma, Maurice  wrote:
>
> This vendor specific device driver implementation does not seem to fit into 
> UEFI payload package scope well.
>
> Do you think https://github.com/tianocore/edk2-platforms/tree/master/Silicon 
> 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
> >
> > From: Patrick Rudolph 
> >
> > Implement a subset of the gEfiSmbusHcProtocolGuid using a generic 
> > PCI i801 SMBus controller.
> >
> > 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
> >
> > diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> > b/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
> > index f4153a09f8..666c3280cc 16
> > --- 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 00..7bf7b893ad
> > --- /dev/null
> > +++ b/UefiPayloadPkg/SmbusDxe/SMBusi801Dxe.c
> > @@ -0,0 +1,556 @@
> > +/** @file+  Implementation for a generic i801 SMBus 
> > +driver.++Copyright (c)
> > 2016, Intel