diff --git a/Makefile b/Makefile index e519c55c8..d98006c9a 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,12 @@ VERSION?=$(DATE)_$(REV) all: $(BUILD)/ec.rom $(info Built $(VERSION) for $(BOARD)) +CFLAGS = -Isrc/ + # Include common source COMMON_DIR=src/common INCLUDE += $(COMMON_DIR)/common.mk -CFLAGS=-I$(COMMON_DIR)/include -D__FIRMWARE_VERSION__=$(VERSION) +CFLAGS += -I$(COMMON_DIR)/include -D__FIRMWARE_VERSION__=$(VERSION) include $(COMMON_DIR)/common.mk SRC += $(foreach src, $(common-y), $(COMMON_DIR)/$(src)) @@ -51,6 +53,8 @@ CFLAGS+=-I$(EC_DIR)/include include $(EC_DIR)/ec.mk SRC += $(foreach src, $(ec-y), $(EC_DIR)/$(src)) +include src/drivers/Makefile.mk + # The EC will define the architecture # Include the architecture's source ARCH_DIR=src/arch/$(ARCH) diff --git a/docs/security.md b/docs/security.md index 7fb686b46..e5b0f73bb 100644 --- a/docs/security.md +++ b/docs/security.md @@ -1,13 +1,18 @@ # Firmware security The firmware security feature can be configured by setting `CONFIG_SECURITY=1` -in the `src/board/system76/[board]/board.mk` file. This feature prevents +in the `src/board/system76//board.mk` file. This feature prevents programming the EC firmware at runtime, unless the EC is unlocked with the `system76-ectool security unlock` command. After this, on the next reboot, the -EC will respond to the SPI and reset commands. On boards where the `ME_WE` GPIO -exists, it will be set high when the EC security state is unlocked. +EC will respond to the SPI and reset commands. + +This feature will drive the `ME_WE` pin high when the state is unlocked. On +Intel hosts, this pin is connected to `HDA_SDO` and will disable security +policies set in the flash descriptor. + +- `HDA_SDO`: Flash Descriptor Security Override Other firmware components can use this state to perform their own locking and -unlocking primitives. For example, in `coreboot`, flash regions may be locked -when the EC security state is locked. In `EDK2`, a physical presence dialog may -be shown when the EC security state is unlocked. +unlocking primitives. For example, in coreboot, flash regions may be locked +when the EC security state is locked. In the UEFI payload, a physical presence +dialog may be shown when the EC security state is unlocked. diff --git a/src/board/system76/addw1/board.mk b/src/board/system76/addw1/board.mk index 8a21e62f7..8e624bb8b 100644 --- a/src/board/system76/addw1/board.mk +++ b/src/board/system76/addw1/board.mk @@ -36,8 +36,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/addw2/board.mk b/src/board/system76/addw2/board.mk index 16e36aff9..c358c4b4a 100644 --- a/src/board/system76/addw2/board.mk +++ b/src/board/system76/addw2/board.mk @@ -36,8 +36,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/addw3/board.mk b/src/board/system76/addw3/board.mk index 3a5ebc075..2b111cdec 100644 --- a/src/board/system76/addw3/board.mk +++ b/src/board/system76/addw3/board.mk @@ -42,8 +42,8 @@ CONFIG_POWER_LIMIT_AC = 280 CONFIG_POWER_LIMIT_DC = 55 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/addw4/board.mk b/src/board/system76/addw4/board.mk index a0598509c..02b95eeef 100644 --- a/src/board/system76/addw4/board.mk +++ b/src/board/system76/addw4/board.mk @@ -38,8 +38,8 @@ CONFIG_POWER_LIMIT_AC = 230 CONFIG_POWER_LIMIT_DC = 45 # Enable DGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/bonw14/board.mk b/src/board/system76/bonw14/board.mk index 8e125e75a..675786fab 100644 --- a/src/board/system76/bonw14/board.mk +++ b/src/board/system76/bonw14/board.mk @@ -36,8 +36,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/bonw15-b/board.mk b/src/board/system76/bonw15-b/board.mk index ca7db4a35..747836973 100644 --- a/src/board/system76/bonw15-b/board.mk +++ b/src/board/system76/bonw15-b/board.mk @@ -40,17 +40,16 @@ CONFIG_CHARGER_CHARGE_VOLTAGE = 17400 CONFIG_CHARGER_INPUT_CURRENT = 16920 # Set USB-PD parameters -CONFIG_HAVE_USBPD = y -CONFIG_USBPD_TPS65987 = y -CONFIG_I2C_USBPD = I2C_1 +CONFIG_DRIVERS_USBPD_TPS65987 = y +CONFIG_USBPD_I2C = 1 # Set CPU power limits in watts CONFIG_POWER_LIMIT_AC = 330 CONFIG_POWER_LIMIT_DC = 55 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/bonw15/board.mk b/src/board/system76/bonw15/board.mk index f94289947..5f0b8233a 100644 --- a/src/board/system76/bonw15/board.mk +++ b/src/board/system76/bonw15/board.mk @@ -37,17 +37,16 @@ CONFIG_CHARGER_CHARGE_VOLTAGE = 17400 CONFIG_CHARGER_INPUT_CURRENT = 16920 # Set USB-PD parameters -CONFIG_HAVE_USBPD = y -CONFIG_USBPD_TPS65987 = y -CONFIG_I2C_USBPD = I2C_1 +CONFIG_DRIVERS_USBPD_TPS65987 = y +CONFIG_USBPD_I2C = 1 # Set CPU power limits in watts CONFIG_POWER_LIMIT_AC = 330 CONFIG_POWER_LIMIT_DC = 55 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/common/acpi.c b/src/board/system76/common/acpi.c index eac2f8046..7d0eada55 100644 --- a/src/board/system76/common/acpi.c +++ b/src/board/system76/common/acpi.c @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -10,6 +9,7 @@ #include #include #include +#include #if CONFIG_PLATFORM_INTEL #include diff --git a/src/board/system76/common/common.mk b/src/board/system76/common/common.mk index 4f304ad79..21315f989 100644 --- a/src/board/system76/common/common.mk +++ b/src/board/system76/common/common.mk @@ -3,7 +3,6 @@ board-common-y += acpi.c board-common-y += battery.c board-common-y += config.c -board-common-$(CONFIG_HAVE_DGPU) += dgpu.c board-common-y += ecpm.c board-common-$(CONFIG_BUS_ESPI) += espi.c board-common-y += fan.c @@ -19,7 +18,6 @@ board-common-y += pnp.c board-common-y += ps2.c board-common-y += pwm.c board-common-y += scratch.c -board-common-$(CONFIG_SECURITY) += security.c board-common-y += smbus.c board-common-y += smfi.c board-common-y += stdio.c @@ -41,10 +39,6 @@ CFLAGS += -DI2C_SMBUS=$(CONFIG_I2C_SMBUS) # Uncomment to enable I2C debug on 0x76 #CFLAGS+=-DI2C_DEBUGGER=0x76 -ifeq ($(CONFIG_SECURITY),y) -CFLAGS+=-DCONFIG_SECURITY=1 -endif - ifeq ($(CONFIG_PLATFORM_INTEL),y) board-common-y += peci.c board-common-y += power/intel.c @@ -69,11 +63,6 @@ CFLAGS += -DCONFIG_PECI_OVER_ESPI=1 endif endif -ifeq ($(CONFIG_HAVE_DGPU),y) -CFLAGS += -DCONFIG_HAVE_DGPU=1 -CFLAGS += -DI2C_DGPU=$(CONFIG_I2C_DGPU) -endif - # Include system76 common source SYSTEM76_COMMON_DIR=src/board/system76/common INCLUDE += $(SYSTEM76_COMMON_DIR)/common.mk @@ -117,13 +106,6 @@ CFLAGS += -DCHARGER_PSYS_GAIN=$(CONFIG_CHARGER_PSYS_GAIN) endif endif -# Add USB-PD -ifeq ($(CONFIG_HAVE_USBPD),y) -CFLAGS += -DCONFIG_HAVE_USBPD=1 -board-common-$(CONFIG_USBPD_TPS65987) += usbpd/tps65987.c -CFLAGS += -DI2C_USBPD=$(CONFIG_I2C_USBPD) -endif - # Add keyboard ifndef KEYBOARD $(error KEYBOARD is not set by the board) diff --git a/src/board/system76/common/fan.c b/src/board/system76/common/fan.c index 15f005ae4..87a77fc6e 100644 --- a/src/board/system76/common/fan.c +++ b/src/board/system76/common/fan.c @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-3.0-only #include -#include #include #include #include +#include #include #if CONFIG_PLATFORM_INTEL diff --git a/src/board/system76/common/include/board/security.h b/src/board/system76/common/include/board/security.h deleted file mode 100644 index aecca0777..000000000 --- a/src/board/system76/common/include/board/security.h +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only - -#ifndef _BOARD_SECURITY_H -#define _BOARD_SECURITY_H - -#include -#include - -enum SecurityState security_get(void); -bool security_set(enum SecurityState state); -bool security_power(void); - -#endif // _BOARD_SECURITY_H diff --git a/src/board/system76/common/kbled/bonw14.c b/src/board/system76/common/kbled/bonw14.c index a881ee846..057d6ebfe 100644 --- a/src/board/system76/common/kbled/bonw14.c +++ b/src/board/system76/common/kbled/bonw14.c @@ -9,7 +9,7 @@ void kbled_init(void) { kbled_kind = KBLED_RGB; - i2c_reset(&I2C_DGPU, true); + i2c_reset(&DGPU_I2C, true); // Force SMBUS B design to 100kHZ SCLKTSB = 0b10; @@ -17,11 +17,11 @@ void kbled_init(void) { void kbled_reset(void) { uint8_t value = 0xE4; - int16_t res = i2c_set(&I2C_DGPU, 0x2D, 0xA0, &value, 1); + int16_t res = i2c_set(&DGPU_I2C, 0x2D, 0xA0, &value, 1); DEBUG("kbled_reset 0x2D: %d\n", res); //value = 0xC4; - //res = i2c_set(&I2C_DGPU, 0x66, 0xA0, &value, 1); + //res = i2c_set(&DGPU_I2C, 0x66, 0xA0, &value, 1); //DEBUG("kbled_reset 0x66: %d\n", res); // Set brightness and color diff --git a/src/board/system76/common/main.c b/src/board/system76/common/main.c index 4d79566ce..76fdce1bc 100644 --- a/src/board/system76/common/main.c +++ b/src/board/system76/common/main.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -24,10 +23,11 @@ #include #include #include -#include #include #include #include +#include +#include #include #if CONFIG_PLATFORM_INTEL diff --git a/src/board/system76/common/power/intel.c b/src/board/system76/common/power/intel.c index 9e3dd4846..e14962013 100644 --- a/src/board/system76/common/power/intel.c +++ b/src/board/system76/common/power/intel.c @@ -17,8 +17,8 @@ #include #include #include -#include #include +#include #if CONFIG_BUS_ESPI #include @@ -26,7 +26,7 @@ #endif #if CONFIG_SECURITY -#include +#include #endif // CONFIG_SECURITY #define GPIO_SET_DEBUG(G, V) \ diff --git a/src/board/system76/common/scratch.c b/src/board/system76/common/scratch.c index e7e9ed023..b8fbf9877 100644 --- a/src/board/system76/common/scratch.c +++ b/src/board/system76/common/scratch.c @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only -#include #include #include #include +#include #include #include diff --git a/src/board/system76/common/smfi.c b/src/board/system76/common/smfi.c index c2ece637f..9ca1dfd85 100644 --- a/src/board/system76/common/smfi.c +++ b/src/board/system76/common/smfi.c @@ -22,7 +22,7 @@ #include #if CONFIG_SECURITY -#include +#include #endif // CONFIG_SECURITY #endif // !defined(__SCRATCH__) diff --git a/src/board/system76/galp5/board.mk b/src/board/system76/galp5/board.mk index 4eaeecdde..72c58ac3c 100644 --- a/src/board/system76/galp5/board.mk +++ b/src/board/system76/galp5/board.mk @@ -39,8 +39,8 @@ CONFIG_POWER_LIMIT_AC = 65 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze15/board.mk b/src/board/system76/gaze15/board.mk index 4c754612a..86440caeb 100644 --- a/src/board/system76/gaze15/board.mk +++ b/src/board/system76/gaze15/board.mk @@ -36,8 +36,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze16-3050/board.mk b/src/board/system76/gaze16-3050/board.mk index 339cc75d0..0b1cd8035 100644 --- a/src/board/system76/gaze16-3050/board.mk +++ b/src/board/system76/gaze16-3050/board.mk @@ -38,8 +38,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze16-3060-b/board.mk b/src/board/system76/gaze16-3060-b/board.mk index 5e235b89d..88d54f3f0 100644 --- a/src/board/system76/gaze16-3060-b/board.mk +++ b/src/board/system76/gaze16-3060-b/board.mk @@ -41,8 +41,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze16-3060/board.mk b/src/board/system76/gaze16-3060/board.mk index 4aaf8a7a2..31cbaaa97 100644 --- a/src/board/system76/gaze16-3060/board.mk +++ b/src/board/system76/gaze16-3060/board.mk @@ -38,8 +38,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze17-3050/board.mk b/src/board/system76/gaze17-3050/board.mk index 6efb09733..4dc4818fc 100644 --- a/src/board/system76/gaze17-3050/board.mk +++ b/src/board/system76/gaze17-3050/board.mk @@ -39,8 +39,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze17-3060-b/board.mk b/src/board/system76/gaze17-3060-b/board.mk index ec1a2a7d3..74490b2ea 100644 --- a/src/board/system76/gaze17-3060-b/board.mk +++ b/src/board/system76/gaze17-3060-b/board.mk @@ -42,8 +42,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze17-3060/board.mk b/src/board/system76/gaze17-3060/board.mk index 73dafced1..097abaa08 100644 --- a/src/board/system76/gaze17-3060/board.mk +++ b/src/board/system76/gaze17-3060/board.mk @@ -39,8 +39,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze18/board.mk b/src/board/system76/gaze18/board.mk index 575e0c36f..69339f84b 100644 --- a/src/board/system76/gaze18/board.mk +++ b/src/board/system76/gaze18/board.mk @@ -41,8 +41,8 @@ CONFIG_POWER_LIMIT_AC = 150 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/gaze20/board.mk b/src/board/system76/gaze20/board.mk index edbfaa336..4a33d04fa 100644 --- a/src/board/system76/gaze20/board.mk +++ b/src/board/system76/gaze20/board.mk @@ -37,8 +37,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable DGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp10/board.mk b/src/board/system76/oryp10/board.mk index e3e8f9052..670981837 100644 --- a/src/board/system76/oryp10/board.mk +++ b/src/board/system76/oryp10/board.mk @@ -45,8 +45,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp11/board.mk b/src/board/system76/oryp11/board.mk index bd6b5ee91..91ced8f58 100644 --- a/src/board/system76/oryp11/board.mk +++ b/src/board/system76/oryp11/board.mk @@ -38,17 +38,16 @@ CONFIG_CHARGER_CHARGE_VOLTAGE = 17600 CONFIG_CHARGER_INPUT_CURRENT = 11500 # Set USB-PD parameters -CONFIG_HAVE_USBPD = y -CONFIG_USBPD_TPS65987 = y -CONFIG_I2C_USBPD = I2C_1 +CONFIG_DRIVERS_USBPD_TPS65987 = y +CONFIG_USBPD_I2C = 1 # Set CPU power limits in watts CONFIG_POWER_LIMIT_AC = 230 CONFIG_POWER_LIMIT_DC = 55 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp12/board.mk b/src/board/system76/oryp12/board.mk index 90303b5ab..1292c35c8 100644 --- a/src/board/system76/oryp12/board.mk +++ b/src/board/system76/oryp12/board.mk @@ -35,17 +35,16 @@ CONFIG_CHARGER_CHARGE_VOLTAGE = 17600 CONFIG_CHARGER_INPUT_CURRENT = 11500 # Set USB-PD parameters -CONFIG_HAVE_USBPD = y -CONFIG_USBPD_TPS65987 = y -CONFIG_I2C_USBPD = I2C_1 +CONFIG_DRIVERS_USBPD_TPS65987 = y +CONFIG_USBPD_I2C = 1 # Set CPU power limits in watts CONFIG_POWER_LIMIT_AC = 230 CONFIG_POWER_LIMIT_DC = 55 # Enable DGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp5/board.mk b/src/board/system76/oryp5/board.mk index 8a1800aaa..8216320d2 100644 --- a/src/board/system76/oryp5/board.mk +++ b/src/board/system76/oryp5/board.mk @@ -38,8 +38,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp6/board.mk b/src/board/system76/oryp6/board.mk index 55812a2e1..4539f34d3 100644 --- a/src/board/system76/oryp6/board.mk +++ b/src/board/system76/oryp6/board.mk @@ -36,8 +36,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp7/board.mk b/src/board/system76/oryp7/board.mk index 55812a2e1..4539f34d3 100644 --- a/src/board/system76/oryp7/board.mk +++ b/src/board/system76/oryp7/board.mk @@ -36,8 +36,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp8/board.mk b/src/board/system76/oryp8/board.mk index d51060147..007e80f85 100644 --- a/src/board/system76/oryp8/board.mk +++ b/src/board/system76/oryp8/board.mk @@ -37,8 +37,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/oryp9/board.mk b/src/board/system76/oryp9/board.mk index 31e7a2e43..2f086fbd4 100644 --- a/src/board/system76/oryp9/board.mk +++ b/src/board/system76/oryp9/board.mk @@ -42,8 +42,8 @@ CONFIG_POWER_LIMIT_AC = 180 CONFIG_POWER_LIMIT_DC = 45 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/board/system76/serw13/board.mk b/src/board/system76/serw13/board.mk index ddd6632c8..fc019c78b 100644 --- a/src/board/system76/serw13/board.mk +++ b/src/board/system76/serw13/board.mk @@ -37,17 +37,16 @@ CONFIG_CHARGER_CHARGE_VOLTAGE = 13050 CONFIG_CHARGER_INPUT_CURRENT = 14000 # Set USB-PD parameters -CONFIG_HAVE_USBPD = y -CONFIG_USBPD_TPS65987 = y -CONFIG_I2C_USBPD = I2C_1 +CONFIG_DRIVERS_USBPD_TPS65987 = y +CONFIG_USBPD_I2C = 1 # Set CPU power limits in watts CONFIG_POWER_LIMIT_AC = 280 CONFIG_POWER_LIMIT_DC = 55 # Enable dGPU support -CONFIG_HAVE_DGPU = y -CONFIG_I2C_DGPU = I2C_1 +CONFIG_DRIVERS_DGPU_NVIDIA = y +CONFIG_DGPU_I2C = 1 # Fan configs CONFIG_FAN1_PWM = DCR2 diff --git a/src/common/include/common/command.h b/src/common/include/common/command.h index 0e17e51f4..ecec85bd0 100644 --- a/src/common/include/common/command.h +++ b/src/common/include/common/command.h @@ -77,15 +77,4 @@ enum CommandSpiFlag { #define CMD_LED_INDEX_ALL 0xFF -enum SecurityState { - // Default value, flashing is prevented, cannot be set with CMD_SECURITY_SET - SECURITY_STATE_LOCK = 0, - // Flashing is allowed, cannot be set with CMD_SECURITY_SET - SECURITY_STATE_UNLOCK = 1, - // Flashing will be prevented on the next reboot - SECURITY_STATE_PREPARE_LOCK = 2, - // Flashing will be allowed on the next reboot - SECURITY_STATE_PREPARE_UNLOCK = 3, -}; - #endif // _COMMON_COMMAND_H diff --git a/src/drivers/Makefile.mk b/src/drivers/Makefile.mk new file mode 100644 index 000000000..69e733b1e --- /dev/null +++ b/src/drivers/Makefile.mk @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2025 System76, Inc. + +subdirs-y := $(wildcard src/drivers/*) + +$(foreach subdir,$(subdirs-y), \ + $(if $(wildcard $(subdir)/Makefile.mk), \ + $(eval drivers-y:=) \ + $(eval include $(subdir)/Makefile.mk) \ + $(eval INCLUDE+=$(subdir)/Makefile.mk) \ + $(foreach src,$(drivers-y), \ + $(eval SRC+=$(addprefix $(subdir)/,$(src)))))) diff --git a/src/drivers/dgpu/Makefile.mk b/src/drivers/dgpu/Makefile.mk new file mode 100644 index 000000000..2fa7e0057 --- /dev/null +++ b/src/drivers/dgpu/Makefile.mk @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2025 System76, Inc. + +# Discrete GPU (dGPU) support. +# +# Requires: +# - Board must declare the I2C device index to use. + +ifeq ($(CONFIG_DRIVERS_DGPU_NVIDIA),y) +CONFIG_HAVE_DGPU = y +endif + +ifeq ($(CONFIG_HAVE_DGPU),y) + +CFLAGS += -DCONFIG_HAVE_DGPU=1 +CFLAGS += -DDGPU_I2C=I2C_$(CONFIG_DGPU_I2C) + +drivers-$(CONFIG_DRIVERS_DGPU_NVIDIA) += nvidia.c + +endif diff --git a/src/board/system76/common/include/board/dgpu.h b/src/drivers/dgpu/dgpu.h similarity index 85% rename from src/board/system76/common/include/board/dgpu.h rename to src/drivers/dgpu/dgpu.h index cffa2fb50..e1cd28a09 100644 --- a/src/board/system76/common/include/board/dgpu.h +++ b/src/drivers/dgpu/dgpu.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only -#ifndef _BOARD_DGPU_H -#define _BOARD_DGPU_H +#ifndef _DRIVERS_DGPU_H +#define _DRIVERS_DGPU_H #include #include @@ -27,4 +27,4 @@ static inline void dgpu_read_temp(void) {} #endif // CONFIG_HAVE_DGPU -#endif // _BOARD_DGPU_H +#endif // _DRIVERS_DGPU_H diff --git a/src/board/system76/common/dgpu.c b/src/drivers/dgpu/nvidia.c similarity index 90% rename from src/board/system76/common/dgpu.c rename to src/drivers/dgpu/nvidia.c index 8260534c3..0bdd67cff 100644 --- a/src/board/system76/common/dgpu.c +++ b/src/drivers/dgpu/nvidia.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only -#include +#include "dgpu.h" #include #include #include @@ -14,13 +14,13 @@ static int16_t dgpu_temps[4] = { 0 }; void dgpu_init(void) { // Set up for i2c usage - i2c_reset(&I2C_DGPU, true); + i2c_reset(&DGPU_I2C, true); } bool dgpu_get_temp(int16_t *const data) { if (gpio_get(&DGPU_PWR_EN) && !gpio_get(&GC6_FB_EN)) { int8_t rlts; - int16_t res = i2c_get(&I2C_DGPU, 0x4F, 0x00, &rlts, 1); + int16_t res = i2c_get(&DGPU_I2C, 0x4F, 0x00, &rlts, 1); if (res == 1) { *data = (int16_t)rlts; return true; diff --git a/src/drivers/security/Makefile.mk b/src/drivers/security/Makefile.mk new file mode 100644 index 000000000..d019dc640 --- /dev/null +++ b/src/drivers/security/Makefile.mk @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2025 System76, Inc. + +# Firmware security state feature. +# +# Requires: +# - Board must declare the `ME_WE` pin. +# +# External integrations: +# - system76/coreboot: `ec/system76/ec` config `EC_SYSTEM76_EC_LOCKDOWN`. +# - system76/firmware-setup: UEFI protocol for physical presence prompt. + +ifeq ($(CONFIG_SECURITY),y) + +CFLAGS += -DCONFIG_SECURITY=1 + +drivers-y += security.c + +endif diff --git a/src/board/system76/common/security.c b/src/drivers/security/security.c similarity index 97% rename from src/board/system76/common/security.c rename to src/drivers/security/security.c index f81198c90..011d88f97 100644 --- a/src/board/system76/common/security.c +++ b/src/drivers/security/security.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only +#include "security.h" #include -#include static enum SecurityState security_state = SECURITY_STATE_LOCK; diff --git a/src/drivers/security/security.h b/src/drivers/security/security.h new file mode 100644 index 000000000..3583f813a --- /dev/null +++ b/src/drivers/security/security.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-3.0-only + +#ifndef _DRIVERS_SECURITY_H +#define _DRIVERS_SECURITY_H + +#include + +enum SecurityState { + // Default value, flashing is prevented, cannot be set with CMD_SECURITY_SET + SECURITY_STATE_LOCK = 0, + // Flashing is allowed, cannot be set with CMD_SECURITY_SET + SECURITY_STATE_UNLOCK = 1, + // Flashing will be prevented on the next reboot + SECURITY_STATE_PREPARE_LOCK = 2, + // Flashing will be allowed on the next reboot + SECURITY_STATE_PREPARE_UNLOCK = 3, +}; + +enum SecurityState security_get(void); +bool security_set(enum SecurityState state); +bool security_power(void); + +#endif // _DRIVERS_SECURITY_H diff --git a/src/drivers/usbpd/Makefile.mk b/src/drivers/usbpd/Makefile.mk new file mode 100644 index 000000000..20963a826 --- /dev/null +++ b/src/drivers/usbpd/Makefile.mk @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2025 System76, Inc. + +# USB Power Delivery (USB-PD) support. +# +# Requires: +# - Board must declare the I2C device index to use. + +ifeq ($(CONFIG_DRIVERS_USBPD_TPS65987),y) +CONFIG_HAVE_USBPD = y +endif + +ifeq ($(CONFIG_HAVE_USBPD),y) + +CFLAGS += -DCONFIG_HAVE_USBPD=1 +CFLAGS += -DUSBPD_I2C=I2C_$(CONFIG_USBPD_I2C) + +drivers-$(CONFIG_DRIVERS_USBPD_TPS65987) += tps65987.c + +endif diff --git a/src/board/system76/common/usbpd/tps65987.c b/src/drivers/usbpd/tps65987.c similarity index 93% rename from src/board/system76/common/usbpd/tps65987.c rename to src/drivers/usbpd/tps65987.c index 487d1544e..6a9152690 100644 --- a/src/board/system76/common/usbpd/tps65987.c +++ b/src/drivers/usbpd/tps65987.c @@ -3,10 +3,10 @@ // USB-PD driver for TPS65987 and the mostly compatible TPS65993 and TPS65994. // I2C register reference: https://www.ti.com/lit/ug/slvubh2b/slvubh2b.pdf +#include "usbpd.h" #include #include #include -#include #include #include @@ -15,12 +15,12 @@ #define REG_ACTIVE_CONTRACT_PDO 0x34 void usbpd_init(void) { - i2c_reset(&I2C_USBPD, true); + i2c_reset(&USBPD_I2C, true); } static int16_t usbpd_current_limit(void) { uint8_t value[7] = { 0 }; - int16_t res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, REG_ACTIVE_CONTRACT_PDO, value, sizeof(value)); + int16_t res = i2c_get(&USBPD_I2C, USBPD_ADDRESS, REG_ACTIVE_CONTRACT_PDO, value, sizeof(value)); if (res == 7) { if (value[0] == 6) { uint32_t pdo = ((uint32_t)value[1]) | (((uint32_t)value[2]) << 8) | @@ -72,7 +72,7 @@ static void usbpd_dump(void) { // Dump all registers for debugging for (uint8_t reg = 0x00; reg < 0x40; reg += 1) { uint8_t value[65] = { 0 }; - int16_t res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, reg, value, sizeof(value)); + int16_t res = i2c_get(&USBPD_I2C, USBPD_ADDRESS, reg, value, sizeof(value)); if (res < 0) { DEBUG("USBPD %02X ERROR %04X\n", reg, res); } else { @@ -168,7 +168,7 @@ static int16_t usbpd_aneg(void) { int16_t res; uint8_t cmd[5] = { 4, 'A', 'N', 'e', 'g' }; - res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, 0x08, cmd, sizeof(cmd)); + res = i2c_set(&USBPD_I2C, USBPD_ADDRESS, 0x08, cmd, sizeof(cmd)); if (res < 0) { return res; } @@ -185,7 +185,7 @@ void usbpd_disable_charging(void) { // Read current value uint8_t value[2] = { 0 }; - res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_get(&USBPD_I2C, USBPD_ADDRESS, 0x33, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; @@ -200,7 +200,7 @@ void usbpd_disable_charging(void) { // Enable only the first TX sink PDO (5V) value[0] = 1; value[1] = 1; - res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_set(&USBPD_I2C, USBPD_ADDRESS, 0x33, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; @@ -223,7 +223,7 @@ void usbpd_enable_charging(void) { // Read current value uint8_t value[2] = { 0 }; - res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_get(&USBPD_I2C, USBPD_ADDRESS, 0x33, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; @@ -238,7 +238,7 @@ void usbpd_enable_charging(void) { // Enable the first two TX sink PDO (5V and 20V) value[0] = 1; value[1] = 2; - res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_set(&USBPD_I2C, USBPD_ADDRESS, 0x33, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; diff --git a/src/board/system76/common/include/board/usbpd.h b/src/drivers/usbpd/usbpd.h similarity index 83% rename from src/board/system76/common/include/board/usbpd.h rename to src/drivers/usbpd/usbpd.h index 2b38e84a8..15c2e5643 100644 --- a/src/board/system76/common/include/board/usbpd.h +++ b/src/drivers/usbpd/usbpd.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only -#ifndef _BOARD_USBPD_H -#define _BOARD_USBPD_H +#ifndef _DRIVERS_USBPD_H +#define _DRIVERS_USBPD_H #if CONFIG_HAVE_USBPD @@ -19,4 +19,4 @@ static inline void usbpd_enable_charging(void) {} #endif -#endif // _BOARD_USBPD_H +#endif // _DRIVERS_USBPD_H