From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) by mx.groups.io with SMTP id smtpd.web10.95195.1673632606490455124 for ; Fri, 13 Jan 2023 09:56:46 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=G4ei79p9; spf=pass (domain: gmail.com, ip: 209.85.217.42, mailfrom: benjamin.doron00@gmail.com) Received: by mail-vs1-f42.google.com with SMTP id o63so22956029vsc.10 for ; Fri, 13 Jan 2023 09:56:46 -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=DVcmx7IHhW6t2Y8kAAvyZRBL5J+CVu7JFN90r1G6QE0=; b=G4ei79p9/nUHW65AreQ2iLswRe7QPCUJj7ymEp+R5llQoB1ghom26EnoKv+P1gANvs q1WxJnV01gDLHvlZsE9c2Xqy51jLCFq/6H1+JKpU2AEIZZCnsSQuJL5M1g56tiF0oXxi b25/85waaWGW7ErtCQvgyoSxa290IO+DhdN31AcDnAAjE3BMPBwOxHzNYiKtcXyhDblZ 9XmJRvoaY1eqcvZFhTjiN0RTWhr129Pt7F4NNf9+gEF1Nv7ZAkdsECeo3DpjioW71Y4g E7wizDCxcAMbrP3xx4YB4dpBibzDmoEHVntAcqGwa/0TrnNMG4/EZaR9ZfcHTDWEyLFF xlHw== 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=DVcmx7IHhW6t2Y8kAAvyZRBL5J+CVu7JFN90r1G6QE0=; b=3MhuJVVS9o/HTCg8Dt6rTN79upJaNhJ4cRzWV7ktRQlF4ZyEfAxs3ODke3mL/2KQV+ 6cCFIQEM0oceBNJ/KTZOXfvdxlSRc0619G6Gk86dehLr9+Q8dyrx9Kmuqd803acqASls KBQrdarWVMqDMyB5EZ3XlSJgvnJib1tnplk1AEXXIeU5oE90VIMESJmiCDd/GgFoVlkc HYUhIjdpKbjryHnSDbwEfTZLJoXAKHPtj7l7y1deXo0zlcChw+aQd01357j9EgjEiktb Wh/t8cM+NSHLdM/KB4ODeleprellp3FwhovUdt5hoCPwuwrK2UcdaRD4AsgiN4rKyqPq CpEw== X-Gm-Message-State: AFqh2kqJeg7MJN6b/tCwVNAn+ldCydqX4eLbVeYDOQf5A4ltwq5zd5iN 3XgD5nwxRLYuA2cdw+SmGxSeEga5G0k= X-Google-Smtp-Source: AMrXdXtAV9r4OzcWUouYglknwDvNR3Gg/UD06btFgUdOg9/F8hAMs8suIR+CdzKxsu4hEPB1+q3ZyA== X-Received: by 2002:a05:6102:f07:b0:3d0:cfd6:5d0d with SMTP id v7-20020a0561020f0700b003d0cfd65d0dmr12246762vss.5.1673632605231; Fri, 13 Jan 2023 09:56:45 -0800 (PST) Return-Path: Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:b067:d983:eed5:30ec]) by smtp.gmail.com with ESMTPSA id x10-20020a05620a448a00b006faa2c0100bsm13202094qkp.110.2023.01.13.09.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 09:56:44 -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 v2] KabylakeOpenBoardPkg/I2cHdmiDebugSerialPortLib: Configurable timings Date: Fri, 13 Jan 2023 12:56:17 -0500 Message-Id: <7e10276730e9a60e39dc5f4be06a49c2a11e56a5.1673632431.git.benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 dependent, 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 | 9 +++++++-- .../I2cDebugPortProtocol.c | 12 +++++++++--- .../PeiI2cHdmiDebugSerialPortLib.inf | 2 ++ .../SecI2cHdmiDebugSerialPortLib.inf | 2 ++ .../SmmI2cHdmiDebugSerialPortLib.inf | 2 ++ .../KabylakeOpenBoardPkg/OpenBoardPkg.dec | 19 +++++++++++++++++++ 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/DxeI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf index 736b11a561f0..e8af25161008 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /DxeI2cHdmiDebugSerialPortLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /DxeI2cHdmiDebugSerialPortLib.inf @@ -51,3 +51,5 @@ [Pcd]=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel = ## CONSUMES=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs = ## CONSUMES=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/Gmbus.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugS= erialPortLib/Gmbus.c index c6453117843a..31965a1b3a54 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /Gmbus.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /Gmbus.c @@ -443,6 +443,7 @@ GmbusRead ( {=0D EFI_STATUS Status;=0D EFI_STATUS Status2;=0D + UINT8 GmbusClockRate;=0D UINT32 Index;=0D UINT32 GmbusCmdSts;=0D UINT32 GmbusStatus;=0D @@ -472,7 +473,8 @@ GmbusRead ( //=0D // Configure Gmbus port and clock speed=0D //=0D - Status =3D GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTT= MMADR_GMBUS0_PIN_PAIR_MASK));=0D + GmbusClockRate =3D FixedPcdGet8 (PcdI2cHdmiDebugPortGmbusClockRate);=0D + Status =3D GmbusPrepare (GmbusClockRate, (DdcBusPinPair & B_SA_GTTMMADR_= GMBUS0_PIN_PAIR_MASK));=0D if (EFI_ERROR (Status)) {=0D goto Done;=0D }=0D @@ -607,6 +609,7 @@ GmbusWrite ( {=0D EFI_STATUS Status;=0D EFI_STATUS Status2;=0D + UINT8 GmbusClockRate;=0D UINT32 Index;=0D UINT32 GmbusCmdSts;=0D UINT32 GmbusStatus;=0D @@ -637,7 +640,9 @@ GmbusWrite ( =0D //=0D // Configure Gmbus port and clock speed=0D - Status =3D GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTT= MMADR_GMBUS0_PIN_PAIR_MASK));=0D + //=0D + GmbusClockRate =3D FixedPcdGet8 (PcdI2cHdmiDebugPortGmbusClockRate);=0D + Status =3D GmbusPrepare (GmbusClockRate, (DdcBusPinPair & B_SA_GTTMMADR_= GMBUS0_PIN_PAIR_MASK));=0D if (EFI_ERROR (Status)) {=0D goto Done;=0D }=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/I2cDebugPortProtocol.c b/Platform/Intel/KabylakeOpenBoardPkg/Librar= y/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c index f76bcf364cd1..d64251b75b4e 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /I2cDebugPortProtocol.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /I2cDebugPortProtocol.c @@ -38,6 +38,7 @@ I2cDebugPortWrite ( UINT8 WriteBuffer[I2C_DEBUG_PORT_MAX_DATA_SIZE + 1];=0D EFI_STATUS Status;=0D UINT32 Index;=0D + UINT32 ImplementationDelayUs;=0D UINT8 CurrentSize;=0D UINT8 DdcBusPinPair;=0D =0D @@ -51,9 +52,10 @@ I2cDebugPortWrite ( if (EFI_ERROR (Status)) {=0D return Status;=0D }=0D + ImplementationDelayUs =3D FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallU= s); //BP: 3ms stall to catch up=0D RaiseTplForI2cDebugPortAccess ();=0D for (Index =3D 0; Index < Count; Index +=3D I2C_DEBUG_PORT_MAX_DATA_SIZE= ) {=0D - MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up=0D + MicroSecondDelay (ImplementationDelayUs);=0D if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >=3D Count) {=0D CurrentSize =3D (UINT8) (Count - Index);=0D } else {=0D @@ -95,6 +97,7 @@ I2cDebugPortRead ( EFI_STATUS Status;=0D UINT32 Index;=0D UINT32 BytesRead;=0D + UINT32 ImplementationDelayUs;=0D UINT32 CurrentSize;=0D UINT8 DdcBusPinPair;=0D UINT8 GmbusIndexData;=0D @@ -110,9 +113,10 @@ I2cDebugPortRead ( if (EFI_ERROR (Status)) {=0D return Status;=0D }=0D + ImplementationDelayUs =3D FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallU= s); //BP: 3ms stall to catch up=0D RaiseTplForI2cDebugPortAccess ();=0D for (Index =3D 0; Index < (*Count); Index +=3D I2C_DEBUG_PORT_MAX_DATA_S= IZE) {=0D - MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up=0D + MicroSecondDelay (ImplementationDelayUs);=0D if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >=3D (*Count)) {=0D CurrentSize =3D (*Count) - Index;=0D } else {=0D @@ -163,6 +167,7 @@ I2cDebugPortReadyToRead ( EFI_STATUS Status;=0D UINT32 BytesRead;=0D UINT8 DdcBusPinPair;=0D + UINT32 ImplementationDelayUs;=0D UINT8 GmbusIndexData;=0D =0D BytesRead =3D 1;=0D @@ -173,7 +178,8 @@ I2cDebugPortReadyToRead ( if (EFI_ERROR (Status)) {=0D return Status;=0D }=0D - MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up=0D + ImplementationDelayUs =3D FixedPcdGet32 (PcdI2cHdmiDebugPortPacketStallU= s); //BP: 3ms stall to catch up=0D + MicroSecondDelay (ImplementationDelayUs);=0D GmbusIndexData =3D (I2C_DEBUG_PORT_READY_TO_READ_COMMAND << I2C_DEBUG_P= ORT_COMMAND_BIT_POSITION) |=0D (1 & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK); //READY_TO_RE= AD always returns 1 byte=0D RaiseTplForI2cDebugPortAccess ();=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/PeiI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf index c82e0c9e9b76..c141521a0cd9 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /PeiI2cHdmiDebugSerialPortLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /PeiI2cHdmiDebugSerialPortLib.inf @@ -52,3 +52,5 @@ [Pcd]=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel = ## CONSUMES=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs = ## CONSUMES=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/SecI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf index 3b84b25c3148..ed755699c312 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /SecI2cHdmiDebugSerialPortLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /SecI2cHdmiDebugSerialPortLib.inf @@ -51,3 +51,5 @@ [Pcd]=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel = ## CONSUMES=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs = ## CONSUMES=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/SmmI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf index 68ff31495071..9f46d45b8a38 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /SmmI2cHdmiDebugSerialPortLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /SmmI2cHdmiDebugSerialPortLib.inf @@ -51,3 +51,5 @@ [Pcd]=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel = ## CONSUMES=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate = ## CONSUMES=0D + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs = ## CONSUMES=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec b/Platfor= m/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec index 448eafacbfcd..401f6416aa1c 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=0D gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x000= 00000|UINT32|0x90000035=0D =0D +## Specifies the DDC I2C speed to use for the HDMI debug port=0D +# The value is defined as below.=0D +# 0: I2C speed 100K=0D +# 1: I2C speed 50K=0D +# 2: I2C speed 400K=0D +# 3: I2C speed 1M=0D +# Recommendations as below:=0D +# BusPirate: 50K. Increase internal baudrate generator for 100K, maybe 40= 0K. Potentially less stable=0D +# Atmel SAMD boards: 1M=0D +# @Prompt DDC I2C speed to use for the HDMI debug port=0D +gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortGmbusClockRate|0x01= |UINT8|0x90000036=0D +=0D +## Specifies the stall in microsends between packets on the HDMI debug por= t=0D +# Recommendations as below:=0D +# BusPirate: 3000=0D +# Atmel SAMD boards: 60=0D +# @Prompt Stall in microsends between packets on the HDMI debug port=0D +gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortPacketStallUs|3000|= UINT32|0x90000037=0D +=0D [PcdsDynamic]=0D =0D # Board GPIO Table=0D --=20 2.39.0