Skip to contentSkip to conversation

SiFive UART support

PATCH Superseded Anup Patel 3 participants 14 messages Dec 11, 2018 – Dec 17, 2018 1 message not in the archive

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

v2 cover SiFive UART support

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

The patches are based upon latest RISC-V UBoot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 48cbf6246052de10d35b616b5efb2f783904a49d

Changes since v1:
- Fixed copyright header in SiFive UART driver
- Imply SIFIVE_SERIAL for QEMU emulation instead of enabling it in defconfigs.

Anup Patel (2):
drivers: serial: Add SiFive UART driver
riscv: qemu: Imply SIFIVE_SERIAL for emulation

 board/emulation/qemu-riscv/Kconfig |   1 +
 drivers/serial/Kconfig             |  13 ++
 drivers/serial/Makefile            |   1 +
 drivers/serial/serial_sifive.c     | 191 +++++++++++++++++++++++++++++
 4 files changed, 206 insertions(+)
 create mode 100644 drivers/serial/serial_sifive.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/2 drivers: serial: Add SiFive UART driver

This patch adds SiFive UART driver. The driver is 100% DM driver and it determines input clock using clk framework.

---
 drivers/serial/Kconfig         |  13 +++
 drivers/serial/Makefile        |   1 +
 drivers/serial/serial_sifive.c | 191 +++++++++++++++++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 drivers/serial/serial_sifive.c
drivers/serial/Kconfig +13 -0
index 3bcc61e731..30f7e00557 100644
@@ -343,6 +343,13 @@ config DEBUG_UART_SANDBOX
 	  start up driver model. The driver will be available until the real
 	  driver model serial is running.
 
+config DEBUG_UART_SIFIVE
+	bool "SiFive UART"
+	help
+	  Select this to enable a debug UART using the serial_sifive driver. You
+	  will need to provide parameters to make this work. The driver will
+	  be available until the real driver-model serial is running.
+
 config DEBUG_UART_STM32
 	bool "STMicroelectronics STM32"
 	depends on STM32_SERIAL
@@ -685,6 +692,12 @@ config PXA_SERIAL
 	  If you have a machine based on a Marvell XScale PXA2xx CPU you
 	  can enable its onboard serial ports by enabling this option.
 
+config SIFIVE_SERIAL
+	bool "SiFive UART support"
+	depends on DM_SERIAL
+	help
+	  This driver supports the SiFive UART. If unsure say N.
+
 config STI_ASC_SERIAL
 	bool "STMicroelectronics on-chip UART"
 	depends on DM_SERIAL && ARCH_STI
drivers/serial/Makefile +1 -0
index b6377b1076..b6781535a8 100644
@@ -68,6 +68,7 @@ obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
 obj-$(CONFIG_OWL_SERIAL) += serial_owl.o
 obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o
 obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o
+obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
drivers/serial/serial_sifive.c new file +191 -0

191 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 1/2 drivers: serial: Add SiFive UART driver

Quoted 4 lines · Anup Patel

This patch adds SiFive UART driver. The driver is 100% DM driver and it determines input clock using clk framework.

Quoted 9 lines
---
 drivers/serial/Kconfig         |  13 +++
 drivers/serial/Makefile        |   1 +
 drivers/serial/serial_sifive.c | 191 +++++++++++++++++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 drivers/serial/serial_sifive.c
author
#3 lore raw

PATCH v2 2/2 riscv: qemu: Imply SIFIVE_SERIAL for emulation

In reply to Anup Patel

This patch enables SiFive UART driver for QEMU RISC-V emulation by implying SIFIVE_SERIAL on BOARD_SPECIFIC_OPTIONS.

---
 board/emulation/qemu-riscv/Kconfig | 1 +
 1 file changed, 1 insertion(+)
board/emulation/qemu-riscv/Kconfig +1 -0
index 56bb5337d4..436db01a53 100644
@@ -32,5 +32,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply CMD_FAT
 	imply BOARD_LATE_INIT
 	imply OF_BOARD_SETUP
+	imply SIFIVE_SERIAL
 
 endif
Signature · 1 line
2.17.1
#5 lore raw

