Skip to content

Commit

Permalink
RPM: Enable 5V BSTB for USB-C / USB-OTG.
Browse files Browse the repository at this point in the history
Big thanks to @Googulator.
  • Loading branch information
imbushuo committed Apr 9, 2019
1 parent cd5e3f8 commit cf332bb
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 32 deletions.
34 changes: 7 additions & 27 deletions AcpiTables/8994/src/SSDT.asl
@@ -1,24 +1,4 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20190108 (32-bit version)
* Copyright (c) 2000 - 2019 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
* Disassembly of ../../Documents/GitHub/Lumia950XLPkg/AcpiTables/8994/SSDT.aml, Fri Jan 18 19:32:58 2019
*
* Original Table Header:
* Signature "SSDT"
* Length 0x000013D3 (5075)
* Revision 0x02
* Checksum 0x1B
* OEM ID "MMO "
* OEM Table ID "MSM8994 "
* OEM Revision 0x00000003 (3)
* Compiler ID "INTL"
* Compiler Version 0x20180209 (538444297)
*/
DefinitionBlock ("", "SSDT", 2, "MMO ", "MSM8994 ", 0x00000004)
DefinitionBlock ("", "SSDT", 2, "MMO ", "MSM8994 ", 0x00000011)
{
External (_SB_.ABD_.AVBL, IntObj)
External (_SB_.GIO0, DeviceObj)
Expand Down Expand Up @@ -750,7 +730,7 @@ DefinitionBlock ("", "SSDT", 2, "MMO ", "MSM8994 ", 0x00000004)
0x1001
}
})
Return (RBUF) /* \_SB_.USBC._CRS.RBUF */
Return (RBUF) /* \_SB_.CPSW._CRS.RBUF */
}

Name (_DSD, Package (0x02) // _DSD: Device-Specific Data
Expand Down Expand Up @@ -795,7 +775,7 @@ DefinitionBlock ("", "SSDT", 2, "MMO ", "MSM8994 ", 0x00000004)
})
Name (PGID, Buffer (0x0A)
{
"\\_SB.USBC"
"\\_SB.CPSW"
})
Name (DBUF, Buffer (DBFL){})
CreateByteField (DBUF, Zero, STAT)
Expand All @@ -820,21 +800,21 @@ DefinitionBlock ("", "SSDT", 2, "MMO ", "MSM8994 ", 0x00000004)
{
DEID = Buffer (ESNL){}
DVAL = Zero
DEID = PGID /* \_SB_.USBC.PGID */
DEID = PGID /* \_SB_.CPSW.PGID */
If (\_SB.ABD.AVBL)
{
\_SB.PEP0.FLD0 = DBUF /* \_SB_.USBC.DBUF */
\_SB.PEP0.FLD0 = DBUF /* \_SB_.CPSW.DBUF */
}
}

Method (_PS3, 0, NotSerialized) // _PS3: Power State 3
{
DEID = Buffer (ESNL){}
DVAL = 0x03
DEID = PGID /* \_SB_.USBC.PGID */
DEID = PGID /* \_SB_.CPSW.PGID */
If (\_SB.ABD.AVBL)
{
\_SB.PEP0.FLD0 = DBUF /* \_SB_.USBC.DBUF */
\_SB.PEP0.FLD0 = DBUF /* \_SB_.CPSW.DBUF */
}
}
}
Expand Down
45 changes: 45 additions & 0 deletions Driver/SmdRpmDxe/Driver.c
Expand Up @@ -113,6 +113,35 @@ static uint32_t ldo30[][14] = {
},
};

static uint32_t bst5v[][14] = {
{
BSTB_RES_TYPE,
1,
KEY_SOFTWARE_ENABLE,
4,
GENERIC_DISABLE,
KEY_MICRO_VOLT,
4,
0,
KEY_CURRENT,
4,
0,
},
{
BSTB_RES_TYPE,
1,
KEY_SOFTWARE_ENABLE,
4,
GENERIC_ENABLE,
KEY_MICRO_VOLT,
4,
5000000,
KEY_CURRENT,
4,
0,
},
};

VOID EFIAPI RpmDxeDeInitialize(IN EFI_EVENT Event, IN VOID *Context)
{
DEBUG((EFI_D_INFO, "Unregistering RPM \n"));
Expand Down Expand Up @@ -152,6 +181,18 @@ rpm_ldo30_enable(VOID)
return EFI_SUCCESS;
}

