diff --git a/src/board/system76/common/wireless.c b/src/board/system76/common/wireless.c index 8976313..c3755d0 100644 --- a/src/board/system76/common/wireless.c +++ b/src/board/system76/common/wireless.c @@ -17,6 +17,8 @@ * Set the WLAN card power state. */ void wireless_power(bool enable) { + MAYBE_UNUSED(enable); + #if HAVE_BT_EN gpio_set(&BT_EN, enable); #endif diff --git a/src/board/system76/oryp11/board.c b/src/board/system76/oryp11/board.c new file mode 100644 index 0000000..7951c28 --- /dev/null +++ b/src/board/system76/oryp11/board.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-3.0-only + +#include +#include +#include +#include +#include + +void board_init(void) { + espi_init(); + + // Make sure charger is in off state, also enables PSYS + battery_charger_disable(); + + // Allow backlight to be turned on + gpio_set(&BKL_EN, true); + // Enable camera + gpio_set(&CCD_EN, true); + // Enable USB port power + gpio_set(&USB_PWR_EN_N, false); +} + +void board_event(void) { + espi_event(); + + ec_read_post_codes(); +} diff --git a/src/board/system76/oryp11/board.mk b/src/board/system76/oryp11/board.mk new file mode 100644 index 0000000..6abcbd5 --- /dev/null +++ b/src/board/system76/oryp11/board.mk @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: GPL-3.0-only + +board-y += board.c +board-y += gpio.c + +EC=ite +CONFIG_EC_ITE_IT5570E=y + +# Enable eSPI +CONFIG_BUS_ESPI=y + +# Include keyboard +KEYBOARD=15in_102 + +# Set keyboard LED mechanism +KBLED=rgb_pwm + +# Set discrete GPU I2C bus +CFLAGS+=-DI2C_DGPU=I2C_1 + +# Set battery I2C bus +CFLAGS+=-DI2C_SMBUS=I2C_4 + +# Set touchpad PS2 bus +CFLAGS+=-DPS2_TOUCHPAD=PS2_3 + +# Set smart charger parameters +# TODO: actually bq24800 +# XXX: What is PRS3? +CFLAGS+=\ + -DCHARGER_ADAPTER_RSENSE=5 \ + -DCHARGER_BATTERY_RSENSE=10 \ + -DCHARGER_CHARGE_CURRENT=2048 \ + -DCHARGER_CHARGE_VOLTAGE=13050 \ + -DCHARGER_INPUT_CURRENT=14000 + +# Set CPU power limits in watts +CFLAGS+=\ + -DPOWER_LIMIT_AC=180 \ + -DPOWER_LIMIT_DC=28 + +# Disable syncing fan speeds +#CFLAGS+=-DSYNC_FANS=0 + +# Custom fan curve +CFLAGS+=-DBOARD_HEATUP=5 +CFLAGS+=-DBOARD_COOLDOWN=20 +CFLAGS+=-DBOARD_FAN_POINTS="\ + FAN_POINT(50, 40), \ + FAN_POINT(55, 40), \ + FAN_POINT(60, 55), \ + FAN_POINT(69, 55), \ + FAN_POINT(74, 68), \ + FAN_POINT(79, 68), \ + FAN_POINT(80, 72), \ + FAN_POINT(87, 100), \ +" + +# Enable DGPU support +CFLAGS+=-DHAVE_DGPU=1 +CFLAGS+=-DBOARD_DGPU_HEATUP=5 +CFLAGS+=-DBOARD_DGPU_COOLDOWN=20 +CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\ + FAN_POINT(50, 40), \ + FAN_POINT(56, 40), \ + FAN_POINT(72, 100), \ +" + +# Add system76 common code +include src/board/system76/common/common.mk diff --git a/src/board/system76/oryp11/gpio.c b/src/board/system76/oryp11/gpio.c new file mode 100644 index 0000000..0e4a22a --- /dev/null +++ b/src/board/system76/oryp11/gpio.c @@ -0,0 +1,263 @@ +// SPDX-License-Identifier: GPL-3.0-only + +#include +#include + +// clang-format off +struct Gpio __code ACIN_N = GPIO(B, 0); +struct Gpio __code AC_PRESENT = GPIO(E, 1); +struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0); +struct Gpio __code BKL_EN = GPIO(C, 7); +struct Gpio __code BUF_PLT_RST_N = GPIO(D, 2); // renamed to ESPI_RESET# +struct Gpio __code CCD_EN = GPIO(D, 1); +struct Gpio __code DD_ON = GPIO(E, 4); +struct Gpio __code DGPU_PWR_EN = GPIO(H, 4); +struct Gpio __code EC_EN = GPIO(B, 6); // renamed to SUSBC_EC# +struct Gpio __code EC_RSMRST_N = GPIO(E, 5); +struct Gpio __code GC6_FB_EN = GPIO(D, 3); +struct Gpio __code LAN_WAKEUP_N = GPIO(B, 2); +struct Gpio __code LED_ACIN = GPIO(H, 2); +struct Gpio __code LED_BAT_CHG = GPIO(H, 5); +struct Gpio __code LED_BAT_FULL = GPIO(J, 0); +struct Gpio __code LED_PWR = GPIO(D, 0); +struct Gpio __code LID_SW_N = GPIO(B, 1); +struct Gpio __code PCH_DPWROK_EC = GPIO(F, 3); +struct Gpio __code PCH_PWROK_EC = GPIO(C, 6); +struct Gpio __code PWR_BTN_N = GPIO(D, 5); +struct Gpio __code PWR_SW_N = GPIO(B, 3); +struct Gpio __code SLP_SUS_N = GPIO(H, 7); +struct Gpio __code SUSB_N_PCH = GPIO(H, 6); +struct Gpio __code SUSC_N_PCH = GPIO(H, 1); +struct Gpio __code SWI_N = GPIO(B, 5); +struct Gpio __code USB_PWR_EN_N = GPIO(E, 3); +struct Gpio __code VA_EC_EN = GPIO(J, 4); +struct Gpio __code XLP_OUT = GPIO(B, 4); +// clang-format on + +void gpio_init(void) { + // Not documented + //GCR22 = BIT(7); + // PWRSW WDT 2 Enable 2 + GCR9 = BIT(5); + // PWRSW WDT 2 Enable 1 + GCR8 = BIT(4); + // Enable LPC reset on GPD2 + GCR = 0b10 << 1; + // Disable UARTs + GCR6 = 0; + // Enable SMBus channel 4 + GCR15 = BIT(4); + // Set GPD2 to 1.8V + GCR19 = BIT(0); + // Set GPF2 and GPF3 to 3.3V + GCR20 = 0; + // Not documented + //GCR22 = BIT(7); + // Set GPM6 power domain to VCC + GCR23 = BIT(0); + + // Set GPIO data + GPDRA = 0; + // XLP_OUT, PWR_SW# + GPDRB = BIT(4) | BIT(3); + GPDRC = 0; + GPDRD = 0; + // USB_PWR_EN# + GPDRE = BIT(3); + // PCH_DPWROK_EC + GPDRF = BIT(3); + // H_PROCHOT_N_EC + GPDRG = BIT(6); + // LAN_PWR_EN + GPDRH = BIT(3); + // EC_AMP_EN + GPDRI = BIT(5); + // PLVDD_RST_EC, BL_PWM_EN_EC, KBC_MUTE# + GPDRJ = BIT(3) | BIT(2) | BIT(1); + + // Set GPIO control + // EC_PWM_LEDKB_P + GPCRA0 = GPIO_ALT; + // KBC_BEEP + GPCRA1 = GPIO_ALT; + // CPU_FAN_PWM + GPCRA2 = GPIO_ALT; + // DDS_EC_PWM (Not connected) + GPCRA3 = GPIO_IN | GPIO_UP; + // VGA_FAN_PWM1 + GPCRA4 = GPIO_ALT; + // EC_PWM_LEDKB_R + GPCRA5 = GPIO_ALT; + // EC_PWM_LEDKB_G + GPCRA6 = GPIO_ALT; + // EC_PWM_LEDKB_B + GPCRA7 = GPIO_ALT; + + // AC_IN# + GPCRB0 = GPIO_IN | GPIO_UP; + // LID_SW# + GPCRB1 = GPIO_IN | GPIO_UP; + // LAN_WAKEUP# + GPCRB2 = GPIO_IN | GPIO_UP; + // PWR_SW# + GPCRB3 = GPIO_IN; + // XLP_OUT + GPCRB4 = GPIO_OUT; + // SWI# + GPCRB5 = GPIO_OUT; + // SUSBC_EC# + GPCRB6 = GPIO_OUT | GPIO_UP; + // Not connected + GPCRB7 = GPIO_IN | GPIO_UP; + + // ALL_SYS_PWRGD + GPCRC0 = GPIO_IN; + // SMC_VGA_THERM + GPCRC1 = GPIO_ALT | GPIO_UP; + // SMD_VGA_THERM + GPCRC2 = GPIO_ALT | GPIO_UP; + // KB-SO16 + GPCRC3 = GPIO_ALT | GPIO_UP; + // CNVI_DET# + GPCRC4 = GPIO_IN | GPIO_UP; + // KB-SO17 + GPCRC5 = GPIO_ALT | GPIO_UP; + // PCH_PWROK_EC + GPCRC6 = GPIO_OUT; + // BKL_EN + GPCRC7 = GPIO_OUT | GPIO_UP; + + // LED_PWR + GPCRD0 = GPIO_OUT | GPIO_UP; + // CCD_EN + GPCRD1 = GPIO_OUT | GPIO_UP; + // ESPI_RESET# + GPCRD2 = GPIO_ALT; + // GC6_FB_EN_PCH + GPCRD3 = GPIO_IN; + // ACE_I2C_IRQ2Z_EC + GPCRD4 = GPIO_IN; + // PWR_BTN# + GPCRD5 = GPIO_OUT | GPIO_UP; + // CPU_FANSEN + GPCRD6 = GPIO_ALT; + // VGA_FANSEN + GPCRD7 = GPIO_ALT; + + // SMC_BAT + GPCRE0 = GPIO_ALT | GPIO_UP; + // AC_PRESENT + GPCRE1 = GPIO_OUT | GPIO_UP; + // RGBKB-DET# + GPCRE2 = GPIO_IN | GPIO_UP; + // USB_PWR_EN# + GPCRE3 = GPIO_OUT; + // DD_ON + GPCRE4 = GPIO_OUT | GPIO_DOWN; + // EC_RSMRST# + GPCRE5 = GPIO_OUT; + // JACK_IN#_EC + GPCRE6 = GPIO_IN; + // SMD_BAT + GPCRE7 = GPIO_ALT | GPIO_UP; + + // 80CLK + GPCRF0 = GPIO_IN; + // USB_CHARGE_EN + GPCRF1 = GPIO_OUT | GPIO_UP; + // 3IN1 + GPCRF2 = GPIO_IN | GPIO_UP; + // PCH_DPWROK_EC + GPCRF3 = GPIO_OUT; + // TP_CLK + GPCRF4 = GPIO_ALT; + // TP_DATA + GPCRF5 = GPIO_ALT; + // H_PECI + GPCRF6 = GPIO_ALT; + // SINK_CTRL + GPCRF7 = GPIO_IN; + + // Not connected + GPCRG0 = GPIO_IN | GPIO_UP; + // Not connected + GPCRG1 = GPIO_IN | GPIO_UP; + // AUTO_LOAD_PWR + GPCRG2 = GPIO_IN; + // ALSPI_CE# + GPCRG3 = GPIO_ALT; + // ALSPI_MSI + GPCRG4 = GPIO_ALT; + // ALSPI_MSO + GPCRG5 = GPIO_ALT; + // H_PROCHOT_N_EC + GPCRG6 = GPIO_OUT | GPIO_UP; + // ALSPI_SCLK + GPCRG7 = GPIO_ALT; + + // ME_WE + GPCRH0 = GPIO_OUT; + // SUSC#_PCH + GPCRH1 = GPIO_IN; + // LED_ACIN + GPCRH2 = GPIO_OUT | GPIO_UP; + // LAN_PWR_EN + GPCRH3 = GPIO_OUT; + // DGPU_PWR_EN + GPCRH4 = GPIO_IN; + // LED_BAT_CHG + GPCRH5 = GPIO_OUT | GPIO_UP; + // SUSB#_PCH + GPCRH6 = GPIO_IN; + // SLP_SUS# + GPCRH7 = GPIO_IN; + + // BAT_DET + GPCRI0 = GPIO_ALT; + // BAT_VOLT + GPCRI1 = GPIO_ALT; + // MUX_CTRL_BIOS + GPCRI2 = GPIO_OUT; + // THERM_VOLT_CPU + GPCRI3 = GPIO_ALT; + // TOTAL_CUR + GPCRI4 = GPIO_ALT; + // EC_AMP_EN + GPCRI5 = GPIO_OUT; + // PM_BATLOW# + GPCRI6 = GPIO_IN; + // MODEL_ID + GPCRI7 = GPIO_ALT; + + // LED_BAT_FULL + GPCRJ0 = GPIO_OUT | GPIO_UP; + // KBC_MUTE# / USB charger detection + GPCRJ1 = GPIO_OUT; + // BL_PWM_EN_EC + GPCRJ2 = GPIO_OUT; + // PLVDD_RST_EC + GPCRJ3 = GPIO_OUT; + // VA_EC_EN + GPCRJ4 = GPIO_OUT; + // VBATT_BOOST# + GPCRJ5 = GPIO_OUT; + // EC_GPIO + GPCRJ6 = GPIO_OUT | GPIO_UP; + // PERKB_DET# + GPCRJ7 = GPIO_IN | GPIO_UP; + + // ESPI_IO0_EC + GPCRM0 = GPIO_ALT | GPIO_UP | GPIO_DOWN; + // ESPI_IO1_EC + GPCRM1 = GPIO_ALT | GPIO_UP | GPIO_DOWN; + // ESPI_IO2_EC + GPCRM2 = GPIO_ALT | GPIO_UP | GPIO_DOWN; + // ESPI_IO3_EC + GPCRM3 = GPIO_ALT | GPIO_UP | GPIO_DOWN; + // ESPI_CLK_EC + GPCRM4 = GPIO_ALT | GPIO_UP | GPIO_DOWN; + // ESPI_CS_EC# + GPCRM5 = GPIO_ALT; + // ESPI_ALRT0# + GPCRM6 = GPIO_IN | GPIO_UP | GPIO_DOWN; +} diff --git a/src/board/system76/oryp11/include/board/gpio.h b/src/board/system76/oryp11/include/board/gpio.h new file mode 100644 index 0000000..b5ca8a5 --- /dev/null +++ b/src/board/system76/oryp11/include/board/gpio.h @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-3.0-only + +#ifndef _BOARD_GPIO_H +#define _BOARD_GPIO_H + +#include + +void gpio_init(void); + +// clang-format off +extern struct Gpio __code ACIN_N; +extern struct Gpio __code AC_PRESENT; +extern struct Gpio __code ALL_SYS_PWRGD; +extern struct Gpio __code BKL_EN; +#define HAVE_BT_EN 0 +extern struct Gpio __code BUF_PLT_RST_N; +extern struct Gpio __code CCD_EN; +extern struct Gpio __code DD_ON; +extern struct Gpio __code DGPU_PWR_EN; +extern struct Gpio __code EC_EN; +extern struct Gpio __code EC_RSMRST_N; +extern struct Gpio __code GC6_FB_EN; +extern struct Gpio __code LAN_WAKEUP_N; +extern struct Gpio __code LED_ACIN; +#define HAVE_LED_AIRPLANE_N 0 +extern struct Gpio __code LED_BAT_CHG; +extern struct Gpio __code LED_BAT_FULL; +extern struct Gpio __code LED_PWR; +extern struct Gpio __code LID_SW_N; +extern struct Gpio __code PCH_DPWROK_EC; +extern struct Gpio __code PCH_PWROK_EC; +#define HAVE_PM_PWROK 0 +extern struct Gpio __code PWR_BTN_N; +extern struct Gpio __code PWR_SW_N; +extern struct Gpio __code SLP_SUS_N; +#define HAVE_SUSWARN_N 0 +#define HAVE_SUS_PWR_ACK 0 +extern struct Gpio __code SUSB_N_PCH; +extern struct Gpio __code SUSC_N_PCH; +extern struct Gpio __code SWI_N; +extern struct Gpio __code USB_PWR_EN_N; +extern struct Gpio __code VA_EC_EN; +#define HAVE_WLAN_EN 0 +#define HAVE_WLAN_PWR_EN 0 +extern struct Gpio __code XLP_OUT; +// clang-format on + +#endif // _BOARD_GPIO_H diff --git a/src/common/include/common/macro.h b/src/common/include/common/macro.h index c96eb02..383ee0d 100644 --- a/src/common/include/common/macro.h +++ b/src/common/include/common/macro.h @@ -9,6 +9,8 @@ #define xstr(s) str(s) #define str(s) #s +#define MAYBE_UNUSED(x) ((void)(x)) + #define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) #define BIT(X) (1UL << (X))