riscv: add initial LiteX SoC support
Subsystems (2)
cover riscv: add initial LiteX SoC support
This RFC patchseries adds initial LiteX RISC-V SoC support for barebox.
You can obtain this patchseries from github:
$ git clone -b 20190602.litex https://github.com/frantony/barebox
LiteX is a Migen-based System on Chip [1], supporting softcore VexRiscv CPU,
a 32-bits Linux Capable RISC-V CPU [2].
All the components used to create the LiteX SoC are open-source and the flexibility of Spinal HDL/Migen allow targeting easily very various FPGA devices/boards: Lattice, Altera, Xilinx, Microsemi FPGAs with SDRAM/DDR/DDR2/DDR3/DDR4 RAMs, RMII/MII/RGMII/1000BASE-X Ethernet PHYs.
The LiteX SoC with VexRiscv CPU can be deployed on e.g. Digilent ARTY board [3] or Terasic DE0-Nano board [4].
You can boot barebox from serial port using flterm [5]:, e.g.:
flterm --port /dev/ttyUSB0 --kernel <path_to_barebox.bin> --kernel-adr 0x40000000
TODO
====
* add pbl support for riscv barebox;
* add liteeth Ethernet core support [6] (tip: use ARTY board);
* fix issues (see the WIP commit);
* use barebox to start linux [2] and zephyr [7].
REFERENCES
==========
[1] https://github.com/enjoy-digital/litex
[2] https://github.com/enjoy-digital/linux-on-litex-vexriscv
[3] https://store.digilentinc.com/arty-a7-artix-7-fpga-development-board-for-makers-and-hobbyists/
[4] http://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&No=593
[5] https://github.com/timvideos/flterm
[6] https://github.com/enjoy-digital/liteeth
[7] https://github.com/zephyrproject-rtos/zephyr/tree/master/boards/riscv32/litex_vexriscv
Antony Pavlov (4):
riscv: add initial LiteX SoC support
serial: add litex UART driver
WIP: make it work on litex
riscv: add litex_defconfig
arch/riscv/Kconfig | 6 + arch/riscv/Makefile | 1 + arch/riscv/boot/start.S | 2 - arch/riscv/configs/litex_defconfig | 45 +++++++ arch/riscv/dts/litex-generic.dts | 17 +++ arch/riscv/dts/litex.dtsi | 36 +++++ arch/riscv/mach-litex/Kconfig | 11 ++ arch/riscv/mach-litex/Makefile | 3 + arch/riscv/mach-litex/include/mach/debug_ll.h | 124 ++++++++++++++++++ common/bootm.c | 2 + drivers/serial/Makefile | 1 + drivers/serial/serial_litex.c | 99 ++++++++++++++ 12 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 arch/riscv/configs/litex_defconfig create mode 100644 arch/riscv/dts/litex-generic.dts create mode 100644 arch/riscv/dts/litex.dtsi create mode 100644 arch/riscv/mach-litex/Kconfig create mode 100644 arch/riscv/mach-litex/Makefile create mode 100644 arch/riscv/mach-litex/include/mach/debug_ll.h create mode 100644 drivers/serial/serial_litex.c
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 1/4 riscv: add initial LiteX SoC support
LiteX is a Migen-based System on Chip, supporting softcore VexRiscv CPU,
a 32-bits Linux Capable RISC-V CPU.
See https://github.com/enjoy-digital/litex for details.
--- arch/riscv/Kconfig | 6 + arch/riscv/Makefile | 1 + arch/riscv/dts/litex-generic.dts | 17 +++ arch/riscv/dts/litex.dtsi | 36 +++++ arch/riscv/mach-litex/Kconfig | 11 ++ arch/riscv/mach-litex/Makefile | 3 + arch/riscv/mach-litex/include/mach/debug_ll.h | 124 ++++++++++++++++++ 7 files changed, 198 insertions(+)
arch/riscv/Kconfig +6 -0
@@ -24,6 +24,11 @@ config MACH_ERIZO select HAS_DEBUG_LL select HAS_NMON +config MACH_LITEX + bool "litex family" + select HAS_DEBUG_LL + select HAS_NMON + endchoice choice
@@ -63,6 +68,7 @@ config BUILTIN_DTB_NAME depends on BUILTIN_DTB source "arch/riscv/mach-erizo/Kconfig" +source "arch/riscv/mach-litex/Kconfig" endmenu
arch/riscv/Makefile +1 -0
@@ -12,6 +12,7 @@ LDFLAGS += $(ldflags-y) LDFLAGS_barebox += -nostdlib machine-$(CONFIG_MACH_ERIZO) := erizo +machine-$(CONFIG_MACH_LITEX) := litex TEXT_BASE = $(CONFIG_TEXT_BASE) CPPFLAGS += -DTEXT_BASE=$(CONFIG_TEXT_BASE)
arch/riscv/dts/litex-generic.dts new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include "litex.dtsi" + +/ { + model = "LiteX VexRiscV"; + compatible = "litex,vexriscv"; + + memory@40000000 { + device_type = "memory"; + reg = <0x40000000 0x00800000>; + }; +}; + +&uart0 { + status = "okay"; +};
arch/riscv/dts/litex.dtsi new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/dts-v1/; + +/ { + compatible = "litex,vexriscv", "litex-dev"; + + #address-cells = <1>; + #size-cells = <1>; + + clocks { + ref_clk: ref_clk { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <50000000>; + }; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "spinalhdl,vexriscv", "riscv"; + clocks = <&ref_clk>; + reg = <0>; + }; + }; + + uart0: serial@e0001800 { + compatible = "litex,uart"; + reg = <0xe0001800 0x18>; + status = "disabled"; + }; +};
arch/riscv/mach-litex/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +if MACH_LITEX + +choice + prompt "Board type" + +config BOARD_LITEX_GENERIC + bool "litex generic board" + +endchoice + +endif
arch/riscv/mach-litex/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# just to build a built-in.o. Otherwise compilation fails when no o-files is +# created. +obj- += dummy.o
arch/riscv/mach-litex/include/mach/debug_ll.h new file +124 -0
124 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 2/4 serial: add litex UART driver
In reply to Antony Pavlov--- drivers/serial/Makefile | 1 + drivers/serial/serial_litex.c | 99 +++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+)
drivers/serial/Makefile +1 -0
@@ -23,3 +23,4 @@ obj-$(CONFIG_DRIVER_SERIAL_CADENCE) += serial_cadence.o obj-$(CONFIG_DRIVER_SERIAL_EFI_STDIO) += efi-stdio.o obj-$(CONFIG_DRIVER_SERIAL_DIGIC) += serial_digic.o obj-$(CONFIG_DRIVER_SERIAL_LPUART) += serial_lpuart.o +obj-$(CONFIG_MACH_LITEX) += serial_litex.o
drivers/serial/serial_litex.c new file +99 -0
99 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 2/4] serial: add litex UART driver
Quoted 21 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>--- drivers/serial/Makefile | 1 + drivers/serial/serial_litex.c | 99 +++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+)drivers/serial/Makefile +1
-0@@ -23,3 +23,4 @@ obj-$(CONFIG_DRIVER_SERIAL_CADENCE) += serial_cadence.o obj-$(CONFIG_DRIVER_SERIAL_EFI_STDIO) += efi-stdio.o obj-$(CONFIG_DRIVER_SERIAL_DIGIC) += serial_digic.o obj-$(CONFIG_DRIVER_SERIAL_LPUART) += serial_lpuart.o +obj-$(CONFIG_MACH_LITEX) += serial_litex.odrivers/serial/serial_litex.c new file +0
-0
drivers/serial/serial_litex.c line 1
Quoted 1 line
drivers/serial/serial_litex.c new file +1
-0@@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.
Rest of the line is missing is here.
Quoted 4 lines
drivers/serial/serial_litex.c new file +4
-0+/* +* Copyright (C) 2019 Antony Pavlov <[email protected]> +* +* This file is part of barebox.
drivers/serial/serial_litex.c line 15
Quoted 10 lines
drivers/serial/serial_litex.c new file +10
-0+* See file CREDITS for list of people who contributed to this project. +* +*/ + +#include <common.h> +#include <init.h> +#include <malloc.h> +#include <io.h> + +#include <mach/debug_ll.h>
left-over header?
drivers/serial/serial_litex.c line 18
Quoted 3 lines
drivers/serial/serial_litex.c new file +3
-0+ +static inline uint32_t litex_serial_readb (struct console_device *cdev, +uint32_t offset)
Not a problem here, but I find it strange to have a readb that returns uint32_t.
Quoted 34 lines
drivers/serial/serial_litex.c new file +34
-0+{ +void __iomem *base = cdev->dev->priv; + +return readb (base + offset); +} + +static inline void litex_serial_writeb (struct console_device *cdev, +uint32_t value,uint32_t offset) +{ +void __iomem *base = cdev->dev->priv; + +writeb (value, base + offset); +} + +static void litex_serial_putc (struct console_device *cdev,char c) +{ +while (litex_serial_readb (cdev,UART_TXFULL )) + ; + +litex_serial_writeb (cdev, c,UART_RXTX ); +} + +static int litex_serial_getc (struct console_device *cdev) +{ +int c; + +while (litex_serial_readb (cdev,UART_RXEMPTY )) + ; + + c =litex_serial_readb (cdev,UART_RXTX ); + +/* refresh UART_RXEMPTY by writing UART_EV_RX to UART_EV_PENDING */ +litex_serial_writeb (cdev,UART_EV_RX ,UART_EV_PENDING ); +
drivers/serial/serial_litex.c line 62
Quoted 10 lines
drivers/serial/serial_litex.c new file +10
-0+return c; +} + +static int litex_serial_tstc (struct console_device *cdev) +{ +if (litex_serial_readb (cdev,UART_RXEMPTY )) { +return 0 ; + } + +return 1 ;
return !litex_serial_readb(cdev, UART_RXEMPTY)); ?
Quoted 38 lines
drivers/serial/serial_litex.c new file +37
-0+} + +static int litex_serial_probe (struct device_d *dev) +{ +struct resource *iores; +struct console_device *cdev; + + cdev =xzalloc (sizeof (struct console_device )); + iores =dev_request_mem_resource (dev,0 ); +if (IS_ERR (iores)) +return PTR_ERR (iores); + dev->priv =IOMEM (iores->start); + cdev->dev = dev; + cdev->tstc = &litex_serial_tstc; + cdev->putc = &litex_serial_putc; + cdev->getc = &litex_serial_getc; + cdev->setbrg =NULL ; + +console_register (cdev); + +return 0 ; +} + +static __maybe_unused struct of_device_id litex_serial_dt_ids[] = { + { + .compatible ="litex,uart" , + }, { +/* sentinel */ + } +}; + +static struct driver_d litex_serial_driver = { + .name ="litex-uart" , + .probe = litex_serial_probe, + .of_compatible =DRV_OF_COMPAT (litex_serial_dt_ids), +}; +console_platform_driver (litex_serial_driver);
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 2/4] serial: add litex UART driver
Quoted 12 lines · Ahmad Fatoum
Quoted 10 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>--- drivers/serial/Makefile | 1 + drivers/serial/serial_litex.c | 99 +++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+)drivers/serial/Makefile +0
-0
Quoted 4 lines
drivers/serial/Makefile
Quoted 2 lines
drivers/serial/Makefile +2
-0+ +#include <mach/debug_ll.h>left-over header?
Ah never mind, it's used for the register definitions.
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 3/4 WIP: make it work on litex
In reply to Antony Pavlov* litex platform does not use ns16550 at all
so debug_ll_ns16550_init should be eliminated;
* there is no IH_ARCH_RISCV definition in include/image.h
at the moment, so the error stops compiling:
common/bootm.c: In function 'bootm_open_os_uimage':
common/bootm.c:491:34: error: 'IH_ARCH' undeclared (first use in this function)
if (data->os->header.ih_arch != IH_ARCH) {
^~~~~~~
--- arch/riscv/boot/start.S | 2 -- common/bootm.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
arch/riscv/boot/start.S +0 -2
@@ -28,8 +28,6 @@ .globl _start _start: - debug_ll_ns16550_init - riscv_nmon li sp, STACK_BASE + STACK_SIZE
common/bootm.c +2 -0
@@ -487,11 +487,13 @@ static int bootm_open_os_uimage(struct image_data *data)uimage_print_contents (data->os); +#if 0 if (data->os->header.ih_arch !=IH_ARCH ) {printf ("Unsupported Architecture 0x%x\n" , data->os->header.ih_arch);return -EINVAL ; } +#endif if (data->os_address ==UIMAGE_SOME_ADDRESS ) data->os_address = data->os->header.ih_load;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 3/4] WIP: make it work on litex
Quoted 10 lines · Antony Pavlov
* litex platform does not use ns16550 at all
so debug_ll_ns16550_init should be eliminated;* there is no
IH_ARCH_RISCVdefinition ininclude/image.h
at the moment, so the error stops compiling:
common/bootm.c: In function 'bootm_open_os_uimage':
common/bootm.c:491:34: error: 'IH_ARCH' undeclared (first use in this function)
if (data->os->header.ih_arch!=IH_ARCH) {
^~~~~~~
U-Boot has IH_ARCH_RISCV already, you can copy it there.
Quoted 12 lines
Signed-off-by Antony Pavlov <[email protected]>--- arch/riscv/boot/start.S | 2 -- common/bootm.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)arch/riscv/boot/start.S +0
-0
arch/riscv/boot/start.S line 32
Quoted 5 lines
arch/riscv/boot/start.S +0
-2@@ -28,8 +28,6 @@ .globl _start _start: - debug_ll_ns16550_init -
This should be done by board code.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 4/4 riscv: add litex_defconfig
In reply to Antony Pavlov--- arch/riscv/configs/litex_defconfig | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/riscv/configs/litex_defconfig new file +45 -0
@@ -0,0 +1,45 @@ +CONFIG_MACH_LITEX=y +CONFIG_BUILTIN_DTB=y +CONFIG_BUILTIN_DTB_NAME="litex-generic" +CONFIG_NMON=y +CONFIG_NMON_HELP=y +CONFIG_TEXT_BASE=0x40000000 +CONFIG_MEMORY_LAYOUT_FIXED=y +CONFIG_STACK_BASE=0x400e0000 +CONFIG_STACK_SIZE=0x20000 +CONFIG_MALLOC_BASE=0x40100000 +CONFIG_MALLOC_SIZE=0x100000 +CONFIG_MALLOC_TLSF=y +CONFIG_PANIC_HANG=y +CONFIG_HUSH_FANCY_PROMPT=y +CONFIG_CMDLINE_EDITING=y +CONFIG_AUTO_COMPLETE=y +# CONFIG_ERRNO_MESSAGES is not set +# CONFIG_TIMESTAMP is not set +CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y +CONFIG_POLLER=y +CONFIG_DEBUG_LL=y +CONFIG_LONGHELP=y +CONFIG_CMD_IOMEM=y +CONFIG_CMD_IMD=y +CONFIG_CMD_MEMINFO=y +# CONFIG_CMD_BOOTM is not set +CONFIG_CMD_GO=y +CONFIG_CMD_LOADY=y +CONFIG_CMD_CMP=y +CONFIG_CMD_MD5SUM=y +CONFIG_CMD_SHA1SUM=y +CONFIG_CMD_MSLEEP=y +CONFIG_CMD_SLEEP=y +CONFIG_CMD_MEMTEST=y +CONFIG_CMD_MM=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_OF_DUMP=y +CONFIG_CMD_TIME=y +CONFIG_CMD_DHRYSTONE=y +CONFIG_OFDEVICE=y +# CONFIG_SPI is not set +CONFIG_CLOCKSOURCE_DUMMY_RATE=60000 +CONFIG_GPIO_GENERIC_PLATFORM=y +# CONFIG_PINCTRL is not set +CONFIG_DIGEST_CRC32_GENERIC=y
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Antony
Nice patch series, thanks for sharing.
Quoted 14 lines · Antony Pavlov
This RFC patchseries adds initial LiteX RISC-V SoC support for barebox.
You can obtain this patchseries from github:
$ git clone -b 20190602.litex https://github.com/frantony/bareboxLiteX is a Migen-based System on Chip [1], supporting softcore VexRiscv CPU,
a 32-bits Linux Capable RISC-V CPU [2].All the components used to create the LiteX SoC are open-source and the flexibility of Spinal HDL/Migen allow targeting easily very various FPGA devices/boards: Lattice, Altera, Xilinx, Microsemi FPGAs with SDRAM/DDR/DDR2/DDR3/DDR4 RAMs, RMII/MII/RGMII/1000BASE-X Ethernet PHYs.
Quoted 6 lines
The LiteX SoC with VexRiscv CPU can be deployed on e.g. Digilent ARTY board [3] or Terasic DE0-Nano board [4].
You can boot barebox from serial port using flterm [5]:, e.g.:
flterm --port
/dev/ttyUSB0--kernel <path_to_barebox.bin> --kernel-adr0x40000000
Can you be persuaded to include the above in a .rst file in Documentation, so others can find this info later?
Sam
Quoted 41 lines
TODO
====* add pbl support for riscv barebox;
* add liteeth Ethernet core support [6] (tip: use ARTY board);
* fix issues (see the WIP commit);
* use barebox to start linux [2] and zephyr [7].REFERENCES
==========[1] https://github.com/enjoy-digital/litex
[2] https://github.com/enjoy-digital/linux-on-litex-vexriscv
[3] https://store.digilentinc.com/arty-a7-artix-7-fpga-development-board-for-makers-and-hobbyists/
[4] http://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&No=593
[5] https://github.com/timvideos/flterm
[6] https://github.com/enjoy-digital/liteeth
[7] https://github.com/zephyrproject-rtos/zephyr/tree/master/boards/riscv32/litex_vexriscvAntony Pavlov (4):
riscv: add initial LiteX SoC support
serial: add litex UART driver
WIP: make it work on litex
riscv: addlitex_defconfigarch/riscv/Kconfig | 6 + arch/riscv/Makefile | 1 + arch/riscv/boot/start.S | 2 - arch/riscv/configs/litex_defconfig | 45 +++++++ arch/riscv/dts/litex-generic.dts | 17 +++ arch/riscv/dts/litex.dtsi | 36 +++++ arch/riscv/mach-litex/Kconfig | 11 ++ arch/riscv/mach-litex/Makefile | 3 + arch/riscv/mach-litex/include/mach/debug_ll.h | 124 ++++++++++++++++++ common/bootm.c | 2 + drivers/serial/Makefile | 1 + drivers/serial/serial_litex.c | 99 ++++++++++++++
Quoted 17 lines
12 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 arch/riscv/configs/litex_defconfig create mode 100644 arch/riscv/dts/litex-generic.dts create mode 100644 arch/riscv/dts/litex.dtsi create mode 100644 arch/riscv/mach-litex/Kconfig create mode 100644 arch/riscv/mach-litex/Makefile create mode 100644 arch/riscv/mach-litex/include/mach/debug_ll.h create mode 100644 drivers/serial/serial_litex.cSignature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox