Skip to contentSkip to conversation

Renesas Stout board support (R-Car Gen2)

PATCH Superseded Oleksandr Tyshchenko 2 participants 28 messages Aug 6, 2018 – Aug 22, 2018 Arm/RISC-V/Renesas architecture

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Renesas Stout board support (R-Car Gen2)

From: Oleksandr Tyshchenko <[email protected]>

Hi, all.

The purpose of this patch series is to add required support to be able to run Xen on Renesas Stout board [1] which uses SCIFA compatible UART as a console interface.

Actually Xen already has support for SCIF compatible UARTs which are used on Renesas Lager (R-Car Gen2), Salvator-X, H3ULCB/M3ULCB (R-Car Gen3) and other development boards.
So this patch series extends existing support to be able to handle both interfaces.

Tested on Stout (ARM32) and H3ULCB (ARM64) boards using current master. Have a plan to update Xen Wiki regarding this board.

You can find current patch series here:
repo: https://github.com/otyshchenko1/xen.git branch: stout_xen_4.12_unstable

[1] https://elinux.org/R-Car/Boards/Stout

Oleksandr Tyshchenko (4):
xen/arm: drivers: scif: Remove unused #define-s xen/arm: drivers: scif: Add support for SCIFA compatible UARTs xen/arm: Add SCIFA UART support for early printk xen/arm: Reuse R-Car Gen2 platform code for Stout board

 docs/misc/arm/early-printk.txt     |   3 +-
 xen/arch/arm/Rules.mk              |   1 +
 xen/arch/arm/arm32/debug-scifa.inc |  51 ++++++++++++++
 xen/arch/arm/platforms/rcar2.c     |   4 ++
 xen/drivers/char/scif-uart.c       | 133 ++++++++++++++++++++++++++++---------
 xen/include/asm-arm/scif-uart.h    |  55 ++++++++++-----
 6 files changed, 196 insertions(+), 51 deletions(-)
 create mode 100644 xen/arch/arm/arm32/debug-scifa.inc
Signature · 7 lines
2.7.4


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

PATCH 1/4 xen/arm: drivers: scif: Remove unused #define-s

From: Oleksandr Tyshchenko <[email protected]>

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
 xen/drivers/char/scif-uart.c    |  4 ----
 xen/include/asm-arm/scif-uart.h | 11 -----------
 2 files changed, 15 deletions(-)
xen/drivers/char/scif-uart.c +0 -4
index 4a71bac..465fb34 100644
@@ -29,10 +29,6 @@
 #include <asm/scif-uart.h>
 #include <asm/io.h>
 
-#define PARITY_NONE    0
-#define PARITY_EVEN    1
-#define PARITY_ODD     2
-
 #define scif_readb(uart, off)          readb((uart)->regs + (off))
 #define scif_writeb(uart, off, val)    writeb((val), (uart)->regs + (off))
 
xen/include/asm-arm/scif-uart.h +0 -11
index d030b26..8137850 100644
@@ -47,17 +47,6 @@
 #define SCSCR_CKE1    (1 << 1)    /* Clock Enable 1 */
 #define SCSCR_CKE0    (1 << 0)    /* Clock Enable 0 */
 
-#define SCSCR_CKE00    (0)
-#define SCSCR_CKE01    (SCSCR_CKE0)
-#define SCSCR_CKE10    (SCSCR_CKE1)
-#define SCSCR_CKE11    (SCSCR_CKE1 | SCSCR_CKE0)
-
-/* Serial Mode Register (SCSMR) */
-#define SCSMR_CHR     (1 << 6)    /* 7-bit Character Length */
-#define SCSMR_PE      (1 << 5)    /* Parity Enable */
-#define SCSMR_ODD     (1 << 4)    /* Odd Parity */
-#define SCSMR_STOP    (1 << 3)    /* Stop Bit Length */
-
 /* Serial Status Register (SCFSR) */
 #define SCFSR_ER      (1 << 7)    /* Receive Error */
 #define SCFSR_TEND    (1 << 6)    /* Transmission End */
Signature · 7 lines
2.7.4


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

Re: [PATCH v1 1/4] xen/arm: drivers: scif: Remove unused #define-s

Hi Oleksandr,

Quoted 5 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>

Cheers,

Quoted 43 lines
---
  xen/drivers/char/scif-uart.c    |  4 ----
  xen/include/asm-arm/scif-uart.h | 11 -----------
  2 files changed, 15 deletions(-)
xen/drivers/char/scif-uart.c +0 -4
index 4a71bac..465fb34 100644
@@ -29,10 +29,6 @@
  #include <asm/scif-uart.h>
  #include <asm/io.h>
 
-#define PARITY_NONE    0
-#define PARITY_EVEN    1
-#define PARITY_ODD     2
-
  #define scif_readb(uart, off)          readb((uart)->regs + (off))
  #define scif_writeb(uart, off, val)    writeb((val), (uart)->regs + (off))
 
xen/include/asm-arm/scif-uart.h +0 -11
index d030b26..8137850 100644
@@ -47,17 +47,6 @@
  #define SCSCR_CKE1    (1 << 1)    /* Clock Enable 1 */
  #define SCSCR_CKE0    (1 << 0)    /* Clock Enable 0 */
 
-#define SCSCR_CKE00    (0)
-#define SCSCR_CKE01    (SCSCR_CKE0)
-#define SCSCR_CKE10    (SCSCR_CKE1)
-#define SCSCR_CKE11    (SCSCR_CKE1 | SCSCR_CKE0)
-
-/* Serial Mode Register (SCSMR) */
-#define SCSMR_CHR     (1 << 6)    /* 7-bit Character Length */
-#define SCSMR_PE      (1 << 5)    /* Parity Enable */
-#define SCSMR_ODD     (1 << 4)    /* Odd Parity */
-#define SCSMR_STOP    (1 << 3)    /* Stop Bit Length */
-
  /* Serial Status Register (SCFSR) */
  #define SCFSR_ER      (1 << 7)    /* Receive Error */
  #define SCFSR_TEND    (1 << 6)    /* Transmission End */
Signature · 6 lines
Julien Grall

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

PATCH 2/4 xen/arm: drivers: scif: Add support for SCIFA compatible UARTs

In reply to Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Extend existing driver to be able to handle SCIFA interface as well. SCIF and SCIFA have lot in common, though SCIFA has different offsets and bits for some registers.

Use compatible string to recognize what interface is present on a target board.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
 xen/drivers/char/scif-uart.c    | 129 +++++++++++++++++++++++++++++++---------
 xen/include/asm-arm/scif-uart.h |  44 ++++++++++++--
 2 files changed, 138 insertions(+), 35 deletions(-)
xen/drivers/char/scif-uart.c +100 -29
index 465fb34..d1eb713 100644
@@ -1,7 +1,7 @@
 /*
  * xen/drivers/char/scif-uart.c
  *
- * Driver for SCIF (Serial communication interface with FIFO)
+ * Driver for SCIF(A) (Serial communication interface with FIFO (A))
  * compatible UART.
  *
  * Oleksandr Tyshchenko <[email protected]>
@@ -40,8 +40,57 @@ static struct scif_uart {
     char __iomem *regs;
     struct irqaction irqaction;
     struct vuart_info vuart;
+    const struct port_params *params;
 } scif_com = {0};
 
+enum
+{
+    SCIF_PORT,
+    SCIFA_PORT,
+    NR_PORTS,
+};
+
+struct port_params
+{
+    unsigned int status_reg;
+    unsigned int tx_fifo_reg;
+    unsigned int rx_fifo_reg;
+    unsigned int overrun_reg;
+    unsigned int overrun_mask;
+    unsigned int error_mask;
+    unsigned int irq_flags;
+    unsigned int fifo_size;
+};
+
+static const struct port_params port_params[NR_PORTS] =
+{
+    [SCIF_PORT] =
+    {
+        .status_reg   = SCIF_SCFSR,
+        .tx_fifo_reg  = SCIF_SCFTDR,
+        .rx_fifo_reg  = SCIF_SCFRDR,
+        .overrun_reg  = SCIF_SCLSR,
+        .overrun_mask = SCLSR_ORER,
+        .error_mask   = SCFSR_PER | SCFSR_FER | SCFSR_BRK | SCFSR_ER,
+        .irq_flags    = SCSCR_RIE | SCSCR_TIE | SCSCR_REIE,
+        .fifo_size    = 16,
+    },
+
+    [SCIFA_PORT] =
+    {
+        .status_reg   = SCIFA_SCASSR,
+        .tx_fifo_reg  = SCIFA_SCAFTDR,
+        .rx_fifo_reg  = SCIFA_SCAFRDR,
+        .overrun_reg  = SCIFA_SCASSR,
+        .overrun_mask = SCASSR_ORER,
+        .error_mask   = SCASSR_PER | SCASSR_FER | SCASSR_BRK | SCASSR_ER |
+                        SCASSR_ORER,
+        .irq_flags    = SCASCR_RIE | SCASCR_TIE | SCASCR_DRIE | SCASCR_ERIE |
+                        SCASCR_BRIE,
+        .fifo_size    = 64,
+    },
+};
+
 static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
 {
     struct serial_port *port = data;
@@ -49,7 +98,7 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
     uint16_t status, ctrl;
 
     ctrl = scif_readw(uart, SCIF_SCSCR);
-    status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND;
+    status = scif_readw(uart, uart->params->status_reg) & ~SCFSR_TEND;
     /* Ignore next flag if TX Interrupt is disabled */
     if ( !(ctrl & SCSCR_TIE) )
         status &= ~SCFSR_TDFE;
@@ -65,13 +114,19 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
             serial_rx_interrupt(port, regs);
 
         /* Error Interrupt */
-        if ( status & SCIF_ERRORS )
-            scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS);
-        if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER )
-            scif_writew(uart, SCIF_SCLSR, 0);
+        if ( status & uart->params->error_mask )
+            scif_writew(uart, uart->params->status_reg,
+                        ~uart->params->error_mask);
+        if ( uart->params->overrun_reg != uart->params->status_reg )
+        {
+            if ( scif_readw(uart, uart->params->overrun_reg) &
+                 uart->params->overrun_mask )
+                scif_writew(uart, uart->params->overrun_reg,
+                            ~uart->params->overrun_mask);
+        }
 
         ctrl = scif_readw(uart, SCIF_SCSCR);
-        status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND;
+        status = scif_readw(uart, uart->params->status_reg) & ~SCFSR_TEND;
         /* Ignore next flag if TX Interrupt is disabled */
         if ( !(ctrl & SCSCR_TIE) )
             status &= ~SCFSR_TDFE;
@@ -86,7 +141,7 @@ static void __init scif_uart_init_preirq(struct serial_port *port)
      * Wait until last bit has been transmitted. This is needed for a smooth
      * transition when we come from early printk
      */
-    while ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TEND) );
+    while ( !(scif_readw(uart, uart->params->status_reg) & SCFSR_TEND) );
 
     /* Disable TX/RX parts and all interrupts */
     scif_writew(uart, SCIF_SCSCR, 0);
@@ -95,10 +150,13 @@ static void __init scif_uart_init_preirq(struct serial_port *port)
     scif_writew(uart, SCIF_SCFCR, SCFCR_RFRST | SCFCR_TFRST);
 
     /* Clear all errors and flags */
-    scif_readw(uart, SCIF_SCFSR);
-    scif_writew(uart, SCIF_SCFSR, 0);
-    scif_readw(uart, SCIF_SCLSR);
-    scif_writew(uart, SCIF_SCLSR, 0);
+    scif_readw(uart, uart->params->status_reg);
+    scif_writew(uart, uart->params->status_reg, 0);
+    if ( uart->params->overrun_reg != uart->params->status_reg )
+    {
+        scif_readw(uart, uart->params->overrun_reg);
+        scif_writew(uart, uart->params->overrun_reg, 0);
+    }
 
     /* Setup trigger level for TX/RX FIFOs */
     scif_writew(uart, SCIF_SCFCR, SCFCR_RTRG11 | SCFCR_TTRG11);
@@ -122,14 +180,19 @@ static void __init scif_uart_init_postirq(struct serial_port *port)
                 uart->irq);
 
     /* Clear all errors */
-    if ( scif_readw(uart, SCIF_SCFSR) & SCIF_ERRORS )
-        scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS);
-    if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER )
-        scif_writew(uart, SCIF_SCLSR, 0);
+    if ( scif_readw(uart, uart->params->status_reg) & uart->params->error_mask )
+        scif_writew(uart, uart->params->status_reg, ~uart->params->error_mask);
+    if ( uart->params->overrun_reg != uart->params->status_reg )
+    {
+        if ( scif_readw(uart, uart->params->overrun_reg) &
+             uart->params->overrun_mask )
+            scif_writew(uart, uart->params->overrun_reg,
+                        ~uart->params->overrun_mask);
+    }
 
     /* Enable TX/RX and Error Interrupts  */
     scif_writew(uart, SCIF_SCSCR, scif_readw(uart, SCIF_SCSCR) |
-                 SCSCR_TIE | SCSCR_RIE | SCSCR_REIE);
+                uart->params->irq_flags);
 }
 
 static void scif_uart_suspend(struct serial_port *port)
@@ -148,24 +211,25 @@ static int scif_uart_tx_ready(struct serial_port *port)
     uint16_t cnt;
 
     /* Check for empty space in TX FIFO */
-    if ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TDFE) )
+    if ( !(scif_readw(uart, uart->params->status_reg) & SCFSR_TDFE) )
         return 0;
 
      /* Check number of data bytes stored in TX FIFO */
     cnt = scif_readw(uart, SCIF_SCFDR) >> 8;
