ec/it*: Merge remaining ITE EC files

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford 2021-06-10 12:55:13 -06:00 committed by Jeremy Soller
parent cd8e76420d
commit f9e4e25b05
20 changed files with 58 additions and 531 deletions

View File

@ -1,16 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_SCRATCH_H
#define _EC_SCRATCH_H
#include <stdint.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;
#define SCARL SCAR0L
#define SCARM SCAR0M
#define SCARH SCAR0H
#endif // _EC_SCRATCH_H

View File

@ -1,8 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <ec/ec.h>
#include <ec/gctrl.h>
void ec_init(void) {
RSTS = 0x84;
}

View File

@ -1,152 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <stdbool.h>
#include <common/i2c.h>
#include <ec/smbus.h>
//TODO: find best value
#define I2C_TIMEOUT 10000
struct I2C {
volatile uint8_t * hosta;
volatile uint8_t * hoctl;
volatile uint8_t * hoctl2;
volatile uint8_t * hobdb;
volatile uint8_t * trasla;
};
struct I2C __code I2C_0 = {
.hosta = HOSTAA,
.hoctl = HOCTLA,
.hoctl2 = HOCTL2A,
.hobdb = HOBDBA,
.trasla = TRASLAA,
};
struct I2C __code I2C_1 = {
.hosta = HOSTAB,
.hoctl = HOCTLB,
.hoctl2 = HOCTL2B,
.hobdb = HOBDBB,
.trasla = TRASLAB,
};
void i2c_reset(struct I2C * i2c, bool kill) {
if (*(i2c->hosta) & HOSTA_BUSY) {
// Set kill bit
if (kill) *(i2c->hoctl) |= BIT(1);
// Wait for host to finish
while (*(i2c->hosta) & HOSTA_BUSY) {}
}
// Clear status register
*(i2c->hosta) = *(i2c->hosta);
// Clear current command
*(i2c->hoctl) = 0;
// Disable host interface
*(i2c->hoctl2) = 0;
}
int i2c_start(struct I2C * i2c, uint8_t addr, bool read) __reentrant {
// If we are already in a transaction
if (*(i2c->hosta) & HOSTA_BYTE_DONE) {
// If we are switching direction
if ((*(i2c->trasla) & 1) != read) {
// If we are switching to read mode
if (read) {
// Enable direction switch
*(i2c->hoctl2) |= BIT(3) | BIT(2);
} else {
// Unsupported!
i2c_reset(i2c, true);
return -1;
}
}
} else {
i2c_reset(i2c, true);
// Enable host controller with i2c compatibility
*(i2c->hoctl2) = BIT(1) | BIT(0);
// Set address
*(i2c->trasla) = (addr << 1) | read;
}
return 0;
}
void i2c_stop(struct I2C * i2c) {
// Disable i2c compatibility
*(i2c->hoctl2) &= ~BIT(1);
// Clear status
*(i2c->hosta) = *(i2c->hosta);
i2c_reset(i2c, false);
}
static int i2c_transaction(struct I2C * i2c, uint8_t * data, int length, bool read) {
int i;
for (i = 0; i < length; i++) {
if (read) {
// If last byte
if ((i + 1) == length) {
// Set last byte bit
*(i2c->hoctl) |= BIT(5);
}
} else {
// Write byte
*(i2c->hobdb) = data[i];
}
// If we are already in a transaction
if (*(i2c->hosta) & HOSTA_BYTE_DONE) {
// Clear status to process next byte
*(i2c->hosta) = *(i2c->hosta);
} else {
// Start new transaction
*(i2c->hoctl) = BIT(6) | (0b111 << 2);
}
// If we are waiting on direction switch
if (*(i2c->hoctl2) & BIT(2)) {
// Complete direction switch
*(i2c->hoctl2) &= ~BIT(2);
}
// Wait for byte done, timeout, or error
uint8_t status;
uint32_t timeout = I2C_TIMEOUT;
for(timeout = I2C_TIMEOUT; timeout > 0; timeout--) {
status = *(i2c->hosta);
// If error occured, kill transaction and return error
if (status & HOSTA_ERR) {
i2c_reset(i2c, true);
return -(int)(status);
} else
// If byte done, break
if (status & HOSTA_BYTE_DONE) {
break;
}
}
// If timeout occured, kill transaction and return error
if (timeout == 0) {
i2c_reset(i2c, true);
return -(0x1000 | (int)status);
}
if (read) {
// Read byte
data[i] = *(i2c->hobdb);
}
}
return i;
}
int i2c_read(struct I2C * i2c, uint8_t * data, int length) __reentrant {
return i2c_transaction(i2c, data, length, true);
}
int i2c_write(struct I2C * i2c, uint8_t * data, int length) __reentrant {
return i2c_transaction(i2c, data, length, false);
}

