Update .clang-format and apply
Update .clang-format for LLVM 14.0, available on Ubuntu 22.04. There is still plenty that clang-format sucks at or does wrong, so either add some more blocks to disable it, or just put up with it. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
c3267fc4ad
commit
e032c5f0f2
@@ -35,30 +35,30 @@ struct VirtualWire __code VW_SUS_ACK_N = VIRTUAL_WIRE(40, 0);
|
||||
struct VirtualWire __code VW_SUS_WARN_N = VIRTUAL_WIRE(41, 0);
|
||||
struct VirtualWire __code VW_SUS_PWRDN_ACK = VIRTUAL_WIRE(41, 1);
|
||||
|
||||
enum VirtualWireState vw_get(struct VirtualWire * vw) __critical {
|
||||
enum VirtualWireState vw_get(struct VirtualWire *vw) __critical {
|
||||
uint8_t index = *vw->index;
|
||||
switch ((index >> vw->shift) & VWS_HIGH) {
|
||||
case VWS_LOW:
|
||||
return VWS_LOW;
|
||||
case VWS_HIGH:
|
||||
return VWS_HIGH;
|
||||
default:
|
||||
return VWS_INVALID;
|
||||
case VWS_LOW:
|
||||
return VWS_LOW;
|
||||
case VWS_HIGH:
|
||||
return VWS_HIGH;
|
||||
default:
|
||||
return VWS_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
void vw_set(struct VirtualWire * vw, enum VirtualWireState state) __critical {
|
||||
void vw_set(struct VirtualWire *vw, enum VirtualWireState state) __critical {
|
||||
uint8_t index = *vw->index;
|
||||
index &= ~(VWS_HIGH << vw->shift);
|
||||
switch (state) {
|
||||
case VWS_LOW:
|
||||
index |= VWS_LOW << vw->shift;
|
||||
break;
|
||||
case VWS_HIGH:
|
||||
index |= VWS_HIGH << vw->shift;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case VWS_LOW:
|
||||
index |= VWS_LOW << vw->shift;
|
||||
break;
|
||||
case VWS_HIGH:
|
||||
index |= VWS_HIGH << vw->shift;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*vw->index = index;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <ec/gpio.h>
|
||||
|
||||
bool gpio_get(struct Gpio * gpio) {
|
||||
bool gpio_get(struct Gpio *gpio) {
|
||||
if (*(gpio->data) & gpio->value) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -10,7 +10,7 @@ bool gpio_get(struct Gpio * gpio) {
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_set(struct Gpio * gpio, bool value) {
|
||||
void gpio_set(struct Gpio *gpio, bool value) {
|
||||
if (value) {
|
||||
*(gpio->data) |= gpio->value;
|
||||
} else {
|
||||
|
@@ -9,11 +9,11 @@
|
||||
#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;
|
||||
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 = {
|
||||
@@ -42,10 +42,11 @@ struct I2C __code I2C_4 = {
|
||||
};
|
||||
#endif
|
||||
|
||||
void i2c_reset(struct I2C * i2c, bool kill) {
|
||||
void i2c_reset(struct I2C *i2c, bool kill) {
|
||||
if (*(i2c->hosta) & HOSTA_BUSY) {
|
||||
// Set kill bit
|
||||
if (kill) *(i2c->hoctl) |= BIT(1);
|
||||
if (kill)
|
||||
*(i2c->hoctl) |= BIT(1);
|
||||
// Wait for host to finish
|
||||
while (*(i2c->hosta) & HOSTA_BUSY) {}
|
||||
}
|
||||
@@ -57,7 +58,7 @@ void i2c_reset(struct I2C * i2c, bool kill) {
|
||||
*(i2c->hoctl2) = 0;
|
||||
}
|
||||
|
||||
int16_t i2c_start(struct I2C * i2c, uint8_t addr, bool read) __reentrant {
|
||||
int16_t 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
|
||||
@@ -85,7 +86,7 @@ int16_t i2c_start(struct I2C * i2c, uint8_t addr, bool read) __reentrant {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void i2c_stop(struct I2C * i2c) {
|
||||
void i2c_stop(struct I2C *i2c) {
|
||||
// Disable i2c compatibility
|
||||
*(i2c->hoctl2) &= ~BIT(1);
|
||||
// Clear status
|
||||
@@ -94,7 +95,7 @@ void i2c_stop(struct I2C * i2c) {
|
||||
i2c_reset(i2c, false);
|
||||
}
|
||||
|
||||
static int16_t i2c_transaction(struct I2C * i2c, uint8_t * data, uint16_t length, bool read) {
|
||||
static int16_t i2c_transaction(struct I2C *i2c, uint8_t *data, uint16_t length, bool read) {
|
||||
uint16_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
if (read) {
|
||||
@@ -126,17 +127,17 @@ static int16_t i2c_transaction(struct I2C * i2c, uint8_t * data, uint16_t length
|
||||
// Wait for byte done, timeout, or error
|
||||
uint8_t status;
|
||||
uint32_t timeout = I2C_TIMEOUT;
|
||||
for(timeout = I2C_TIMEOUT; timeout > 0; 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 -(int16_t)(status);
|
||||
} else
|
||||
// If byte done, break
|
||||
if (status & HOSTA_BYTE_DONE) {
|
||||
break;
|
||||
}
|
||||
// If byte done, break
|
||||
if (status & HOSTA_BYTE_DONE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If timeout occured, kill transaction and return error
|
||||
if (timeout == 0) {
|
||||
@@ -153,10 +154,10 @@ static int16_t i2c_transaction(struct I2C * i2c, uint8_t * data, uint16_t length
|
||||
return i;
|
||||
}
|
||||
|
||||
int16_t i2c_read(struct I2C * i2c, uint8_t * data, uint16_t length) __reentrant {
|
||||
int16_t i2c_read(struct I2C *i2c, uint8_t *data, uint16_t length) __reentrant {
|
||||
return i2c_transaction(i2c, data, length, true);
|
||||
}
|
||||
|
||||
int16_t i2c_write(struct I2C * i2c, uint8_t * data, uint16_t length) __reentrant {
|
||||
int16_t i2c_write(struct I2C *i2c, uint8_t *data, uint16_t length) __reentrant {
|
||||
return i2c_transaction(i2c, data, length, false);
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
struct VirtualWire {
|
||||
volatile uint8_t __xdata * index;
|
||||
volatile uint8_t __xdata *index;
|
||||
uint8_t shift;
|
||||
};
|
||||
|
||||
@@ -23,9 +23,9 @@ enum VirtualWireState {
|
||||
VWS_HIGH = 0x11,
|
||||
};
|
||||
|
||||
enum VirtualWireState vw_get(struct VirtualWire * vw) __critical;
|
||||
enum VirtualWireState vw_get(struct VirtualWire *vw) __critical;
|
||||
|
||||
void vw_set(struct VirtualWire * vw, enum VirtualWireState state) __critical;
|
||||
void vw_set(struct VirtualWire *vw, enum VirtualWireState state) __critical;
|
||||
|
||||
// Not all wires are defined or implemented
|
||||
// Index 2 - AP to EC
|
||||
|
@@ -8,16 +8,18 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// clang-format off
|
||||
#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)
|
||||
// clang-format on
|
||||
|
||||
struct Gpio {
|
||||
volatile uint8_t __xdata * data;
|
||||
volatile uint8_t __xdata * mirror;
|
||||
volatile uint8_t __xdata * control;
|
||||
volatile uint8_t __xdata *data;
|
||||
volatile uint8_t __xdata *mirror;
|
||||
volatile uint8_t __xdata *control;
|
||||
uint8_t value;
|
||||
};
|
||||
|
||||
@@ -30,8 +32,8 @@ struct Gpio {
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
bool gpio_get(struct Gpio * gpio);
|
||||
void gpio_set(struct Gpio * gpio, bool value);
|
||||
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;
|
||||
|
@@ -11,6 +11,6 @@ extern struct I2C __code I2C_1;
|
||||
extern struct I2C __code I2C_4;
|
||||
#endif
|
||||
|
||||
void i2c_reset(struct I2C * i2c, bool kill);
|
||||
void i2c_reset(struct I2C *i2c, bool kill);
|
||||
|
||||
#endif // _EC_I2C_H
|
||||
|
@@ -12,17 +12,17 @@ void kbc_init(void);
|
||||
|
||||
struct Kbc {
|
||||
// Control register
|
||||
volatile uint8_t * control;
|
||||
volatile uint8_t *control;
|
||||
// Interrupt control register
|
||||
volatile uint8_t * irq;
|
||||
volatile uint8_t *irq;
|
||||
// Status register
|
||||
volatile uint8_t * status;
|
||||
volatile uint8_t *status;
|
||||
// Keyboard out register
|
||||
volatile uint8_t * keyboard_out;
|
||||
volatile uint8_t *keyboard_out;
|
||||
// Mouse out register
|
||||
volatile uint8_t * mouse_out;
|
||||
volatile uint8_t *mouse_out;
|
||||
// Data in register
|
||||
volatile uint8_t * data_in;
|
||||
volatile uint8_t *data_in;
|
||||
};
|
||||
|
||||
extern struct Kbc __code KBC;
|
||||
@@ -31,10 +31,10 @@ extern struct Kbc __code KBC;
|
||||
#define KBC_STS_IBF BIT(1)
|
||||
#define KBC_STS_CMD BIT(3)
|
||||
|
||||
uint8_t kbc_status(struct Kbc * kbc);
|
||||
uint8_t kbc_read(struct Kbc * kbc);
|
||||
bool kbc_keyboard(struct Kbc * kbc, uint8_t data, uint16_t timeout);
|
||||
bool kbc_mouse(struct Kbc * kbc, uint8_t data, uint16_t timeout);
|
||||
uint8_t kbc_status(struct Kbc *kbc);
|
||||
uint8_t kbc_read(struct Kbc *kbc);
|
||||
bool kbc_keyboard(struct Kbc *kbc, uint8_t data, uint16_t timeout);
|
||||
bool kbc_mouse(struct Kbc *kbc, uint8_t data, uint16_t timeout);
|
||||
|
||||
volatile uint8_t __xdata __at(0x1300) KBHICR;
|
||||
volatile uint8_t __xdata __at(0x1302) KBIRQR;
|
||||
|
@@ -10,13 +10,13 @@
|
||||
|
||||
struct Pmc {
|
||||
// Status register
|
||||
volatile uint8_t * status;
|
||||
volatile uint8_t *status;
|
||||
// Data out register
|
||||
volatile uint8_t * data_out;
|
||||
volatile uint8_t *data_out;
|
||||
// Data in register
|
||||
volatile uint8_t * data_in;
|
||||
volatile uint8_t *data_in;
|
||||
// Control register
|
||||
volatile uint8_t * control;
|
||||
volatile uint8_t *control;
|
||||
};
|
||||
|
||||
extern struct Pmc __code PMC_1;
|
||||
@@ -29,10 +29,10 @@ extern struct Pmc __code PMC_5;
|
||||
#define PMC_STS_IBF BIT(1)
|
||||
#define PMC_STS_CMD BIT(3)
|
||||
|
||||
uint8_t pmc_status(struct Pmc * pmc);
|
||||
void pmc_set_status(struct Pmc * pmc, uint8_t status);
|
||||
uint8_t pmc_read(struct Pmc * pmc);
|
||||
void pmc_write(struct Pmc * pmc, uint8_t data);
|
||||
uint8_t pmc_status(struct Pmc *pmc);
|
||||
void pmc_set_status(struct Pmc *pmc, uint8_t status);
|
||||
uint8_t pmc_read(struct Pmc *pmc);
|
||||
void pmc_write(struct Pmc *pmc, uint8_t data);
|
||||
|
||||
volatile uint8_t __xdata __at(0x1500) PM1STS;
|
||||
volatile uint8_t __xdata __at(0x1501) PM1DO;
|
||||
|
@@ -12,17 +12,17 @@
|
||||
#define PSSTS_DONE BIT(3)
|
||||
|
||||
struct Ps2 {
|
||||
volatile uint8_t * control;
|
||||
volatile uint8_t * interrupt;
|
||||
volatile uint8_t * status;
|
||||
volatile uint8_t * data;
|
||||
volatile uint8_t *control;
|
||||
volatile uint8_t *interrupt;
|
||||
volatile uint8_t *status;
|
||||
volatile uint8_t *data;
|
||||
};
|
||||
|
||||
extern struct Ps2 __code PS2_1;
|
||||
extern struct Ps2 __code PS2_2;
|
||||
extern struct Ps2 __code PS2_3;
|
||||
|
||||
void ps2_reset(struct Ps2 * ps2);
|
||||
void ps2_reset(struct Ps2 *ps2);
|
||||
|
||||
volatile uint8_t __xdata __at(0x1700) PSCTL1;
|
||||
volatile uint8_t __xdata __at(0x1701) PSCTL2;
|
||||
|
@@ -17,13 +17,13 @@ volatile uint8_t __xdata __at(0x1045) SCAR1H;
|
||||
#endif
|
||||
|
||||
#if CONFIG_EC_ITE_IT8587E
|
||||
#define SCARL SCAR1L
|
||||
#define SCARM SCAR1M
|
||||
#define SCARH SCAR1H
|
||||
#define SCARL SCAR1L
|
||||
#define SCARM SCAR1M
|
||||
#define SCARH SCAR1H
|
||||
#else
|
||||
#define SCARL SCAR0L
|
||||
#define SCARM SCAR0M
|
||||
#define SCARH SCAR0H
|
||||
#define SCARL SCAR0L
|
||||
#define SCARM SCAR0M
|
||||
#define SCARH SCAR0H
|
||||
#endif
|
||||
|
||||
#endif // _EC_SCRATCH_H
|
||||
|
@@ -12,32 +12,35 @@ struct Kbc __code KBC = {
|
||||
.data_in = &KBHIDIR,
|
||||
};
|
||||
|
||||
uint8_t kbc_status(struct Kbc * kbc) {
|
||||
uint8_t kbc_status(struct Kbc *kbc) {
|
||||
return *(kbc->status);
|
||||
}
|
||||
|
||||
uint8_t kbc_read(struct Kbc * kbc) {
|
||||
uint8_t kbc_read(struct Kbc *kbc) {
|
||||
return *(kbc->data_in);
|
||||
}
|
||||
|
||||
static bool kbc_wait(struct Kbc * kbc, uint16_t timeout) {
|
||||
static bool kbc_wait(struct Kbc *kbc, uint16_t timeout) {
|
||||
while (*(kbc->status) & KBC_STS_OBF) {
|
||||
if (timeout == 0) return false;
|
||||
if (timeout == 0)
|
||||
return false;
|
||||
timeout -= 1;
|
||||
delay_us(1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool kbc_keyboard(struct Kbc * kbc, uint8_t data, uint16_t timeout) {
|
||||
if (!kbc_wait(kbc, timeout)) return false;
|
||||
bool kbc_keyboard(struct Kbc *kbc, uint8_t data, uint16_t timeout) {
|
||||
if (!kbc_wait(kbc, timeout))
|
||||
return false;
|
||||
*(kbc->status) &= ~0x20;
|
||||
*(kbc->keyboard_out) = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool kbc_mouse(struct Kbc * kbc, uint8_t data, uint16_t timeout) {
|
||||
if (!kbc_wait(kbc, timeout)) return false;
|
||||
bool kbc_mouse(struct Kbc *kbc, uint8_t data, uint16_t timeout) {
|
||||
if (!kbc_wait(kbc, timeout))
|
||||
return false;
|
||||
*(kbc->status) |= 0x20;
|
||||
*(kbc->mouse_out) = data;
|
||||
return true;
|
||||
|
@@ -17,18 +17,18 @@ struct Pmc __code PMC_3 = PMC(3);
|
||||
struct Pmc __code PMC_4 = PMC(4);
|
||||
struct Pmc __code PMC_5 = PMC(5);
|
||||
|
||||
uint8_t pmc_status(struct Pmc * pmc) {
|
||||
uint8_t pmc_status(struct Pmc *pmc) {
|
||||
return *(pmc->status);
|
||||
}
|
||||
|
||||
void pmc_set_status(struct Pmc * pmc, uint8_t status) {
|
||||
void pmc_set_status(struct Pmc *pmc, uint8_t status) {
|
||||
*(pmc->status) = status;
|
||||
}
|
||||
|
||||
uint8_t pmc_read(struct Pmc * pmc) {
|
||||
uint8_t pmc_read(struct Pmc *pmc) {
|
||||
return *(pmc->data_in);
|
||||
}
|
||||
|
||||
void pmc_write(struct Pmc * pmc, uint8_t data) {
|
||||
void pmc_write(struct Pmc *pmc, uint8_t data) {
|
||||
*(pmc->data_out) = data;
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ struct Ps2 __code PS2_1 = PS2(1);
|
||||
struct Ps2 __code PS2_2 = PS2(2);
|
||||
struct Ps2 __code PS2_3 = PS2(3);
|
||||
|
||||
void ps2_reset(struct Ps2 * ps2) {
|
||||
void ps2_reset(struct Ps2 *ps2) {
|
||||
// Reset interface to defaults
|
||||
*(ps2->control) = 1;
|
||||
// Clear status
|
||||
|
Reference in New Issue
Block a user