-    ASSERT( cnt >= 0 && cnt <= SCIF_FIFO_MAX_SIZE );
+    ASSERT( cnt >= 0 && cnt <= uart->params->fifo_size );
 
-    return (SCIF_FIFO_MAX_SIZE - cnt);
+    return (uart->params->fifo_size - cnt);
 }
 
 static void scif_uart_putc(struct serial_port *port, char c)
 {
     struct scif_uart *uart = port->uart;
 
-    scif_writeb(uart, SCIF_SCFTDR, c);
+    scif_writeb(uart, uart->params->tx_fifo_reg, c);
     /* Clear required TX flags */
-    scif_writew(uart, SCIF_SCFSR, scif_readw(uart, SCIF_SCFSR) &
-                 ~(SCFSR_TEND | SCFSR_TDFE));
+    scif_writew(uart, uart->params->status_reg,
+                scif_readw(uart, uart->params->status_reg) &
+                ~(SCFSR_TEND | SCFSR_TDFE));
 }
 
 static int scif_uart_getc(struct serial_port *port, char *pc)
@@ -173,15 +237,16 @@ static int scif_uart_getc(struct serial_port *port, char *pc)
     struct scif_uart *uart = port->uart;
 
     /* Check for available data bytes in RX FIFO */
-    if ( !(scif_readw(uart, SCIF_SCFSR) & (SCFSR_RDF | SCFSR_DR)) )
+    if ( !(scif_readw(uart, uart->params->status_reg) &
+          (SCFSR_RDF | SCFSR_DR)) )
         return 0;
 
-    *pc = scif_readb(uart, SCIF_SCFRDR);
+    *pc = scif_readb(uart, uart->params->rx_fifo_reg);
 
     /* dummy read */
-    scif_readw(uart, SCIF_SCFSR);
+    scif_readw(uart, uart->params->status_reg);
     /* Clear required RX flags */
-    scif_writew(uart, SCIF_SCFSR, ~(SCFSR_RDF | SCFSR_DR));
+    scif_writew(uart, uart->params->status_reg, ~(SCFSR_RDF | SCFSR_DR));
 
     return 1;
 }
@@ -265,10 +330,15 @@ static int __init scif_uart_init(struct dt_device_node *dev,
         return -ENOMEM;
     }
 
+    if ( dt_device_is_compatible(dev, "renesas,scifa") )
+        uart->params = &port_params[SCIFA_PORT];
+    else
+        uart->params = &port_params[SCIF_PORT];
+
     uart->vuart.base_addr  = addr;
     uart->vuart.size       = size;
-    uart->vuart.data_off   = SCIF_SCFTDR;
-    uart->vuart.status_off = SCIF_SCFSR;
+    uart->vuart.data_off   = uart->params->tx_fifo_reg;
+    uart->vuart.status_off = uart->params->status_reg;
     uart->vuart.status     = SCFSR_TDFE;
 
     /* Register with generic serial driver */
@@ -282,6 +352,7 @@ static int __init scif_uart_init(struct dt_device_node *dev,
 static const struct dt_device_match scif_uart_dt_match[] __initconst =
 {
     DT_MATCH_COMPATIBLE("renesas,scif"),
+    DT_MATCH_COMPATIBLE("renesas,scifa"),
     { /* sentinel */ },
 };
 
xen/include/asm-arm/scif-uart.h +38 -6

68 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
#4 lore raw

Re: [PATCH v1 2/4] xen/arm: drivers: scif: Add support for SCIFA compatible UARTs

Hi Oleksandr,

Quoted 31 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Extend existing driver to be able to handle SCIFA interface as well. SCIF and SCIFA have lot in common, though SCIFA has different offsets and bits for some registers.

Use compatible string to recognize what interface is present on a target board.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
  xen/drivers/char/scif-uart.c    | 129 +++++++++++++++++++++++++++++++---------
  xen/include/asm-arm/scif-uart.h |  44 ++++++++++++--
  2 files changed, 138 insertions(+), 35 deletions(-)
xen/drivers/char/scif-uart.c +1 -1
index 465fb34..d1eb713 100644
@@ -1,7 +1,7 @@
  /*
   * xen/drivers/char/scif-uart.c
   *
- * Driver for SCIF (Serial communication interface with FIFO)
+ * Driver for SCIF(A) (Serial communication interface with FIFO (A))
   * compatible UART.
   *
   * Oleksandr Tyshchenko <[email protected]>

xen/drivers/char/scif-uart.c static struct scif_uart { · line 46

Quoted 7 lines
xen/drivers/char/scif-uart.c +2 -0
@@ -40,8 +40,57 @@ static struct scif_uart {
      char __iomem *regs;
      struct irqaction irqaction;
      struct vuart_info vuart;
+    const struct port_params *params;
  } scif_com = {0};
 
+enum

Should not this enum has a name?

Quoted 51 lines
xen/drivers/char/scif-uart.c +47 -0
+{
+    SCIF_PORT,
+    SCIFA_PORT,
+    NR_PORTS,
+};
+
+struct port_params
+{
+    unsigned int status_reg;
+    unsigned int tx_fifo_reg;
+    unsigned int rx_fifo_reg;
+    unsigned int overrun_reg;
+    unsigned int overrun_mask;
+    unsigned int error_mask;
+    unsigned int irq_flags;
+    unsigned int fifo_size;
+};
+
+static const struct port_params port_params[NR_PORTS] =
+{
+    [SCIF_PORT] =
+    {
+        .status_reg   = SCIF_SCFSR,
+        .tx_fifo_reg  = SCIF_SCFTDR,
+        .rx_fifo_reg  = SCIF_SCFRDR,
+        .overrun_reg  = SCIF_SCLSR,
+        .overrun_mask = SCLSR_ORER,
+        .error_mask   = SCFSR_PER | SCFSR_FER | SCFSR_BRK | SCFSR_ER,
+        .irq_flags    = SCSCR_RIE | SCSCR_TIE | SCSCR_REIE,
+        .fifo_size    = 16,
+    },
+
+    [SCIFA_PORT] =
+    {
+        .status_reg   = SCIFA_SCASSR,
+        .tx_fifo_reg  = SCIFA_SCAFTDR,
+        .rx_fifo_reg  = SCIFA_SCAFRDR,
+        .overrun_reg  = SCIFA_SCASSR,
+        .overrun_mask = SCASSR_ORER,
+        .error_mask   = SCASSR_PER | SCASSR_FER | SCASSR_BRK | SCASSR_ER |
+                        SCASSR_ORER,
+        .irq_flags    = SCASCR_RIE | SCASCR_TIE | SCASCR_DRIE | SCASCR_ERIE |
+                        SCASCR_BRIE,
+        .fifo_size    = 64,
+    },
+};
+
  static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
  {
      struct serial_port *port = data;

xen/drivers/char/scif-uart.c static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs) · line 101

Quoted 5 lines
xen/drivers/char/scif-uart.c +1 -1
@@ -49,7 +98,7 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
      uint16_t status, ctrl;
 
      ctrl = scif_readw(uart, SCIF_SCSCR);
-    status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND;
+    status = scif_readw(uart, uart->params->status_reg) & ~SCFSR_TEND;

I would prefer if you introduce a local variable for the params. This would avoid to write uart->params everywhere.

Quoted 38 lines
xen/drivers/char/scif-uart.c +12 -6
      /* Ignore next flag if TX Interrupt is disabled */
      if ( !(ctrl & SCSCR_TIE) )
          status &= ~SCFSR_TDFE;
@@ -65,13 +114,19 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
              serial_rx_interrupt(port, regs);
 
          /* Error Interrupt */
-        if ( status & SCIF_ERRORS )
-            scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS);
-        if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER )
-            scif_writew(uart, SCIF_SCLSR, 0);
+        if ( status & uart->params->error_mask )
+            scif_writew(uart, uart->params->status_reg,
+                        ~uart->params->error_mask);
+        if ( uart->params->overrun_reg != uart->params->status_reg )
+        {
+            if ( scif_readw(uart, uart->params->overrun_reg) &
+                 uart->params->overrun_mask )
+                scif_writew(uart, uart->params->overrun_reg,
+                            ~uart->params->overrun_mask);
+        }
 
          ctrl = scif_readw(uart, SCIF_SCSCR);
-        status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND;
+        status = scif_readw(uart, uart->params->status_reg) & ~SCFSR_TEND;
          /* Ignore next flag if TX Interrupt is disabled */
          if ( !(ctrl & SCSCR_TIE) )
              status &= ~SCFSR_TDFE;
@@ -86,7 +141,7 @@ static void __init scif_uart_init_preirq(struct serial_port *port)
       * Wait until last bit has been transmitted. This is needed for a smooth
       * transition when we come from early printk
       */
-    while ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TEND) );
+    while ( !(scif_readw(uart, uart->params->status_reg) & SCFSR_TEND) );
 
      /* Disable TX/RX parts and all interrupts */
      scif_writew(uart, SCIF_SCSCR, 0);

xen/drivers/char/scif-uart.c static void __init scif_uart_init_preirq(struct serial_port *port) · line 155

Quoted 10 lines
xen/drivers/char/scif-uart.c +3 -4
@@ -95,10 +150,13 @@ static void __init scif_uart_init_preirq(struct serial_port *port)
      scif_writew(uart, SCIF_SCFCR, SCFCR_RFRST | SCFCR_TFRST);
 
      /* Clear all errors and flags */
-    scif_readw(uart, SCIF_SCFSR);
-    scif_writew(uart, SCIF_SCFSR, 0);
-    scif_readw(uart, SCIF_SCLSR);
-    scif_writew(uart, SCIF_SCLSR, 0);
+    scif_readw(uart, uart->params->status_reg);
+    scif_writew(uart, uart->params->status_reg, 0);
+    if ( uart->params->overrun_reg != uart->params->status_reg )

I don't think there is any harm to reset the registers twice when overrun_reg != status_reg.

Quoted 19 lines
xen/drivers/char/scif-uart.c +8 -4
+    {
+        scif_readw(uart, uart->params->overrun_reg);
+        scif_writew(uart, uart->params->overrun_reg, 0);
+    }
 
      /* Setup trigger level for TX/RX FIFOs */
      scif_writew(uart, SCIF_SCFCR, SCFCR_RTRG11 | SCFCR_TTRG11);
@@ -122,14 +180,19 @@ static void __init scif_uart_init_postirq(struct serial_port *port)
                  uart->irq);
 
      /* Clear all errors */
-    if ( scif_readw(uart, SCIF_SCFSR) & SCIF_ERRORS )
-        scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS);
-    if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER )
-        scif_writew(uart, SCIF_SCLSR, 0);
+    if ( scif_readw(uart, uart->params->status_reg) & uart->params->error_mask )
+        scif_writew(uart, uart->params->status_reg, ~uart->params->error_mask);
+    if ( uart->params->overrun_reg != uart->params->status_reg )
+    {

xen/drivers/char/scif-uart.c static void __init scif_uart_init_postirq(struct serial_port *port) · line 195

Quoted 10 lines
xen/drivers/char/scif-uart.c +6 -1
+        if ( scif_readw(uart, uart->params->overrun_reg) &
+             uart->params->overrun_mask )
+            scif_writew(uart, uart->params->overrun_reg,
+                        ~uart->params->overrun_mask);
+    }
 
      /* Enable TX/RX and Error Interrupts  */
      scif_writew(uart, SCIF_SCSCR, scif_readw(uart, SCIF_SCSCR) |
-                 SCSCR_TIE | SCSCR_RIE | SCSCR_REIE);
+                uart->params->irq_flags);

The indentation looks wrong here.

Quoted 57 lines
xen/drivers/char/scif-uart.c +12 -10
  }
 
  static void scif_uart_suspend(struct serial_port *port)
@@ -148,24 +211,25 @@ static int scif_uart_tx_ready(struct serial_port *port)
      uint16_t cnt;
 
      /* Check for empty space in TX FIFO */
-    if ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TDFE) )
+    if ( !(scif_readw(uart, uart->params->status_reg) & SCFSR_TDFE) )
          return 0;
 
       /* Check number of data bytes stored in TX FIFO */
      cnt = scif_readw(uart, SCIF_SCFDR) >> 8;
-    ASSERT( cnt >= 0 && cnt <= SCIF_FIFO_MAX_SIZE );
+    ASSERT( cnt >= 0 && cnt <= uart->params->fifo_size );
 
-    return (SCIF_FIFO_MAX_SIZE - cnt);
+    return (uart->params->fifo_size - cnt);
  }
 
  static void scif_uart_putc(struct serial_port *port, char c)
  {
      struct scif_uart *uart = port->uart;
 
-    scif_writeb(uart, SCIF_SCFTDR, c);
+    scif_writeb(uart, uart->params->tx_fifo_reg, c);
      /* Clear required TX flags */
-    scif_writew(uart, SCIF_SCFSR, scif_readw(uart, SCIF_SCFSR) &
-                 ~(SCFSR_TEND | SCFSR_TDFE));
+    scif_writew(uart, uart->params->status_reg,
+                scif_readw(uart, uart->params->status_reg) &
+                ~(SCFSR_TEND | SCFSR_TDFE));
  }
 
  static int scif_uart_getc(struct serial_port *port, char *pc)
@@ -173,15 +237,16 @@ static int scif_uart_getc(struct serial_port *port, char *pc)
      struct scif_uart *uart = port->uart;
 
      /* Check for available data bytes in RX FIFO */
-    if ( !(scif_readw(uart, SCIF_SCFSR) & (SCFSR_RDF | SCFSR_DR)) )
+    if ( !(scif_readw(uart, uart->params->status_reg) &
+          (SCFSR_RDF | SCFSR_DR)) )
          return 0;
 
-    *pc = scif_readb(uart, SCIF_SCFRDR);
+    *pc = scif_readb(uart, uart->params->rx_fifo_reg);
 
      /* dummy read */
