Skip to content

Commit b16b161

Browse files
soburinashif
authored andcommitted
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 <[email protected]>
1 parent 188a42b commit b16b161

File tree

7 files changed

+123
-0
lines changed

7 files changed

+123
-0
lines changed

MAINTAINERS.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,6 +4354,7 @@ USB:
43544354
- samples/subsys/usb/
43554355
- subsys/usb/
43564356
- tests/subsys/usb/
4357+
- tests/drivers/build_all/usb/
43574358
- tests/drivers/usb/
43584359
- tests/drivers/udc/
43594360
- doc/connectivity/usb/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(build_all)
6+
7+
FILE(GLOB app_sources src/*.c)
8+
target_sources(app PRIVATE ${app_sources})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2024 TOKITA Hiroshi
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/ {
7+
test {
8+
#address-cells = <1>;
9+
#size-cells = <1>;
10+
11+
test_gpio: gpio@deadbeef {
12+
compatible = "vnd,gpio";
13+
gpio-controller;
14+
reg = <0xdeadbeef 0x1000>;
15+
#gpio-cells = <0x2>;
16+
status = "okay";
17+
};
18+
19+
test_i2c: i2c@11112222 {
20+
#address-cells = <1>;
21+
#size-cells = <0>;
22+
compatible = "vnd,i2c";
23+
reg = <0x11112222 0x1000>;
24+
status = "okay";
25+
clock-frequency = <100000>;
26+
27+
test_i2c_pi3usb9201: pi3usb9201@0 {
28+
compatible = "diodes,pi3usb9201";
29+
reg = <0x0>;
30+
charging-mode = "BC12_TYPE_NONE";
31+
intb-gpios = <&test_gpio 0 0>;
32+
};
33+
};
34+
};
35+
};

tests/drivers/build_all/usb/prj.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_TEST=y
2+
CONFIG_TEST_USERSPACE=y
3+
CONFIG_USB_BC12=y
4+
CONFIG_UHC_DRIVER=y
5+
CONFIG_GPIO=y
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2024 TOKITA Hiroshi
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/ {
7+
test {
8+
#address-cells = <1>;
9+
#size-cells = <1>;
10+
11+
test_gpio: gpio@deadbeef {
12+
compatible = "vnd,gpio";
13+
gpio-controller;
14+
reg = <0xdeadbeef 0x1000>;
15+
#gpio-cells = <0x2>;
16+
status = "okay";
17+
};
18+
19+
test_spi: spi@33334444 {
20+
#address-cells = <1>;
21+
#size-cells = <0>;
22+
compatible = "vnd,spi";
23+
reg = <0x33334444 0x1000>;
24+
status = "okay";
25+
clock-frequency = <2000000>;
26+
27+
/* one entry for every devices at spi.dtsi */
28+
cs-gpios = <&test_gpio 0 0>,
29+
<&test_gpio 0 0>,
30+
<&test_gpio 0 0>,
31+
<&test_gpio 0 0>,
32+
<&test_gpio 0 0>;
33+
34+
max3421e_spi: max3421e_spi@0 {
35+
compatible = "maxim,max3421e_spi";
36+
reg = <0>;
37+
spi-max-frequency = <5000000>;
38+
int-gpios = <&test_gpio 0 0>;
39+
status = "okay";
40+
};
41+
};
42+
};
43+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright © 2024 TOKITA Hiroshi
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
int main(void)
8+
{
9+
return 0;
10+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
common:
2+
build_only: true
3+
tags:
4+
- drivers
5+
- usb
6+
tests:
7+
drivers.usb.build.i2c:
8+
extra_args: DTC_OVERLAY_FILE="i2c_devices.overlay"
9+
extra_configs:
10+
- CONFIG_I2C=y
11+
platform_allow:
12+
- native_sim
13+
- native_sim/native/64
14+
15+
drivers.usb.build.spi:
16+
extra_args: DTC_OVERLAY_FILE="spi_devices.overlay"
17+
extra_configs:
18+
- CONFIG_SPI=y
19+
platform_allow:
20+
- native_sim
21+
- native_sim/native/64

0 commit comments

Comments
 (0)