diff options
author | Jun Lin <CHLin56@nuvoton.com> | 2022-10-20 17:24:07 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-24 03:44:24 +0000 |
commit | 7ab0fe87dd235e92e87ab81afd820b42b32f2cab (patch) | |
tree | 52de65025c0c10e82bb1bc60fd650010223b6d24 /chip | |
parent | 0bcc79f4ba3517488c0e7c35cd1138eacfdd500f (diff) | |
download | chrome-ec-7ab0fe87dd235e92e87ab81afd820b42b32f2cab.tar.gz |
gpio: npcx: fix incorrect report from gpio_get_flags_by_mask
The current driver reports the configured level regardless of the GPIO's
direction (input/output). It should report it only when the pin in
question is an output. Also, it should read the level from the PxDOUT
register instead of the PXDIN register.
BRANCH=none
BUG=b:254739925
TEST=build npcx9_evb with CONFIG_GPIO_GET_EXTENDED and
CONFIG_CMD_GPIO_EXTENDED defined, check the report form `gpioget`
console command is correct.
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Change-Id: I1f40bb757c1a012697374b294b57934608d5e293
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3967955
Tested-by: CH Lin <chlin56@nuvoton.corp-partner.google.com>
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Andrew McRae <amcrae@google.com>
Commit-Queue: CH Lin <chlin56@nuvoton.com>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/npcx/gpio.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c index 690615729d..4127b79e30 100644 --- a/chip/npcx/gpio.c +++ b/chip/npcx/gpio.c @@ -354,10 +354,12 @@ int gpio_get_flags_by_mask(uint32_t port, uint32_t mask) else flags |= GPIO_INPUT; - if (NPCX_PDIN(port) & mask) - flags |= GPIO_HIGH; - else - flags |= GPIO_LOW; + if (flags & GPIO_OUTPUT) { + if (NPCX_PDOUT(port) & mask) + flags |= GPIO_HIGH; + else + flags |= GPIO_LOW; + } if (NPCX_PTYPE(port) & mask) flags |= GPIO_OPEN_DRAIN; |