nios2: Add Altera JTAG UART emulation
PATCH v6 1/1 nios2: Add Altera JTAG UART emulation
Add the Altera JTAG UART model.
Hardware emulation based on:
https://www.altera.com/en_US/pdfs/literature/ug/ug_embedded_ip.pdf
(Please see "Register Map" on page 65)
---
V2: - Removed link to hw specs(checkpatch: line over 90 characters)
V3: - New link to do hw specs
V4: - Modified check for correct fifo size
- Made fifo_size a property
- Use register offsets instead of register indeces
- Removed redundant test for fifo overflow
- Modified commit message
V5: - definine ALTERA_JTAG_UART_REGS_MEM_SIZE
- Modified commit message
- Replaced DEFAULT_FIFO_SIZE by ALTERA_JUART_DEFAULT_FIFO_SIZE
- Modified test for fifo size
- Simplified error message in altera_juart_create().
V6: - Removed confusing comments in altera_juart_write()
- Fixed error in altera_juart_create: max fifo size is 32768 not 3276
- altera_juart.h: fixed function prototype alignment
--- default-configs/nios2-softmmu.mak | 1 + hw/char/Makefile.objs | 1 + hw/char/altera_juart.c | 278 ++++++++++++++++++++++++++++++++++++++ include/hw/char/altera_juart.h | 46 +++++++ 4 files changed, 326 insertions(+) create mode 100644 hw/char/altera_juart.c create mode 100644 include/hw/char/altera_juart.h
default-configs/nios2-softmmu.mak +1 -0
@@ -4,3 +4,4 @@ CONFIG_NIOS2=y CONFIG_SERIAL=y CONFIG_PTIMER=y CONFIG_ALTERA_TIMER=y +CONFIG_ALTERA_JUART=y
hw/char/Makefile.objs +1 -0
@@ -27,5 +27,6 @@ common-obj-$(CONFIG_LM32) += lm32_juart.o common-obj-$(CONFIG_LM32) += lm32_uart.o common-obj-$(CONFIG_MILKYMIST) += milkymist-uart.o common-obj-$(CONFIG_SCLPCONSOLE) += sclpconsole.o sclpconsole-lm.o +common-obj-$(CONFIG_ALTERA_JUART) += altera_juart.o obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o
hw/char/altera_juart.c new file +278 -0
278 lines not on this page · raw message
include/hw/char/altera_juart.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 7 lines · Juro Bystricky
Add the Altera JTAG UART model.
Hardware emulation based on:
https://www.altera.com/en_US/pdfs/literature/ug/ug_embedded_ip.pdf
(Please see "Register Map" on page 65)Signed-off-by Juro Bystricky <[email protected]>
Signature · 2 lines
Best regards, Marek Vasut
Quoted 7 lines · Juro Bystricky
Add the Altera JTAG UART model.
Hardware emulation based on:
https://www.altera.com/en_US/pdfs/literature/ug/ug_embedded_ip.pdf
(Please see "Register Map" on page 65)Signed-off-by Juro Bystricky <[email protected]>
After instantiating an Altera UART in nios2_10m50_ghrd_init (hw/nios2/10m50_devboard.c) using the following:
altera_juart_create(1, 0xf8001530, irq[7], 64);
and adjusting the use of VMSTATE_VBUFFER_UINT32() to omit the _start argument (see below), I was able to successfully boot Linux with console on Altera JTAG UART with "qemu-system-nios2 -M 10m50-ghrd" using this patch.
Feel free to add my
Quoted 1 line
hw/char/altera_juart.c +0
-0
[...]
hw/char/altera_juart.c line 227
Quoted 8 lines
hw/char/altera_juart.c +8
-0+static const VMStateDescription vmstate_altera_juart = { + .name ="altera-juart" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (jdata, AlteraJUARTState), +VMSTATE_UINT32 (jcontrol, AlteraJUARTState), +VMSTATE_VBUFFER_UINT32 (rx_fifo, AlteraJUARTState,1 ,NULL ,0 , rx_fifo_size),
This should now be
VMSTATE_VBUFFER_UINT32(rx_fifo, AlteraJUARTState, 1, NULL, rx_fifo_size),
due to commit 59046ec29ad4 ("migration: consolidate VMStateField.start") getting rid of the _start macro argument.
Quoted 33 lines · Tobias Klauser
Quoted 7 lines · Juro Bystricky
Add the Altera JTAG UART model.
Hardware emulation based on:
https://www.altera.com/en_US/pdfs/literature/ug/ug_embedded_ip.pdf
(Please see "Register Map" on page 65)Signed-off-by Juro Bystricky <[email protected]>After instantiating an Altera UART in
nios2_10m50_ghrd_init(hw/nios2/10m50_devboard.c) using the following:altera_juart_create(1, 0xf8001530, irq[7], 64);and adjusting the use of
VMSTATE_VBUFFER_UINT32()to omit the_startargument (see below), I was able to successfully boot Linux with console on Altera JTAG UART with "qemu-system-nios2 -M 10m50-ghrd" using this patch.Feel free to add my
Tested-by Tobias Klauser <[email protected]>Quoted 1 line
hw/char/altera_juart.c +0
-0[...]
hw/char/altera_juart.c line 227
Quoted 8 lines
hw/char/altera_juart.c +8
-0+static const VMStateDescription vmstate_altera_juart = { + .name ="altera-juart" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT32 (jdata, AlteraJUARTState), +VMSTATE_UINT32 (jcontrol, AlteraJUARTState), +VMSTATE_VBUFFER_UINT32 (rx_fifo, AlteraJUARTState,1 ,NULL ,0 , rx_fifo_size),
Quoted 7 lines
This should now be
VMSTATE_VBUFFER_UINT32(rx_fifo, AlteraJUARTState, 1, NULL, rx_fifo_size),due to commit
59046ec29ad4("migration: consolidate VMStateField.start") getting rid of the_startmacro argument.
Cool, thanks for checking. Can we get a V7 ?
Signature · 2 lines
Best regards, Marek Vasut