Re: [edk2] [PATCH] EmbeddedPkg/DwEmmcDxe: limit max clock for platform
On Mon, Jul 03, 2017 at 12:01:56PM +0800, Jun Nie wrote: > Some boards may have max clock limitation. Add a Pcd to notify > driver. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jun Nie > --- > EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 4 > EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf | 1 + > EmbeddedPkg/EmbeddedPkg.dec | 1 + > 3 files changed, 6 insertions(+) > > diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > index fe23d11..308f3a7 100644 > --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > @@ -560,6 +560,10 @@ DwEmmcSetIos ( >EFI_STATUS Status = EFI_SUCCESS; >UINT32Data; > > + if (BusClockFreq > PcdGet32 (PcdDwEmmcDxeMaxClockFrequencyInHz)) { This snippet means that any platform that was using this driver successfully, but where BusClockFreq is higher than the default value of this Pcd will stop working. > +return EFI_UNSUPPORTED; > + } > + >if (TimingMode != EMMCBACKWARD) { > Data = MmioRead32 (DWEMMC_UHSREG); > switch (TimingMode) { > diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > index e3c8313..3582997 100644 > --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > @@ -48,6 +48,7 @@ > [Pcd] >gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress >gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz > + gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz > > [Depex] >TRUE > diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec > index 0d4a062..aec8259 100644 > --- a/EmbeddedPkg/EmbeddedPkg.dec > +++ b/EmbeddedPkg/EmbeddedPkg.dec > @@ -167,6 +167,7 @@ ># DwEmmc Driver PCDs >gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0x0|UINT32|0x0035 > > gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|0x0|UINT32|0x0036 > + > gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz|0x0|UINT32|4 And this definition sets the default value of this Pcd to 0. Meaning that all existing drivers would stop working. Also, 0x0037 would seem like a more suitable Token than 4. If introducing a new limit value like this, I would strongly recommend making "0" a magic value meaning "no restrictions". i.e. UINT32 MaxFreq; MaxFreq = PcdGet32 (PcdDwEmmcDxeMaxClockFrequencyInHz); if ((MaxFreq != 0) && (BusClockFreq > MaxFreq)) { / Leif > ># ># Android FastBoot > -- > 1.9.1 > ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] EmbeddedPkg/DwEmmcDxe: limit max clock for platform
On 3 July 2017 at 05:01, Jun Nie wrote: > Some boards may have max clock limitation. Add a Pcd to notify > driver. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jun Nie > --- > EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 4 > EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf | 1 + > EmbeddedPkg/EmbeddedPkg.dec | 1 + > 3 files changed, 6 insertions(+) > > diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > index fe23d11..308f3a7 100644 > --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > @@ -560,6 +560,10 @@ DwEmmcSetIos ( >EFI_STATUS Status = EFI_SUCCESS; >UINT32Data; > > + if (BusClockFreq > PcdGet32 (PcdDwEmmcDxeMaxClockFrequencyInHz)) { > +return EFI_UNSUPPORTED; > + } > + >if (TimingMode != EMMCBACKWARD) { > Data = MmioRead32 (DWEMMC_UHSREG); > switch (TimingMode) { > diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > index e3c8313..3582997 100644 > --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf > @@ -48,6 +48,7 @@ > [Pcd] >gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress >gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz > + gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz > > [Depex] >TRUE > diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec > index 0d4a062..aec8259 100644 > --- a/EmbeddedPkg/EmbeddedPkg.dec > +++ b/EmbeddedPkg/EmbeddedPkg.dec > @@ -167,6 +167,7 @@ ># DwEmmc Driver PCDs >gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0x0|UINT32|0x0035 > > gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|0x0|UINT32|0x0036 > + > gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz|0x0|UINT32|4 > Please use the correct token space guid, or add it to the correct .dec file. ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] EmbeddedPkg/DwEmmcDxe: limit max clock for platform
Some boards may have max clock limitation. Add a Pcd to notify driver. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jun Nie --- EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 4 EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf | 1 + EmbeddedPkg/EmbeddedPkg.dec | 1 + 3 files changed, 6 insertions(+) diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c index fe23d11..308f3a7 100644 --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c @@ -560,6 +560,10 @@ DwEmmcSetIos ( EFI_STATUS Status = EFI_SUCCESS; UINT32Data; + if (BusClockFreq > PcdGet32 (PcdDwEmmcDxeMaxClockFrequencyInHz)) { +return EFI_UNSUPPORTED; + } + if (TimingMode != EMMCBACKWARD) { Data = MmioRead32 (DWEMMC_UHSREG); switch (TimingMode) { diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf index e3c8313..3582997 100644 --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf @@ -48,6 +48,7 @@ [Pcd] gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz + gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz [Depex] TRUE diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index 0d4a062..aec8259 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -167,6 +167,7 @@ # DwEmmc Driver PCDs gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0x0|UINT32|0x0035 gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|0x0|UINT32|0x0036 + gDwEmmcDxeTokenSpaceGuid.PcdDwEmmcDxeMaxClockFrequencyInHz|0x0|UINT32|4 # # Android FastBoot -- 1.9.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel