Addw2 support (#67)

* Add addw2 board

* Set charge params and update gpio.h

* Set VGA fan to 100% when entering scratch rom

* Implement keyboard LEDs

* Turn off keyboard LEDs in gpio defaults

* Default airplane mode LED to off

* Enable GPU power and fan control

* Add NVIDIA GPU power and temp to power.csv

* Add NVIDIA GPU fan value to power.sh

* Move GPU init back to coreboot

* Do not turn on GPU fan if GPU is off

* Show POST codes

* Add timestamps to console_external

* Accept port 81 cycles

* Move setting RSTS into ec_init

* Move post code debugging to system76/common

* Move some GPIO init from system76/common to boards

* Make some power signals optional

* Remove POST code support - it only works on IT5570
This commit is contained in:
Jeremy Soller 2020-06-04 13:22:59 -06:00 committed by GitHub
parent 83102f77ba
commit 39cd014f7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 1100 additions and 37 deletions

View File

@ -10,6 +10,12 @@ then
header=0
fi
has_dgpu=0
if nvidia-smi &> /dev/null
then
has_dgpu=1
fi
while true
do
if [ "${header}" == "1" ]
@ -20,7 +26,13 @@ do
F="${F}\tCPU PL1"
F="${F}\tCPU PL2"
F="${F}\tCPU C"
F="${F}\tFAN %"
F="${F}\tCPU FAN"
if [ "${has_dgpu}" == "1" ]
then
F="${F}\tGPU W"
F="${F}\tGPU C"
F="${F}\tGPU FAN"
fi
else
F="$(date "+%T")"
@ -53,6 +65,19 @@ do
D="$(sudo tool/target/release/system76_ectool fan 0)"
P="$(echo "(${D} * 100)/255" | bc -lq)"
F="${F}\t$(printf "%.0f" "${P}")"
if [ "${has_dgpu}" == "1" ]
then
DGPU_W="$(nvidia-smi --query-gpu=power.draw --format=csv,noheader | cut -d' ' -f1)"
F="${F}\t$(printf "%.1f" "${DGPU_W}")"
DGPU_T="$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader)"
F="${F}\t${DGPU_T}"
D="$(sudo tool/target/release/system76_ectool fan 1)"
P="$(echo "(${D} * 100)/255" | bc -lq)"
F="${F}\t$(printf "%.0f" "${P}")"
fi
fi
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq

View File

@ -1,5 +1,6 @@
#include <8051.h>
#include <arch/arch.h>
#include <arch/time.h>
void arch_init(void) {

View File

@ -0,0 +1,161 @@
#include <board/acpi.h>
#include <board/battery.h>
#include <board/gpio.h>
#include <board/kbled.h>
#include <board/lid.h>
#include <board/peci.h>
#include <common/debug.h>
extern uint8_t sci_extra;
uint8_t ecos = 0;
static uint8_t fcmd = 0;
static uint8_t fdat = 0;
static uint8_t fbuf[4] = { 0, 0, 0, 0 };
void fcommand(void) {
switch (fcmd) {
// Keyboard backlight
case 0xCA:
switch (fdat) {
// Set LED color
case 0x03:
kbled_set_color(
((uint32_t)fbuf[0]) |
((uint32_t)fbuf[1] << 16) |
((uint32_t)fbuf[2] << 8)
);
break;
// Set LED brightness
case 0x06:
kbled_set(fbuf[0]);
break;
}
break;
}
}
uint8_t acpi_read(uint8_t addr) {
uint8_t data = 0;
#define ACPI_8(K, V) \
case (K): \
data = (uint8_t)(V); \
break
#define ACPI_16(K, V) \
ACPI_8(K, V); \
ACPI_8((K) + 1, (V) >> 8)
#define ACPI_32(K, V) \
ACPI_16(K, V); \
ACPI_16((K) + 2, (V) >> 16)
switch (addr) {
// Lid state and other flags
case 0x03:
if (gpio_get(&LID_SW_N)) {
// Lid is open
data |= 1 << 0;
}
if (lid_wake) {
data |= 1 << 2;
}
break;
// Handle AC adapter and battery present
case 0x10:
if (!gpio_get(&ACIN_N)) {
// AC adapter connected
data |= 1 << 0;
}
// BAT0 always connected - TODO
data |= 1 << 2;
break;
ACPI_16(0x16, battery_design_capacity);
ACPI_16(0x1A, battery_full_capacity);
ACPI_16(0x22, battery_design_voltage);
case 0x26:
// If AC adapter connected
if (!gpio_get(&ACIN_N)) {
// And battery is not fully charged
if (!(battery_status & 0x0020)) {
// Battery is charging
data |= 1 << 1;
}
}
break;
ACPI_16(0x2A, battery_current);
ACPI_16(0x2E, battery_remaining_capacity);
ACPI_16(0x32, battery_voltage);
ACPI_8(0x68, ecos);
ACPI_8(0xCC, sci_extra);
// Airplane mode LED
case 0xD9:
if (!gpio_get(&LED_AIRPLANE_N)) {
data |= (1 << 6);
}
break;
// Set size of flash (from old firmware)
ACPI_8 (0xE5, 0x80);
ACPI_8 (0xF8, fcmd);
ACPI_8 (0xF9, fdat);
ACPI_8 (0xFA, fbuf[0]);
ACPI_8 (0xFB, fbuf[1]);
ACPI_8 (0xFC, fbuf[2]);
ACPI_8 (0xFD, fbuf[3]);
}
DEBUG("acpi_read %02X = %02X\n", addr, data);
return data;
}
void acpi_write(uint8_t addr, uint8_t data) {
DEBUG("acpi_write %02X = %02X\n", addr, data);
switch (addr) {
// Lid state and other flags
case 0x03:
lid_wake = (bool)(data & (1 << 2));
break;
case 0x68:
ecos = data;
break;
// Airplane mode LED
case 0xD9:
gpio_set(&LED_AIRPLANE_N, !(bool)(data & (1 << 6)));
break;
case 0xF8:
fcmd = data;
fcommand();
break;
case 0xF9:
fdat = data;
break;
case 0xFA:
fbuf[0] = data;
break;
case 0xFB:
fbuf[1] = data;
break;
case 0xFC:
fbuf[2] = data;
break;
case 0xFD:
fbuf[3] = data;
break;
}
}

View File

@ -0,0 +1,72 @@
#include <arch/time.h>
#include <board/battery.h>
#include <board/board.h>
#include <board/dgpu.h>
#include <board/gpio.h>
#include <board/kbc.h>
#include <board/power.h>
#include <common/debug.h>
extern uint8_t main_cycle;
void board_init(void) {
// Allow backlight to be turned on
gpio_set(&BKL_EN, true);
// Enable camera
gpio_set(&CCD_EN, true);
// Enable wireless
gpio_set(&WLAN_EN, true);
gpio_set(&WLAN_PWR_EN, true);
// Assert SMI#, SCI#, and SWI#
gpio_set(&SCI_N, true);
gpio_set(&SMI_N, true);
gpio_set(&SWI_N, true);
dgpu_init();
}
void board_event(void) {
if (main_cycle == 0) {
if (gpio_get(&ACIN_N)) {
// Discharging (no AC adapter)
gpio_set(&LED_BAT_CHG, false);
gpio_set(&LED_BAT_FULL, false);
} else if (battery_status & 0x0020) {
// Fully charged
// TODO: turn off charger
gpio_set(&LED_BAT_CHG, false);
gpio_set(&LED_BAT_FULL, true);
} else {
// Charging
// TODO: detect no battery connected
gpio_set(&LED_BAT_CHG, true);
gpio_set(&LED_BAT_FULL, false);
}
if (power_state == POWER_STATE_S0 || power_state == POWER_STATE_S3 || power_state == POWER_STATE_DS3) {
// System is on
} else if (gpio_get(&ACIN_N)) {
// Power off VDD3 if system should be off
gpio_set(&XLP_OUT, 0);
}
static uint32_t last_time = 0;
uint32_t time = time_get();
// Only run the following once a second
if (last_time > time || (time - last_time) >= 1000) {
last_time = time;
// Updates discrete GPU fan status and temps
dgpu_event();
}
}
// Set keyboard LEDs
static uint8_t last_kbc_leds = 0;
if (kbc_leds != last_kbc_leds) {
gpio_set(&LED_SCROLL_N, (kbc_leds & 1) == 0);
gpio_set(&LED_NUM_N, (kbc_leds & 2) == 0);
gpio_set(&LED_CAP_N, (kbc_leds & 4) == 0);
last_kbc_leds = kbc_leds;
}
}

View File

@ -0,0 +1,38 @@
EC=it5570e
# Add keymap to src
KEYMAP?=default
SRC+=$(BOARD_DIR)/keymap/$(KEYMAP).c
# Set log level
# 0 - NONE
# 1 - ERROR
# 2 - WARN
# 3 - INFO
# 4 - DEBUG
# 5 - TRACE
CFLAGS+=-DLEVEL=4
# Enable I2C debug on 0x76
#CFLAGS+=-DI2C_DEBUGGER=0x76
# 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
CFLAGS+=\
-DCHARGER_CHARGE_CURRENT=1536 \
-DCHARGER_CHARGE_VOLTAGE=12600 \
-DCHARGER_INPUT_CURRENT=11800
# Enable debug logging over keyboard parallel port
#CFLAGS+=-DPARPORT_DEBUG
# Add system76 common code
include src/board/system76/common/common.mk

View File

@ -0,0 +1,144 @@
#include <stdbool.h>
#include <stdint.h>
#include <board/gpio.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/i2c.h>
#include <ec/pwm.h>
// Fan speed is the lowest requested over HEATUP seconds
#define HEATUP 10
// Fan speed is the highest HEATUP speed over COOLDOWN seconds
#define COOLDOWN 10
// Interpolate duty cycle
#define INTERPOLATE 0
int16_t dgpu_temp = 0;
uint8_t dgpu_duty = 0;
#define DGPU_TEMP(X) ((int16_t)(X))
#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))
struct FanPoint {
int16_t temp;
uint8_t duty;
};
#define FAN_POINT(T, D) { .temp = DGPU_TEMP(T), .duty = PWM_DUTY(D) }
// Fan curve with temperature in degrees C, duty cycle in percent
static struct FanPoint __code FAN_POINTS[] = {
FAN_POINT(70, 40),
FAN_POINT(75, 50),
FAN_POINT(80, 60),
FAN_POINT(85, 65),
FAN_POINT(90, 65)
};
// Get duty cycle based on temperature, adapted from
// https://github.com/pop-os/system76-power/blob/master/src/fan.rs
static uint8_t fan_duty(int16_t temp) {
for (int i = 0; i < ARRAY_SIZE(FAN_POINTS); i++) {
const struct FanPoint * cur = &FAN_POINTS[i];
// If exactly the current temp, return the current duty
if (temp == cur->temp) {
return cur->duty;
} else if (temp < cur->temp) {
// If lower than first temp, return 0%
if (i == 0) {
return PWM_DUTY(0);
} else {
const struct FanPoint * prev = &FAN_POINTS[i - 1];
#if INTERPOLATE
// If in between current temp and previous temp, interpolate
if (temp > prev->temp) {
int16_t dtemp = (cur->temp - prev->temp);
int16_t dduty = ((int16_t)cur->duty) - ((int16_t)prev->duty);
return (uint8_t)(
((int16_t)prev->duty) +
((temp - prev->temp) * dduty) / dtemp
);
}
#else // INTERPOLATE
return prev->duty;
#endif // INTERPOLATE
}
}
}
// If no point is found, return 100%
return PWM_DUTY(100);
}
static uint8_t fan_heatup(uint8_t duty) {
static uint8_t history[HEATUP] = { 0 };
uint8_t lowest = duty;
int i;
for (i = 0; (i + 1) < ARRAY_SIZE(history); i++) {
uint8_t value = history[i + 1];
if (value < lowest) {
lowest = value;
}
history[i] = value;
}
history[i] = duty;
return lowest;
}
static uint8_t fan_cooldown(uint8_t duty) {
static uint8_t history[COOLDOWN] = { 0 };
uint8_t highest = duty;
int i;
for (i = 0; (i + 1) < ARRAY_SIZE(history); i++) {
uint8_t value = history[i + 1];
if (value > highest) {
highest = value;
}
history[i] = value;
}
history[i] = duty;
return highest;
}
void dgpu_init(void) {
// Set up for i2c usage
i2c_reset(&I2C_DGPU, true);
}
void dgpu_event(void) {
if (power_state == POWER_STATE_S0 && gpio_get(&DGPU_PWR_EN)) {
// Use I2CS if in S0 state
int8_t rlts;
int res = i2c_get(&I2C_DGPU, 0x4F, 0x00, &rlts, 1);
if (res == 1) {
dgpu_temp = (int16_t)rlts;
dgpu_duty = fan_duty(dgpu_temp);
} else {
DEBUG("DGPU temp error: %d\n", res);
// Default to 50% if there is an error
dgpu_temp = 0;
dgpu_duty = PWM_DUTY(50);
}
} else {
// Turn fan off if not in S0 state or GPU power not on
dgpu_temp = 0;
dgpu_duty = PWM_DUTY(0);
}
uint8_t heatup_duty = fan_heatup(dgpu_duty);
uint8_t cooldown_duty = fan_cooldown(heatup_duty);
if (cooldown_duty != DCR4) {
DCR4 = cooldown_duty;
DEBUG("DGPU temp=%d = %d\n", dgpu_temp, cooldown_duty);
}
}

View File

@ -0,0 +1,269 @@
#include <board/gpio.h>
#include <common/debug.h>
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(H, 2);
struct Gpio __code BUF_PLT_RST_N = GPIO(D, 2);
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_EN
struct Gpio __code EC_RSMRST_N = GPIO(E, 5);
struct Gpio __code LED_ACIN = GPIO(C, 7);
struct Gpio __code LED_AIRPLANE_N = GPIO(H, 7);
struct Gpio __code LED_CAP_N = GPIO(J, 2);
struct Gpio __code LED_BAT_CHG = GPIO(H, 5);
struct Gpio __code LED_BAT_FULL = GPIO(J, 0);
struct Gpio __code LED_NUM_N = GPIO(G, 0);
struct Gpio __code LED_PWR = GPIO(D, 0);
struct Gpio __code LED_SCROLL_N = GPIO(J, 3);
struct Gpio __code LID_SW_N = GPIO(B, 1);
struct Gpio __code PM_CLKRUN_N = GPIO(H, 0); // renamed to ECCLKRUN#
struct Gpio __code PM_PWROK = GPIO(C, 6);
struct Gpio __code PWR_BTN_N = GPIO(D, 5);
struct Gpio __code PWR_SW_N = GPIO(B, 3);
struct Gpio __code SCI_N = GPIO(D, 3);
struct Gpio __code SMI_N = GPIO(D, 4);
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 VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(J, 7);
struct Gpio __code XLP_OUT = GPIO(B, 4);
void gpio_init() {
// Enable LPC reset on GPD2
GCR = 0x04;
// Enable SMBus channel 4
GCR15 = (1 << 4);
// Set GPF2 and GPF3 to 3.3V
GCR20 = 0;
// Set GPIO data
GPDRA = 0x00;
GPDRB = 0x18;
GPDRC = 0x00;
GPDRD = 0x38;
GPDRE = 0x40;
GPDRF = 0x40;
GPDRG = 0x41;
GPDRH = 0x80;
GPDRI = 0x00;
GPDRJ = 0x0C;
// Set GPIO control
// EC_PWM_LEDKB_P
GPCRA0 = GPIO_ALT;
// KBC_BEEP
GPCRA1 = GPIO_ALT;
// CPU_FAN
GPCRA2 = GPIO_ALT;
// BRIGHTNESS
GPCRA3 = GPIO_IN;
// VGA_FAN
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 | GPIO_UP;
// SUSBC_EN
GPCRB6 = GPIO_OUT | GPIO_UP;
//
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM
GPCRC1 = GPIO_ALT;
// SMD_VGA_THERM
GPCRC2 = GPIO_ALT;
// KB-SO16
GPCRC3 = 0x04;
// CNVI_DET#_EC
GPCRC4 = GPIO_IN | GPIO_UP;
// KB-SO17
GPCRC5 = 0x04;
// PM_PWEROK
GPCRC6 = GPIO_OUT;
// LED_ACIN
GPCRC7 = GPIO_OUT | GPIO_UP;
// LED_PWR
GPCRD0 = GPIO_OUT | GPIO_UP;
// CCD_EN
GPCRD1 = GPIO_OUT | GPIO_UP;
// BUF_PLT_RST#
GPCRD2 = GPIO_ALT;
// SCI#
GPCRD3 = GPIO_IN;
// SMI#
GPCRD4 = GPIO_IN;
// PWR_BTN#
GPCRD5 = GPIO_OUT | GPIO_UP;
// CPU_FANSEN
GPCRD6 = GPIO_IN;
// VGA_FANSEN
GPCRD7 = GPIO_IN;
// SMC_BAT_EC
GPCRE0 = GPIO_ALT;
// AC_PRESENT
GPCRE1 = GPIO_OUT | GPIO_DOWN;
// PERKB-DET#
GPCRE2 = GPIO_IN | GPIO_UP;
// BL_PWM_EN_EC
GPCRE3 = GPIO_OUT | GPIO_UP;
// DD_ON
GPCRE4 = GPIO_OUT | GPIO_DOWN;
// EC_RSMRST#
GPCRE5 = GPIO_OUT;
// PLVDD_RST_EC
GPCRE6 = GPIO_OUT | GPIO_UP;
// SMD_BAT_EC
GPCRE7 = GPIO_ALT;
// 80CLK
GPCRF0 = GPIO_IN;
// USB_CHARGE_EN
GPCRF1 = GPIO_OUT | GPIO_UP;
// 3IN1
GPCRF2 = GPIO_IN | GPIO_UP;
// MUX_CTRL_BIOS
GPCRF3 = GPIO_OUT | GPIO_UP;
// TP_CLK
GPCRF4 = GPIO_IN;
// TP_DATA
GPCRF5 = GPIO_IN;
// EC_PECI
GPCRF6 = GPIO_ALT;
// SLP_S0#
GPCRF7 = GPIO_IN | GPIO_UP;
// LED_NUM#
GPCRG0 = GPIO_OUT | GPIO_UP;
// WLAN_EN
GPCRG1 = GPIO_OUT | GPIO_UP;
// AUTO_LOAD
GPCRG2 = GPIO_OUT;
// ALSPI_CE#
GPCRG3 = GPIO_ALT;
// ALSPI_MSI
GPCRG4 = GPIO_ALT;
// ALSPI_MSO
GPCRG5 = GPIO_ALT;
// H_PROCHOT#_EC
GPCRG6 = GPIO_OUT | GPIO_UP;
// ALSPI_SCLK
GPCRG7 = GPIO_ALT;
// ECCLKRUN#
GPCRH0 = GPIO_ALT;
// SUSC#_PCH
GPCRH1 = GPIO_IN;
// BKL_EN
GPCRH2 = GPIO_OUT | GPIO_UP;
// GC6_FB_EN_PCH
GPCRH3 = GPIO_IN;
// DGPU_PWR_EN
GPCRH4 = GPIO_IN;
// LED_BAT_CHG
GPCRH5 = GPIO_OUT | GPIO_UP;
// SUSB#_PCH
GPCRH6 = GPIO_IN;
// AIRPLAN_LED#
GPCRH7 = GPIO_OUT | GPIO_UP;
// BAT_DET
GPCRI0 = GPIO_ALT;
// BAT_VOLT
GPCRI1 = GPIO_ALT;
// ME_WE
GPCRI2 = GPIO_OUT;
// THERM_VOLT
GPCRI3 = GPIO_ALT;
// TOTAL_CUR
GPCRI4 = GPIO_ALT;
// RGBKB-DET#
GPCRI5 = GPIO_IN | GPIO_UP;
// OVERT#_EC
GPCRI6 = GPIO_IN;
// MODEL_ID
GPCRI7 = GPIO_IN;
// LED_BAT_FULL
GPCRJ0 = GPIO_OUT | GPIO_UP;
// KBC_MUTE#
GPCRJ1 = GPIO_IN;
// LED_CAP#
GPCRJ2 = GPIO_OUT | GPIO_UP;
// LED_SCROLL#
GPCRJ3 = GPIO_OUT | GPIO_UP;
// VA_EC_EN
GPCRJ4 = GPIO_OUT;
// VBATT_BOOST#
GPCRJ5 = GPIO_OUT;
// POWER_IC_EN
GPCRJ6 = GPIO_OUT | GPIO_UP;
// WLAN_PWR_EN
GPCRJ7 = GPIO_OUT | GPIO_UP;
// LPC_AD0
GPCRM0 = GPIO_ALT;
// LPC_AD1
GPCRM1 = GPIO_ALT;
// LPC_AD2
GPCRM2 = GPIO_ALT;
// LPC_AD3
GPCRM3 = GPIO_ALT;
// PCLK_KBC
GPCRM4 = GPIO_ALT;
// LPC_FRAME#
GPCRM5 = GPIO_ALT;
// SERIRQ
GPCRM6 = GPIO_ALT;
}
#if GPIO_DEBUG
void gpio_debug_bank(
char * bank,
uint8_t data,
uint8_t mirror,
uint8_t pot,
volatile uint8_t * control
) {
for(char i = 0; i < 8; i++) {
DEBUG(
"%s%d:\n\tdata %d\n\tmirror %d\n\tpot %d\n\tcontrol %02X\n",
bank,
i,
(data >> i) & 1,
(mirror >> i) & 1,
(pot >> i) & 1,
*(control + i)
);
}
}
void gpio_debug(void) {
#define bank(BANK) gpio_debug_bank(#BANK, GPDR ## BANK, GPDMR ## BANK, GPOT ## BANK, &GPCR ## BANK ## 0)
bank(A);
bank(B);
bank(C);
bank(D);
bank(E);
bank(F);
bank(G);
bank(H);
bank(I);
bank(J);
#undef bank
}
#endif

View File

@ -0,0 +1,7 @@
#ifndef _BOARD_DGPU_H
#define _BOARD_DGPU_H
void dgpu_init(void);
void dgpu_event(void);
#endif // _BOARD_DGPU_H

View File

@ -0,0 +1,53 @@
#ifndef _BOARD_GPIO_H
#define _BOARD_GPIO_H
#include <ec/gpio.h>
#define GPIO_ALT 0x00
#define GPIO_IN 0x80
#define GPIO_OUT 0x40
#define GPIO_UP 0x04
#define GPIO_DOWN 0x02
void gpio_init(void);
void gpio_debug(void);
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;
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; // renamed to SUSBC_EN
extern struct Gpio __code EC_RSMRST_N;
extern struct Gpio __code LED_ACIN;
extern struct Gpio __code LED_AIRPLANE_N;
extern struct Gpio __code LED_CAP_N;
extern struct Gpio __code LED_BAT_CHG;
extern struct Gpio __code LED_BAT_FULL;
extern struct Gpio __code LED_NUM_N;
extern struct Gpio __code LED_PWR;
extern struct Gpio __code LED_SCROLL_N;
extern struct Gpio __code LID_SW_N;
#define HAVE_PCH_DPWROK_EC 0
#define HAVE_PCH_PWROK_EC 0
extern struct Gpio __code PM_CLKRUN_N; // renamed to ECCLKRUN#
extern struct Gpio __code PM_PWROK;
extern struct Gpio __code PWR_BTN_N;
extern struct Gpio __code PWR_SW_N;
extern struct Gpio __code SCI_N;
#define HAVE_SLP_SUS_N 0
extern struct Gpio __code SMI_N;
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 SWI_N;
extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
#endif // _BOARD_GPIO_H

View File

@ -0,0 +1,12 @@
#ifndef _BOARD_KBLED_H
#define _BOARD_KBLED_H
#include <stdint.h>
void kbled_init(void);
void kbled_reset(void);
uint8_t kbled_get(void);
void kbled_set(uint8_t level);
void kbled_set_color(uint32_t color);
#endif // _BOARD_KBLED_H

View File

@ -0,0 +1,50 @@
#ifndef _BOARD_KEYMAP_H
#define _BOARD_KEYMAP_H
#include <common/keymap.h>
#define ___ 0
// Conversion of physical layout to keyboard matrix
#define LAYOUT( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0I, K0J, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, \
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, K3F, \
K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, K4E, K4F, K4G, \
K50, K51, K52, K53, K54, K55, K56, K57, K58, K59, K5A, K5B, K5C \
) { \
{ ___, ___, ___, ___, ___, ___, K50, K57 }, \
{ ___, ___, ___, ___, ___, ___, K53, K55 }, \
{ ___, ___, ___, ___, ___, ___, K40, K4B }, \
{ K52, ___, ___, ___, ___, ___, ___, K54 }, \
{ K41, K1H, ___, K2F, K4E, ___, ___, ___ }, \
{ K0I, K22, ___, ___, K1E, K3D, K3F, K30 }, \
{ K0J, K1B, K23, K39, ___, ___, K47, ___ }, \
{ K38, K26, K1A, K24, ___, K3A, K20, K00 }, \
{ K5B, K37, K2C, K19, K25, K07, K18, K01 }, \
{ K5C, K34, K36, K02, ___, K4G, K3B, K45 }, \
{ K1F, K48, ___, K2B, K32, K08, K06, K12 }, \
{ K1G, K49, K17, K33, ___, ___, K11, K2A }, \
{ K2D, ___, K31, K4A, ___, K03, K28, K16 }, \
{ ___, K44, K0D, K09, K46, K29, K15, K05 }, \
{ K21, K0A, K2E, K04, K3E, K0E, K0F, K14 }, \
{ K56, K42, K3C, K2H, K27, K2G, K13, K1D }, \
{ K0H, K0G, K43, K4C, K59, K10, K0B, K0C }, \
{ K35, K1C, K4F, K51, K4D, K58, K5A, ___ } \
}
// Keymap output pins
#define KM_OUT 18
// Keymap input pins
#define KM_IN 8
// Keymap layers (normal, Fn)
#define KM_LAY 2
// Keymap
extern uint16_t __code KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Get a keycode from the keymap
uint16_t keymap(int output, int input, int layer);
#endif // _BOARD_KEYMAP_H

View File

@ -0,0 +1,34 @@
#include <board/kbled.h>
#include <ec/pwm.h>
void kbled_init(void) {
//TODO: enable PWMs
kbled_reset();
}
void kbled_reset(void) {
// Set brightness and color
kbled_set_color(0xFFFFFF);
kbled_set(0x00);
}
uint8_t kbled_get(void) {
// Get PWM for power
return DCR0;
}
void kbled_set(uint8_t level) {
// Set PWM for power
DCR0 = level;
}
void kbled_set_color(uint32_t color) {
// Set PWM for blue component
DCR7 = (uint8_t)(color);
// Set PWM for green component
DCR6 = (uint8_t)(color >> 8);
// Set PWM for red component
DCR5 = (uint8_t)(color >> 16);
}

View File

@ -0,0 +1,22 @@
// Default layout
#include <board/keymap.h>
uint16_t __code KEYMAP[KM_LAY][KM_OUT][KM_IN] = {
LAYOUT(
K_ESC, K_F1, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8, K_F9, K_F10, K_F11, K_F12, K_PRINT_SCREEN, K_INSERT, K_DEL, K_HOME, K_END, K_PGUP, K_PGDN,
K_TICK, K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9, K_0, K_MINUS, K_EQUALS, K_BKSP, K_NUM_LOCK, K_NUM_SLASH, K_NUM_ASTERISK, K_NUM_MINUS,
K_TAB, K_Q, K_W, K_E, K_R, K_T, K_Y, K_U, K_I, K_O, K_P, K_BRACE_OPEN, K_BRACE_CLOSE, K_BACKSLASH, K_NUM_7, K_NUM_8, K_NUM_9, K_NUM_PLUS,
K_CAPS, K_A, K_S, K_D, K_F, K_G, K_H, K_J, K_K, K_L, K_SEMICOLON, K_QUOTE, K_ENTER, K_NUM_4, K_NUM_5, K_NUM_6,
K_LEFT_SHIFT, K_Z, K_X, K_C, K_V, K_B, K_N, K_M, K_COMMA, K_PERIOD, K_SLASH, K_RIGHT_SHIFT, K_UP, K_NUM_1, K_NUM_2, K_NUM_3, K_NUM_ENTER,
K_LEFT_CTRL, KT_FN, K_LEFT_SUPER, K_LEFT_ALT, K_SPACE, K_RIGHT_ALT, K_APP, K_RIGHT_CTRL, K_LEFT, K_DOWN, K_RIGHT, K_NUM_0, K_NUM_PERIOD
),
LAYOUT(
K_ESC, K_TOUCHPAD, KT_SCI | SCI_DISPLAY_TOGGLE, K_MUTE, K_F4, K_VOLUME_DOWN, K_VOLUME_UP, K_DISPLAY_MODE, KT_SCI | SCI_BRIGHTNESS_DOWN, KT_SCI | SCI_BRIGHTNESS_UP, KT_SCI | SCI_CAMERA_TOGGLE, KT_SCI | SCI_AIRPLANE_MODE, KT_SCI | SCI_SUSPEND, K_PRINT_SCREEN, K_INSERT, K_DEL, K_HOME, K_END, K_PGUP, K_PGDN,
K_PLAY_PAUSE, K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9, K_0, K_MINUS, K_EQUALS, K_BKSP, K_NUM_LOCK, KT_SCI_EXTRA | SCI_EXTRA_KBD_COLOR, KT_SCI_EXTRA | SCI_EXTRA_KBD_TOGGLE, KT_SCI_EXTRA | SCI_EXTRA_KBD_DOWN,
K_TAB, K_Q, K_W, K_E, K_R, K_T, K_Y, K_U, K_I, K_O, K_P, K_BRACE_OPEN, K_BRACE_CLOSE, K_BACKSLASH, K_NUM_7, K_NUM_8, K_NUM_9, KT_SCI_EXTRA | SCI_EXTRA_KBD_UP,
K_CAPS, K_A, K_S, K_D, K_F, K_G, K_H, K_J, K_K, K_L, K_SEMICOLON, K_QUOTE, K_ENTER, K_NUM_4, K_NUM_5, K_NUM_6,
K_LEFT_SHIFT, K_Z, K_X, K_C, K_V, K_B, K_N, K_M, K_COMMA, K_PERIOD, K_SLASH, K_RIGHT_SHIFT, K_UP, K_NUM_1, K_NUM_2, K_NUM_3, K_NUM_ENTER,
K_LEFT_CTRL, KT_FN, K_LEFT_SUPER, K_LEFT_ALT, K_SPACE, K_RIGHT_ALT, K_APP, K_RIGHT_CTRL, K_LEFT, K_DOWN, K_RIGHT, K_NUM_0, K_NUM_PERIOD
)
};

View File

@ -0,0 +1,22 @@
// Default layout
#include <board/keymap.h>
uint16_t __code KEYMAP[KM_LAY][KM_OUT][KM_IN] = {
LAYOUT(
K_ESC, K_F1, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8, K_F9, K_F10, K_F11, K_F12, K_PRINT_SCREEN, K_INSERT, K_DEL, K_HOME, K_END, K_PGUP, K_PGDN,
K_TICK, K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9, K_0, K_MINUS, K_EQUALS, K_BKSP, K_NUM_LOCK, K_NUM_SLASH, K_NUM_ASTERISK, K_NUM_MINUS,
K_TAB, K_Q, K_W, K_E, K_R, K_T, K_Y, K_U, K_I, K_O, K_P, K_BRACE_OPEN, K_BRACE_CLOSE, K_BACKSLASH, K_NUM_7, K_NUM_8, K_NUM_9, K_NUM_PLUS,
KT_FN, K_A, K_S, K_D, K_F, K_G, K_H, K_J, K_K, K_L, K_SEMICOLON, K_QUOTE, K_ENTER, K_NUM_4, K_NUM_5, K_NUM_6,
K_LEFT_SHIFT, K_Z, K_X, K_C, K_V, K_B, K_N, K_M, K_COMMA, K_PERIOD, K_SLASH, K_RIGHT_SHIFT, K_UP, K_NUM_1, K_NUM_2, K_NUM_3, K_NUM_ENTER,
K_LEFT_CTRL, KT_FN, K_LEFT_ALT, K_LEFT_SUPER, K_SPACE, KT_FN, K_RIGHT_ALT, K_RIGHT_CTRL, K_LEFT, K_DOWN, K_RIGHT, K_NUM_0, K_NUM_PERIOD
),
LAYOUT(
K_ESC, K_TOUCHPAD, KT_SCI | SCI_DISPLAY_TOGGLE, K_MUTE, K_F4, K_VOLUME_DOWN, K_VOLUME_UP, K_DISPLAY_MODE, KT_SCI | SCI_BRIGHTNESS_DOWN, KT_SCI | SCI_BRIGHTNESS_UP, KT_SCI | SCI_CAMERA_TOGGLE, KT_SCI | SCI_AIRPLANE_MODE, KT_SCI | SCI_SUSPEND, K_PRINT_SCREEN, K_INSERT, K_DEL, K_HOME, K_END, K_PGUP, K_PGDN,
K_PLAY_PAUSE, K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9, K_0, K_MINUS, K_EQUALS, K_DEL, K_NUM_LOCK, KT_SCI_EXTRA | SCI_EXTRA_KBD_COLOR, KT_SCI_EXTRA | SCI_EXTRA_KBD_TOGGLE, KT_SCI_EXTRA | SCI_EXTRA_KBD_DOWN,
K_TAB, K_Q, K_W, K_E, K_R, K_T, K_Y, K_PGUP, K_HOME, K_PGDN, K_P, K_BRACE_OPEN, K_BRACE_CLOSE, K_BACKSLASH, K_NUM_7, K_NUM_8, K_NUM_9, KT_SCI_EXTRA | SCI_EXTRA_KBD_UP,
KT_FN, K_A, K_S, K_D, K_F, K_G, K_LEFT, K_DOWN, K_UP, K_RIGHT, K_BKSP, K_DEL, K_ENTER, K_NUM_4, K_NUM_5, K_NUM_6,
K_LEFT_SHIFT, K_Z, K_X, K_C, K_V, K_B, K_END, K_M, K_COMMA, K_PERIOD, K_SLASH, K_RIGHT_SHIFT, K_UP, K_NUM_1, K_NUM_2, K_NUM_3, K_NUM_ENTER,
K_LEFT_CTRL, KT_FN, K_LEFT_ALT, K_LEFT_SUPER, K_ESC, KT_FN, K_RIGHT_ALT, K_RIGHT_CTRL, K_LEFT, K_DOWN, K_RIGHT, K_NUM_0, K_NUM_PERIOD
)
};

View File

@ -0,0 +1,40 @@
#include <8051.h>
#include <stdint.h>
#include <board/smfi.h>
#include <common/macro.h>
#include <ec/pwm.h>
// Include scratch ROM
uint8_t __code __at(SCRATCH_OFFSET) scratch_rom[] = {
#include <scratch.h>
};
// SCAR0 is stored in processor cache, not in xram
volatile uint8_t __xdata __at(0x1040) SCAR0L;
volatile uint8_t __xdata __at(0x1041) SCAR0M;
volatile uint8_t __xdata __at(0x1042) SCAR0H;
// Enter or exit scratch ROM
void scratch_trampoline(void) {
// Set fans to 100%
DCR2 = 0xFF;
DCR4 = 0xFF;
//TODO: Clear keyboard presses
// Start watchdog timer
smfi_watchdog();
// Disable interrupts
EA = 0;
// Use DMA mapping to copy flash data
SCAR0H = 0x80;
SCAR0L = (uint8_t)(SCRATCH_OFFSET);
SCAR0M = (uint8_t)(SCRATCH_OFFSET >> 8);
SCAR0H = 0;
// Jump to scratch reset function
__asm__("ljmp " xstr(SCRATCH_OFFSET));
}

View File

@ -13,7 +13,7 @@ console_internal:
console_external:
sleep 1 && echo C | sudo tee /dev/ttyACM* &
sudo tio -b 1000000 -m INLCRNL /dev/ttyACM*
sudo tio -b 1000000 -m INLCRNL -t /dev/ttyACM*
flash_internal: $(BUILD)/ec.rom
cargo build --manifest-path tool/Cargo.toml --release

View File

@ -7,6 +7,7 @@
extern bool kbc_first;
extern bool kbc_second;
extern uint8_t kbc_leds;
void kbc_init(void);
bool kbc_scancode(struct Kbc * kbc, uint16_t key, bool pressed);

View File

@ -21,6 +21,8 @@ bool kbc_second = false;
// Translate from scancode set 2 to scancode set 1
// for basically no good reason
static bool kbc_translate = true;
// LED state
uint8_t kbc_leds = 0;
// Values from linux/drivers/input/keyboard/atkbd.c
static const uint16_t kbc_typematic_period[32] = {
@ -256,6 +258,7 @@ void kbc_event(struct Kbc * kbc) {
case KBC_STATE_SET_LEDS:
TRACE(" set leds\n");
state = KBC_STATE_NORMAL;
kbc_leds = data;
kbc_keyboard(kbc, 0xFA, KBC_TIMEOUT);
break;
case KBC_STATE_SCANCODE:

View File

@ -24,6 +24,7 @@
#include <common/debug.h>
#include <common/macro.h>
#include <common/version.h>
#include <ec/ec.h>
#ifdef PARPORT_DEBUG
#include <ec/parallel.h>
@ -42,7 +43,7 @@ uint8_t main_cycle = 0;
void init(void) {
// Must happen first
arch_init();
board_init();
ec_init();
gctrl_init();
gpio_init();
@ -62,6 +63,9 @@ void init(void) {
smfi_init();
//TODO: INTC
// Must happen last
board_init();
}
void main(void) {
@ -73,23 +77,6 @@ void main(void) {
gpio_debug();
#endif
// Allow CPU to boot
gpio_set(&SB_KBCRST_N, true);
// Allow backlight to be turned on
gpio_set(&BKL_EN, true);
// Enable camera
gpio_set(&CCD_EN, true);
// Enable wireless
gpio_set(&BT_EN, true);
gpio_set(&WLAN_EN, true);
gpio_set(&WLAN_PWR_EN, true);
// Enable right USB port
gpio_set(&USB_PWR_EN_N, false);
// Assert SMI#, SCI#, and SWI#
gpio_set(&SCI_N, true);
gpio_set(&SMI_N, true);
gpio_set(&SWI_N, true);
INFO("System76 EC board '%s', version '%s'\n", board(), version());
uint32_t last_time = 0;

View File

@ -12,6 +12,26 @@
// Platform does not currently support Deep Sx
#define DEEP_SX 0
#ifndef HAVE_PCH_DPWROK_EC
#define HAVE_PCH_DPWROK_EC 1
#endif
#ifndef HAVE_PCH_PWROK_EC
#define HAVE_PCH_PWROK_EC 1
#endif
#ifndef HAVE_SLP_SUS_N
#define HAVE_SLP_SUS_N 1
#endif
#ifndef HAVE_SUSWARN_N
#define HAVE_SUSWARN_N 1
#endif
#ifndef HAVE_SUS_PWR_ACK
#define HAVE_SUS_PWR_ACK 1
#endif
extern uint8_t main_cycle;
// VccRTC stable (55%) to RTCRST# high
@ -128,8 +148,10 @@ void power_on_ds5(void) {
tPCH01;
tPCH02;
#if HAVE_PCH_DPWROK_EC
// Deep sleep well is a-ok
gpio_set(&PCH_DPWROK_EC, true);
#endif // HAVE_PCH_DPWROK_EC
// Wait for deep sleep well to propogate
tPCH32;
#else // DEEP_SX
@ -193,12 +215,16 @@ void power_on_s5(void) {
// Enable VDD5
gpio_set(&DD_ON, true);
#if HAVE_SUS_PWR_ACK
// De-assert SUS_ACK# - TODO is this needed on non-dsx?
gpio_set(&SUS_PWR_ACK, true);
#endif // HAVE_SUS_PWR_ACK
tPCH03;
#if HAVE_PCH_DPWROK_EC
// Assert DSW_PWROK
gpio_set(&PCH_DPWROK_EC, true);
#endif // HAVE_PCH_DPWROK_EC
// De-assert RSMRST#
gpio_set(&EC_RSMRST_N, true);
@ -225,8 +251,10 @@ void power_off_s5(void) {
#if DEEP_SX
// TODO
#else // DEEP_SX
#if HAVE_PCH_PWROK_EC
// De-assert SYS_PWROK
gpio_set(&PCH_PWROK_EC, false);
#endif // HAVE_PCH_PWROK_EC
// De-assert PCH_PWROK
gpio_set(&PM_PWROK, false);
@ -244,8 +272,10 @@ void power_off_s5(void) {
// Disable VCCPRIM_* planes
gpio_set(&VA_EC_EN, false);
#if HAVE_PCH_DPWROK_EC
// De-assert DSW_PWROK
gpio_set(&PCH_DPWROK_EC, false);
#endif // HAVE_PCH_DPWROK_EC
tPCH14;
#endif // DEEP_SX
@ -348,13 +378,17 @@ void power_event(void) {
// OEM defined delay from ALL_SYS_PWRGD to SYS_PWROK - TODO
delay_ms(10);
#if HAVE_PCH_PWROK_EC
// Assert SYS_PWROK, system can finally perform PLT_RST# and boot
gpio_set(&PCH_PWROK_EC, true);
#endif // HAVE_PCH_PWROK_EC
} else if(!pg_new && pg_last) {
DEBUG("%02X: ALL_SYS_PWRGD de-asserted\n", main_cycle);
#if HAVE_PCH_PWROK_EC
// De-assert SYS_PWROK
gpio_set(&PCH_PWROK_EC, false);
#endif // HAVE_PCH_PWROK_EC
// De-assert PCH_PWROK
gpio_set(&PM_PWROK, false);
@ -374,6 +408,7 @@ void power_event(void) {
}
rst_last = rst_new;
#if HAVE_SLP_SUS_N
#if LEVEL >= LEVEL_DEBUG
static bool sus_last = true;
bool sus_new = gpio_get(&SLP_SUS_N);
@ -384,7 +419,9 @@ void power_event(void) {
}
sus_last = sus_new;
#endif
#endif // HAVE_SLP_SUS_N
#if HAVE_SUSWARN_N
// EC must keep VccPRIM powered if SUSPWRDNACK is de-asserted low or system
// state is S3
static bool ack_last = false;
@ -398,7 +435,9 @@ void power_event(void) {
#endif
ack_last = ack_new;
if (ack_new) {
if (ack_new)
#endif // HAVE_SUSWARN_N
{
// Disable S5 power plane if not needed
if (power_state == POWER_STATE_S5) {
power_off_s5();

View File

@ -10,6 +10,10 @@ void pwm_init(void) {
// Set prescalar clock frequency to EC clock
PCFSR = 0b01;
// Use C0CPRS and CTR0 for all channels
PCSSGL = 0;
PCSSGH = 0;
// Set clock prescaler to 0 + 1
C0CPRS = 0;

View File

@ -144,11 +144,16 @@ static enum Result cmd_reset(void) {
#ifndef __SCRATCH__
static enum Result cmd_fan_get(void) {
// If setting fan 0
if (smfi_cmd[2] == 0) {
// Get duty of fan 0
smfi_cmd[3] = DCR2;
return RES_OK;
switch (smfi_cmd[2]) {
case 0:
// Get duty of fan 0
smfi_cmd[3] = DCR2;
return RES_OK;
case 1:
// Get duty of fan 1
//TODO: only allow on platforms like addw2
smfi_cmd[3] = DCR4;
return RES_OK;
}
// Failed if fan not found
@ -156,11 +161,16 @@ static enum Result cmd_fan_get(void) {
}
static enum Result cmd_fan_set(void) {
// If setting fan 0
if (smfi_cmd[2] == 0) {
// Set duty cycle of fan 0
DCR2 = smfi_cmd[3];
return RES_OK;
switch (smfi_cmd[2]) {
case 0:
// Set duty cycle of fan 0
DCR2 = smfi_cmd[3];
return RES_OK;
case 1:
// Set duty cycle of fan 1
//TODO: only allow on platforms like addw2
DCR4 = smfi_cmd[3];
return RES_OK;
}
// Failed if fan not found

View File

@ -1,12 +1,26 @@
#include <board/battery.h>
#include <board/board.h>
#include <board/gctrl.h>
#include <board/gpio.h>
extern uint8_t main_cycle;
void board_init(void) {
RSTS = 0x84;
// Allow CPU to boot
gpio_set(&SB_KBCRST_N, true);
// Allow backlight to be turned on
gpio_set(&BKL_EN, true);
// Enable camera
gpio_set(&CCD_EN, true);
// Enable wireless
gpio_set(&BT_EN, true);
gpio_set(&WLAN_EN, true);
gpio_set(&WLAN_PWR_EN, true);
// Enable right USB port
gpio_set(&USB_PWR_EN_N, false);
// Assert SMI#, SCI#, and SWI#
gpio_set(&SCI_N, true);
gpio_set(&SMI_N, true);
gpio_set(&SWI_N, true);
}
void board_event(void) {

View File

@ -1,12 +1,26 @@
#include <board/battery.h>
#include <board/board.h>
#include <board/gctrl.h>
#include <board/gpio.h>
extern uint8_t main_cycle;
void board_init(void) {
RSTS = 0x84;
// Allow CPU to boot
gpio_set(&SB_KBCRST_N, true);
// Allow backlight to be turned on
gpio_set(&BKL_EN, true);
// Enable camera
gpio_set(&CCD_EN, true);
// Enable wireless
gpio_set(&BT_EN, true);
gpio_set(&WLAN_EN, true);
gpio_set(&WLAN_PWR_EN, true);
// Enable right USB port
gpio_set(&USB_PWR_EN_N, false);
// Assert SMI#, SCI#, and SWI#
gpio_set(&SCI_N, true);
gpio_set(&SMI_N, true);
gpio_set(&SWI_N, true);
}
void board_event(void) {

View File

@ -1,12 +1,26 @@
#include <board/board.h>
#include <board/gctrl.h>
#include <board/gpio.h>
#include <board/power.h>
extern uint8_t main_cycle;
void board_init(void) {
RSTS = 0x44;
// Allow CPU to boot
gpio_set(&SB_KBCRST_N, true);
// Allow backlight to be turned on
gpio_set(&BKL_EN, true);
// Enable camera
gpio_set(&CCD_EN, true);
// Enable wireless
gpio_set(&BT_EN, true);
gpio_set(&WLAN_EN, true);
gpio_set(&WLAN_PWR_EN, true);
// Enable right USB port
gpio_set(&USB_PWR_EN_N, false);
// Assert SMI#, SCI#, and SWI#
gpio_set(&SCI_N, true);
gpio_set(&SMI_N, true);
gpio_set(&SWI_N, true);
}
void board_event(void) {

6
src/ec/it5570e/ec.c Normal file
View File

@ -0,0 +1,6 @@
#include <ec/ec.h>
#include <ec/gctrl.h>
void ec_init(void) {
RSTS = 0x44;
}

View File

@ -0,0 +1,6 @@
#ifndef _EC_EC_H
#define _EC_EC_H
void ec_init(void);
#endif // _EC_EC_H

View File

@ -6,5 +6,8 @@
volatile uint8_t __xdata __at(0x2006) RSTS;
volatile uint8_t __xdata __at(0x200A) BADRSEL;
volatile uint8_t __xdata __at(0x200D) SPCTRL1;
volatile uint8_t __xdata __at(0x2030) P80H81HS;
volatile uint8_t __xdata __at(0x2031) P80HD;
volatile uint8_t __xdata __at(0x2032) P81HD;
#endif // _EC_GCTRL_H

6
src/ec/it8587e/ec.c Normal file
View File

@ -0,0 +1,6 @@
#include <ec/ec.h>
#include <ec/gctrl.h>
void ec_init(void) {
RSTS = 0x84;
}

View File

@ -0,0 +1,6 @@
#ifndef _EC_EC_H
#define _EC_EC_H
void ec_init(void);
#endif // _EC_EC_H