nios2: remap and translate reg address in device tree
PATCH 1/2 nios2: remap and translate reg address in device tree
As the io space remapping ioremap() and bridge address translation fdt_translate_address() are not usually used in u-boot driver model by dev_get_addr(). We would better convert the reg address map in the device tree of nios2 boards, so that it is io mapped and bridge translated.
--- arch/nios2/dts/3c120_devboard.dts | 171 +++++++++++++++----------------------- 1 file changed, 69 insertions(+), 102 deletions(-)
arch/nios2/dts/3c120_devboard.dts +69 -102
@@ -14,6 +14,73 @@ #address-cells = <1>; #size-cells = <1>; + aliases { + console = &jtag_uart; + }; + + timer_1ms: timer at 0x400000 { + compatible = "altr,timer-1.0"; + reg = <0xe8400000 0x00000020>; + interrupt-parent = <&cpu>; + interrupts = <11>; + clock-frequency = <125000000>; + u-boot,dm-pre-reloc; + }; + + jtag_uart: serial at 0x4d50 { + compatible = "altr,juart-1.0"; + reg = <0xe8004d50 0x00000008>; + interrupt-parent = <&cpu>; + interrupts = <1>; + u-boot,dm-pre-reloc; + }; + + tse_mac: ethernet at 0x4000 { + compatible = "altr,tse-1.0"; + reg = <0xe8004000 0x00000400>, + <0xe8004400 0x00000040>, + <0xe8004800 0x00000040>, + <0xe8002000 0x00002000>; + reg-names = "control_port", "rx_csr", "tx_csr", "s1"; + interrupt-parent = <&cpu>; + interrupts = <2 3>; + interrupt-names = "rx_irq", "tx_irq"; + rx-fifo-depth = <8192>; + tx-fifo-depth = <8192>; + max-frame-size = <1518>; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rgmii-id"; + phy-handle = <&phy0>; + tse_mac_mdio: mdio { + compatible = "altr,tse-mdio"; + #address-cells = <1>; + #size-cells = <0>; + phy0: ethernet-phy at 18 { + reg = <18>; + device_type = "ethernet-phy"; + }; + }; + }; + + uart: serial at 0x4c80 { + compatible = "altr,uart-1.0"; + reg = <0xe8004c80 0x00000020>; + interrupt-parent = <&cpu>; + interrupts = <10>; + current-speed = <115200>; + clock-frequency = <62500000>; + u-boot,dm-pre-reloc; + }; + + user_led_pio_8out: gpio at 0x4cc0 { + compatible = "altr,pio-1.0"; + reg = <0xe8004cc0 0x00000010>; + resetvalue = <255>; + width = <8>; + #gpio-cells = <2>; + gpio-controller; + }; + cpus { #address-cells = <1>; #size-cells = <0>;
@@ -46,108 +113,8 @@ memory at 0 { device_type = "memory"; - reg = <0x10000000 0x08000000>, - <0x07fff400 0x00000400>; + reg = <0xd0000000 0x08000000>, + <0xc7fff400 0x00000400>; }; - sopc at 0 { - device_type = "soc"; - ranges; - #address-cells = <1>; - #size-cells = <1>; - compatible = "altr,avalon", "simple-bus"; - bus-frequency = <125000000>; - - pb_cpu_to_io: bridge at 0x8000000 { - compatible = "simple-bus"; - reg = <0x08000000 0x00800000>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x00002000 0x08002000 0x00002000>, - <0x00004000 0x08004000 0x00000400>, - <0x00004400 0x08004400 0x00000040>, - <0x00004800 0x08004800 0x00000040>, - <0x00004c80 0x08004c80 0x00000020>, - <0x00004d50 0x08004d50 0x00000008>, - <0x00008000 0x08008000 0x00000020>, - <0x00400000 0x08400000 0x00000020>; - - timer_1ms: timer at 0x400000 { - compatible = "altr,timer-1.0"; - reg = <0x00400000 0x00000020>; - interrupt-parent = <&cpu>; - interrupts = <11>; - clock-frequency = <125000000>; - }; - - timer_0: timer at 0x8000 { - compatible = "altr,timer-1.0"; - reg = < 0x00008000 0x00000020 >; - interrupt-parent = < &cpu >; - interrupts = < 5 >; - clock-frequency = < 125000000 >; - }; - - jtag_uart: serial at 0x4d50 { - compatible = "altr,juart-1.0"; - reg = <0x00004d50 0x00000008>; - interrupt-parent = <&cpu>; - interrupts = <1>; - }; - - tse_mac: ethernet at 0x4000 { - compatible = "altr,tse-1.0"; - reg = <0x00004000 0x00000400>, - <0x00004400 0x00000040>, - <0x00004800 0x00000040>, - <0x00002000 0x00002000>; - reg-names = "control_port", "rx_csr", "tx_csr", "s1"; - interrupt-parent = <&cpu>; - interrupts = <2 3>; - interrupt-names = "rx_irq", "tx_irq"; - rx-fifo-depth = <8192>; - tx-fifo-depth = <8192>; - max-frame-size = <1518>; - local-mac-address = [ 00 00 00 00 00 00 ]; - phy-mode = "rgmii-id"; - phy-handle = <&phy0>; - tse_mac_mdio: mdio { - compatible = "altr,tse-mdio"; - #address-cells = <1>; - #size-cells = <0>; - phy0: ethernet-phy at 18 { - reg = <18>; - device_type = "ethernet-phy"; - }; - }; - }; - - uart: serial at 0x4c80 { - compatible = "altr,uart-1.0"; - reg = <0x00004c80 0x00000020>; - interrupt-parent = <&cpu>; - interrupts = <10>; - current-speed = <115200>; - clock-frequency = <62500000>; - }; - }; - - cfi_flash_64m: flash at 0x0 { - compatible = "cfi-flash"; - reg = <0x00000000 0x04000000>; - bank-width = <2>; - device-width = <1>; - #address-cells = <1>; - #size-cells = <1>; - - partition at 800000 { - reg = <0x00800000 0x01e00000>; - label = "JFFS2 Filesystem"; - }; - }; - }; - - chosen { - bootargs = "debug console=ttyJ0,115200"; - }; };
Signature · 1 line
2.1.4
PATCH 2/2 nios2: convert altera_jtag_uart to driver model
Convert altera_jtag_uart to driver model.
--- configs/nios2-generic_defconfig | 3 + drivers/serial/Kconfig | 13 ++++ drivers/serial/altera_jtag_uart.c | 124 +++++++++++++++++++++----------------- include/configs/nios2-generic.h | 3 - 4 files changed, 84 insertions(+), 59 deletions(-)
configs/nios2-generic_defconfig +3 -0
@@ -1,4 +1,5 @@ CONFIG_NIOS2=y +CONFIG_DM_SERIAL=y CONFIG_TARGET_NIOS2_GENERIC=y CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard" CONFIG_HUSH_PARSER=y
@@ -14,3 +15,5 @@ CONFIG_CMD_PING=y CONFIG_OF_CONTROL=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_DM=y +CONFIG_ALTERA_JTAG_UART=y +CONFIG_ALTERA_JTAG_UART_BYPASS=y
drivers/serial/Kconfig +13 -0
@@ -109,6 +109,19 @@ config DEBUG_UART_SHIFT value. Use this value to specify the shift to use, where 0=byte registers, 2=32-bit word registers, etc. +config ALTERA_JTAG_UART + bool "Altera JTAG UART support" + depends on NIOS2 && DM_SERIAL + help + Select this to enable an JTAG UART for Altera devices. + +config ALTERA_JTAG_UART_BYPASS + bool "Bypass output when no connection" + depends on ALTERA_JTAG_UART + help + Bypass console output and keep going even if there is no + JTAG terminal connection with the host. + config ROCKCHIP_SERIAL bool "Rockchip on-chip UART support" depends on ARCH_UNIPHIER && DM_SERIAL
drivers/serial/altera_jtag_uart.c +68 -56
166 lines not on this page · raw message
include/configs/nios2-generic.h +0 -3
@@ -23,14 +23,11 @@/* * SERIAL */ -#define CONFIG_ALTERA_JTAG_UART #if defined(CONFIG_ALTERA_JTAG_UART ) -# define CONFIG_SYS_NIOS_CONSOLE CONFIG_SYS_JTAG_UART_BASE#else # define CONFIG_SYS_NIOS_CONSOLE CONFIG_SYS_UART_BASE#endif -#define CONFIG_ALTERA_JTAG_UART_BYPASS #define CONFIG_SYS_NIOS_FIXEDBAUD #define CONFIG_BAUDRATE CONFIG_SYS_UART_BAUD#define CONFIG_SYS_BAUDRATE_TABLE {CONFIG_BAUDRATE}
Signature · 1 line
2.1.4
PATCH 2/2 nios2: convert altera_jtag_uart to driver model
Quoted 3 lines · Thomas Chou
Convert
altera_jtag_uartto driver model.Signed-off-by Thomas Chou <[email protected]>
[...]
Quoted 11 lines
drivers/serial/altera_jtag_uart.c +3
-5-static int altera_jtag_serial_init (void ) +static int altera_jtaguart_putc (struct udevice *dev,const char c) { -return 0 ; -} +struct altera_jtaguart_platdata *plat = dev->platdata; +struct altera_jtaguart_regs *const regs = plat->reg; -static void altera_jtag_serial_putc (char c) -{while (1 ) {
drivers/serial/altera_jtag_uart.c line 59
Quoted 10 lines
drivers/serial/altera_jtag_uart.c +2
-3-unsigned st =readl (&jtag->control); +unsigned st =readl (®s->control);if (NIOS_JTAG_WSPACE (st))break ;#ifdef CONFIG_ALTERA_JTAG_UART_BYPASS if (!(st &NIOS_JTAG_AC ))/* no connection */ -return ; +return 0 ;#endif -WATCHDOG_RESET ();
Please keep those WATCHDOG_RESET() calls, they're needed in case you do have a WDT on your board.
Quoted 6 lines
drivers/serial/altera_jtag_uart.c +3
-1} -writel ((unsigned char )c, &jtag->data); +writel ((unsigned char )c, ®s->data); + +return 0 ; }
[...]
Quoted 7 lines
drivers/serial/altera_jtag_uart.c +3
-2-static int altera_jtag_serial_getc (void ) +static int altera_jtaguart_getc (struct udevice *dev) { -int c; +struct altera_jtaguart_platdata *plat = dev->platdata; +struct altera_jtaguart_regs *const regs = plat->reg;unsigned val;
drivers/serial/altera_jtag_uart.c line 69
Quoted 10 lines
drivers/serial/altera_jtag_uart.c +1
-8-while (1 ) { -WATCHDOG_RESET (); - val =readl (&jtag->data); -if (val &NIOS_JTAG_RVALID ) -break ; - } - c = val &0x0ff ; -return (c); +while (!((val =readl (®s->data)) &NIOS_JTAG_RVALID ))
Ewww, this is ugly. Please expand it into something like the following, for the sake of readability.
while (1) {
val = readl()
if (val & cond)
break;
}
drivers/serial/altera_jtag_uart.c line 73
Quoted 4 lines
drivers/serial/altera_jtag_uart.c +3
-0+ ; + +return (val &0xff ); }
Looks good otherwise, thanks ! :)
[...]
PATCH 1/2 nios2: remap and translate reg address in device tree
In reply to Thomas ChouQuoted 7 lines · Thomas Chou
As the io space remapping
ioremap()and bridge address translationfdt_translate_address()are not usually used in u-boot driver model bydev_get_addr(). We would better convert the reg address map in the device tree of nios2 boards, so that it is io mapped and bridge translated.Signed-off-by Thomas Chou <[email protected]>
I'm not opposed.
btw. It might be just about time to split the DT bits into nios2.dtsi and nios2_3c120_devboard.dts , where the former would contain the generic bits of the binding and the later would only fill in the necessary address ranges and such. I do understand though, that the problem here might be that the hardware is just too flexible.
Best regards,
Marek Vasut
PATCH 1/2 nios2: remap and translate reg address in device tree
+Stefan
Hi,
Quoted 9 lines · Marek Vasut
Quoted 7 lines · Thomas Chou
As the io space remapping
ioremap()and bridge address translationfdt_translate_address()are not usually used in u-boot driver model bydev_get_addr(). We would better convert the reg address map in the device tree of nios2 boards, so that it is io mapped and bridge translated.Signed-off-by Thomas Chou <[email protected]>
Quoted 7 lines
I'm not opposed.
btw. It might be just about time to split the DT bits into
nios2.dtsiandnios2_3c120_devboard.dts, where the former would contain the generic bits of the binding and the later would only fill in the necessary address ranges and such. I do understand though, that the problem here might be that the hardware is just too flexible.
Please do check the patch under discussion here:
http://patchwork.ozlabs.org/patch/513313/
Does it solve your problem?
Regards,
Simon
PATCH 1/2 nios2: remap and translate reg address in device tree
In reply to Marek VasutHi Marek,
Quoted 5 lines · Marek Vasut
btw. It might be just about time to split the DT bits into
nios2.dtsiandnios2_3c120_devboard.dts, where the former would contain the generic bits of the binding and the later would only fill in the necessary address ranges and such. I do understand though, that the problem here might be that the hardware is just too flexible.
Yes, the FPGA hardware is too flexible so that I cannot find a generic part of dts to split into a dtsi. Almost every parameter is programmable. :)
Best regards,
Thomas Chou
v2 cover nios2: convert altera_jtag_uart to driver model
In reply to Thomas ChouUpdate the dts and convert altera_jtag_uart to driver model.
v2
add ioremap.
make the change to dts compatible with linux.
Thomas Chou (3):
nios2: map physical address to uncached virtual address
nios2: remove bridges in device tree
nios2: convert altera_jtag_uart to driver model
arch/nios2/cpu/interrupts.c | 4 +- arch/nios2/dts/3c120_devboard.dts | 162 ++++++++++++++++++-------------------- arch/nios2/include/asm/io.h | 5 ++ configs/nios2-generic_defconfig | 3 + drivers/serial/Kconfig | 13 +++ drivers/serial/altera_jtag_uart.c | 125 ++++++++++++++++------------- include/configs/nios2-generic.h | 3 - 7 files changed, 168 insertions(+), 147 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/3 nios2: map physical address to uncached virtual address
Add ioremap() to map physical address to uncached virtual address. We need this to convert the reg address from the device tree.
The order of headers inclusion in interrupts.c is changed because common.h will include board header that contains IO_REGION_BASE.
In the future, the IO_REGION_BASE should be decided from the device tree.
--- arch/nios2/cpu/interrupts.c | 4 ++-- arch/nios2/include/asm/io.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
arch/nios2/cpu/interrupts.c +2 -2
@@ -8,12 +8,12 @@* SPDX-License-Identifier: GPL-2.0+ */ +#include <common.h> +#include <command.h> #include <asm/nios2.h> #include <asm/types.h> #include <asm/io.h> #include <asm/ptrace.h> -#include <common.h> -#include <command.h> /*************************************************************************/ struct irq_action {
arch/nios2/include/asm/io.h +5 -0
@@ -42,6 +42,11 @@ static inline phys_addr_t virt_to_phys(void * vaddr)return (phys_addr_t)(vaddr); } +static inline void *ioremap (unsigned long physaddr,unsigned long size) +{ +return (void *)(IO_REGION_BASE | physaddr); +} +extern unsigned char inb (unsigned char *port);extern unsigned short inw (unsigned short *port);extern unsigned inl (unsigned port);
Signature · 1 line
2.1.4
PATCH v2 1/3 nios2: map physical address to uncached virtual address
Quoted 4 lines · Thomas Chou
Add
ioremap()to map physical address to uncached virtual address. We need this to convert the reg address from the device tree.
Quoted 8 lines
The order of headers inclusion in
interrupts.cis changed becausecommon.hwill include board header that containsIO_REGION_BASE.In the future, the
IO_REGION_BASEshould be decided from the device tree.Signed-off-by Thomas Chou <[email protected]>
This is good :)
Best regards,
Marek Vasut
PATCH v2 1/3 nios2: map physical address to uncached virtual address
Hi,
Quoted 10 lines · Marek Vasut
Quoted 8 lines · Thomas Chou
Add
ioremap()to map physical address to uncached virtual address. We need this to convert the reg address from the device tree.The order of headers inclusion in
interrupts.cis changed becausecommon.hwill include board header that containsIO_REGION_BASE.
Quoted 9 lines
Quoted 4 lines
In the future, the
IO_REGION_BASEshould be decided from the device tree.Signed-off-by Thomas Chou <[email protected]>This is good :)
Acked-by Marek Vasut <[email protected]>
Can we not rely on the 'ranges' property to sort this out?
Regards,
Simon
PATCH v2 1/3 nios2: map physical address to uncached virtual address
Hi Simon,
Quoted 4 lines · Simon Glass
Quoted 3 lines
Quoted 3 lines
Add
ioremap()to map physical address to uncached virtual address. We need this to convert the reg address from the device tree.Can we not rely on the 'ranges' property to sort this out?
The ranges translate address across buses/bridges. The address is still physical address. In the case of nios2, the virtual address map of mmu or nonmmu are different, though the physical address should be the same. So we really need sort of ioremap(). You may find a lots of call to ioremap() in linux drivers. It is quite standard. We also want to use the same dts/dtb for both u-boot and linux. I would suggest ioremap() is the way.
Thanks a lot for your review.
Best regards,
Thomas
PATCH v2 1/3 nios2: map physical address to uncached virtual address
Quoted 11 lines · Thomas Chou
Hi Simon,
Quoted 6 lines · Simon Glass
Quoted 4 lines
Quoted 4 lines
Add
ioremap()to map physical address to uncached virtual address. We need this to convert the reg address from the device tree.Can we not rely on the 'ranges' property to sort this out?
Quoted 6 lines
The ranges translate address across buses/bridges. The address is still physical address. In the case of nios2, the virtual address map of mmu or nonmmu are different, though the physical address should be the same. So we really need sort of
ioremap(). You may find a lots of call toioremap()in linux drivers. It is quite standard. We also want to use the same dts/dtb for both u-boot and linux. I would suggestioremap()is the way.
Yes I see this on another thread. Thanks for explaining it.
PATCH v2 2/3 nios2: remove bridges in device tree
In reply to Thomas ChouAs the device tree handlers in driver model does not translate address across bridges, we would remove the bridges in device tree and translate the reg address.
We want to use the same device tree for both u-boot and linux. The ioremap() should be used to map the address returned from dev_get_addr().
--- arch/nios2/dts/3c120_devboard.dts | 157 +++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 86 deletions(-)
arch/nios2/dts/3c120_devboard.dts +71 -86
@@ -50,100 +50,85 @@ <0x07fff400 0x00000400>; }; - sopc at 0 { - device_type = "soc"; - ranges; - #address-cells = <1>; - #size-cells = <1>; - compatible = "altr,avalon", "simple-bus"; - bus-frequency = <125000000>; - - pb_cpu_to_io: bridge at 0x8000000 { - compatible = "simple-bus"; - reg = <0x08000000 0x00800000>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x00002000 0x08002000 0x00002000>, - <0x00004000 0x08004000 0x00000400>, - <0x00004400 0x08004400 0x00000040>, - <0x00004800 0x08004800 0x00000040>, - <0x00004c80 0x08004c80 0x00000020>, - <0x00004d50 0x08004d50 0x00000008>, - <0x00008000 0x08008000 0x00000020>, - <0x00400000 0x08400000 0x00000020>; + timer_1ms: timer at 0x400000 { + compatible = "altr,timer-1.0"; + reg = <0x08400000 0x00000020>; + interrupt-parent = <&cpu>; + interrupts = <11>; + clock-frequency = <125000000>; + }; - timer_1ms: timer at 0x400000 { - compatible = "altr,timer-1.0"; - reg = <0x00400000 0x00000020>; - interrupt-parent = <&cpu>; - interrupts = <11>; - clock-frequency = <125000000>; - }; + timer_0: timer at 0x8000 { + compatible = "altr,timer-1.0"; + reg = < 0x08008000 0x00000020 >; + interrupt-parent = < &cpu >; + interrupts = < 5 >; + clock-frequency = < 125000000 >; + }; - timer_0: timer at 0x8000 { - compatible = "altr,timer-1.0"; - reg = < 0x00008000 0x00000020 >; - interrupt-parent = < &cpu >; - interrupts = < 5 >; - clock-frequency = < 125000000 >; - }; + jtag_uart: serial at 0x4d50 { + compatible = "altr,juart-1.0"; + reg = <0x08004d50 0x00000008>; + interrupt-parent = <&cpu>; + interrupts = <1>; + }; - jtag_uart: serial at 0x4d50 { - compatible = "altr,juart-1.0"; - reg = <0x00004d50 0x00000008>; - interrupt-parent = <&cpu>; - interrupts = <1>; + tse_mac: ethernet at 0x4000 { + compatible = "altr,tse-1.0"; + reg = <0x08004000 0x00000400>, + <0x08004400 0x00000040>, + <0x08004800 0x00000040>, + <0x08002000 0x00002000>; + reg-names = "control_port", "rx_csr", "tx_csr", "s1"; + interrupt-parent = <&cpu>; + interrupts = <2 3>; + interrupt-names = "rx_irq", "tx_irq"; + rx-fifo-depth = <8192>; + tx-fifo-depth = <8192>; + max-frame-size = <1518>; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rgmii-id"; + phy-handle = <&phy0>; + tse_mac_mdio: mdio { + compatible = "altr,tse-mdio"; + #address-cells = <1>; + #size-cells = <0>; + phy0: ethernet-phy at 18 { + reg = <18>; + device_type = "ethernet-phy"; }; + }; + }; - tse_mac: ethernet at 0x4000 { - compatible = "altr,tse-1.0"; - reg = <0x00004000 0x00000400>, - <0x00004400 0x00000040>, - <0x00004800 0x00000040>, - <0x00002000 0x00002000>; - reg-names = "control_port", "rx_csr", "tx_csr", "s1"; - interrupt-parent = <&cpu>; - interrupts = <2 3>; - interrupt-names = "rx_irq", "tx_irq"; - rx-fifo-depth = <8192>; - tx-fifo-depth = <8192>; - max-frame-size = <1518>; - local-mac-address = [ 00 00 00 00 00 00 ]; - phy-mode = "rgmii-id"; - phy-handle = <&phy0>; - tse_mac_mdio: mdio { - compatible = "altr,tse-mdio"; - #address-cells = <1>; - #size-cells = <0>; - phy0: ethernet-phy at 18 { - reg = <18>; - device_type = "ethernet-phy"; - }; - }; - }; + uart: serial at 0x4c80 { + compatible = "altr,uart-1.0"; + reg = <0x08004c80 0x00000020>; + interrupt-parent = <&cpu>; + interrupts = <10>; + current-speed = <115200>; + clock-frequency = <62500000>; + }; - uart: serial at 0x4c80 { - compatible = "altr,uart-1.0"; - reg = <0x00004c80 0x00000020>; - interrupt-parent = <&cpu>; - interrupts = <10>; - current-speed = <115200>; - clock-frequency = <62500000>; - }; - }; + user_led_pio_8out: gpio at 0x4cc0 { + compatible = "altr,pio-1.0"; + reg = <0x08004cc0 0x00000010>; + resetvalue = <255>; + width = <8>; + #gpio-cells = <2>; + gpio-controller; + }; - cfi_flash_64m: flash at 0x0 { - compatible = "cfi-flash"; - reg = <0x00000000 0x04000000>; - bank-width = <2>; - device-width = <1>; - #address-cells = <1>; - #size-cells = <1>; + cfi_flash_64m: flash at 0x0 { + compatible = "cfi-flash"; + reg = <0x00000000 0x04000000>; + bank-width = <2>; + device-width = <1>; + #address-cells = <1>; + #size-cells = <1>; - partition at 800000 { - reg = <0x00800000 0x01e00000>; - label = "JFFS2 Filesystem"; - }; + partition at 800000 { + reg = <0x00800000 0x01e00000>; + label = "JFFS2 Filesystem"; }; };
Signature · 1 line
2.1.4
PATCH v2 3/3 nios2: convert altera_jtag_uart to driver model
In reply to Thomas ChouConvert altera_jtag_uart to driver model.
--- arch/nios2/dts/3c120_devboard.dts | 5 ++ configs/nios2-generic_defconfig | 3 + drivers/serial/Kconfig | 13 ++++ drivers/serial/altera_jtag_uart.c | 125 +++++++++++++++++++++----------------- include/configs/nios2-generic.h | 3 - 5 files changed, 90 insertions(+), 59 deletions(-)
arch/nios2/dts/3c120_devboard.dts +5 -0
@@ -71,6 +71,7 @@ reg = <0x08004d50 0x00000008>; interrupt-parent = <&cpu>; interrupts = <1>; + u-boot,dm-pre-reloc; }; tse_mac: ethernet at 0x4000 {
@@ -132,6 +133,10 @@ }; }; + aliases { + console = &jtag_uart; + }; + chosen { bootargs = "debug console=ttyJ0,115200"; };
configs/nios2-generic_defconfig +3 -0
@@ -1,4 +1,5 @@ CONFIG_NIOS2=y +CONFIG_DM_SERIAL=y CONFIG_TARGET_NIOS2_GENERIC=y CONFIG_DEFAULT_DEVICE_TREE="3c120_devboard" CONFIG_HUSH_PARSER=y
@@ -14,3 +15,5 @@ CONFIG_CMD_PING=y CONFIG_OF_CONTROL=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_DM=y +CONFIG_ALTERA_JTAG_UART=y +CONFIG_ALTERA_JTAG_UART_BYPASS=y
drivers/serial/Kconfig +13 -0
@@ -109,6 +109,19 @@ config DEBUG_UART_SHIFT value. Use this value to specify the shift to use, where 0=byte registers, 2=32-bit word registers, etc. +config ALTERA_JTAG_UART + bool "Altera JTAG UART support" + depends on NIOS2 && DM_SERIAL + help + Select this to enable an JTAG UART for Altera devices. + +config ALTERA_JTAG_UART_BYPASS + bool "Bypass output when no connection" + depends on ALTERA_JTAG_UART + help + Bypass console output and keep going even if there is no + JTAG terminal connection with the host. + config ROCKCHIP_SERIAL bool "Rockchip on-chip UART support" depends on ARCH_UNIPHIER && DM_SERIAL
drivers/serial/altera_jtag_uart.c +69 -56
167 lines not on this page · raw message
include/configs/nios2-generic.h +0 -3
@@ -23,14 +23,11 @@/* * SERIAL */ -#define CONFIG_ALTERA_JTAG_UART #if defined(CONFIG_ALTERA_JTAG_UART ) -# define CONFIG_SYS_NIOS_CONSOLE CONFIG_SYS_JTAG_UART_BASE#else # define CONFIG_SYS_NIOS_CONSOLE CONFIG_SYS_UART_BASE#endif -#define CONFIG_ALTERA_JTAG_UART_BYPASS #define CONFIG_SYS_NIOS_FIXEDBAUD #define CONFIG_BAUDRATE CONFIG_SYS_UART_BAUD#define CONFIG_SYS_BAUDRATE_TABLE {CONFIG_BAUDRATE}
Signature · 1 line
2.1.4
PATCH 1/2 nios2: remap and translate reg address in device tree
In reply to Thomas ChouHi Thomas,
added Simon and Stephen to cc on this.
Quoted 5 lines · Thomas Chou
As the io space remapping
ioremap()and bridge address translationfdt_translate_address()are not usually used in u-boot driver model bydev_get_addr(). We would better convert the reg address map in the device tree of nios2 boards, so that it is io mapped and bridge translated.
So you are changing the DT sources for your platform because the U-Boot implementation does support the bus translation correctly (ranges properties)? I think this is the wrong approach. We need to make sure that U-Boot supports DT correctly instead. I have a patch queued to enable this. Please take a look at this thread:
https://patchwork.ozlabs.org/patch/514331/
Could you please check if this patch (with the config options enabled) helps on your platform without DT changes?
Quoted 185 lines
Signed-off-by Thomas Chou <[email protected]>--- arch/nios2/dts/3c120_devboard.dts | 171 +++++++++++++++----------------------- 1 file changed, 69 insertions(+), 102 deletions(-)arch/nios2/dts/3c120_devboard.dts +69
-93@@ -14,6 +14,73 @@ #address-cells = <1>; #size-cells = <1>; + aliases { + console = &jtag_uart; + }; + + timer_1ms: timer at 0x400000 { + compatible = "altr,timer-1.0"; + reg = <0xe8400000 0x00000020>; + interrupt-parent = <&cpu>; + interrupts = <11>; + clock-frequency = <125000000>; + u-boot,dm-pre-reloc; + }; + + jtag_uart: serial at 0x4d50 { + compatible = "altr,juart-1.0"; + reg = <0xe8004d50 0x00000008>; + interrupt-parent = <&cpu>; + interrupts = <1>; + u-boot,dm-pre-reloc; + }; + + tse_mac: ethernet at 0x4000 { + compatible = "altr,tse-1.0"; + reg = <0xe8004000 0x00000400>, + <0xe8004400 0x00000040>, + <0xe8004800 0x00000040>, + <0xe8002000 0x00002000>; + reg-names = "control_port", "rx_csr", "tx_csr", "s1"; + interrupt-parent = <&cpu>; + interrupts = <2 3>; + interrupt-names = "rx_irq", "tx_irq"; + rx-fifo-depth = <8192>; + tx-fifo-depth = <8192>; + max-frame-size = <1518>; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rgmii-id"; + phy-handle = <&phy0>; + tse_mac_mdio: mdio { + compatible = "altr,tse-mdio"; + #address-cells = <1>; + #size-cells = <0>; + phy0: ethernet-phy at 18 { + reg = <18>; + device_type = "ethernet-phy"; + }; + }; + }; + + uart: serial at 0x4c80 { + compatible = "altr,uart-1.0"; + reg = <0xe8004c80 0x00000020>; + interrupt-parent = <&cpu>; + interrupts = <10>; + current-speed = <115200>; + clock-frequency = <62500000>; + u-boot,dm-pre-reloc; + }; + + user_led_pio_8out: gpio at 0x4cc0 { + compatible = "altr,pio-1.0"; + reg = <0xe8004cc0 0x00000010>; + resetvalue = <255>; + width = <8>; + #gpio-cells = <2>; + gpio-controller; + }; + cpus { #address-cells = <1>; #size-cells = <0>;@@ -46,108 +113,8 @@ memory at 0 { device_type = "memory"; - reg = <0x10000000 0x08000000>, - <0x07fff400 0x00000400>; + reg = <0xd0000000 0x08000000>, + <0xc7fff400 0x00000400>; }; - sopc at 0 { - device_type = "soc"; - ranges; - #address-cells = <1>; - #size-cells = <1>; - compatible = "altr,avalon", "simple-bus"; - bus-frequency = <125000000>; - - pb_cpu_to_io: bridge at 0x8000000 { - compatible = "simple-bus"; - reg = <0x08000000 0x00800000>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x00002000 0x08002000 0x00002000>, - <0x00004000 0x08004000 0x00000400>, - <0x00004400 0x08004400 0x00000040>, - <0x00004800 0x08004800 0x00000040>, - <0x00004c80 0x08004c80 0x00000020>, - <0x00004d50 0x08004d50 0x00000008>, - <0x00008000 0x08008000 0x00000020>, - <0x00400000 0x08400000 0x00000020>; - - timer_1ms: timer at 0x400000 { - compatible = "altr,timer-1.0"; - reg = <0x00400000 0x00000020>; - interrupt-parent = <&cpu>; - interrupts = <11>; - clock-frequency = <125000000>; - }; - - timer_0: timer at 0x8000 { - compatible = "altr,timer-1.0"; - reg = < 0x00008000 0x00000020 >; - interrupt-parent = < &cpu >; - interrupts = < 5 >; - clock-frequency = < 125000000 >; - }; - - jtag_uart: serial at 0x4d50 { - compatible = "altr,juart-1.0"; - reg = <0x00004d50 0x00000008>; - interrupt-parent = <&cpu>; - interrupts = <1>; - }; - - tse_mac: ethernet at 0x4000 { - compatible = "altr,tse-1.0"; - reg = <0x00004000 0x00000400>, - <0x00004400 0x00000040>, - <0x00004800 0x00000040>, - <0x00002000 0x00002000>; - reg-names = "control_port", "rx_csr", "tx_csr", "s1"; - interrupt-parent = <&cpu>; - interrupts = <2 3>; - interrupt-names = "rx_irq", "tx_irq"; - rx-fifo-depth = <8192>; - tx-fifo-depth = <8192>; - max-frame-size = <1518>; - local-mac-address = [ 00 00 00 00 00 00 ]; - phy-mode = "rgmii-id"; - phy-handle = <&phy0>; - tse_mac_mdio: mdio { - compatible = "altr,tse-mdio"; - #address-cells = <1>; - #size-cells = <0>; - phy0: ethernet-phy at 18 { - reg = <18>; - device_type = "ethernet-phy"; - }; - }; - }; - - uart: serial at 0x4c80 { - compatible = "altr,uart-1.0"; - reg = <0x00004c80 0x00000020>; - interrupt-parent = <&cpu>; - interrupts = <10>; - current-speed = <115200>; - clock-frequency = <62500000>; - }; - }; - - cfi_flash_64m: flash at 0x0 { - compatible = "cfi-flash"; - reg = <0x00000000 0x04000000>; - bank-width = <2>; - device-width = <1>; - #address-cells = <1>; - #size-cells = <1>; - - partition at 800000 {
arch/nios2/dts/3c120_devboard.dts line 120
Quoted 10 lines
arch/nios2/dts/3c120_devboard.dts +0
-9- reg = <0x00800000 0x01e00000>; - label = "JFFS2 Filesystem"; - }; - }; - }; - - chosen { - bootargs = "debug console=ttyJ0,115200"; - }; };
Thanks,
Stefan
PATCH 1/2 nios2: remap and translate reg address in device tree
Hi Stefan,
Quoted 5 lines · Stefan Roese
So you are changing the DT sources for your platform because the U-Boot implementation does support the bus translation correctly (ranges properties)? I think this is the wrong approach. We need to make sure that U-Boot supports DT correctly instead. I have a patch queued to enable this. Please take a look at this thread:
Thanks a lot. So nice! This is almost the same as what I had tried but didn't work yet last day. I will try out this patch and let you know.
Best regards,
Thomas Chou