Skip to contentSkip to conversation

xen/arm: Add Amlogic Meson SoCs earlyprintk support

PATCH Superseded Amit Singh Tomar 3 participants 8 messages Jan 26, 2019 – Mar 21, 2019 Arm/Amlogic Meson SoC support

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 xen/arm: Add Amlogic Meson SoCs earlyprintk support

---
TODO:
* Capture XEN boot info on WIKI(just forgot my XEN Wiki credentials).

Changes since RFC:

* Replaced LDRH with LDR, with this there is no scattered output on console now.
* Used tbnz instead of tst and b.ne.
* Used AML_ prefix against register names.

---
 docs/misc/arm/early-printk.txt     |  1 +
 xen/arch/arm/arm64/debug-meson.inc | 51 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc
docs/misc/arm/early-printk.txt +1 -0
index f765f59..2aa9528 100644
@@ -41,6 +41,7 @@ the name of the machine:
   - juno: printk with pl011 on Juno platform
   - lager: printk with SCIF0 on Renesas R-Car H2 processors
   - midway: printk with the pl011 on Calxeda Midway processors
+  - meson: printk with the MESON for Amlogic S905 SoCs
   - mvebu: printk with the MVEBU for Marvell Armada 3700 SoCs
   - omap5432: printk with UART3 on TI OMAP5432 processors
   - rcar3: printk with SCIF2 on Renesas R-Car Gen3 processors
xen/arch/arm/arm64/debug-meson.inc new file +51 -0

51 lines not on this page · raw message

Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 2/2 xen/arm: Add MESON UART driver for Amlogic Meson SoCs

This patch adds driver for UART controller present on Amlogic Meson SoCs and it has been tested on Nanopi K2 board based on S905 SoC.

Controller registers defination is taken from Linux 4.20.

---
Changes since RFC:

* Removed S905 reference as other Amlogic SoCs have this uart controller.
* Replaced meson_s905_read/write helper with clrsetbit and friends helper.
* Followed proper UART reset sequence.
* List all UART compatible strings same as Linux driver.

---
 xen/drivers/char/Kconfig      |   8 ++
 xen/drivers/char/Makefile     |   1 +
 xen/drivers/char/meson-uart.c | 282 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 291 insertions(+)
 create mode 100644 xen/drivers/char/meson-uart.c
xen/drivers/char/Kconfig +8 -0
index b1f07f8..d4add7f 100644
@@ -20,6 +20,14 @@ config HAS_MVEBU
 	  This selects the Marvell MVEBU UART. If you have a ARMADA 3700
 	  based board, say Y.
 
+config HAS_MESON
+        bool "Amlogic MESON UART driver"
+        default y
+        depends on ARM_64
+        help
+          This selects the Amlogic MESON UART. If you have a Amlogic based
+          board, say Y.
+
 config HAS_PL011
 	bool "ARM PL011 UART driver"
 	default y
xen/drivers/char/Makefile +1 -0
index b68c330..7c646d7 100644
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MESON) += meson-uart.o
 obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
xen/drivers/char/meson-uart.c new file +282 -0

282 lines not on this page · raw message

Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

Re: [PATCH v1 2/2] xen/arm: Add MESON UART driver for Amlogic Meson SoCs

Hi Amit,

I will leave Andre to properly review the driver. But see the some comments below.

Quoted 4 lines · Amit Singh Tomar

This patch adds driver for UART controller present on Amlogic Meson SoCs and it has been tested on Nanopi K2 board based on S905 SoC.

Controller registers defination is taken from Linux 4.20.

defination/definition/

Also, please add a pointer to the driver in Linux.

Quoted 7 lines

---
Changes since RFC:

* Removed S905 reference as other Amlogic SoCs have this uart controller.

A link to the specification would have still been nice.

Quoted 9 lines

* Replaced meson_s905_read/write helper with clrsetbit and friends helper.
* Followed proper UART reset sequence.
* List all UART compatible strings same as Linux driver.

---
  xen/drivers/char/Kconfig      |   8 ++
  xen/drivers/char/Makefile     |   1 +
  xen/drivers/char/meson-uart.c | 282 ++++++++++++++++++++++++++++++++++++++++++

