Skip to content

Commit

Permalink
tests: drivers: build_all: Add a build_all test for usb
Browse files Browse the repository at this point in the history
The test targets the following devices at this time.

- diodes,pi3usb9201
- maxim,max3421e_spi

Signed-off-by: TOKITA Hiroshi <[email protected]>
  • Loading branch information
soburi committed Oct 21, 2024
1 parent 2f47de6 commit 8d07377
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
8 changes: 8 additions & 0 deletions tests/drivers/build_all/usb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
35 changes: 35 additions & 0 deletions tests/drivers/build_all/usb/i2c_devices.overlay
Original file line number Diff line number Diff line change
@@ -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>;
};
};
};
};
5 changes: 5 additions & 0 deletions tests/drivers/build_all/usb/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_TEST=y
CONFIG_TEST_USERSPACE=y
CONFIG_USB_BC12=y
CONFIG_UHC_DRIVER=y
CONFIG_GPIO=y
43 changes: 43 additions & 0 deletions tests/drivers/build_all/usb/spi_devices.overlay
Original file line number Diff line number Diff line change
@@ -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";
};
};
};
};
10 changes: 10 additions & 0 deletions tests/drivers/build_all/usb/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright © 2024 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/

int main(void)
{
return 0;
}
21 changes: 21 additions & 0 deletions tests/drivers/build_all/usb/testcase.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8d07377

Please sign in to comment.