Skip to content

Commit

Permalink
Initial MP1 adjustment support for Strix Point
Browse files Browse the repository at this point in the history
Also annotated functions with corresponding ACPI calls.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
  • Loading branch information
FlyGoat committed Sep 5, 2024
1 parent fceacb4 commit b30c7f2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
49 changes: 49 additions & 0 deletions lib/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ do { \
EXP int CALL set_stapm_limit(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x05, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -449,6 +451,7 @@ EXP int CALL set_stapm_limit(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x14);
if (err) {
printf("%s: Retry with PSMU\n", __func__);
Expand All @@ -463,6 +466,7 @@ EXP int CALL set_stapm_limit(ryzen_access ry, uint32_t value){
EXP int CALL set_fast_limit(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x06, val]) */
switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -478,6 +482,7 @@ EXP int CALL set_fast_limit(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x15);
default:
break;
Expand All @@ -488,6 +493,8 @@ EXP int CALL set_fast_limit(ryzen_access ry, uint32_t value){
EXP int CALL set_slow_limit(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x07, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -503,6 +510,7 @@ EXP int CALL set_slow_limit(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x16);
default:
break;
Expand All @@ -513,6 +521,8 @@ EXP int CALL set_slow_limit(ryzen_access ry, uint32_t value){
EXP int CALL set_slow_time(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x08, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -528,6 +538,7 @@ EXP int CALL set_slow_time(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x17);
default:
break;
Expand All @@ -538,6 +549,8 @@ EXP int CALL set_slow_time(ryzen_access ry, uint32_t value){
EXP int CALL set_stapm_time(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x01, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -553,6 +566,7 @@ EXP int CALL set_stapm_time(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x18);
default:
break;
Expand All @@ -563,6 +577,8 @@ EXP int CALL set_stapm_time(ryzen_access ry, uint32_t value){
EXP int CALL set_tctl_temp(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x03, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -578,6 +594,7 @@ EXP int CALL set_tctl_temp(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x19);
default:
break;
Expand All @@ -588,6 +605,8 @@ EXP int CALL set_tctl_temp(ryzen_access ry, uint32_t value){
EXP int CALL set_vrm_current(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x0b, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -603,6 +622,7 @@ EXP int CALL set_vrm_current(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x1a);
default:
break;
Expand All @@ -613,6 +633,8 @@ EXP int CALL set_vrm_current(ryzen_access ry, uint32_t value){
EXP int CALL set_vrmsoc_current(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x0e, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -628,6 +650,7 @@ EXP int CALL set_vrmsoc_current(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x1b);
default:
break;
Expand Down Expand Up @@ -664,6 +687,8 @@ EXP int CALL set_vrmcvip_current(ryzen_access ry, uint32_t value){
EXP int CALL set_vrmmax_current(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x0c, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -678,6 +703,7 @@ EXP int CALL set_vrmmax_current(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x1c);
break;
case FAM_VANGOGH:
Expand All @@ -704,6 +730,8 @@ EXP int CALL set_vrmgfxmax_current(ryzen_access ry, uint32_t value){
EXP int CALL set_vrmsocmax_current(ryzen_access ry, uint32_t value){
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x11, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -718,6 +746,7 @@ EXP int CALL set_vrmsocmax_current(ryzen_access ry, uint32_t value){
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x1d);
default:
break;
Expand Down Expand Up @@ -954,6 +983,8 @@ EXP int CALL set_min_lclk(ryzen_access ry, uint32_t value){
EXP int CALL set_prochot_deassertion_ramp(ryzen_access ry, uint32_t value) {
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x09, val]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -973,6 +1004,7 @@ EXP int CALL set_prochot_deassertion_ramp(ryzen_access ry, uint32_t value) {
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x1f);
default:
break;
Expand All @@ -983,6 +1015,8 @@ EXP int CALL set_prochot_deassertion_ramp(ryzen_access ry, uint32_t value) {
EXP int CALL set_apu_skin_temp_limit(ryzen_access ry, uint32_t value) {
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x22, val]) */

value *= 256;
switch (ry->family)
{
Expand All @@ -1007,6 +1041,8 @@ EXP int CALL set_apu_skin_temp_limit(ryzen_access ry, uint32_t value) {
EXP int CALL set_dgpu_skin_temp_limit(ryzen_access ry, uint32_t value) {
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x23, val]) */

value *= 256;
switch (ry->family)
{
Expand All @@ -1020,6 +1056,7 @@ EXP int CALL set_dgpu_skin_temp_limit(ryzen_access ry, uint32_t value) {
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x34);
break;
default:
Expand All @@ -1031,6 +1068,8 @@ EXP int CALL set_dgpu_skin_temp_limit(ryzen_access ry, uint32_t value) {
EXP int CALL set_apu_slow_limit(ryzen_access ry, uint32_t value) {
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x13, val]) */

switch (ry->family)
{
case FAM_RENOIR:
Expand All @@ -1041,6 +1080,7 @@ EXP int CALL set_apu_slow_limit(ryzen_access ry, uint32_t value) {
case FAM_REMBRANDT:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x23);
break;
default:
Expand All @@ -1052,6 +1092,8 @@ EXP int CALL set_apu_slow_limit(ryzen_access ry, uint32_t value) {
EXP int CALL set_skin_temp_power_limit(ryzen_access ry, uint32_t value) {
int err = ADJ_ERR_FAM_UNSUPPORTED;

/* \_SB.ALIB (0x0c, [size, 0x2e, val]) */

switch (ry->family)
{
case FAM_RENOIR:
Expand All @@ -1064,6 +1106,7 @@ EXP int CALL set_skin_temp_power_limit(ryzen_access ry, uint32_t value) {
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x4a);
break;
default:
Expand Down Expand Up @@ -1097,6 +1140,8 @@ EXP int CALL set_power_saving(ryzen_access ry) {
int err = ADJ_ERR_FAM_UNSUPPORTED;
uint32_t value = 0;

/* \_SB.ALIB (0x01, [size, 0x1]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -1112,6 +1157,7 @@ EXP int CALL set_power_saving(ryzen_access ry) {
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x12);
break;
default:
Expand All @@ -1124,6 +1170,8 @@ EXP int CALL set_max_performance(ryzen_access ry) {
int err = ADJ_ERR_FAM_UNSUPPORTED;
uint32_t value = 0;

/* \_SB.ALIB (0x01, [size, 0x0]) */

switch (ry->family)
{
case FAM_RAVEN:
Expand All @@ -1139,6 +1187,7 @@ EXP int CALL set_max_performance(ryzen_access ry) {
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
case FAM_STRIXPOINT:
_do_adjust(0x11);
break;
default:
Expand Down
16 changes: 14 additions & 2 deletions lib/nb_smu_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,26 @@ smu_t get_smu(nb_t nb, int smu_type) {
/* Fill SMU information */
switch(smu_type){
case TYPE_MP1:
if (family == FAM_REMBRANDT || family == FAM_VANGOGH || family == FAM_MENDOCINO || family == FAM_PHOENIX || family == FAM_HAWKPOINT) {
switch (family) {
case FAM_REMBRANDT:
case FAM_VANGOGH:
case FAM_MENDOCINO:
case FAM_PHOENIX:
case FAM_HAWKPOINT:
smu->msg = MP1_C2PMSG_MESSAGE_ADDR_2;
smu->rep = MP1_C2PMSG_RESPONSE_ADDR_2;
smu->arg_base = MP1_C2PMSG_ARG_BASE_2;
} else {
break;
case FAM_STRIXPOINT:
smu->msg = MP1_C2PMSG_MESSAGE_ADDR_3;
smu->rep = MP1_C2PMSG_RESPONSE_ADDR_3;
smu->arg_base = MP1_C2PMSG_ARG_BASE_3;
break;
default:
smu->msg = MP1_C2PMSG_MESSAGE_ADDR_1;
smu->rep = MP1_C2PMSG_RESPONSE_ADDR_1;
smu->arg_base = MP1_C2PMSG_ARG_BASE_1;
break;
}
break;
case TYPE_PSMU:
Expand Down
5 changes: 5 additions & 0 deletions lib/nb_smu_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ enum SMU_TYPE{
#define MP1_C2PMSG_RESPONSE_ADDR_2 0x3B10578
#define MP1_C2PMSG_ARG_BASE_2 0x3B10998

/* For Strix Point */
#define MP1_C2PMSG_MESSAGE_ADDR_3 0x3b10928
#define MP1_C2PMSG_RESPONSE_ADDR_3 0x3b10978
#define MP1_C2PMSG_ARG_BASE_3 0x3b10998

#define PSMU_C2PMSG_MESSAGE_ADDR 0x3B10a20
#define PSMU_C2PMSG_RESPONSE_ADDR 0x3B10a80
#define PSMU_C2PMSG_ARG_BASE 0x3B10a88
Expand Down

0 comments on commit b30c7f2

Please sign in to comment.