From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::443; helo=mail-wr1-x443.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D71E421959CB2 for ; Tue, 18 Dec 2018 09:47:24 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id v13so16804544wrw.5 for ; Tue, 18 Dec 2018 09:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FW6/8IEYg2dB47TgfRRAti3XRPmevPL4C4B0wBbF0hc=; b=e7mUvbVQEu/o6DIJEMiAtPj/yDP7chxqBwmb+H6wDNhpeKoWZb9mYMbl6TWJoDBBv4 5z6FFi1m8puFN8BFQmb3XV8xkpUkKGjrToxzJH7pFo/L7Ri7syrVUpU5q74wN4fHrdsj mg0clDtjgtMr99FOkcVKFtswoB3sMWD+7HLOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FW6/8IEYg2dB47TgfRRAti3XRPmevPL4C4B0wBbF0hc=; b=tsc7YiUe0s1SBCdvQHwFtUj+M1+hD5NiLrI8W2Er69L2mysGuvdivKygjNx1tlQhIO BwH+kvgLb06f84WAD8t3cvJINQOpoIPG83QgNTl64v6oG7nOVIMt3y/MsBlJT/1bw/sN ANJ3ZUiKsGP+6NEQw+6oh/apwCGU6BVHv/K7CWcettWk3E+kMnGJG7HDIbi0EqqTmofc wkCwheAtdu09y1/m7IgrVwd4occlC8qkrL1M+WywOY2KqbVsfcGpHYxcyz9IYpmlgIBc p68irAtuBKtRvCA8EuTCYb7cnx80wDl7hzzC9wgitJ1fBGC2ZWKcwsAOT/19DEOl5y1M FIZQ== X-Gm-Message-State: AA+aEWaw2umoYRJ1+a7FyVN+SnvvpeOw6gzc2X+lBnZOyzJMQYLDmAGu 34gEa9xEiuPDMcK34c0ZXYBOig== X-Google-Smtp-Source: AFSGD/V70SPCohLPUn1fLi20DEEyweNUA7KgiZMqC0zAQG1CS1ffkr39QgnkWlkanAXrrqARMQpAPg== X-Received: by 2002:adf:b608:: with SMTP id f8mr14914443wre.120.1545155243215; Tue, 18 Dec 2018 09:47:23 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id x81sm3312907wmg.17.2018.12.18.09.47.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Dec 2018 09:47:22 -0800 (PST) Date: Tue, 18 Dec 2018 17:47:21 +0000 From: Leif Lindholm To: Meenakshi Aggarwal Cc: ard.biesheuvel@linaro.org, michael.d.kinney@intel.com, edk2-devel@lists.01.org, udit.kumar@nxp.com, v.sethi@nxp.com Message-ID: <20181218174721.fjmu3bj44s3lxh5g@bivouac.eciton.net> References: <1518771035-6733-1-git-send-email-meenakshi.aggarwal@nxp.com> <1543417315-5763-1-git-send-email-meenakshi.aggarwal@nxp.com> <1543417315-5763-9-git-send-email-meenakshi.aggarwal@nxp.com> MIME-Version: 1.0 In-Reply-To: <1543417315-5763-9-git-send-email-meenakshi.aggarwal@nxp.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms 08/41] Platform/NXP: Add Platform driver for LS1043 RDB board X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Dec 2018 17:47:25 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Please add a commit message. What does the platform driver _do_? (No comments on the code.) / Leif On Wed, Nov 28, 2018 at 08:31:22PM +0530, Meenakshi Aggarwal wrote: > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Meenakshi Aggarwal > --- > .../Drivers/PlatformDxe/PlatformDxe.c | 119 +++++++++++++++++++++ > .../Drivers/PlatformDxe/PlatformDxe.inf | 58 ++++++++++ > 2 files changed, 177 insertions(+) > create mode 100644 Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c > create mode 100644 Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf > > diff --git a/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c > new file mode 100644 > index 0000000..7ce7318 > --- /dev/null > +++ b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c > @@ -0,0 +1,119 @@ > +/** @file > + LS1043 DXE platform driver. > + > + Copyright 2018 NXP > + > + 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 > + http://opensource.org/licenses/bsd-license.php > + > + 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 > + > +typedef struct { > + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR StartDesc; > + UINT8 EndDesc; > +} ADDRESS_SPACE_DESCRIPTOR; > + > +STATIC ADDRESS_SPACE_DESCRIPTOR mI2cDesc[FixedPcdGet64 (PcdNumI2cController)]; > + > +STATIC > +EFI_STATUS > +RegisterDevice ( > + IN EFI_GUID *TypeGuid, > + IN ADDRESS_SPACE_DESCRIPTOR *Desc, > + OUT EFI_HANDLE *Handle > + ) > +{ > + NON_DISCOVERABLE_DEVICE *Device; > + EFI_STATUS Status; > + > + Device = (NON_DISCOVERABLE_DEVICE *)AllocateZeroPool (sizeof (*Device)); > + if (Device == NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + Device->Type = TypeGuid; > + Device->DmaType = NonDiscoverableDeviceDmaTypeNonCoherent; > + Device->Resources = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Desc; > + > + Status = gBS->InstallMultipleProtocolInterfaces (Handle, > + &gEdkiiNonDiscoverableDeviceProtocolGuid, Device, > + NULL); > + if (EFI_ERROR (Status)) { > + goto FreeDevice; > + } > + return EFI_SUCCESS; > + > +FreeDevice: > + FreePool (Device); > + > + return Status; > +} > + > +VOID > +PopulateI2cInformation ( > + IN VOID > + ) > +{ > + UINT32 Index; > + > + for (Index = 0; Index < FixedPcdGet32 (PcdNumI2cController); Index++) { > + mI2cDesc[Index].StartDesc.Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR; > + mI2cDesc[Index].StartDesc.Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3; > + mI2cDesc[Index].StartDesc.ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; > + mI2cDesc[Index].StartDesc.GenFlag = 0; > + mI2cDesc[Index].StartDesc.SpecificFlag = 0; > + mI2cDesc[Index].StartDesc.AddrSpaceGranularity = 32; > + mI2cDesc[Index].StartDesc.AddrRangeMin = FixedPcdGet64 (PcdI2c0BaseAddr) + > + (Index * FixedPcdGet32 (PcdI2cSize)); > + mI2cDesc[Index].StartDesc.AddrRangeMax = mI2cDesc[Index].StartDesc.AddrRangeMin + > + FixedPcdGet32 (PcdI2cSize) - 1; > + mI2cDesc[Index].StartDesc.AddrTranslationOffset = 0; > + mI2cDesc[Index].StartDesc.AddrLen = FixedPcdGet32 (PcdI2cSize); > + > + mI2cDesc[Index].EndDesc = ACPI_END_TAG_DESCRIPTOR; > + } > +} > + > +EFI_STATUS > +EFIAPI > +PlatformDxeEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE Handle; > + > + Handle = NULL; > + > + PopulateI2cInformation (); > + > + Status = RegisterDevice (&gNxpNonDiscoverableI2cMasterGuid, > + &mI2cDesc[0], &Handle); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Install the DS1307 I2C Master protocol on this handle so the RTC driver > + // can identify it as the I2C master it can invoke directly. > + // > + Status = gBS->InstallProtocolInterface (&Handle, > + &gDs1307RealTimeClockLibI2cMasterProtocolGuid, > + EFI_NATIVE_INTERFACE, NULL); > + ASSERT_EFI_ERROR (Status); > + > + return EFI_SUCCESS; > +} > diff --git a/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf > new file mode 100644 > index 0000000..91d6ad3 > --- /dev/null > +++ b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf > @@ -0,0 +1,58 @@ > +## @file > +# > +# Component description file for LS1043 DXE platform driver. > +# > +# Copyright 2018 NXP > +# > +# 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 > +# http://opensource.org/licenses/bsd-license.php > +# > +# 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 = 0x0001001A > + BASE_NAME = PlatformDxe > + FILE_GUID = 21108101-adcd-4123-930e-a2354a554db7 > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT = PlatformDxeEntryPoint > + > +[Sources] > + PlatformDxe.c > + > +[Packages] > + ArmPkg/ArmPkg.dec > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.dec > + Silicon/NXP/NxpQoriqLs.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + MemoryAllocationLib > + PcdLib > + UefiBootServicesTableLib > + UefiDriverEntryPoint > + UefiLib > + > +[Guids] > + gNxpNonDiscoverableI2cMasterGuid > + > +[Protocols] > + gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES > + gDs1307RealTimeClockLibI2cMasterProtocolGuid ## PRODUCES > + > +[FixedPcd] > + gNxpQoriqLsTokenSpaceGuid.PcdI2c0BaseAddr > + gNxpQoriqLsTokenSpaceGuid.PcdI2cSize > + gNxpQoriqLsTokenSpaceGuid.PcdNumI2cController > + > +[Depex] > + TRUE > -- > 1.9.1 >