From nobody Tue May 14 11:38:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+98310+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98310+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1673468340; cv=none; d=zohomail.com; s=zohoarc; b=PbrjaqVSLFTgX57+JY8bUSf8y9rUQ5wEy3f+iO2IFFdwwAScz+O6p13NbUl2z9AO4uf3KVfftfmGrMp6yj5MbWUepd+BPfq5Ekrqn77f5sjbhc70Egs87NOHGmw/aFWuzPbVTVf9oam/6d+ppTG5xLVmDchOMZgLD0ephI4SVNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673468340; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=1T+CPP4a39cVPAOIZqTgt/qDdi/j29T+vcaaj3yG1Xk=; b=TnDKfQRpUruOzLGmhkAedLneHYGhijlSS0WLSwEzTAuIatrfWR4Sk5q1xtJi+4a4zdceXW9Z0tPoRPUJ3Pbq63+TbCHtnVHwepM2GwauQ6l4bozZ208U9gR7npcApMKNVQit07oG2TGivm9WxQwF9Gsl01s3TbCZUARmaoo89gA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98310+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1673468340507585.8408322848345; Wed, 11 Jan 2023 12:19:00 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id abZpYY1788612xPEJRzSWQ3L; Wed, 11 Jan 2023 12:18:59 -0800 X-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 X-Received: by mail-qt1-f173.google.com with SMTP id x7so4664523qtv.13 for ; Wed, 11 Jan 2023 12:18:59 -0800 (PST) X-Gm-Message-State: qZiPkpX04DCzhrlqVFzRd6rcx1787277AA= 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) X-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-devel] [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> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1673468339; bh=9pJq8ETc9beWn/wMND5cu3C4cKIdrP43lucSswEvXhU=; h=Cc:Date:From:Reply-To:Subject:To; b=JoMliGSnOviYqVrDM7camGwD6/e+i+K69MAxmI0tG+nbQN+pjMJcUTCB9+8iShWmTdy XdCPp88zeJbkvcxC5BzwiUoCdWEUx23ZXxzkNZiPgEZSSwqu/CW/YPyGmAA9IR8XtAzSl Hmw1UDdNMzbsw2LwWfQw78l7A0awDmizMhk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1673468342697100002 Content-Type: text/plain; charset="utf-8" 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/I2cHdmiDebugSerial= PortLib/DxeI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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/I2cHdmiDebugSerial= PortLib/Gmbus.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugS= erialPortLib/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 ( =20 // // Configure Gmbus port and clock speed - //GMBUS_CLOCK_RATE_100K @todo - Status =3D GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTT= MMADR_GMBUS0_PIN_PAIR_MASK)); + // + GmbusClockRate =3D FixedPcdGet8 (PcdI2cHdmiDebugPortGmbusClockRate); + Status =3D 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 ( =20 // // Configure Gmbus port and clock speed - Status =3D GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTT= MMADR_GMBUS0_PIN_PAIR_MASK)); + // + GmbusClockRate =3D FixedPcdGet8 (PcdI2cHdmiDebugPortGmbusClockRate); + Status =3D GmbusPrepare (GmbusClockRate, (DdcBusPinPair & B_SA_GTTMMADR_= GMBUS0_PIN_PAIR_MASK)); if (EFI_ERROR (Status)) { goto Done; } diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/I2cDebugPortProtocol.c b/Platform/Intel/KabylakeOpenBoardPkg/Librar= y/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 @@ =20 #include #include +#include #include =20 #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; =20 @@ -50,8 +52,9 @@ I2cDebugPortWrite ( return Status; } RaiseTplForI2cDebugPortAccess (); + ImplementationDelayUs =3D FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallU= s); //BP: 3ms stall to catch up for (Index =3D 0; Index < Count; Index +=3D 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) >=3D Count) { CurrentSize =3D (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 =3D FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallU= s); //BP: 3ms stall to catch up for (Index =3D 0; Index < (*Count); Index +=3D I2C_DEBUG_PORT_MAX_DATA_S= IZE) { - MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up + MicroSecondDelay (ImplementationDelayUs); if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >=3D (*Count)) { CurrentSize =3D (*Count) - Index; } else { @@ -161,6 +166,7 @@ I2cDebugPortReadyToRead ( EFI_STATUS Status; UINT32 BytesRead; UINT8 DdcBusPinPair; + UINTN ImplementationDelayUs; UINT8 GmbusIndexData; =20 BytesRead =3D 1; @@ -171,7 +177,8 @@ I2cDebugPortReadyToRead ( if (EFI_ERROR (Status)) { return Status; } - MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up + ImplementationDelayUs =3D FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallU= s); //BP: 3ms stall to catch up + MicroSecondDelay (ImplementationDelayUs); GmbusIndexData =3D (I2C_DEBUG_PORT_READY_TO_READ_COMMAND << I2C_DEBUG_P= ORT_COMMAND_BIT_POSITION) | (1 & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK); //READY_TO_RE= AD always returns 1 byte RaiseTplForI2cDebugPortAccess (); diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/PeiI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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/I2cHdmiDebugSerial= PortLib/SecI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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/I2cHdmiDebugSerial= PortLib/SmmI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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/Platfor= m/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.PcdI2cHdmiDebugPor= tSerialTerminalEnable|FALS # @Prompt DDC I2C channel to claim as the HDMI debug port gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x000= 00000|UINT32|0x90000035 =20 +## 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] =20 # Board GPIO Table --=20 2.38.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 (#98310): https://edk2.groups.io/g/devel/message/98310 Mute This Topic: https://groups.io/mt/96208330/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-