View File

@ -1,9 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_ESPI_H
#define _EC_ESPI_H
// eSPI not supported on IT8587E
#define EC_ESPI 0
#endif // _EC_ESPI_H

View File

@ -1,12 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_GCTRL_H
#define _EC_GCTRL_H
#include <stdint.h>
volatile uint8_t __xdata __at(0x2006) RSTS;
volatile uint8_t __xdata __at(0x200A) BADRSEL;
volatile uint8_t __xdata __at(0x200D) SPCTRL1;
#endif // _EC_GCTRL_H

View File

@ -1,188 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_GPIO_H
#define _EC_GPIO_H
#include <common/macro.h>
#include <stdbool.h>
#include <stdint.h>
#define GPIO_ALT (0b00U << 6)
#define GPIO_IN (0b10U << 6)
#define GPIO_OUT (0b01U << 6)
#define GPIO_UP BIT(2)
#define GPIO_DOWN BIT(1)
struct Gpio {
volatile uint8_t __xdata * data;
volatile uint8_t __xdata * mirror;
volatile uint8_t __xdata * control;
uint8_t value;
};
#define GPIO(BLOCK, NUMBER) { \
.data = &GPDR ## BLOCK, \
.mirror = &GPDMR ## BLOCK, \
.control = &GPCR ## BLOCK ## NUMBER, \
.value = BIT(NUMBER), \
}
bool gpio_get(struct Gpio * gpio);
void gpio_set(struct Gpio * gpio, bool value);
volatile uint8_t __xdata __at(0x1600) GCR;
volatile uint8_t __xdata __at(0x16F0) GCR1;
volatile uint8_t __xdata __at(0x16F1) GCR2;
volatile uint8_t __xdata __at(0x16F2) GCR3;
volatile uint8_t __xdata __at(0x16F3) GCR4;
volatile uint8_t __xdata __at(0x16F4) GCR5;
volatile uint8_t __xdata __at(0x16F5) GCR6;
volatile uint8_t __xdata __at(0x16F6) GCR7;
volatile uint8_t __xdata __at(0x16F7) GCR8;
volatile uint8_t __xdata __at(0x16F8) GCR9;
volatile uint8_t __xdata __at(0x16F9) GCR10;
volatile uint8_t __xdata __at(0x16FA) GCR11;
volatile uint8_t __xdata __at(0x16FB) GCR12;
volatile uint8_t __xdata __at(0x16FC) GCR13;
volatile uint8_t __xdata __at(0x16FD) GCR14;
volatile uint8_t __xdata __at(0x16FE) GCR15;
volatile uint8_t __xdata __at(0x16E0) GCR16;
volatile uint8_t __xdata __at(0x16E1) GCR17;
volatile uint8_t __xdata __at(0x16E2) GCR18;
volatile uint8_t __xdata __at(0x1601) GPDRA;
volatile uint8_t __xdata __at(0x1602) GPDRB;
volatile uint8_t __xdata __at(0x1603) GPDRC;
volatile uint8_t __xdata __at(0x1604) GPDRD;
volatile uint8_t __xdata __at(0x1605) GPDRE;
volatile uint8_t __xdata __at(0x1606) GPDRF;
volatile uint8_t __xdata __at(0x1607) GPDRG;
volatile uint8_t __xdata __at(0x1608) GPDRH;
volatile uint8_t __xdata __at(0x1609) GPDRI;
volatile uint8_t __xdata __at(0x160A) GPDRJ;
volatile uint8_t __xdata __at(0x160D) GPDRM;
volatile uint8_t __xdata __at(0x1661) GPDMRA;
volatile uint8_t __xdata __at(0x1662) GPDMRB;
volatile uint8_t __xdata __at(0x1663) GPDMRC;
volatile uint8_t __xdata __at(0x1664) GPDMRD;
volatile uint8_t __xdata __at(0x1665) GPDMRE;
volatile uint8_t __xdata __at(0x1666) GPDMRF;
volatile uint8_t __xdata __at(0x1667) GPDMRG;
volatile uint8_t __xdata __at(0x1668) GPDMRH;
volatile uint8_t __xdata __at(0x1669) GPDMRI;
volatile uint8_t __xdata __at(0x166A) GPDMRJ;
volatile uint8_t __xdata __at(0x166D) GPDMRM;
volatile uint8_t __xdata __at(0x1671) GPOTA;
volatile uint8_t __xdata __at(0x1672) GPOTB;
volatile uint8_t __xdata __at(0x1673) GPOTC;
volatile uint8_t __xdata __at(0x1674) GPOTD;
volatile uint8_t __xdata __at(0x1675) GPOTE;
volatile uint8_t __xdata __at(0x1676) GPOTF;
volatile uint8_t __xdata __at(0x1677) GPOTG;
volatile uint8_t __xdata __at(0x1678) GPOTH;
volatile uint8_t __xdata __at(0x1679) GPOTI;
volatile uint8_t __xdata __at(0x167A) GPOTJ;
// GPOTM does not exist
volatile uint8_t __xdata __at(0x1610) GPCRA0;
volatile uint8_t __xdata __at(0x1611) GPCRA1;
volatile uint8_t __xdata __at(0x1612) GPCRA2;
volatile uint8_t __xdata __at(0x1613) GPCRA3;
volatile uint8_t __xdata __at(0x1614) GPCRA4;
volatile uint8_t __xdata __at(0x1615) GPCRA5;
volatile uint8_t __xdata __at(0x1616) GPCRA6;
volatile uint8_t __xdata __at(0x1617) GPCRA7;
volatile uint8_t __xdata __at(0x1618) GPCRB0;
volatile uint8_t __xdata __at(0x1619) GPCRB1;
volatile uint8_t __xdata __at(0x161A) GPCRB2;
volatile uint8_t __xdata __at(0x161B) GPCRB3;
volatile uint8_t __xdata __at(0x161C) GPCRB4;
volatile uint8_t __xdata __at(0x161D) GPCRB5;
volatile uint8_t __xdata __at(0x161E) GPCRB6;
volatile uint8_t __xdata __at(0x161F) GPCRB7;
volatile uint8_t __xdata __at(0x1620) GPCRC0;
volatile uint8_t __xdata __at(0x1621) GPCRC1;
volatile uint8_t __xdata __at(0x1622) GPCRC2;
volatile uint8_t __xdata __at(0x1623) GPCRC3;
volatile uint8_t __xdata __at(0x1624) GPCRC4;
volatile uint8_t __xdata __at(0x1625) GPCRC5;
volatile uint8_t __xdata __at(0x1626) GPCRC6;
volatile uint8_t __xdata __at(0x1627) GPCRC7;
volatile uint8_t __xdata __at(0x1628) GPCRD0;
volatile uint8_t __xdata __at(0x1629) GPCRD1;
volatile uint8_t __xdata __at(0x162A) GPCRD2;
volatile uint8_t __xdata __at(0x162B) GPCRD3;
volatile uint8_t __xdata __at(0x162C) GPCRD4;
volatile uint8_t __xdata __at(0x162D) GPCRD5;
volatile uint8_t __xdata __at(0x162E) GPCRD6;
volatile uint8_t __xdata __at(0x162F) GPCRD7;
volatile uint8_t __xdata __at(0x1630) GPCRE0;
volatile uint8_t __xdata __at(0x1631) GPCRE1;
volatile uint8_t __xdata __at(0x1632) GPCRE2;
volatile uint8_t __xdata __at(0x1633) GPCRE3;
volatile uint8_t __xdata __at(0x1634) GPCRE4;
volatile uint8_t __xdata __at(0x1635) GPCRE5;
volatile uint8_t __xdata __at(0x1636) GPCRE6;
volatile uint8_t __xdata __at(0x1637) GPCRE7;
volatile uint8_t __xdata __at(0x1638) GPCRF0;
volatile uint8_t __xdata __at(0x1639) GPCRF1;
volatile uint8_t __xdata __at(0x163A) GPCRF2;
volatile uint8_t __xdata __at(0x163B) GPCRF3;
volatile uint8_t __xdata __at(0x163C) GPCRF4;
volatile uint8_t __xdata __at(0x163D) GPCRF5;
volatile uint8_t __xdata __at(0x163E) GPCRF6;
volatile uint8_t __xdata __at(0x163F) GPCRF7;
volatile uint8_t __xdata __at(0x1640) GPCRG0;
volatile uint8_t __xdata __at(0x1641) GPCRG1;
volatile uint8_t __xdata __at(0x1642) GPCRG2;
volatile uint8_t __xdata __at(0x1643) GPCRG3;
volatile uint8_t __xdata __at(0x1644) GPCRG4;
volatile uint8_t __xdata __at(0x1645) GPCRG5;
volatile uint8_t __xdata __at(0x1646) GPCRG6;
volatile uint8_t __xdata __at(0x1647) GPCRG7;
volatile uint8_t __xdata __at(0x1648) GPCRH0;
volatile uint8_t __xdata __at(0x1649) GPCRH1;
volatile uint8_t __xdata __at(0x164A) GPCRH2;
volatile uint8_t __xdata __at(0x164B) GPCRH3;
volatile uint8_t __xdata __at(0x164C) GPCRH4;
volatile uint8_t __xdata __at(0x164D) GPCRH5;
volatile uint8_t __xdata __at(0x164E) GPCRH6;
volatile uint8_t __xdata __at(0x164F) GPCRH7;
volatile uint8_t __xdata __at(0x1650) GPCRI0;
volatile uint8_t __xdata __at(0x1651) GPCRI1;
volatile uint8_t __xdata __at(0x1652) GPCRI2;
volatile uint8_t __xdata __at(0x1653) GPCRI3;
volatile uint8_t __xdata __at(0x1654) GPCRI4;
volatile uint8_t __xdata __at(0x1655) GPCRI5;
volatile uint8_t __xdata __at(0x1656) GPCRI6;
volatile uint8_t __xdata __at(0x1657) GPCRI7;
volatile uint8_t __xdata __at(0x1658) GPCRJ0;
volatile uint8_t __xdata __at(0x1659) GPCRJ1;
volatile uint8_t __xdata __at(0x165A) GPCRJ2;
volatile uint8_t __xdata __at(0x165B) GPCRJ3;
volatile uint8_t __xdata __at(0x165C) GPCRJ4;
volatile uint8_t __xdata __at(0x165D) GPCRJ5;
volatile uint8_t __xdata __at(0x165E) GPCRJ6;
volatile uint8_t __xdata __at(0x165F) GPCRJ7;
volatile uint8_t __xdata __at(0x16A0) GPCRM0;
volatile uint8_t __xdata __at(0x16A1) GPCRM1;
volatile uint8_t __xdata __at(0x16A2) GPCRM2;
volatile uint8_t __xdata __at(0x16A3) GPCRM3;
volatile uint8_t __xdata __at(0x16A4) GPCRM4;
volatile uint8_t __xdata __at(0x16A5) GPCRM5;
volatile uint8_t __xdata __at(0x16A6) GPCRM6;
#endif // _EC_GPIO_H

