From: "Jeremy Linton" <jeremy.linton@arm.com>
To: devel@edk2.groups.io
Cc: ardb+tianocore@kernel.org, quic_llindhol@quicinc.com,
Jeremy Linton <jeremy.linton@arm.com>
Subject: [edk2-devel] [PATCH 4/7] Platform/RaspberryPi: Add mailbox cmd to control audio amp
Date: Wed, 10 Jan 2024 18:04:07 -0600 [thread overview]
Message-ID: <20240111000412.2734985-5-jeremy.linton@arm.com> (raw)
In-Reply-To: <20240111000412.2734985-1-jeremy.linton@arm.com>
The lower level firmware can enable/disable a LDO audio
amp, which allows us to mute/unmute audio output while
the firmware is running.
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
.../Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 60 ++++++++++++++++++-
.../Include/IndustryStandard/RpiMbox.h | 1 +
.../Include/Protocol/RpiFirmware.h | 7 +++
3 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 4edec0ad04..ea0ac1eefe 100644
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -1532,6 +1532,63 @@ RpiFirmwareNotifyGpioSetCfg (
return Status;
}
+#pragma pack()
+typedef struct {
+ UINT32 State;
+} RPI_FW_SET_LDO_REG_TAG;
+
+typedef struct {
+ RPI_FW_BUFFER_HEAD BufferHead;
+ RPI_FW_TAG_HEAD TagHead;
+ RPI_FW_SET_LDO_REG_TAG TagBody;
+ UINT32 EndTag;
+} RPI_FW_SET_LDO_REG_CMD;
+#pragma pack()
+
+
+STATIC
+EFI_STATUS
+EFIAPI
+RpiFirmwareSetLdoRegState (
+ IN UINTN State
+ )
+{
+ RPI_FW_SET_LDO_REG_CMD *Cmd;
+ EFI_STATUS Status;
+ UINT32 Result;
+
+ if (!AcquireSpinLockOrFail (&mMailboxLock)) {
+ DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __func__));
+ return EFI_DEVICE_ERROR;
+ }
+
+ Cmd = mDmaBuffer;
+ ZeroMem (Cmd, sizeof (*Cmd));
+
+ Cmd->BufferHead.BufferSize = sizeof (*Cmd);
+ Cmd->BufferHead.Response = 0;
+ Cmd->TagHead.TagId = RPI_MBOX_SET_LDO_REGULATOR;
+ Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
+ Cmd->TagBody.State = State;
+
+ Cmd->TagHead.TagValueSize = 0;
+ Cmd->EndTag = 0;
+
+ Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
+
+ if (EFI_ERROR (Status) ||
+ Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
+ DEBUG ((DEBUG_ERROR,
+ "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
+ __func__, Status, Cmd->BufferHead.Response));
+ }
+
+ ReleaseSpinLock (&mMailboxLock);
+
+ return Status;
+}
+
+
STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
RpiFirmwareSetPowerState,
RpiFirmwareGetMacAddress,
@@ -1557,7 +1614,8 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
RpiFirmwareNotifyXhciReset,
RpiFirmwareGetCurrentClockState,
RpiFirmwareSetClockState,
- RpiFirmwareNotifyGpioSetCfg
+ RpiFirmwareNotifyGpioSetCfg,
+ RpiFirmwareSetLdoRegState
};
/**
diff --git a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
index 551c2b82e5..f36aaafaf8 100644
--- a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
+++ b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
@@ -92,6 +92,7 @@
#define RPI_MBOX_NOTIFY_REBOOT 0x00030048
#define RPI_MBOX_GET_POE_HAT_VAL 0x00030049
#define RPI_MBOX_SET_POE_HAT_VAL 0x00030050
+#define RPI_MBOX_SET_LDO_REGULATOR 0x00030056
#define RPI_MBOX_NOTIFY_XHCI_RESET 0x00030058
#define RPI_MBOX_SET_CLOCK_STATE 0x00038001
diff --git a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
index c48bb6e434..175894e37a 100644
--- a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
+++ b/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h
@@ -171,6 +171,12 @@ EFI_STATUS
UINTN State
);
+typedef
+EFI_STATUS
+(EFIAPI *SET_LDO_REGULATOR) (
+ UINTN State
+ );
+
typedef struct {
SET_POWER_STATE SetPowerState;
GET_MAC_ADDRESS GetMacAddress;
@@ -197,6 +203,7 @@ typedef struct {
GET_CLOCK_STATE GetClockState;
SET_CLOCK_STATE SetClockState;
GPIO_SET_CFG SetGpioConfig;
+ SET_LDO_REGULATOR SetLdoRegState;
} RASPBERRY_PI_FIRMWARE_PROTOCOL;
extern EFI_GUID gRaspberryPiFirmwareProtocolGuid;
--
2.43.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113553): https://edk2.groups.io/g/devel/message/113553
Mute This Topic: https://groups.io/mt/103653089/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-01-11 0:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 0:04 [edk2-devel] [PATCH 0/7] RaspberryPi: SPI Variables, again Jeremy Linton
2024-01-11 0:04 ` [edk2-devel] [PATCH 1/7] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Jeremy Linton
2024-01-11 0:04 ` [edk2-devel] [PATCH 2/7] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton
2024-01-11 0:04 ` [edk2-devel] [PATCH 3/7] Platform/RaspberryPi: Add constants for controlling SPI Jeremy Linton
2024-01-11 0:04 ` Jeremy Linton [this message]
2024-01-11 0:04 ` [edk2-devel] [PATCH 5/7] Platform/RaspberryPi: Add SPI/GPIO to memory map Jeremy Linton
2024-01-11 0:04 ` [edk2-devel] [PATCH 6/7] Platform/RaspberryPi: Allow pin function selection at runtime Jeremy Linton
2024-01-11 0:04 ` [edk2-devel] [PATCH 7/7] Platform/RaspberryPi: Add SPI flash variable store Jeremy Linton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240111000412.2734985-5-jeremy.linton@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox