From 7a246c30bd0bc258162254390efc6508c6334361 Mon Sep 17 00:00:00 2001 From: Jan Van Winkel Date: Wed, 2 Jan 2019 00:26:13 +0100 Subject: [PATCH] dts: posix: Add DTS support for POSIX architecture Added device tree support for POSIX architecture based boards. Signed-off-by: Jan Van Winkel --- CODEOWNERS | 1 + boards/posix/native_posix/Kconfig.board | 1 + boards/posix/native_posix/dts_fixup.h | 9 +++ boards/posix/native_posix/native_posix.dts | 74 +++++++++++++++++++ drivers/serial/Kconfig.native_posix | 7 -- drivers/serial/uart_native_posix.c | 5 +- .../zephyr,native-posix-flash-controller.yaml | 16 ++++ .../serial/zephyr,native-posix-uart.yaml | 19 +++++ dts/posix/posix.dtsi | 9 +++ include/arch/posix/arch.h | 3 + 10 files changed, 134 insertions(+), 10 deletions(-) create mode 100644 boards/posix/native_posix/dts_fixup.h create mode 100644 boards/posix/native_posix/native_posix.dts create mode 100644 dts/bindings/flash_controller/zephyr,native-posix-flash-controller.yaml create mode 100644 dts/bindings/serial/zephyr,native-posix-uart.yaml create mode 100644 dts/posix/posix.dtsi diff --git a/CODEOWNERS b/CODEOWNERS index 3faaeca96488..6d8641c7ac85 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -179,6 +179,7 @@ /dts/bindings/*/sifive* @mateusz-holenko @kgugala @pgielda @nategraff-sifive /dts/bindings/*/litex* @mateusz-holenko @kgugala @pgielda /dts/bindings/*/vexriscv* @mateusz-holenko @kgugala @pgielda +/dts/posix/ @aescolar @vanwinkeljan /ext/hal/atmel/asf/sam/include/same70*/ @aurel32 /ext/hal/atmel/asf/sam0/include/samr21/ @benpicco /ext/hal/cmsis/ @MaureenHelm @galak diff --git a/boards/posix/native_posix/Kconfig.board b/boards/posix/native_posix/Kconfig.board index 381458cf73d1..beea4b77fa97 100644 --- a/boards/posix/native_posix/Kconfig.board +++ b/boards/posix/native_posix/Kconfig.board @@ -3,6 +3,7 @@ config BOARD_NATIVE_POSIX bool "Native POSIX" depends on SOC_POSIX + select HAS_DTS select NATIVE_POSIX_TIMER select NATIVE_POSIX_CONSOLE help diff --git a/boards/posix/native_posix/dts_fixup.h b/boards/posix/native_posix/dts_fixup.h new file mode 100644 index 000000000000..3b81f441f6c9 --- /dev/null +++ b/boards/posix/native_posix/dts_fixup.h @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2019 Jan Van Winkel (jan.van_winkel@dxplore.eu) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_FLASH_DEV_NAME DT_ZEPHYR_NATIVE_POSIX_FLASH_CONTROLLER_0_LABEL +#define DT_UART_0_DEV_NAME DT_ZEPHYR_NATIVE_POSIX_UART_1_LABEL + diff --git a/boards/posix/native_posix/native_posix.dts b/boards/posix/native_posix/native_posix.dts new file mode 100644 index 000000000000..8e5b8294ba05 --- /dev/null +++ b/boards/posix/native_posix/native_posix.dts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019 Jan Van Winkel (jan.van_winkel@dxplore.eu) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Native POSIX Board"; + compatible = "zephyr,posix"; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,uart-mcumgr = &uart0; + zephyr,flash = &flash0; + }; + + + flash-controller@0 { + compatible = "zephyr,native-posix-flash-controller"; + reg = <0x00000000 DT_SIZE_K(2048)>; + + #address-cells = <1>; + #size-cells = <1>; + + label = "flash_ctrl"; + + flash0: flash@0 { + status = "ok"; + compatible = "soc-nv-flash"; + label = "flash"; + erase-block-size = <1>; + write-block-size = <1>; + reg = <0x00000000 DT_SIZE_K(2048)>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x000000000 0x0000C000>; + }; + slot0_partition: partition@c000 { + label = "image-0"; + reg = <0x0000C000 0x000069000>; + }; + slot1_partition: partition@75000 { + label = "image-1"; + reg = <0x00075000 0x000069000>; + }; + scratch_partition: partition@de000 { + label = "image-scratch"; + reg = <0x000de000 0x0001e000>; + }; + storage_partition: partition@fc000 { + label = "storage"; + reg = <0x000fc000 0x00004000>; + }; + }; + }; + }; + + uart0: uart@1 { + status = "ok"; + compatible = "zephyr,native-posix-uart"; + reg = <1 0>; + label = "UART_0"; + }; +}; diff --git a/drivers/serial/Kconfig.native_posix b/drivers/serial/Kconfig.native_posix index f044a09cd2f8..a4a60b088813 100644 --- a/drivers/serial/Kconfig.native_posix +++ b/drivers/serial/Kconfig.native_posix @@ -12,13 +12,6 @@ config UART_NATIVE_POSIX if UART_NATIVE_POSIX -config UART_NATIVE_POSIX_PORT_0_NAME - string "Port 0 Device Name" - default "UART_0" - help - This is the device name for the first UART, and is included in the - device struct. - choice prompt "Native UART Port 0 connection" default NATIVE_UART_0_ON_OWN_PTY diff --git a/drivers/serial/uart_native_posix.c b/drivers/serial/uart_native_posix.c index 256dcfdea772..351d7b7831af 100644 --- a/drivers/serial/uart_native_posix.c +++ b/drivers/serial/uart_native_posix.c @@ -201,8 +201,7 @@ static int np_uart_0_init(struct device *dev) d = (struct native_uart_status *)dev->driver_data; if (IS_ENABLED(CONFIG_NATIVE_UART_0_ON_OWN_PTY)) { - int tty_fn = open_tty(d, CONFIG_UART_NATIVE_POSIX_PORT_0_NAME, - auto_attach); + int tty_fn = open_tty(d, DT_UART_0_DEV_NAME, auto_attach); d->in_fd = tty_fn; d->out_fd = tty_fn; @@ -337,7 +336,7 @@ static int np_uart_tty_poll_in(struct device *dev, unsigned char *p_char) } DEVICE_AND_API_INIT(uart_native_posix0, - CONFIG_UART_NATIVE_POSIX_PORT_0_NAME, &np_uart_0_init, + DT_UART_0_DEV_NAME, &np_uart_0_init, (void *)&native_uart_status_0, NULL, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &np_uart_driver_api_0); diff --git a/dts/bindings/flash_controller/zephyr,native-posix-flash-controller.yaml b/dts/bindings/flash_controller/zephyr,native-posix-flash-controller.yaml new file mode 100644 index 000000000000..26c6827334a1 --- /dev/null +++ b/dts/bindings/flash_controller/zephyr,native-posix-flash-controller.yaml @@ -0,0 +1,16 @@ +--- +title: Native POSIX Flash Controller +version: 0.1 + +description: > + This binding gives a base representation of the Native POSIX flash + controller + +inherits: + !include flash-controller.yaml + +properties: + compatible: + constraint: "zephyr,native-posix-flash-controller" + +... diff --git a/dts/bindings/serial/zephyr,native-posix-uart.yaml b/dts/bindings/serial/zephyr,native-posix-uart.yaml new file mode 100644 index 000000000000..c56e5b7c0d5b --- /dev/null +++ b/dts/bindings/serial/zephyr,native-posix-uart.yaml @@ -0,0 +1,19 @@ +# +# Copyright (c) 2019, Jan Van Winkel (jan.van_winkel@dxplore.eu) +# +# SPDX-License-Identifier: Apache-2.0 +# +--- +title: Native POSIX UART +version: 0.1 + +description: > + This binding gives a base representation of the Native POSIX UART + +inherits: + !include uart.yaml + +properties: + compatible: + constraint: "zephyr,native-posix-uart" +... diff --git a/dts/posix/posix.dtsi b/dts/posix/posix.dtsi new file mode 100644 index 000000000000..8b4630ce38d8 --- /dev/null +++ b/dts/posix/posix.dtsi @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2019 Jan Van Winkel (jan.van_winkel@dxplore.eu) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "skeleton.dtsi" +#include + diff --git a/include/arch/posix/arch.h b/include/arch/posix/arch.h index 60bf659cf359..82969d78a8d6 100644 --- a/include/arch/posix/arch.h +++ b/include/arch/posix/arch.h @@ -17,6 +17,9 @@ #ifndef ZEPHYR_INCLUDE_ARCH_POSIX_ARCH_H_ #define ZEPHYR_INCLUDE_ARCH_POSIX_ARCH_H_ +/* Add include for DTS generated information */ +#include + #include #include #include