v2 cover SiFive UART support

In reply to Anup Patel

Hi Anup,

Quoted 9 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

Could you please specify how to test this? I tried your v1 patch but U-Boot did not boot. I must have missed something ...

Quoted 9 lines

The patches are based upon latest RISC-V UBoot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 48cbf6246052de10d35b616b5efb2f783904a49d

Changes since v1:
- Fixed copyright header in SiFive UART driver
- Imply SIFIVE_SERIAL for QEMU emulation instead of enabling it in defconfigs.

Regards,
Bin

author
#6 lore raw

v2 cover SiFive UART support

Quoted 8 lines · Bin Meng

Hi Anup,

Quoted 4 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

Quoted 8 lines
Quoted 5 lines

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

Could you please specify how to test this? I tried your v1 patch but U-Boot did not boot. I must have missed something ...

To try this patches in M-mode do the following (in u-boot source directory):
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make
# qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio
-kernel ./u-boot
OR
# qemu-system-riscv64 -M virt -m 256M -display none -serial stdio
-kernel ./u-boot

Regards,
Anup

#7 lore raw

v2 cover SiFive UART support

Hi Anup,

Quoted 19 lines · Anup Patel
Quoted 8 lines · Bin Meng

Hi Anup,

Quoted 4 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

Quoted 8 lines
Quoted 5 lines

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

Could you please specify how to test this? I tried your v1 patch but U-Boot did not boot. I must have missed something ...

Quoted 7 lines

To try this patches in M-mode do the following (in u-boot source directory):
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make
# qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio
-kernel ./u-boot

I tried exactly the same, but no console output.

Quoted 4 lines

OR

# qemu-system-riscv64 -M virt -m 256M -display none -serial stdio
-kernel ./u-boot

Regards,
Bin

author
#8 lore raw

v2 cover SiFive UART support

Quoted 31 lines · Bin Meng

Hi Anup,

Quoted 19 lines · Anup Patel
Quoted 8 lines · Bin Meng

Hi Anup,

Quoted 4 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

Quoted 8 lines
Quoted 5 lines

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

Could you please specify how to test this? I tried your v1 patch but U-Boot did not boot. I must have missed something ...

Quoted 7 lines

To try this patches in M-mode do the following (in u-boot source directory):
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make
# qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio
-kernel ./u-boot
Quoted 2 lines

I tried exactly the same, but no console output.

Ahh, understood your problem.

There is a bug in QEMU FDT generation for sifive_u.

Here's the QEMU fix (which I have send to QEMU mailing list):

Return-Path: <[email protected]>
Received: from anup-ubuntu64.qualcomm.com ([49.207.50.107])
by smtp.googlemail.com with ESMTPSA id
19sm33410406pfs.108.2018.12.05.00.27.14

        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 05 Dec 2018 00:27:15 -0800 (PST)

From: Anup Patel <[email protected]>
To: qemu-riscv at nongnu.org
Cc: Anup Patel <[email protected]>
Subject: [PATCH 2/2] hw/riscv/sifive_u: Set 'clock-frequency' DT property for SiFive UART
Date: Wed,
5 Dec 2018 13:57:03 +0530
Message-Id: <[email protected]>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <[email protected]>
References: <[email protected]>

The 'clock-frequency' DT property is required by U-Boot to compute divider value. This patch sets 'clock-frequency' DT property of SiFive UART DT node (similar to virt machine).

---
 hw/riscv/sifive_u.c | 2 ++
 1 file changed, 2 insertions(+)
hw/riscv/sifive_u.c +0 -0
index b3a4352986..5fa666fefc 100644
@@ -238,6 +238,8 @@ static void create_fdt(SiFiveUState *s, const

struct MemmapEntry *memmap,

     qemu_fdt_setprop_cells(fdt, nodename, "reg",
         0x0, memmap[SIFIVE_U_UART0].base,
         0x0, memmap[SIFIVE_U_UART0].size);
+    qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency",
+        SIFIVE_U_CLOCK_FREQ / 2);
     qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", plic_phandle);
     qemu_fdt_setprop_cells(fdt, nodename, "interrupts", 1);
