From 8d07377711f6825432d1c9347dbd532b07ca2b99 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Sat, 28 Sep 2024 12:56:10 +0900 Subject: [PATCH] tests: drivers: build_all: Add a build_all test for usb The test targets the following devices at this time. - diodes,pi3usb9201 - maxim,max3421e_spi Signed-off-by: TOKITA Hiroshi --- MAINTAINERS.yml | 1 + tests/drivers/build_all/usb/CMakeLists.txt | 8 ++++ .../drivers/build_all/usb/i2c_devices.overlay | 35 +++++++++++++++ tests/drivers/build_all/usb/prj.conf | 5 +++ .../drivers/build_all/usb/spi_devices.overlay | 43 +++++++++++++++++++ tests/drivers/build_all/usb/src/main.c | 10 +++++ tests/drivers/build_all/usb/testcase.yaml | 21 +++++++++ 7 files changed, 123 insertions(+) create mode 100644 tests/drivers/build_all/usb/CMakeLists.txt create mode 100644 tests/drivers/build_all/usb/i2c_devices.overlay create mode 100644 tests/drivers/build_all/usb/prj.conf create mode 100644 tests/drivers/build_all/usb/spi_devices.overlay create mode 100644 tests/drivers/build_all/usb/src/main.c create mode 100644 tests/drivers/build_all/usb/testcase.yaml diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index d93a3ed2392f2a..0cbed9f63f4454 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -4267,6 +4267,7 @@ USB: - samples/subsys/usb/ - subsys/usb/ - tests/subsys/usb/ + - tests/drivers/build_all/usb/ - tests/drivers/usb/ - tests/drivers/udc/ - doc/connectivity/usb/ diff --git a/tests/drivers/build_all/usb/CMakeLists.txt b/tests/drivers/build_all/usb/CMakeLists.txt new file mode 100644 index 00000000000000..518596a02f7800 --- /dev/null +++ b/tests/drivers/build_all/usb/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(build_all) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/drivers/build_all/usb/i2c_devices.overlay b/tests/drivers/build_all/usb/i2c_devices.overlay new file mode 100644 index 00000000000000..9f458d79d861fd --- /dev/null +++ b/tests/drivers/build_all/usb/i2c_devices.overlay @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 TOKITA Hiroshi + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + test { + #address-cells = <1>; + #size-cells = <1>; + + test_gpio: gpio@deadbeef { + compatible = "vnd,gpio"; + gpio-controller; + reg = <0xdeadbeef 0x1000>; + #gpio-cells = <0x2>; + status = "okay"; + }; + + test_i2c: i2c@11112222 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "vnd,i2c"; + reg = <0x11112222 0x1000>; + status = "okay"; + clock-frequency = <100000>; + + test_i2c_pi3usb9201: pi3usb9201@0 { + compatible = "diodes,pi3usb9201"; + reg = <0x0>; + charging-mode = "BC12_TYPE_NONE"; + intb-gpios = <&test_gpio 0 0>; + }; + }; + }; +}; diff --git a/tests/drivers/build_all/usb/prj.conf b/tests/drivers/build_all/usb/prj.conf new file mode 100644 index 00000000000000..b68e9de578d434 --- /dev/null +++ b/tests/drivers/build_all/usb/prj.conf @@ -0,0 +1,5 @@ +CONFIG_TEST=y +CONFIG_TEST_USERSPACE=y +CONFIG_USB_BC12=y +CONFIG_UHC_DRIVER=y +CONFIG_GPIO=y diff --git a/tests/drivers/build_all/usb/spi_devices.overlay b/tests/drivers/build_all/usb/spi_devices.overlay new file mode 100644 index 00000000000000..421d2894c82673 --- /dev/null +++ b/tests/drivers/build_all/usb/spi_devices.overlay @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 TOKITA Hiroshi + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + test { + #address-cells = <1>; + #size-cells = <1>; + + test_gpio: gpio@deadbeef { + compatible = "vnd,gpio"; + gpio-controller; + reg = <0xdeadbeef 0x1000>; + #gpio-cells = <0x2>; + status = "okay"; + }; + + test_spi: spi@33334444 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "vnd,spi"; + reg = <0x33334444 0x1000>; + status = "okay"; + clock-frequency = <2000000>; + + /* one entry for every devices at spi.dtsi */ + cs-gpios = <&test_gpio 0 0>, + <&test_gpio 0 0>, + <&test_gpio 0 0>, + <&test_gpio 0 0>, + <&test_gpio 0 0>; + + max3421e_spi: max3421e_spi@0 { + compatible = "maxim,max3421e_spi"; + reg = <0>; + spi-max-frequency = <5000000>; + int-gpios = <&test_gpio 0 0>; + status = "okay"; + }; + }; + }; +}; diff --git a/tests/drivers/build_all/usb/src/main.c b/tests/drivers/build_all/usb/src/main.c new file mode 100644 index 00000000000000..16e3d7c8a68696 --- /dev/null +++ b/tests/drivers/build_all/usb/src/main.c @@ -0,0 +1,10 @@ +/* + * Copyright © 2024 TOKITA Hiroshi + * + * SPDX-License-Identifier: Apache-2.0 + */ + +int main(void) +{ + return 0; +} diff --git a/tests/drivers/build_all/usb/testcase.yaml b/tests/drivers/build_all/usb/testcase.yaml new file mode 100644 index 00000000000000..a66f0445cb4f5e --- /dev/null +++ b/tests/drivers/build_all/usb/testcase.yaml @@ -0,0 +1,21 @@ +common: + build_only: true + tags: + - drivers + - usb +tests: + drivers.usb.build.i2c: + extra_args: DTC_OVERLAY_FILE="i2c_devices.overlay" + extra_configs: + - CONFIG_I2C=y + platform_allow: + - native_sim + - native_sim/native/64 + + drivers.usb.build.spi: + extra_args: DTC_OVERLAY_FILE="spi_devices.overlay" + extra_configs: + - CONFIG_SPI=y + platform_allow: + - native_sim + - native_sim/native/64