Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ INCLUDE += $(BOARD_DIR)/Makefile.mk
CFLAGS+=-I$(BOARD_DIR)/include -D__BOARD__=$(BOARD)
include $(BOARD_DIR)/Makefile.mk
SRC += $(foreach src, $(board-y), $(BOARD_DIR)/$(src))
SRC += $(foreach src, $(board-common-y), $(SYSTEM76_COMMON_DIR)/$(src))
SRC += $(foreach src, $(keyboard-y), $(KEYBOARD_DIR)/$(src))

# The board will define the embedded controller
Expand All @@ -60,6 +59,13 @@ CFLAGS+=-I$(ARCH_DIR)/include -D__ARCH__=$(ARCH)
include $(ARCH_DIR)/Makefile.mk
SRC += $(foreach src, $(arch-y), $(ARCH_DIR)/$(src))

# Add System76 EC app
APP_DIR = src/app/main
INCLUDE += $(APP_DIR)/Makefile.mk
CFLAGS += -I$(APP_DIR)/include
include $(APP_DIR)/Makefile.mk
SRC += $(foreach src,$(app-y),$(APP_DIR)/$(src))

include $(ARCH_DIR)/toolchain.mk

# TODO: Generate config file as part of build.
Expand Down
4 changes: 2 additions & 2 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ For details on configuring the Mega 2560 and breakout board, see
#### Setup

1. Enable parallel port debugging in the EC firmware
- Uncomment `PARALLEL_DEBUG` in `src/board/system76/common/Makefile.mk`
- Uncomment `PARALLEL_DEBUG` in `src/app/main/Makefile.mk`
- Build and flash the firmware for the target
2. Power off target
3. Remove bottom panel
Expand Down Expand Up @@ -112,7 +112,7 @@ Requirements:
- USB-C cable

1. Enable I2C debugging in the EC firmware for the target
- Uncomment `I2C_DEBUGGER` in `src/board/system76/common/Makefile.mk`
- Uncomment `I2C_DEBUGGER` in `src/app/main/Makefile.mk`
- Build and flash firmware
2. Connect Trinket M0 to host
- This will create an ACM device at `/dev/ttyACM*`
Expand Down
73 changes: 34 additions & 39 deletions src/board/system76/common/Makefile.mk → src/app/main/Makefile.mk
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# SPDX-License-Identifier: GPL-3.0-only

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
board-common-y += gctrl.c
board-common-y += kbc.c
board-common-y += kbscan.c
board-common-y += keymap.c
board-common-y += lid.c
board-common-y += main.c
board-common-y += parallel.c
board-common-y += pmc.c
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
board-common-y += wireless.c
app-y += acpi.c
app-y += battery.c
app-y += config.c
app-$(CONFIG_HAVE_DGPU) += dgpu.c
app-y += ecpm.c
app-$(CONFIG_BUS_ESPI) += espi.c
app-y += fan.c
app-y += gctrl.c
app-y += kbc.c
app-y += kbscan.c
app-y += keymap.c
app-y += lid.c
app-y += main.c
app-y += parallel.c
app-y += pmc.c
app-y += pnp.c
app-y += ps2.c
app-y += pwm.c
app-y += scratch.c
app-$(CONFIG_SECURITY) += security.c
app-y += smbus.c
app-y += smfi.c
app-y += stdio.c
app-y += wireless.c

# Set log level
# 0 - NONE
Expand All @@ -46,11 +46,11 @@ CFLAGS+=-DCONFIG_SECURITY=1
endif

ifeq ($(CONFIG_PLATFORM_INTEL),y)
board-common-y += peci.c
board-common-y += power/intel.c
app-y += peci.c
app-y += power/intel.c
CFLAGS += -DCONFIG_PLATFORM_INTEL=1
else ifeq ($(CONFIG_PLATFORM_AMD),y)
board-common-y += power/amd.c
app-y += power/amd.c
CFLAGS += -DCONFIG_PLATFORM_AMD=1
else
$(error PLATFORM not specified)
Expand All @@ -74,11 +74,6 @@ 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)/Makefile.mk
CFLAGS+=-I$(SYSTEM76_COMMON_DIR)/include

