Skip to content

Commit 48b545b

Browse files
ozbenhmpe
authored andcommitted
powerpc/microwatt: Use standard 16550 UART for console
This adds support to the Microwatt platform to use the standard 16550-style UART which available in the standalone Microwatt FPGA. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Paul Mackerras <[email protected]> Reviewed-by: Segher Boessenkool <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent aa9c5ad commit 48b545b

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-6
lines changed

arch/powerpc/boot/dts/microwatt.dts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
model-name = "microwatt";
77
compatible = "microwatt-soc";
88

9+
aliases {
10+
serial0 = &UART0;
11+
};
12+
913
reserved-memory {
1014
#size-cells = <0x02>;
1115
#address-cells = <0x02>;
@@ -89,12 +93,6 @@
8993
};
9094
};
9195

92-
chosen {
93-
bootargs = "";
94-
ibm,architecture-vec-5 = [19 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00
95-
00 00 00 00 00 00 00 00 40 00 40];
96-
};
97-
9896
soc@c0000000 {
9997
compatible = "simple-bus";
10098
#address-cells = <1>;
@@ -119,5 +117,22 @@
119117
#interrupt-cells = <2>;
120118
};
121119

120+
UART0: serial@2000 {
121+
device_type = "serial";
122+
compatible = "ns16550";
123+
reg = <0x2000 0x8>;
124+
clock-frequency = <100000000>;
125+
current-speed = <115200>;
126+
reg-shift = <2>;
127+
fifo-size = <16>;
128+
interrupts = <0x10 0x1>;
129+
};
130+
};
131+
132+
chosen {
133+
bootargs = "";
134+
ibm,architecture-vec-5 = [19 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00
135+
00 00 00 00 00 00 00 00 40 00 40];
136+
stdout-path = &UART0;
122137
};
123138
};

arch/powerpc/kernel/udbg_16550.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,42 @@ void __init udbg_init_40x_realmode(void)
296296
}
297297

298298
#endif /* CONFIG_PPC_EARLY_DEBUG_40x */
299+
300+
#ifdef CONFIG_PPC_EARLY_DEBUG_MICROWATT
301+
302+
#define UDBG_UART_MW_ADDR ((void __iomem *)0xc0002000)
303+
304+
static u8 udbg_uart_in_isa300_rm(unsigned int reg)
305+
{
306+
uint64_t msr = mfmsr();
307+
uint8_t c;
308+
309+
mtmsr(msr & ~(MSR_EE|MSR_DR));
310+
isync();
311+
eieio();
312+
c = __raw_rm_readb(UDBG_UART_MW_ADDR + (reg << 2));
313+
mtmsr(msr);
314+
isync();
315+
return c;
316+
}
317+
318+
static void udbg_uart_out_isa300_rm(unsigned int reg, u8 val)
319+
{
320+
uint64_t msr = mfmsr();
321+
322+
mtmsr(msr & ~(MSR_EE|MSR_DR));
323+
isync();
324+
eieio();
325+
__raw_rm_writeb(val, UDBG_UART_MW_ADDR + (reg << 2));
326+
mtmsr(msr);
327+
isync();
328+
}
329+
330+
void __init udbg_init_debug_microwatt(void)
331+
{
332+
udbg_uart_in = udbg_uart_in_isa300_rm;
333+
udbg_uart_out = udbg_uart_out_isa300_rm;
334+
udbg_use_uart();
335+
}
336+
337+
#endif /* CONFIG_PPC_EARLY_DEBUG_MICROWATT */

arch/powerpc/platforms/microwatt/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config PPC_MICROWATT
66
select PPC_ICS_NATIVE
77
select PPC_ICP_NATIVE
88
select PPC_NATIVE
9+
select PPC_UDBG_16550
910
help
1011
This option enables support for FPGA-based Microwatt implementations.
1112

arch/powerpc/platforms/microwatt/setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/machdep.h>
1515
#include <asm/time.h>
1616
#include <asm/xics.h>
17+
#include <asm/udbg.h>
1718

1819
static void __init microwatt_init_IRQ(void)
1920
{
@@ -35,5 +36,6 @@ define_machine(microwatt) {
3536
.name = "microwatt",
3637
.probe = microwatt_probe,
3738
.init_IRQ = microwatt_init_IRQ,
39+
.progress = udbg_progress,
3840
.calibrate_decr = generic_calibrate_decr,
3941
};

0 commit comments

Comments
 (0)