diff --git a/src/board/system76/galp3-c/include/board/pnp.h b/src/board/system76/galp3-c/include/board/pnp.h new file mode 100644 index 0000000..53dbb68 --- /dev/null +++ b/src/board/system76/galp3-c/include/board/pnp.h @@ -0,0 +1,6 @@ +#ifndef _BOARD_PNP_H +#define _BOARD_PNP_H + +void pnp_enable(void); + +#endif // _BOARD_PNP_H diff --git a/src/board/system76/galp3-c/pnp.c b/src/board/system76/galp3-c/pnp.c new file mode 100644 index 0000000..c22422f --- /dev/null +++ b/src/board/system76/galp3-c/pnp.c @@ -0,0 +1,43 @@ +#include + +#include + +volatile uint8_t __xdata __at(0x1200) IHIOA; +volatile uint8_t __xdata __at(0x1201) IHD; +volatile uint8_t __xdata __at(0x1204) IBMAE; +volatile uint8_t __xdata __at(0x1205) IBCTL; +void e2ci_write(uint8_t port, uint8_t data) { + while (IBCTL & ((1 << 2) | (1 << 1))) {} + IHIOA = port; + IHD = data; + IBMAE = 1; + IBCTL = 1; + while (IBCTL & (1 << 2)) {} + IBMAE = 0; + IBCTL = 0; +} + +void pnp_write(uint8_t reg, uint8_t data) { + e2ci_write(0x2E, reg); + e2ci_write(0x2F, data); +} + +void pnp_enable() { + DEBUG("Enable PNP devices\n"); + + // Enable PMC + pnp_write(0x07, 0x11); + pnp_write(0x30, 0x01); + + // Enable KBC keyboard + pnp_write(0x07, 0x06); + pnp_write(0x30, 0x01); + + // Enable KBC mouse + pnp_write(0x07, 0x05); + pnp_write(0x30, 0x01); + + // Enable SWUC + pnp_write(0x07, 0x04); + pnp_write(0x30, 0x01); +}