As Jan mentioned in the previous version, you want to update MAINTAINERS to add the file meson-uart.c under "ARM".

Quoted 8 lines
  3 files changed, 291 insertions(+)

create mode 100644 xen/drivers/char/meson-uart.c

xen/drivers/char/Kconfig +0 -0
index b1f07f8..d4add7f 100644

xen/drivers/char/Kconfig config HAS_MVEBU · line 29

Quoted 10 lines
xen/drivers/char/Kconfig +7 -0
@@ -20,6 +20,14 @@ config HAS_MVEBU
  	  This selects the Marvell MVEBU UART. If you have a ARMADA 3700
  	  based board, say Y.
 
+config HAS_MESON
+        bool "Amlogic MESON UART driver"
+        default y
+        depends on ARM_64
+        help
+          This selects the Amlogic MESON UART. If you have a Amlogic based
+          board, say Y.

The indentation still looks wrong to me. You want to use hard tab for Kconfig.

Quoted 67 lines
xen/drivers/char/Kconfig +1 -0
+
  config HAS_PL011
  	bool "ARM PL011 UART driver"
  	default y
xen/drivers/char/Makefile +1 -0
index b68c330..7c646d7 100644
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
  obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
  obj-$(CONFIG_HAS_PL011) += pl011.o
  obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MESON) += meson-uart.o
  obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
  obj-$(CONFIG_HAS_OMAP) += omap-uart.o
  obj-$(CONFIG_HAS_SCIF) += scif-uart.o
xen/drivers/char/meson-uart.c new file +45 -0
new file mode 100644
index 0000000..990ae95
@@ -0,0 +1,282 @@
+/*
+ * xen/drivers/char/meson-uart.c
+ *
+ * Driver for Amlogic MESON UART
+ *
+ * Copyright (c) 2019, Amit Singh Tomar <[email protected]>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/irq.h>
+#include <xen/serial.h>
+#include <xen/vmap.h>
+#include <asm/io.h>
+
+/* Register offsets */
+#define AML_UART_WFIFO_REG              0x00
+#define AML_UART_RFIFO_REG              0x04
+#define AML_UART_CONTROL_REG            0x08
+#define AML_UART_STATUS_REG             0x0c
+#define AML_UART_MISC_REG               0x10
+
+/* UART_CONTROL bits */
+#define AML_UART_TX_RST                 BIT(22)
+#define AML_UART_RX_RST                 BIT(23)
+#define AML_UART_CLEAR_ERR              BIT(24)
+#define AML_UART_RX_INT_EN              BIT(27)
+#define AML_UART_TX_INT_EN              BIT(28)
+
+/* UART_STATUS bits */
+#define AML_UART_RX_FIFO_EMPTY          BIT(20)
+#define AML_UART_TX_FIFO_FULL           BIT(21)
+#define AML_UART_TX_FIFO_EMPTY          BIT(22)
+#define AML_UART_TX_CNT_MASK            GENMASK(14, 8)
+

xen/drivers/char/meson-uart.c line 55

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+/* AML_UART_MISC bits */
+#define AML_UART_XMIT_IRQ(c)            (((c) & 0xff) << 8)
+#define AML_UART_RECV_IRQ(c)            ((c) & 0xff)
+
+#define TX_FIFO_SIZE                    64
+
+#define setbits(addr, set)              writel((readl(addr) | (set)), (addr))
+#define clrbits(addr, clear)            writel((readl(addr) & ~(clear)), (addr))
+#define clrsetbits(addr, clear, set)    writel(((readl(addr) & ~(clear)) \
+                                        | (set)), (addr))

I would prefer if you provide static inline helpers from *bits.

xen/drivers/char/meson-uart.c line 65

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+
+static struct meson_uart {
+    unsigned int irq;
+    void __iomem *regs;
+    struct irqaction irqaction;
+    struct vuart_info vuart;
+} meson_com;
+
+static void meson_uart_interrupt(int irq, void *data,
+                                      struct cpu_user_regs *regs)

The indentation looks wrong here.

xen/drivers/char/meson-uart.c line 74