View File

@ -1,13 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_I2C_H
#define _EC_I2C_H
#include <common/i2c.h>
extern struct I2C __code I2C_0;
extern struct I2C __code I2C_1;
void i2c_reset(struct I2C * i2c, bool kill);
#endif // _EC_I2C_H

View File

@ -1,16 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_SCRATCH_H
#define _EC_SCRATCH_H
#include <stdint.h>
// SCAR1 is in xram at 0x800-0xC00
volatile uint8_t __xdata __at(0x1043) SCAR1L;
volatile uint8_t __xdata __at(0x1044) SCAR1M;
volatile uint8_t __xdata __at(0x1045) SCAR1H;
#define SCARL SCAR1L
#define SCARM SCAR1M
#define SCARH SCAR1H
#endif // _EC_SCRATCH_H

View File

@ -1,107 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_SMBUS_H
#define _EC_SMBUS_H
#include <common/macro.h>
#include <stdint.h>
#define HOSTA_BYTE_DONE BIT(7)
#define HOSTA_TIMEOUT BIT(6)
#define HOSTA_NACK BIT(5)
#define HOSTA_FAIL BIT(4)
#define HOSTA_BUS_ERR BIT(3)
#define HOSTA_DEV_ERR BIT(2)
#define HOSTA_FINISH BIT(1)
#define HOSTA_BUSY BIT(0)
#define HOSTA_ERR (HOSTA_TIMEOUT | HOSTA_NACK | HOSTA_FAIL | HOSTA_BUS_ERR | HOSTA_DEV_ERR)
// Host status for channel A
volatile uint8_t __xdata __at(0x1C00) HOSTAA;
// Host control for channel A
volatile uint8_t __xdata __at(0x1C01) HOCTLA;
// Host command for channel A
volatile uint8_t __xdata __at(0x1C02) HOCMDA;
// Transmit slave address for channel A
volatile uint8_t __xdata __at(0x1C03) TRASLAA;
// Host data 0 for channel A
volatile uint8_t __xdata __at(0x1C04) D0REGA;
// Host data 1 for channel A
volatile uint8_t __xdata __at(0x1C05) D1REGA;
// Host block data byte for channel A
volatile uint8_t __xdata __at(0x1C06) HOBDBA;
// Packet error check for channel A
volatile uint8_t __xdata __at(0x1C07) PECERCA;
// Receive slave address for channel A
volatile uint8_t __xdata __at(0x1C08) RESLADRA;
// Slave data for channel A
volatile uint8_t __xdata __at(0x1C09) SLDAA;
// SMBus pin control for channel A
volatile uint8_t __xdata __at(0x1C0A) SMBPCTLA;
// Slave status for channel A
volatile uint8_t __xdata __at(0x1C0B) SLSTAA;
// Slave interrupt control for channel A
volatile uint8_t __xdata __at(0x1C0C) SICRA;
// Notify device address for channel A
volatile uint8_t __xdata __at(0x1C0D) NDADRA;
// Notify data low byte for channel A
volatile uint8_t __xdata __at(0x1C0E) NDLBA;
// Notify data high byte for channel A
volatile uint8_t __xdata __at(0x1C0F) NDHBA;
// Host control 2 for channel A
volatile uint8_t __xdata __at(0x1C10) HOCTL2A;
// Receive slave address 2 for channel A
volatile uint8_t __xdata __at(0x1C3F) RESLADR2A;
// SMCLK timing setting for channel A
volatile uint8_t __xdata __at(0x1C40) SCLKTSA;
// Host status for channel B
volatile uint8_t __xdata __at(0x1C11) HOSTAB;
// Host control for channel B
volatile uint8_t __xdata __at(0x1C12) HOCTLB;
// Host command for channel B
volatile uint8_t __xdata __at(0x1C13) HOCMDB;
// Transmit slave address for channel B
volatile uint8_t __xdata __at(0x1C14) TRASLAB;
// Host data 0 for channel B
volatile uint8_t __xdata __at(0x1C15) D0REGB;
// Host data 1 for channel B
volatile uint8_t __xdata __at(0x1C16) D1REGB;
// Host block data byte for channel B
volatile uint8_t __xdata __at(0x1C17) HOBDBB;
// Packet error check for channel B
volatile uint8_t __xdata __at(0x1C18) PECERCB;
// Receive slave address for channel B
volatile uint8_t __xdata __at(0x1C19) RESLADRB;
// Slave data for channel B
volatile uint8_t __xdata __at(0x1C1A) SLDAB;
// SMBus pin control for channel B
volatile uint8_t __xdata __at(0x1C1B) SMBPCTLB;
// Slave status for channel B
volatile uint8_t __xdata __at(0x1C1C) SLSTAB;
// Slave interrupt control for channel B
volatile uint8_t __xdata __at(0x1C1D) SICRB;
// Notify device address for channel B
volatile uint8_t __xdata __at(0x1C1E) NDADRB;
// Notify data low byte for channel A
volatile uint8_t __xdata __at(0x1C1F) NDLBB;
// Notify data high byte for channel B
volatile uint8_t __xdata __at(0x1C20) NDHBB;
// Host control 2 for channel B
volatile uint8_t __xdata __at(0x1C21) HOCTL2B;
// Receive slave address 2 for channel B
volatile uint8_t __xdata __at(0x1C44) RESLADR2B;
// SMCLK timing setting for channel B
volatile uint8_t __xdata __at(0x1C41) SCLKTSB;
// Timing registers
volatile uint8_t __xdata __at(0x1C22) SMB4P7USL;
volatile uint8_t __xdata __at(0x1C23) SMB4P0USL;
volatile uint8_t __xdata __at(0x1C24) SMB300NS;
volatile uint8_t __xdata __at(0x1C25) SMB250NS;
volatile uint8_t __xdata __at(0x1C26) SMB25MS;
volatile uint8_t __xdata __at(0x1C27) SMB45P3USL;
volatile uint8_t __xdata __at(0x1C28) SMB45P3USH;
#endif // _EC_SMBUS_H