-    scif_readw(uart, SCIF_SCFSR);
+    scif_readw(uart, uart->params->status_reg);
      /* Clear required RX flags */
-    scif_writew(uart, SCIF_SCFSR, ~(SCFSR_RDF | SCFSR_DR));
+    scif_writew(uart, uart->params->status_reg, ~(SCFSR_RDF | SCFSR_DR));
 
      return 1;
  }

xen/drivers/char/scif-uart.c static int __init scif_uart_init(struct dt_device_node *dev, · line 336

Quoted 7 lines
xen/drivers/char/scif-uart.c +4 -0
@@ -265,10 +330,15 @@ static int __init scif_uart_init(struct dt_device_node *dev,
          return -ENOMEM;
      }
 
+    if ( dt_device_is_compatible(dev, "renesas,scifa") )
+        uart->params = &port_params[SCIFA_PORT];
+    else
+        uart->params = &port_params[SCIF_PORT];

You can use the field .data in dt_device_match to store specific data and then use dt_match_node to find the correct node.

Quoted 85 lines
xen/drivers/char/scif-uart.c +4 -2
+
      uart->vuart.base_addr  = addr;
      uart->vuart.size       = size;
-    uart->vuart.data_off   = SCIF_SCFTDR;
-    uart->vuart.status_off = SCIF_SCFSR;
+    uart->vuart.data_off   = uart->params->tx_fifo_reg;
+    uart->vuart.status_off = uart->params->status_reg;
      uart->vuart.status     = SCFSR_TDFE;
 
      /* Register with generic serial driver */
@@ -282,6 +352,7 @@ static int __init scif_uart_init(struct dt_device_node *dev,
  static const struct dt_device_match scif_uart_dt_match[] __initconst =
  {
      DT_MATCH_COMPATIBLE("renesas,scif"),
+    DT_MATCH_COMPATIBLE("renesas,scifa"),
      { /* sentinel */ },
  };
 
xen/include/asm-arm/scif-uart.h +31 -6
index 8137850..bce3404 100644
@@ -2,7 +2,7 @@
   * xen/include/asm-arm/scif-uart.h
   *
   * Common constant definition between early printk and the UART driver
- * for the SCIF compatible UART.
+ * for the SCIF(A) compatible UART.
   *
   * Oleksandr Tyshchenko <[email protected]>
   * Copyright (C) 2014, Globallogic.
@@ -21,9 +21,7 @@
  #ifndef __ASM_ARM_SCIF_UART_H
  #define __ASM_ARM_SCIF_UART_H
 
-#define SCIF_FIFO_MAX_SIZE    16
-
-/* Register offsets */
+/* Register offsets (SCIF) */
  #define SCIF_SCSMR     (0x00)    /* Serial mode register           */
  #define SCIF_SCBRR     (0x04)    /* Bit rate register              */
  #define SCIF_SCSCR     (0x08)    /* Serial control register        */
@@ -57,8 +55,6 @@
  #define SCFSR_RDF     (1 << 1)    /* Receive FIFO Data Full */
  #define SCFSR_DR      (1 << 0)    /* Receive Data Ready */
 
-#define SCIF_ERRORS    (SCFSR_PER | SCFSR_FER | SCFSR_ER | SCFSR_BRK)
-
  /* Line Status Register (SCLSR) */
  #define SCLSR_TO      (1 << 2)    /* Timeout */
  #define SCLSR_ORER    (1 << 0)    /* Overrun Error */
@@ -83,6 +79,42 @@
  #define SCFCR_TTRG10    (SCFCR_TTRG1)
  #define SCFCR_TTRG11    (SCFCR_TTRG1 | SCFCR_TTRG0)
 
+/* Register offsets (SCIFA) */
+#define SCIFA_SCASMR     (0x00)    /* Serial mode register           */
+#define SCIFA_SCABRR     (0x04)    /* Bit rate register              */
+#define SCIFA_SCASCR     (0x08)    /* Serial control register        */
+#define SCIFA_SCATDSR    (0x0C)    /* Transmit data stop register    */
+#define SCIFA_SCAFER     (0x10)    /* FIFO error count register      */
+#define SCIFA_SCASSR     (0x14)    /* Serial status register         */
+#define SCIFA_SCAFCR     (0x18)    /* FIFO control register          */
+#define SCIFA_SCAFDR     (0x1C)    /* FIFO data count register       */
+#define SCIFA_SCAFTDR    (0x20)    /* Transmit FIFO data register    */
+#define SCIFA_SCAFRDR    (0x24)    /* Receive FIFO data register     */
+#define SCIFA_SCAPCR     (0x30)    /* Serial port control register   */
+#define SCIFA_SCAPDR     (0x34)    /* Serial port data register      */
+
+/* Serial Control Register (SCASCR) */
+#define SCASCR_ERIE     (1 << 10)    /* Receive Error Interrupt Enable */
+#define SCASCR_BRIE     (1 << 9)     /* Break Interrupt Enable */
+#define SCASCR_DRIE     (1 << 8)     /* Receive Data Ready Interrupt Enable */
+#define SCASCR_TIE      (1 << 7)     /* Transmit Interrupt Enable */
+#define SCASCR_RIE      (1 << 6)     /* Receive Interrupt Enable */
+#define SCASCR_TE       (1 << 5)     /* Transmit Enable */
+#define SCASCR_RE       (1 << 4)     /* Receive Enable */
+#define SCASCR_CKE0     (1 << 0)     /* Clock Enable 0 */
+
+/* Serial Status Register (SCASSR) */
+#define SCASSR_ORER    (1 << 9)    /* Overrun Error */
+#define SCASSR_TSF     (1 << 8)    /* Transmit Data Stop */
+#define SCASSR_ER      (1 << 7)    /* Receive Error */
+#define SCASSR_TEND    (1 << 6)    /* Transmission End */

xen/include/asm-arm/scif-uart.h line 120

Quoted 10 lines
xen/include/asm-arm/scif-uart.h +7 -0
+#define SCASSR_TDFE    (1 << 5)    /* Transmit FIFO Data Empty */
+#define SCASSR_BRK     (1 << 4)    /* Break Detect */
+#define SCASSR_FER     (1 << 3)    /* Framing Error */
+#define SCASSR_PER     (1 << 2)    /* Parity Error */
+#define SCASSR_RDF     (1 << 1)    /* Receive FIFO Data Full */
+#define SCASSR_DR      (1 << 0)    /* Receive Data Ready */
+
  #endif /* __ASM_ARM_SCIF_UART_H */
 
  /*

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 2/4] xen/arm: drivers: scif: Add support for SCIFA compatible UARTs

Quoted 1 line · Julien Grall

Hi Oleksandr,

Hi, Julien

Quoted 37 lines · Oleksandr Tyshchenko
Quoted 34 lines

From: Oleksandr Tyshchenko <[email protected]>

Extend existing driver to be able to handle SCIFA interface as well. SCIF and SCIFA have lot in common, though SCIFA has different offsets and bits for some registers.

Use compatible string to recognize what interface is present on a target board.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
  xen/drivers/char/scif-uart.c    | 129
+++++++++++++++++++++++++++++++---------
  xen/include/asm-arm/scif-uart.h |  44 ++++++++++++--
  2 files changed, 138 insertions(+), 35 deletions(-)
xen/drivers/char/scif-uart.c +1 -1
index 465fb34..d1eb713 100644
@@ -1,7 +1,7 @@
  /*
   * xen/drivers/char/scif-uart.c
   *
- * Driver for SCIF (Serial communication interface with FIFO)
+ * Driver for SCIF(A) (Serial communication interface with FIFO (A))
   * compatible UART.
   *
   * Oleksandr Tyshchenko <[email protected]>
@@ -40,8 +40,57 @@ static struct scif_uart {
      char __iomem *regs;
Quoted 8 lines

xen/drivers/char/scif-uart.c static struct scif_uart {

Quoted 5 lines
xen/drivers/char/scif-uart.c +1 -0
      struct irqaction irqaction;
      struct vuart_info vuart;
+    const struct port_params *params;
  } scif_com = {0};
  +enum

Should not this enum has a name?

I think, it should.

Quoted 57 lines
Quoted 57 lines
xen/drivers/char/scif-uart.c +40 -0
+{
+    SCIF_PORT,
+    SCIFA_PORT,
+    NR_PORTS,
+};
+
+struct port_params
+{
+    unsigned int status_reg;
+    unsigned int tx_fifo_reg;
+    unsigned int rx_fifo_reg;
+    unsigned int overrun_reg;
+    unsigned int overrun_mask;
+    unsigned int error_mask;
+    unsigned int irq_flags;
+    unsigned int fifo_size;
+};
+
+static const struct port_params port_params[NR_PORTS] =
+{
+    [SCIF_PORT] =
+    {
+        .status_reg   = SCIF_SCFSR,
+        .tx_fifo_reg  = SCIF_SCFTDR,
+        .rx_fifo_reg  = SCIF_SCFRDR,
+        .overrun_reg  = SCIF_SCLSR,
+        .overrun_mask = SCLSR_ORER,
+        .error_mask   = SCFSR_PER | SCFSR_FER | SCFSR_BRK | SCFSR_ER,
+        .irq_flags    = SCSCR_RIE | SCSCR_TIE | SCSCR_REIE,
+        .fifo_size    = 16,
+    },
+
+    [SCIFA_PORT] =
+    {
+        .status_reg   = SCIFA_SCASSR,
+        .tx_fifo_reg  = SCIFA_SCAFTDR,
+        .rx_fifo_reg  = SCIFA_SCAFRDR,
+        .overrun_reg  = SCIFA_SCASSR,
+        .overrun_mask = SCASSR_ORER,
+        .error_mask   = SCASSR_PER | SCASSR_FER | SCASSR_BRK | SCASSR_ER

|

xen/drivers/char/scif-uart.c +2 -0
+                        SCASSR_ORER,
+        .irq_flags    = SCASCR_RIE | SCASCR_TIE | SCASCR_DRIE |

SCASCR_ERIE |

xen/drivers/char/scif-uart.c +5 -0
+                        SCASCR_BRIE,
+        .fifo_size    = 64,
+    },
+};
+
  static void scif_uart_interrupt(int irq, void *data, struct

cpu_user_regs *regs)

  {
      struct serial_port *port = data;
xen/drivers/char/scif-uart.c +0 -0
@@ -49,7 +98,7 @@ static void scif_uart_interrupt(int irq, void *data,
 struct cpu_user_regs *regs)
Quoted 8 lines

xen/drivers/char/scif-uart.c static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs) · line 101

Quoted 4 lines
xen/drivers/char/scif-uart.c +1 -1
      uint16_t status, ctrl;
        ctrl = scif_readw(uart, SCIF_SCSCR);
-    status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND;
+    status = scif_readw(uart, uart->params->status_reg) & ~SCFSR_TEND;

I would prefer if you introduce a local variable for the params. This would avoid to write uart->params everywhere.

Agree. Do you want me to use this local variable only in interrupt handler or everywhere in a file where uart->params is used?

Quoted 47 lines
Quoted 47 lines
xen/drivers/char/scif-uart.c +11 -5
      /* Ignore next flag if TX Interrupt is disabled */
      if ( !(ctrl & SCSCR_TIE) )
          status &= ~SCFSR_TDFE;
@@ -65,13 +114,19 @@ static void scif_uart_interrupt(int irq, void *data,
 struct cpu_user_regs *regs)
              serial_rx_interrupt(port, regs);
            /* Error Interrupt */
-        if ( status & SCIF_ERRORS )
-            scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS);
-        if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER )
-            scif_writew(uart, SCIF_SCLSR, 0);
+        if ( status & uart->params->error_mask )
+            scif_writew(uart, uart->params->status_reg,
+                        ~uart->params->error_mask);
+        if ( uart->params->overrun_reg != uart->params->status_reg )
+        {
+            if ( scif_readw(uart, uart->params->overrun_reg) &
+                 uart->params->overrun_mask )
+                scif_writew(uart, uart->params->overrun_reg,
+                            ~uart->params->overrun_mask);
+        }
            ctrl = scif_readw(uart, SCIF_SCSCR);
-        status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND;
+        status = scif_readw(uart, uart->params->status_reg) &
 ~SCFSR_TEND;
          /* Ignore next flag if TX Interrupt is disabled */
          if ( !(ctrl & SCSCR_TIE) )
              status &= ~SCFSR_TDFE;
@@ -86,7 +141,7 @@ static void __init scif_uart_init_preirq(struct
 serial_port *port)
       * Wait until last bit has been transmitted. This is needed for a

smooth
* transition when we come from early printk */

xen/drivers/char/scif-uart.c +1 -4
-    while ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TEND) );
+    while ( !(scif_readw(uart, uart->params->status_reg) & SCFSR_TEND) );
        /* Disable TX/RX parts and all interrupts */
      scif_writew(uart, SCIF_SCSCR, 0);
@@ -95,10 +150,13 @@ static void __init scif_uart_init_preirq(struct
 serial_port *port)
      scif_writew(uart, SCIF_SCFCR, SCFCR_RFRST | SCFCR_TFRST);
        /* Clear all errors and flags */
-    scif_readw(uart, SCIF_SCFSR);
-    scif_writew(uart, SCIF_SCFSR, 0);
-    scif_readw(uart, SCIF_SCLSR);
Quoted 8 lines

xen/drivers/char/scif-uart.c static void __init scif_uart_init_preirq(struct serial_port *port) · line 155

Quoted 4 lines
xen/drivers/char/scif-uart.c +3 -1
-    scif_writew(uart, SCIF_SCLSR, 0);
+    scif_readw(uart, uart->params->status_reg);
+    scif_writew(uart, uart->params->status_reg, 0);
+    if ( uart->params->overrun_reg != uart->params->status_reg )