Quoted 9 lines
xen/drivers/char/meson-uart.c new file +9 -0
+{
+    struct serial_port *port = data;
+    struct meson_uart *uart = port->uart;
+    uint32_t st = readl(uart->regs + AML_UART_STATUS_REG);
+
+    if ( !(st & AML_UART_RX_FIFO_EMPTY) )
+    {
+        serial_rx_interrupt(port, regs);
+    }

The {} are not necessary.

xen/drivers/char/meson-uart.c line 79

Quoted 5 lines
xen/drivers/char/meson-uart.c new file +5 -0
+
+    if ( !(st & AML_UART_TX_FIFO_FULL) )
+    {
+        serial_tx_interrupt(port, regs);
+    }

Same here.

Quoted 6 lines
xen/drivers/char/meson-uart.c new file +6 -0
+}
+
+static void __init meson_uart_init_preirq(struct serial_port *port)
+{
+    struct meson_uart *uart = port->uart;
+

xen/drivers/char/meson-uart.c line 95

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+    /* Reset UART */
+    setbits(uart->regs + AML_UART_CONTROL_REG,
+            (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR));
+
+    clrbits(uart->regs + AML_UART_CONTROL_REG,
+            (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR));
+
+    /* Disable Rx/Tx interrupts */
+    clrsetbits(uart->regs + AML_UART_CONTROL_REG,
+               (AML_UART_RX_INT_EN | AML_UART_TX_INT_EN), 0);

What is 0?

xen/drivers/char/meson-uart.c line 96

Quoted 1 line
xen/drivers/char/meson-uart.c new file +1 -0
+}

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw

Re: [PATCH v1 2/2] xen/arm: Add MESON UART driver for Amlogic Meson SoCs

In reply to Amit Singh Tomar
Quoted 105 lines · Amit Singh Tomar

This patch adds driver for UART controller present on Amlogic Meson SoCs and it has been tested on Nanopi K2 board based on S905 SoC.

Controller registers defination is taken from Linux 4.20.

---
Changes since RFC:

* Removed S905 reference as other Amlogic SoCs have this uart controller.
* Replaced meson_s905_read/write helper with clrsetbit and friends helper.
* Followed proper UART reset sequence.
* List all UART compatible strings same as Linux driver.

---
 xen/drivers/char/Kconfig      |   8 ++
 xen/drivers/char/Makefile     |   1 +
 xen/drivers/char/meson-uart.c | 282 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 291 insertions(+)
 create mode 100644 xen/drivers/char/meson-uart.c
xen/drivers/char/Kconfig +8 -0
index b1f07f8..d4add7f 100644
@@ -20,6 +20,14 @@ config HAS_MVEBU
 	  This selects the Marvell MVEBU UART. If you have a ARMADA 3700
 	  based board, say Y.
 
+config HAS_MESON
+        bool "Amlogic MESON UART driver"
+        default y
+        depends on ARM_64
+        help
+          This selects the Amlogic MESON UART. If you have a Amlogic based
+          board, say Y.
+
 config HAS_PL011
 	bool "ARM PL011 UART driver"
 	default y
xen/drivers/char/Makefile +1 -0
index b68c330..7c646d7 100644
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MESON) += meson-uart.o
 obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
xen/drivers/char/meson-uart.c new file +45 -0
new file mode 100644
index 0000000..990ae95
@@ -0,0 +1,282 @@
+/*
+ * xen/drivers/char/meson-uart.c
+ *
+ * Driver for Amlogic MESON UART
+ *
+ * Copyright (c) 2019, Amit Singh Tomar <[email protected]>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/irq.h>
+#include <xen/serial.h>
+#include <xen/vmap.h>
+#include <asm/io.h>
+
+/* Register offsets */
+#define AML_UART_WFIFO_REG              0x00
+#define AML_UART_RFIFO_REG              0x04
+#define AML_UART_CONTROL_REG            0x08
+#define AML_UART_STATUS_REG             0x0c
+#define AML_UART_MISC_REG               0x10
+
+/* UART_CONTROL bits */
+#define AML_UART_TX_RST                 BIT(22)
+#define AML_UART_RX_RST                 BIT(23)
+#define AML_UART_CLEAR_ERR              BIT(24)
+#define AML_UART_RX_INT_EN              BIT(27)
+#define AML_UART_TX_INT_EN              BIT(28)
+
+/* UART_STATUS bits */
+#define AML_UART_RX_FIFO_EMPTY          BIT(20)
+#define AML_UART_TX_FIFO_FULL           BIT(21)
+#define AML_UART_TX_FIFO_EMPTY          BIT(22)
+#define AML_UART_TX_CNT_MASK            GENMASK(14, 8)
+