View File

@ -1,6 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
static __code const unsigned char __at(0x40) SIGNATURE[16] = {
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0x94,
0x85, 0x12, 0x5A, 0x5A, 0xAA, 0x00, 0x55, 0x55,
};

View File

@ -6,13 +6,18 @@
#include <common/macro.h>
void ec_init(void) {
RSTS = 0x44;
#ifdef it8587e
RSTS = (0b10U << 6) | BIT(2);
#else
RSTS = (0b01U << 6) | BIT(2);
// Enable POST codes
SPCTRL1 |= BIT(7) | BIT(6) | BIT(3);
#endif
}
void ec_read_post_codes(void) {
#ifdef it5570e
while (P80H81HS & 1) {
uint8_t p80h = P80HD;
uint8_t p81h = P81HD;
@ -20,4 +25,5 @@ void ec_read_post_codes(void) {
DEBUG("POST %02X%02X\n", p81h, p80h);
}
#endif
}

View File

@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <common/debug.h>
#include <ec/espi.h>
#ifdef it5570e
// Not all wires are defined or implemented
// Index 2 - AP to EC
struct VirtualWire __code VW_SLP_S3_N = VIRTUAL_WIRE(2, 0);
@ -61,3 +62,5 @@ void vw_set(struct VirtualWire * vw, enum VirtualWireState state) __critical {
}
*vw->index = index;
}
#endif // it5570e

