summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zephyr/CMakeLists.txt2
-rw-r--r--zephyr/Kconfig.adc13
-rw-r--r--zephyr/program/minimal/prj.conf2
-rw-r--r--zephyr/shim/src/CMakeLists.txt2
-rw-r--r--zephyr/shim/src/adc.c6
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;
}