EFI_STATUS
EFIAPI
rpm_5vsw_enable(VOID)
{
// Unconditionally enable 5V Boost (BSTB)
ASSERT(rpm_send_data(&bst5v[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE) == 0);
gBS->Stall(100);
DEBUG((EFI_D_INFO, "5V BSTB enabled \n"));

return EFI_SUCCESS;
}

EFI_STATUS
EFIAPI
RpmDxeInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Expand All @@ -171,5 +212,9 @@ RpmDxeInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
&gEfiEventExitBootServicesGuid, &mExitBootServicesEvent);

ASSERT_EFI_ERROR(Status);

// Try to initialize 5V SW
rpm_5vsw_enable();

return Status;
}
1 change: 0 additions & 1 deletion Hapanero.fdf
Expand Up @@ -66,7 +66,6 @@ READ_LOCK_STATUS = TRUE
INF Lumia950XLPkg/Driver/I2cQupDxe/I2cQupDxe.inf
INF Lumia950XLPkg/Driver/SmemDxe/SmemDxe.inf
INF Lumia950XLPkg/Driver/SmemPtableDxe/SmemPtableDxe.inf
# Wont enable RPM until future use.
INF Lumia950XLPkg/Driver/SmdRpmDxe/RpmDxe.inf
INF Lumia950XLPkg/Driver/SsbiDxe/SsbiDxe.inf
INF Lumia950XLPkg/Driver/BoardDxe/BoardDxe.inf
Expand Down
1 change: 1 addition & 0 deletions Include/Chipset/regulator.h
Expand Up @@ -35,6 +35,7 @@
#define SW_MODE_LDO_IPEAK 1
#define LDOA_RES_TYPE 0x616F646C // aodl
#define SMPS_RES_TYPE 0x61706D73 // apms
#define BSTB_RES_TYPE 0x62747362 // bstb

This comment has been minimized.

Copy link
@Googulator

Googulator Apr 9, 2019

Contributor

Typo, should be "// btsb"


#define KEY_SOFTWARE_ENABLE 0x6E657773 // swen - software enable
#define KEY_LDO_SOFTWARE_MODE 0X646D736C // lsmd - LDO software mode
Expand Down
3 changes: 1 addition & 2 deletions Lumia950.fdf
Expand Up @@ -66,8 +66,7 @@ READ_LOCK_STATUS = TRUE
INF Lumia950XLPkg/Driver/I2cQupDxe/I2cQupDxe.inf
INF Lumia950XLPkg/Driver/SmemDxe/SmemDxe.inf
INF Lumia950XLPkg/Driver/SmemPtableDxe/SmemPtableDxe.inf
# Wont enable RPM until future use.
# INF Lumia950XLPkg/Driver/SmdRpmDxe/RpmDxe.inf
INF Lumia950XLPkg/Driver/SmdRpmDxe/RpmDxe.inf
INF Lumia950XLPkg/Driver/SsbiDxe/SsbiDxe.inf
INF Lumia950XLPkg/Driver/BoardDxe/BoardDxe.inf
INF Lumia950XLPkg/Driver/RuntimeMemoryConfigDxe/RuntimeMemoryConfigDxe.inf
Expand Down
3 changes: 1 addition & 2 deletions Lumia950XL.fdf
Expand Up @@ -66,8 +66,7 @@ READ_LOCK_STATUS = TRUE
INF Lumia950XLPkg/Driver/I2cQupDxe/I2cQupDxe.inf
INF Lumia950XLPkg/Driver/SmemDxe/SmemDxe.inf
INF Lumia950XLPkg/Driver/SmemPtableDxe/SmemPtableDxe.inf
# Wont enable RPM until future use.
# INF Lumia950XLPkg/Driver/SmdRpmDxe/RpmDxe.inf
INF Lumia950XLPkg/Driver/SmdRpmDxe/RpmDxe.inf
INF Lumia950XLPkg/Driver/SsbiDxe/SsbiDxe.inf
INF Lumia950XLPkg/Driver/BoardDxe/BoardDxe.inf
INF Lumia950XLPkg/Driver/RuntimeMemoryConfigDxe/RuntimeMemoryConfigDxe.inf
Expand Down

0 comments on commit cf332bb

Please sign in to comment.