I don't think there is any harm to reset the registers twice when overrun_reg != status_reg.

Agree.

Quoted 26 lines
Quoted 26 lines
xen/drivers/char/scif-uart.c +12 -4
+    {
+        scif_readw(uart, uart->params->overrun_reg);
+        scif_writew(uart, uart->params->overrun_reg, 0);
+    }
        /* Setup trigger level for TX/RX FIFOs */
      scif_writew(uart, SCIF_SCFCR, SCFCR_RTRG11 | SCFCR_TTRG11);
@@ -122,14 +180,19 @@ static void __init scif_uart_init_postirq(struct
 serial_port *port)
                  uart->irq);
        /* Clear all errors */
-    if ( scif_readw(uart, SCIF_SCFSR) & SCIF_ERRORS )
-        scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS);
-    if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER )
-        scif_writew(uart, SCIF_SCLSR, 0);
+    if ( scif_readw(uart, uart->params->status_reg) &
 uart->params->error_mask )
+        scif_writew(uart, uart->params->status_reg,
 ~uart->params->error_mask);
+    if ( uart->params->overrun_reg != uart->params->status_reg )
+    {
+        if ( scif_readw(uart, uart->params->overrun_reg) &
+             uart->params->overrun_mask )
+            scif_writew(uart, uart->params->overrun_reg,
+                        ~uart->params->overrun_mask);
Quoted 8 lines

xen/drivers/char/scif-uart.c static void __init scif_uart_init_postirq(struct serial_port *port) · line 195

Quoted 5 lines
xen/drivers/char/scif-uart.c +2 -1
+    }
        /* Enable TX/RX and Error Interrupts  */
      scif_writew(uart, SCIF_SCSCR, scif_readw(uart, SCIF_SCSCR) |
-                 SCSCR_TIE | SCSCR_RIE | SCSCR_REIE);
+                uart->params->irq_flags);

The indentation looks wrong here.

Will correct.

Quoted 53 lines
Quoted 53 lines
xen/drivers/char/scif-uart.c +12 -7
  }
    static void scif_uart_suspend(struct serial_port *port)
@@ -148,24 +211,25 @@ static int scif_uart_tx_ready(struct serial_port
 *port)
      uint16_t cnt;
        /* Check for empty space in TX FIFO */
-    if ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TDFE) )
+    if ( !(scif_readw(uart, uart->params->status_reg) & SCFSR_TDFE) )
          return 0;
         /* Check number of data bytes stored in TX FIFO */
      cnt = scif_readw(uart, SCIF_SCFDR) >> 8;
-    ASSERT( cnt >= 0 && cnt <= SCIF_FIFO_MAX_SIZE );
+    ASSERT( cnt >= 0 && cnt <= uart->params->fifo_size );
  -    return (SCIF_FIFO_MAX_SIZE - cnt);
+    return (uart->params->fifo_size - cnt);
  }
    static void scif_uart_putc(struct serial_port *port, char c)
  {
      struct scif_uart *uart = port->uart;
  -    scif_writeb(uart, SCIF_SCFTDR, c);
+    scif_writeb(uart, uart->params->tx_fifo_reg, c);
      /* Clear required TX flags */
-    scif_writew(uart, SCIF_SCFSR, scif_readw(uart, SCIF_SCFSR) &
-                 ~(SCFSR_TEND | SCFSR_TDFE));
+    scif_writew(uart, uart->params->status_reg,
+                scif_readw(uart, uart->params->status_reg) &
+                ~(SCFSR_TEND | SCFSR_TDFE));
  }
    static int scif_uart_getc(struct serial_port *port, char *pc)
@@ -173,15 +237,16 @@ static int scif_uart_getc(struct serial_port *port,
 char *pc)
      struct scif_uart *uart = port->uart;
        /* Check for available data bytes in RX FIFO */
-    if ( !(scif_readw(uart, SCIF_SCFSR) & (SCFSR_RDF | SCFSR_DR)) )
+    if ( !(scif_readw(uart, uart->params->status_reg) &
+          (SCFSR_RDF | SCFSR_DR)) )
          return 0;
  -    *pc = scif_readb(uart, SCIF_SCFRDR);
+    *pc = scif_readb(uart, uart->params->rx_fifo_reg);
        /* dummy read */
-    scif_readw(uart, SCIF_SCFSR);
+    scif_readw(uart, uart->params->status_reg);
      /* Clear required RX flags */
-    scif_writew(uart, SCIF_SCFSR, ~(SCFSR_RDF | SCFSR_DR));
+    scif_writew(uart, uart->params->status_reg, ~(SCFSR_RDF | SCFSR_DR));
        return 1;
  }
@@ -265,10 +330,15 @@ static int __init scif_uart_init(struct
 dt_device_node *dev,
          return -ENOMEM;
      }
Quoted 8 lines