Signature · 5 lines
2.17.1


Regards,
Anup
#9 lore raw

v2 cover SiFive UART support

Quoted 33 lines · Anup Patel
Quoted 31 lines · Bin Meng

Hi Anup,

Quoted 26 lines · Anup Patel
Quoted 8 lines · Bin Meng

Hi Anup,

Quoted 4 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

Quoted 8 lines
Quoted 5 lines

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

Could you please specify how to test this? I tried your v1 patch but U-Boot did not boot. I must have missed something ...

To try this patches in M-mode do the following (in u-boot source directory):
# ARCH=riscv
# CROSS_COMPILE=riscv64-unknown-linux-gnu-

# make qemu-riscv64_defconfig
# make
# qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio
-kernel ./u-boot
Quoted 9 lines
Quoted 2 lines

I tried exactly the same, but no console output.

Ahh, understood your problem.

There is a bug in QEMU FDT generation for sifive_u.

Here's the QEMU fix (which I have send to QEMU mailing list):

With the new info, now I am able to boot U-Boot on QEMU sifive_u.

Regards,
Bin

author
#10 lore raw

v2 cover SiFive UART support

In reply to Anup Patel
Quoted 29 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

The patches are based upon latest RISC-V UBoot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 48cbf6246052de10d35b616b5efb2f783904a49d

Changes since v1:
- Fixed copyright header in SiFive UART driver
- Imply SIFIVE_SERIAL for QEMU emulation instead of enabling it in defconfigs.

Anup Patel (2):
drivers: serial: Add SiFive UART driver
riscv: qemu: Imply SIFIVE_SERIAL for emulation

 board/emulation/qemu-riscv/Kconfig |   1 +
 drivers/serial/Kconfig             |  13 ++
 drivers/serial/Makefile            |   1 +
 drivers/serial/serial_sifive.c     | 191 +++++++++++++++++++++++++++++
 4 files changed, 206 insertions(+)
 create mode 100644 drivers/serial/serial_sifive.c
Quoted 3 lines

--
2.17.1

Hi Rick,

The required QEMU fix has been submitted by Alistair Francis on QEMU mailing list.
(QEMU PATCH subject "sifive_u: Set 'clock-frequency' DT property for SiFive UART")

Can you please consider this series for U-Boot v2019.01?

Thanks,
Anup

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw

v2 cover SiFive UART support

Hi Anup

Quoted 42 lines
Quoted 42 lines

From: Anup Patel [mailto:anup at brainfault.org]
Sent: Friday, December 14, 2018 5:23 PM
To: Rick Jian-Zhi Chen(陳建志); Bin Meng; Lukas Auer
Cc: Alexander Graf; Palmer Dabbelt; Atish Patra; Christoph Hellwig; U-Boot Mailing List
Subject: Re: [PATCH v2 0/2] SiFive UART support

Quoted 28 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

The patches are based upon latest RISC-V UBoot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 48cbf6246052de10d35b616b5efb2f783904a49d

Changes since v1:
- Fixed copyright header in SiFive UART driver
- Imply SIFIVE_SERIAL for QEMU emulation instead
of enabling it in defconfigs.

Anup Patel (2):
drivers: serial: Add SiFive UART driver
riscv: qemu: Imply SIFIVE_SERIAL for emulation

 board/emulation/qemu-riscv/Kconfig |   1 +
 drivers/serial/Kconfig             |  13 ++
 drivers/serial/Makefile            |   1 +
 drivers/serial/serial_sifive.c     | 191 +++++++++++++++++++++++++++++
 4 files changed, 206 insertions(+)
 create mode 100644 drivers/serial/serial_sifive.c
Quoted 3 lines

--
2.17.1

Hi Rick,

Quoted 7 lines
Quoted 7 lines

The required QEMU fix has been submitted by Alistair Francis on QEMU mailing list.
(QEMU PATCH subject "sifive_u: Set 'clock-frequency' DT property for SiFive UART")

Can you please consider this series for U-Boot v2019.01?

OK
I will include yours in this PR.

B.R
Rick

Quoted 2 lines
Quoted 2 lines

Thanks,
Anup

author
#13 lore raw

