diff --git a/boards/nios2/qemu_nios2/board.h b/boards/nios2/qemu_nios2/board.h index 6f45889a580..39d984a6c10 100644 --- a/boards/nios2/qemu_nios2/board.h +++ b/boards/nios2/qemu_nios2/board.h @@ -7,4 +7,6 @@ #ifndef __INC_BOARD_H #define __INC_BOARD_H +#include + #endif /* __INC_BOARD_H */ diff --git a/boards/nios2/qemu_nios2/qemu_nios2.dts b/boards/nios2/qemu_nios2/qemu_nios2.dts index 542adf89ed1..89e6ca92b33 100644 --- a/boards/nios2/qemu_nios2/qemu_nios2.dts +++ b/boards/nios2/qemu_nios2/qemu_nios2.dts @@ -7,17 +7,23 @@ compatible = "qemu,nios2"; aliases { - uart-0 = &uart0; + uart_0 = &jtag_uart; + uart_1 = &ns16550_uart; }; chosen { zephyr,sram = &sram0; zephyr,flash = &flash0; - zephyr,console = &uart0; + zephyr,console = &jtag_uart; }; }; -&uart0 { +&jtag_uart { + status = "ok"; + current-speed = <115200>; +}; + +&ns16550_uart { status = "ok"; current-speed = <115200>; }; diff --git a/boards/nios2/qemu_nios2/qemu_nios2_defconfig b/boards/nios2/qemu_nios2/qemu_nios2_defconfig index 2c500219e17..a558679967c 100644 --- a/boards/nios2/qemu_nios2/qemu_nios2_defconfig +++ b/boards/nios2/qemu_nios2/qemu_nios2_defconfig @@ -7,7 +7,8 @@ CONFIG_CONSOLE=y CONFIG_PRINTK=y CONFIG_SERIAL=y CONFIG_UART_ALTERA_JTAG=y +CONFIG_UART_NS16550=y +CONFIG_UART_NS16550_PORT_0=y CONFIG_UART_CONSOLE=y -CONFIG_UART_CONSOLE_ON_DEV_NAME="jtag_uart0" CONFIG_INCLUDE_RESET_VECTOR=n CONFIG_EXTRA_EXCEPTION_INFO=y diff --git a/dts/nios2/nios2-qemu.dtsi b/dts/nios2/nios2-qemu.dtsi index 5f9b3ed4445..f5f9301c602 100644 --- a/dts/nios2/nios2-qemu.dtsi +++ b/dts/nios2/nios2-qemu.dtsi @@ -29,7 +29,7 @@ compatible = "simple-bus"; ranges; - uart0: uart@201000 { + jtag_uart: uart@201000 { compatible = "altera,jtag-uart"; reg = <0x201000 0x400>; label = "jtag_uart0"; @@ -37,5 +37,13 @@ status = "disabled"; }; + ns16550_uart: uart@440000 { + compatible = "ns16550"; + reg = <0x440000 0x400>; + label = "UART_0"; + + status = "disabled"; + }; + }; }; diff --git a/soc/nios2/nios2-qemu/dts.fixup b/soc/nios2/nios2-qemu/dts.fixup index 6016d714d30..1a1d47430f7 100644 --- a/soc/nios2/nios2-qemu/dts.fixup +++ b/soc/nios2/nios2-qemu/dts.fixup @@ -1,3 +1,7 @@ +#define CONFIG_UART_NS16550_PORT_0_BAUD_RATE NS16550_440000_CURRENT_SPEED + +#define CONFIG_UART_NS16550_PORT_0_NAME NS16550_440000_LABEL + #define _RAM_ADDR CONFIG_SRAM_BASE_ADDRESS #define _RAM_SIZE (CONFIG_SRAM_SIZE * 1024) diff --git a/soc/nios2/nios2-qemu/soc.h b/soc/nios2/nios2-qemu/soc.h new file mode 100644 index 00000000000..47a80e66de6 --- /dev/null +++ b/soc/nios2/nios2-qemu/soc.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + + +#ifndef __SOC_H_ +#define __SOC_H_ + +#include + +#define CONFIG_UART_NS16550_PORT_0_BASE_ADDR A_16550_UART_0_BASE +#define CONFIG_UART_NS16550_PORT_0_IRQ A_16550_UART_0_IRQ +#define CONFIG_UART_NS16550_PORT_0_CLK_FREQ A_16550_UART_0_FREQ + +#endif