xen/drivers/char/meson-uart.c line 55

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+/* AML_UART_MISC bits */
+#define AML_UART_XMIT_IRQ(c)            (((c) & 0xff) << 8)
+#define AML_UART_RECV_IRQ(c)            ((c) & 0xff)
+
+#define TX_FIFO_SIZE                    64
+
+#define setbits(addr, set)              writel((readl(addr) | (set)), (addr))
+#define clrbits(addr, clear)            writel((readl(addr) & ~(clear)), (addr))
+#define clrsetbits(addr, clear, set)    writel(((readl(addr) & ~(clear)) \
+                                        | (set)), (addr))

You don't seem to need this last one. Every user of it below sets "set" to 0, so it's effectively just clrbits().

And keeping the other two as macros is probably fine then.

xen/drivers/char/meson-uart.c line 65

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+
+static struct meson_uart {
+    unsigned int irq;
+    void __iomem *regs;
+    struct irqaction irqaction;
+    struct vuart_info vuart;
+} meson_com;
+
+static void meson_uart_interrupt(int irq, void *data,
+                                      struct cpu_user_regs *regs)

w/s

Quoted 20 lines
xen/drivers/char/meson-uart.c new file +20 -0
+{
+    struct serial_port *port = data;
+    struct meson_uart *uart = port->uart;
+    uint32_t st = readl(uart->regs + AML_UART_STATUS_REG);
+
+    if ( !(st & AML_UART_RX_FIFO_EMPTY) )
+    {
+        serial_rx_interrupt(port, regs);
+    }
+
+    if ( !(st & AML_UART_TX_FIFO_FULL) )
+    {
+        serial_tx_interrupt(port, regs);
+    }
+}
+
+static void __init meson_uart_init_preirq(struct serial_port *port)
+{
+    struct meson_uart *uart = port->uart;
+

xen/drivers/char/meson-uart.c line 95

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+    /* Reset UART */
+    setbits(uart->regs + AML_UART_CONTROL_REG,
+            (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR));
+
+    clrbits(uart->regs + AML_UART_CONTROL_REG,
+            (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR));
+
+    /* Disable Rx/Tx interrupts */
+    clrsetbits(uart->regs + AML_UART_CONTROL_REG,
+               (AML_UART_RX_INT_EN | AML_UART_TX_INT_EN), 0);

This is just clrbits(), which also means you can merge those last two calls into one.

xen/drivers/char/meson-uart.c line 108

Quoted 13 lines
xen/drivers/char/meson-uart.c new file +13 -0
+}
+
+static void __init meson_uart_init_postirq(struct serial_port *port)
+{
+    struct meson_uart *uart = port->uart;
+
+    uart->irqaction.handler = meson_uart_interrupt;
+    uart->irqaction.name    = "meson_uart";
+    uart->irqaction.dev_id  = port;
+
+    if ( setup_irq(uart->irq, 0, &uart->irqaction) != 0 )
+    {
+        printk("Failed to allocated meson_s905_uart IRQ %d\n", uart->irq);

Seems like a 905 leftover. Just "Failed to allocate Meson UART IRQ"?

Quoted 53 lines
xen/drivers/char/meson-uart.c new file +53 -0
+        return;
+    }
+
+    /*
+     * Configure Rx/Tx interrupts based on bytes in FIFO, these bits have
+     * taken from Linux driver
+     */
+    writel((AML_UART_RECV_IRQ(1) | AML_UART_XMIT_IRQ(TX_FIFO_SIZE / 2)),
+           uart->regs + AML_UART_MISC_REG);
+
+    /* Make sure Rx/Tx interrupts are enabled now */
+    setbits(uart->regs + AML_UART_CONTROL_REG,
+            (AML_UART_RX_INT_EN | AML_UART_TX_INT_EN));
+}
+
+static void meson_uart_suspend(struct serial_port *port)
+{
+    BUG();
+}
+
+static void meson_uart_resume(struct serial_port *port)
+{
+    BUG();
+}
+
+static void meson_uart_putc(struct serial_port *port, char c)
+{
+    struct meson_uart *uart = port->uart;
+
+    writel(c, uart->regs + AML_UART_WFIFO_REG);
+}
+
+static int meson_uart_getc(struct serial_port *port, char *c)
+{
+    struct meson_uart *uart = port->uart;
+
+    if ( (readl(uart->regs + AML_UART_STATUS_REG) & AML_UART_RX_FIFO_EMPTY) )
+        return 0;
+
+    *c = readl(uart->regs + AML_UART_RFIFO_REG) & 0xff;
+
+    return 1;
+}
+
+static int __init meson_irq(struct serial_port *port)
+{
+    struct meson_uart *uart = port->uart;
+
+    return uart->irq;
+}
+
+static const struct vuart_info *meson_vuart_info(struct serial_port *port)
+{

xen/drivers/char/meson-uart.c line 171

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+    struct meson_uart *uart = port->uart;
+
+    return &uart->vuart;
+}
+
+static void meson_uart_stop_tx(struct serial_port *port)
+{
+    struct meson_uart *uart = port->uart;
+
+    clrsetbits(uart->regs + AML_UART_CONTROL_REG, AML_UART_TX_INT_EN, 0);

Just clrbits().

The rest seems fine to me.
Briefly tested by booting Xen (no Dom0) on an Odroid C2. Both early printk and normale console output look alright.

Cheers,
Andre.

Quoted 102 lines
xen/drivers/char/meson-uart.c new file +101 -0
+}
+
+static void meson_uart_start_tx(struct serial_port *port)
+{
+    struct meson_uart *uart = port->uart;
+
+    setbits(uart->regs + AML_UART_CONTROL_REG, AML_UART_TX_INT_EN);
+}
+
+static int meson_uart_tx_ready(struct serial_port *port)
+{
+    struct meson_uart *uart = port->uart;
+    uint32_t reg;
+
+    reg = readl(uart->regs + AML_UART_STATUS_REG);
+
+    if ( reg & AML_UART_TX_FIFO_EMPTY )
+        return TX_FIFO_SIZE;
+    if ( reg & AML_UART_TX_FIFO_FULL )
+        return 0;
+
+    return (reg & AML_UART_TX_CNT_MASK) >> 8;
+}
+
+static struct uart_driver __read_mostly meson_uart_driver = {
+    .init_preirq  = meson_uart_init_preirq,
+    .init_postirq = meson_uart_init_postirq,
+    .endboot      = NULL,
+    .suspend      = meson_uart_suspend,
+    .resume       = meson_uart_resume,
+    .putc         = meson_uart_putc,
+    .getc         = meson_uart_getc,
+    .tx_ready     = meson_uart_tx_ready,
+    .stop_tx      = meson_uart_stop_tx,
+    .start_tx     = meson_uart_start_tx,
+    .irq          = meson_irq,
+    .vuart_info   = meson_vuart_info,
+};
+
+static int __init meson_uart_init(struct dt_device_node *dev, const void *data)
+{
+    const char *config = data;
+    struct meson_uart *uart;
+    int res;
+    u64 addr, size;
+
+    if ( strcmp(config, "") )
+        printk("WARNING: UART configuration is not supported\n");
+
+    uart = &meson_com;
+
+    res = dt_device_get_address(dev, 0, &addr, &size);
+    if ( res )
+    {
+        printk("meson: Unable to retrieve the base address of the UART\n");
+        return res;
+    }
+
+    res = platform_get_irq(dev, 0);
+    if ( res < 0 )
+    {
+        printk("meson: Unable to retrieve the IRQ\n");
+        return -EINVAL;
+    }
+
+    uart->irq  = res;
+
+    uart->regs = ioremap_nocache(addr, size);
+    if ( !uart->regs )
+    {
+        printk("meson: Unable to map the UART\n");
+        return -ENOMEM;
+    }
+
+    uart->vuart.base_addr = addr;
+    uart->vuart.size = size;
+    uart->vuart.data_off = AML_UART_WFIFO_REG;
+    uart->vuart.status_off = AML_UART_STATUS_REG;
+    uart->vuart.status = AML_UART_RX_FIFO_EMPTY | AML_UART_TX_FIFO_EMPTY;
+
+    /* Register with generic serial driver. */
+    serial_register_uart(SERHND_DTUART, &meson_uart_driver, uart);
+
+    dt_device_set_used_by(dev, DOMID_XEN);
+
+    return 0;
+}
+
+static const struct dt_device_match meson_dt_match[] __initconst =
+{
+    DT_MATCH_COMPATIBLE("amlogic,meson-uart"),
+    DT_MATCH_COMPATIBLE("amlogic,meson6-uart"),
+    DT_MATCH_COMPATIBLE("amlogic,meson8-uart"),
+    DT_MATCH_COMPATIBLE("amlogic,meson8b-uart"),
+    DT_MATCH_COMPATIBLE("amlogic,meson-gx-uart"),
+    { /* sentinel */ },
+};
+
+DT_DEVICE_START(meson, "Amlogic UART", DEVICE_SERIAL)
+    .dt_match = meson_dt_match,
+    .init = meson_uart_init,