v2 cover SiFive UART support

Quoted 50 lines · Rick Chen

Hi Anup

Quoted 47 lines
Quoted 47 lines

From: Anup Patel [mailto:anup at brainfault.org]
Sent: Friday, December 14, 2018 5:23 PM
To: Rick Jian-Zhi Chen(陳建志); Bin Meng; Lukas Auer
Cc: Alexander Graf; Palmer Dabbelt; Atish Patra; Christoph Hellwig; U-Boot Mailing List
Subject: Re: [PATCH v2 0/2] SiFive UART support

Quoted 28 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

The patches are based upon latest RISC-V UBoot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 48cbf6246052de10d35b616b5efb2f783904a49d

Changes since v1:
- Fixed copyright header in SiFive UART driver
- Imply SIFIVE_SERIAL for QEMU emulation instead
of enabling it in defconfigs.

Anup Patel (2):
drivers: serial: Add SiFive UART driver
riscv: qemu: Imply SIFIVE_SERIAL for emulation

 board/emulation/qemu-riscv/Kconfig |   1 +
 drivers/serial/Kconfig             |  13 ++
 drivers/serial/Makefile            |   1 +
 drivers/serial/serial_sifive.c     | 191 +++++++++++++++++++++++++++++
 4 files changed, 206 insertions(+)
 create mode 100644 drivers/serial/serial_sifive.c
Quoted 3 lines

--
2.17.1

Hi Rick,

The required QEMU fix has been submitted by Alistair Francis on QEMU mailing list.
(QEMU PATCH subject "sifive_u: Set 'clock-frequency' DT property for SiFive UART")

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Can you please consider this series for U-Boot v2019.01?

OK
I will include yours in this PR.

I have send v3 of this patch. Please include that.

Thanks,
Anup

#14 lore raw

v2 cover SiFive UART support

Hi Anup

Anup Patel <[email protected]> 於 2018年12月17日 週一 下午12:15寫道:

Quoted 52 lines · Rick Chen
Quoted 50 lines

Hi Anup

Quoted 47 lines
Quoted 47 lines

From: Anup Patel [mailto:anup at brainfault.org]
Sent: Friday, December 14, 2018 5:23 PM
To: Rick Jian-Zhi Chen(陳建志); Bin Meng; Lukas Auer
Cc: Alexander Graf; Palmer Dabbelt; Atish Patra; Christoph Hellwig; U-Boot Mailing List
Subject: Re: [PATCH v2 0/2] SiFive UART support

Quoted 28 lines · Anup Patel

This patchset adds SiFive UART driver for SiFive UART found on SiFive boards.

The driver is tested on QEMU sifive_u machine. In fact, with this patchset same U-Boot binary boots on QEMU virt machine and QEMU sifive_u machine in both M-mode and S-mode.

The patches are based upon latest RISC-V UBoot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 48cbf6246052de10d35b616b5efb2f783904a49d

Changes since v1:
- Fixed copyright header in SiFive UART driver
- Imply SIFIVE_SERIAL for QEMU emulation instead
of enabling it in defconfigs.

Anup Patel (2):
drivers: serial: Add SiFive UART driver
riscv: qemu: Imply SIFIVE_SERIAL for emulation

 board/emulation/qemu-riscv/Kconfig |   1 +
 drivers/serial/Kconfig             |  13 ++
 drivers/serial/Makefile            |   1 +
 drivers/serial/serial_sifive.c     | 191 +++++++++++++++++++++++++++++
 4 files changed, 206 insertions(+)
 create mode 100644 drivers/serial/serial_sifive.c
Quoted 3 lines

--
2.17.1

Hi Rick,

The required QEMU fix has been submitted by Alistair Francis on QEMU mailing list.
(QEMU PATCH subject "sifive_u: Set 'clock-frequency' DT property for SiFive UART")

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Can you please consider this series for U-Boot v2019.01?

OK
I will include yours in this PR.

I have send v3 of this patch. Please include that.

Yes.
I fetch your v3 and apply to u-boot-riscv.git.
Travis is verifying.
Then I will send a PR later.

B.R
Rick

Quoted 2 lines

Thanks,
Anup