From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 320FCD8024B for ; Thu, 11 Jan 2024 00:04:34 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=8E/+R+mOWcD/qapTBJHBhTnHubskV+z1/DDaQtxQ+Qo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704931472; v=1; b=KxPgRh9tbQcYW2RSYINv6BGyXaxCCb4PuHk/S1EFRjWqCfFAMv3cq8bH+KgqZURTIvdONetx Tv1nST4JrEqQyWcHajgpPLAV2+YehGUXMGpbSFPY4fVTYB3sNi0nhHNUjPopFWpGfxlQLZtX+zV 4JUY3JrK5rfiCTqypS8pgUnc= X-Received: by 127.0.0.2 with SMTP id 1zEXYY7687511xNoytHrbV8j; Wed, 10 Jan 2024 16:04:32 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.9467.1704931469122767513 for ; Wed, 10 Jan 2024 16:04:29 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 40AC21424; Wed, 10 Jan 2024 16:05:15 -0800 (PST) X-Received: from u200865.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 290353F5A1; Wed, 10 Jan 2024 16:04:29 -0800 (PST) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: ardb+tianocore@kernel.org, quic_llindhol@quicinc.com, Jeremy Linton Subject: [edk2-devel] [RFC 4/6] Silicon/Maxim: Fix runtime issues Date: Wed, 10 Jan 2024 18:04:24 -0600 Message-ID: <20240111000426.2735007-5-jeremy.linton@arm.com> In-Reply-To: <20240111000426.2735007-1-jeremy.linton@arm.com> References: <20240111000426.2735007-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk 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,jeremy.linton@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: lsfbrdkM0TxlDtHMWGd6Brmqx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=KxPgRh9t; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) The Ds1307 is ideally a runtime RTC but its use of the I2C protocol might make it better if it updated the I2C_MASTER_PROTOCOL callbacks it uses, although... hmmm maybe think about this a bit more. Signed-off-by: Jeremy Linton --- .../Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c | 36 +++++++++++++++++-- .../Library/Ds1307RtcLib/Ds1307RtcLib.inf | 7 +++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c b/Silicon/= Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c index 444e011248..ede890448f 100644 --- a/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c +++ b/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.c @@ -18,14 +18,40 @@ #include #include #include +#include #include =20 #include "Ds1307Rtc.h" =20 STATIC VOID *mDriverEventRegistration; STATIC EFI_HANDLE mI2cMasterHandle; +STATIC EFI_EVENT mRtcVirtualAddrChangeEvent; STATIC EFI_I2C_MASTER_PROTOCOL *mI2cMaster; =20 + +/** + Fixup internal data so that EFI can be call in virtual mode. + Call the passed in Child Notify event and convert any pointers in + lib to virtual mode. + + @param[in] Event The Event that is being processed + @param[in] Context Event Context +**/ +VOID +EFIAPI +LibRtcVirtualNotifyEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EfiConvertPointer (0x0, (VOID **)&mI2cMaster->SetBusFrequency); + EfiConvertPointer (0x0, (VOID **)&mI2cMaster->Reset); + EfiConvertPointer (0x0, (VOID **)&mI2cMaster->StartRequest); + EfiConvertPointer (0x0, (VOID **)&mI2cMaster->I2cControllerCapabilitie= s); + EfiConvertPointer (0x0, (VOID **)&mI2cMaster); +} + + /** Read RTC register. Data Read-Slave Transmitter Mode @@ -54,7 +80,7 @@ RtcRead ( =20 Req.OperationCount =3D 2; =20 - Req.SetAddressOp.Flags =3D 0; + Req.SetAddressOp.Flags =3D 0; //I2C_FLAG_WRITE Req.SetAddressOp.LengthInBytes =3D sizeof (RtcRegAddr); Req.SetAddressOp.Buffer =3D &RtcRegAddr; =20 @@ -98,7 +124,7 @@ RtcWrite ( Buffer[0] =3D RtcRegAddr; Buffer[1] =3D Val; =20 - Req.SetAddressOp.Flags =3D 0; + Req.SetAddressOp.Flags =3D 0; //I2C_FLAG_WRITE Req.SetAddressOp.LengthInBytes =3D sizeof (Buffer); Req.SetAddressOp.Buffer =3D Buffer; =20 @@ -375,5 +401,11 @@ LibRtcInitialize ( NULL, &mDriverEventRegistration); =20 + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, + LibRtcVirtualNotifyEvent, NULL, + &gEfiEventVirtualAddressChangeGuid, + &mRtcVirtualAddrChangeEvent); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } diff --git a/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.inf b/Silico= n/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.inf index b92f658bfc..9d8cf16d28 100644 --- a/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.inf +++ b/Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.inf @@ -28,6 +28,9 @@ UefiBootServicesTableLib UefiLib =20 +[Guids] + gEfiEventVirtualAddressChangeGuid + [Protocols] gEfiI2cMasterProtocolGuid ## CONSUMES gDs1307RealTimeClockLibI2cMasterProtocolGuid ## CONSUMES @@ -36,5 +39,7 @@ gDs1307RtcLibTokenSpaceGuid.PcdI2cSlaveAddress gDs1307RtcLibTokenSpaceGuid.PcdI2cBusFrequency =20 +# 2.15 EDK II INF, .. the generic (i.e depex).. are not permitted +# yet it ANDs this into the parent's depex [Depex] - gDs1307RealTimeClockLibI2cMasterProtocolGuid + gDs1307RealTimeClockLibI2cMasterProtocolGuid AND gEfiI2cMasterProtocol= Guid --=20 2.43.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113561): https://edk2.groups.io/g/devel/message/113561 Mute This Topic: https://groups.io/mt/103653100/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-