Add lemp13-b

This commit is contained in:
Jeremy Soller
2024-05-16 09:33:53 -06:00
parent 88c77aa1d3
commit b4768ed2dd
4 changed files with 382 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/battery.h>
#include <board/board.h>
#include <board/espi.h>
#include <board/gpio.h>
#include <ec/ec.h>
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);
}
void board_event(void) {
espi_event();
ec_read_post_codes();
}

View File

@ -0,0 +1,44 @@
# SPDX-License-Identifier: GPL-3.0-only
board-y += board.c
board-y += gpio.c
EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_256K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
CONFIG_PECI_OVER_ESPI = y
# Enable firmware security
CONFIG_SECURITY=y
# Include keyboard
KEYBOARD=14in_83
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2
# Set touchpad PS2 bus
CFLAGS+=-DPS2_TOUCHPAD=PS2_3
# Set smart charger parameters
CHARGER=oz26786
CFLAGS+=-DI2C_SMBUS=I2C_4
CFLAGS+=\
-DCHARGER_ADAPTER_RSENSE=5 \
-DCHARGER_BATTERY_RSENSE=10 \
-DCHARGER_CHARGE_CURRENT=1536 \
-DCHARGER_CHARGE_VOLTAGE=17600 \
-DCHARGER_INPUT_CURRENT=3420
# Set CPU power limits in watts
CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Add system76 common code
include src/board/system76/common/common.mk

View File

