All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@ozlabs.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH 06/11] powerpc: microwatt: Use standard 16550 UART for console
Date: Tue, 15 Jun 2021 09:01:27 +1000	[thread overview]
Message-ID: <YMffx9iB13wRUvqz@thinks.paulus.ozlabs.org> (raw)
In-Reply-To: <YMfeswgEHeXSLOUF@thinks.paulus.ozlabs.org>

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

This adds support to the Microwatt platform to use the standard
1655-style UART which available in the standalone Microwatt FPGA.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/boot/dts/microwatt.dts      | 25 ++++++++++++---
 arch/powerpc/kernel/udbg_16550.c         | 39 ++++++++++++++++++++++++
 arch/powerpc/platforms/microwatt/Kconfig |  1 +
 arch/powerpc/platforms/microwatt/setup.c |  2 ++
 4 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/boot/dts/microwatt.dts b/arch/powerpc/boot/dts/microwatt.dts
index 2e75600320e8..dbde200d4692 100644
--- a/arch/powerpc/boot/dts/microwatt.dts
+++ b/arch/powerpc/boot/dts/microwatt.dts
@@ -6,6 +6,10 @@ / {
 	model-name = "microwatt";
 	compatible = "microwatt-soc";
 
+	aliases {
+		serial0 = &UART0;
+	};
+
 	reserved-memory {
 		#size-cells = <0x02>;
 		#address-cells = <0x02>;
@@ -97,11 +101,6 @@ PowerPC,Microwatt@0 {
 		};
 	};
 
-	chosen {
-		bootargs = "";
-		ibm,architecture-vec-5 = [19 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 40];
-	};
-
 	soc@c0000000 {
 		compatible = "simple-bus";
 		#address-cells = <1>;
@@ -126,5 +125,21 @@ ICS: interrupt-controller@5000 {
 			#interrupt-cells = <2>;
 		};
 
+		UART0: serial@2000 {
+			device_type = "serial";
+			compatible = "ns16550";
+			reg = <0x2000 0x8>;
+			clock-frequency = <100000000>;
+			current-speed = <115200>;
+			reg-shift = <2>;
+			fifo-size = <16>;
+			interrupts = <0x10 0x1>;
+		};
+	};
+
+	chosen {
+		bootargs = "";
+		ibm,architecture-vec-5 = [19 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 40];
+		stdout-path = &UART0;
 	};
 };
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 9356b60d6030..8513aa49614e 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -296,3 +296,42 @@ void __init udbg_init_40x_realmode(void)
 }
 
 #endif /* CONFIG_PPC_EARLY_DEBUG_40x */
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_MICROWATT
+
+#define UDBG_UART_MW_ADDR	((void __iomem *)0xc0002000)
+
+static u8 udbg_uart_in_isa300_rm(unsigned int reg)
+{
+	uint64_t msr = mfmsr();
+	uint8_t  c;
+
+	mtmsr(msr & ~(MSR_EE|MSR_DR));
+	isync();
+	eieio();
+	c = __raw_rm_readb(UDBG_UART_MW_ADDR + (reg << 2));
+	mtmsr(msr);
+	isync();
+	return c;
+}
+
+static void udbg_uart_out_isa300_rm(unsigned int reg, u8 val)
+{
+	uint64_t msr = mfmsr();
+
+	mtmsr(msr & ~(MSR_EE|MSR_DR));
+	isync();
+	eieio();
+	__raw_rm_writeb(val, UDBG_UART_MW_ADDR + (reg << 2));
+	mtmsr(msr);
+	isync();
+}
+
+void __init udbg_init_debug_microwatt(void)
+{
+	udbg_uart_in = udbg_uart_in_isa300_rm;
+	udbg_uart_out = udbg_uart_out_isa300_rm;
+	udbg_use_uart();
+}
+
+#endif /* CONFIG_PPC_EARLY_DEBUG_MICROWATT */
diff --git a/arch/powerpc/platforms/microwatt/Kconfig b/arch/powerpc/platforms/microwatt/Kconfig
index b52c869c0eb8..50ed0cedb5f1 100644
--- a/arch/powerpc/platforms/microwatt/Kconfig
+++ b/arch/powerpc/platforms/microwatt/Kconfig
@@ -6,6 +6,7 @@ config PPC_MICROWATT
 	select PPC_ICS_NATIVE
 	select PPC_ICP_NATIVE
 	select PPC_NATIVE
