From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 87C7D9403E3 for ; Thu, 11 Jan 2024 00:04:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=JH1Kl3SKmL4QU5pQAifrwezGj94aQ+QPPV3U4ol5Ny8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704931461; v=1; b=kUJB7fdJ5cH7SfTuQHkPNPjGiV9llsi1a7Kd4oUuX79LLWsqaJQyunvTOD/Y/vWs5FiHmqOV mamiWNh0TT3ENwINqlGsuKtmc6B9dqs7Ugpxk1fMNHZicppYCxc2hAic6K0i56NgboCOIcTzDFc 5FBR6rJWOIvYM4gpw5Irn760= X-Received: by 127.0.0.2 with SMTP id KwRlYY7687511xswYzTlZGOY; Wed, 10 Jan 2024 16:04:21 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.9454.1704931457148794238 for ; Wed, 10 Jan 2024 16:04:17 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 961F21424; Wed, 10 Jan 2024 16:05:02 -0800 (PST) X-Received: from u200865.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 80E833F5A1; Wed, 10 Jan 2024 16:04:16 -0800 (PST) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: ardb+tianocore@kernel.org, quic_llindhol@quicinc.com, Jeremy Linton Subject: [edk2-devel] [PATCH 4/7] Platform/RaspberryPi: Add mailbox cmd to control audio amp Date: Wed, 10 Jan 2024 18:04:07 -0600 Message-ID: <20240111000412.2734985-5-jeremy.linton@arm.com> In-Reply-To: <20240111000412.2734985-1-jeremy.linton@arm.com> References: <20240111000412.2734985-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jeremy.linton@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6utqYkXvB0B8QUD4scvrSyaCx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=kUJB7fdJ; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- .../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; } =20 +#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 =3D mDmaBuffer; + ZeroMem (Cmd, sizeof (*Cmd)); + + Cmd->BufferHead.BufferSize =3D sizeof (*Cmd); + Cmd->BufferHead.Response =3D 0; + Cmd->TagHead.TagId =3D RPI_MBOX_SET_LDO_REGULATOR; + Cmd->TagHead.TagSize =3D sizeof (Cmd->TagBody); + Cmd->TagBody.State =3D State; + + Cmd->TagHead.TagValueSize =3D 0; + Cmd->EndTag =3D 0; + + Status =3D MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC= _CHANNEL, &Result); + + if (EFI_ERROR (Status) || + Cmd->BufferHead.Response !=3D RPI_MBOX_RESP_SUCCESS) { + DEBUG ((DEBUG_ERROR, + "%a: mailbox transaction error: Status =3D=3D %r, Response =3D=3D= 0x%x\n", + __func__, Status, Cmd->BufferHead.Response)); + } + + ReleaseSpinLock (&mMailboxLock); + + return Status; +} + + STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol =3D { RpiFirmwareSetPowerState, RpiFirmwareGetMacAddress, @@ -1557,7 +1614,8 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareP= rotocol =3D { RpiFirmwareNotifyXhciReset, RpiFirmwareGetCurrentClockState, RpiFirmwareSetClockState, - RpiFirmwareNotifyGpioSetCfg + RpiFirmwareNotifyGpioSetCfg, + RpiFirmwareSetLdoRegState }; =20 /** diff --git a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h b/Pl= atform/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 =20 #define RPI_MBOX_SET_CLOCK_STATE 0x00038001 diff --git a/Platform/RaspberryPi/Include/Protocol/RpiFirmware.h b/Platfo= rm/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 ); =20 +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; =20 extern EFI_GUID gRaspberryPiFirmwareProtocolGuid; --=20 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] -=-=-=-=-=-=-=-=-=-=-=-