@ -0,0 +1,264 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(A, 4);
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 CPU_C10_GATE_N = GPIO(F, 7);
struct Gpio __code DD_ON = GPIO(E, 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 LED_ACIN = GPIO(H, 2);
struct Gpio __code LED_PWR = GPIO(D, 4);
struct Gpio __code LID_SW_N = GPIO(B, 1);
struct Gpio __code ME_WE = GPIO(D, 7);
struct Gpio __code PCH_PWROK_EC = GPIO(F, 3);
struct Gpio __code PD_EN = GPIO(D, 0); // renamed to PD_POWER_EN
struct Gpio __code PWR_BTN_N = GPIO(D, 5);
struct Gpio __code PWR_SW_N = GPIO(B, 3);
struct Gpio __code SLP_S0_N = GPIO(B, 5);
struct Gpio __code SUSB_N_PCH = GPIO(H, 0);
struct Gpio __code SUSC_N_PCH = GPIO(H, 1);
struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
void gpio_init(void) {
// Enable LPC reset on GPD2
GCR = 0b10 << 1;
// Disable PECI
GCR2 = 0;
// Disable UARTs
GCR6 = 0;
// PWRSW WDT 2 Enable 1
GCR8 = BIT(4);
// PWRSW WDT 2 Enable 2
GCR9 = BIT(5);
// PWRSW counter 12 seconds
GCR10 = BIT(1);
// Enable SMBus channel 4
GCR15 = BIT(4);
// Set GPB5 and GPD2 to 1.8V
GCR19 = BIT(7) | BIT(0);
// Set GPD3 to 1.8V, GPF2 and GPF3 to 3.3V
GCR20 = BIT(7);
// Set GPF7, GPH0, and GPH1 to 1.8V
GCR21 = BIT(5) | BIT(2) | BIT(1);
// Not documented
GCR22 = BIT(7);
// Set GPM6 power domain to VCC
GCR23 = BIT(0);
// Set GPIO data
GPDRA = 0;
// XLP_OUT
GPDRB = BIT(4);
GPDRC = 0;
// PWR_BTN#
GPDRD = BIT(5);
// USB_PWR_EN
GPDRE = BIT(3);
// H_PECI
GPDRF = BIT(6);
// H_PROCHOT_EC
GPDRG = BIT(6);
GPDRH = 0;
GPDRI = 0;
// KBC_MUTE#
GPDRJ = BIT(1);
GPDRM = 0;
// Set GPIO control
// EC_PWM_LEDKB_P
GPCRA0 = GPIO_OUT;
// KBC_BEEP
GPCRA1 = GPIO_IN;
// CPU_FAN
GPCRA2 = GPIO_ALT;
// WLAN_PWR_EN
GPCRA3 = GPIO_OUT;
// AC_PRESENT_EC
GPCRA4 = GPIO_OUT;
// EC_PWM_LEDKB_R
GPCRA5 = GPIO_ALT;
// EC_PWM_LEDKB_G
GPCRA6 = GPIO_ALT;
// TBTA_VBUS_2_EN#
GPCRA7 = GPIO_IN;
// AC_IN#
GPCRB0 = GPIO_IN | GPIO_UP;
// LID_SW#
GPCRB1 = GPIO_IN | GPIO_UP;
// PCIE_WAKE#
GPCRB2 = GPIO_IN;
// PWR_SW#
GPCRB3 = GPIO_IN;
// XLP_OUT
GPCRB4 = GPIO_OUT;
// SLP_S0#
GPCRB5 = GPIO_IN;
// SUSBC_EC#
GPCRB6 = GPIO_OUT;
// Does not exist
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMB_CLK_EC
GPCRC1 = GPIO_ALT | GPIO_UP;
// SMB_DATA_EC
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;
// TMRI1-TEST
GPCRC6 = GPIO_IN;
// BKL_EN
GPCRC7 = GPIO_OUT;
// PD_POWER_EN
GPCRD0 = GPIO_OUT;
// CCD_EN
GPCRD1 = GPIO_OUT;
// ESPI_RESET#
GPCRD2 = GPIO_ALT;
// SLP_A#
GPCRD3 = GPIO_IN;
// LED_PWR
GPCRD4 = GPIO_OUT;
// EC_PWR_BTN#
GPCRD5 = GPIO_OUT;
// CPU_FANSEN
GPCRD6 = GPIO_ALT | GPIO_DOWN;
// EC_ME_WE
GPCRD7 = GPIO_OUT;
// SMC_BAT
GPCRE0 = GPIO_ALT | GPIO_UP;
// GPE1_TEST
GPCRE1 = GPIO_IN;
// ACE_I2C_IRQ2Z
GPCRE2 = GPIO_IN;
// USB_PWR_EN
GPCRE3 = GPIO_OUT;
// DD_ON
GPCRE4 = GPIO_OUT;
// EC_RSMRST#
GPCRE5 = GPIO_OUT;
// JACK_IN#_EC
GPCRE6 = GPIO_IN;
// SMD_BAT
GPCRE7 = GPIO_ALT | GPIO_UP;
// 80CLK
GPCRF0 = GPIO_OUT;
// USB_CHARGE_EN
GPCRF1 = GPIO_OUT;
// 3IN1
GPCRF2 = GPIO_OUT;
// PCH_PWROK_EC
GPCRF3 = GPIO_OUT;
// TP_CLK
GPCRF4 = GPIO_ALT | GPIO_UP;
// TP_DATA
GPCRF5 = GPIO_ALT | GPIO_UP;
// H_PECI
GPCRF6 = GPIO_ALT;
// CPU_C10_GATE#
GPCRF7 = GPIO_IN;
// 10k pull-down
GPCRG0 = GPIO_IN;
// WLAN_EN
GPCRG1 = GPIO_IN;
// Pull up to VDD3
GPCRG2 = GPIO_IN;
// ALSPI_CE#
GPCRG3 = GPIO_ALT;
// ALSPI_MSI
GPCRG4 = GPIO_ALT;
// ALSPI_MSO
GPCRG5 = GPIO_ALT;
// H_PROCHOT_EC
GPCRG6 = GPIO_OUT;
// ALSPI_SCLK
GPCRG7 = GPIO_ALT;
// SUSB#_PCH
GPCRH0 = GPIO_IN;
// SUSC#_PCH
GPCRH1 = GPIO_IN;
// LED_ACIN
GPCRH2 = GPIO_OUT;
// 3G_EN
GPCRH3 = GPIO_OUT;
// 3G_PWR_EN
GPCRH4 = GPIO_OUT;
// TBTA_VBUS_1_EN#
GPCRH5 = GPIO_IN;
// Not connected
GPCRH6 = GPIO_IN;
// Not connected
GPCRH7 = GPIO_IN;
// BAT_DET
GPCRI0 = GPIO_ALT;
// BAT_VOLT
GPCRI1 = GPIO_ALT;
// RGBKB-DET#
GPCRI2 = GPIO_IN | GPIO_UP;
// THERM_VOLT_CPU_1
GPCRI3 = GPIO_ALT;
// TOTAL_CUR
GPCRI4 = GPIO_ALT;
// Not connected
GPCRI5 = GPIO_IN;
// THERM_VOLT_CPU_2
GPCRI6 = GPIO_ALT;
// MODEL_ID
GPCRI7 = GPIO_IN;
// SINK_CTRL_EC_1
GPCRJ0 = GPIO_IN;
// KBC_MUTE#
GPCRJ1 = GPIO_OUT;
// KBLIGHT_ADJ
GPCRJ2 = GPIO_ALT;
// SINK_CTRL_EC_2
GPCRJ3 = GPIO_IN;
// VA_EC_EN
GPCRJ4 = GPIO_OUT;
// VBATT_BOOST#
GPCRJ5 = GPIO_IN;
// EC_GPIO
GPCRJ6 = GPIO_OUT;
// LEDKB_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;
}

View File

@ -0,0 +1,49 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _BOARD_GPIO_H
#define _BOARD_GPIO_H
#include <ec/gpio.h>
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 CPU_C10_GATE_N;
extern struct Gpio __code DD_ON;
extern struct Gpio __code EC_EN;
extern struct Gpio __code EC_RSMRST_N;
#define HAVE_LAN_WAKEUP_N 0
extern struct Gpio __code LED_ACIN;
#define HAVE_LED_AIRPLANE_N 0
#define HAVE_LED_BAT_CHG 0
#define HAVE_LED_BAT_FULL 0
extern struct Gpio __code LED_PWR;
extern struct Gpio __code LID_SW_N;
extern struct Gpio __code ME_WE;
#define HAVE_PCH_DPWROK_EC 0
extern struct Gpio __code PCH_PWROK_EC;
#define HAVE_PD_EN 1
extern struct Gpio __code PD_EN;
#define HAVE_PM_PWROK 0
extern struct Gpio __code PWR_BTN_N;
extern struct Gpio __code PWR_SW_N;
extern struct Gpio __code SLP_S0_N;
#define HAVE_SLP_SUS_N 0
extern struct Gpio __code SUSB_N_PCH;
extern struct Gpio __code SUSC_N_PCH;
#define HAVE_SUSWARN_N 0
#define HAVE_SUS_PWR_ACK 0
extern struct Gpio __code VA_EC_EN;
#define HAVE_WLAN_EN 0
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H