diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2022-12-15 20:13:31 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-19 10:51:34 +0000 |
commit | 8d4c7c9afe575ff8bdffb170a6802aec134e1350 (patch) | |
tree | 60bfe89e5244cd671a14b414ba1b382f69c9db8f | |
parent | 7e5283549f8be6c3efb610b55e3e37ac1da0c5e7 (diff) | |
download | chrome-ec-8d4c7c9afe575ff8bdffb170a6802aec134e1350.tar.gz |
zephyr: adc: add a dedicated NAMED_ADC_CHANNELS option
Add a dedicated NAMED_ADC_CHANNELS option to decouple the platforms
setting from the Zephyr ADC one. This allows running tests for code that
uses only the Zephyr APIs without having to define named channels as
well.
Also allows dropping some #if guards that made no sense since they were
guarding a data structure used outside of the guard.
BRANCH=none
BUG=none
TEST=cq dry run
TEST=zmake compare-builds -a
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: I4193a8c41d3bfd684ec03407eee57660aba2c56c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4111644
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Sam Hurst <shurst@google.com>
-rw-r--r-- | zephyr/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/Kconfig.adc | 13 | ||||
-rw-r--r-- | zephyr/program/minimal/prj.conf | 2 | ||||
-rw-r--r-- | zephyr/shim/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/shim/src/adc.c | 6 |
5 files changed, 13 insertions, 12 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index aa6b979038..4856019886 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -185,7 +185,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_FIFO "${PLATFORM_EC}/common/motion_sense_fifo.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BODY_DETECTION "${PLATFORM_EC}/common/body_detection.c") -zephyr_library_sources_ifdef(CONFIG_ADC +zephyr_library_sources_ifdef(CONFIG_NAMED_ADC_CHANNELS "${PLATFORM_EC}/common/adc.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ALS_TCS3400 "${PLATFORM_EC}/driver/als_tcs3400.c") diff --git a/zephyr/Kconfig.adc b/zephyr/Kconfig.adc index 5efc1a9bd5..37245f5070 100644 --- a/zephyr/Kconfig.adc +++ b/zephyr/Kconfig.adc @@ -2,12 +2,14 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -config ADC +config NAMED_ADC_CHANNELS + bool "Named ADC Channels support" default y depends on DT_HAS_NAMED_ADC_CHANNELS_ENABLED + select ADC -# Note - CONFIG_ADC is defined in upstream Zephyr -if ADC +# Options using the named channels APIs. +if NAMED_ADC_CHANNELS # Chromium EC provides it's own "adc" command. Disable the Zephyr # built-in ADC shell command. @@ -24,6 +26,11 @@ config PLATFORM_EC_ADC_CMD EC_CMD_ADC_READ host command. Replaces generic Zephyr "adc" command. +endif # NAMED_ADC_CHANNELS + +# Options used by native drivers as well. +if ADC + config PLATFORM_EC_ADC_RESOLUTION int "ADC resolution" default 10 diff --git a/zephyr/program/minimal/prj.conf b/zephyr/program/minimal/prj.conf index bacb4fe288..159fe58f44 100644 --- a/zephyr/program/minimal/prj.conf +++ b/zephyr/program/minimal/prj.conf @@ -8,7 +8,7 @@ CONFIG_SHIMMED_TASKS=y CONFIG_SYSCON=y # Disable default features we don't want in a minimal example. -CONFIG_ADC=n +CONFIG_NAMED_ADC_CHANNELS=n CONFIG_PWM=n CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_KEYBOARD=n diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 0491d8c842..d2a35dda49 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -18,7 +18,7 @@ endif() zephyr_library_sources_ifdef(no_libgcc libgcc_${ARCH}.S) -zephyr_library_sources_ifdef(CONFIG_ADC adc.c) +zephyr_library_sources_ifdef(CONFIG_NAMED_ADC_CHANNELS adc.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY battery.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_RT9490 diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c index b448823eee..0041335662 100644 --- a/zephyr/shim/src/adc.c +++ b/zephyr/shim/src/adc.c @@ -16,9 +16,6 @@ LOG_MODULE_REGISTER(shim_adc, LOG_LEVEL_ERR); #error "Define only one 'adc' console command." #endif -#define HAS_NAMED_ADC_CHANNELS DT_NODE_EXISTS(DT_INST(0, named_adc_channels)) - -#if HAS_NAMED_ADC_CHANNELS #define ADC_CHANNEL_INIT(node_id) \ [ZSHIM_ADC_ID(node_id)] = { \ .name = DT_NODE_FULL_NAME(node_id), \ @@ -42,13 +39,11 @@ struct adc_t adc_channels[] = { DT_FOREACH_CHILD(DT_INST(0, named_adc_channels), const struct adc_t adc_channels[] = { DT_FOREACH_CHILD( DT_INST(0, named_adc_channels), ADC_CHANNEL_INIT) }; #endif -#endif /* named_adc_channels */ static int init_device_bindings(const struct device *device) { ARG_UNUSED(device); -#if HAS_NAMED_ADC_CHANNELS for (int i = 0; i < ARRAY_SIZE(adc_channels); i++) { if (!device_is_ready(adc_channels[i].dev)) k_oops(); @@ -56,7 +51,6 @@ static int init_device_bindings(const struct device *device) adc_channel_setup(adc_channels[i].dev, &adc_channels[i].channel_cfg); } -#endif return 0; } |