Move gpio_debug from board to EC code
The gpio_debug() functionality depends on the ITE registers and not anything board-specific. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Tim Crawford
parent
f687000a4f
commit
59c386ec12
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <ec/gpio.h>
|
||||
#include <common/debug.h>
|
||||
|
||||
bool gpio_get(struct Gpio *gpio) {
|
||||
if (*(gpio->data) & gpio->value) {
|
||||
@@ -17,3 +18,43 @@ void gpio_set(struct Gpio *gpio, bool value) {
|
||||
*(gpio->data) &= ~(gpio->value);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GPIO_DEBUG
|
||||
static 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: data %d mirror %d pot %d control %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);
|
||||
#define GPOTM 0
|
||||
bank(M);
|
||||
#undef GPOTM
|
||||
#undef bank
|
||||
}
|
||||
#endif // GPIO_DEBUG
|
||||
|
@@ -35,6 +35,10 @@ struct Gpio {
|
||||
bool gpio_get(struct Gpio *gpio);
|
||||
void gpio_set(struct Gpio *gpio, bool value);
|
||||
|
||||
#ifdef GPIO_DEBUG
|
||||
void gpio_debug(void);
|
||||
#endif
|
||||
|
||||
volatile uint8_t __xdata __at(0x1600) GCR;
|
||||
volatile uint8_t __xdata __at(0x16F0) GCR1;
|
||||
volatile uint8_t __xdata __at(0x16F1) GCR2;
|
||||
|
Reference in New Issue
Block a user