From 8ac822e69ccc581c17f9a869cd88ccdf4f5f1ffd Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 24 Jan 2023 10:12:18 -0700 Subject: [PATCH] emul: Cleanup emul directory Avoid implementations in the subsys emul directory to keep the directory focused on emulator subsystem instead of consumers. Consumers should be implemented side-by-side to their drivers Signed-off-by: Yuval Peress --- drivers/eeprom/CMakeLists.txt | 2 ++ drivers/eeprom/Kconfig | 21 +++++++++++++++++++ .../eeprom/eeprom_at2x_emul.c | 0 drivers/fuel_gauge/sbs_gauge/CMakeLists.txt | 3 +++ drivers/sensor/sbs_gauge/CMakeLists.txt | 3 +++ drivers/sensor/sbs_gauge/Kconfig | 7 +++++++ .../sensor/sbs_gauge}/emul_sbs_gauge.c | 2 +- subsys/emul/CMakeLists.txt | 1 - subsys/emul/Kconfig | 7 ------- subsys/emul/i2c/CMakeLists.txt | 8 ------- subsys/emul/i2c/Kconfig | 12 ----------- .../eeprom/api/boards/native_posix.conf | 2 +- tests/drivers/fuel_gauge/sbs_gauge/prj.conf | 1 + 13 files changed, 39 insertions(+), 30 deletions(-) rename subsys/emul/i2c/emul_atmel_at24.c => drivers/eeprom/eeprom_at2x_emul.c (100%) rename {subsys/emul/i2c => drivers/sensor/sbs_gauge}/emul_sbs_gauge.c (99%) delete mode 100644 subsys/emul/i2c/CMakeLists.txt delete mode 100644 subsys/emul/i2c/Kconfig diff --git a/drivers/eeprom/CMakeLists.txt b/drivers/eeprom/CMakeLists.txt index 29448017d8..fd27835174 100644 --- a/drivers/eeprom/CMakeLists.txt +++ b/drivers/eeprom/CMakeLists.txt @@ -13,3 +13,5 @@ zephyr_library_sources_ifdef(CONFIG_EEPROM_EMULATOR eeprom_emulator.c) zephyr_library_sources_ifdef(CONFIG_EEPROM_TMP116 eeprom_tmp116.c) zephyr_library_sources_ifdef(CONFIG_EEPROM_XEC eeprom_mchp_xec.c) zephyr_library_sources_ifdef(CONFIG_EEPROM_FAKE eeprom_fake.c) + +zephyr_library_sources_ifdef(CONFIG_EEPROM_AT2X_EMUL eeprom_at2x_emul.c) diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig index f076f414fd..f4f1ac55c5 100644 --- a/drivers/eeprom/Kconfig +++ b/drivers/eeprom/Kconfig @@ -41,6 +41,27 @@ config EEPROM_AT2X Enable support for Atmel AT2x (and compatible) I2C/SPI EEPROMs. +config EEPROM_AT2X_EMUL + bool "Emulate an Atmel AT24 I2C chip" + depends on EMUL + help + This is an emulator for the Atmel AT24 series of I2C-attached EEPROMs. + + At present it only supports 8-bit addressing. The size of the EEPROM + is given by the 'size' property. See the binding for further details. + +config EMUL_EEPROM_AT2X + bool "[DEPRECATED] Emulate an Atmel AT24 I2C chip" + select EEPROM_AT2X_EMUL + select DEPRECATED + help + This is an emulator for the Atmel AT24 series of I2C-attached EEPROMs. + + At present it only supports 8-bit addressing. The size of the EEPROM + is given by the 'size' property. See the binding for further details. + + [DEPRECATED] Select EEPROM_AT2X_EMUL instead. + config EEPROM_AT24 bool "Atmel AT24 (and compatible) I2C EEPROM support" default y diff --git a/subsys/emul/i2c/emul_atmel_at24.c b/drivers/eeprom/eeprom_at2x_emul.c similarity index 100% rename from subsys/emul/i2c/emul_atmel_at24.c rename to drivers/eeprom/eeprom_at2x_emul.c diff --git a/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt b/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt index 5fdf28d3be..a0c311285e 100644 --- a/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt +++ b/drivers/fuel_gauge/sbs_gauge/CMakeLists.txt @@ -1,3 +1,6 @@ zephyr_library() zephyr_library_sources(sbs_gauge.c) + +zephyr_include_directories_ifdef(CONFIG_EMUL_SBS_GAUGE .) +zephyr_library_sources_ifdef(CONFIG_EMUL_SBS_GAUGE ../../sensor/sbs_gauge/emul_sbs_gauge.c) diff --git a/drivers/sensor/sbs_gauge/CMakeLists.txt b/drivers/sensor/sbs_gauge/CMakeLists.txt index 5fdf28d3be..5d62cd13b3 100644 --- a/drivers/sensor/sbs_gauge/CMakeLists.txt +++ b/drivers/sensor/sbs_gauge/CMakeLists.txt @@ -1,3 +1,6 @@ zephyr_library() zephyr_library_sources(sbs_gauge.c) + +zephyr_include_directories_ifdef(CONFIG_EMUL_SBS_GAUGE .) +zephyr_library_sources_ifdef(CONFIG_EMUL_SBS_GAUGE emul_sbs_gauge.c) diff --git a/drivers/sensor/sbs_gauge/Kconfig b/drivers/sensor/sbs_gauge/Kconfig index 51d4bed6f7..58be1e519e 100644 --- a/drivers/sensor/sbs_gauge/Kconfig +++ b/drivers/sensor/sbs_gauge/Kconfig @@ -8,3 +8,10 @@ config SBS_GAUGE select I2C help Enable I2C-based/SMBus-based driver for a Smart Battery Fuel Gauge. + +config EMUL_SBS_GAUGE + bool "Emulate an SBS 1.1 compliant smart battery fuel gauge" + depends on EMUL + help + It provides readings which follow a simple sequence, thus allowing + test code to check that things are working as expected. diff --git a/subsys/emul/i2c/emul_sbs_gauge.c b/drivers/sensor/sbs_gauge/emul_sbs_gauge.c similarity index 99% rename from subsys/emul/i2c/emul_sbs_gauge.c rename to drivers/sensor/sbs_gauge/emul_sbs_gauge.c index c0a39fda47..893284fbd8 100644 --- a/subsys/emul/i2c/emul_sbs_gauge.c +++ b/drivers/sensor/sbs_gauge/emul_sbs_gauge.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(sbs_sbs_gauge); #include #include -#include +#include "sbs_gauge.h" /** Run-time data used by the emulator */ struct sbs_gauge_emul_data { diff --git a/subsys/emul/CMakeLists.txt b/subsys/emul/CMakeLists.txt index 991227621f..ea8b6401e6 100644 --- a/subsys/emul/CMakeLists.txt +++ b/subsys/emul/CMakeLists.txt @@ -4,5 +4,4 @@ zephyr_library() zephyr_library_sources_ifdef(CONFIG_EMUL emul.c) -add_subdirectory(i2c) add_subdirectory(espi) diff --git a/subsys/emul/Kconfig b/subsys/emul/Kconfig index d4cb80ec58..cca94429b5 100644 --- a/subsys/emul/Kconfig +++ b/subsys/emul/Kconfig @@ -34,13 +34,6 @@ module = EMUL module-str = emul source "subsys/logging/Kconfig.template.log_config" -config EMUL_SBS_GAUGE - bool "Emulate an SBS 1.1 compliant smart battery fuel gauge" - help - It provides readings which follow a simple sequence, thus allowing - test code to check that things are working as expected. - -source "subsys/emul/i2c/Kconfig" source "subsys/emul/espi/Kconfig" endif diff --git a/subsys/emul/i2c/CMakeLists.txt b/subsys/emul/i2c/CMakeLists.txt deleted file mode 100644 index 2786919eb0..0000000000 --- a/subsys/emul/i2c/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -# Once we have more than 10 devices we should consider splitting them into -# subdirectories to match the drivers/ structure. -zephyr_library_sources_ifdef(CONFIG_EMUL_EEPROM_AT2X emul_atmel_at24.c) - -zephyr_include_directories_ifdef(CONFIG_EMUL_SBS_GAUGE ${ZEPHYR_BASE}/drivers/sensor/sbs_gauge) -zephyr_library_sources_ifdef(CONFIG_EMUL_SBS_GAUGE emul_sbs_gauge.c) diff --git a/subsys/emul/i2c/Kconfig b/subsys/emul/i2c/Kconfig deleted file mode 100644 index 0a72f6f78b..0000000000 --- a/subsys/emul/i2c/Kconfig +++ /dev/null @@ -1,12 +0,0 @@ -# Configuration options for I2C emulators - -# Copyright 2020 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -config EMUL_EEPROM_AT2X - bool "Emulate an Atmel AT24 I2C chip" - help - This is an emulator for the Atmel AT24 series of I2C-attached EEPROMs. - - At present it only supports 8-bit addressing. The size of the EEPROM - is given by the 'size' property. See the binding for further details. diff --git a/tests/drivers/eeprom/api/boards/native_posix.conf b/tests/drivers/eeprom/api/boards/native_posix.conf index a131100e89..d29d163bfb 100644 --- a/tests/drivers/eeprom/api/boards/native_posix.conf +++ b/tests/drivers/eeprom/api/boards/native_posix.conf @@ -3,4 +3,4 @@ CONFIG_EMUL=y CONFIG_EEPROM_INIT_PRIORITY=75 -CONFIG_EMUL_EEPROM_AT2X=y +CONFIG_EEPROM_AT2X_EMUL=y diff --git a/tests/drivers/fuel_gauge/sbs_gauge/prj.conf b/tests/drivers/fuel_gauge/sbs_gauge/prj.conf index 23ceb0b3cd..cdbbc113c3 100644 --- a/tests/drivers/fuel_gauge/sbs_gauge/prj.conf +++ b/tests/drivers/fuel_gauge/sbs_gauge/prj.conf @@ -3,5 +3,6 @@ CONFIG_ZTEST_NEW_API=y CONFIG_I2C=y CONFIG_TEST_USERSPACE=y CONFIG_LOG=y +CONFIG_SENSOR=y CONFIG_FUEL_GAUGE=y