summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2019-07-04 17:51:20 +0100
committerLeif Lindholm <leif.lindholm@linaro.org>2019-07-19 12:34:17 +0100
commit3542dfdecab11e55997c93b09edd59eb90f422ef (patch)
tree0b87c0c6e59e727fff1ae96239a2995ac816aeaa
parentef3512a5332455dfc20fd32435b620fd59079e75 (diff)
Platform/Rpi3: Add custom CPU frequency support
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> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c13
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf1
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni4
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr22
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c6
-rw-r--r--Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h3
-rw-r--r--Platform/RaspberryPi/RPi3/RPi3.dec1
-rw-r--r--Platform/RaspberryPi/RPi3/RPi3.dsc1
8 files changed, 47 insertions, 4 deletions
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
index d64e70ad..fcb4ce69 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
@@ -109,6 +109,14 @@ SetupVariables (
}
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,
NULL, &Size, &Var32);
@@ -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 3fee190a..6d6c90b7 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
@@ -54,6 +54,7 @@
[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 a9c10143..65b45f3e 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 7a182452..217a285b 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
@@ -47,11 +47,16 @@ 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.
* 1 - uSD slot routed to Arasan SDHCI.
@@ -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 925f5a92..9b5ee194 100644
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -799,8 +799,9 @@ STATIC
EFI_STATUS
EFIAPI
RpiFirmwareSetClockRate (
- IN UINT32 ClockId,
- IN UINT32 ClockRate
+ IN UINT32 ClockId,
+ IN UINT32 ClockRate,
+ IN BOOLEAN 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 ? 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 f3e3d1e9..ec70f28e 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 BOOLEAN SkipTurbo
);
typedef
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dec b/Platform/RaspberryPi/RPi3/RPi3.dec
index ab378823..22de439f 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dec
+++ b/Platform/RaspberryPi/RPi3/RPi3.dec
@@ -47,5 +47,6 @@
gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000013
gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000014
gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000015
+ gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|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 ad8fb03a..2b9e619a 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -393,6 +393,7 @@
#
gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSetGuid|0x0|0
+ gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gConfigDxeFormSetGuid|0x0|600
#
# SD-related.