# Fan configs
ifneq ($(CONFIG_FAN1_PWM),)
CFLAGS += -DFAN1_PWM=$(CONFIG_FAN1_PWM)
Expand Down Expand Up @@ -106,7 +101,7 @@ CFLAGS+=\

# Add charger
ifneq ($(CONFIG_CHARGER),)
board-common-y += charger/$(CONFIG_CHARGER).c
app-y += charger/$(CONFIG_CHARGER).c
CFLAGS += -DCHARGER_ADAPTER_RSENSE=$(CONFIG_CHARGER_ADAPTER_RSENSE)
CFLAGS += -DCHARGER_BATTERY_RSENSE=$(CONFIG_CHARGER_BATTERY_RSENSE)
CFLAGS += -DCHARGER_CHARGE_CURRENT=$(CONFIG_CHARGER_CHARGE_CURRENT)
Expand All @@ -120,7 +115,7 @@ endif
# Add USB-PD
ifeq ($(CONFIG_HAVE_USBPD),y)
CFLAGS += -DCONFIG_HAVE_USBPD=1
board-common-$(CONFIG_USBPD_TPS65987) += usbpd/tps65987.c
app-$(CONFIG_USBPD_TPS65987) += usbpd/tps65987.c
CFLAGS += -DI2C_USBPD=$(CONFIG_I2C_USBPD)
endif

Expand All @@ -134,8 +129,8 @@ include $(KEYBOARD_DIR)/Makefile.mk
# Add kbled
ifeq ($(CONFIG_HAVE_KBLED),y)
CFLAGS += -DCONFIG_HAVE_KBLED=1
board-common-y += kbled/common.c
board-common-y += kbled/$(CONFIG_KBLED).c
app-y += kbled/common.c
app-y += kbled/$(CONFIG_KBLED).c
ifneq ($(CONFIG_KBLED_DAC),)
CFLAGS += -DKBLED_DAC=$(CONFIG_KBLED_DAC)
endif
Expand All @@ -152,11 +147,11 @@ endif # CONFIG_HAVE_KBLED
CFLAGS += -DPS2_TOUCHPAD=$(CONFIG_PS2_TOUCHPAD)

# Add scratch ROM
include $(SYSTEM76_COMMON_DIR)/scratch/Makefile.mk
include $(APP_DIR)/scratch/Makefile.mk

# Add scratch ROM for flash access
include $(SYSTEM76_COMMON_DIR)/flash/Makefile.mk
board-common-y += flash/wrapper.c
include $(APP_DIR)/flash/Makefile.mk
app-y += flash/wrapper.c

# Set external programmer
PROGRAMMER=$(wildcard /dev/serial/by-id/usb-Arduino*)
Expand Down
16 changes: 8 additions & 8 deletions src/board/system76/common/acpi.c → src/app/main/acpi.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/acpi.h>
#include <board/battery.h>
#include <board/dgpu.h>
#include <board/fan.h>
#include <app/acpi.h>
#include <app/battery.h>
#include <app/dgpu.h>
#include <app/fan.h>
#include <app/kbled.h>
#include <app/lid.h>
#include <app/pwm.h>
#include <board/gpio.h>
#include <board/kbled.h>
#include <board/lid.h>
#include <board/pwm.h>
#include <common/debug.h>
#include <common/macro.h>

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

#ifndef HAVE_LED_AIRPLANE_N
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/battery.h>
#include <board/flash.h>
#include <app/battery.h>
#include <app/flash.h>
#include <app/smbus.h>
#include <board/gpio.h>
#include <board/smbus.h>
#include <common/debug.h>

