diff options
author | Simon Glass <sjg@chromium.org> | 2021-03-22 10:39:59 +1300 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-23 23:38:21 +0000 |
commit | 9327c77b1ce762084b16a16233f79e7ac61161c4 (patch) | |
tree | 7f9c7fab87a8eb2c38c32ba44059a4505d1d8ad6 /zephyr | |
parent | daa8ac7486cbf6cff5230d0226a66513bcd34cbd (diff) | |
download | chrome-ec-9327c77b1ce762084b16a16233f79e7ac61161c4.tar.gz |
zephyr: Tidy up BATTERY_PRESENT_GPIO
This is not a boolean CONFIG in ECOS but it must be with Zephyr. There
doesn't seem to be any advantage to allowing an arbitrary name here,
since the mapping is controlled in the device tree anyway.
So hard-code it to GPIO_BATT_PRES_ODL and document this in the Kconfig.
Also drop the unnecessary logic in config_chip.h since Kconfig handles
ensuring that only one option is set. This makes the code easier to
follow and avoids errors. Fix the error that is there.
BUG=b:183296099
BRANCH=none
TEST=make BOARD=lazor -j4
Signed-off-by: Simon Glass <sjg@chromium.org>
Change-Id: I55a9083ad01be2f6b1e9314f73fbbff1442e486c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2777633
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/Kconfig.battery | 18 | ||||
-rw-r--r-- | zephyr/shim/include/config_chip.h | 11 |
2 files changed, 21 insertions, 8 deletions
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery index 3cfebbb129..396799ed96 100644 --- a/zephyr/Kconfig.battery +++ b/zephyr/Kconfig.battery @@ -55,11 +55,21 @@ config PLATFORM_EC_BATTERY_PRESENT_GPIO bool "Check a GPIO" help Use this method if a GPIO signals whether the battery is present. The - GPIO should read low if the battery is present, high if absent, + GPIO should read low if the battery is present, high if absent. - TODO: - The actual GPIO to use is not defined by this option. Perhaps this - needs to be placed in the devicetree. + The GPIO is hard-coded to GPIO_BATT_PRES_ODL so you should define this + in the device tree and GPIO map. The convention is to use the signal + name from schematic as both the node name and label for the GPIO. For + example: + + /* gpio.dts */ + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + label = "EC_BATT_PRES_ODL"; + }; + + /* gpio_map.h */ + #define GPIO_BATT_PRES_ODL NAMED_GPIO(ec_batt_pres_odl) endchoice # battery presence diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index d4384cb38c..4a921ba58e 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -146,12 +146,15 @@ enum battery_type { #endif #undef CONFIG_BATTERY_PRESENT_CUSTOM -#undef CONFIG_BATTERY_PRESENT_GPIO #ifdef CONFIG_PLATFORM_EC_BATTERY_PRESENT_CUSTOM #define CONFIG_BATTERY_PRESENT_CUSTOM -#elif defined(PLATFORM_EC_BATTERY_PRESENT_GPIO) -#define CONFIG_BATTERY_PRESENT_GPIO -#endif /* CONFIG_PLATFORM_EC_BATTERY_PRESENT_CUSTOM */ +#endif + +#undef CONFIG_BATTERY_PRESENT_GPIO +#ifdef CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO +/* This is always GPIO_BATT_PRES_ODL with Zephyr */ +#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BATT_PRES_ODL +#endif #undef CONFIG_BATTERY_CUT_OFF #ifdef CONFIG_PLATFORM_EC_BATTERY_CUT_OFF |