xen/drivers/char/meson-uart.c line 282

Quoted 10 lines
xen/drivers/char/meson-uart.c new file +10 -0
+DT_DEVICE_END
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+*/

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
In reply to Amit Singh Tomar

Hi,

On 26/01/2019 08:53, Amit Singh Tomar wrote:

As pointed out by Andre on the previous version, the commit message is missing.

Among things that a commit message could describe is:
- Link to the specification
- Why we don't need to initialize the UART. I know we discussed about it on the
previous version. But a summary is always helpful if someone looked at the code in the future.

Quoted 23 lines

---
TODO:
* Capture XEN boot info on WIKI(just forgot my XEN Wiki credentials).

Changes since RFC:

* Replaced LDRH with LDR, with this there is no scattered output on console now.
* Used tbnz instead of tst and b.ne.
* Used AML_ prefix against register names.

---
  docs/misc/arm/early-printk.txt     |  1 +
  xen/arch/arm/arm64/debug-meson.inc | 51 ++++++++++++++++++++++++++++++++++++++
  2 files changed, 52 insertions(+)

create mode 100644 xen/arch/arm/arm64/debug-meson.inc

docs/misc/arm/early-printk.txt +0 -0
index f765f59..2aa9528 100644

docs/misc/arm/early-printk.txt the name of the machine: · line 44

