Skip to contentSkip to conversation

lib: utils/serial: Support Synopsys DesignWare APB UART

PATCH New Bin Meng 3 participants 7 messages May 14, 2021 – May 19, 2021

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 lib: utils/serial: Support Synopsys DesignWare APB UART

Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board.

With this patch, the generic platform firmware can be used out of the box on the BeagleV board.

---

 lib/utils/serial/fdt_serial_uart8250.c | 1 +
 1 file changed, 1 insertion(+)
lib/utils/serial/fdt_serial_uart8250.c +1 -0
index 918193a..36f364c 100644
@@ -28,6 +28,7 @@ static int serial_uart8250_init(void *fdt, int nodeoff,
 static const struct fdt_match serial_uart8250_match[] = {
 	{ .compatible = "ns16550" },
 	{ .compatible = "ns16550a" },
+	{ .compatible = "snps,dw-apb-uart" },
 	{ },
 };
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 20 lines · Bin Meng

Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board.

With this patch, the generic platform firmware can be used out of the box on the BeagleV board.

---

lib/utils/serial/fdt_serial_uart8250.c | 1 +

1 file changed, 1 insertion(+)
lib/utils/serial/fdt_serial_uart8250.c +0 -0
index 918193a..36f364c 100644

lib/utils/serial/fdt_serial_uart8250.c static int serial_uart8250_init(void *fdt, int nodeoff, · line 31

Quoted 4 lines
lib/utils/serial/fdt_serial_uart8250.c +1 -0
@@ -28,6 +28,7 @@ static int serial_uart8250_init(void *fdt, int nodeoff,
 static const struct fdt_match serial_uart8250_match[] = {
 	{ .compatible = "ns16550" },
 	{ .compatible = "ns16550a" },
+	{ .compatible = "snps,dw-apb-uart" },

If it?s compatible, why does it not use

  compatible = ?snps,dw-apb-uart?, ?ns16550?;

or similar in its FDT?

Jess

author
#2 lore raw

PATCH 1/1 lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 29 lines · Jessica Clarke
Quoted 20 lines · Bin Meng

Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board.

With this patch, the generic platform firmware can be used out of the box on the BeagleV board.

---

lib/utils/serial/fdt_serial_uart8250.c | 1 +

1 file changed, 1 insertion(+)
lib/utils/serial/fdt_serial_uart8250.c +0 -0
index 918193a..36f364c 100644

lib/utils/serial/fdt_serial_uart8250.c static int serial_uart8250_init(void *fdt, int nodeoff, · line 31

Quoted 4 lines
lib/utils/serial/fdt_serial_uart8250.c +1 -0
@@ -28,6 +28,7 @@ static int serial_uart8250_init(void *fdt, int nodeoff,
 static const struct fdt_match serial_uart8250_match[] = {
      { .compatible = "ns16550" },
      { .compatible = "ns16550a" },
+     { .compatible = "snps,dw-apb-uart" },

If it?s compatible, why does it not use

Quoted 3 lines
  compatible = ?snps,dw-apb-uart?, ?ns16550?;

or similar in its FDT?

Good question. By looking at the Linux kernel driver, it is supported as a variant of 8250 (drivers/tty/serial/8250/8250_dw.c).

I have not looked into details, but I suspect there are some minor oddities which matter for the kernel. The existing driver is enough to make OpenSBI happy.

Regards,
Bin

#3 lore raw

PATCH 1/1 lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 33 lines · Bin Meng
Quoted 31 lines · Jessica Clarke
Quoted 20 lines · Bin Meng

Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board.

With this patch, the generic platform firmware can be used out of the box on the BeagleV board.

---

lib/utils/serial/fdt_serial_uart8250.c | 1 +

1 file changed, 1 insertion(+)
lib/utils/serial/fdt_serial_uart8250.c +0 -0
index 918193a..36f364c 100644

lib/utils/serial/fdt_serial_uart8250.c static int serial_uart8250_init(void *fdt, int nodeoff, · line 31

Quoted 4 lines
lib/utils/serial/fdt_serial_uart8250.c +1 -0
@@ -28,6 +28,7 @@ static int serial_uart8250_init(void *fdt, int nodeoff,
 static const struct fdt_match serial_uart8250_match[] = {
     { .compatible = "ns16550" },
     { .compatible = "ns16550a" },
+     { .compatible = "snps,dw-apb-uart" },

If it?s compatible, why does it not use

compatible = ?snps,dw-apb-uart?, ?ns16550?;

Quoted 8 lines
Quoted 1 line

or similar in its FDT?

Good question. By looking at the Linux kernel driver, it is supported as a variant of 8250 (drivers/tty/serial/8250/8250_dw.c).

I have not looked into details, but I suspect there are some minor oddities which matter for the kernel. The existing driver is enough to make OpenSBI happy.

It seems there are various additional clocks and resets you may need to handle (baudclk is required, apb_pclk is optional and there?s an optional reset too). For this particular board the FDT has a them clocks as all fixed-clock, but in general this is not a correct implementation of the driver, as the clocks must be enabled when attaching.

Jess

author
#4 lore raw

PATCH 1/1 lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 44 lines · Jessica Clarke
Quoted 33 lines · Bin Meng
Quoted 31 lines · Jessica Clarke
Quoted 20 lines · Bin Meng

Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board.

With this patch, the generic platform firmware can be used out of the box on the BeagleV board.

---

lib/utils/serial/fdt_serial_uart8250.c | 1 +

1 file changed, 1 insertion(+)
lib/utils/serial/fdt_serial_uart8250.c +0 -0
index 918193a..36f364c 100644

lib/utils/serial/fdt_serial_uart8250.c static int serial_uart8250_init(void *fdt, int nodeoff, · line 31

Quoted 4 lines
lib/utils/serial/fdt_serial_uart8250.c +1 -0
@@ -28,6 +28,7 @@ static int serial_uart8250_init(void *fdt, int nodeoff,
 static const struct fdt_match serial_uart8250_match[] = {
     { .compatible = "ns16550" },
     { .compatible = "ns16550a" },
+     { .compatible = "snps,dw-apb-uart" },

If it?s compatible, why does it not use

compatible = ?snps,dw-apb-uart?, ?ns16550?;

Quoted 8 lines
Quoted 1 line

or similar in its FDT?

Good question. By looking at the Linux kernel driver, it is supported as a variant of 8250 (drivers/tty/serial/8250/8250_dw.c).

I have not looked into details, but I suspect there are some minor oddities which matter for the kernel. The existing driver is enough to make OpenSBI happy.

Quoted 5 lines

It seems there are various additional clocks and resets you may need to handle (baudclk is required, apb_pclk is optional and there?s an optional reset too). For this particular board the FDT has a them clocks as all fixed-clock, but in general this is not a correct implementation of the driver, as the clocks must be enabled when attaching.

I don't think OpenSBI needs to handle the clock and reset of each peripheral in its driver. Such should to be done in the bootloader, i.e.: U-Boot SPL.

Regards,
Bin

#5 lore raw

PATCH 1/1 lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 60 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 14 May 2021 07:48
To: Jessica Clarke <[email protected]>
Cc: Anup Patel <[email protected]>; OpenSBI <[email protected]>
Subject: Re: [PATCH] lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 4 lines · Jessica Clarke
Quoted 2 lines · Bin Meng

On Fri, May 14, 2021 at 9:19 AM Jessica Clarke <[email protected]>

Quoted 37 lines · wrote:
Quoted 37 lines
Quoted 30 lines · Bin Meng
Quoted 21 lines

Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board.

With this patch, the generic platform firmware can be used out of the box on the BeagleV board.

---

lib/utils/serial/fdt_serial_uart8250.c | 1 +

1 file changed, 1 insertion(+)
lib/utils/serial/fdt_serial_uart8250.c +0 -0
index 918193a..36f364c 100644

lib/utils/serial/fdt_serial_uart8250.c static int serial_uart8250_init(void *fdt, int · line 31

Quoted 4 lines
lib/utils/serial/fdt_serial_uart8250.c +1 -0
@@ -28,6 +28,7 @@ static int serial_uart8250_init(void *fdt, int
 nodeoff, static const struct fdt_match serial_uart8250_match[] = {
     { .compatible = "ns16550" },
     { .compatible = "ns16550a" },
+     { .compatible = "snps,dw-apb-uart" },

If it?s compatible, why does it not use

Quoted 3 lines

compatible = ?snps,dw-apb-uart?, ?ns16550?;

or similar in its FDT?

Good question. By looking at the Linux kernel driver, it is supported as a variant of 8250 (drivers/tty/serial/8250/8250_dw.c).

Quoted 6 lines
Quoted 3 lines

I have not looked into details, but I suspect there are some minor oddities which matter for the kernel. The existing driver is enough to make OpenSBI happy.

It seems there are various additional clocks and resets you may need to handle (baudclk is required, apb_pclk is optional and there?s an optional

Quoted 8 lines

reset too).

Quoted 3 lines

For this particular board the FDT has a them clocks as all fixed-clock, but in general this is not a correct implementation of the driver, as the clocks must be enabled when attaching.

I don't think OpenSBI needs to handle the clock and reset of each peripheral in its driver. Such should to be done in the bootloader,
i.e.: U-Boot SPL.

Most likely, we will not require to handle clock and reset of each peripheral. At least, the previous booting stage should set the "clock-frequency" DT property in UART DT node to be used as console.

Regarding this patch, I am fine with it because the 8250 DT bindings doesn?t mandate "ns16550" string to be always there. We lot of ARM64 DTS files having just "snps,dw-apb-uart" as compatible string.

Regards,
Anup

Applied
#6 lore raw

PATCH 1/1 lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 84 lines

-----Original Message-----
From: Anup Patel
Sent: 19 May 2021 12:05
To: 'Bin Meng' <[email protected]>; Jessica Clarke <[email protected]>
Cc: OpenSBI <[email protected]>
Subject: RE: [PATCH] lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 59 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: 14 May 2021 07:48
To: Jessica Clarke <[email protected]>
Cc: Anup Patel <[email protected]>; OpenSBI <[email protected]>
Subject: Re: [PATCH] lib: utils/serial: Support Synopsys DesignWare APB UART

Quoted 4 lines · Jessica Clarke
Quoted 2 lines · Bin Meng

On Fri, May 14, 2021 at 9:19 AM Jessica Clarke <[email protected]>

Quoted 37 lines · wrote:
Quoted 37 lines
Quoted 30 lines · Bin Meng
Quoted 21 lines

Synopsys DesignWare APB UART is seen on the StarFive JH7100 SoC. Its programming interface is compatible with the existing 8250 UART driver. Simply add its compatible string to the driver makes it work with the StarFive JH7100 SoC on a BeagleV board.

With this patch, the generic platform firmware can be used out of the box on the BeagleV board.

---

lib/utils/serial/fdt_serial_uart8250.c | 1 +

1 file changed, 1 insertion(+)
lib/utils/serial/fdt_serial_uart8250.c +0 -0
index 918193a..36f364c 100644

lib/utils/serial/fdt_serial_uart8250.c static int serial_uart8250_init(void *fdt, int · line 31

Quoted 4 lines
lib/utils/serial/fdt_serial_uart8250.c +1 -0
@@ -28,6 +28,7 @@ static int serial_uart8250_init(void *fdt, int
 nodeoff, static const struct fdt_match serial_uart8250_match[] = {
     { .compatible = "ns16550" },
     { .compatible = "ns16550a" },
+     { .compatible = "snps,dw-apb-uart" },

If it?s compatible, why does it not use

Quoted 3 lines

compatible = ?snps,dw-apb-uart?, ?ns16550?;

or similar in its FDT?

Good question. By looking at the Linux kernel driver, it is supported as a variant of 8250 (drivers/tty/serial/8250/8250_dw.c).

Quoted 7 lines
Quoted 3 lines

I have not looked into details, but I suspect there are some minor oddities which matter for the kernel. The existing driver is enough to make OpenSBI happy.

It seems there are various additional clocks and resets you may need to handle (baudclk is required, apb_pclk is optional and there?s an optional

Quoted 8 lines

reset too).

Quoted 3 lines

For this particular board the FDT has a them clocks as all fixed-clock, but in general this is not a correct implementation of the driver, as the clocks must be enabled when attaching.

I don't think OpenSBI needs to handle the clock and reset of each peripheral in its driver. Such should to be done in the bootloader, i.e.: U-Boot SPL.

Most likely, we will not require to handle clock and reset of each peripheral. At least, the previous booting stage should set the "clock-frequency" DT property in UART DT node to be used as console.

Quoted 5 lines

Regarding this patch, I am fine with it because the 8250 DT bindings doesn?t mandate "ns16550" string to be always there. We lot of
ARM64 DTS files having just "snps,dw-apb-uart" as compatible string.

Applied this patch to the riscv/opensbi repo.

Regards,
Anup

Quoted 3 lines

Regards,
Anup