xen/drivers/char/scif-uart.c static int __init scif_uart_init(struct dt_device_node *dev, · line 336

Quoted 4 lines
xen/drivers/char/scif-uart.c +3 -0
  +    if ( dt_device_is_compatible(dev, "renesas,scifa") )
+        uart->params = &port_params[SCIFA_PORT];
+    else
+        uart->params = &port_params[SCIF_PORT];

You can use the field .data in dt_device_match to store specific data and then use dt_match_node to find the correct node.

I understand. Will change.

Quoted 99 lines
Quoted 84 lines
xen/drivers/char/scif-uart.c +4 -2
+
      uart->vuart.base_addr  = addr;
      uart->vuart.size       = size;
-    uart->vuart.data_off   = SCIF_SCFTDR;
-    uart->vuart.status_off = SCIF_SCFSR;
+    uart->vuart.data_off   = uart->params->tx_fifo_reg;
+    uart->vuart.status_off = uart->params->status_reg;
      uart->vuart.status     = SCFSR_TDFE;
        /* Register with generic serial driver */
@@ -282,6 +352,7 @@ static int __init scif_uart_init(struct dt_device_node
 *dev,
  static const struct dt_device_match scif_uart_dt_match[] __initconst =
  {
      DT_MATCH_COMPATIBLE("renesas,scif"),
+    DT_MATCH_COMPATIBLE("renesas,scifa"),
      { /* sentinel */ },
  };

diff --git a/xen/include/asm-arm/scif-uart.h
b/xen/include/asm-arm/scif-uart.h
index 8137850..bce3404 100644

xen/include/asm-arm/scif-uart.h +19 -4
@@ -2,7 +2,7 @@
   * xen/include/asm-arm/scif-uart.h
   *
   * Common constant definition between early printk and the UART driver
- * for the SCIF compatible UART.
+ * for the SCIF(A) compatible UART.
   *
   * Oleksandr Tyshchenko <[email protected]>
   * Copyright (C) 2014, Globallogic.
@@ -21,9 +21,7 @@
  #ifndef __ASM_ARM_SCIF_UART_H
  #define __ASM_ARM_SCIF_UART_H
  -#define SCIF_FIFO_MAX_SIZE    16
-
-/* Register offsets */
+/* Register offsets (SCIF) */
  #define SCIF_SCSMR     (0x00)    /* Serial mode register           */
  #define SCIF_SCBRR     (0x04)    /* Bit rate register              */
  #define SCIF_SCSCR     (0x08)    /* Serial control register        */
@@ -57,8 +55,6 @@
  #define SCFSR_RDF     (1 << 1)    /* Receive FIFO Data Full */
  #define SCFSR_DR      (1 << 0)    /* Receive Data Ready */
  -#define SCIF_ERRORS    (SCFSR_PER | SCFSR_FER | SCFSR_ER | SCFSR_BRK)
-
  /* Line Status Register (SCLSR) */
  #define SCLSR_TO      (1 << 2)    /* Timeout */
  #define SCLSR_ORER    (1 << 0)    /* Overrun Error */
@@ -83,6 +79,42 @@
  #define SCFCR_TTRG10    (SCFCR_TTRG1)
  #define SCFCR_TTRG11    (SCFCR_TTRG1 | SCFCR_TTRG0)
  +/* Register offsets (SCIFA) */
+#define SCIFA_SCASMR     (0x00)    /* Serial mode register           */
+#define SCIFA_SCABRR     (0x04)    /* Bit rate register              */
+#define SCIFA_SCASCR     (0x08)    /* Serial control register        */
+#define SCIFA_SCATDSR    (0x0C)    /* Transmit data stop register    */
+#define SCIFA_SCAFER     (0x10)    /* FIFO error count register      */
+#define SCIFA_SCASSR     (0x14)    /* Serial status register         */
+#define SCIFA_SCAFCR     (0x18)    /* FIFO control register          */
+#define SCIFA_SCAFDR     (0x1C)    /* FIFO data count register       */
+#define SCIFA_SCAFTDR    (0x20)    /* Transmit FIFO data register    */
+#define SCIFA_SCAFRDR    (0x24)    /* Receive FIFO data register     */
+#define SCIFA_SCAPCR     (0x30)    /* Serial port control register   */
+#define SCIFA_SCAPDR     (0x34)    /* Serial port data register      */
+
+/* Serial Control Register (SCASCR) */
+#define SCASCR_ERIE     (1 << 10)    /* Receive Error Interrupt Enable */
+#define SCASCR_BRIE     (1 << 9)     /* Break Interrupt Enable */
+#define SCASCR_DRIE     (1 << 8)     /* Receive Data Ready Interrupt

Enable */

xen/include/asm-arm/scif-uart.h +10 -0
+#define SCASCR_TIE      (1 << 7)     /* Transmit Interrupt Enable */
+#define SCASCR_RIE      (1 << 6)     /* Receive Interrupt Enable */
+#define SCASCR_TE       (1 << 5)     /* Transmit Enable */
+#define SCASCR_RE       (1 << 4)     /* Receive Enable */
+#define SCASCR_CKE0     (1 << 0)     /* Clock Enable 0 */
+
+/* Serial Status Register (SCASSR) */
+#define SCASSR_ORER    (1 << 9)    /* Overrun Error */
+#define SCASSR_TSF     (1 << 8)    /* Transmit Data Stop */
+#define SCASSR_ER      (1 << 7)    /* Receive Error */

xen/include/asm-arm/scif-uart.h line 120

Quoted 10 lines
xen/include/asm-arm/scif-uart.h +8 -0
+#define SCASSR_TEND    (1 << 6)    /* Transmission End */
+#define SCASSR_TDFE    (1 << 5)    /* Transmit FIFO Data Empty */
+#define SCASSR_BRK     (1 << 4)    /* Break Detect */
+#define SCASSR_FER     (1 << 3)    /* Framing Error */
+#define SCASSR_PER     (1 << 2)    /* Parity Error */
+#define SCASSR_RDF     (1 << 1)    /* Receive FIFO Data Full */
+#define SCASSR_DR      (1 << 0)    /* Receive Data Ready */
+
  #endif /* __ASM_ARM_SCIF_UART_H */
    /*

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 2/4] xen/arm: drivers: scif: Add support for SCIFA compatible UARTs

Hi Oleksandr,

Quoted 6 lines · Oleksandr Tyshchenko
Quoted 3 lines · Julien Grall

On 06/08/18 19:35, Oleksandr Tyshchenko wrote:
I would prefer if you introduce a local variable for the params. This would avoid to write uart->params everywhere.

Agree. Do you want me to use this local variable only in interrupt handler or everywhere in a file where uart->params is used?

At least in all functions where uart->params is used more than once.

Cheers,

Signature · 6 lines
Julien Grall

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

PATCH 3/4 xen/arm: Add SCIFA UART support for early printk

In reply to Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Add support for Renesas "Stout" development board based on R-Car H2 SoC which has SCIFA compatible UART.

Actually existing SCIF UART support (debug-scif.inc) and newly added SCIFA UART support (debug-scifa.inc) differ only in registers offsets.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
 docs/misc/arm/early-printk.txt     |  3 ++-
 xen/arch/arm/Rules.mk              |  1 +
 xen/arch/arm/arm32/debug-scifa.inc | 51 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 xen/arch/arm/arm32/debug-scifa.inc
docs/misc/arm/early-printk.txt +2 -1
index f765f59..f1b55d3 100644
@@ -39,12 +39,13 @@ the name of the machine:
   - fastmodel: printk on ARM Fastmodel software emulators
   - hikey960: printk with pl011 with Hikey 960
   - juno: printk with pl011 on Juno platform
-  - lager: printk with SCIF0 on Renesas R-Car H2 processors
+  - lager: printk with SCIF0 on Renesas Lager board (R-Car H2 processor)
   - midway: printk with the pl011 on Calxeda Midway processors
   - 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
   - seattle: printk with pl011 for AMD Seattle processor
+  - stout: printk with SCIFA0 on Renesas Stout board (R-Car H2 processor)
   - sun6i: printk with 8250 on Allwinner A31 processors
   - sun7i: printk with 8250 on Allwinner A20 processors
   - thunderx: printk with pl011 for Cavium ThunderX processor
xen/arch/arm/Rules.mk +1 -0
index f264592..e011f8b 100644
@@ -40,6 +40,7 @@ EARLY_PRINTK_mvebu          := mvebu,0xd0012000
 EARLY_PRINTK_omap5432       := 8250,0x48020000,2
 EARLY_PRINTK_rcar3          := scif,0xe6e88000
 EARLY_PRINTK_seattle        := pl011,0xe1010000
+EARLY_PRINTK_stout          := scifa,0xe6c40000
 EARLY_PRINTK_sun6i          := 8250,0x01c28000,2
 EARLY_PRINTK_sun7i          := 8250,0x01c28000,2
 EARLY_PRINTK_thunderx       := pl011,0x87e024000000
xen/arch/arm/arm32/debug-scifa.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
#8 lore raw

Re: [PATCH v1 3/4] xen/arm: Add SCIFA UART support for early printk

Hi,

Quoted 8 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Add support for Renesas "Stout" development board based on R-Car H2 SoC which has SCIFA compatible UART.

Actually existing SCIF UART support (debug-scif.inc) and newly added SCIFA UART support (debug-scifa.inc) differ only in registers offsets.

In that case, could we just extend debug-scif.inc?

Quoted 16 lines
CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
  docs/misc/arm/early-printk.txt     |  3 ++-
  xen/arch/arm/Rules.mk              |  1 +
  xen/arch/arm/arm32/debug-scifa.inc | 51 ++++++++++++++++++++++++++++++++++++++
  3 files changed, 54 insertions(+), 1 deletion(-)

create mode 100644 xen/arch/arm/arm32/debug-scifa.inc

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

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

Quoted 5 lines
docs/misc/arm/early-printk.txt +1 -1
@@ -39,12 +39,13 @@ the name of the machine:
    - fastmodel: printk on ARM Fastmodel software emulators
    - hikey960: printk with pl011 with Hikey 960
    - juno: printk with pl011 on Juno platform
-  - lager: printk with SCIF0 on Renesas R-Car H2 processors
+  - lager: printk with SCIF0 on Renesas Lager board (R-Car H2 processor)

Why this change?

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

Quoted 6 lines
docs/misc/arm/early-printk.txt +1 -0
    - midway: printk with the pl011 on Calxeda Midway processors
    - 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
    - seattle: printk with pl011 for AMD Seattle processor
+  - stout: printk with SCIFA0 on Renesas Stout board (R-Car H2 processor)

I have started to look at porting that to Kconfig ealyprintk and it is a massive pain. So I would tend to prefer if we avoid adding more convenience alias and instead document on the wiki page how to use earlyprintk for that.

Quoted 63 lines
docs/misc/arm/early-printk.txt +0 -0
    - sun6i: printk with 8250 on Allwinner A31 processors
    - sun7i: printk with 8250 on Allwinner A20 processors
    - thunderx: printk with pl011 for Cavium ThunderX processor
xen/arch/arm/Rules.mk +1 -0
index f264592..e011f8b 100644
@@ -40,6 +40,7 @@ EARLY_PRINTK_mvebu          := mvebu,0xd0012000
  EARLY_PRINTK_omap5432       := 8250,0x48020000,2
  EARLY_PRINTK_rcar3          := scif,0xe6e88000
  EARLY_PRINTK_seattle        := pl011,0xe1010000
+EARLY_PRINTK_stout          := scifa,0xe6c40000
  EARLY_PRINTK_sun6i          := 8250,0x01c28000,2
  EARLY_PRINTK_sun7i          := 8250,0x01c28000,2
  EARLY_PRINTK_thunderx       := pl011,0x87e024000000
xen/arch/arm/arm32/debug-scifa.inc new file +41 -0
new file mode 100644
index 0000000..b5e60db
@@ -0,0 +1,51 @@
+/*
+ * xen/arch/arm/arm32/debug-scifa.inc
+ *
+ * SCIFA specific debug code
+ *
+ * Oleksandr Tyshchenko <[email protected]>
+ * Copyright (C) 2018 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+#include <asm/scif-uart.h>
+
+/*
+ * SCIFA UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register
+ */
+.macro early_uart_ready rb rc
+1:
+        ldrh   \rc, [\rb, #SCIFA_SCASSR]   /* <- SCASSR (status register) */
+        tst    \rc, #SCASSR_TDFE           /* Check TDFE bit */
+        beq    1b                          /* Wait for the UART to be ready */
+.endm
+
+/*
+ * SCIFA UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit
+ */
+.macro early_uart_transmit rb rt
+        strb   \rt, [\rb, #SCIFA_SCAFTDR]                  /* -> SCAFTDR (data register) */
+        ldrh   \rt, [\rb, #SCIFA_SCASSR]                   /* <- SCASSR (status register) */

xen/arch/arm/arm32/debug-scifa.inc line 51

Quoted 10 lines
xen/arch/arm/arm32/debug-scifa.inc new file +10 -0
+        and    \rt, \rt, #(~(SCASSR_TEND | SCASSR_TDFE))   /* Clear TEND and TDFE bits */
+        strh   \rt, [\rb, #SCIFA_SCASSR]                   /* -> SCASSR (status register) */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 3/4] xen/arm: Add SCIFA UART support for early printk

Quoted 1 line · Julien Grall

Hi,

Hi, Julien

Quoted 13 lines · Oleksandr Tyshchenko
Quoted 9 lines

From: Oleksandr Tyshchenko <[email protected]>

Add support for Renesas "Stout" development board based on R-Car H2 SoC which has SCIFA compatible UART.

Actually existing SCIF UART support (debug-scif.inc) and newly added SCIFA UART support (debug-scifa.inc) differ only in registers offsets.

In that case, could we just extend debug-scif.inc?

I was thinking about that, but couldn't find suitable solution without adding extra config option.
As I understand, we need to recognize in run-time somehow which interface is present to use proper register offsets,
so in UART driver it is easy to recognize using device-tree compatible string, but what to do here in such an early code.

Quoted 13 lines
Quoted 13 lines
CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
  docs/misc/arm/early-printk.txt     |  3 ++-
  xen/arch/arm/Rules.mk              |  1 +
  xen/arch/arm/arm32/debug-scifa.inc | 51
++++++++++++++++++++++++++++++++++++++
  3 files changed, 54 insertions(+), 1 deletion(-)

create mode 100644 xen/arch/arm/arm32/debug-scifa.inc

Quoted 14 lines

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

Quoted 11 lines
docs/misc/arm/early-printk.txt +1 -1
index f765f59..f1b55d3 100644
@@ -39,12 +39,13 @@ the name of the machine:
    - fastmodel: printk on ARM Fastmodel software emulators
    - hikey960: printk with pl011 with Hikey 960
    - juno: printk with pl011 on Juno platform
-  - lager: printk with SCIF0 on Renesas R-Car H2 processors
+  - lager: printk with SCIF0 on Renesas Lager board (R-Car H2 processor)

Why this change?

This sentence was not entirely correct. Since SCIF0 interface is applicable for Lager
board, but is not applicable for Stout board which also based on R-Car H2 processor.
Shall I create a separate patch for this small correction?

Quoted 9 lines

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

Quoted 7 lines
docs/misc/arm/early-printk.txt +1 -0
    - midway: printk with the pl011 on Calxeda Midway processors
    - 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
    - seattle: printk with pl011 for AMD Seattle processor
+  - stout: printk with SCIFA0 on Renesas Stout board (R-Car H2 processor)
Quoted 3 lines

I have started to look at porting that to Kconfig ealyprintk and it is a massive pain. So I would tend to prefer if we avoid adding more convenience alias and instead document on the wiki page how to use earlyprintk for that.

I will update a wiki page. Shall I drop this string in early-printk.txt?

Quoted 87 lines
Quoted 75 lines
docs/misc/arm/early-printk.txt +0 -0
    - sun6i: printk with 8250 on Allwinner A31 processors
    - sun7i: printk with 8250 on Allwinner A20 processors
    - thunderx: printk with pl011 for Cavium ThunderX processor
xen/arch/arm/Rules.mk +1 -0
index f264592..e011f8b 100644
@@ -40,6 +40,7 @@ EARLY_PRINTK_mvebu          := mvebu,0xd0012000
  EARLY_PRINTK_omap5432       := 8250,0x48020000,2
  EARLY_PRINTK_rcar3          := scif,0xe6e88000
  EARLY_PRINTK_seattle        := pl011,0xe1010000
+EARLY_PRINTK_stout          := scifa,0xe6c40000
  EARLY_PRINTK_sun6i          := 8250,0x01c28000,2
  EARLY_PRINTK_sun7i          := 8250,0x01c28000,2
  EARLY_PRINTK_thunderx       := pl011,0x87e024000000
xen/arch/arm/arm32/debug-scifa.inc new file +29 -0
new file mode 100644
index 0000000..b5e60db
@@ -0,0 +1,51 @@
+/*
+ * xen/arch/arm/arm32/debug-scifa.inc
+ *
+ * SCIFA specific debug code
+ *
+ * Oleksandr Tyshchenko <[email protected]>
+ * Copyright (C) 2018 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+#include <asm/scif-uart.h>
+
+/*
+ * SCIFA UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register
+ */
+.macro early_uart_ready rb rc
+1:
+        ldrh   \rc, [\rb, #SCIFA_SCASSR]   /* <- SCASSR (status register)

*/

xen/arch/arm/arm32/debug-scifa.inc new file +2 -0
+        tst    \rc, #SCASSR_TDFE           /* Check TDFE bit */
+        beq    1b                          /* Wait for the UART to be

ready */
+.endm

xen/arch/arm/arm32/debug-scifa.inc new file +8 -0
+
+/*
+ * SCIFA UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit
+ */
+.macro early_uart_transmit rb rt
+        strb   \rt, [\rb, #SCIFA_SCAFTDR]                  /* -> SCAFTDR

(data register) */
+ ldrh \rt, [\rb, #SCIFA_SCASSR] /* <- SCASSR
(status register) */
+ and \rt, \rt, #(~(SCASSR_TEND | SCASSR_TDFE)) /* Clear TEND
and TDFE bits */
+ strh \rt, [\rb, #SCIFA_SCASSR] /* -> SCASSR
(status register) */
+.endm

xen/arch/arm/arm32/debug-scifa.inc line 51

Quoted 7 lines
xen/arch/arm/arm32/debug-scifa.inc new file +7 -0
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 3/4] xen/arm: Add SCIFA UART support for early printk

Quoted 13 lines · Oleksandr Tyshchenko
Quoted 1 line · Julien Grall

Hi,

Hi, Julien

Quoted 8 lines · Oleksandr Tyshchenko
Quoted 6 lines

From: Oleksandr Tyshchenko <[email protected]>

Add support for Renesas "Stout" development board based on R-Car H2 SoC which has SCIFA compatible UART.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Actually existing SCIF UART support (debug-scif.inc) and newly added SCIFA UART support (debug-scifa.inc) differ only in registers offsets.

In that case, could we just extend debug-scif.inc?

I was thinking about that, but couldn't find suitable solution without adding extra config option.

I had the config option in my mind. But it may not be worth it.

Quoted 32 lines

As I understand, we need to recognize in run-time somehow which interface is present to use proper register offsets,
so in UART driver it is easy to recognize using device-tree compatible string, but what to do here in such an early code.

Quoted 13 lines
Quoted 13 lines
CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
   docs/misc/arm/early-printk.txt     |  3 ++-
   xen/arch/arm/Rules.mk              |  1 +
   xen/arch/arm/arm32/debug-scifa.inc | 51
++++++++++++++++++++++++++++++++++++++
   3 files changed, 54 insertions(+), 1 deletion(-)

create mode 100644 xen/arch/arm/arm32/debug-scifa.inc

Quoted 14 lines

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

Quoted 11 lines
docs/misc/arm/early-printk.txt +1 -1
index f765f59..f1b55d3 100644
@@ -39,12 +39,13 @@ the name of the machine:
     - fastmodel: printk on ARM Fastmodel software emulators
     - hikey960: printk with pl011 with Hikey 960
     - juno: printk with pl011 on Juno platform
-  - lager: printk with SCIF0 on Renesas R-Car H2 processors
+  - lager: printk with SCIF0 on Renesas Lager board (R-Car H2 processor)

Why this change?

Quoted 5 lines

This sentence was not entirely correct. Since SCIF0 interface is applicable for Lager
board, but is not applicable for Stout board which also based on R-Car H2 processor.
Shall I create a separate patch for this small correction?

Yes please.

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
docs/misc/arm/early-printk.txt +1 -0
     - midway: printk with the pl011 on Calxeda Midway processors
     - 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
     - seattle: printk with pl011 for AMD Seattle processor
+  - stout: printk with SCIFA0 on Renesas Stout board (R-Car H2 processor)
Quoted 4 lines
Quoted 3 lines

I have started to look at porting that to Kconfig ealyprintk and it is a massive pain. So I would tend to prefer if we avoid adding more convenience alias and instead document on the wiki page how to use earlyprintk for that.

I will update a wiki page. Shall I drop this string in early-printk.txt?

Yes please.

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 3/4] xen/arm: Add SCIFA UART support for early printk

Quoted 7 lines · Julien Grall
Quoted 4 lines · Oleksandr Tyshchenko
Quoted 2 lines · Julien Grall

Hi,

Hi, Julien

Quoted 18 lines
Quoted 18 lines

Hi, Julien

Quoted 14 lines · Oleksandr Tyshchenko
Quoted 10 lines

From: Oleksandr Tyshchenko <[email protected]>

Add support for Renesas "Stout" development board based on R-Car H2 SoC which has SCIFA compatible UART.

Actually existing SCIF UART support (debug-scif.inc) and newly added SCIFA UART support (debug-scifa.inc) differ only in registers offsets.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

In that case, could we just extend debug-scif.inc?

I was thinking about that, but couldn't find suitable solution without adding extra config option.

I had the config option in my mind. But it may not be worth it.

So, if you or anyone else don't mind I leave this patch creating debug-scifa.inc file.

Quoted 73 lines
Quoted 37 lines

As I understand, we need to recognize in run-time somehow which interface is present to use proper register offsets,
so in UART driver it is easy to recognize using device-tree compatible string, but what to do here in such an early code.

Quoted 13 lines
Quoted 13 lines
CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
   docs/misc/arm/early-printk.txt     |  3 ++-
   xen/arch/arm/Rules.mk              |  1 +
   xen/arch/arm/arm32/debug-scifa.inc | 51
++++++++++++++++++++++++++++++++++++++
   3 files changed, 54 insertions(+), 1 deletion(-)

create mode 100644 xen/arch/arm/arm32/debug-scifa.inc

Quoted 16 lines

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

Quoted 12 lines
docs/misc/arm/early-printk.txt +1 -1
index f765f59..f1b55d3 100644
@@ -39,12 +39,13 @@ the name of the machine:
     - fastmodel: printk on ARM Fastmodel software emulators
     - hikey960: printk with pl011 with Hikey 960
     - juno: printk with pl011 on Juno platform
-  - lager: printk with SCIF0 on Renesas R-Car H2 processors
+  - lager: printk with SCIF0 on Renesas Lager board (R-Car H2
 processor)

Why this change?

Quoted 5 lines

This sentence was not entirely correct. Since SCIF0 interface is applicable for Lager
board, but is not applicable for Stout board which also based on R-Car H2 processor.
Shall I create a separate patch for this small correction?

Yes please.

Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
docs/misc/arm/early-printk.txt +1 -0
     - midway: printk with the pl011 on Calxeda Midway processors
     - 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
     - seattle: printk with pl011 for AMD Seattle processor
+  - stout: printk with SCIFA0 on Renesas Stout board (R-Car H2
 processor)
Quoted 7 lines
Quoted 5 lines

I have started to look at porting that to Kconfig ealyprintk and it is a massive pain. So I would tend to prefer if we avoid adding more convenience
alias and instead document on the wiki page how to use earlyprintk for that.

I will update a wiki page. Shall I drop this string in early-printk.txt?

Yes please.

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

PATCH 4/4 xen/arm: Reuse R-Car Gen2 platform code for Stout board

In reply to Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
 xen/arch/arm/platforms/rcar2.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +4 -0
index df0ac84..ee2ded0 100644
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
 static const char *const rcar2_dt_compat[] __initconst =
 {
     "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",
     NULL
 };
 
Signature · 7 lines
2.7.4


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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Hi,

Quoted 18 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
  xen/arch/arm/platforms/rcar2.c | 4 ++++
  1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +0 -0
index df0ac84..ee2ded0 100644

xen/arch/arm/platforms/rcar2.c static int __init rcar2_smp_init(void) · line 55

Quoted 7 lines
xen/arch/arm/platforms/rcar2.c +4 -0
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
  static const char *const rcar2_dt_compat[] __initconst =
  {
      "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",

I am quite reluctant to add compatible that are not present in upstream Linux. Looking at the DT upstreamed in Linux, the compatible for r8a7790 SoC seem to be "renesas,r8a7790". Wouldn't it be sufficient to cover all the boards? But ...

... don't you have PSCI support on those platforms?

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Hi, Julien

Quoted 28 lines · Julien Grall

Hi,

Quoted 25 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
  xen/arch/arm/platforms/rcar2.c | 4 ++++
  1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +2 -0
index df0ac84..ee2ded0 100644
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
  static const char *const rcar2_dt_compat[] __initconst =
  {
      "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
Quoted 8 lines

xen/arch/arm/platforms/rcar2.c static int __init rcar2_smp_init(void) · line 55

Quoted 2 lines
xen/arch/arm/platforms/rcar2.c +2 -0
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",

I am quite reluctant to add compatible that are not present in upstream Linux. Looking at the DT upstreamed in Linux, the compatible for r8a7790 SoC seem to be "renesas,r8a7790". Wouldn't it be sufficient to cover all the boards? But ...

This compatible came from official BSP for this board...
https://elinux.org/R-Car/Boards/Yocto#Running

I have just checked "renesas,r8a7790" and you was right, it covers these modifications. So, I will change.
Moreover, we can just have only single compatible, which will cover (I hope) all boards based on R-Car H2 SoC, including Lager board (compatible = "renesas,lager", "renesas,r8a7790")

static const char *const rcar2_dt_compat[] __initconst = {
- "renesas,lager",
+ "renesas,r8a7790",
NULL
};

What do you think?

Quoted 2 lines

... don't you have PSCI support on those platforms?

AFAIK, no.
This code is definitely needed for Stout board as well, since the SoC is the same (R-Car Gen2).

Quoted 5 lines

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Quoted 1 line · Oleksandr Tyshchenko

Hi, Julien

Hi Oleksandr,

Quoted 55 lines · Julien Grall
Quoted 28 lines

Hi,

Quoted 25 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
   xen/arch/arm/platforms/rcar2.c | 4 ++++
   1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +2 -0
index df0ac84..ee2ded0 100644
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
   static const char *const rcar2_dt_compat[] __initconst =
   {
       "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
Quoted 8 lines

xen/arch/arm/platforms/rcar2.c static int __init rcar2_smp_init(void) · line 55

Quoted 2 lines
xen/arch/arm/platforms/rcar2.c +2 -0
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",

I am quite reluctant to add compatible that are not present in upstream Linux. Looking at the DT upstreamed in Linux, the compatible for r8a7790 SoC seem to be "renesas,r8a7790". Wouldn't it be sufficient to cover all the boards? But ...

This compatible came from official BSP for this board...
https://elinux.org/R-Car/Boards/Yocto#Running

I have just checked "renesas,r8a7790" and you was right, it covers these modifications. So, I will change.
Moreover, we can just have only single compatible, which will cover (I hope) all boards based on R-Car H2 SoC, including Lager board (compatible = "renesas,lager", "renesas,r8a7790")

  static const char *const rcar2_dt_compat[] __initconst =
  {
(quoted diff) +1 -1
-    "renesas,lager",
+    "renesas,r8a7790",
      NULL
  };
Quoted 1 line

What do you think?

That would be the best.

Quoted 7 lines
Quoted 3 lines

... don't you have PSCI support on those platforms?

AFAIK, no.
This code is definitely needed for Stout board as well, since the SoC is the same (R-Car Gen2).

When I looked at the device-tree upstreamed for R-Car Gen2 (I think r8a7790), PSCI is supported. So I am a bit surprised that the Stout (or even lager) does not support it. Are you sure you are not using an old firmware?

If not, can you please point me to the code in Linux (upstream or BSP) doing the SMP bring-up for the R-Car?

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Quoted 6 lines · Julien Grall
Quoted 2 lines · Oleksandr Tyshchenko

Hi, Julien

Hi Oleksandr,

Hi Julien

Quoted 72 lines
Quoted 62 lines · Julien Grall
Quoted 35 lines

Hi,

Quoted 21 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
   xen/arch/arm/platforms/rcar2.c | 4 ++++
   1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +0 -0
index df0ac84..ee2ded0 100644

xen/arch/arm/platforms/rcar2.c static int __init rcar2_smp_init(void) · line 55

Quoted 7 lines
xen/arch/arm/platforms/rcar2.c +4 -0
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
   static const char *const rcar2_dt_compat[] __initconst =
   {
       "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",
Quoted 5 lines

I am quite reluctant to add compatible that are not present in upstream Linux. Looking at the DT upstreamed in Linux, the compatible for r8a7790 SoC
seem to be "renesas,r8a7790". Wouldn't it be sufficient to cover all the boards? But ...

This compatible came from official BSP for this board...
https://elinux.org/R-Car/Boards/Yocto#Running

I have just checked "renesas,r8a7790" and you was right, it covers these modifications. So, I will change.
Moreover, we can just have only single compatible, which will cover (I hope) all boards based on R-Car H2 SoC, including Lager board (compatible = "renesas,lager", "renesas,r8a7790")

  static const char *const rcar2_dt_compat[] __initconst =
  {
(quoted diff) +1 -1
-    "renesas,lager",
+    "renesas,r8a7790",
      NULL
  };
Quoted 1 line

What do you think?

That would be the best.

Quoted 5 lines
Quoted 3 lines

... don't you have PSCI support on those platforms?

Quoted 8 lines
Quoted 3 lines

AFAIK, no.
This code is definitely needed for Stout board as well, since the SoC is the same (R-Car Gen2).

When I looked at the device-tree upstreamed for R-Car Gen2 (I think r8a7790), PSCI is supported. So I am a bit surprised that the Stout (or even lager) does not support it. Are you sure you are not using an old firmware?

This is the topic I am not quite familiar with, so may mistake...

Yes, the BSP I use is quite old, but I managed to run it on top of Xen... Just to clarify, saying firmware you mean something running in Secure World, like ARM TF, for example
and providing PSCI services? If yes, the BSP for R-Car Gen2 seems doesn't contain it. Only U-Boot is available.
But U-Boot was modified to be able to switch A15 cores to HYP mode. Here [1] you can see how it was done for Lager board, something similar I did for Stout board.

So, in a nutshell, SMP bring-up under Xen is done in following way:
- U-Boot switches all cores to HYP mode and jumps to Xen on a boot core, while non-boot cores are waiting in U-Boot.
- Platform SMP init code (rcar2.c) brings each non-boot core to Xen.

Quoted 3 lines

If not, can you please point me to the code in Linux (upstream or BSP) doing the SMP bring-up for the R-Car?

BSP is based on + additional patches in Yocto layers:
https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/boot/dts/r8a7790.dtsi?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8
https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/mach-shmobile/platsmp-apmu.c?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8

Upstream code:
https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/r8a7790.dtsi
https://github.com/torvalds/linux/blob/master/arch/arm/mach-shmobile/platsmp-apmu.c

Could you point me a link to device-tree where PSCI is supported?

[1] https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/Lager

Quoted 5 lines

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Hi Oleksandr,

Quoted 114 lines · Oleksandr Tyshchenko
Quoted 6 lines · Julien Grall
Quoted 2 lines · Oleksandr Tyshchenko

Hi, Julien

Hi Oleksandr,

Hi Julien

Quoted 72 lines
Quoted 62 lines · Julien Grall
Quoted 35 lines

Hi,

Quoted 21 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
    xen/arch/arm/platforms/rcar2.c | 4 ++++
    1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +0 -0
index df0ac84..ee2ded0 100644

xen/arch/arm/platforms/rcar2.c static int __init rcar2_smp_init(void) · line 55

Quoted 7 lines
xen/arch/arm/platforms/rcar2.c +4 -0
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
    static const char *const rcar2_dt_compat[] __initconst =
    {
        "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",
Quoted 5 lines

I am quite reluctant to add compatible that are not present in upstream Linux. Looking at the DT upstreamed in Linux, the compatible for r8a7790 SoC
seem to be "renesas,r8a7790". Wouldn't it be sufficient to cover all the boards? But ...

This compatible came from official BSP for this board...
https://elinux.org/R-Car/Boards/Yocto#Running

I have just checked "renesas,r8a7790" and you was right, it covers these modifications. So, I will change.
Moreover, we can just have only single compatible, which will cover (I hope) all boards based on R-Car H2 SoC, including Lager board (compatible = "renesas,lager", "renesas,r8a7790")

   static const char *const rcar2_dt_compat[] __initconst =
   {
(quoted diff) +1 -1
-    "renesas,lager",
+    "renesas,r8a7790",
       NULL
   };
Quoted 1 line

What do you think?

That would be the best.

Quoted 5 lines
Quoted 3 lines

... don't you have PSCI support on those platforms?

Quoted 8 lines
Quoted 3 lines

AFAIK, no.
This code is definitely needed for Stout board as well, since the SoC is the same (R-Car Gen2).

When I looked at the device-tree upstreamed for R-Car Gen2 (I think r8a7790), PSCI is supported. So I am a bit surprised that the Stout (or even lager) does not support it. Are you sure you are not using an old firmware?

This is the topic I am not quite familiar with, so may mistake...

Yes, the BSP I use is quite old, but I managed to run it on top of Xen... Just to clarify, saying firmware you mean something running in Secure World, like ARM TF, for example
and providing PSCI services? If yes, the BSP for R-Car Gen2 seems doesn't contain it. Only U-Boot is available.
But U-Boot was modified to be able to switch A15 cores to HYP mode. Here [1] you can see how it was done for Lager board, something similar I did for Stout board.

So, in a nutshell, SMP bring-up under Xen is done in following way:
- U-Boot switches all cores to HYP mode and jumps to Xen on a boot core, while non-boot cores are waiting in U-Boot.
- Platform SMP init code (rcar2.c) brings each non-boot core to Xen.

Quoted 3 lines

If not, can you please point me to the code in Linux (upstream or BSP) doing the SMP bring-up for the R-Car?

BSP is based on + additional patches in Yocto layers:
https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/boot/dts/r8a7790.dtsi?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8
https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/mach-shmobile/platsmp-apmu.c?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8

Quoted 5 lines

Upstream code:
https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/r8a7790.dtsi
https://github.com/torvalds/linux/blob/master/arch/arm/mach-shmobile/platsmp-apmu.c

Could you point me a link to device-tree where PSCI is supported?

Somehow I thought the platform was 64-bit and found a SOC name very similar to it. Sorry for the confusion. PSCI seems indeed not supported for that platform.

However, the code looks fairly different than what we have in Xen. For instance secondary CPU seems to require to initialize CNTVOFF, the function to power on a CPU also looks different.

Could you explain why such differences?

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Quoted 1 line · Julien Grall

Hi Oleksandr,

Hi Julien.

Quoted 143 lines · Oleksandr Tyshchenko
Quoted 140 lines · Julien Grall
Quoted 9 lines · Oleksandr Tyshchenko
Quoted 3 lines

Hi, Julien

Hi Oleksandr,

Hi Julien

Quoted 87 lines
Quoted 69 lines
Quoted 38 lines · Julien Grall

Hi,

Quoted 22 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
    xen/arch/arm/platforms/rcar2.c | 4 ++++
    1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +0 -0
index df0ac84..ee2ded0 100644

xen/arch/arm/platforms/rcar2.c static int __init rcar2_smp_init(void) · line 55

Quoted 7 lines
xen/arch/arm/platforms/rcar2.c +4 -0
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
    static const char *const rcar2_dt_compat[] __initconst =
    {
        "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",
Quoted 7 lines

I am quite reluctant to add compatible that are not present in upstream Linux. Looking at the DT upstreamed in Linux, the compatible for r8a7790
SoC
seem to be "renesas,r8a7790". Wouldn't it be sufficient to cover all the
boards? But ...

This compatible came from official BSP for this board...
https://elinux.org/R-Car/Boards/Yocto#Running

I have just checked "renesas,r8a7790" and you was right, it covers these modifications. So, I will change.
Moreover, we can just have only single compatible, which will cover (I hope) all boards based on R-Car H2 SoC, including Lager board (compatible = "renesas,lager", "renesas,r8a7790")

   static const char *const rcar2_dt_compat[] __initconst =
   {
(quoted diff) +1 -1
-    "renesas,lager",
+    "renesas,r8a7790",
       NULL
   };
Quoted 1 line

What do you think?

That would be the best.

Quoted 9 lines
Quoted 3 lines

... don't you have PSCI support on those platforms?

AFAIK, no.
This code is definitely needed for Stout board as well, since the SoC is the same (R-Car Gen2).

Quoted 5 lines

When I looked at the device-tree upstreamed for R-Car Gen2 (I think r8a7790), PSCI is supported. So I am a bit surprised that the Stout (or even
lager) does not support it. Are you sure you are not using an old firmware?

This is the topic I am not quite familiar with, so may mistake...

Yes, the BSP I use is quite old, but I managed to run it on top of Xen... Just to clarify, saying firmware you mean something running in Secure World, like ARM TF, for example
and providing PSCI services? If yes, the BSP for R-Car Gen2 seems doesn't contain it. Only U-Boot is available.
But U-Boot was modified to be able to switch A15 cores to HYP mode. Here [1] you can see how it was done for Lager board, something similar I did for Stout board.

So, in a nutshell, SMP bring-up under Xen is done in following way:
- U-Boot switches all cores to HYP mode and jumps to Xen on a boot core, while non-boot cores are waiting in U-Boot.
- Platform SMP init code (rcar2.c) brings each non-boot core to Xen.

Quoted 4 lines

If not, can you please point me to the code in Linux (upstream or BSP) doing
the SMP bring-up for the R-Car?

BSP is based on + additional patches in Yocto layers:

https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/boot/dts/r8a7790.dtsi?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8

https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/mach-shmobile/platsmp-apmu.c?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8

Upstream code:

https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/r8a7790.dtsi

Quoted 8 lines
Quoted 3 lines

https://github.com/torvalds/linux/blob/master/arch/arm/mach-shmobile/platsmp-apmu.c

Could you point me a link to device-tree where PSCI is supported?

Somehow I thought the platform was 64-bit and found a SOC name very similar to it. Sorry for the confusion. PSCI seems indeed not supported for that platform.

R-Car Gen3 is ARM64 (H2 SoC -> r8a7790) and does support PSCI. But R-Car Gen2 is ARM32 (H2 SoC -> r8a7790)

Quoted 4 lines

However, the code looks fairly different than what we have in Xen. For instance secondary CPU seems to require to initialize CNTVOFF, the function to power on a CPU also looks different.

Sorry, which code you are taking about, U-Boot or Linux?

Quoted 7 lines

Could you explain why such differences?

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Quoted 3 lines · Oleksandr Tyshchenko
Quoted 1 line · Julien Grall

Hi Oleksandr,

Hi Julien.

Hi.

Quoted 146 lines
Quoted 146 lines · Oleksandr Tyshchenko
Quoted 142 lines · Julien Grall
Quoted 9 lines · Oleksandr Tyshchenko
Quoted 3 lines

Hi, Julien

Hi Oleksandr,

Hi Julien

Quoted 87 lines
Quoted 69 lines
Quoted 38 lines · Julien Grall

Hi,

Quoted 22 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Renesas "Stout" development board (with different expansion boards) is also based on R-Car Gen2 SoC. So extend compat array with board's compatible strings.

CC Stefano Stabellini <[email protected]>
CC Julien Grall <[email protected]>
---
    xen/arch/arm/platforms/rcar2.c | 4 ++++
    1 file changed, 4 insertions(+)
xen/arch/arm/platforms/rcar2.c +0 -0
index df0ac84..ee2ded0 100644

xen/arch/arm/platforms/rcar2.c static int __init rcar2_smp_init(void) · line 55

Quoted 7 lines
xen/arch/arm/platforms/rcar2.c +4 -0
@@ -49,6 +49,10 @@ static int __init rcar2_smp_init(void)
    static const char *const rcar2_dt_compat[] __initconst =
    {
        "renesas,lager",
+    "renesas,r8a7790stout",
+    "renesas,r8a7790stout-view",
+    "renesas,r8a7790stout-had",
+    "renesas,r8a7790stout-full",
Quoted 7 lines

I am quite reluctant to add compatible that are not present in upstream Linux. Looking at the DT upstreamed in Linux, the compatible for r8a7790
SoC
seem to be "renesas,r8a7790". Wouldn't it be sufficient to cover all the
boards? But ...

This compatible came from official BSP for this board...
https://elinux.org/R-Car/Boards/Yocto#Running

I have just checked "renesas,r8a7790" and you was right, it covers these modifications. So, I will change.
Moreover, we can just have only single compatible, which will cover (I hope) all boards based on R-Car H2 SoC, including Lager board (compatible = "renesas,lager", "renesas,r8a7790")

   static const char *const rcar2_dt_compat[] __initconst =
   {
(quoted diff) +1 -1
-    "renesas,lager",
+    "renesas,r8a7790",
       NULL
   };
Quoted 1 line

What do you think?

That would be the best.

Quoted 9 lines
Quoted 3 lines

... don't you have PSCI support on those platforms?

AFAIK, no.
This code is definitely needed for Stout board as well, since the SoC is the same (R-Car Gen2).

Quoted 5 lines

When I looked at the device-tree upstreamed for R-Car Gen2 (I think r8a7790), PSCI is supported. So I am a bit surprised that the Stout (or even
lager) does not support it. Are you sure you are not using an old firmware?

This is the topic I am not quite familiar with, so may mistake...

Yes, the BSP I use is quite old, but I managed to run it on top of Xen... Just to clarify, saying firmware you mean something running in Secure World, like ARM TF, for example
and providing PSCI services? If yes, the BSP for R-Car Gen2 seems doesn't contain it. Only U-Boot is available.
But U-Boot was modified to be able to switch A15 cores to HYP mode. Here [1] you can see how it was done for Lager board, something similar I did for Stout board.

So, in a nutshell, SMP bring-up under Xen is done in following way:
- U-Boot switches all cores to HYP mode and jumps to Xen on a boot core, while non-boot cores are waiting in U-Boot.
- Platform SMP init code (rcar2.c) brings each non-boot core to Xen.

Quoted 4 lines

If not, can you please point me to the code in Linux (upstream or BSP) doing
the SMP bring-up for the R-Car?

BSP is based on + additional patches in Yocto layers:

https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/boot/dts/r8a7790.dtsi?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8

https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-backport.git/tree/arch/arm/mach-shmobile/platsmp-apmu.c?h=bsp/v3.10.31-ltsi/rcar-gen2-1.9.8

Upstream code:

https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/r8a7790.dtsi

https://github.com/torvalds/linux/blob/master/arch/arm/mach-shmobile/platsmp-apmu.c

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

Could you point me a link to device-tree where PSCI is supported?

Somehow I thought the platform was 64-bit and found a SOC name very similar to it. Sorry for the confusion. PSCI seems indeed not supported for that platform.

R-Car Gen3 is ARM64 (H2 SoC -> r8a7790) and does support PSCI.

Sorry for the typo, should be:
R-Car Gen3 is ARM64 (H3 SoC -> r8a7795) and does support PSCI.

Quoted 22 lines

But R-Car Gen2 is ARM32 (H2 SoC -> r8a7790)

Quoted 4 lines

However, the code looks fairly different than what we have in Xen. For instance secondary CPU seems to require to initialize CNTVOFF, the function to power on a CPU also looks different.

Sorry, which code you are taking about, U-Boot or Linux?

Quoted 7 lines

Could you explain why such differences?

Cheers,

--
Julien Grall

--
Regards,

Oleksandr Tyshchenko

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

In reply to Oleksandr Tyshchenko
Quoted 4 lines · Oleksandr Tyshchenko
Quoted 3 lines · Julien Grall

Somehow I thought the platform was 64-bit and found a SOC name very similar to it. Sorry for the confusion. PSCI seems indeed not supported for that platform.

Quoted 8 lines

R-Car Gen3 is ARM64 (H2 SoC -> r8a7790) and does support PSCI. But R-Car Gen2 is ARM32 (H2 SoC -> r8a7790)

Quoted 4 lines

However, the code looks fairly different than what we have in Xen. For instance secondary CPU seems to require to initialize CNTVOFF, the function to power on a CPU also looks different.

Sorry, which code you are taking about, U-Boot or Linux?

The SMP code in Linux vs the SMP code in Xen for the R-Car. In most of the cases, Xen should replicate what Linux does.

I am trying to understand why such differences at the moment.

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Hi Julien.

Quoted 20 lines · Julien Grall
Quoted 17 lines · Oleksandr Tyshchenko
Quoted 5 lines · Julien Grall

Somehow I thought the platform was 64-bit and found a SOC name very similar
to it. Sorry for the confusion. PSCI seems indeed not supported for that platform.

R-Car Gen3 is ARM64 (H2 SoC -> r8a7790) and does support PSCI. But R-Car Gen2 is ARM32 (H2 SoC -> r8a7790)

Quoted 5 lines

However, the code looks fairly different than what we have in Xen. For instance secondary CPU seems to require to initialize CNTVOFF, the function
to power on a CPU also looks different.

Quoted 7 lines
Quoted 1 line

Sorry, which code you are taking about, U-Boot or Linux?

The SMP code in Linux vs the SMP code in Xen for the R-Car. In most of the cases, Xen should replicate what Linux does.

I am trying to understand why such differences at the moment.

As I understand, the SMP code for Linux can't be used in Xen, since the requirement is to boot into Xen with cores already being in Hypervisor mode.
But, all cores seems to start in Monitor mode after powering them up. So, they must be switched into Hypervisor mode beforehand, correct?

U-Boot brings non-boot cores up (using ported from Linux's platsmp-apmu code functions). Then U-Boot switches all cores to HYP mode.
While jump into Xen on a boot core, all non-boot cores are left in U-Boot to wait to be "woken up by Xen" (actually rcar2_smp_init() is used for).
Platform R-Car2 code in Xen doesn't power on cores, it just "brings them to Xen".

Please correct me if I am wrong.

Also, U-Boot seems to reset to zero CNTVOFF on all cores before leaving Monitor mode.

Quoted 5 lines

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Quoted 1 line · Oleksandr Tyshchenko

Hi Julien.

Hi Oleksandr,

Quoted 27 lines · Julien Grall
Quoted 26 lines · Oleksandr Tyshchenko
Quoted 12 lines · Julien Grall
Quoted 5 lines

Somehow I thought the platform was 64-bit and found a SOC name very similar
to it. Sorry for the confusion. PSCI seems indeed not supported for that platform.

R-Car Gen3 is ARM64 (H2 SoC -> r8a7790) and does support PSCI. But R-Car Gen2 is ARM32 (H2 SoC -> r8a7790)

Quoted 1 line
Quoted 6 lines
Quoted 4 lines

However, the code looks fairly different than what we have in Xen. For instance secondary CPU seems to require to initialize CNTVOFF, the function
to power on a CPU also looks different.

Sorry, which code you are taking about, U-Boot or Linux?

The SMP code in Linux vs the SMP code in Xen for the R-Car. In most of the cases, Xen should replicate what Linux does.

Quoted 7 lines
Quoted 1 line

I am trying to understand why such differences at the moment.

As I understand, the SMP code for Linux can't be used in Xen, since the requirement is to boot into Xen with cores already being in Hypervisor mode.
But, all cores seems to start in Monitor mode after powering them up. So, they must be switched into Hypervisor mode beforehand, correct?

I am quite confused here. If a CPU will be in hypervisor mode for Xen, how come the same CPU will boot in monitor mode for Linux? Surely there should be no difference in term of boot here. Are you using different firmware here?

Quoted 4 lines

U-Boot brings non-boot cores up (using ported from Linux's platsmp-apmu code functions). Then U-Boot switches all cores to HYP mode.

Who did the port? Is it upstream?

Quoted 5 lines

While jump into Xen on a boot core, all non-boot cores are left in U-Boot to wait to be "woken up by Xen" (actually rcar2_smp_init() is used for).
Platform R-Car2 code in Xen doesn't power on cores, it just "brings them to Xen".

What does the address 0xe63c0000 corresponds too? From the DT it seems it is part of the ICRAM. But it is not clear why you write in there.

Could you point to any relevant documentation?

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Quoted 6 lines · Julien Grall
Quoted 2 lines · Oleksandr Tyshchenko

Hi Julien.

Hi Oleksandr,

Hi Julien

Quoted 47 lines
Quoted 37 lines · Julien Grall
Quoted 35 lines · Oleksandr Tyshchenko
Quoted 17 lines
Quoted 7 lines · Julien Grall

Somehow I thought the platform was 64-bit and found a SOC name very similar
to it. Sorry for the confusion. PSCI seems indeed not supported for that
platform.

R-Car Gen3 is ARM64 (H2 SoC -> r8a7790) and does support PSCI. But R-Car Gen2 is ARM32 (H2 SoC -> r8a7790)

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

However, the code looks fairly different than what we have in Xen. For instance secondary CPU seems to require to initialize CNTVOFF, the function
to power on a CPU also looks different.

Sorry, which code you are taking about, U-Boot or Linux?

The SMP code in Linux vs the SMP code in Xen for the R-Car. In most of the
cases, Xen should replicate what Linux does.

Quoted 8 lines
Quoted 1 line

I am trying to understand why such differences at the moment.

As I understand, the SMP code for Linux can't be used in Xen, since the requirement is to boot into Xen with cores already being in Hypervisor mode.
But, all cores seems to start in Monitor mode after powering them up. So, they must be switched into Hypervisor mode beforehand, correct?

Quoted 4 lines

I am quite confused here. If a CPU will be in hypervisor mode for Xen, how come the same CPU will boot in monitor mode for Linux? Surely there should be no difference in term of boot here. Are you using different firmware here?

Yes, in order to run modified U-Boot is used. You can see here what exactly was modified.
This instruction [1] contains link to patches [2] (see "Apply additional patches" step)
which should be applied to bare U-Boot.

[1] https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/Lager
[2] https://lists.xenproject.org/archives/html/xen-devel/2015-01/msg02475.html

Quoted 8 lines
Quoted 5 lines

U-Boot brings non-boot cores up (using ported from Linux's platsmp-apmu code functions). Then U-Boot switches all cores to HYP mode.

Who did the port? Is it upstream?

AFAIR Iurii Konovalenko did this port, he is also an author of xen/arch/arm/platforms/rcar2.c.
I don't think U-Boot changes are upsteamed. But anybody who wants to run Xen on Lager board is able (I think) to apply
published patches [2] to U-Boot and build it.
The same way anybody who will want to run Xen on Stout board will be able to apply U-Boot patches I will attach to the future Wiki page for Stout board.

Quoted 10 lines
Quoted 6 lines

While jump into Xen on a boot core, all non-boot cores are left in U-Boot to wait to be "woken up by Xen" (actually rcar2_smp_init() is used for).
Platform R-Car2 code in Xen doesn't power on cores, it just "brings them to Xen".

What does the address 0xe63c0000 corresponds too? From the DT it seems it is part of the ICRAM. But it is not clear why you write in there.

Yes, it is a part of the ICRAM.

Unfortunately, I am not an expert in such code to definitively say how it is supposed to work.
But it seems that 0xE63C0FFC is an address which is being polled by non-boot core in U-Boot. It was set to zero value beforehand. So, writing an actual value to this address, Xen triggers an action for bringing non-boot core up to Xen.

Waiting loop in U-Boot:

asm(".arm \n"
".align 2 \n"
".global smp_waitloop \n"
"smp_waitloop: \n"
"1: wfe \n"
"ldr r0, =0xE63C0FFC \n"
"ldr r0, [r0] \n"
"teq r0, #0x0 \n"
"beq 1b \n"
"b _do_nonsec_entry \n"
".type smp_waitloop, %function \n"
".size smp_waitloop, .-smp_waitloop \n");

Trigger code in Xen:

writel(__pa(init_secondary), 0xE63C0FFC);

Quoted 2 lines

Could you point to any relevant documentation?

I am afraid, I can't point to documentation.

Quoted 5 lines

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Hi Oleksandr,

Quoted 9 lines · Oleksandr Tyshchenko
Quoted 7 lines · Julien Grall
Quoted 2 lines · Oleksandr Tyshchenko
Quoted 1 line · Julien Grall

On 08/09/2018 05:18 PM, Oleksandr Tyshchenko wrote:

I am quite confused here. If a CPU will be in hypervisor mode for Xen, how come the same CPU will boot in monitor mode for Linux? Surely there should be no difference in term of boot here. Are you using different firmware here?

Quoted 6 lines

Yes, in order to run modified U-Boot is used. You can see here what exactly was modified.
This instruction [1] contains link to patches [2] (see "Apply additional patches" step)
which should be applied to bare U-Boot.

I don't think it is reasonable to request a specific U-boot just for Xen. What if the user decide to run Linux on baremetal? Will he have to switch back and forth between firmware?

Quoted 12 lines

[1] https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/Lager
[2] https://lists.xenproject.org/archives/html/xen-devel/2015-01/msg02475.html

Quoted 8 lines
Quoted 5 lines

U-Boot brings non-boot cores up (using ported from Linux's platsmp-apmu code functions). Then U-Boot switches all cores to HYP mode.

Who did the port? Is it upstream?

Quoted 7 lines

AFAIR Iurii Konovalenko did this port, he is also an author of xen/arch/arm/platforms/rcar2.c.
I don't think U-Boot changes are upsteamed. But anybody who wants to run Xen on Lager board is able (I think) to apply
published patches [2] to U-Boot and build it.
The same way anybody who will want to run Xen on Stout board will be able to apply U-Boot patches I will attach to the future Wiki page for Stout board.

I am a bit concerned that patch for lager has never been upstreamed. Is it at least part of the Renesas BSP?

What's the plan for Stout support?

Quoted 34 lines
Quoted 10 lines
Quoted 6 lines

While jump into Xen on a boot core, all non-boot cores are left in U-Boot to wait to be "woken up by Xen" (actually rcar2_smp_init() is used for).
Platform R-Car2 code in Xen doesn't power on cores, it just "brings them to Xen".

What does the address 0xe63c0000 corresponds too? From the DT it seems it is part of the ICRAM. But it is not clear why you write in there.

Yes, it is a part of the ICRAM.

Unfortunately, I am not an expert in such code to definitively say how it is supposed to work.
But it seems that 0xE63C0FFC is an address which is being polled by non-boot core in U-Boot. It was set to zero value beforehand. So, writing an actual value to this address, Xen triggers an action for bringing non-boot core up to Xen.

Waiting loop in U-Boot:

asm(".arm \n"
".align 2 \n"
".global smp_waitloop \n"
"smp_waitloop: \n"
"1: wfe \n"
"ldr r0, =0xE63C0FFC \n"
"ldr r0, [r0] \n"
"teq r0, #0x0 \n"
"beq 1b \n"
"b _do_nonsec_entry \n"
".type smp_waitloop, %function \n"
".size smp_waitloop, .-smp_waitloop \n");

Quoted 7 lines

Trigger code in Xen:

writel(__pa(init_secondary), 0xE63C0FFC);

Quoted 2 lines

Could you point to any relevant documentation?

I am afraid, I can't point to documentation.

While the code was added for Lager and you just piggy-back on it,
if you already hack U-boot to bring-up CPUs in hyp mode, then you better add PSCI support.

To be honest, the lager support was likely accepted based on the code would make the way to Upstream. It is now been 3 years without any change. If there are no plan to address that, then I will send a patch to drop the support for Lager in Xen.

Cheers,

Signature · 6 lines
Julien Gral

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

Re: [PATCH v1 4/4] xen/arm: Reuse R-Car Gen2 platform code for Stout board

Quoted 1 line · Julien Grall

Hi Oleksandr,

Hi Julien.

Quoted 28 lines · Oleksandr Tyshchenko
Quoted 19 lines
Quoted 6 lines · Julien Grall
Quoted 4 lines · Oleksandr Tyshchenko
Quoted 1 line · Julien Grall
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Oleksandr Tyshchenko

I am quite confused here. If a CPU will be in hypervisor mode for Xen, how
come the same CPU will boot in monitor mode for Linux? Surely there should
be no difference in term of boot here. Are you using different firmware here?

Quoted 6 lines

Yes, in order to run modified U-Boot is used. You can see here what exactly was modified.
This instruction [1] contains link to patches [2] (see "Apply additional patches" step)
which should be applied to bare U-Boot.

Quoted 3 lines

I don't think it is reasonable to request a specific U-boot just for Xen. What if the user decide to run Linux on baremetal? Will he have to switch back and forth between firmware?

Unfortunately, yes. At least for now.

Quoted 27 lines
Quoted 17 lines

[1]
https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/Lager
[2]
https://lists.xenproject.org/archives/html/xen-devel/2015-01/msg02475.html

Quoted 9 lines
Quoted 5 lines

U-Boot brings non-boot cores up (using ported from Linux's platsmp-apmu code functions). Then U-Boot switches all cores to HYP mode.

Who did the port? Is it upstream?

Quoted 8 lines

AFAIR Iurii Konovalenko did this port, he is also an author of xen/arch/arm/platforms/rcar2.c.
I don't think U-Boot changes are upsteamed. But anybody who wants to run Xen on Lager board is able (I think) to apply
published patches [2] to U-Boot and build it.
The same way anybody who will want to run Xen on Stout board will be able to apply U-Boot patches I will attach to the future Wiki page for Stout board.

Quoted 2 lines

I am a bit concerned that patch for lager has never been upstreamed. Is it at least part of the Renesas BSP?

U-Boot patches for Lager board for bringing not-boot cores up and switching into HYP mode have never been up-streamed. No, Renesas BSP doesn't contain it either.

Quoted 51 lines

What's the plan for Stout support?

Quoted 37 lines
Quoted 9 lines
Quoted 6 lines

While jump into Xen on a boot core, all non-boot cores are left in U-Boot to wait to be "woken up by Xen" (actually rcar2_smp_init() is used for).
Platform R-Car2 code in Xen doesn't power on cores, it just "brings them to Xen".

Quoted 3 lines

What does the address 0xe63c0000 corresponds too? From the DT it seems it is
part of the ICRAM. But it is not clear why you write in there.

Yes, it is a part of the ICRAM.

Unfortunately, I am not an expert in such code to definitively say how it is supposed to work.
But it seems that 0xE63C0FFC is an address which is being polled by non-boot core in U-Boot. It was set to zero value beforehand. So, writing an actual value to this address, Xen triggers an action for bringing non-boot core up to Xen.

Waiting loop in U-Boot:

asm(".arm \n"
".align 2 \n"
".global smp_waitloop \n"
"smp_waitloop: \n"
"1: wfe \n"
"ldr r0, =0xE63C0FFC \n"
"ldr r0, [r0] \n"
"teq r0, #0x0 \n"
"beq 1b \n"
"b _do_nonsec_entry \n"
".type smp_waitloop, %function \n"
".size smp_waitloop, .-smp_waitloop \n");

Quoted 8 lines

Trigger code in Xen:

writel(__pa(init_secondary), 0xE63C0FFC);

Quoted 2 lines

Could you point to any relevant documentation?

I am afraid, I can't point to documentation.

Quoted 8 lines

While the code was added for Lager and you just piggy-back on it, if you already hack U-boot to bring-up CPUs in hyp mode, then you better add PSCI support.

To be honest, the lager support was likely accepted based on the code would make the way to Upstream. It is now been 3 years without any change. If there are no plan to address that, then I will send a patch to drop the support for Lager in Xen.

Definitely we would like to address that. I don't now exactly what direction we will stick to,
either adding PSCI support for Gen2 boards in U-Boot (which will cover Stout board) or
using some firmware in SW for providing PSCI services (ARM TF for ARM V7 or even OP-TEE), etc

I think, I will come up with something more concrete after some time... For this period current patch series is postponed.

Quoted 5 lines

Cheers,

--
Julien Gral

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#26 lore raw
In reply to Oleksandr Tyshchenko
Quoted 1 line · Oleksandr Tyshchenko

Hi, all.

Hi,

Can you CC relevant people on the cover letter? It would save me time to dig into my e-mail :).

Quoted 11 lines

The purpose of this patch series is to add required support to be able to run Xen on Renesas Stout board [1] which uses SCIFA compatible UART as a console interface.

Actually Xen already has support for SCIF compatible UARTs which are used on Renesas Lager (R-Car Gen2), Salvator-X, H3ULCB/M3ULCB (R-Car Gen3) and other development boards.
So this patch series extends existing support to be able to handle both interfaces.

Tested on Stout (ARM32) and H3ULCB (ARM64) boards using current master. Have a plan to update Xen Wiki regarding this board.

Quoted 7 lines

You can find current patch series here:
repo: https://github.com/otyshchenko1/xen.git branch: stout_xen_4.12_unstable

[1] https://elinux.org/R-Car/Boards/Stout

Oleksandr Tyshchenko (4):
xen/arm: drivers: scif: Remove unused #define-s

I have committed this patch. The rest requires a respin.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#27 lore raw
Quoted 6 lines · Julien Grall
Quoted 2 lines · Oleksandr Tyshchenko

Hi, all.

Hi,

Hi, Julien

Quoted 3 lines

Can you CC relevant people on the cover letter? It would save me time to dig into my e-mail :).

Sure.

Quoted 20 lines
Quoted 20 lines

The purpose of this patch series is to add required support to be able to run Xen on
Renesas Stout board [1] which uses SCIFA compatible UART as a console interface.

Actually Xen already has support for SCIF compatible UARTs which are used on Renesas Lager (R-Car Gen2),
Salvator-X, H3ULCB/M3ULCB (R-Car Gen3) and other development boards. So this patch series extends existing support to be able to handle both interfaces.

Tested on Stout (ARM32) and H3ULCB (ARM64) boards using current master. Have a plan to update Xen Wiki regarding this board.

You can find current patch series here:
repo: https://github.com/otyshchenko1/xen.git branch:
stout_xen_4.12_unstable

Quoted 7 lines
Quoted 4 lines

[1] https://elinux.org/R-Car/Boards/Stout

Oleksandr Tyshchenko (4):
xen/arm: drivers: scif: Remove unused #define-s

I have committed this patch. The rest requires a respin.

Thank you.

Quoted 5 lines

Cheers,

--
Julien Grall

Signature · 8 lines
Regards,

Oleksandr Tyshchenko

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