Skip to contentSkip to conversation

Add support for MStar MSC313 uarts

PATCH In review Daniel Palmer 5 participants 10 messages Mar 24, 2022 – Apr 1, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add support for MStar MSC313 uarts

This is a fairly simple series to add support for the MStar MSC313 uarts found in MStar/SigmaStar ARMv7 based SoCs.

I have been using this for years now but I held off sending it because I wasn't entirely sure the uart was actually a DW based design.

We got documentation recently and it refers to this being a "DW UART" so I'm pretty sure it is now.

Daniel Palmer (4):
dt-bindings: serial: snps-dw-apb-uart: Add MStar MSC313 uarts
serial: 8250_dw: Add MStar MSC313 quirk
ARM: dts: mstar: Switch pm_uart to mstar,msc313-uart
ARM: dts: mstar: Add second UART to base dtsi.

 .../devicetree/bindings/serial/snps-dw-apb-uart.yaml   |  3 +++
 arch/arm/boot/dts/mstar-v7.dtsi                        | 10 +++++++++-
 drivers/tty/serial/8250/8250_dw.c                      |  5 +++++
 3 files changed, 17 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/4 dt-bindings: serial: snps-dw-apb-uart: Add MStar MSC313 uarts

Add compatible for the MStar MSC313 uarts.

---
 Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml +3 -0
index 12137fe80acf..486e9deaef0f 100644
@@ -45,6 +45,9 @@ properties:
               - starfive,jh7100-hsuart
               - starfive,jh7100-uart
           - const: snps,dw-apb-uart
+      - items:
+          - const: mstar,msc313-uart
+          - const: snps,dw-apb-uart
       - const: snps,dw-apb-uart
 
   reg:
Signature · 1 line
2.35.1
#3 lore raw

PATCH 2/4 serial: 8250_dw: Add MStar MSC313 quirk

In reply to Daniel Palmer

The version of the IP used on the MStar MSC313 and later MStar and SigmaStar SoCs has the USR register at a different location. Add a quirk for this.

---
 drivers/tty/serial/8250/8250_dw.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/tty/serial/8250/8250_dw.c +5 -0
index 1769808031c5..01737e5706a5 100644
@@ -416,6 +416,10 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
 			p->serial_out = dw8250_serial_out38x;
 		if (of_device_is_compatible(np, "starfive,jh7100-uart"))
 			p->set_termios = dw8250_do_set_termios;
+		if (of_device_is_compatible(np, "mstar,msc313-uart")) {
+			data->usr_reg = 0x7;
+			data->skip_autocfg = true;
+		}
 
 	} else if (acpi_dev_present("APMC0D08", NULL, -1)) {
 		p->iotype = UPIO_MEM32;
@@ -699,6 +703,7 @@ static const struct of_device_id dw8250_of_match[] = {
 	{ .compatible = "marvell,armada-38x-uart" },
 	{ .compatible = "renesas,rzn1-uart" },
 	{ .compatible = "starfive,jh7100-uart" },
+	{ .compatible = "mstar,msc313-uart" },
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dw8250_of_match);
Signature · 1 line
2.35.1
#4 lore raw

Re: [PATCH 2/4] serial: 8250_dw: Add MStar MSC313 quirk

Quoted 3 lines · Daniel Palmer

The version of the IP used on the MStar MSC313 and later MStar and SigmaStar SoCs has the USR register at a different location. Add a quirk for this.

I'm fine with the change if it goes before [1]. Otherwise you will need to rebase.

[1]: https://lore.kernel.org/linux-serial/[email protected]/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

PATCH 3/4 ARM: dts: mstar: Switch pm_uart to mstar,msc313-uart

In reply to Daniel Palmer

The UART used in these SoCs is actually a variant of the dw apb uart. Now there is a compatible string in that driver to handle the quirks switch the compatible for pm_uart over to mstar,msc313-uart.

---
 arch/arm/boot/dts/mstar-v7.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/mstar-v7.dtsi +1 -1
index c26ba9b7b6dd..8464a8f1b136 100644
@@ -175,7 +175,7 @@ gpio: gpio@207800 {
 			};
 
 			pm_uart: uart@221000 {
-				compatible = "ns16550a";
+				compatible = "mstar,msc313-uart", "snps,dw-apb-uart";
 				reg = <0x221000 0x100>;
 				reg-shift = <3>;
 				interrupts-extended = <&intc_irq GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
Signature · 1 line
2.35.1
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] ARM: dts: mstar: Switch pm_uart to mstar,msc313-uart

Hi Daniel,

Quoted 6 lines · Daniel Palmer

The UART used in these SoCs is actually a variant of the dw apb uart. Now there is a compatible string in that driver to handle the quirks switch the compatible for pm_uart over to mstar,msc313-uart.

#7 lore raw

PATCH 4/4 ARM: dts: mstar: Add second UART to base dtsi.

In reply to Daniel Palmer

Add the second UART to the base dtsi.

---
 arch/arm/boot/dts/mstar-v7.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/mstar-v7.dtsi +8 -0
index 8464a8f1b136..baf2422b9854 100644
@@ -182,6 +182,14 @@ pm_uart: uart@221000 {
 				clock-frequency = <172000000>;
 				status = "disabled";
 			};
+
+			uart1: uart@221200 {
+				compatible = "mstar,msc313-uart", "snps,dw-apb-uart";
+				reg = <0x221200 0x100>;
+				reg-shift = <3>;
+				interrupts-extended = <&intc_irq GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
+				status = "disabled";
+			};
 		};
 
 		imi: sram@a0000000 {
Signature · 1 line
2.35.1
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] ARM: dts: mstar: Add second UART to base dtsi.

Hi Daniel,

Quoted 4 lines · Daniel Palmer

Add the second UART to the base dtsi.

More context in the long message would help, imho. Otherwise:

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#9 lore raw

Re: [PATCH 4/4] ARM: dts: mstar: Add second UART to base dtsi.

In reply to Daniel Palmer
Quoted 13 lines · Daniel Palmer

Add the second UART to the base dtsi.

---
 arch/arm/boot/dts/mstar-v7.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/mstar-v7.dtsi +0 -0
index 8464a8f1b136..baf2422b9854 100644

arch/arm/boot/dts/mstar-v7.dtsi pm_uart: uart@221000 { · line 186

Quoted 5 lines
arch/arm/boot/dts/mstar-v7.dtsi +2 -0
@@ -182,6 +182,14 @@ pm_uart: uart@221000 {
                                clock-frequency = <172000000>;
                                status = "disabled";
                        };
+
+                       uart1: uart@221200 {

serial@...

Please run schema checks on your DT as that should be a warning that I don't have to tell you about.

Rob