From 938340d8f53a38b5b9196f5d4450c2d73052cc91 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Wed, 28 Aug 2024 12:30:32 -0600 Subject: [PATCH] Require Intel for PECI, add empty AMD power module PECI is an Intel-only mechanism for getting CPU temp. AMD will use SB-TSI to get temps. Add empty power functions for AMD so the project will compile with AMD selected. Signed-off-by: Tim Crawford --- src/board/system76/common/acpi.c | 7 ++++++- src/board/system76/common/common.mk | 7 +++++-- src/board/system76/common/fan.c | 10 +++++++++- src/board/system76/common/include/board/power.h | 1 - src/board/system76/common/main.c | 9 ++++++++- src/board/system76/common/power/amd.c | 12 ++++++++++++ src/board/system76/common/power/intel.c | 3 ++- 7 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/board/system76/common/power/amd.c diff --git a/src/board/system76/common/acpi.c b/src/board/system76/common/acpi.c index 8deb7afca..3b06c89c0 100644 --- a/src/board/system76/common/acpi.c +++ b/src/board/system76/common/acpi.c @@ -6,11 +6,14 @@ #include #include #include -#include #include #include #include +#if CONFIG_PLATFORM_INTEL +#include +#endif + #ifndef HAVE_LED_AIRPLANE_N #define HAVE_LED_AIRPLANE_N 1 #endif // HAVE_LED_AIRPLANE_N @@ -112,7 +115,9 @@ uint8_t acpi_read(uint8_t addr) { } break; +#if CONFIG_PLATFORM_INTEL ACPI_8(0x07, peci_temp); +#endif // Handle AC adapter and battery present case 0x10: diff --git a/src/board/system76/common/common.mk b/src/board/system76/common/common.mk index 30167a885..d22148d3b 100644 --- a/src/board/system76/common/common.mk +++ b/src/board/system76/common/common.mk @@ -14,7 +14,6 @@ board-common-y += keymap.c board-common-y += lid.c board-common-y += main.c board-common-y += parallel.c -board-common-y += peci.c board-common-y += pmc.c board-common-y += pnp.c board-common-y += ps2.c @@ -42,10 +41,14 @@ CFLAGS+=-DLEVEL=4 #CFLAGS+=-DI2C_DEBUGGER=0x76 ifeq ($(CONFIG_PLATFORM_INTEL),y) +board-common-y += peci.c board-common-y += power/intel.c CFLAGS += -DCONFIG_PLATFORM_INTEL=1 +else ifeq ($(CONFIG_PLATFORM_AMD),y) +board-common-y += power/amd.c +CFLAGS += -DCONFIG_PLATFORM_AMD=1 else -$(error PLATFORM not specified) +#$(error PLATFORM not specified) endif ifeq ($(CONFIG_SECURITY),y) diff --git a/src/board/system76/common/fan.c b/src/board/system76/common/fan.c index 7d9569dc0..b544f81e1 100644 --- a/src/board/system76/common/fan.c +++ b/src/board/system76/common/fan.c @@ -2,12 +2,15 @@ #include #include -#include #include #include #include #include +#if CONFIG_PLATFORM_INTEL +#include +#endif + bool fan_max = false; static uint8_t last_fan1_duty = 0; @@ -220,11 +223,16 @@ static uint8_t fan_get_duty(const struct Fan *const fan, int16_t temp) { } void fan_update_duty(void) { +#if CONFIG_PLATFORM_INTEL #if CONFIG_HAVE_DGPU int16_t sys_temp = MAX(peci_temp, dgpu_temp); #else int16_t sys_temp = peci_temp; #endif +#elif CONFIG_PLATFORM_AMD + // TODO: AMD SB-TSI temp + int16_t sys_temp = 50; +#endif uint8_t fan1_duty = fan_get_duty(&FAN1, sys_temp); #ifdef FAN2_PWM diff --git a/src/board/system76/common/include/board/power.h b/src/board/system76/common/include/board/power.h index ee372da94..bddfa47a6 100644 --- a/src/board/system76/common/include/board/power.h +++ b/src/board/system76/common/include/board/power.h @@ -17,7 +17,6 @@ void power_init(void); void power_on(void); void power_off(void); void power_cpu_reset(void); - void power_event(void); #endif // _BOARD_POWER_H diff --git a/src/board/system76/common/main.c b/src/board/system76/common/main.c index c5b0194ca..9bd4de6a4 100644 --- a/src/board/system76/common/main.c +++ b/src/board/system76/common/main.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -31,6 +30,10 @@ #include #include +#if CONFIG_PLATFORM_INTEL +#include +#endif + #ifdef PARALLEL_DEBUG #include #endif // PARALLEL_DEBUG @@ -73,7 +76,9 @@ void init(void) { kbscan_init(); } keymap_init(); +#if CONFIG_PLATFORM_INTEL peci_init(); +#endif pmc_init(); pwm_init(); smbus_init(); @@ -134,7 +139,9 @@ void main(void) { last_time_fan = time; // Read thermal data +#if CONFIG_PLATFORM_INTEL peci_read_temp(); +#endif dgpu_read_temp(); // Update fan speeds diff --git a/src/board/system76/common/power/amd.c b/src/board/system76/common/power/amd.c new file mode 100644 index 000000000..52e8c0cd3 --- /dev/null +++ b/src/board/system76/common/power/amd.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-3.0-only + +#include + +enum PowerState power_state = POWER_STATE_OFF; + +void update_power_state(void) {} +void power_init(void) {} +void power_on(void) {} +void power_off(void) {} +void power_cpu_reset(void) {} +void power_event(void) {} diff --git a/src/board/system76/common/power/intel.c b/src/board/system76/common/power/intel.c index 5be58ee94..b64a76021 100644 --- a/src/board/system76/common/power/intel.c +++ b/src/board/system76/common/power/intel.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only +#include + #include #include #include @@ -12,7 +14,6 @@ #include #include #include -#include #include #include #include