From 92a00ee39bc83892f26d653e31623b8946ed0a50 Mon Sep 17 00:00:00 2001 From: Johann Fischer Date: Sat, 7 Aug 2021 10:54:03 +0200 Subject: [PATCH] drivers: uart_altera_jtag_hal: use DEVICE_DT_INST_DEFINE() The conversion to devicetree seems to be half lost for this driver. There are already bindings and nodes for compatible "altr,jtag-uart", update driver to use it. Remove last mention of CONFIG_UART_CONSOLE_ON_DEV_NAME. Resolves #37207 Signed-off-by: Johann Fischer --- boards/nios2/altera_max10/doc/index.rst | 12 +++++++----- boards/nios2/qemu_nios2/qemu_nios2_defconfig | 1 - drivers/serial/Kconfig.altera_jtag | 3 +++ drivers/serial/uart_altera_jtag_hal.c | 11 ++++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/boards/nios2/altera_max10/doc/index.rst b/boards/nios2/altera_max10/doc/index.rst index 1c2915d9300..f96710075f5 100644 --- a/boards/nios2/altera_max10/doc/index.rst +++ b/boards/nios2/altera_max10/doc/index.rst @@ -122,13 +122,15 @@ minicom with flow control disabled, 115200-8N1 settings. JTAG UART --------- -You can also have it send its console output to the JTAG UART. Set these in your -project configuration: +You can also have it send its console output to the JTAG UART. +Enable ``jtag_uart`` node in :file:`altera_max10.dts` or overlay file: -.. code-block:: console +.. code-block:: devicetree - CONFIG_UART_ALTERA_JTAG=y - CONFIG_UART_CONSOLE_ON_DEV_NAME="jtag_uart0" + &jtag_uart { + status = "okay"; + current-speed = <115200>; + }; To view these messages on your local workstation, run the terminal application in the SDK: diff --git a/boards/nios2/qemu_nios2/qemu_nios2_defconfig b/boards/nios2/qemu_nios2/qemu_nios2_defconfig index aaf51a4811a..c60fd0a2e71 100644 --- a/boards/nios2/qemu_nios2/qemu_nios2_defconfig +++ b/boards/nios2/qemu_nios2/qemu_nios2_defconfig @@ -6,7 +6,6 @@ CONFIG_HAS_ALTERA_HAL=y CONFIG_CONSOLE=y CONFIG_PRINTK=y CONFIG_SERIAL=y -CONFIG_UART_ALTERA_JTAG=y CONFIG_UART_NS16550=y CONFIG_UART_CONSOLE=y CONFIG_INCLUDE_RESET_VECTOR=n diff --git a/drivers/serial/Kconfig.altera_jtag b/drivers/serial/Kconfig.altera_jtag index bc5e81fb84a..9ea84c0300a 100644 --- a/drivers/serial/Kconfig.altera_jtag +++ b/drivers/serial/Kconfig.altera_jtag @@ -1,7 +1,10 @@ # SPDX-License-Identifier: Apache-2.0 +DT_COMPAT_ALTR_JTAG_UART := altr,jtag-uart + config UART_ALTERA_JTAG bool "Nios II JTAG UART driver" + default $(dt_compat_enabled,$(DT_COMPAT_ALTR_JTAG_UART)) select SERIAL_HAS_DRIVER help Enable the Altera JTAG UART driver, built in to many Nios II CPU diff --git a/drivers/serial/uart_altera_jtag_hal.c b/drivers/serial/uart_altera_jtag_hal.c index f73cb690791..98eb2b5f231 100644 --- a/drivers/serial/uart_altera_jtag_hal.c +++ b/drivers/serial/uart_altera_jtag_hal.c @@ -13,6 +13,8 @@ #include "altera_avalon_jtag_uart.h" #include "altera_avalon_jtag_uart_regs.h" +#define DT_DRV_COMPAT altr_jtag_uart + #define UART_ALTERA_JTAG_DATA_REG 0 #define UART_ALTERA_JTAG_CONTROL_REG 1 @@ -57,8 +59,7 @@ static const struct uart_device_config uart_altera_jtag_dev_cfg_0 = { .sys_clk_freq = 0, /* Unused */ }; -DEVICE_DEFINE(uart_altera_jtag_0, "jtag_uart0", - uart_altera_jtag_init, NULL, NULL, - &uart_altera_jtag_dev_cfg_0, - PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, - &uart_altera_jtag_driver_api); +DEVICE_DT_INST_DEFINE(0, uart_altera_jtag_init, NULL, + NULL, &uart_altera_jtag_dev_cfg_0, + PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + &uart_altera_jtag_driver_api);