struct battery_info battery_info = { 0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// TI BQ24780S Smart Charger
// https://www.ti.com/lit/ds/symlink/bq24780s.pdf

#include <board/battery.h>
#include <board/smbus.h>
#include <app/battery.h>
#include <app/smbus.h>
#include <common/macro.h>
#include <common/debug.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// O2 Micro OZ26786
// No public datasheet

#include <board/battery.h>
#include <board/smbus.h>
#include <app/battery.h>
#include <app/smbus.h>
#include <common/debug.h>
#include <common/macro.h>

Expand Down
6 changes: 3 additions & 3 deletions src/board/system76/common/config.c → src/app/main/config.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/config.h>
#include <app/config.h>

#include <board/battery.h>
#include <board/kbscan.h>
#include <app/battery.h>
#include <app/kbscan.h>
#include <board/keymap.h>
#include <common/debug.h>

Expand Down
4 changes: 2 additions & 2 deletions src/board/system76/common/dgpu.c → src/app/main/dgpu.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/dgpu.h>
#include <app/dgpu.h>
#include <app/power.h>
#include <board/gpio.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/i2c.h>
Expand Down
2 changes: 1 addition & 1 deletion src/board/system76/common/ecpm.c → src/app/main/ecpm.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/ecpm.h>
#include <app/ecpm.h>
#include <common/macro.h>

void ecpm_init(void) {
Expand Down
4 changes: 2 additions & 2 deletions src/board/system76/common/espi.c → src/app/main/espi.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/espi.h>
#include <app/espi.h>

#include <app/power.h>
#include <arch/delay.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/ecpm.h>
Expand Down
8 changes: 4 additions & 4 deletions src/board/system76/common/fan.c → src/app/main/fan.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only

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

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

bool fan_max = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FLASH_INCLUDE=$(INCLUDE)
FLASH_CFLAGS=$(CFLAGS)

# Include flash source.
FLASH_DIR=$(SYSTEM76_COMMON_DIR)/flash
FLASH_DIR = $(APP_DIR)/flash
# Note: main.c *must* be first to ensure that flash_start is at the correct address
FLASH_INCLUDE += $(FLASH_DIR)/Makefile.mk
FLASH_CFLAGS+=-I$(FLASH_DIR)/include -D__FLASH__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#include <stdint.h>
#include <board/flash.h>
#include <app/flash.h>
#include <flash/entry.h>
#include <stdint.h>

// EC indirect flash access
volatile uint8_t __xdata __at(0x103B) ECINDAR0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#include <stdint.h>
#include <stddef.h>
#include <board/flash.h>
#include <app/flash.h>
#include <ec/scratch.h>
#include "include/flash/entry.h"
#include <stdint.h>
#include <stddef.h>

// Include flash ROM
uint8_t __code __at(FLASH_OFFSET) flash_rom[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/board/system76/common/gctrl.c → src/app/main/gctrl.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only

#include <board/gctrl.h>
#include <app/gctrl.h>

void gctrl_init(void) {
// Set I2EC as R/W
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only

#ifndef _BOARD_ACPI_H
#define _BOARD_ACPI_H
#ifndef _APP_ACPI_H
#define _APP_ACPI_H

#include <stdint.h>

Expand All @@ -19,4 +19,4 @@ void acpi_reset(void);
uint8_t acpi_read(uint8_t addr);
void acpi_write(uint8_t addr, uint8_t data);

#endif // _BOARD_ACPI_H
#endif // _APP_ACPI_H
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only

#ifndef _BOARD_BATTERY_H
#define _BOARD_BATTERY_H
#ifndef _APP_BATTERY_H
#define _APP_BATTERY_H

#include <common/macro.h>

Expand Down Expand Up @@ -56,4 +56,4 @@ int16_t battery_charger_enable(void);
void battery_charger_event(void);
void battery_debug(void);

#endif // _BOARD_BATTERY_H
#endif // _APP_BATTERY_H
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only

#ifndef _BOARD_BOARD_H
#define _BOARD_BOARD_H
#ifndef _APP_BOARD_H
#define _APP_BOARD_H

#include <stdbool.h>

void board_init(void);
void board_event(void);

#endif // _BOARD_BOARD_H
#endif // _APP_BOARD_H
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only

#ifndef _BOARD_CONFIG_H
#define _BOARD_CONFIG_H
#ifndef _APP_CONFIG_H
#define _APP_CONFIG_H

#include <stdbool.h>

bool config_should_reset(void);
void config_reset(void);

#endif // _BOARD_CONFIG_H
#endif // _APP_CONFIG_H
Loading