Quoted 4 lines
docs/misc/arm/early-printk.txt +1 -0
@@ -41,6 +41,7 @@ the name of the machine:
    - juno: printk with pl011 on Juno platform
    - lager: printk with SCIF0 on Renesas R-Car H2 processors
    - midway: printk with the pl011 on Calxeda Midway processors
+  - meson: printk with the MESON for Amlogic S905 SoCs

You have dropped the platform alias. So the documentation should also be dropped.

Quoted 43 lines
docs/misc/arm/early-printk.txt +0 -0
    - mvebu: printk with the MVEBU for Marvell Armada 3700 SoCs
    - omap5432: printk with UART3 on TI OMAP5432 processors
    - rcar3: printk with SCIF2 on Renesas R-Car Gen3 processors
xen/arch/arm/arm64/debug-meson.inc new file +34 -0
new file mode 100644
index 0000000..164bcdf
@@ -0,0 +1,51 @@
+/*
+ * xen/arch/arm/arm64/debug-meson.inc
+ *
+ * MESON specific debug code.
+ *
+ * Copyright (c) 2019, Amit Singh Tomar <[email protected]>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define AML_UART_WFIFO_REG      0x00
+#define AML_UART_STATUS_REG     0x0c
+
+#define AML_UART_TX_FIFO_FULL   21
+
+/*
+ * MESON UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+        ldr     w\c, [\xb, #AML_UART_STATUS_REG]        /* status register */
+        tbnz    w\c, #AML_UART_TX_FIFO_FULL, 1b         /* Check TXFIFO FULL bit */