View File

@ -32,6 +32,7 @@ struct I2C __code I2C_1 = {
.trasla = TRASLAB,
};
#ifdef it5570e
struct I2C __code I2C_4 = {
.hosta = HOSTAE,
.hoctl = HOCTLE,
@ -39,6 +40,7 @@ struct I2C __code I2C_4 = {
.hobdb = HOBDBE,
.trasla = TRASLAE,
};
#endif
void i2c_reset(struct I2C * i2c, bool kill) {
if (*(i2c->hosta) & HOSTA_BUSY) {

View File

@ -2,11 +2,15 @@
#ifndef _EC_ESPI_H
#define _EC_ESPI_H
#include <stdint.h>
// eSPI not supported on IT8587E, may not be used on IT5570E
#ifndef EC_ESPI
#define EC_ESPI 0
#endif // EC_ESPI
#endif
#include <stdint.h>
#ifdef it5570e
struct VirtualWire {
volatile uint8_t __xdata * index;
@ -120,4 +124,6 @@ volatile uint8_t __xdata __at(0x3293) VWCTRL3;
volatile uint8_t __xdata __at(0x3295) VWCTRL5;
volatile uint8_t __xdata __at(0x3296) VWCTRL6;
#endif // it5570e
#endif // _EC_ESPI_H

View File

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

View File

@ -50,9 +50,11 @@ volatile uint8_t __xdata __at(0x16FE) GCR15;
volatile uint8_t __xdata __at(0x16E0) GCR16;
volatile uint8_t __xdata __at(0x16E1) GCR17;
volatile uint8_t __xdata __at(0x16E2) GCR18;
#ifdef it5570e
volatile uint8_t __xdata __at(0x16E4) GCR19;
volatile uint8_t __xdata __at(0x16E5) GCR20;
volatile uint8_t __xdata __at(0x16E6) GCR21;
#endif
volatile uint8_t __xdata __at(0x1601) GPDRA;
volatile uint8_t __xdata __at(0x1602) GPDRB;

View File

@ -7,7 +7,9 @@
extern struct I2C __code I2C_0;
extern struct I2C __code I2C_1;
#ifdef it5570e
extern struct I2C __code I2C_4;
#endif
void i2c_reset(struct I2C * i2c, bool kill);

View File

@ -0,0 +1,29 @@
// SPDX-License-Identifier: GPL-3.0-only
#ifndef _EC_SCRATCH_H
#define _EC_SCRATCH_H
#include <stdint.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;
#ifdef it8587e
// SCAR1 is in xram at 0x800-0xC00
volatile uint8_t __xdata __at(0x1043) SCAR1L;
volatile uint8_t __xdata __at(0x1044) SCAR1M;
volatile uint8_t __xdata __at(0x1045) SCAR1H;
#endif
#ifdef it8587e
#define SCARL SCAR1L
#define SCARM SCAR1M
#define SCARH SCAR1H
#else
#define SCARL SCAR0L
#define SCARM SCAR0M
#define SCARH SCAR0H
#endif
#endif // _EC_SCRATCH_H

View File

@ -95,6 +95,7 @@ volatile uint8_t __xdata __at(0x1C44) RESLADR2B;
// SMCLK timing setting for channel B
volatile uint8_t __xdata __at(0x1C41) SCLKTSB;
#ifdef it5570e
// Host status for channel E
volatile uint8_t __xdata __at(0x1CA0) HOSTAE;
// Host control for channel E
@ -117,6 +118,7 @@ volatile uint8_t __xdata __at(0x1CA9) SMBPCTLE;
volatile uint8_t __xdata __at(0x1CAA) HOCTL2E;
// SMCLK timing setting for channel E
volatile uint8_t __xdata __at(0x1CAB) SCLKTSE;
#endif
// Timing registers
volatile uint8_t __xdata __at(0x1C22) SMB4P7USL;