public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms: PATCH 0/2] Platform/RPi3 improve boot order and add custom freqs
@ 2019-07-02 16:13 Pete Batard
  2019-07-02 16:13 ` [edk2-platforms: PATCH 1/2] Platform/RPi3: Set the boot option of UEFI Shell as non-active Pete Batard
  2019-07-02 16:13 ` [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support Pete Batard
  0 siblings, 2 replies; 6+ messages in thread
From: Pete Batard @ 2019-07-02 16:13 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif.lindholm

The following 2 patches update the Raspberry Pi 3 platform to:
- Remove UEFI Shell as default boot target, to instead default to SD then USB,
  which is the what most users of the UEFI firmware are likely to expect.
- Add the ability to set a custom CPU frequency [100 - 1600 MHz] instead
  of only allowing to pick from a limited set of default values.

Regards,

/Pete

Pete Batard (2):
  Platform/RPi3: Set the boot option of UEFI Shell as non-active
  Platform/Rpi3: Add custom CPU frequency support

 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c               | 13 +++++++++++-
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf             |  1 +
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni          |  4 ++++
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr          | 22 ++++++++++++++++++++
 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c     |  4 +++-
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h              |  3 ++-
 Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c |  2 +-
 Platform/RaspberryPi/RPi3/RPi3.dec                                    | 17 ++++++++-------
 Platform/RaspberryPi/RPi3/RPi3.dsc                                    |  1 +
 Platform/RaspberryPi/RPi3/Readme.md                                   |  6 +++---
 10 files changed, 58 insertions(+), 15 deletions(-)

-- 
2.21.0.windows.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [edk2-platforms: PATCH 1/2] Platform/RPi3: Set the boot option of UEFI Shell as non-active
  2019-07-02 16:13 [edk2-platforms: PATCH 0/2] Platform/RPi3 improve boot order and add custom freqs Pete Batard
@ 2019-07-02 16:13 ` Pete Batard
  2019-07-03 11:43   ` Leif Lindholm
  2019-07-02 16:13 ` [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support Pete Batard
  1 sibling, 1 reply; 6+ messages in thread
From: Pete Batard @ 2019-07-02 16:13 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif.lindholm

This makes boot from SD/USB the default, which is what most users
should expect. Pressing F1 at boot still boots to UEFI Shell.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c | 2 +-
 Platform/RaspberryPi/RPi3/Readme.md                                   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
index 92f3b6146dd7..e7757115d82c 100644
--- a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
@@ -460,7 +460,7 @@ PlatformRegisterOptionsAndKeys (
 
   RemoveStaleBootOptions ();
 
-  ShellOption = PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE);
+  ShellOption = PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_CATEGORY_APP);
   if (ShellOption != -1) {
     //
     // F1 boots Shell.
diff --git a/Platform/RaspberryPi/RPi3/Readme.md b/Platform/RaspberryPi/RPi3/Readme.md
index 7434233df0fb..624f3a8d287a 100644
--- a/Platform/RaspberryPi/RPi3/Readme.md
+++ b/Platform/RaspberryPi/RPi3/Readme.md
@@ -26,9 +26,9 @@ It also provides support for ATF ([Arm Trusted Platform](https://github.com/ARM-
 HDMI and the mini-UART serial port can be used for output devices, with mirrored output.
 USB keyboards and the mini-UART serial port can be used as input.
 
-On a freshly built firmware, the default is to boot the UEFI shell.
-To change the default boot order (for instance to boot uSD media by default) you
-will need to edit the preferences in _Boot Maintenance Manager_.
+The default for the firmware is to first attempt boot from SD then USB. The UEFI
+Shell can also be accessed by pressing F1. To change the boot order you can edit
+the preferences in the _Boot Maintenance Manager_ menu.
 
 For additional information about the tested systems and how to set them up,
 please see [Systems.md](./Systems.md).
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support
  2019-07-02 16:13 [edk2-platforms: PATCH 0/2] Platform/RPi3 improve boot order and add custom freqs Pete Batard
  2019-07-02 16:13 ` [edk2-platforms: PATCH 1/2] Platform/RPi3: Set the boot option of UEFI Shell as non-active Pete Batard
@ 2019-07-02 16:13 ` Pete Batard
  2019-07-03 11:42   ` Leif Lindholm
  1 sibling, 1 reply; 6+ messages in thread
From: Pete Batard @ 2019-07-02 16:13 UTC (permalink / raw)
  To: devel; +Cc: ard.biesheuvel, leif.lindholm

Allow users to set a custom CPU frequency [100 - 1600 MHz]
in 'Device Manager' -> 'Raspberry Pi Configuration'.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c           | 13 +++++++++++-
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf         |  1 +
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni      |  4 ++++
 Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr      | 22 ++++++++++++++++++++
 Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c |  4 +++-
 Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h          |  3 ++-
 Platform/RaspberryPi/RPi3/RPi3.dec                                | 17 ++++++++-------
 Platform/RaspberryPi/RPi3/RPi3.dsc                                |  1 +
 8 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
index d64e70adce36..fcb4ce6935b6 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
@@ -108,6 +108,14 @@ SetupVariables (
     PcdSet32 (PcdCpuClock, PcdGet32 (PcdCpuClock));
   }
 
+  Size = sizeof (UINT32);
+  Status = gRT->GetVariable(L"CustomCpuClock",
+                            &gConfigDxeFormSetGuid,
+                            NULL, &Size, &Var32);
+  if (EFI_ERROR (Status)) {
+    PcdSet32 (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
+  }
+
   Size = sizeof (UINT32);
   Status = gRT->GetVariable (L"SdIsArasan",
                   &gConfigDxeFormSetGuid,
@@ -201,6 +209,7 @@ ApplyVariables (
   UINTN Gpio48Group;
   EFI_STATUS Status;
   UINT32 CpuClock = PcdGet32 (PcdCpuClock);
+  UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock);
   UINT32 Rate = 0;
 
   if (CpuClock != 0) {
@@ -213,6 +222,8 @@ ApplyVariables (
       if (Status != EFI_SUCCESS) {
         DEBUG ((DEBUG_ERROR, "Couldn't get the max CPU speed, leaving as is: %r\n", Status));
       }
+    } else if (CpuClock == 3) {
+      Rate = CustomCpuClock * 1000000;
     } else {
       Rate = 600 * 1000000;
     }
@@ -220,7 +231,7 @@ ApplyVariables (
 
   if (Rate != 0) {
     DEBUG ((DEBUG_INFO, "Setting CPU speed to %uHz\n", Rate));
-    Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate);
+    Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate, 1);
     if (Status != EFI_SUCCESS) {
       DEBUG ((DEBUG_ERROR, "Couldn't set the CPU speed: %r\n", Status));
     }
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
index 3fee190ac41b..6d6c90b78408 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -54,6 +54,7 @@ [Protocols]
 
 [Pcd]
   gRaspberryPiTokenSpaceGuid.PcdCpuClock
+  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock
   gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
   gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit
   gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
index a9c101433008..04f735949ba5 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -25,6 +25,10 @@
 #string STR_CHIPSET_CLOCK_CPU_NA     #language en-US "Don't Override"
 #string STR_CHIPSET_CLOCK_CPU_600MHZ #language en-US "Min (600MHz)"
 #string STR_CHIPSET_CLOCK_CPU_MAX    #language en-US "Max"
+#string STR_CHIPSET_CLOCK_CPU_CUSTOM #language en-US "Custom"
+
+#string STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT #language en-US "CPU Clock Rate (MHz)"
+#string STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP   #language en-US "Adjust the CPU speed.\nMin value: 100 MHz\nMax value: 1600 MHz\n\nWarning: Overclocking can make the system unbootable!"
 
 #string STR_CHIPSET_SD_PROMPT        #language en-US "uSD Routing"
 #string STR_CHIPSET_SD_HELP          #language en-US "Choose host controller to drive uSD slot"
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
index 7a1824525892..217a285b5a1f 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
@@ -47,10 +47,15 @@ typedef struct {
    * 0 - don't change the clock rate.
    * 1 - 600MHz.
    * 2 - maximum.
+   * 3 - custom.
    */
   UINT32 Clock;
 } CHIPSET_CPU_CLOCK_VARSTORE_DATA;
 
+typedef struct {
+  UINT32 Clock;
+} CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA;
+
 typedef struct {
   /*
    * 0 - uSD slot routed to Broadcom SDHOST.
@@ -116,6 +121,11 @@ formset
       name  = CpuClock,
       guid  = CONFIGDXE_FORM_SET_GUID;
 
+    efivarstore CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA,
+      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+      name  = CustomCpuClock,
+      guid  = CONFIGDXE_FORM_SET_GUID;
+
     efivarstore CHIPSET_SD_VARSTORE_DATA,
       attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
       name  = SdIsArasan,
@@ -198,8 +208,20 @@ formset
             option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_NA), value = 0, flags = DEFAULT;
             option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_600MHZ), value = 1, flags = 0;
             option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_MAX), value = 2, flags = 0;
+            option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_CUSTOM), value = 3, flags = 0;
         endoneof;
 
+        grayoutif NOT ideqval CpuClock.Clock == 3;
+          numeric varid = CustomCpuClock.Clock,
+              prompt  = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT),
+              help    = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP),
+              flags   = DISPLAY_UINT_DEC | NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
+              minimum = 100,
+              maximum = 1600,
+              default = 600,
+          endnumeric;
+        endif;
+
         oneof varid = SdIsArasan.Routing,
             prompt      = STRING_TOKEN(STR_CHIPSET_SD_PROMPT),
             help        = STRING_TOKEN(STR_CHIPSET_SD_HELP),
diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 925f5a921290..5d96c0d84181 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -800,7 +800,8 @@ EFI_STATUS
 EFIAPI
 RpiFirmwareSetClockRate (
   IN  UINT32 ClockId,
-  IN  UINT32 ClockRate
+  IN  UINT32 ClockRate,
+  IN  UINT32 SkipTurbo
   )
 {
   RPI_FW_SET_CLOCK_RATE_CMD   *Cmd;
@@ -822,6 +823,7 @@ RpiFirmwareSetClockRate (
   Cmd->TagHead.TagValueSize   = 0;
   Cmd->TagBody.ClockId        = ClockId;
   Cmd->TagBody.ClockRate      = ClockRate;
+  Cmd->TagBody.SkipTurbo      = SkipTurbo;
   Cmd->EndTag                 = 0;
 
   Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
index f3e3d1e99eba..cc4e2786e653 100644
--- a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
+++ b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
@@ -44,7 +44,8 @@ typedef
 EFI_STATUS
 (EFIAPI *SET_CLOCK_RATE) (
   IN  UINT32    ClockId,
-  OUT UINT32    ClockRate
+  OUT UINT32    ClockRate,
+  IN  UINT32    SkipTurbo
   );
 
 typedef
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dec b/Platform/RaspberryPi/RPi3/RPi3.dec
index ab3788237861..56eac262502e 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dec
+++ b/Platform/RaspberryPi/RPi3/RPi3.dec
@@ -39,13 +39,14 @@ [PcdsFixedAtBuild.common]
 
 [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   gRaspberryPiTokenSpaceGuid.PcdCpuClock|0|UINT32|0x0000000d
-  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|0|UINT32|0x0000000e
-  gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|0|UINT32|0x0000000f
-  gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|0|UINT32|0x00000010
-  gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|0|UINT32|0x00000011
-  gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000012
-  gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000013
-  gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000014
-  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000015
+  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|0|UINT32|0x0000000e
+  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|0|UINT32|0x0000000f
+  gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|0|UINT32|0x00000010
+  gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|0|UINT32|0x00000011
+  gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|0|UINT32|0x00000012
+  gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000013
+  gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000014
+  gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000015
+  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000016
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableVModes|0|UINT32|0x00000017
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|0|UINT32|0x00000018
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index ad8fb03ab305..2b9e619ad55c 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -393,6 +393,7 @@ [PcdsDynamicHii.common.DEFAULT]
   #
 
   gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSetGuid|0x0|0
+  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gConfigDxeFormSetGuid|0x0|600
 
   #
   # SD-related.
-- 
2.21.0.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support
  2019-07-02 16:13 ` [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support Pete Batard
@ 2019-07-03 11:42   ` Leif Lindholm
  2019-07-03 12:09     ` Pete Batard
  0 siblings, 1 reply; 6+ messages in thread
From: Leif Lindholm @ 2019-07-03 11:42 UTC (permalink / raw)
  To: Pete Batard; +Cc: devel, ard.biesheuvel

On Tue, Jul 02, 2019 at 05:13:41PM +0100, Pete Batard wrote:
> Allow users to set a custom CPU frequency [100 - 1600 MHz]
> in 'Device Manager' -> 'Raspberry Pi Configuration'.
> 
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
>  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c           | 13 +++++++++++-
>  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf         |  1 +
>  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni      |  4 ++++
>  Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr      | 22 ++++++++++++++++++++
>  Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c |  4 +++-
>  Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h          |  3 ++-
>  Platform/RaspberryPi/RPi3/RPi3.dec                                | 17 ++++++++-------
>  Platform/RaspberryPi/RPi3/RPi3.dsc                                |  1 +
>  8 files changed, 54 insertions(+), 11 deletions(-)
> 
> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
> index d64e70adce36..fcb4ce6935b6 100644
> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
> @@ -108,6 +108,14 @@ SetupVariables (
>      PcdSet32 (PcdCpuClock, PcdGet32 (PcdCpuClock));
>    }
>  
> +  Size = sizeof (UINT32);
> +  Status = gRT->GetVariable(L"CustomCpuClock",
> +                            &gConfigDxeFormSetGuid,
> +                            NULL, &Size, &Var32);
> +  if (EFI_ERROR (Status)) {
> +    PcdSet32 (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
> +  }
> +
>    Size = sizeof (UINT32);
>    Status = gRT->GetVariable (L"SdIsArasan",
>                    &gConfigDxeFormSetGuid,
> @@ -201,6 +209,7 @@ ApplyVariables (
>    UINTN Gpio48Group;
>    EFI_STATUS Status;
>    UINT32 CpuClock = PcdGet32 (PcdCpuClock);
> +  UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock);
>    UINT32 Rate = 0;
>  
>    if (CpuClock != 0) {
> @@ -213,6 +222,8 @@ ApplyVariables (
>        if (Status != EFI_SUCCESS) {
>          DEBUG ((DEBUG_ERROR, "Couldn't get the max CPU speed, leaving as is: %r\n", Status));
>        }
> +    } else if (CpuClock == 3) {
> +      Rate = CustomCpuClock * 1000000;
>      } else {
>        Rate = 600 * 1000000;
>      }
> @@ -220,7 +231,7 @@ ApplyVariables (
>  
>    if (Rate != 0) {
>      DEBUG ((DEBUG_INFO, "Setting CPU speed to %uHz\n", Rate));
> -    Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate);
> +    Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate, 1);
>      if (Status != EFI_SUCCESS) {
>        DEBUG ((DEBUG_ERROR, "Couldn't set the CPU speed: %r\n", Status));
>      }
> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
> index 3fee190ac41b..6d6c90b78408 100644
> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
> @@ -54,6 +54,7 @@ [Protocols]
>  
>  [Pcd]
>    gRaspberryPiTokenSpaceGuid.PcdCpuClock
> +  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock
>    gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
>    gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit
>    gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed
> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
> index a9c101433008..04f735949ba5 100644
> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
> @@ -25,6 +25,10 @@
>  #string STR_CHIPSET_CLOCK_CPU_NA     #language en-US "Don't Override"
>  #string STR_CHIPSET_CLOCK_CPU_600MHZ #language en-US "Min (600MHz)"
>  #string STR_CHIPSET_CLOCK_CPU_MAX    #language en-US "Max"
> +#string STR_CHIPSET_CLOCK_CPU_CUSTOM #language en-US "Custom"
> +
> +#string STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT #language en-US "CPU Clock Rate (MHz)"
> +#string STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP   #language en-US "Adjust the CPU speed.\nMin value: 100 MHz\nMax value: 1600 MHz\n\nWarning: Overclocking can make the system unbootable!"
>  
>  #string STR_CHIPSET_SD_PROMPT        #language en-US "uSD Routing"
>  #string STR_CHIPSET_SD_HELP          #language en-US "Choose host controller to drive uSD slot"
> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
> index 7a1824525892..217a285b5a1f 100644
> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
> @@ -47,10 +47,15 @@ typedef struct {
>     * 0 - don't change the clock rate.
>     * 1 - 600MHz.
>     * 2 - maximum.
> +   * 3 - custom.
>     */
>    UINT32 Clock;
>  } CHIPSET_CPU_CLOCK_VARSTORE_DATA;
>  
> +typedef struct {
> +  UINT32 Clock;
> +} CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA;
> +
>  typedef struct {
>    /*
>     * 0 - uSD slot routed to Broadcom SDHOST.
> @@ -116,6 +121,11 @@ formset
>        name  = CpuClock,
>        guid  = CONFIGDXE_FORM_SET_GUID;
>  
> +    efivarstore CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA,
> +      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,

Is the runtime access intentional? Are we expecting users to change
the (post reboot) frequency from within the operating system?

> +      name  = CustomCpuClock,
> +      guid  = CONFIGDXE_FORM_SET_GUID;
> +
>      efivarstore CHIPSET_SD_VARSTORE_DATA,
>        attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
>        name  = SdIsArasan,
> @@ -198,8 +208,20 @@ formset
>              option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_NA), value = 0, flags = DEFAULT;
>              option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_600MHZ), value = 1, flags = 0;
>              option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_MAX), value = 2, flags = 0;
> +            option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_CUSTOM), value = 3, flags = 0;
>          endoneof;
>  
> +        grayoutif NOT ideqval CpuClock.Clock == 3;
> +          numeric varid = CustomCpuClock.Clock,
> +              prompt  = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT),
> +              help    = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP),
> +              flags   = DISPLAY_UINT_DEC | NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
> +              minimum = 100,
> +              maximum = 1600,
> +              default = 600,
> +          endnumeric;
> +        endif;
> +
>          oneof varid = SdIsArasan.Routing,
>              prompt      = STRING_TOKEN(STR_CHIPSET_SD_PROMPT),
>              help        = STRING_TOKEN(STR_CHIPSET_SD_HELP),
> diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
> index 925f5a921290..5d96c0d84181 100644
> --- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
> +++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
> @@ -800,7 +800,8 @@ EFI_STATUS
>  EFIAPI
>  RpiFirmwareSetClockRate (
>    IN  UINT32 ClockId,
> -  IN  UINT32 ClockRate
> +  IN  UINT32 ClockRate,
> +  IN  UINT32 SkipTurbo
>    )
>  {
>    RPI_FW_SET_CLOCK_RATE_CMD   *Cmd;
> @@ -822,6 +823,7 @@ RpiFirmwareSetClockRate (
>    Cmd->TagHead.TagValueSize   = 0;
>    Cmd->TagBody.ClockId        = ClockId;
>    Cmd->TagBody.ClockRate      = ClockRate;
> +  Cmd->TagBody.SkipTurbo      = SkipTurbo;

I guess this is defined in some protocol defined somewhere to be a
32-bit value, since the struct is already defined before this set.

However, from the EDK2 API side, it doesn't really make sense - could
you change the function parameter to BOOL and the callers to use
TRUE/FALSE instead of 1/0?

>    Cmd->EndTag                 = 0;
>  
>    Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
> diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
> index f3e3d1e99eba..cc4e2786e653 100644
> --- a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
> +++ b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
> @@ -44,7 +44,8 @@ typedef
>  EFI_STATUS
>  (EFIAPI *SET_CLOCK_RATE) (
>    IN  UINT32    ClockId,
> -  OUT UINT32    ClockRate
> +  OUT UINT32    ClockRate,
> +  IN  UINT32    SkipTurbo
>    );
>  
>  typedef
> diff --git a/Platform/RaspberryPi/RPi3/RPi3.dec b/Platform/RaspberryPi/RPi3/RPi3.dec
> index ab3788237861..56eac262502e 100644
> --- a/Platform/RaspberryPi/RPi3/RPi3.dec
> +++ b/Platform/RaspberryPi/RPi3/RPi3.dec
> @@ -39,13 +39,14 @@ [PcdsFixedAtBuild.common]
>  
>  [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>    gRaspberryPiTokenSpaceGuid.PcdCpuClock|0|UINT32|0x0000000d
> -  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|0|UINT32|0x0000000e
> -  gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|0|UINT32|0x0000000f
> -  gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|0|UINT32|0x00000010
> -  gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|0|UINT32|0x00000011
> -  gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000012
> -  gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000013
> -  gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000014
> -  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000015
> +  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|0|UINT32|0x0000000e
> +  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|0|UINT32|0x0000000f
> +  gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|0|UINT32|0x00000010
> +  gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|0|UINT32|0x00000011
> +  gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|0|UINT32|0x00000012
> +  gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000013
> +  gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000014
> +  gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000015
> +  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000016

Ouch.
I think I would rather have the token ids, or the Pcds, out of order than
reindexing them when we add a new one. The tool will warn you about duplicates.

/
    Leif

>    gRaspberryPiTokenSpaceGuid.PcdDisplayEnableVModes|0|UINT32|0x00000017
>    gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|0|UINT32|0x00000018
> diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
> index ad8fb03ab305..2b9e619ad55c 100644
> --- a/Platform/RaspberryPi/RPi3/RPi3.dsc
> +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
> @@ -393,6 +393,7 @@ [PcdsDynamicHii.common.DEFAULT]
>    #
>  
>    gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSetGuid|0x0|0
> +  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gConfigDxeFormSetGuid|0x0|600
>  
>    #
>    # SD-related.
> -- 
> 2.21.0.windows.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-platforms: PATCH 1/2] Platform/RPi3: Set the boot option of UEFI Shell as non-active
  2019-07-02 16:13 ` [edk2-platforms: PATCH 1/2] Platform/RPi3: Set the boot option of UEFI Shell as non-active Pete Batard
@ 2019-07-03 11:43   ` Leif Lindholm
  0 siblings, 0 replies; 6+ messages in thread
From: Leif Lindholm @ 2019-07-03 11:43 UTC (permalink / raw)
  To: Pete Batard; +Cc: devel, ard.biesheuvel

On Tue, Jul 02, 2019 at 05:13:40PM +0100, Pete Batard wrote:
> This makes boot from SD/USB the default, which is what most users
> should expect. Pressing F1 at boot still boots to UEFI Shell.
> 
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
>  Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c | 2 +-
>  Platform/RaspberryPi/RPi3/Readme.md                                   | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
> index 92f3b6146dd7..e7757115d82c 100644
> --- a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -460,7 +460,7 @@ PlatformRegisterOptionsAndKeys (
>  
>    RemoveStaleBootOptions ();
>  
> -  ShellOption = PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE);
> +  ShellOption = PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_CATEGORY_APP);

If you make a v2, could you break the above line please?

/
    Leif

>    if (ShellOption != -1) {
>      //
>      // F1 boots Shell.
> diff --git a/Platform/RaspberryPi/RPi3/Readme.md b/Platform/RaspberryPi/RPi3/Readme.md
> index 7434233df0fb..624f3a8d287a 100644
> --- a/Platform/RaspberryPi/RPi3/Readme.md
> +++ b/Platform/RaspberryPi/RPi3/Readme.md
> @@ -26,9 +26,9 @@ It also provides support for ATF ([Arm Trusted Platform](https://github.com/ARM-
>  HDMI and the mini-UART serial port can be used for output devices, with mirrored output.
>  USB keyboards and the mini-UART serial port can be used as input.
>  
> -On a freshly built firmware, the default is to boot the UEFI shell.
> -To change the default boot order (for instance to boot uSD media by default) you
> -will need to edit the preferences in _Boot Maintenance Manager_.
> +The default for the firmware is to first attempt boot from SD then USB. The UEFI
> +Shell can also be accessed by pressing F1. To change the boot order you can edit
> +the preferences in the _Boot Maintenance Manager_ menu.
>  
>  For additional information about the tested systems and how to set them up,
>  please see [Systems.md](./Systems.md).
> -- 
> 2.21.0.windows.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support
  2019-07-03 11:42   ` Leif Lindholm
@ 2019-07-03 12:09     ` Pete Batard
  0 siblings, 0 replies; 6+ messages in thread
From: Pete Batard @ 2019-07-03 12:09 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: devel, ard.biesheuvel

Hi Leif,

On 2019.07.03 12:42, Leif Lindholm wrote:
> On Tue, Jul 02, 2019 at 05:13:41PM +0100, Pete Batard wrote:
>> Allow users to set a custom CPU frequency [100 - 1600 MHz]
>> in 'Device Manager' -> 'Raspberry Pi Configuration'.
>>
>> Signed-off-by: Pete Batard <pete@akeo.ie>
>> ---
>>   Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c           | 13 +++++++++++-
>>   Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf         |  1 +
>>   Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni      |  4 ++++
>>   Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr      | 22 ++++++++++++++++++++
>>   Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c |  4 +++-
>>   Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h          |  3 ++-
>>   Platform/RaspberryPi/RPi3/RPi3.dec                                | 17 ++++++++-------
>>   Platform/RaspberryPi/RPi3/RPi3.dsc                                |  1 +
>>   8 files changed, 54 insertions(+), 11 deletions(-)
>>
>> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
>> index d64e70adce36..fcb4ce6935b6 100644
>> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
>> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
>> @@ -108,6 +108,14 @@ SetupVariables (
>>       PcdSet32 (PcdCpuClock, PcdGet32 (PcdCpuClock));
>>     }
>>   
>> +  Size = sizeof (UINT32);
>> +  Status = gRT->GetVariable(L"CustomCpuClock",
>> +                            &gConfigDxeFormSetGuid,
>> +                            NULL, &Size, &Var32);
>> +  if (EFI_ERROR (Status)) {
>> +    PcdSet32 (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
>> +  }
>> +
>>     Size = sizeof (UINT32);
>>     Status = gRT->GetVariable (L"SdIsArasan",
>>                     &gConfigDxeFormSetGuid,
>> @@ -201,6 +209,7 @@ ApplyVariables (
>>     UINTN Gpio48Group;
>>     EFI_STATUS Status;
>>     UINT32 CpuClock = PcdGet32 (PcdCpuClock);
>> +  UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock);
>>     UINT32 Rate = 0;
>>   
>>     if (CpuClock != 0) {
>> @@ -213,6 +222,8 @@ ApplyVariables (
>>         if (Status != EFI_SUCCESS) {
>>           DEBUG ((DEBUG_ERROR, "Couldn't get the max CPU speed, leaving as is: %r\n", Status));
>>         }
>> +    } else if (CpuClock == 3) {
>> +      Rate = CustomCpuClock * 1000000;
>>       } else {
>>         Rate = 600 * 1000000;
>>       }
>> @@ -220,7 +231,7 @@ ApplyVariables (
>>   
>>     if (Rate != 0) {
>>       DEBUG ((DEBUG_INFO, "Setting CPU speed to %uHz\n", Rate));
>> -    Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate);
>> +    Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate, 1);
>>       if (Status != EFI_SUCCESS) {
>>         DEBUG ((DEBUG_ERROR, "Couldn't set the CPU speed: %r\n", Status));
>>       }
>> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
>> index 3fee190ac41b..6d6c90b78408 100644
>> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
>> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
>> @@ -54,6 +54,7 @@ [Protocols]
>>   
>>   [Pcd]
>>     gRaspberryPiTokenSpaceGuid.PcdCpuClock
>> +  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock
>>     gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
>>     gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit
>>     gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed
>> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
>> index a9c101433008..04f735949ba5 100644
>> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
>> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
>> @@ -25,6 +25,10 @@
>>   #string STR_CHIPSET_CLOCK_CPU_NA     #language en-US "Don't Override"
>>   #string STR_CHIPSET_CLOCK_CPU_600MHZ #language en-US "Min (600MHz)"
>>   #string STR_CHIPSET_CLOCK_CPU_MAX    #language en-US "Max"
>> +#string STR_CHIPSET_CLOCK_CPU_CUSTOM #language en-US "Custom"
>> +
>> +#string STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT #language en-US "CPU Clock Rate (MHz)"
>> +#string STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP   #language en-US "Adjust the CPU speed.\nMin value: 100 MHz\nMax value: 1600 MHz\n\nWarning: Overclocking can make the system unbootable!"
>>   
>>   #string STR_CHIPSET_SD_PROMPT        #language en-US "uSD Routing"
>>   #string STR_CHIPSET_SD_HELP          #language en-US "Choose host controller to drive uSD slot"
>> diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
>> index 7a1824525892..217a285b5a1f 100644
>> --- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
>> +++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
>> @@ -47,10 +47,15 @@ typedef struct {
>>      * 0 - don't change the clock rate.
>>      * 1 - 600MHz.
>>      * 2 - maximum.
>> +   * 3 - custom.
>>      */
>>     UINT32 Clock;
>>   } CHIPSET_CPU_CLOCK_VARSTORE_DATA;
>>   
>> +typedef struct {
>> +  UINT32 Clock;
>> +} CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA;
>> +
>>   typedef struct {
>>     /*
>>      * 0 - uSD slot routed to Broadcom SDHOST.
>> @@ -116,6 +121,11 @@ formset
>>         name  = CpuClock,
>>         guid  = CONFIGDXE_FORM_SET_GUID;
>>   
>> +    efivarstore CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA,
>> +      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
> 
> Is the runtime access intentional? Are we expecting users to change
> the (post reboot) frequency from within the operating system?

You're right, I don't think having EFI_VARIABLE_RUNTIME_ACCESS makes 
sense. Or at least, I'm not aware of any OS that would provide the 
functionality to alter this custom frequency. Let me remove it.

> 
>> +      name  = CustomCpuClock,
>> +      guid  = CONFIGDXE_FORM_SET_GUID;
>> +
>>       efivarstore CHIPSET_SD_VARSTORE_DATA,
>>         attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
>>         name  = SdIsArasan,
>> @@ -198,8 +208,20 @@ formset
>>               option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_NA), value = 0, flags = DEFAULT;
>>               option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_600MHZ), value = 1, flags = 0;
>>               option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_MAX), value = 2, flags = 0;
>> +            option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_CUSTOM), value = 3, flags = 0;
>>           endoneof;
>>   
>> +        grayoutif NOT ideqval CpuClock.Clock == 3;
>> +          numeric varid = CustomCpuClock.Clock,
>> +              prompt  = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT),
>> +              help    = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP),
>> +              flags   = DISPLAY_UINT_DEC | NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
>> +              minimum = 100,
>> +              maximum = 1600,
>> +              default = 600,
>> +          endnumeric;
>> +        endif;
>> +
>>           oneof varid = SdIsArasan.Routing,
>>               prompt      = STRING_TOKEN(STR_CHIPSET_SD_PROMPT),
>>               help        = STRING_TOKEN(STR_CHIPSET_SD_HELP),
>> diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
>> index 925f5a921290..5d96c0d84181 100644
>> --- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
>> +++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
>> @@ -800,7 +800,8 @@ EFI_STATUS
>>   EFIAPI
>>   RpiFirmwareSetClockRate (
>>     IN  UINT32 ClockId,
>> -  IN  UINT32 ClockRate
>> +  IN  UINT32 ClockRate,
>> +  IN  UINT32 SkipTurbo
>>     )
>>   {
>>     RPI_FW_SET_CLOCK_RATE_CMD   *Cmd;
>> @@ -822,6 +823,7 @@ RpiFirmwareSetClockRate (
>>     Cmd->TagHead.TagValueSize   = 0;
>>     Cmd->TagBody.ClockId        = ClockId;
>>     Cmd->TagBody.ClockRate      = ClockRate;
>> +  Cmd->TagBody.SkipTurbo      = SkipTurbo;
> 
> I guess this is defined in some protocol defined somewhere to be a
> 32-bit value, since the struct is already defined before this set.
> 
> However, from the EDK2 API side, it doesn't really make sense - could
> you change the function parameter to BOOL and the callers to use
> TRUE/FALSE instead of 1/0?

I'll switch to using a BOOL.

> 
>>     Cmd->EndTag                 = 0;
>>   
>>     Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
>> diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
>> index f3e3d1e99eba..cc4e2786e653 100644
>> --- a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
>> +++ b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
>> @@ -44,7 +44,8 @@ typedef
>>   EFI_STATUS
>>   (EFIAPI *SET_CLOCK_RATE) (
>>     IN  UINT32    ClockId,
>> -  OUT UINT32    ClockRate
>> +  OUT UINT32    ClockRate,
>> +  IN  UINT32    SkipTurbo
>>     );
>>   
>>   typedef
>> diff --git a/Platform/RaspberryPi/RPi3/RPi3.dec b/Platform/RaspberryPi/RPi3/RPi3.dec
>> index ab3788237861..56eac262502e 100644
>> --- a/Platform/RaspberryPi/RPi3/RPi3.dec
>> +++ b/Platform/RaspberryPi/RPi3/RPi3.dec
>> @@ -39,13 +39,14 @@ [PcdsFixedAtBuild.common]
>>   
>>   [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>>     gRaspberryPiTokenSpaceGuid.PcdCpuClock|0|UINT32|0x0000000d
>> -  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|0|UINT32|0x0000000e
>> -  gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|0|UINT32|0x0000000f
>> -  gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|0|UINT32|0x00000010
>> -  gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|0|UINT32|0x00000011
>> -  gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000012
>> -  gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000013
>> -  gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000014
>> -  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000015
>> +  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|0|UINT32|0x0000000e
>> +  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|0|UINT32|0x0000000f
>> +  gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|0|UINT32|0x00000010
>> +  gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|0|UINT32|0x00000011
>> +  gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|0|UINT32|0x00000012
>> +  gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000013
>> +  gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000014
>> +  gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000015
>> +  gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000016
> 
> Ouch.
> I think I would rather have the token ids, or the Pcds, out of order than
> reindexing them when we add a new one. The tool will warn you about duplicates.

Alright then. I'll leave the existing values and only add the one we 
need. I will send a v2 later that also takes into account the breaking 
of the line you requested for the other patch.

Regards,

/Pete

> 
> /
>      Leif
> 
>>     gRaspberryPiTokenSpaceGuid.PcdDisplayEnableVModes|0|UINT32|0x00000017
>>     gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|0|UINT32|0x00000018
>> diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
>> index ad8fb03ab305..2b9e619ad55c 100644
>> --- a/Platform/RaspberryPi/RPi3/RPi3.dsc
>> +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
>> @@ -393,6 +393,7 @@ [PcdsDynamicHii.common.DEFAULT]
>>     #
>>   
>>     gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSetGuid|0x0|0
>> +  gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gConfigDxeFormSetGuid|0x0|600
>>   
>>     #
>>     # SD-related.
>> -- 
>> 2.21.0.windows.1
>>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-03 12:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-02 16:13 [edk2-platforms: PATCH 0/2] Platform/RPi3 improve boot order and add custom freqs Pete Batard
2019-07-02 16:13 ` [edk2-platforms: PATCH 1/2] Platform/RPi3: Set the boot option of UEFI Shell as non-active Pete Batard
2019-07-03 11:43   ` Leif Lindholm
2019-07-02 16:13 ` [edk2-platforms: PATCH 2/2] Platform/Rpi3: Add custom CPU frequency support Pete Batard
2019-07-03 11:42   ` Leif Lindholm
2019-07-03 12:09     ` Pete Batard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox