From fc3bad29a2a31555bccaaacb6af6d20b7bb1b7f6 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Mon, 6 May 2024 15:57:54 -0600 Subject: [PATCH] pnp: Match EC2I programming guide Use the sequence specified by the flowcharts in the ITE manuals. Ref: IT5570E V0.3.2 datasheet; 7.15.5 EC2I Programming Guide Signed-off-by: Tim Crawford --- src/board/system76/common/pnp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/board/system76/common/pnp.c b/src/board/system76/common/pnp.c index f6cc4b7..abdf663 100644 --- a/src/board/system76/common/pnp.c +++ b/src/board/system76/common/pnp.c @@ -13,22 +13,29 @@ volatile uint8_t __xdata __at(0x1204) IBMAE; volatile uint8_t __xdata __at(0x1205) IBCTL; uint8_t ec2i_read(uint8_t port) { + uint8_t ihd; + while (IBCTL & (BIT(2) | BIT(1))) {} - IBCTL = 1; - IBMAE = 1; IHIOA = port; - IBCTL |= BIT(1); + IBMAE = BIT(0); + IBCTL = BIT(1); + IBCTL |= BIT(0); while (IBCTL & BIT(1)) {} - return IHD; + ihd = IHD; + IBMAE = 0; + IBCTL = 0; + return ihd; } void ec2i_write(uint8_t port, uint8_t data) { while (IBCTL & (BIT(2) | BIT(1))) {} - IBCTL = 1; - IBMAE = 1; IHIOA = port; IHD = data; + IBMAE = BIT(0); + IBCTL = BIT(0); while (IBCTL & BIT(2)) {} + IBMAE = 0; + IBCTL = 0; } uint8_t pnp_read(uint8_t reg) {