+	select PPC_UDBG_16550
 	help
           This option enables support for FPGA-based Microwatt implementations.
 
diff --git a/arch/powerpc/platforms/microwatt/setup.c b/arch/powerpc/platforms/microwatt/setup.c
index 1c1b7791fa57..0b02603bdb74 100644
--- a/arch/powerpc/platforms/microwatt/setup.c
+++ b/arch/powerpc/platforms/microwatt/setup.c
@@ -14,6 +14,7 @@
 #include <asm/machdep.h>
 #include <asm/time.h>
 #include <asm/xics.h>
+#include <asm/udbg.h>
 
 static void __init microwatt_init_IRQ(void)
 {
@@ -35,5 +36,6 @@ define_machine(microwatt) {
 	.name			= "microwatt",
 	.probe			= microwatt_probe,
 	.init_IRQ		= microwatt_init_IRQ,
+	.progress		= udbg_progress,
 	.calibrate_decr		= generic_calibrate_decr,
 };
-- 
2.31.1


  parent reply	other threads:[~2021-06-14 23:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 22:56 [PATCH 00/11] powerpc: Add support for Microwatt soft-core Paul Mackerras
2021-06-14 22:57 ` [PATCH 01/11] powerpc: Add Microwatt platform Paul Mackerras
2021-06-16 18:40   ` Segher Boessenkool
2021-06-16 22:24     ` Paul Mackerras
2021-06-14 22:58 ` [PATCH 02/11] powerpc: Add Microwatt device tree Paul Mackerras
2021-06-17  4:41   ` Michael Ellerman
2021-06-18  2:58     ` Paul Mackerras
2021-06-14 22:59 ` [PATCH 03/11] powerpc/radix: Add support for microwatt's PRTBL SPR Paul Mackerras
2021-06-15  1:12   ` Nicholas Piggin
2021-06-14 23:00 ` [PATCH 04/11] powerpc/microwatt: Populate platform bus from device-tree Paul Mackerras
2021-06-14 23:00 ` [PATCH 05/11] powerpc/xics: Add a native ICS backend for microwatt Paul Mackerras
2021-06-14 23:01 ` Paul Mackerras [this message]
2021-06-16 20:42   ` [PATCH 06/11] powerpc: microwatt: Use standard 16550 UART for console Segher Boessenkool
2021-06-14 23:02 ` [PATCH 07/11] powerpc: Add support for microwatt's hardware random number generator Paul Mackerras
2021-06-15  1:40   ` Nicholas Piggin
2021-06-16 13:16     ` Michael Ellerman
2021-06-16 22:22       ` Paul Mackerras
2021-06-14 23:02 ` [PATCH 08/11] powerpc/microwatt: Add microwatt_defconfig Paul Mackerras
2021-06-14 23:03 ` [PATCH 10/11] powerpc/microwatt: Add a boot wrapper for Microwatt Paul Mackerras
2021-06-14 23:04 ` [PATCH 09/11] powerpc: boot: Fixup device-tree on little endian Paul Mackerras
2021-06-14 23:05 ` [PATCH 11/11] powerpc/microwatt: Disable interrupts in boot wrapper main program Paul Mackerras
2021-06-15  1:21   ` Nicholas Piggin
2021-06-16 23:37   ` Segher Boessenkool
2021-06-17  1:40     ` Nicholas Piggin
2021-06-17  4:06       ` Michael Ellerman
2021-06-17 16:54       ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YMffx9iB13wRUvqz@thinks.paulus.ozlabs.org \
    --to=paulus@ozlabs.org \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.