From 7753aff1b0a0f52448e9a3177e23dd984eb85754 Mon Sep 17 00:00:00 2001 From: Tomasz Michalec Date: Mon, 12 Apr 2021 15:15:41 +0200 Subject: zephyr: drivers: add CBI test suite CBI test suite uses EC code. It is required to use I2C and eeprom emulators for storage and GPIO emulator for write protect pin. The overlay.dts is extended with required devices. BUG=b:185205123 BRANCH=none TEST=run zmake drivers test Signed-off-by: Tomasz Michalec Change-Id: I2dc743b97aac0efa11624ebba4ac2e1b6811b847 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2821699 Reviewed-by: Jeremy Bettis --- zephyr/test/drivers/CMakeLists.txt | 2 ++ zephyr/test/drivers/overlay.dts | 30 +++++++++++++++++++++++++++++- zephyr/test/drivers/prj.conf | 2 ++ zephyr/test/drivers/src/main.c | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index cea2f5600a..3f796dd5a1 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -11,3 +11,5 @@ zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") FILE(GLOB test_sources src/*.c) target_sources(app PRIVATE ${test_sources}) + +target_sources(app PRIVATE "${PLATFORM_EC}/test/cbi.c") diff --git a/zephyr/test/drivers/overlay.dts b/zephyr/test/drivers/overlay.dts index f0faba8de1..6f25844438 100644 --- a/zephyr/test/drivers/overlay.dts +++ b/zephyr/test/drivers/overlay.dts @@ -19,6 +19,16 @@ enum-name = "GPIO_AC_PRESENT"; label = "ACOK_OD"; }; + /* In test WP is output because CBI use it, but it is also + * input, because test_all_tags set it to enable write + * protection. + */ + gpio_wp_l: wp_l { + #gpio-cells = <0>; + gpios = <&gpio0 3 (GPIO_INPUT | GPIO_OUTPUT)>; + enum-name = "GPIO_WP_L"; + label = "WP_L"; + }; }; named-i2c-ports { compatible = "named-i2c-ports"; @@ -43,6 +53,11 @@ enum-name = "I2C_PORT_CHARGER"; label = "CHARGER"; }; + eeprom { + i2c-port = <&i2c0>; + enum-name = "I2C_PORT_EEPROM"; + label = "EEPROM"; + }; }; named-batteries { @@ -55,5 +70,18 @@ }; &gpio0 { - ngpios = <3>; + ngpios = <4>; +}; + +&i2c0 { + cbi_eeprom: eeprom@56 { + compatible = "atmel,at24"; + reg = <0x56>; + label = "EEPROM_CBI"; + size = <512>; + pagesize = <8>; + address-width = <8>; + timeout = <5>; + wp-gpios = <&gpio_wp_l>; + }; }; diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 68aa484ddd..12df68d8e6 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -11,6 +11,7 @@ CONFIG_I2C=y CONFIG_I2C_EMUL=y CONFIG_GPIO=y CONFIG_GPIO_EMUL=y +CONFIG_EMUL_EEPROM_AT2X=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y @@ -32,6 +33,7 @@ CONFIG_PLATFORM_EC_HOSTCMD=y CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=y CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y +CONFIG_PLATFORM_EC_CBI=y # Things that default to on, but aren't working yet CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/test/drivers/src/main.c b/zephyr/test/drivers/src/main.c index 7c5113d4ab..04f6f55f0a 100644 --- a/zephyr/test/drivers/src/main.c +++ b/zephyr/test/drivers/src/main.c @@ -8,6 +8,7 @@ #include "ec_app_main.h" extern void test_suite_battery(void); +extern void test_suite_cbi(void); void test_main(void) { @@ -17,4 +18,5 @@ void test_main(void) /* Test suites to run after ec_app_main.*/ test_suite_battery(); + test_suite_cbi(); } -- cgit v1.2.1