Skip to content

Commit 3d8204c

Browse files
committed
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 <tcrawford@system76.com>
1 parent 2c6977b commit 3d8204c

7 files changed

Lines changed: 41 additions & 6 deletions

File tree

src/board/system76/common/acpi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
#include <board/gpio.h>
88
#include <board/kbled.h>
99
#include <board/lid.h>
10-
#include <board/peci.h>
1110
#include <board/pwm.h>
1211
#include <common/debug.h>
1312
#include <common/macro.h>
1413

14+
#if CONFIG_PLATFORM_INTEL
15+
#include <board/peci.h>
16+
#endif
17+
1518
#ifndef HAVE_LED_AIRPLANE_N
1619
#define HAVE_LED_AIRPLANE_N 1
1720
#endif // HAVE_LED_AIRPLANE_N
@@ -113,7 +116,9 @@ uint8_t acpi_read(uint8_t addr) {
113116
}
114117
break;
115118

119+
#if CONFIG_PLATFORM_INTEL
116120
ACPI_8(0x07, peci_temp);
121+
#endif
117122

118123
// Handle AC adapter and battery present
119124
case 0x10:

src/board/system76/common/common.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ board-common-y += keymap.c
1414
board-common-y += lid.c
1515
board-common-y += main.c
1616
board-common-y += parallel.c
17-
board-common-y += peci.c
1817
board-common-y += pmc.c
1918
board-common-y += pnp.c
2019
board-common-y += ps2.c
@@ -42,8 +41,12 @@ CFLAGS+=-DLEVEL=4
4241
#CFLAGS+=-DI2C_DEBUGGER=0x76
4342

4443
ifeq ($(CONFIG_PLATFORM_INTEL),y)
44+
board-common-y += peci.c
4545
board-common-y += power/intel.c
4646
CFLAGS += -DCONFIG_PLATFORM_INTEL=1
47+
else ifeq ($(CONFIG_PLATFORM_AMD),y)
48+
board-common-y += power/amd.c
49+
CFLAGS += -DCONFIG_PLATFORM_AMD=1
4750
else
4851
$(error PLATFORM not specified)
4952
endif

src/board/system76/common/fan.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
#include <board/fan.h>
44
#include <board/dgpu.h>
5-
#include <board/peci.h>
65
#include <board/power.h>
76
#include <common/debug.h>
87
#include <common/macro.h>
98
#include <ec/pwm.h>
109

10+
#if CONFIG_PLATFORM_INTEL
11+
#include <board/peci.h>
12+
#endif
13+
1114
bool fan_max = false;
1215

1316
uint8_t fan1_pwm_actual = 0;
@@ -195,11 +198,16 @@ static uint16_t fan_get_tach1_rpm(void) {
195198
}
196199

197200
void fan_event(void) {
201+
#if CONFIG_PLATFORM_INTEL
198202
#if CONFIG_HAVE_DGPU
199203
int16_t sys_temp = MAX(peci_temp, dgpu_temp);
200204
#else
201205
int16_t sys_temp = peci_temp;
202206
#endif
207+
#elif CONFIG_PLATFORM_AMD
208+
// TODO: AMD SB-TSI temp
209+
int16_t sys_temp = 50;
210+
#endif
203211

204212
// Fan update interval is 100ms (main.c). The event changes PWM duty
205213
// by 1 every interval to give a smoothing effect.

src/board/system76/common/include/board/power.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ void power_init(void);
1717
void power_on(void);
1818
void power_off(void);
1919
void power_cpu_reset(void);
20-
2120
void power_event(void);
2221

2322
#endif // _BOARD_POWER_H

src/board/system76/common/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <board/kbscan.h>
1919
#include <board/keymap.h>
2020
#include <board/lid.h>
21-
#include <board/peci.h>
2221
#include <board/pmc.h>
2322
#include <board/power.h>
2423
#include <board/ps2.h>
@@ -31,6 +30,10 @@
3130
#include <common/version.h>
3231
#include <ec/ec.h>
3332

33+
#if CONFIG_PLATFORM_INTEL
34+
#include <board/peci.h>
35+
#endif
36+
3437
#ifdef PARALLEL_DEBUG
3538
#include <board/parallel.h>
3639
#endif // PARALLEL_DEBUG
@@ -73,7 +76,9 @@ void init(void) {
7376
kbscan_init();
7477
}
7578
keymap_init();
79+
#if CONFIG_PLATFORM_INTEL
7680
peci_init();
81+
#endif
7782
pmc_init();
7883
pwm_init();
7984
smbus_init();
@@ -140,7 +145,9 @@ void main(void) {
140145
if ((time - last_time_250ms) >= INTERVAL_250MS) {
141146
last_time_250ms = time;
142147

148+
#if CONFIG_PLATFORM_INTEL
143149
peci_read_temp();
150+
#endif
144151
dgpu_read_temp();
145152
}
146153

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
3+
#include <board/power.h>
4+
5+
enum PowerState power_state = POWER_STATE_OFF;
6+
7+
void update_power_state(void) {}
8+
void power_init(void) {}
9+
void power_on(void) {}
10+
void power_off(void) {}
11+
void power_cpu_reset(void) {}
12+
void power_event(void) {}

src/board/system76/common/power/intel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: GPL-3.0-only
22

3+
#include <board/power.h>
4+
35
#include <arch/delay.h>
46
#include <arch/time.h>
57
#include <board/acpi.h>
@@ -12,7 +14,6 @@
1214
#include <board/kbled.h>
1315
#include <board/lid.h>
1416
#include <board/peci.h>
15-
#include <board/power.h>
1617
#include <board/pmc.h>
1718
#include <board/pnp.h>
1819
#include <board/wireless.h>

0 commit comments

Comments
 (0)