Skip to content

Instantly share code, notes, and snippets.

@N1kroks
N1kroks / spmi.c
Last active January 24, 2025 20:47
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/UefiBootServicesTableLib.h>
#define CORE 0x0c440000
#define OBSRVR 0x0e600000
#define PMIC_USID 4 // PM6150L GPIO USID
#define PMIC_GPIO_BASE 0xC000 // PM6150L GPIO address
#define VOL_UP_GPIO 2
def TuneDataPatch(data, value1, value2):
movInstruction = 0x52800002
instr1 = movInstruction | (value1 << 5)
instr2 = movInstruction | (value2 << 5)
loc = data.find(instr1.to_bytes(4, byteorder='little'))
if loc < 0 or loc % 4 != 0:
return data
print("Patching tune data at 0x{:08x}".format(loc))
import argparse
import re
import typing
from pyfdt.pyfdt import FdtBlobParse, Fdt, FdtNode, FdtProperty
CONFIG_PARAMETERS_BLACKLIST = [
"ConfigParameterCount",
"MaxCount",
"StrMaxCount"
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/EFISPMI.h>
EFI_QCOM_SPMI_PROTOCOL *gSPMIProtocol;