From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) (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 124B821B00DE1 for ; Wed, 8 Nov 2017 08:43:38 -0800 (PST) Received: by mail-wr0-x243.google.com with SMTP id y9so3028740wrb.2 for ; Wed, 08 Nov 2017 08:47:39 -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=vam8FMWf+WpMuS9wNgC3/vT8Jy7n8snOchXVDv2n188=; b=ECCfyG0EmixrtZ5NKlc2XHBTx9bpeloWl2BkwCiOnTGtc6XSDKGxLrc2UaFe77Dv25 qepxkzK2ZssJCYZl6Wkm1d/F66ouD/xpnhW81kY59hBM+lf+gqApjyTZfGvHIUlO7WgG pnowEtq3OFxJeLwpPkq87DEXHXZ123CCnq75s= 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=vam8FMWf+WpMuS9wNgC3/vT8Jy7n8snOchXVDv2n188=; b=NrVODFpoCsPcV6hF4MJe0ytNrYi05mpbbBdKJy8IBA9QlA6jwnXos+XUWNQ1pboFrw 7bOscW9Nc7KqsO1XiCzFCFQ8SkCT/5czeKlMKpo9n/GmZeKFACWhIGWVlyih9mqG4fHX g9q/z1rdVjZjCRs68aUbcalXgv3/8+EV14zZ0Th8bmrk6odxkjqgwfxd6w7+6FdavFal 7Cu4qOsqQzT6F1ykGvrnhgaN3YBk0mgQHT5oQj2zDvUfL2Ag9Bi8NjWYsz4TU2vzkiJo K7Zpg02e//RJjYhYNC7kiS48nAC+HNkvOF/Im5ft5vxlQcEgKJlzO0ts0dnJBVrIHnIx YSBg== X-Gm-Message-State: AJaThX7h/TJkkzzaZE86zYrUVv6Fgjw4ZDOHD2YIzH5AFD7QJ/utqgSC u/24M+81x9QE6HiLj1H24v0QDA== X-Google-Smtp-Source: ABhQp+RtViW9qncjcn2sJeF+oNFX52wXBHhZ7pA2Fzlcsol9Ybs1lClDtuYrfrWO4IwANtEHZw+hbQ== X-Received: by 10.223.139.140 with SMTP id o12mr944702wra.78.1510159658427; Wed, 08 Nov 2017 08:47:38 -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 h185sm6926163wma.19.2017.11.08.08.47.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Nov 2017 08:47:36 -0800 (PST) Date: Wed, 8 Nov 2017 16:47:35 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, daniel.thompson@linaro.org Message-ID: <20171108164735.udmmxrzo6gnvmzxo@bivouac.eciton.net> References: <20171103101654.30973-1-ard.biesheuvel@linaro.org> <20171103101654.30973-4-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20171103101654.30973-4-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [RFC PATCH edk2-platforms 3/3] Platform/DeveloperBox: wire up RTC support 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: Wed, 08 Nov 2017 16:43:39 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Nov 03, 2017 at 10:16:54AM +0000, Ard Biesheuvel wrote: > Add the drivers, library resolutions and PCD settings to enable RTC > support on DeveloperBox. Also, update PlatformDxe to register the > non-discoverable device handles for both I2C controllers. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm > --- > Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 8 ++- > Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 5 ++ > Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 76 +++++++++++++++++--- > Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 6 +- > Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h | 8 +++ > Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 4 ++ > 6 files changed, 96 insertions(+), 11 deletions(-) > > diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > index b558b1f805b4..91898faa6ecc 100644 > --- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc > @@ -446,8 +446,7 @@ [Components.common] > MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf > EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf { > > - ## TODO > - RealTimeClockLib|EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf > + RealTimeClockLib|Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf > } > MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf > MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf > @@ -627,6 +626,11 @@ [Components.common] > > Platform/Socionext/DeveloperBox/OsInstallerMenuDxe/OsInstallerMenuDxe.inf > > + # > + # I2C > + # > + Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf > + > !if $(DO_X86EMU) == TRUE > # > # x86 emulator > diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf > index 19dbcf17c1e1..368bf801e036 100644 > --- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf > +++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf > @@ -236,6 +236,11 @@ [FV.FvMain] > > INF Platform/Socionext/DeveloperBox/OsInstallerMenuDxe/OsInstallerMenuDxe.inf > > + # > + # I2C > + # > + INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf > + > !if $(DO_X86EMU) == TRUE > # > # x86 emulator > diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c > index 1d300b15e25b..b39cbc5f5291 100644 > --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c > +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c > @@ -62,27 +62,61 @@ STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mNetsecDesc[] = { > } > }; > > +STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c0Desc[] = { > + { > + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc > + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len > + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType > + 0, // GenFlag > + 0, // SpecificFlag > + 32, // AddrSpaceGranularity > + SYNQUACER_I2C0_BASE, // AddrRangeMin > + SYNQUACER_I2C0_BASE + SYNQUACER_I2C0_SIZE - 1, // AddrRangeMax > + 0, // AddrTranslationOffset > + SYNQUACER_I2C0_SIZE, // AddrLen > + }, { > + ACPI_END_TAG_DESCRIPTOR // Desc > + } > +}; > + > +STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c1Desc[] = { > + { > + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc > + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len > + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType > + 0, // GenFlag > + 0, // SpecificFlag > + 32, // AddrSpaceGranularity > + SYNQUACER_I2C1_BASE, // AddrRangeMin > + SYNQUACER_I2C1_BASE + SYNQUACER_I2C1_SIZE - 1, // AddrRangeMax > + 0, // AddrTranslationOffset > + SYNQUACER_I2C1_SIZE, // AddrLen > + }, { > + ACPI_END_TAG_DESCRIPTOR // Desc > + } > +}; > + > STATIC > EFI_STATUS > -RegisterNetsec ( > - VOID > +RegisterDevice ( > + IN EFI_GUID *TypeGuid, > + IN EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc, > + OUT EFI_HANDLE *Handle > ) > { > NON_DISCOVERABLE_DEVICE *Device; > EFI_STATUS Status; > - EFI_HANDLE Handle; > > Device = (NON_DISCOVERABLE_DEVICE *)AllocateZeroPool (sizeof (*Device)); > if (Device == NULL) { > return EFI_OUT_OF_RESOURCES; > } > > - Device->Type = &gNetsecNonDiscoverableDeviceGuid; > + Device->Type = TypeGuid; > Device->DmaType = NonDiscoverableDeviceDmaTypeNonCoherent; > - Device->Resources = mNetsecDesc; > + Device->Resources = Desc; > > - Handle = NULL; > - Status = gBS->InstallMultipleProtocolInterfaces (&Handle, > + Status = gBS->InstallMultipleProtocolInterfaces (Handle, > &gEdkiiNonDiscoverableDeviceProtocolGuid, Device, > NULL); > if (EFI_ERROR (Status)) { > @@ -106,6 +140,7 @@ PlatformDxeEntryPoint ( > EFI_STATUS Status; > VOID *Dtb; > UINTN DtbSize; > + EFI_HANDLE Handle; > > Dtb = NULL; > Status = DtPlatformLoadDtb (&Dtb, &DtbSize); > @@ -118,5 +153,30 @@ PlatformDxeEntryPoint ( > Status)); > } > > - return RegisterNetsec (); > + Handle = NULL; > + Status = RegisterDevice (&gNetsecNonDiscoverableDeviceGuid, mNetsecDesc, > + &Handle); > + ASSERT_EFI_ERROR (Status); > + > + Handle = NULL; > + Status = RegisterDevice (&gSynQuacerNonDiscoverableRuntimeI2cMasterGuid, > + mI2c0Desc, &Handle); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Install the PCF8563 I2C Master protocol on this handle so the RTC driver > + // can identify it as the I2C master it can invoke directly, rather than > + // through the I2C driver stack (which cannot be used at runtime) > + // > + Status = gBS->InstallProtocolInterface (&Handle, > + &gPcf8563RealTimeClockLibI2cMasterProtolGuid, > + EFI_NATIVE_INTERFACE, NULL); > + ASSERT_EFI_ERROR (Status); > + > + Handle = NULL; > + Status = RegisterDevice (&gSynQuacerNonDiscoverableI2cMasterGuid, mI2c1Desc, > + &Handle); > + ASSERT_EFI_ERROR (Status); > + > + return EFI_SUCCESS; > } > diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf > index 25e6248f1c61..478e0c7d33e9 100644 > --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf > +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf > @@ -29,6 +29,7 @@ [Packages] > EmbeddedPkg/EmbeddedPkg.dec > MdeModulePkg/MdeModulePkg.dec > MdePkg/MdePkg.dec > + Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec > Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec > Silicon/Socionext/SynQuacer/SynQuacer.dec > > @@ -43,9 +44,12 @@ [LibraryClasses] > [Guids] > gFdtTableGuid > gNetsecNonDiscoverableDeviceGuid > + gSynQuacerNonDiscoverableI2cMasterGuid > + gSynQuacerNonDiscoverableRuntimeI2cMasterGuid > > [Protocols] > - gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES > + gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES > + gPcf8563RealTimeClockLibI2cMasterProtolGuid ## PRODUCES > > [FixedPcd] > gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase > diff --git a/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h > index 1ccd3122cdda..49795f97602c 100644 > --- a/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h > +++ b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h > @@ -42,6 +42,14 @@ > #define SYNQUACER_GPIO_BASE 0x51000000 > #define SYNQUACER_GPIO_SIZE SIZE_4KB > > +// I2C0 block > +#define SYNQUACER_I2C0_BASE 0x51200000 > +#define SYNQUACER_I2C0_SIZE SIZE_4KB > + > +// I2C1 block > +#define SYNQUACER_I2C1_BASE 0x51210000 > +#define SYNQUACER_I2C1_SIZE SIZE_4KB > + > // eMMC(SDH30) > #define SYNQUACER_EMMC_BASE 0x52300000 > #define SYNQUACER_EMMC_BASE_SZ SIZE_4KB > diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c > index be9e28d2ff49..c8c940f27917 100644 > --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c > +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c > @@ -82,6 +82,10 @@ STATIC CONST ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[] = { > ARM_DEVICE_REGION (FixedPcdGet32 (PcdNetsecEepromBase), > SYNQUACER_EEPROM_BASE_SZ), > > + // SynQuacer I2C > + ARM_DEVICE_REGION (SYNQUACER_I2C0_BASE, SYNQUACER_I2C0_SIZE), > + ARM_DEVICE_REGION (SYNQUACER_I2C1_BASE, SYNQUACER_I2C1_SIZE), > + > // SynQuacer NETSEC > ARM_DEVICE_REGION (SYNQUACER_NETSEC_BASE, SYNQUACER_NETSEC_BASE_SZ), > > -- > 2.11.0 >