From: "Benjamin Doron" <benjamin.doron00@gmail.com>
To: devel@edk2.groups.io
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>,
Isaac Oram <isaac.w.oram@intel.com>,
Nate DeSimone <nathaniel.l.desimone@intel.com>,
Chasel Chiu <chasel.chiu@intel.com>
Subject: [edk2-platforms][PATCH v1] KabylakeOpenBoardPkg/I2cHdmiDebugSerialPortLib: Configurable timings
Date: Wed, 11 Jan 2023 15:18:25 -0500 [thread overview]
Message-ID: <20230111201825.1584047-1-benjamin.doron00@gmail.com> (raw)
Now that an implementation of the HDMI debug port is available at high
speed, make the timing parameters configurable. As this is
implementation-, not board-layer, perhaps these could become
dynamic PCDs.
Arduino sketch available at
https://github.com/benjamindoron/i2c_debug_port.
Tested on Adafruit ItsyBitsy M4, using 1 MHz clock and 60 us delay.
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
---
.../DxeI2cHdmiDebugSerialPortLib.inf | 2 ++
.../Library/I2cHdmiDebugSerialPortLib/Gmbus.c | 11 ++++++++---
.../I2cDebugPortProtocol.c | 13 ++++++++++---
.../PeiI2cHdmiDebugSerialPortLib.inf | 2 ++
.../SecI2cHdmiDebugSerialPortLib.inf | 2 ++
.../SmmI2cHdmiDebugSerialPortLib.inf | 2 ++
.../KabylakeOpenBoardPkg/OpenBoardPkg.dec | 19 +++++++++++++++++++
9 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
index 327afdce519a..54c3c2fdcc24 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
@@ -49,3 +49,5 @@
[Pcd]
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel ## CONSUMES
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
index b673926dcc6b..b6d3bd1f8ce9 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
@@ -444,6 +444,7 @@ GmbusRead (
{
EFI_STATUS Status;
EFI_STATUS Status2;
+ UINT8 GmbusClockRate;
UINT32 Index;
UINT32 GmbusCmdSts;
UINT32 GmbusStatus;
@@ -472,8 +473,9 @@ GmbusRead (
//
// Configure Gmbus port and clock speed
- //GMBUS_CLOCK_RATE_100K @todo
- Status = GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTTMMADR_GMBUS0_PIN_PAIR_MASK));
+ //
+ GmbusClockRate = FixedPcdGet8 (PcdI2cHdmiDebugPortGmbusClockRate);
+ Status = GmbusPrepare (GmbusClockRate, (DdcBusPinPair & B_SA_GTTMMADR_GMBUS0_PIN_PAIR_MASK));
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -608,6 +610,7 @@ GmbusWrite (
{
EFI_STATUS Status;
EFI_STATUS Status2;
+ UINT8 GmbusClockRate;
UINT32 Index;
UINT32 GmbusCmdSts;
UINT32 GmbusStatus;
@@ -638,7 +641,9 @@ GmbusWrite (
//
// Configure Gmbus port and clock speed
- Status = GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTTMMADR_GMBUS0_PIN_PAIR_MASK));
+ //
+ GmbusClockRate = FixedPcdGet8 (PcdI2cHdmiDebugPortGmbusClockRate);
+ Status = GmbusPrepare (GmbusClockRate, (DdcBusPinPair & B_SA_GTTMMADR_GMBUS0_PIN_PAIR_MASK));
if (EFI_ERROR (Status)) {
goto Done;
}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
index 52689c98d11d..56117bad8fb1 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
@@ -8,6 +8,7 @@
#include <Base.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
#include <Library/TimerLib.h>
#include <IgfxI2c.h>
@@ -36,6 +37,7 @@ I2cDebugPortWrite (
UINT8 WriteBuffer[I2C_DEBUG_PORT_MAX_DATA_SIZE + 1];
EFI_STATUS Status;
UINT32 Index;
+ UINTN ImplementationDelayUs;
UINT8 CurrentSize;
UINT8 DdcBusPinPair;
@@ -50,8 +52,9 @@ I2cDebugPortWrite (
return Status;
}
RaiseTplForI2cDebugPortAccess ();
+ ImplementationDelayUs = FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallUs); //BP: 3ms stall to catch up
for (Index = 0; Index < Count; Index += I2C_DEBUG_PORT_MAX_DATA_SIZE) {
- MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up
+ MicroSecondDelay (ImplementationDelayUs);
if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >= Count) {
CurrentSize = (UINT8) (Count - Index);
} else {
@@ -93,6 +96,7 @@ I2cDebugPortRead (
EFI_STATUS Status;
UINT32 Index;
UINT32 BytesRead;
+ UINTN ImplementationDelayUs;
UINT32 CurrentSize;
UINT8 DdcBusPinPair;
UINT8 GmbusIndexData;
@@ -109,8 +113,9 @@ I2cDebugPortRead (
return Status;
}
RaiseTplForI2cDebugPortAccess ();
+ ImplementationDelayUs = FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallUs); //BP: 3ms stall to catch up
for (Index = 0; Index < (*Count); Index += I2C_DEBUG_PORT_MAX_DATA_SIZE) {
- MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up
+ MicroSecondDelay (ImplementationDelayUs);
if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >= (*Count)) {
CurrentSize = (*Count) - Index;
} else {
@@ -161,6 +166,7 @@ I2cDebugPortReadyToRead (
EFI_STATUS Status;
UINT32 BytesRead;
UINT8 DdcBusPinPair;
+ UINTN ImplementationDelayUs;
UINT8 GmbusIndexData;
BytesRead = 1;
@@ -171,7 +177,8 @@ I2cDebugPortReadyToRead (
if (EFI_ERROR (Status)) {
return Status;
}
- MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up
+ ImplementationDelayUs = FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallUs); //BP: 3ms stall to catch up
+ MicroSecondDelay (ImplementationDelayUs);
GmbusIndexData = (I2C_DEBUG_PORT_READY_TO_READ_COMMAND << I2C_DEBUG_PORT_COMMAND_BIT_POSITION) |
(1 & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK); //READY_TO_READ always returns 1 byte
RaiseTplForI2cDebugPortAccess ();
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
index 18aee1f91c92..da1f08dbccdd 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
@@ -51,3 +51,5 @@
[Pcd]
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel ## CONSUMES
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
index d1593f6c3908..863a0eeee442 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
@@ -46,3 +46,5 @@
[Pcd]
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel ## CONSUMES
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
index 5bd1f52749a9..367646bebe02 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
@@ -47,3 +47,5 @@
[Pcd]
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel ## CONSUMES
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate ## CONSUMES
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
index 448eafacbfcd..048b826e2994 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
@@ -102,6 +102,25 @@ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalEnable|FALS
# @Prompt DDC I2C channel to claim as the HDMI debug port
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x00000000|UINT32|0x90000035
+## Specifies the DDC I2C speed to use for the HDMI debug port
+# The value is defined as below.
+# 0: I2C speed 100K
+# 1: I2C speed 50K
+# 2: I2C speed 400K
+# 3: I2C speed 1M
+# Recommendations as below:
+# BusPirate: 50K. Maybe 100K possible with more baudrate generator debug.
+# Atmel SAMD boards: 1M.
+# @Prompt DDC I2C speed to use for the HDMI debug port
+gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate|0x01|UINT8|0x90000036
+
+## Specifies the stall in microsends between packets on the HDMI debug port
+# Recommendations as below:
+# BusPirate: 3000
+# Atmel SAMD boards: 60
+# @Prompt DDC I2C speed to use for the HDMI debug port
+gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs|3000|UINT32|0x90000037
+
[PcdsDynamic]
# Board GPIO Table
--
2.38.1
reply other threads:[~2023-01-11 20:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230111201825.1584047-1-benjamin.doron00@gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox