-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: scripts: extract_dts_includes.py pinctrl directive
Test correct generation of defines for the pinctrl directive in device trees. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
- Loading branch information
Showing
14 changed files
with
941 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (c) 2018 Bobby Noelte <b0661n0e17e@gmail.com> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Prepare generic unit test environment | ||
# | ||
# parameters: | ||
# - INCLUDE is relative to zephyr base | ||
# - SOURCES defaults to main.c | ||
# | ||
# target: | ||
# - testbinary (default) | ||
list(APPEND INCLUDE subsys) # for ztest | ||
include($ENV{ZEPHYR_BASE}/tests/unit/unittest.cmake) | ||
|
||
# Fake zephyr environment to prepare the | ||
# generation of include/generated/generated_dts_board.h from DTS | ||
set(ZEPHYR_BASE $ENV{ZEPHYR_BASE}) | ||
set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
set(PROJECT_SOURCE_DIR ${ZEPHYR_BASE}) | ||
set(ARCH host) | ||
set(BOARD_FAMILY host) | ||
set(BOARD host) | ||
set(CONFIG_HAS_DTS True) | ||
set(APPLICATION_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
include(${ZEPHYR_BASE}/cmake/extensions.cmake) | ||
|
||
# Get the tools for DTS - python and DTC | ||
find_package(PythonInterp 3.4) | ||
include(${ZEPHYR_BASE}/cmake/host-tools.cmake) | ||
|
||
# Generate include/generated/generated_dts_board.h from DTS | ||
file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/include/generated) | ||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/generated) | ||
set(AUTOCONF_H ${APPLICATION_SOURCE_DIR}/autoconf.h) | ||
set(DTS_SOURCE ${APPLICATION_SOURCE_DIR}/dts/test.dts) | ||
|
||
set(DTS_BINDINGS_DIR ${APPLICATION_SOURCE_DIR}/bindings) | ||
include(${ZEPHYR_BASE}/cmake/dts.cmake) | ||
|
||
|
||
# Make test aware of | ||
# - dts bindings header files | ||
# - generated include file | ||
target_include_directories(testbinary PRIVATE | ||
${DTS_BINDINGS_DIR} | ||
${PROJECT_BINARY_DIR}/include | ||
${PROJECT_BINARY_DIR}/include/generated | ||
) | ||
|
||
project(none) # switches PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR |
Empty file.
32 changes: 32 additions & 0 deletions
32
tests/unit/scripts/extract_dts_includes/bindings/arm,v7m-nvic.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: ARM Cortex M4 NVIC Interrupt Controller | ||
version: 0.1 | ||
|
||
description: > | ||
This binding describes the ARM Cortex M4 NVIC IRQ controller | ||
properties: | ||
compatible: | ||
category: required | ||
type: string | ||
description: compatible strings | ||
constraint: "arm,v7m-nvic" | ||
|
||
reg: | ||
category: required | ||
type: int | ||
description: mmio register space | ||
generation: define | ||
|
||
arm,num-irq-priority-bits: | ||
category: required | ||
type: int | ||
description: number of bits of IRQ priorities | ||
generation: define | ||
|
||
cell_string: IRQ | ||
|
||
"#cells": | ||
- irq | ||
- priority | ||
... |
64 changes: 64 additions & 0 deletions
64
tests/unit/scripts/extract_dts_includes/bindings/test,device.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Test Device | ||
id: test,device | ||
version: 0.1 | ||
|
||
description: > | ||
This binding gives a base representation of the test device | ||
properties: | ||
compatible: | ||
type: string | ||
category: required | ||
description: compatible strings | ||
constraint: "test,device" | ||
generation: define | ||
|
||
label: | ||
type: string | ||
category: required | ||
description: Human readable string describing the device | ||
generation: define | ||
|
||
reg: | ||
type: array | ||
description: mmio register space | ||
generation: define | ||
category: required | ||
|
||
interrupts: | ||
type: array | ||
category: required | ||
description: required interrupts | ||
generation: define | ||
|
||
clocks: | ||
type: array | ||
category: required | ||
description: Clock gate control information | ||
generation: define | ||
|
||
clock-frequency: | ||
type: int | ||
category: optional | ||
description: Clock frequency information for UART operation | ||
generation: define | ||
|
||
current-speed: | ||
type: int | ||
category: required | ||
description: Initial baud rate setting for UART | ||
generation: define | ||
|
||
interrupt-names: | ||
type: stringlist | ||
category: optional | ||
description: names of required interrupts | ||
generation: define | ||
|
||
pinctrl-\d+: | ||
type: array | ||
category: optional | ||
description: pinctrl information | ||
generation: define | ||
... |
46 changes: 46 additions & 0 deletions
46
tests/unit/scripts/extract_dts_includes/bindings/test,gpio.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: TEST GPIO | ||
id: test,gpio | ||
version: 0.1 | ||
|
||
description: > | ||
This binding gives a base representation of the TEST GPIO | ||
properties: | ||
compatible: | ||
type: string | ||
category: required | ||
description: compatible strings | ||
constraint: "test,gpio" | ||
generation: define | ||
|
||
gpio-controller: | ||
type: string | ||
category: required | ||
description: device controller identification | ||
generation: define | ||
|
||
label: | ||
type: string | ||
category: required | ||
description: Human readable string describing the device | ||
generation: define | ||
|
||
reg: | ||
type: array | ||
description: mmio register space | ||
generation: define | ||
category: required | ||
|
||
interrupts: | ||
type: array | ||
category: required | ||
description: required interrupts | ||
generation: define | ||
|
||
gpio-ranges: | ||
type: array | ||
category: required | ||
description: gpio range in pin controller | ||
generation: define | ||
... |
35 changes: 35 additions & 0 deletions
35
tests/unit/scripts/extract_dts_includes/bindings/test,pinctrl.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: TEST PINCTRL | ||
id: test,pinctrl | ||
version: 0.1 | ||
|
||
description: > | ||
This binding gives a base representation of the TEST PINCTRL device | ||
properties: | ||
compatible: | ||
type: string | ||
category: required | ||
description: compatible strings | ||
constraint: "test,pinctrl" | ||
generation: define | ||
|
||
pin-controller: | ||
type: string | ||
category: required | ||
description: device controller identification | ||
generation: define | ||
|
||
label: | ||
type: string | ||
category: required | ||
description: Human readable string describing the device | ||
generation: define | ||
|
||
reg: | ||
type: int | ||
description: mmio register space | ||
generation: define | ||
category: required | ||
|
||
... |
32 changes: 32 additions & 0 deletions
32
tests/unit/scripts/extract_dts_includes/bindings/test,pinmux.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: TEST PINMUX | ||
id: test,pinmux | ||
version: 0.1 | ||
|
||
description: > | ||
This binding gives a base representation of the TEST PINMUX | ||
properties: | ||
compatible: | ||
type: string | ||
category: required | ||
description: compatible strings | ||
constraint: "test,pinmux" | ||
generation: define | ||
|
||
label: | ||
type: string | ||
category: required | ||
description: Human readable string describing the device | ||
generation: define | ||
|
||
reg: | ||
type: int | ||
description: mmio register space | ||
generation: define | ||
category: required | ||
|
||
"#cells": | ||
- pin | ||
- function | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "skeleton.dtsi" | ||
|
||
/ { | ||
soc { | ||
#address-cells = <1>; | ||
#size-cells = <1>; | ||
compatible = "simple-bus"; | ||
interrupt-parent = <&nvic>; | ||
ranges; | ||
|
||
nvic: interrupt-controller@e000e100 { | ||
compatible = "arm,v7m-nvic"; | ||
reg = <0xe000e100 0xc00>; | ||
interrupt-controller; | ||
#interrupt-cells = <2>; | ||
}; | ||
|
||
systick: timer@e000e010 { | ||
compatible = "arm,armv7m-systick"; | ||
reg = <0xe000e010 0x10>; | ||
status = "disabled"; | ||
}; | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Skeleton device tree; the bare minimum needed to boot; just include and | ||
* add a compatible value. The bootloader will typically populate the memory | ||
* node. | ||
*/ | ||
|
||
/ { | ||
#address-cells = <1>; | ||
#size-cells = <1>; | ||
chosen { }; | ||
aliases { }; | ||
}; |
59 changes: 59 additions & 0 deletions
59
tests/unit/scripts/extract_dts_includes/dts/test-pinctrl.dtsi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2018 Bobby Noelte | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "../pinctrl_test.h" | ||
|
||
/{ | ||
soc { | ||
pinctrl0:pin-controller@40000000 { | ||
device0_rx_pins_a:device0@000 { | ||
rx { | ||
pinmux = <1000 2000>; | ||
bias-pull-up = <1000>; | ||
input-enable; | ||
}; | ||
}; | ||
device0_tx_pins_a:device0@001 { | ||
tx { | ||
pinmux = <1001 2001>; | ||
bias-pull-down = <1001>; | ||
output-enable; | ||
}; | ||
}; | ||
device0_rx_pins_b:device0@002 { | ||
rx { | ||
pinmux = <1002 2002>; | ||
bias-pull-up = <1002>; | ||
input-enable; | ||
}; | ||
}; | ||
device0_tx_pins_b:device0@003 { | ||
tx { | ||
pinmux = <1003 2003>; | ||
bias-pull-down = <1003>; | ||
output-enable; | ||
}; | ||
}; | ||
}; | ||
pinctrl1:pin-controller@50000000 { | ||
device1_rx_tx_pins_a:device1@000 | ||
{ | ||
rx_tx { | ||
pins = "PIN_A", "PIN_B"; | ||
output-high; | ||
}; | ||
}; | ||
}; | ||
pinmux0:pinmux@60000000 { | ||
device2_rx_tx_pins_a:device2@0 { | ||
rx_tx { | ||
rx = <1234 5678>; | ||
tx = <2345 6789>; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; |
Oops, something went wrong.