From: "Jeremy Linton" <jeremy.linton@arm.com>
To: devel@edk2.groups.io
Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com,
awarkentin@vmware.com, Sunny.Wang@arm.com,
samer.el-haj-mahmoud@arm.com, mariobalanica02@gmail.com,
Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH 6/9] Platform/RaspberryPi: Add mailbox cmd to control audio amp
Date: Thu, 2 Dec 2021 10:52:03 -0600 [thread overview]
Message-ID: <20211202165206.79615-7-jeremy.linton@arm.com> (raw)
In-Reply-To: <20211202165206.79615-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 | 62 +++++++++++++++++++++-
.../RaspberryPi/Include/IndustryStandard/RpiMbox.h | 1 +
.../RaspberryPi/Include/Protocol/RpiFirmware.h | 7 +++
3 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index d38ffbc7d3..03c1e1708f 100644
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -1532,6 +1532,65 @@ 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", __FUNCTION__));
+ return EFI_DEVICE_ERROR;
+ }
+
+ DEBUG ((DEBUG_ERROR, "%a: set LDO\n", __FUNCTION__));
+ 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);
+
+ DEBUG ((DEBUG_ERROR, "%a: set LDO Done\n", __FUNCTION__));
+ if (EFI_ERROR (Status) ||
+ Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
+ DEBUG ((DEBUG_ERROR,
+ "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
+ __FUNCTION__, Status, Cmd->BufferHead.Response));
+ }
+
+ ReleaseSpinLock (&mMailboxLock);
+
+ return Status;
+}
+
+
STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
RpiFirmwareSetPowerState,
RpiFirmwareGetMacAddress,
@@ -1557,7 +1616,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.13.7
next prev parent reply other threads:[~2021-12-02 16:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 16:51 [PATCH 0/9] Platform/RaspberryPi: Utilize SPI flash for EFI variables Jeremy Linton
2021-12-02 16:51 ` [PATCH 1/9] Platform/RaspberryPi: Cleanup menu visibility Jeremy Linton
2021-12-02 16:51 ` [PATCH 2/9] Platform/RaspberryPi: Give the user control over the XHCI mailbox Jeremy Linton
2021-12-02 16:52 ` [PATCH 3/9] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Jeremy Linton
2021-12-02 16:52 ` [PATCH 4/9] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton
2021-12-02 16:52 ` [PATCH 5/9] Platform/RaspberryPi: Add constants for controlling SPI Jeremy Linton
2021-12-02 16:52 ` Jeremy Linton [this message]
2021-12-02 16:52 ` [PATCH 7/9] Platform/RaspberryPi: Add SPI/GPIO to memory map Jeremy Linton
2021-12-02 16:52 ` [PATCH 8/9] Platform/RaspberryPi: Allow pin function selection at runtime Jeremy Linton
2021-12-02 17:03 ` [edk2-devel] [PATCH 0/9] Platform/RaspberryPi: Utilize SPI flash for EFI variables Ard Biesheuvel
2021-12-02 17:09 ` Ard Biesheuvel
2021-12-02 17:29 ` Jeremy Linton
2021-12-02 17:55 ` Jeremy Linton
2021-12-03 18:12 ` Ard Biesheuvel
2021-12-03 19:31 ` 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=20211202165206.79615-7-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