From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by mx.groups.io with SMTP id smtpd.web11.35517.1673468339148471968 for ; Wed, 11 Jan 2023 12:18:59 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JWvzHvvP; spf=pass (domain: gmail.com, ip: 209.85.160.173, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qt1-f173.google.com with SMTP id x7so4664523qtv.13 for ; Wed, 11 Jan 2023 12:18:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6Xgl+9UaNJP+CKf0O3QnweEVS4jeywizexpHZ6SlfFY=; b=JWvzHvvPxVCAtcaZNJi3e4HPguUBX1yZ0p/cTDwzi6E5VSwNJnR4MI0C8767mvPC3e brbKvpRU3stQCx47LkNVNr4dfJ/ivIN+WHojLH0RFHg0tS6h/hdn5lPfGhs7O4RfCEWH w/NF7tKiIn9TRoJ07mLmqSDA5J24fbgrQUicSMNjVvfjYGrgpzwlfp4Dh1u7vnWTUKx2 F5pmkOBQlYoHt/24+EoqFTM40tJ005hmhIz19BarsNtdaoPEk+gA3HbMLfU/lLevkJoX TJPYZkb1R4XuLXBY4ndmXcYTKSp8X/01jTxqeb+JVUqMIXOh37vBz3+a4gHXT5HPsMWs Km6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6Xgl+9UaNJP+CKf0O3QnweEVS4jeywizexpHZ6SlfFY=; b=nmzFIh797pWh35X/h0aUHQO3B6Vw/u22mb2SwCowr7JuQ9CePIMQkRxIeG/pBd6R5r C3q7DBy50IVDydG5Sh4jJd1RNMwP0yIZQj4eyckQjj0EDseNGX5gYHq9g2PLeFEoWjoR 5H2HhpFCmwKgf1opBqTLTAIQMiYE899emfvK8ENsma06U6Lv1TauPTuA8rQrreEBLkF0 uE+njdfXrpOaMFixHoP5KaMBcj+XBhtJMRLcYoNFkw2w4GskyjvCQICywWc4gzgeB4mL AD6CS1Ep0TG+5kk4WeUfDsywZOLqZzqOHdk+TAOpGe1Hn87vxE+W1ra1Qt9rUttqWdGa K/Jw== X-Gm-Message-State: AFqh2kr8R2PadBneF85yaLCE5fRRncIGFFFlaLrQsiNgvf3NO49SE6hP s238UQ4ujo8gaCDtN+pUZnNk+5le+zU= X-Google-Smtp-Source: AMrXdXt4AnvC0uL6ntWKJUE4bLc3jW062jeu5vXPn6Pv4gOYuCywRLjJC21CG55sQEyagVgoYefM1Q== X-Received: by 2002:a05:622a:5c85:b0:3a7:e271:fc05 with SMTP id ge5-20020a05622a5c8500b003a7e271fc05mr96299996qtb.3.1673468337970; Wed, 11 Jan 2023 12:18:57 -0800 (PST) Return-Path: Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:e671:7c77:319e:bfc2]) by smtp.gmail.com with ESMTPSA id p23-20020ac87417000000b003ae7bf5c1d8sm720490qtq.25.2023.01.11.12.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:18:57 -0800 (PST) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Sai Chaganty , Isaac Oram , Nate DeSimone , Chasel Chiu Subject: [edk2-platforms][PATCH v1] KabylakeOpenBoardPkg/I2cHdmiDebugSerialPortLib: Configurable timings Date: Wed, 11 Jan 2023 15:18:25 -0500 Message-Id: <20230111201825.1584047-1-benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Isaac Oram Cc: Nate DeSimone Cc: Chasel Chiu Signed-off-by: Benjamin Doron --- .../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 #include +#include #include #include @@ -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