Skip to content

Commit

Permalink
Add support for fan controlling in settings
Browse files Browse the repository at this point in the history
Signed-off-by: Molly Sophia <[email protected]>
  • Loading branch information
MollySophia committed Aug 13, 2023
1 parent a46a675 commit 9ec8f97
Show file tree
Hide file tree
Showing 25 changed files with 453 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,23 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}


VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,22 @@ PciePeReset (
}
}

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,24 +270,41 @@ PciePeReset (
}
}

PWM_DATA pwm_data = {
.ControllerID = PWM_CONTROLLER0,
.ChannelID = PWM_CHANNEL3,
.PeriodNs = 4000000,
.DutyNs = 4000000,
.Polarity = FALSE,
}; // PWM0_CH3

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
GpioPinSetFunction (3, GPIO_PIN_PB2, 0xB); // PWM3_IR_M1
RkPwmSetConfig(&pwm_data);
RkPwmEnable(&pwm_data);
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
pwm_data.DutyNs = pwm_data.PeriodNs * Percentage / 100;
RkPwmSetConfig(&pwm_data);
}

VOID
EFIAPI
PlatformEarlyInit (
VOID
)
{
// Configure various things specific to this platform
DEBUG((EFI_D_WARN, "PlatformEarlyInit called\n"));
GpioPinSetFunction (3, GPIO_PIN_PB2, 0xB); // PWM3_IR_M1

PWM_DATA pwm_data = {
.ControllerID = PWM_CONTROLLER0,
.ChannelID = PWM_CHANNEL3,
.PeriodNs = 1000000,
.DutyNs = 500000,
.Polarity = FALSE,
}; // PWM0_CH3

RkPwmSetConfig(&pwm_data);
RkPwmEnable(&pwm_data);
}
5 changes: 5 additions & 0 deletions edk2-rockchip/Platform/Radxa/ROCK5A/ROCK5A.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
gRK3588TokenSpaceGuid.PcdComboPhy0ModeDefault|$(COMBO_PHY_MODE_PCIE)
gRK3588TokenSpaceGuid.PcdComboPhy2ModeDefault|$(COMBO_PHY_MODE_USB3)

#
# On-Board fan output
#
gRK3588TokenSpaceGuid.PcdHasOnBoardFanOutput|TRUE

################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,30 @@ PciePeReset (
}
}

PWM_DATA pwm_data = {
.ControllerID = PWM_CONTROLLER0,
.ChannelID = PWM_CHANNEL1,
.PeriodNs = 25000,
.DutyNs = 15000,
.Polarity = FALSE,
}; // PWM0_CH1

VOID
EFIAPI
PwmFanIoSetup(
VOID
)
{
}

VOID
EFIAPI
PwmFanSetSpeed(
UINT32 Percentage
)
{
}

VOID
EFIAPI
PlatformEarlyInit (
Expand All @@ -332,13 +356,7 @@ PlatformEarlyInit (
DEBUG((EFI_D_WARN, "PlatformEarlyInit called\n"));
GpioPinSetFunction (0, GPIO_PIN_PC0, 0x3); // PWM1_M0

PWM_DATA pwm_data = {
.ControllerID = PWM_CONTROLLER0,
.ChannelID = PWM_CHANNEL1,
.PeriodNs = 25000,
.DutyNs = 15000,
.Polarity = FALSE,
}; // PWM0_CH1


RkPwmSetConfig(&pwm_data);
RkPwmEnable(&pwm_data);
Expand Down
Loading

0 comments on commit 9ec8f97

Please sign in to comment.