forked from Mirrors/opensbi
lib: utils/serial: Add PXA UARTs support
The PXA variant of the uart8250 adds the UART Unit Enable bit (UUE) that needs to be set to enable the XScale PXA UART. And it is required for some RISC-V SoCs like the Spacemit K1 that implement the PXA UART. This introduces the "intel,xscale-uart" compatible to handle setting the UUE bit. Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250327-pxa-uart-support-v2-1-c4400c1fcd0b@pigmoral.tech Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
#include <sbi/sbi_types.h>
|
#include <sbi/sbi_types.h>
|
||||||
|
|
||||||
|
#define UART_CAP_UUE BIT(0) /* Check UUE capability for XScale PXA UARTs */
|
||||||
|
|
||||||
int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
||||||
u32 reg_width, u32 reg_offset);
|
u32 reg_width, u32 reg_offset, u32 caps);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -14,8 +14,9 @@
|
|||||||
static int serial_uart8250_init(const void *fdt, int nodeoff,
|
static int serial_uart8250_init(const void *fdt, int nodeoff,
|
||||||
const struct fdt_match *match)
|
const struct fdt_match *match)
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
struct platform_uart_data uart = { 0 };
|
struct platform_uart_data uart = { 0 };
|
||||||
|
ulong caps = (ulong)match->data;
|
||||||
|
int rc;
|
||||||
|
|
||||||
rc = fdt_parse_uart_node(fdt, nodeoff, &uart);
|
rc = fdt_parse_uart_node(fdt, nodeoff, &uart);
|
||||||
if (rc)
|
if (rc)
|
||||||
@@ -23,13 +24,15 @@ static int serial_uart8250_init(const void *fdt, int nodeoff,
|
|||||||
|
|
||||||
return uart8250_init(uart.addr, uart.freq, uart.baud,
|
return uart8250_init(uart.addr, uart.freq, uart.baud,
|
||||||
uart.reg_shift, uart.reg_io_width,
|
uart.reg_shift, uart.reg_io_width,
|
||||||
uart.reg_offset);
|
uart.reg_offset, caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct fdt_match serial_uart8250_match[] = {
|
static const struct fdt_match serial_uart8250_match[] = {
|
||||||
{ .compatible = "ns16550" },
|
{ .compatible = "ns16550" },
|
||||||
{ .compatible = "ns16550a" },
|
{ .compatible = "ns16550a" },
|
||||||
{ .compatible = "snps,dw-apb-uart" },
|
{ .compatible = "snps,dw-apb-uart" },
|
||||||
|
{ .compatible = "intel,xscale-uart",
|
||||||
|
.data = (void *)UART_CAP_UUE },
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -39,6 +39,12 @@
|
|||||||
#define UART_LSR_DR 0x01 /* Receiver data ready */
|
#define UART_LSR_DR 0x01 /* Receiver data ready */
|
||||||
#define UART_LSR_BRK_ERROR_BITS 0x1E /* BI, FE, PE, OE bits */
|
#define UART_LSR_BRK_ERROR_BITS 0x1E /* BI, FE, PE, OE bits */
|
||||||
|
|
||||||
|
/* The XScale PXA UARTs define these bits */
|
||||||
|
#define UART_IER_DMAE 0x80 /* DMA Requests Enable */
|
||||||
|
#define UART_IER_UUE 0x40 /* UART Unit Enable */
|
||||||
|
#define UART_IER_NRZE 0x20 /* NRZ coding Enable */
|
||||||
|
#define UART_IER_RTOIE 0x10 /* Receiver Time Out Interrupt Enable */
|
||||||
|
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
static volatile char *uart8250_base;
|
static volatile char *uart8250_base;
|
||||||
@@ -93,7 +99,7 @@ static struct sbi_console_device uart8250_console = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
||||||
u32 reg_width, u32 reg_offset)
|
u32 reg_width, u32 reg_offset, u32 caps)
|
||||||
{
|
{
|
||||||
u16 bdiv = 0;
|
u16 bdiv = 0;
|
||||||
|
|
||||||
@@ -109,7 +115,8 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disable all interrupts */
|
/* Disable all interrupts */
|
||||||
set_reg(UART_IER_OFFSET, 0x00);
|
set_reg(UART_IER_OFFSET, (caps & UART_CAP_UUE) ?
|
||||||
|
UART_IER_UUE : 0x00);
|
||||||
/* Enable DLAB */
|
/* Enable DLAB */
|
||||||
set_reg(UART_LCR_OFFSET, 0x80);
|
set_reg(UART_LCR_OFFSET, 0x80);
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#define ARIANE_UART_REG_SHIFT 2
|
#define ARIANE_UART_REG_SHIFT 2
|
||||||
#define ARIANE_UART_REG_WIDTH 4
|
#define ARIANE_UART_REG_WIDTH 4
|
||||||
#define ARIANE_UART_REG_OFFSET 0
|
#define ARIANE_UART_REG_OFFSET 0
|
||||||
|
#define ARIANE_UART_CAPS 0
|
||||||
#define ARIANE_PLIC_ADDR 0xc000000
|
#define ARIANE_PLIC_ADDR 0xc000000
|
||||||
#define ARIANE_PLIC_SIZE (0x200000 + \
|
#define ARIANE_PLIC_SIZE (0x200000 + \
|
||||||
(ARIANE_HART_COUNT * 0x1000))
|
(ARIANE_HART_COUNT * 0x1000))
|
||||||
@@ -78,7 +79,8 @@ static int ariane_early_init(bool cold_boot)
|
|||||||
ARIANE_UART_BAUDRATE,
|
ARIANE_UART_BAUDRATE,
|
||||||
ARIANE_UART_REG_SHIFT,
|
ARIANE_UART_REG_SHIFT,
|
||||||
ARIANE_UART_REG_WIDTH,
|
ARIANE_UART_REG_WIDTH,
|
||||||
ARIANE_UART_REG_OFFSET);
|
ARIANE_UART_REG_OFFSET,
|
||||||
|
ARIANE_UART_CAPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#define OPENPITON_DEFAULT_UART_REG_SHIFT 0
|
#define OPENPITON_DEFAULT_UART_REG_SHIFT 0
|
||||||
#define OPENPITON_DEFAULT_UART_REG_WIDTH 1
|
#define OPENPITON_DEFAULT_UART_REG_WIDTH 1
|
||||||
#define OPENPITON_DEFAULT_UART_REG_OFFSET 0
|
#define OPENPITON_DEFAULT_UART_REG_OFFSET 0
|
||||||
|
#define OPENPITON_DEFAULT_UART_CAPS 0
|
||||||
#define OPENPITON_DEFAULT_PLIC_ADDR 0xfff1100000
|
#define OPENPITON_DEFAULT_PLIC_ADDR 0xfff1100000
|
||||||
#define OPENPITON_DEFAULT_PLIC_SIZE (0x200000 + \
|
#define OPENPITON_DEFAULT_PLIC_SIZE (0x200000 + \
|
||||||
(OPENPITON_DEFAULT_HART_COUNT * 0x1000))
|
(OPENPITON_DEFAULT_HART_COUNT * 0x1000))
|
||||||
@@ -111,7 +112,8 @@ static int openpiton_early_init(bool cold_boot)
|
|||||||
return uart8250_init(uart.addr, uart.freq, uart.baud,
|
return uart8250_init(uart.addr, uart.freq, uart.baud,
|
||||||
OPENPITON_DEFAULT_UART_REG_SHIFT,
|
OPENPITON_DEFAULT_UART_REG_SHIFT,
|
||||||
OPENPITON_DEFAULT_UART_REG_WIDTH,
|
OPENPITON_DEFAULT_UART_REG_WIDTH,
|
||||||
OPENPITON_DEFAULT_UART_REG_OFFSET);
|
OPENPITON_DEFAULT_UART_REG_OFFSET,
|
||||||
|
OPENPITON_DEFAULT_UART_CAPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -75,7 +75,7 @@ static int platform_early_init(bool cold_boot)
|
|||||||
|
|
||||||
/* Example if the generic UART8250 driver is used */
|
/* Example if the generic UART8250 driver is used */
|
||||||
return uart8250_init(PLATFORM_UART_ADDR, PLATFORM_UART_INPUT_FREQ,
|
return uart8250_init(PLATFORM_UART_ADDR, PLATFORM_UART_INPUT_FREQ,
|
||||||
PLATFORM_UART_BAUDRATE, 0, 1, 0);
|
PLATFORM_UART_BAUDRATE, 0, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user