From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.0.78; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=udit.kumar@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0078.outbound.protection.outlook.com [104.47.0.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B149C2034A888 for ; Mon, 6 Nov 2017 03:05:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=18btx6WhjX2G0sA2rRV/LbalkqET6CPZ3z3u3gHUxus=; b=I3En9R9EsbRROIP0auH+Bzfzf2SUZP03eQDc/eQJn66EByEaWE0+nJ+FmWCEhTNJQhj/hSnFCo8XceASF4FDhrK8P+TTq8GhXKDZR9/9hY0+QrwBudMOW3hmG8sapDg5prVrXW/nJN1Ig4qln3iYm5tFEV3B1BOXdZypU7JyOk0= Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com (52.133.18.151) by AM6PR0402MB3333.eurprd04.prod.outlook.com (52.133.18.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Mon, 6 Nov 2017 11:09:17 +0000 Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::7cbb:e077:2ee1:20f0]) by AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::7cbb:e077:2ee1:20f0%13]) with mapi id 15.20.0197.019; Mon, 6 Nov 2017 11:09:17 +0000 From: Udit Kumar To: Ard Biesheuvel , "edk2-devel@lists.01.org" , "leif.lindholm@linaro.org" , "daniel.thompson@linaro.org" Thread-Topic: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC support library for PCF8563 I2C IP Thread-Index: AQHTVIztdbDgPYntnkyfE+Cl3TGtZKMHMk+A Date: Mon, 6 Nov 2017 11:09:17 +0000 Message-ID: References: <20171103101654.30973-1-ard.biesheuvel@linaro.org> <20171103101654.30973-2-ard.biesheuvel@linaro.org> In-Reply-To: <20171103101654.30973-2-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=udit.kumar@nxp.com; x-originating-ip: [192.88.169.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR0402MB3333; 6:KoASHgRti4Pzr0IEHBa0SpKd77wWhqB13/7woHcnCIbITn0jWR+kujAnEhix5GK8PS9y/2utKNgu2KPjphc4GFI9+MEFOk6qR0D/OCDchzN5tVXvwimQiCsaQL+OnUIYzRbKRwkDy5E8H6kP7xnCT9nYnaB4PegCD3UrQ+vcyTA74QPoWedBwVwsy8kyNXg5uOPSTOufObOvJp5eI+2dXVmRDfG2EkM7GREtJ0viGW1s7B78wH2QOXsMje2HwfkCPQS6Aog5PnpthiYHxZD3t5bdEb521JPI8TT1HBey4xlipg5VYhAoeH6uvOpFSP8+4Z5sz7De3lgpmzwRd/GXVEI+gBQcThQsunRcfKUTl7k=; 5:uWexjnNDfC7scx5DbESZ8iLDA7Ga/AnZgJWiJl7Gd74UpLvUsyK36RG2WZIGjmJ9abp07nTk8p6g4zI5NXB99r1vNCgTuTbxvxrWJPjZ0p6tKHTixpvRpHinDklfO4P1ykECQCk6ewnrW3sLWj810rnBABDe0CjK14SHwewcU2k=; 24:0SJo87EqnoqxEWbRkn+INddcRZiz4mqWa1niKdCUt79dAvPHBNIcq4uXLnRzJiPEDC/Xky2lieuVDnsSE9cSAhevU0xM3vLehArNLgusmCc=; 7:D5MsL3xFJEVWHW01rCtT9N85IjYlTt7t0TYNnEOKHAOKs8/TE8hbGRD5p8VXrW2CiYAwUp2TZVQocNVyQ25ghMV7Bm3czYEXwEKvIdQXWzB4mPon1B0NuIr2GvzPDs/Yy8a0qjjYlhjeRXnv7z3tg9rbDlvj1kVhUMTSNzOfjRclabMLgPNn4ZrgnOS64x8yMeGSNFpUQkzlvVEY5FvrG8bUmEPlpijp3uUdSKTeSc8as+Qa+9yrYbKPYhBSN548 x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 0201c4c3-a319-4d2b-273c-08d52506d295 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199); SRVR:AM6PR0402MB3333; x-ms-traffictypediagnostic: AM6PR0402MB3333: x-exchange-antispam-report-test: UriScan:(189930954265078)(162533806227266)(45079756050767)(21532816269658); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3231021)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM6PR0402MB3333; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM6PR0402MB3333; x-forefront-prvs: 048396AFA0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(39860400002)(346002)(199003)(13464003)(189002)(43544003)(189998001)(45080400002)(966005)(14454004)(102836003)(6116002)(3846002)(3660700001)(2201001)(50986999)(8676002)(86362001)(54356999)(81166006)(575784001)(76176999)(81156014)(8936002)(2906002)(3280700002)(68736007)(25786009)(478600001)(2900100001)(55016002)(316002)(7736002)(9686003)(6246003)(305945005)(6506006)(6306002)(6436002)(105586002)(101416001)(110136005)(2950100002)(16799955002)(66066001)(53546010)(5660300001)(97736004)(2501003)(5250100002)(99286004)(5890100001)(7696004)(106356001)(33656002)(53946003)(53936002)(229853002)(74316002)(217873001)(579004)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0402MB3333; H:AM6PR0402MB3334.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0201c4c3-a319-4d2b-273c-08d52506d295 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2017 11:09:17.5189 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3333 Subject: Re: [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC support library for PCF8563 I2C IP X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Nov 2017 11:05:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks Ard.=20 This will allow to use PCF8563 on any platform not limiting to targeted pla= tform.=20 Few comments are inline. Regards Udit=20 > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ar= d > Biesheuvel > Sent: Friday, November 03, 2017 3:47 PM > To: edk2-devel@lists.01.org; leif.lindholm@linaro.org; > daniel.thompson@linaro.org > Cc: Ard Biesheuvel > Subject: [edk2] [RFC PATCH edk2-platforms 1/3] Silicon/NXP: add RTC suppo= rt > library for PCF8563 I2C IP >=20 > Add a RealTimeClockLib implementation for the NXP PCF8563 as used on > the Socionext Developer Box board. Note that the standard I2C protocol > stack does not support runtime use, so this driver invokes the I2C master > protocol directly. This requires support from the platform side as well, > and so this driver will only attach to a I2C master that has the > gPcf8563RealTimeClockLibI2cMasterProtolGuid protocol installed on its > handle. It is up to the platform to ensure that the driver producing > the I2C master protocol in question is runtime capable, and is not > shared with the I2C protocol stack (i.e., it should not have the I2C > Bus Configuration Management protocol installed as well). >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c = | > 385 ++++++++++++++++++++ > Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec = | > 29 ++ > Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf = | > 52 +++ > 3 files changed, 466 insertions(+) >=20 > diff --git > a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c > b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c > new file mode 100644 > index 000000000000..fea65a225d7f > --- /dev/null > +++ > b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c > @@ -0,0 +1,385 @@ > +/** @file > + > + Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> + > + This program and the accompanying materials > + are licensed and made available under the terms and conditions of the = BSD > License > + which accompanies this distribution. The full text of the license may= be found > at > + > https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fopens= o > urce.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cudit.kumar%40nxp.com%7C6faa68073eef4ed07 > 25208d522a40d65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636 > 453010374642660&sdata=3DvDhroHNG20VCsMtj7%2FggWcWRG8hwt5fbV1Kv4R > Na98Q%3D&reserved=3D0 > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define SLAVE_ADDRESS (FixedPcdGet8 (PcdI2cSlaveAddress)) > +#define PCF8563_DATA_REG_OFFSET 0x2 > + > +#define PCF8563_SECONDS_MASK 0x7f > +#define PCF8563_MINUTES_MASK 0x7f > +#define PCF8563_HOURS_MASK 0x3f > +#define PCF8563_DAYS_MASK 0x3f > +#define PCF8563_WEEKDAYS_MASK 0x07 > +#define PCF8563_MONTHS_MASK 0x1f > +#define PCF8563_CENTURY_MASK 0x80 > + > +#define EPOCH_BASE 2000 > + > +STATIC EFI_HANDLE mI2cMasterHandle; > +STATIC VOID *mDriverEventRegistration; > +STATIC EFI_I2C_MASTER_PROTOCOL *mI2cMaster; > +STATIC EFI_EVENT mRtcVirtualAddrChangeEvent; > + > +typedef struct { > + UINTN OperationCount; > + EFI_I2C_OPERATION SetAddressOp; > + EFI_I2C_OPERATION GetSetDateTimeOp; > +} RTC_I2C_REQUEST; > + > +#pragma pack(1) > +typedef struct { > + UINT8 VL_seconds; > + UINT8 Minutes; > + UINT8 Hours; > + UINT8 Days; > + UINT8 Weekdays; > + UINT8 Century_months; > + UINT8 Years; > +} RTC_DATETIME; > +#pragma pack() > + > +/** > + Returns the current time and date information, and the time-keeping > + capabilities of the hardware platform. > + > + @param Time A pointer to storage to receive a snapsh= ot of > + the current time. > + @param Capabilities An optional pointer to a buffer to recei= ve the > + real time clock device's capabilities. > + > + @retval EFI_SUCCESS The operation completed successfully. > + @retval EFI_INVALID_PARAMETER Time is NULL. > + @retval EFI_DEVICE_ERROR The time could not be retrieved due to > hardware > + error. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibGetTime ( > + OUT EFI_TIME *Time, > + OUT EFI_TIME_CAPABILITIES *Capabilities > + ) > +{ > + RTC_I2C_REQUEST Op; > + RTC_DATETIME DateTime; > + EFI_STATUS Status; > + UINT8 Reg; > + > + if (Time =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (mI2cMaster =3D=3D NULL) { > + return EFI_DEVICE_ERROR; > + } > + > + Reg =3D PCF8563_DATA_REG_OFFSET; > + > + Op.OperationCount =3D 2; > + > + Op.SetAddressOp.Flags =3D 0; > + Op.SetAddressOp.LengthInBytes =3D 1; > + Op.SetAddressOp.Buffer =3D &Reg; > + > + Op.GetSetDateTimeOp.Flags =3D I2C_FLAG_READ; > + Op.GetSetDateTimeOp.LengthInBytes =3D sizeof (RTC_DATETIME); > + Op.GetSetDateTimeOp.Buffer =3D (VOID *)&DateTime; > + > + Status =3D mI2cMaster->StartRequest (mI2cMaster, SLAVE_ADDRESS, > + (VOID *)&Op, NULL, NULL); > + if (EFI_ERROR (Status)) { > + return EFI_DEVICE_ERROR; > + } > + > + Time->Second =3D BcdToDecimal8 (DateTime.VL_seconds & > PCF8563_SECONDS_MASK); > + Time->Minute =3D BcdToDecimal8 (DateTime.Minutes & > PCF8563_MINUTES_MASK); > + Time->Hour =3D BcdToDecimal8 (DateTime.Hours & PCF8563_HOURS_MASK); > + Time->Day =3D BcdToDecimal8 (DateTime.Days & PCF8563_DAYS_MASK); > + Time->Month =3D BcdToDecimal8 (DateTime.Century_months & > PCF8563_MONTHS_MASK); > + Time->Year =3D BcdToDecimal8 (DateTime.Years) + EPOCH_BASE; > + > + if (DateTime.Century_months & PCF8563_CENTURY_MASK) { > + Time->Year +=3D 100; > + } > + > + Time->Daylight =3D EFI_TIME_ADJUST_DAYLIGHT; > + Time->TimeZone =3D 0; /* UTC */ Need to take care of time-zone as well.=20 > + > + if (Capabilities !=3D NULL) { > + Capabilities->Resolution =3D 1; > + Capabilities->Accuracy =3D 0; > + Capabilities->SetsToZero =3D TRUE; > + } > + return EFI_SUCCESS; > +} > + > + > +/** > + Sets the current local time and date information. > + > + @param Time A pointer to the current time. > + > + @retval EFI_SUCCESS The operation completed successfully. > + @retval EFI_INVALID_PARAMETER A time field is out of range. > + @retval EFI_DEVICE_ERROR The time could not be set due due to > hardware > + error. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibSetTime ( > + IN EFI_TIME *Time > + ) > +{ > + RTC_I2C_REQUEST Op; > + RTC_DATETIME DateTime; > + EFI_STATUS Status; > + UINT8 Reg; > + > + if (mI2cMaster =3D=3D NULL) { > + return EFI_DEVICE_ERROR; > + } Please see, if check can be added for time validity=20 > + > + DateTime.VL_seconds =3D DecimalToBcd8 (Time->Second); > + DateTime.Minutes =3D DecimalToBcd8 (Time->Minute); > + DateTime.Hours =3D DecimalToBcd8 (Time->Hour); > + DateTime.Days =3D DecimalToBcd8 (Time->Day); > + DateTime.Century_months =3D DecimalToBcd8 (Time->Month); > + DateTime.Years =3D DecimalToBcd8 (Time->Year % 100); > + if (Time->Year >=3D EPOCH_BASE + 100) { > + DateTime.Century_months |=3D PCF8563_CENTURY_MASK; > + } > + > + Reg =3D PCF8563_DATA_REG_OFFSET; > + > + Op.OperationCount =3D 2; > + > + Op.SetAddressOp.Flags =3D 0; > + Op.SetAddressOp.LengthInBytes =3D 1; > + Op.SetAddressOp.Buffer =3D &Reg; > + > + Op.GetSetDateTimeOp.Flags =3D 0; > + Op.GetSetDateTimeOp.LengthInBytes =3D sizeof (RTC_DATETIME); > + Op.GetSetDateTimeOp.Buffer =3D (VOID *)&DateTime; > + > + Status =3D mI2cMaster->StartRequest (mI2cMaster, SLAVE_ADDRESS, > + (VOID *)&Op, NULL, NULL); > + if (EFI_ERROR (Status)) { > + return EFI_DEVICE_ERROR; > + } > + return EFI_SUCCESS; > +} > + > + > +/** > + Returns the current wakeup alarm clock setting. > + > + @param Enabled Indicates if the alarm is currently enab= led or > + disabled. > + @param Pending Indicates if the alarm signal is pending= and > + requires acknowledgement. > + @param Time The current alarm setting. > + > + @retval EFI_SUCCESS The alarm settings were returned. > + @retval EFI_INVALID_PARAMETER Any parameter is NULL. > + @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved d= ue > to a > + hardware error. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibGetWakeupTime ( > + OUT BOOLEAN *Enabled, > + OUT BOOLEAN *Pending, > + OUT EFI_TIME *Time > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > + > +/** > + Sets the system wakeup alarm clock time. > + > + @param Enabled Enable or disable the wakeup alarm. > + @param Time If Enable is TRUE, the time to set the w= akeup > + alarm for. > + > + @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm= was > + enabled. If Enable is FALSE, then the wa= keup > + alarm was disabled. > + @retval EFI_INVALID_PARAMETER A time field is out of range. > + @retval EFI_DEVICE_ERROR The wakeup time could not be set due to = a > + hardware error. > + @retval EFI_UNSUPPORTED A wakeup timer is not supported on this > + platform. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibSetWakeupTime ( > + IN BOOLEAN Enabled, > + OUT EFI_TIME *Time > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +STATIC > +VOID > +DriverRegistrationEvent ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + EFI_HANDLE Handle[2]; > + UINTN BufferSize; > + EFI_STATUS Status; > + EFI_I2C_MASTER_PROTOCOL *I2cMaster; > + UINTN BusFrequency; > + > + // > + // Try to connect the newly registered driver to our handle. > + // > + do { > + BufferSize =3D sizeof (EFI_HANDLE); > + Status =3D gBS->LocateHandle (ByRegisterNotify, > + &gEfiDriverBindingProtocolGuid, > + mDriverEventRegistration, > + &BufferSize, > + Handle); > + if (EFI_ERROR (Status)) { > + if (Status !=3D EFI_NOT_FOUND) { > + DEBUG ((DEBUG_WARN, "%a: gBS->LocateHandle () returned %r\n", > + __FUNCTION__, Status)); > + } > + break; > + } > + > + // > + // Check if we can connect our handle to this driver. > + // > + Handle[1] =3D NULL; > + Status =3D gBS->ConnectController (mI2cMasterHandle, Handle, NULL, F= ALSE); > + if (EFI_ERROR (Status)) { > + continue; > + } > + > + DEBUG ((DEBUG_INFO, "%a: found I2C master!\n", __FUNCTION__)); > + > + gBS->CloseEvent (Event); > + > + Status =3D gBS->OpenProtocol (mI2cMasterHandle, > &gEfiI2cMasterProtocolGuid, > + (VOID **)&I2cMaster, gImageHandle, NULL, > + EFI_OPEN_PROTOCOL_EXCLUSIVE); > + ASSERT_EFI_ERROR (Status); > + > + Status =3D I2cMaster->Reset (I2cMaster); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: I2CMaster->Reset () failed - %r\n", > + __FUNCTION__, Status)); > + break; > + } > + > + BusFrequency =3D FixedPcdGet16 (PcdI2cBusFrequency); > + Status =3D I2cMaster->SetBusFrequency (I2cMaster, &BusFrequency); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: I2CMaster->SetBusFrequency () failed - > %r\n", > + __FUNCTION__, Status)); > + break; > + } > + > + mI2cMaster =3D I2cMaster; > + break; > + } while (TRUE); > +} > + > +/** > + 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); > +} > + > +/** > + Library entry point > + > + @param ImageHandle Handle that identifies the loaded image. > + @param SystemTable System Table for this image. > + > + @retval EFI_SUCCESS The operation completed successfully. > + > +**/ > +EFI_STATUS > +EFIAPI > +LibRtcInitialize ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + UINTN BufferSize; > + > + // > + // Find the handle that marks the controller > + // that will provide the I2C master protocol. > + // > + BufferSize =3D sizeof (EFI_HANDLE); > + Status =3D gBS->LocateHandle (ByProtocol, > + &gPcf8563RealTimeClockLibI2cMasterProtolGuid, NULL, > + &BufferSize, &mI2cMasterHandle); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Register a protocol registration notification callback on the drive= r > + // binding protocol so we can attempt to connect our I2C master to it > + // as soon as it appears. > + // > + EfiCreateProtocolNotifyEvent ( > + &gEfiDriverBindingProtocolGuid, > + TPL_CALLBACK, > + DriverRegistrationEvent, > + NULL, > + &mDriverEventRegistration); > + > + // > + // Register for the virtual address change event > + // > + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, > + LibRtcVirtualNotifyEvent, NULL, > + &gEfiEventVirtualAddressChangeGuid, > + &mRtcVirtualAddrChangeEvent); > + ASSERT_EFI_ERROR (Status); > + > + return EFI_SUCCESS; > +} > diff --git > a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec > b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec > new file mode 100644 > index 000000000000..bc8fc60c0602 > --- /dev/null > +++ > b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec > @@ -0,0 +1,29 @@ > +#/** @file > +# > +# Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> +# > +# This program and the accompanying materials > +# are licensed and made available under the terms and conditions of the= BSD > License > +# which accompanies this distribution. The full text of the license may= be found > at > +# > https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fopens= o > urce.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cudit.kumar%40nxp.com%7C6faa68073eef4ed07 > 25208d522a40d65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636 > 453010374642660&sdata=3DvDhroHNG20VCsMtj7%2FggWcWRG8hwt5fbV1Kv4R > Na98Q%3D&reserved=3D0 > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > +# > +# > +#**/ > + > +[Defines] > + DEC_SPECIFICATION =3D 0x0001001A > + PACKAGE_NAME =3D Pcf8563RealTimeClockLib > + PACKAGE_GUID =3D 44d63668-c86b-446a-b303-f3a5176702a= a > + PACKAGE_VERSION =3D 0.1 > + > +[Guids] > + gPcf8563RealTimeClockLibTokenSpaceGuid =3D { 0xaaf5b169, 0x93a0, 0x4d6= 0, { > 0xba, 0xe4, 0x06, 0x07, 0x92, 0x8e, 0x63, 0xdd }} > + > +[Protocols] > + gPcf8563RealTimeClockLibI2cMasterProtolGuid =3D { 0xa6af18ae, 0x3bd5, > 0x4af9, { 0xbb, 0x6a, 0xdb, 0x85, 0x07, 0x62, 0x81, 0x38 }} > + > +[PcdsFixedAtBuild] > + > gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cSlaveAddress|0x51|UINT8|0 > x00000001 > + > gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cBusFrequency|400|UINT16|0 > x00000002 > diff --git > a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf > b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf > new file mode 100644 > index 000000000000..e1e001162144 > --- /dev/null > +++ > b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf > @@ -0,0 +1,52 @@ > +#/** @file > +# > +# Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> +# > +# This program and the accompanying materials > +# are licensed and made available under the terms and conditions of the= BSD > License > +# which accompanies this distribution. The full text of the license may= be found > at > +# > https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fopens= o > urce.org%2Flicenses%2Fbsd- > license.php&data=3D02%7C01%7Cudit.kumar%40nxp.com%7C6faa68073eef4ed07 > 25208d522a40d65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636 > 453010374642660&sdata=3DvDhroHNG20VCsMtj7%2FggWcWRG8hwt5fbV1Kv4R > Na98Q%3D&reserved=3D0 > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > +# > +# > +#**/ > + > +[Defines] > + INF_VERSION =3D 0x0001001A > + BASE_NAME =3D Pcf8563RealTimeClockLib > + FILE_GUID =3D 1e3d33f3-a671-4116-bd81-6b435296c1e= 0 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RealTimeClockLib > + > +[Sources.common] > + Pcf8563RealTimeClockLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + EmbeddedPkg/EmbeddedPkg.dec > + Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.de= c > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + IoLib > + UefiBootServicesTableLib > + UefiLib > + UefiRuntimeLib > + > +[Guids] > + gEfiEventVirtualAddressChangeGuid > + > +[Protocols] > + gEfiDriverBindingProtocolGuid ## CONSUMES > + gEfiI2cMasterProtocolGuid ## CONSUMES > + gPcf8563RealTimeClockLibI2cMasterProtolGuid ## CONSUMES > + > +[FixedPcd] > + gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cSlaveAddress > + gPcf8563RealTimeClockLibTokenSpaceGuid.PcdI2cBusFrequency > + > +[Depex] > + gPcf8563RealTimeClockLibI2cMasterProtolGuid > -- > 2.11.0 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://emea01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flist= s.01 > .org%2Fmailman%2Flistinfo%2Fedk2- > devel&data=3D02%7C01%7Cudit.kumar%40nxp.com%7C6faa68073eef4ed072520 > 8d522a40d65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6364530 > 10374642660&sdata=3Dvr4qAgDuDX0M7MGeuS%2FKAY%2B%2FqhVmz0%2FMrEx > K42tQIbM%3D&reserved=3D0