Skip to content

Commit

Permalink
dts: posix: Add DTS support for POSIX architecture
Browse files Browse the repository at this point in the history
Added device tree support for POSIX architecture based boards.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
  • Loading branch information
vanwinkeljan authored and nashif committed May 29, 2019
1 parent 951a82d commit 7a246c3
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 10 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions boards/posix/native_posix/Kconfig.board
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions 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

74 changes: 74 additions & 0 deletions 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 <posix/posix.dtsi>

/ {
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";
};
};
7 changes: 0 additions & 7 deletions drivers/serial/Kconfig.native_posix
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions drivers/serial/uart_native_posix.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
@@ -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"

...
19 changes: 19 additions & 0 deletions 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"
...
9 changes: 9 additions & 0 deletions 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 <mem.h>

3 changes: 3 additions & 0 deletions include/arch/posix/arch.h
Expand Up @@ -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 <generated_dts_board.h>

#include <toolchain.h>
#include <irq.h>
#include <arch/posix/asm_inline.h>
Expand Down

0 comments on commit 7a246c3

Please sign in to comment.