From nobody Fri Dec 19 17:42:27 2025 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+113561+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+113561+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1704931471; cv=none; d=zohomail.com; s=zohoarc; b=LI7ZBNxMf9YPeoMCyaNKzYaRUSIjSIoZCRdekXLwXxSgi3ShFZPw3cyCjGblY4uCYDWTtEv6Zq/JjZ5V4P/jf1PZFED74WnPkpebokSlPnCCKIDmQ21xFuxjkHg74kXPWxX7/ZrSBlWRwxHJFnLFao/xkMOC9k8Nz2xDWTrs7tM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704931471; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=X7FHRpFLvJxZaTz2gqj6wPf/LQg1kDc/k5lXuabT08U=; b=DGwZpfUPCiqQ/8Gzerlza6+1k3UOp2P9O1h2IkSwZEz5wkRXxIAdxWoPy1WprzUu6T6DlKgbcXj1auxi6zmlr9wYCdu1B43Di5fbBZizfYRC2FY2qcCCWKcrX53y93axZ75JV6M00mnJfampRCrGAPGJiddzgnCeKy6X8wF8poA= 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+113561+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 1704931471157166.27230802412362; Wed, 10 Jan 2024 16:04:31 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=wH8OJD9S+/fLqW07ACIKua+5njKwRDXl3bbIR+Jbl0A=; 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=1704931470; v=1; b=fCzX5UECzPJ2lIv/n63aIyHypstYsqKn/wPmiTOUI04GKo/jxtpTSiVqEz7Z/aXFSRScVu6T iD9b0wmhYNQeMazcOrEylxQiXN80Ge2TFgt3Q9py0CERD1V6/UvG0T6gBdxo7TgKzujAkCkE93v JRxW1iKOjswpTis2MR2Q4tf4= X-Received: by 127.0.0.2 with SMTP id fY9RYY1788612xAyMYVWpIFB; Wed, 10 Jan 2024 16:04:30 -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: PzZ0TQAfnLrkzOvgdXGoCjeax1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1704931471340100001 Content-Type: text/plain; charset="utf-8" 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/Ma= xim/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->I2cControllerCapabilities); + 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/Silicon/= 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 gEfiI2cMasterProtocolGu= id --=20 2.43.0 -=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 (#113561): https://edk2.groups.io/g/devel/message/113561 Mute This Topic: https://groups.io/mt/103653100/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-