Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-25 Thread Julien Grall

On 22/02/2019 17:34, Oleksandr wrote:


Hi, Julien


Hi Oleksandr,



Your solution below require to overwrite EARLY_PRINTK_INC and not very easy 
to extend of other version (e.g scifb). As I suggested earlier, we can 
introduce an option the same way REG_SHIFT exist for 8250. The definition of 
CONFIG_EARLY_PRINTK is:


CONFIG_EARLY_PRINTK=,,

 would be the version. Nothing for SCIF and A for SCFIA.

Then in Rules.mk, you would have something like:

ifneq ($(word 3,$(EARLY_PRINTK_CFG)),)
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_$(word 3, $(EARLY_PRINTK_CFG)
else
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_NONE
endif

debug-scif.inc would then contain:

#ifdef CONFIG_EARLY_PRINTK_VERSION_A
#define foo
#define bar
#elifdef CONFIG_EARLY_PRINTK_VERSION_NONE
#define foo
#define bar
#endif

The CONFIG_EARLY_PRINTK_VERSION_NONE is here to help catching new addition. 
If someone if using a different version, it would not compile.
Also, the code in Rules.mk is generic enough to extend for other version (e.g 
scifb).


Does it make sense?


Absolutely. Thank you



Idea works as expected.


Just a quick question.

Shall I do this by a single patch or this should be spitted in two patches: 
"reworking current code" followed by "adding SCIFA"?


Separate patch if possible. Thank you!

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-22 Thread Oleksandr


Hi, Julien


Your solution below require to overwrite EARLY_PRINTK_INC and not 
very easy to extend of other version (e.g scifb). As I suggested 
earlier, we can introduce an option the same way REG_SHIFT exist for 
8250. The definition of CONFIG_EARLY_PRINTK is:


CONFIG_EARLY_PRINTK=,,

 would be the version. Nothing for SCIF and A for SCFIA.

Then in Rules.mk, you would have something like:

ifneq ($(word 3,$(EARLY_PRINTK_CFG)),)
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_$(word 3, $(EARLY_PRINTK_CFG)
else
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_NONE
endif

debug-scif.inc would then contain:

#ifdef CONFIG_EARLY_PRINTK_VERSION_A
#define foo
#define bar
#elifdef CONFIG_EARLY_PRINTK_VERSION_NONE
#define foo
#define bar
#endif

The CONFIG_EARLY_PRINTK_VERSION_NONE is here to help catching new 
addition. If someone if using a different version, it would not compile.
Also, the code in Rules.mk is generic enough to extend for other 
version (e.g scifb).


Does it make sense?


Absolutely. Thank you



Idea works as expected.


Just a quick question.

Shall I do this by a single patch or this should be spitted in two 
patches: "reworking current code" followed by "adding SCIFA"?








Cheers,


--
Regards,

Oleksandr Tyshchenko


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-21 Thread Oleksandr


On 21.02.19 20:43, Julien Grall wrote:

Hi Oleksandr,


Hi Julien




On 2/21/19 6:22 PM, Oleksandr wrote:
=> Actually, the main difference for the "early printk" support is in

two reg offsets:

+#define SCIFA_SCASSR   0x14    /* Serial status register */
+#define SCIFA_SCAFTDR  0x20    /* Transmit FIFO data register */

+#define SCIF_SCFSR 0x10    /* Serial status register */
+#define SCIF_SCFTDR    0x0c    /* Transmit FIFO data 
register */



I am not mistaken, we will have to introduce two options to cover 
this case, as the offsets are not correlated with each other, no?


You don't need two options. For instance, you can only introduce an 
option SCIF_VERSION that would be 0 for SCIF and 61 (ascii 'a') for 
SCIFA.


Then in the code, you can use SCIF_VERSION to decides which sets of 
macros you are using.


I think I understand the idea. Will try.



Is it something you would like to see?


Your solution below require to overwrite EARLY_PRINTK_INC and not very 
easy to extend of other version (e.g scifb). As I suggested earlier, 
we can introduce an option the same way REG_SHIFT exist for 8250. The 
definition of CONFIG_EARLY_PRINTK is:


CONFIG_EARLY_PRINTK=,,

 would be the version. Nothing for SCIF and A for SCFIA.

Then in Rules.mk, you would have something like:

ifneq ($(word 3,$(EARLY_PRINTK_CFG)),)
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_$(word 3, $(EARLY_PRINTK_CFG)
else
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_NONE
endif

debug-scif.inc would then contain:

#ifdef CONFIG_EARLY_PRINTK_VERSION_A
#define foo
#define bar
#elifdef CONFIG_EARLY_PRINTK_VERSION_NONE
#define foo
#define bar
#endif

The CONFIG_EARLY_PRINTK_VERSION_NONE is here to help catching new 
addition. If someone if using a different version, it would not compile.
Also, the code in Rules.mk is generic enough to extend for other 
version (e.g scifb).


Does it make sense?


Absolutely. Thank you




Cheers,


--
Regards,

Oleksandr Tyshchenko


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-21 Thread Julien Grall

Hi Oleksandr,

On 2/21/19 6:22 PM, Oleksandr wrote:
=> Actually, the main difference for the "early printk" support is in

two reg offsets:

+#define SCIFA_SCASSR   0x14    /* Serial status register */
+#define SCIFA_SCAFTDR  0x20    /* Transmit FIFO data register */

+#define SCIF_SCFSR 0x10    /* Serial status register */
+#define SCIF_SCFTDR    0x0c    /* Transmit FIFO data 
register */



I am not mistaken, we will have to introduce two options to cover 
this case, as the offsets are not correlated with each other, no?


You don't need two options. For instance, you can only introduce an 
option SCIF_VERSION that would be 0 for SCIF and 61 (ascii 'a') for 
SCIFA.


Then in the code, you can use SCIF_VERSION to decides which sets of 
macros you are using.


I think I understand the idea. Will try.



Is it something you would like to see?


Your solution below require to overwrite EARLY_PRINTK_INC and not very 
easy to extend of other version (e.g scifb). As I suggested earlier, we 
can introduce an option the same way REG_SHIFT exist for 8250. The 
definition of CONFIG_EARLY_PRINTK is:


CONFIG_EARLY_PRINTK=,,

 would be the version. Nothing for SCIF and A for SCFIA.

Then in Rules.mk, you would have something like:

ifneq ($(word 3,$(EARLY_PRINTK_CFG)),)
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_$(word 3, $(EARLY_PRINTK_CFG)
else
CFLAGS-y += -DCONFIG_EARLY_PRINTK_VERSION_NONE
endif

debug-scif.inc would then contain:

#ifdef CONFIG_EARLY_PRINTK_VERSION_A
#define foo
#define bar
#elifdef CONFIG_EARLY_PRINTK_VERSION_NONE
#define foo
#define bar
#endif

The CONFIG_EARLY_PRINTK_VERSION_NONE is here to help catching new 
addition. If someone if using a different version, it would not compile.
Also, the code in Rules.mk is generic enough to extend for other version 
(e.g scifb).


Does it make sense?

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-21 Thread Oleksandr

Hi Julien

Actually, the main difference for the "early printk" support is in 
two reg offsets:


+#define SCIFA_SCASSR   0x14    /* Serial status register */
+#define SCIFA_SCAFTDR  0x20    /* Transmit FIFO data register */

+#define SCIF_SCFSR 0x10    /* Serial status register */
+#define SCIF_SCFTDR    0x0c    /* Transmit FIFO data 
register */



I am not mistaken, we will have to introduce two options to cover 
this case, as the offsets are not correlated with each other, no?


You don't need two options. For instance, you can only introduce an 
option SCIF_VERSION that would be 0 for SCIF and 61 (ascii 'a') for 
SCIFA.


Then in the code, you can use SCIF_VERSION to decides which sets of 
macros you are using.


I think I understand the idea. Will try.



Is it something you would like to see?

[Sorry for formatting]


---
 xen/arch/arm/Rules.mk |  7 +++
 xen/arch/arm/arm32/debug-scif.inc | 22 +++---
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
index f264592..b29bd60 100644
--- a/xen/arch/arm/Rules.mk
+++ b/xen/arch/arm/Rules.mk
@@ -69,6 +69,12 @@ EARLY_PRINTK_BAUD := $(word 3,$(EARLY_PRINTK_CFG))
 endif
 endif

+# For the debug-scif.inc to recognize which UART offsets to apply
+ifeq ($(EARLY_PRINTK_INC),scifa)
+EARLY_PRINTK_SCIFA_OPTION := y
+EARLY_PRINTK_INC := scif
+endif
+
 ifneq ($(EARLY_PRINTK_INC),)
 EARLY_PRINTK := y
 endif
@@ -79,6 +85,7 @@ CFLAGS-$(EARLY_PRINTK) += 
-DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"

 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
 CFLAGS-$(EARLY_PRINTK) += 
-DEARLY_UART_BASE_ADDRESS=$(EARLY_UART_BASE_ADDRESS)

 CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_REG_SHIFT=$(EARLY_UART_REG_SHIFT)
+CFLAGS-$(EARLY_PRINTK_SCIFA_OPTION) += -DEARLY_PRINTK_SCIFA_OPTION

 else # !CONFIG_DEBUG

diff --git a/xen/arch/arm/arm32/debug-scif.inc 
b/xen/arch/arm/arm32/debug-scif.inc

index 143f05d..49df616 100644
--- a/xen/arch/arm/arm32/debug-scif.inc
+++ b/xen/arch/arm/arm32/debug-scif.inc
@@ -1,7 +1,7 @@
 /*
  * xen/arch/arm/arm32/debug-scif.inc
  *
- * SCIF specific debug code
+ * SCIF(A) specific debug code
  *
  * Oleksandr Tyshchenko 
  * Copyright (C) 2014, Globallogic.
@@ -19,28 +19,36 @@

 #include 

+#ifdef EARLY_PRINTK_SCIFA_OPTION
+#define STATUS_REG    SCIFA_SCASSR
+#define TX_FIFO_REG   SCIFA_SCAFTDR
+#else
+#define STATUS_REG    SCIF_SCFSR
+#define TX_FIFO_REG   SCIF_SCFTDR
+#endif
+
 /*
- * SCIF UART wait UART to be ready to transmit
+ * SCIF(A) 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, #SCIF_SCFSR]   /* <- SCFSR (status register) */
+    ldrh   \rc, [\rb, #STATUS_REG]   /* Read status register */
 tst    \rc, #SCFSR_TDFE  /* Check TDFE bit */
 beq    1b    /* Wait for the UART to be 
ready */

 .endm

 /*
- * SCIF UART transmit character
+ * SCIF(A) 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, #SCIF_SCFTDR]  /* -> SCFTDR 
(data register) */
-    ldrh   \rt, [\rb, #SCIF_SCFSR]   /* <- SCFSR 
(status register) */
+    strb   \rt, [\rb, #TX_FIFO_REG]  /* Write data 
register */
+    ldrh   \rt, [\rb, #STATUS_REG]   /* Read status 
register */
 and    \rt, \rt, #(~(SCFSR_TEND | SCFSR_TDFE))   /* Clear TEND 
and TDFE bits */
-    strh   \rt, [\rb, #SCIF_SCFSR]   /* -> SCFSR 
(status register) */
+    strh   \rt, [\rb, #STATUS_REG]   /* Write 
status register */

 .endm

 /*
--
2.7.4






--
Regards,

Oleksandr Tyshchenko


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-20 Thread Oleksandr


On 19.02.19 12:09, Julien Grall wrote:

Hi Oleksandr,


Hi Julien




Actually, the main difference for the "early printk" support is in 
two reg offsets:


+#define SCIFA_SCASSR   0x14    /* Serial status register */
+#define SCIFA_SCAFTDR  0x20    /* Transmit FIFO data register */

+#define SCIF_SCFSR 0x10    /* Serial status register */
+#define SCIF_SCFTDR    0x0c    /* Transmit FIFO data 
register */



I am not mistaken, we will have to introduce two options to cover 
this case, as the offsets are not correlated with each other, no?


You don't need two options. For instance, you can only introduce an 
option SCIF_VERSION that would be 0 for SCIF and 61 (ascii 'a') for 
SCIFA.


Then in the code, you can use SCIF_VERSION to decides which sets of 
macros you are using.


I think I understand the idea. Will try.


--
Regards,

Oleksandr Tyshchenko


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-19 Thread Julien Grall

Hi Oleksandr,

On 2/18/19 8:45 PM, Oleksandr wrote:


On 18.02.19 22:41, Oleksandr wrote:


On 18.02.19 16:05, Julien Grall wrote:

Hi,



Hi




On 01/02/2019 12:37, Oleksandr Tyshchenko wrote:

From: Oleksandr Tyshchenko 

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.


Can we try to merge the two then? One solution is to provide another 
options similar to how we deal with REG_SHIFT on the 8250.



Actually, the main difference for the "early printk" support is in two 
reg offsets:


+#define SCIFA_SCASSR   0x14    /* Serial status register */
+#define SCIFA_SCAFTDR  0x20    /* Transmit FIFO data register */

+#define SCIF_SCFSR 0x10    /* Serial status register */
+#define SCIF_SCFTDR    0x0c    /* Transmit FIFO data register */


I am not mistaken, we will have to introduce two options to cover this 
case, as the offsets are not correlated with each other, no?


You don't need two options. For instance, you can only introduce an 
option SCIF_VERSION that would be 0 for SCIF and 61 (ascii 'a') for SCIFA.


Then in the code, you can use SCIF_VERSION to decides which sets of 
macros you are using.


Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-18 Thread Oleksandr


On 18.02.19 22:41, Oleksandr wrote:


On 18.02.19 16:05, Julien Grall wrote:

Hi,



Hi




On 01/02/2019 12:37, Oleksandr Tyshchenko wrote:

From: Oleksandr Tyshchenko 

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.


Can we try to merge the two then? One solution is to provide another 
options similar to how we deal with REG_SHIFT on the 8250.



Actually, the main difference for the "early printk" support is in two 
reg offsets:


+#define SCIFA_SCASSR   0x14    /* Serial status register */
+#define SCIFA_SCAFTDR  0x20    /* Transmit FIFO data register */

+#define SCIF_SCFSR 0x10    /* Serial status register */
+#define SCIF_SCFTDR    0x0c    /* Transmit FIFO data register */


I am not mistaken, we will have to introduce two options to cover this 
case, as the offsets are not correlated with each other, no?


Sorry, it should read as:

*If* I am not mistaken ...







Cheers,


--
Regards,

Oleksandr Tyshchenko


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-18 Thread Oleksandr


On 18.02.19 16:05, Julien Grall wrote:

Hi,



Hi




On 01/02/2019 12:37, Oleksandr Tyshchenko wrote:

From: Oleksandr Tyshchenko 

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.


Can we try to merge the two then? One solution is to provide another 
options similar to how we deal with REG_SHIFT on the 8250.



Actually, the main difference for the "early printk" support is in two 
reg offsets:


+#define SCIFA_SCASSR   0x14    /* Serial status register */
+#define SCIFA_SCAFTDR  0x20    /* Transmit FIFO data register */

+#define SCIF_SCFSR 0x10    /* Serial status register */
+#define SCIF_SCFTDR    0x0c    /* Transmit FIFO data register */


I am not mistaken, we will have to introduce two options to cover this 
case, as the offsets are not correlated with each other, no?





Cheers,


--
Regards,

Oleksandr Tyshchenko


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-18 Thread Julien Grall

Hi,

On 01/02/2019 12:37, Oleksandr Tyshchenko wrote:

From: Oleksandr Tyshchenko 

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.


Can we try to merge the two then? One solution is to provide another options 
similar to how we deal with REG_SHIFT on the 8250.


Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH V2 3/3] xen/arm: Add SCIFA UART support for early printk

2019-02-01 Thread Oleksandr Tyshchenko
From: Oleksandr Tyshchenko 

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.

Signed-off-by: Oleksandr Tyshchenko 

---
Changes in v2:
- Move clarification regarding Lager board to separate patch
- Drop changes in early-printk.txt and Rules.mk, earlyprink
  usage for Stout board should be documented on a Xen wiki
---
 xen/arch/arm/arm32/debug-scifa.inc | 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 xen/arch/arm/arm32/debug-scifa.inc

diff --git a/xen/arch/arm/arm32/debug-scifa.inc 
b/xen/arch/arm/arm32/debug-scifa.inc
new file mode 100644
index 000..b5e60db
--- /dev/null
+++ b/xen/arch/arm/arm32/debug-scifa.inc
@@ -0,0 +1,51 @@
+/*
+ * xen/arch/arm/arm32/debug-scifa.inc
+ *
+ * SCIFA specific debug code
+ *
+ * Oleksandr Tyshchenko 
+ * 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 
+
+/*
+ * 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 */
+beq1b  /* 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) */
+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:
+ */
-- 
2.7.4


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel