Skip to content

Commit

Permalink
Require Intel for PECI, add empty AMD power module
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
crawfxrd committed Aug 28, 2024
1 parent fd56eff commit 938340d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/board/system76/common/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
#include <board/gpio.h>
#include <board/kbled.h>
#include <board/lid.h>
#include <board/peci.h>
#include <board/pwm.h>
#include <common/debug.h>
#include <common/macro.h>

#if CONFIG_PLATFORM_INTEL
#include <board/peci.h>
#endif

#ifndef HAVE_LED_AIRPLANE_N
#define HAVE_LED_AIRPLANE_N 1
#endif // HAVE_LED_AIRPLANE_N
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions src/board/system76/common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion src/board/system76/common/fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

#include <board/fan.h>
#include <board/dgpu.h>
#include <board/peci.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/pwm.h>

#if CONFIG_PLATFORM_INTEL
#include <board/peci.h>
#endif

bool fan_max = false;

static uint8_t last_fan1_duty = 0;
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/board/system76/common/include/board/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion src/board/system76/common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <board/kbscan.h>
#include <board/keymap.h>
#include <board/lid.h>
#include <board/peci.h>
#include <board/pmc.h>
#include <board/power.h>
#include <board/ps2.h>
Expand All @@ -31,6 +30,10 @@
#include <common/version.h>
#include <ec/ec.h>

#if CONFIG_PLATFORM_INTEL
#include <board/peci.h>
#endif

#ifdef PARALLEL_DEBUG
#include <board/parallel.h>
#endif // PARALLEL_DEBUG
Expand Down Expand Up @@ -73,7 +76,9 @@ void init(void) {
kbscan_init();
}
keymap_init();
#if CONFIG_PLATFORM_INTEL
peci_init();
#endif
pmc_init();
pwm_init();
smbus_init();
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/board/system76/common/power/amd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/power.h>

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) {}
3 changes: 2 additions & 1 deletion src/board/system76/common/power/intel.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/power.h>

#include <arch/delay.h>
#include <arch/time.h>
#include <board/acpi.h>
Expand All @@ -12,7 +14,6 @@
#include <board/kbled.h>
#include <board/lid.h>
#include <board/peci.h>
#include <board/power.h>
#include <board/pmc.h>
#include <board/pnp.h>
#include <board/wireless.h>
Expand Down

0 comments on commit 938340d

Please sign in to comment.