xen/arch/arm/arm64/debug-meson.inc line 44

Quoted 10 lines
xen/arch/arm/arm64/debug-meson.inc new file +10 -0
+.endm
+
+/*
+ * MESON UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+	str    \wt, [\xb, #AML_UART_WFIFO_REG]
+.endm

I will defer to Andre the review on the code.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw
In reply to Amit Singh Tomar
Quoted 69 lines · Amit Singh Tomar

---
TODO:
* Capture XEN boot info on WIKI(just forgot my XEN Wiki credentials).

Changes since RFC:

* Replaced LDRH with LDR, with this there is no scattered output on console now.
* Used tbnz instead of tst and b.ne.
* Used AML_ prefix against register names.

---
 docs/misc/arm/early-printk.txt     |  1 +
 xen/arch/arm/arm64/debug-meson.inc | 51 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc
docs/misc/arm/early-printk.txt +1 -0
index f765f59..2aa9528 100644
@@ -41,6 +41,7 @@ the name of the machine:
   - juno: printk with pl011 on Juno platform
   - lager: printk with SCIF0 on Renesas R-Car H2 processors
   - midway: printk with the pl011 on Calxeda Midway processors
+  - meson: printk with the MESON for Amlogic S905 SoCs
   - mvebu: printk with the MVEBU for Marvell Armada 3700 SoCs
   - omap5432: printk with UART3 on TI OMAP5432 processors
   - rcar3: printk with SCIF2 on Renesas R-Car Gen3 processors
xen/arch/arm/arm64/debug-meson.inc new file +33 -0
new file mode 100644
index 0000000..164bcdf
@@ -0,0 +1,51 @@
+/*
+ * xen/arch/arm/arm64/debug-meson.inc
+ *
+ * MESON specific debug code.
+ *
+ * Copyright (c) 2019, Amit Singh Tomar <[email protected]>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define AML_UART_WFIFO_REG      0x00
+#define AML_UART_STATUS_REG     0x0c
+
+#define AML_UART_TX_FIFO_FULL   21
+
+/*
+ * MESON UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+        ldr     w\c, [\xb, #AML_UART_STATUS_REG]        /* status register */

xen/arch/arm/arm64/debug-meson.inc line 43

Quoted 10 lines
xen/arch/arm/arm64/debug-meson.inc new file +10 -0
+        tbnz    w\c, #AML_UART_TX_FIFO_FULL, 1b         /* Check TXFIFO FULL bit */
+.endm
+
+/*
+ * MESON UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+	str    \wt, [\xb, #AML_UART_WFIFO_REG]

That's a hard tab here.

Apart from this and the unneeded addition to early-printk.txt (which Julien mentioned already) this looks now correct to me.

Cheers,
Andre

xen/arch/arm/arm64/debug-meson.inc line 51

Quoted 9 lines
xen/arch/arm/arm64/debug-meson.inc new file +8 -0
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#6 lore raw

Hi,

Quoted 2 lines

Apart from this and the unneeded addition to early-printk.txt (which Julien mentioned already) this looks now correct to me.

I was wondering, if it's a good idea to have
"CONFIG_EARLY_PRINTK=meson,0xc81004c0"
documented in Rules.mk.

It would give fair idea to someone who is new to Xen, how to compile meson with early printk support ?

Thanks
-Amit.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 1 line · Amit Tomer

Hi,

Hi,

Quoted 9 lines
Quoted 2 lines

Apart from this and the unneeded addition to early-printk.txt (which Julien mentioned already) this looks now correct to me.

I was wondering, if it's a good idea to have
"CONFIG_EARLY_PRINTK=meson,0xc81004c0"
documented in Rules.mk.

It would give fair idea to someone who is new to Xen, how to compile meson with early printk support ?

Someone new to Xen is unlikely going to know that documentation is in Rules.mk.

But, documenting the exact UART address is not going to help a user with a platform different than yours. It can also lead the user to think his board is not supported by Xen when often this is just a different address.

This is why I want to phase out any alias in Xen. The best place to document the earlyprintk is on the wiki along with documentation to boot Xen on your platform.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel