[Xen-devel] [PATCH] xen/arm: Black list everything with a PPI

2019-05-03 Thread Amit Singh Tomar
XEN should not forward PPIs to Dom0 as it only support SPIs.
One of solution to this problem is to skip any device that
uses PPI source completely while building domain itself.

This patch goes through all the interrupt sources of device and skip it
if one of interrupt source is PPI. It fixes XEN boot on i.MX8MQ by
skipping PMU node.

Suggested-by:  Julien Grall 
Signed-off-by: Amit Singh Tomar 
---
* This replaces following patch.
  https://patchwork.kernel.org/patch/10899881/
---
 xen/arch/arm/domain_build.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d983677..0ae54db 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1334,6 +1334,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 DT_MATCH_COMPATIBLE("arm,cortex-a15-pmu"),
 DT_MATCH_COMPATIBLE("arm,cortex-a53-edac"),
 DT_MATCH_COMPATIBLE("arm,armv8-pmuv3"),
+DT_MATCH_COMPATIBLE("arm,cortex-a53-pmu"),
 DT_MATCH_PATH("/cpus"),
 DT_MATCH_TYPE("memory"),
 /* The memory mapped timer is not supported by Xen. */
@@ -1353,7 +1354,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 { /* sentinel */ },
 };
 struct dt_device_node *child;
-int res;
+int res, i, nirq, irq_id;
 const char *name;
 const char *path;
 
@@ -1399,6 +1400,20 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 return 0;
 }
 
+/* Skip the node, using PPI source */
+nirq = dt_number_of_irq(node);
+
+for ( i = 0 ; i < nirq ; i++ )
+{
+irq_id = platform_get_irq(node, i);
+
+if ( irq_id >= 16 && irq_id < 32 )
+{
+dt_dprintk(" Skip node with (PPI source)\n");
+return 0;
+}
+}
+
 /*
  * Xen is using some path for its own purpose. Warn if a node
  * already exists with the same path.
-- 
2.7.4


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

[Xen-devel] [PATCH] xen/arm: Black list everything with a PPI

2019-05-03 Thread Amit Singh Tomar
XEN should not forward PPIs to Dom0 as it only support SPIs.
One of solution to this problem is to skip any device that
uses PPI source completely while building domain itself.

This patch goes through all the interrupt sources of device and skip it
if one of interrupt source is PPI. It fixes XEN boot on i.MX8MQ by
skipping PMU node.

Suggested-by:  Julien Grall 
Signed-off-by: Amit Singh Tomar 
---
* This replaces following patch.
  https://patchwork.kernel.org/patch/10899881/
---
 xen/arch/arm/domain_build.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d983677..8f54472 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1353,7 +1353,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 { /* sentinel */ },
 };
 struct dt_device_node *child;
-int res;
+int res, i, nirq, irq_id;
 const char *name;
 const char *path;
 
@@ -1399,6 +1399,20 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 return 0;
 }
 
+/* Skip the node, using PPI source */
+nirq = dt_number_of_irq(node);
+
+for ( i = 0 ; i < nirq ; i++ )
+{
+irq_id = platform_get_irq(node, i);
+
+if ( irq_id >= 16 && irq_id < 32 )
+{
+dt_dprintk(" Skip node with (PPI source)\n");
+return 0;
+}
+}
+
 /*
  * Xen is using some path for its own purpose. Warn if a node
  * already exists with the same path.
-- 
2.7.4


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

[Xen-devel] [PATCH v2] xen/arm: Black list everything with a PPI

2019-06-02 Thread Amit Singh Tomar
XEN should not forward PPIs to Dom0 as it only support SPIs.
One of solution to this problem is to skip any device that
uses PPI source completely while building domain itself.

This patch goes through all the interrupt sources of device and skip it
if one of interrupt source is PPI. It fixes XEN boot on i.MX8MQ by
skipping PMU node.

Suggested-by:  Julien Grall 
Signed-off-by: Amit Singh Tomar 
---
Changes since v1:
* Added comment for PPIs range.
---
 xen/arch/arm/domain_build.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d983677..5035758 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1353,7 +1353,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 { /* sentinel */ },
 };
 struct dt_device_node *child;
-int res;
+int res, i, nirq, irq_id;
 const char *name;
 const char *path;
 
@@ -1399,6 +1399,21 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 return 0;
 }
 
+/* Skip the node, using PPI source */
+nirq = dt_number_of_irq(node);
+
+for ( i = 0 ; i < nirq ; i++ )
+{
+irq_id = platform_get_irq(node, i);
+
+/* PPIs ranges from ID 16 to 31 */
+if ( irq_id >= 16 && irq_id < 32 )
+{
+dt_dprintk(" Skip node with (PPI source)\n");
+return 0;
+}
+}
+
 /*
  * Xen is using some path for its own purpose. Warn if a node
  * already exists with the same path.
-- 
2.7.4


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

[Xen-devel] [RFC PATCH 0/2] XEN booting on i.MX8M platform

2019-06-07 Thread Amit Singh Tomar
This series tries to enable XEN booting on i.MX 8MQuad Applications 
Processors[1].

Patch-set includes driver for UART controller found on i.MX8MQ SoC and debug 
code
for earlyprintk support.

Mainline dts binding that are used for platform discover has GPC as root 
interrupt parent 
is not yet supported in XEN, therefore following changes is needed to boot XEN 
on this platform.

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 6d635ba..7eac1786 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -13,7 +13,7 @@
 #include "imx8mq-pinfunc.h"
 
 / {
-   interrupt-parent = <&gpc>;
+   interrupt-parent = <&gic>;
 
#address-cells = <2>;
#size-cells = <2>;

It has been tested on nitrogen8m board[2] by booting dom0 with RAMFS.

[1]:https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/i.mx-evaluation-and-development-boards/evaluation-kit-for-the-i.mx-8m-applications-processor:MCIMX8M-EVK
[2]:https://boundarydevices.com/product/nitrogen8m/

Amit Singh Tomar (2):
  xen/arm: Add i.MX8MQ SoCs earlyprintk support
  xen/arm: Add UART driver for i.MX8MQ SoC

 xen/arch/arm/arm64/debug-imx8mq.inc |  54 +++
 xen/drivers/char/Kconfig|   8 +
 xen/drivers/char/Makefile   |   1 +
 xen/drivers/char/imx8mq-uart.c  | 306 
 4 files changed, 369 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-imx8mq.inc
 create mode 100644 xen/drivers/char/imx8mq-uart.c

-- 
2.7.4


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

[Xen-devel] [RFC PATCH 1/2] xen/arm: Add i.MX8MQ SoCs earlyprintk support

2019-06-07 Thread Amit Singh Tomar
This patch adds earlyprintk support for i.MX8MQ SoC based
boards.

As with most of other debug code for other platforms, uart is
initialized by bootloaders(for instance u-boot[1]).

[1]:https://github.com/u-boot/u-boot/blob/master/drivers/serial/serial_mxc.c#L141

Signed-off-by: Amit Singh Tomar 
---
 xen/arch/arm/arm64/debug-imx8mq.inc | 54 +
 1 file changed, 54 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-imx8mq.inc

diff --git a/xen/arch/arm/arm64/debug-imx8mq.inc 
b/xen/arch/arm/arm64/debug-imx8mq.inc
new file mode 100644
index 000..ec331dc
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-imx8mq.inc
@@ -0,0 +1,54 @@
+/*
+ * xen/arch/arm/arm64/debug-imx8mq.inc
+ *
+ * IMX8MQ specific debug code.
+ *
+ * Copyright (c) 2019, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define UTXD0x40
+#define UTS 0xb4
+#define UTS_TXEMPTY 3<<1
+
+.macro early_uart_init xb, c
+/* Uart has already been initialized by bootloader Firmware, for instance by 
TF-A */
+.endm
+
+/*
+ * IMX8MQ UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldrw\c, [\xb, #UTS]/* UART Test Register */
+tbzw\c, #UTS_TXEMPTY, 1b   /* Check TXEMPTY bit */
+.endm
+
+/*
+ * IMX8MQ UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+   str\wt, [\xb, #UTXD]
+.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

[Xen-devel] [RFC PATCH 2/2] xen/arm: Add UART driver for i.MX8MQ SoC

2019-06-07 Thread Amit Singh Tomar
This patch adds driver for UART controller found on i.MX8MQ SoC
and it has been tested on nitrogen8m board.

Controller register defination and some other references has drawn from Linux
kernel driver[1] v5.2.

[1]:https://github.com/torvalds/linux/blob/master/drivers/tty/serial/imx.c

Signed-off-by: Amit Singh Tomar 
---
 xen/drivers/char/Kconfig   |   8 ++
 xen/drivers/char/Makefile  |   1 +
 xen/drivers/char/imx8mq-uart.c | 306 +
 3 files changed, 315 insertions(+)
 create mode 100644 xen/drivers/char/imx8mq-uart.c

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index b572305..f822af5 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -12,6 +12,14 @@ config HAS_CADENCE_UART
  This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq
  based board, say Y.
 
+config HAS_IMX8MQ
+bool "i.MX8MQ UART "
+default y
+depends on ARM_64
+help
+  This selects the NXP i.MX UART. If you have a NXP i.MX8MQ
+  based board, say Y.
+
 config HAS_MVEBU
bool "Marvell MVEBU UART driver"
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 7c646d7..aa1bb29 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -1,6 +1,7 @@
 obj-y += console.o
 obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
+obj-$(CONFIG_HAS_IMX8MQ) += imx8mq-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
 obj-$(CONFIG_HAS_MESON) += meson-uart.o
diff --git a/xen/drivers/char/imx8mq-uart.c b/xen/drivers/char/imx8mq-uart.c
new file mode 100644
index 000..90fd649
--- /dev/null
+++ b/xen/drivers/char/imx8mq-uart.c
@@ -0,0 +1,306 @@
+/*
+ * xen/drivers/char/imx8mq-uart.c
+ *
+ * Driver for i.MX8MQ UART.
+ *
+ * Copyright (c) 2019, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+#define URXD0x0  /* Receiver Register */
+#define UTXD0x40 /* Transmitter Register */
+#define UCR10x80 /* Control Register 1 */
+#define UCR20x84 /* Control Register 2 */
+#define UCR40x8c /* Control Register 4 */
+#define USR10x94 /* Status Register 1 */
+#define USR20x98 /* Status Register 2 */
+#define UBIR0xa4 /* BRM Incremental Register */
+#define UBMR0xa8 /* BRM Modulator Register */
+#define UTS 0xb4 /* UART Test Register */
+
+/* UART Control Register Bit Fields */
+#define  UCR1_ADEN  (1<<15) /* Auto dectect interrupt */
+#define  UCR1_TRDYEN(1<<13) /* Transmitter ready interrupt enable */
+#define  UCR1_IDEN  (1<<12) /* Idle condition interrupt */
+#define  UCR1_RRDYEN(1<<9)  /* Recv ready interrupt enable */
+#define  UCR1_TXMPTYEN  (1<<6)  /* Transimitter empty interrupt enable */
+#define  UCR1_RTSDEN(1<<5)  /* RTS delta interrupt enable */
+#define  UCR1_TDMAEN(1<<3)  /* Transmitter ready DMA enable */
+#define  UCR1_UARTEN(1<<0)  /* UART enabled */
+
+#define UCR2_TXEN   (1<<2)  /* Transmitter enabled */
+#define UCR2_RXEN   (1<<1)  /* Receiver enabled */
+#define UCR2_IRTS   (1<<14) /* Ignore RTS pin */
+#define UCR2_SRST   (1<<0)  /* SW reset */
+#define UCR2_WS (1<<5)  /* Word size */
+#define UCR4_TCEN   (1<<3)  /* Transmit complete interrupt enable */
+#define UCR4_DREN   (1<<0)  /* Recv data ready interrupt enable */
+
+#define UTS_TXEMPTY (1<<6)  /* TxFIFO empty */
+#define UTS_RXEMPTY (1<<5)  /* RxFIFO empty */
+#define UTS_TXFULL  (1<<4)  /* TxFIFO full */
+
+#define USR1_TRDY   (1<<13) /* Transmitter ready interrupt/dma flag */
+#define USR1_RRDY   (1<<9)  /* Receiver ready interrupt/dma flag */
+
+#define USR2_TXDC   (1<<3)  /* Transmitter complete */
+
+#define TXFIFO_SIZE 32
+
+#define setbits(addr, set)  writel((readl(addr) | (set)), (addr))
+#define clrbits(addr, clear)writel((readl(addr) & ~(clear)), (addr))
+
+static struct imx8mq_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} imx8mq_com;
+
+static void imx8m

[Xen-devel] [PATCH v1 1/2] xen/arm: Add Amlogic Meson SoCs earlyprintk support

2019-01-26 Thread Amit Singh Tomar
Signed-off-by: Amit Singh Tomar 
---
TODO:
* Capture XEN boot info on WIKI(just forgot my
  XEN Wiki credentials). 

Changes since RFC:

* Replaced LDRH with LDR, with this there
  is no scattered output on console now.
* Used tbnz instead of tst and b.ne.
* Used AML_ prefix against register names.
---
 docs/misc/arm/early-printk.txt |  1 +
 xen/arch/arm/arm64/debug-meson.inc | 51 ++
 2 files changed, 52 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc

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

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

2019-01-26 Thread Amit Singh Tomar
This patch adds driver for UART controller present on Amlogic Meson
SoCs and it has been tested on Nanopi K2 board based on S905 SoC.

Controller registers defination is taken from Linux 4.20.

Signed-off-by: Amit Singh Tomar 
---
Changes since RFC:

* Removed S905 reference as other Amlogic SoCs
  have this uart controller.
* Replaced meson_s905_read/write helper
  with clrsetbit and friends helper.
* Followed proper UART reset sequence.
* List all UART compatible strings same as Linux
  driver.
---
 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/meson-uart.c | 282 ++
 3 files changed, 291 insertions(+)
 create mode 100644 xen/drivers/char/meson-uart.c

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index b1f07f8..d4add7f 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -20,6 +20,14 @@ config HAS_MVEBU
  This selects the Marvell MVEBU UART. If you have a ARMADA 3700
  based board, say Y.
 
+config HAS_MESON
+bool "Amlogic MESON UART driver"
+default y
+depends on ARM_64
+help
+  This selects the Amlogic MESON UART. If you have a Amlogic based
+  board, say Y.
+
 config HAS_PL011
bool "ARM PL011 UART driver"
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index b68c330..7c646d7 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MESON) += meson-uart.o
 obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c
new file mode 100644
index 000..990ae95
--- /dev/null
+++ b/xen/drivers/char/meson-uart.c
@@ -0,0 +1,282 @@
+/*
+ * xen/drivers/char/meson-uart.c
+ *
+ * Driver for Amlogic MESON UART
+ *
+ * Copyright (c) 2019, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define AML_UART_WFIFO_REG  0x00
+#define AML_UART_RFIFO_REG  0x04
+#define AML_UART_CONTROL_REG0x08
+#define AML_UART_STATUS_REG 0x0c
+#define AML_UART_MISC_REG   0x10
+
+/* UART_CONTROL bits */
+#define AML_UART_TX_RST BIT(22)
+#define AML_UART_RX_RST BIT(23)
+#define AML_UART_CLEAR_ERR  BIT(24)
+#define AML_UART_RX_INT_EN  BIT(27)
+#define AML_UART_TX_INT_EN  BIT(28)
+
+/* UART_STATUS bits */
+#define AML_UART_RX_FIFO_EMPTY  BIT(20)
+#define AML_UART_TX_FIFO_FULL   BIT(21)
+#define AML_UART_TX_FIFO_EMPTY  BIT(22)
+#define AML_UART_TX_CNT_MASKGENMASK(14, 8)
+
+/* AML_UART_MISC bits */
+#define AML_UART_XMIT_IRQ(c)(((c) & 0xff) << 8)
+#define AML_UART_RECV_IRQ(c)((c) & 0xff)
+
+#define TX_FIFO_SIZE64
+
+#define setbits(addr, set)  writel((readl(addr) | (set)), (addr))
+#define clrbits(addr, clear)writel((readl(addr) & ~(clear)), 
(addr))
+#define clrsetbits(addr, clear, set)writel(((readl(addr) & ~(clear)) \
+| (set)), (addr))
+
+static struct meson_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} meson_com;
+
+static void meson_uart_interrupt(int irq, void *data,
+  struct cpu_user_regs *regs)
+{
+struct serial_port *port = data;
+struct meson_uart *uart = port->uart;
+uint32_t st = readl(uart->regs + AML_UART_STATUS_REG);
+
+if ( !(st & AML_UART_RX_FIFO_EMPTY) )
+{
+serial_rx_interrupt(port, regs);
+}
+
+if ( !(st & AML_UART_TX_FIFO_FULL) )
+{
+serial_tx_interrupt(port, regs);
+}
+}
+
+static void __init meson_uart_init_preirq(struct serial_port *port)
+{
+struct meson_uart *uart = port->uart;
+
+/* Reset UART */
+setbits(uart->regs + A

[Xen-devel] [PATCH v2 2/3] xen/arm: Add MESON UART driver for Amlogic Meson SoCs

2019-03-21 Thread Amit Singh Tomar
This patch adds driver for UART controller present on Amlogic Meson
SoCs and it has been tested on Nanopi K2 board based on S905 SoC.

Controller registers defination is taken from Linux 4.20.
https://github.com/torvalds/linux/blob/v4.20-rc1/drivers/tty/serial/meson_uart.c

Signed-off-by: Amit Singh Tomar 
---
Changes since v1:

* Removed clrsetbits macro.
* Fixed coding style issue.
* Updated MAINTAINERS file.

Changes since RFC:

* Removed S905 reference as other Amlogic SoCs
  have this uart controller.
* Replaced meson_s905_read/write helper
  with clrsetbit and friends helper.
* Followed proper UART reset sequence.
* List all UART compatible strings same as Linux
  driver.
---
 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/meson-uart.c | 276 ++
 3 files changed, 285 insertions(+)
 create mode 100644 xen/drivers/char/meson-uart.c

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index b1f07f8..b572305 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -20,6 +20,14 @@ config HAS_MVEBU
  This selects the Marvell MVEBU UART. If you have a ARMADA 3700
  based board, say Y.
 
+config HAS_MESON
+   bool "Amlogic MESON UART driver"
+   default y
+   depends on ARM_64
+   help
+ This selects the Amlogic MESON UART. If you have a Amlogic based
+ board, say Y.
+
 config HAS_PL011
bool "ARM PL011 UART driver"
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index b68c330..7c646d7 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MESON) += meson-uart.o
 obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c
new file mode 100644
index 000..c16c188
--- /dev/null
+++ b/xen/drivers/char/meson-uart.c
@@ -0,0 +1,276 @@
+/*
+ * xen/drivers/char/meson-uart.c
+ *
+ * Driver for Amlogic MESON UART
+ *
+ * Copyright (c) 2019, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define AML_UART_WFIFO_REG  0x00
+#define AML_UART_RFIFO_REG  0x04
+#define AML_UART_CONTROL_REG0x08
+#define AML_UART_STATUS_REG 0x0c
+#define AML_UART_MISC_REG   0x10
+
+/* UART_CONTROL bits */
+#define AML_UART_TX_RST BIT(22)
+#define AML_UART_RX_RST BIT(23)
+#define AML_UART_CLEAR_ERR  BIT(24)
+#define AML_UART_RX_INT_EN  BIT(27)
+#define AML_UART_TX_INT_EN  BIT(28)
+
+/* UART_STATUS bits */
+#define AML_UART_RX_FIFO_EMPTY  BIT(20)
+#define AML_UART_TX_FIFO_FULL   BIT(21)
+#define AML_UART_TX_FIFO_EMPTY  BIT(22)
+#define AML_UART_TX_CNT_MASKGENMASK(14, 8)
+
+/* AML_UART_MISC bits */
+#define AML_UART_XMIT_IRQ(c)(((c) & 0xff) << 8)
+#define AML_UART_RECV_IRQ(c)((c) & 0xff)
+
+#define TX_FIFO_SIZE64
+
+#define setbits(addr, set)  writel((readl(addr) | (set)), (addr))
+#define clrbits(addr, clear)writel((readl(addr) & ~(clear)), 
(addr))
+
+static struct meson_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} meson_com;
+
+static void meson_uart_interrupt(int irq, void *data,
+ struct cpu_user_regs *regs)
+{
+struct serial_port *port = data;
+struct meson_uart *uart = port->uart;
+uint32_t st = readl(uart->regs + AML_UART_STATUS_REG);
+
+if ( !(st & AML_UART_RX_FIFO_EMPTY) )
+serial_rx_interrupt(port, regs);
+
+if ( !(st & AML_UART_TX_FIFO_FULL) )
+serial_tx_interrupt(port, regs);
+}
+
+static void __init meson_uart_init_preirq(struct serial_port *port)
+{
+struct meson_uart *uart = port->uart;
+
+/*

[Xen-devel] [PATCH v2 3/3] MAINTAINERS: add ARM meson serial driver

2019-03-21 Thread Amit Singh Tomar
The meson-uart.c is an ARM specific UART driver for the Amlogic MESON
SoC family.

Signed-off-by: Amit Singh Tomar 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index ba7527c..aff7f81 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -182,6 +182,7 @@ F:  xen/arch/arm/
 F: xen/drivers/char/arm-uart.c
 F: xen/drivers/char/cadence-uart.c
 F: xen/drivers/char/exynos4210-uart.c
+F: xen/drivers/char/meson-uart.c
 F: xen/drivers/char/mvebu-uart.c
 F: xen/drivers/char/omap-uart.c
 F: xen/drivers/char/pl011.c
-- 
2.7.4


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

[Xen-devel] [PATCH v2 1/3] xen/arm: Add Amlogic Meson SoCs earlyprintk support

2019-03-21 Thread Amit Singh Tomar
Signed-off-by: Amit Singh Tomar 
---
TODO:
* Capture XEN boot info on WIKI.

Changes since v1:

* Fixed coding style issue.
* Undone changes in early-printk.txt.

Changes since RFC:

* Replaced LDRH with LDR, with this there
  is no scattered output on console now.
* Used tbnz instead of tst and b.ne.
* Used AML_ prefix against register names.
---
 xen/arch/arm/arm64/debug-meson.inc | 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc

diff --git a/xen/arch/arm/arm64/debug-meson.inc 
b/xen/arch/arm/arm64/debug-meson.inc
new file mode 100644
index 000..01b70f0
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-meson.inc
@@ -0,0 +1,51 @@
+/*
+ * xen/arch/arm/arm64/debug-meson.inc
+ *
+ * MESON specific debug code.
+ *
+ * Copyright (c) 2019, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define AML_UART_WFIFO_REG  0x00
+#define AML_UART_STATUS_REG 0x0c
+
+#define AML_UART_TX_FIFO_FULL   21
+
+/*
+ * MESON UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldr w\c, [\xb, #AML_UART_STATUS_REG]/* status register */
+tbnzw\c, #AML_UART_TX_FIFO_FULL, 1b /* Check TXFIFO FULL 
bit */
+.endm
+
+/*
+ * MESON UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+str\wt, [\xb, #AML_UART_WFIFO_REG]
+.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

[Xen-devel] [PATCH v3] xen/arm: Add Amlogic Meson SoCs earlyprintk support

2019-04-13 Thread Amit Singh Tomar
This patch adds earlyprintk support for Amlogic Meson SoC based
boards.

It relies on firmware[1] to initialize the UART.

Tested With:
 http://wiki.friendlyarm.com/wiki/index.php/NanoPi_K2

[1]: 
https://github.com/ARM-software/arm-trusted-firmware/blob/master/drivers/meson/console/aarch64/meson_console.S#L92

Signed-off-by: Amit Singh Tomar 
---
Changes since v2:

* Added the commit message that talks about
  uart initialization.

* Added dummy early_uart_init function.

Changes since v1:

* Fixed coding style issue.
* Undone changes in early-printk.txt.

Changes since RFC:

* Replaced LDRH with LDR, with this there
  is no scattered output on console now.
* Used tbnz instead of tst and b.ne.
* Used AML_ prefix against register names.
---
 xen/arch/arm/arm64/debug-meson.inc | 55 ++
 1 file changed, 55 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc

diff --git a/xen/arch/arm/arm64/debug-meson.inc 
b/xen/arch/arm/arm64/debug-meson.inc
new file mode 100644
index 000..e1a8fa8
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-meson.inc
@@ -0,0 +1,55 @@
+/*
+ * xen/arch/arm/arm64/debug-meson.inc
+ *
+ * MESON specific debug code.
+ *
+ * Copyright (c) 2019, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define AML_UART_WFIFO_REG  0x00
+#define AML_UART_STATUS_REG 0x0c
+
+#define AML_UART_TX_FIFO_FULL   21
+
+.macro early_uart_init xb, c
+/* Uart has already been initialized by Firmware, for instance by TF-A */
+.endm
+
+/*
+ * MESON UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldr w\c, [\xb, #AML_UART_STATUS_REG]/* status register */
+tbnzw\c, #AML_UART_TX_FIFO_FULL, 1b /* Check TXFIFO FULL 
bit */
+.endm
+
+/*
+ * MESON UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+str\wt, [\xb, #AML_UART_WFIFO_REG]
+.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

[Xen-devel] [PATCH] xen/arm: Blacklist PMU with "arm, cortex-a53-pmu"

2019-04-14 Thread Amit Singh Tomar
At the moment, we hide PMU's from domain 0 and XEN boot fails on platform[1]
where DTS contains "arm,cortex-a53-pmu" as compatible string for PMU node.

This patch simply adds "arm,cortex-a53-pmu" to list of blacklisted PMUs.

[1]: 
https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/freescale/imx8mq.dtsi#L124

Signed-off-by: Amit Singh Tomar 
---
 xen/arch/arm/domain_build.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d983677..b54592a 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1334,6 +1334,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 DT_MATCH_COMPATIBLE("arm,cortex-a15-pmu"),
 DT_MATCH_COMPATIBLE("arm,cortex-a53-edac"),
 DT_MATCH_COMPATIBLE("arm,armv8-pmuv3"),
+DT_MATCH_COMPATIBLE("arm,cortex-a53-pmu"),
 DT_MATCH_PATH("/cpus"),
 DT_MATCH_TYPE("memory"),
 /* The memory mapped timer is not supported by Xen. */
-- 
2.7.4


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

[Xen-devel] [PATCH v4] xen/arm: Add Amlogic Meson SoCs earlyprintk support

2019-04-14 Thread Amit Singh Tomar
This patch adds earlyprintk support for Amlogic Meson SoC based
boards.

ATF[1] and U-boot[2] already initialize the UART for us. So no need to do it 
again.

Tested With:
 http://wiki.friendlyarm.com/wiki/index.php/NanoPi_K2

[1]: 
https://github.com/ARM-software/arm-trusted-firmware/blob/master/drivers/meson/console/aarch64/meson_console.S#L92
[2]: 
https://github.com/u-boot/u-boot/blob/master/drivers/serial/serial_meson.c#L44

Signed-off-by: Amit Singh Tomar 
---
Changes since v3:

* Change the commit message to include firmware names.

Changes since v2:

* Added the commit message that talks about
  uart initialization.

* Added dummy early_uart_init function.

Changes since v1:

* Fixed coding style issue.
* Undone changes in early-printk.txt.

Changes since RFC:

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

---
 xen/arch/arm/arm64/debug-meson.inc | 55 ++
 1 file changed, 55 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc

diff --git a/xen/arch/arm/arm64/debug-meson.inc 
b/xen/arch/arm/arm64/debug-meson.inc
new file mode 100644
index 000..e1a8fa8
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-meson.inc
@@ -0,0 +1,55 @@
+/*
+ * xen/arch/arm/arm64/debug-meson.inc
+ *
+ * MESON specific debug code.
+ *
+ * Copyright (c) 2019, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define AML_UART_WFIFO_REG  0x00
+#define AML_UART_STATUS_REG 0x0c
+
+#define AML_UART_TX_FIFO_FULL   21
+
+.macro early_uart_init xb, c
+/* Uart has already been initialized by Firmware, for instance by TF-A */
+.endm
+
+/*
+ * MESON UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldr w\c, [\xb, #AML_UART_STATUS_REG]/* status register */
+tbnzw\c, #AML_UART_TX_FIFO_FULL, 1b /* Check TXFIFO FULL 
bit */
+.endm
+
+/*
+ * MESON UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+str\wt, [\xb, #AML_UART_WFIFO_REG]
+.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

[Xen-devel] [PATCH 0/2] Add support for Marvell Armada 3700 SoC

2018-04-03 Thread Amit Singh Tomar
This patch-set enables XEN booting[1] on ESPRESSObin board based
on Marvell Armada 3700 SoC.

I would like to Thanks Andre for helping on this.

[1]https://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/ESPRESSObin

Amit Singh Tomar (2):
  xen/arm: Add MVEBU UART driver for Marvell Armada 3700 SoC
  xen/arm: Add Marvell ARMADA 3700 early printk support

 docs/misc/arm/early-printk.txt |   1 +
 xen/arch/arm/Rules.mk  |   1 +
 xen/arch/arm/arm64/debug-mvebu.inc |  50 +++
 xen/drivers/char/Kconfig   |   8 +
 xen/drivers/char/Makefile  |   1 +
 xen/drivers/char/mvebu-uart.c  | 290 +
 6 files changed, 351 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-mvebu.inc
 create mode 100644 xen/drivers/char/mvebu-uart.c

-- 
1.9.1


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

[Xen-devel] [PATCH v2 1/2] xen/arm: Add MVEBU UART driver for Marvell Armada 3700 SoC

2018-04-03 Thread Amit Singh Tomar
This patch adds driver for UART controller found on Armada 3700 SoC.

There is no reference manuals available for 3700 SoC in public and it
is derived by looking at Linux driver[1].

[1]https://github.com/torvalds/linux/blob/master/drivers/tty/serial/mvebu-uart.c

Signed-off-by: Amit Singh Tomar 
---
Changes since v1:
* Addressed Wei Liu's comments
* Addressed Andre's comments.
Changes since RFC:
* Addressed Julien's comments.
---
 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/mvebu-uart.c | 290 ++
 3 files changed, 299 insertions(+)
 create mode 100644 xen/drivers/char/mvebu-uart.c

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index fb53dd8..6bf2730 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -12,6 +12,14 @@ config HAS_CADENCE_UART
  This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq
  based board, say Y.
 
+config HAS_MVEBU
+bool
+default y
+depends on ARM_64
+help
+  This selects the Marvell MVEBU UART. if you have an ARMADA 3700
+  based board, say Y.
+
 config HAS_PL011
bool
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 0d48b16..b68c330 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
 obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
new file mode 100644
index 000..b2059f3
--- /dev/null
+++ b/xen/drivers/char/mvebu-uart.c
@@ -0,0 +1,290 @@
+/*
+ * xen/drivers/char/mvebu3700-uart.c
+ *
+ * Driver for Marvell MVEBU UART.
+ *
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define UART_RX_REG 0x00
+
+#define UART_TX_REG 0x04
+
+#define UART_CTRL_REG   0x08
+#define CTRL_TXFIFO_RST BIT(15)
+#define CTRL_RXFIFO_RST BIT(14)
+#define CTRL_TX_RDY_INT BIT(5)
+#define CTRL_RX_RDY_INT BIT(4)
+#define CTRL_BRK_DET_INTBIT(3)
+#define CTRL_FRM_ERR_INTBIT(2)
+#define CTRL_PAR_ERR_INTBIT(1)
+#define CTRL_OVR_ERR_INTBIT(0)
+#define CTRL_RX_INT (CTRL_BRK_DET_INT | CTRL_FRM_ERR_INT | \
+ CTRL_PAR_ERR_INT | CTRL_OVR_ERR_INT)
+
+#define UART_STATUS_REG 0x0c
+#define STATUS_TXFIFO_EMP   BIT(13)
+#define STATUS_TX_RDY   BIT(5)
+#define STATUS_RX_RDY   BIT(4)
+#define STATUS_BRK_DET  BIT(3)
+#define STATUS_FRM_ERR  BIT(2)
+#define STATUS_PAR_ERR  BIT(1)
+#define STATUS_OVR_ERR  BIT(0)
+#define STATUS_BRK_ERR  (STATUS_BRK_DET | STATUS_FRM_ERR | \
+STATUS_PAR_ERR | STATUS_OVR_ERR)
+
+#define TX_FIFO_SIZE32
+
+static struct mvebu3700_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} mvebu3700_com = {0};
+
+#define mvebu3700_read(uart, off)   readl((uart)->regs + off)
+#define mvebu3700_write(uart, off, val) writel(val, (uart->regs) + off)
+
+static void mvebu3700_uart_interrupt(int irq, void *data,
+ struct cpu_user_regs *regs)
+{
+struct serial_port *port = data;
+struct mvebu3700_uart *uart = port->uart;
+uint32_t st = mvebu3700_read(uart, UART_STATUS_REG);
+
+if ( st & STATUS_TX_RDY )
+serial_tx_interrupt(port, regs);
+
+if ( st & (STATUS_RX_RDY | STATUS_OVR_ERR | STATUS_FRM_ERR |
+   STATUS_BRK_DET) )
+serial_rx_interrupt(port, regs);
+}
+
+static void __init mvebu3700_uart_init_preirq(struct serial_port *port)
+{
+struct mvebu3700_uart *uart = port->uart;
+uint32_t reg;
+
+reg = mvebu3700_read(uart, UART_CTRL_REG);
+reg |= (CTRL_TXFIFO_RST | CTRL_RXFIFO_RST);
+   

[Xen-devel] [PATCH v2 2/2] xen/arm: Add Marvell ARMADA 3700 early printk support

2018-04-03 Thread Amit Singh Tomar
Signed-off-by: Amit Singh Tomar 
---
Changes since v1:
* Removed header file dependency. 

---
 docs/misc/arm/early-printk.txt |  1 +
 xen/arch/arm/Rules.mk  |  1 +
 xen/arch/arm/arm64/debug-mvebu.inc | 50 ++
 3 files changed, 52 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-mvebu.inc

diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt
index 20a8af8..f765f59 100644
--- a/docs/misc/arm/early-printk.txt
+++ b/docs/misc/arm/early-printk.txt
@@ -41,6 +41,7 @@ the name of the machine:
   - juno: printk with pl011 on Juno platform
   - lager: printk with SCIF0 on Renesas R-Car H2 processors
   - midway: printk with the pl011 on Calxeda Midway processors
+  - 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
diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
index b66c19f..f264592 100644
--- a/xen/arch/arm/Rules.mk
+++ b/xen/arch/arm/Rules.mk
@@ -36,6 +36,7 @@ EARLY_PRINTK_hikey960   := pl011,0xfff32000
 EARLY_PRINTK_juno   := pl011,0x7ff8
 EARLY_PRINTK_lager  := scif,0xe6e6
 EARLY_PRINTK_midway := pl011,0xfff36000
+EARLY_PRINTK_mvebu  := mvebu,0xd0012000
 EARLY_PRINTK_omap5432   := 8250,0x4802,2
 EARLY_PRINTK_rcar3  := scif,0xe6e88000
 EARLY_PRINTK_seattle:= pl011,0xe101
diff --git a/xen/arch/arm/arm64/debug-mvebu.inc 
b/xen/arch/arm/arm64/debug-mvebu.inc
new file mode 100644
index 000..ac48889
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-mvebu.inc
@@ -0,0 +1,50 @@
+/*
+ * xen/drivers/char/mvebu3700-uart.c
+ *
+ * Driver for Marvell MVEBU UART.
+ *
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define UART_STATUS_REG 0xc 
+#define UART_TX_REG 0x04
+
+/*
+ * MVEBU UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldrh   w\c, [\xb, #UART_STATUS_REG]  /* <- status register */
+tstw\c, #(1 << 13)  /* <- Check TXFIFO EMP bit */
+beq1b/* <- Wait for the UART to be 
ready */
+.endm
+
+/*
+ * MVEBU UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+   strb  \wt, [\xb, #UART_TX_REG]
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.9.1


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

[Xen-devel] [PATCH v3 2/2] xen/arm: Add Marvell ARMADA 3700 early printk support

2018-04-05 Thread Amit Singh Tomar
Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* Addressed Andre's comments.
Changes since v1:
* Removed header file dependency.
---
 docs/misc/arm/early-printk.txt |  1 +
 xen/arch/arm/Rules.mk  |  1 +
 xen/arch/arm/arm64/debug-mvebu.inc | 50 ++
 3 files changed, 52 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-mvebu.inc

diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt
index 20a8af8..f765f59 100644
--- a/docs/misc/arm/early-printk.txt
+++ b/docs/misc/arm/early-printk.txt
@@ -41,6 +41,7 @@ the name of the machine:
   - juno: printk with pl011 on Juno platform
   - lager: printk with SCIF0 on Renesas R-Car H2 processors
   - midway: printk with the pl011 on Calxeda Midway processors
+  - 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
diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
index b66c19f..f264592 100644
--- a/xen/arch/arm/Rules.mk
+++ b/xen/arch/arm/Rules.mk
@@ -36,6 +36,7 @@ EARLY_PRINTK_hikey960   := pl011,0xfff32000
 EARLY_PRINTK_juno   := pl011,0x7ff8
 EARLY_PRINTK_lager  := scif,0xe6e6
 EARLY_PRINTK_midway := pl011,0xfff36000
+EARLY_PRINTK_mvebu  := mvebu,0xd0012000
 EARLY_PRINTK_omap5432   := 8250,0x4802,2
 EARLY_PRINTK_rcar3  := scif,0xe6e88000
 EARLY_PRINTK_seattle:= pl011,0xe101
diff --git a/xen/arch/arm/arm64/debug-mvebu.inc 
b/xen/arch/arm/arm64/debug-mvebu.inc
new file mode 100644
index 000..3579ea6
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-mvebu.inc
@@ -0,0 +1,50 @@
+/*
+ * xen/arch/arm/arm64/debug-mvebu.inc
+ *
+ * MVEBU specific debug code.
+ *
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define UART_STATUS_REG 0x0c
+#define UART_TX_REG 0x04
+
+/*
+ * MVEBU UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldrh   w\c, [\xb, #UART_STATUS_REG]  /* status register */
+tstw\c, #(1 << 11)  /* Check TXFIFO FULL bit */
+b.ne   1b/* Wait for the UART to be ready 
*/
+.endm
+
+/*
+ * MVEBU UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+   strb  \wt, [\xb, #UART_TX_REG]
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
--
1.9.1


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

[Xen-devel] [PATCH 0/2] Add support for Marvell Armada 3700 SoC

2018-04-05 Thread Amit Singh Tomar
This patch-set enables XEN booting[1] on ESPRESSObin board based
on Marvell Armada 3700 SoC.

I would like to Thanks Andre for helping on this.

[1]https://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/ESPRESSObin

Amit Singh Tomar (2):
  xen/arm: Add MVEBU UART driver for Marvell Armada 3700 SoC
  xen/arm: Add Marvell ARMADA 3700 early printk support

 docs/misc/arm/early-printk.txt |   1 +
 xen/arch/arm/Rules.mk  |   1 +
 xen/arch/arm/arm64/debug-mvebu.inc |  50 +++
 xen/drivers/char/Kconfig   |   8 +
 xen/drivers/char/Makefile  |   1 +
 xen/drivers/char/mvebu-uart.c  | 296 +
 6 files changed, 357 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-mvebu.inc
 create mode 100644 xen/drivers/char/mvebu-uart.c

--
1.9.1


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

[Xen-devel] [PATCH v3 1/2] xen/arm: Add MVEBU UART driver for Marvell Armada 3700 SoC

2018-04-05 Thread Amit Singh Tomar
This patch adds driver for UART controller found on Armada 3700 SoC.

There is no reference manuals available for 3700 SoC in public and it
is derived by looking at Linux driver[1].

[1]https://github.com/torvalds/linux/blob/master/drivers/tty/serial/mvebu-uart.c

Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* Addressed Andre's comments.
Changes since v1:
* Addressed Wei Liu's comments
* Addressed Andre's comments.
Changes since RFC:
* Addressed Julien's comments.
---
 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/mvebu-uart.c | 296 ++
 3 files changed, 305 insertions(+)
 create mode 100644 xen/drivers/char/mvebu-uart.c

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index fb53dd8..04a4087 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -12,6 +12,14 @@ config HAS_CADENCE_UART
  This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq
  based board, say Y.

+config HAS_MVEBU
+bool
+default y
+depends on ARM_64
+help
+  This selects the Marvell MVEBU UART. If you have a ARMADA 3700
+  based board, say Y.
+
 config HAS_PL011
bool
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 0d48b16..b68c330 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
 obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
new file mode 100644
index 000..1561a50
--- /dev/null
+++ b/xen/drivers/char/mvebu-uart.c
@@ -0,0 +1,296 @@
+/*
+ * xen/drivers/char/mvebu3700-uart.c
+ *
+ * Driver for Marvell MVEBU UART.
+ *
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define UART_RX_REG 0x00
+
+#define UART_TX_REG 0x04
+
+#define UART_CTRL_REG   0x08
+#define CTRL_TXFIFO_RST BIT(15)
+#define CTRL_RXFIFO_RST BIT(14)
+#define CTRL_TX_RDY_INT BIT(5)
+#define CTRL_RX_RDY_INT BIT(4)
+#define CTRL_BRK_DET_INTBIT(3)
+#define CTRL_FRM_ERR_INTBIT(2)
+#define CTRL_PAR_ERR_INTBIT(1)
+#define CTRL_OVR_ERR_INTBIT(0)
+#define CTRL_ERR_INT(CTRL_BRK_DET_INT | CTRL_FRM_ERR_INT | \
+ CTRL_PAR_ERR_INT | CTRL_OVR_ERR_INT)
+
+#define UART_STATUS_REG 0x0c
+#define STATUS_TXFIFO_EMP   BIT(13)
+#define STAT_TX_FIFO_FULBIT(11)
+#define STAT_TX_FIFO_HFLBIT(10)
+#define STATUS_TX_RDY   BIT(5)
+#define STATUS_RX_RDY   BIT(4)
+#define STATUS_BRK_DET  BIT(3)
+#define STATUS_FRM_ERR  BIT(2)
+#define STATUS_PAR_ERR  BIT(1)
+#define STATUS_OVR_ERR  BIT(0)
+#define STATUS_BRK_ERR  (STATUS_BRK_DET | STATUS_FRM_ERR | \
+ STATUS_PAR_ERR | STATUS_OVR_ERR)
+
+#define TX_FIFO_SIZE32
+
+static struct mvebu3700_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} mvebu3700_com = {0};
+
+#define mvebu3700_read(uart, off)   readl((uart)->regs + off)
+#define mvebu3700_write(uart, off, val) writel(val, (uart->regs) + off)
+
+static void mvebu3700_uart_interrupt(int irq, void *data,
+ struct cpu_user_regs *regs)
+{
+struct serial_port *port = data;
+struct mvebu3700_uart *uart = port->uart;
+uint32_t st = mvebu3700_read(uart, UART_STATUS_REG);
+
+if ( st & (STATUS_RX_RDY | STATUS_OVR_ERR | STATUS_FRM_ERR |
+   STATUS_BRK_DET) )
+serial_rx_interrupt(port, regs);
+
+if ( st & STATUS_TX_RDY )
+serial_tx_interrupt(port, regs);
+}
+
+static void __init mvebu3700_uart_init_preirq(struct serial_port *port)
+{
+struct mvebu3700_uart *uart = port->uart;
+uint32_t reg;
+
+reg = mvebu3700_read(uart

[Xen-devel] [PATCH v4] xen/arm: Add MVEBU UART driver for Marvell Armada 3700 SoC

2018-04-06 Thread Amit Singh Tomar
This patch adds driver for UART controller found on Armada 3700 SoC.

There is no reference manuals available for 3700 SoC in public and it
is derived by looking at Linux driver[1].

[1]https://github.com/torvalds/linux/blob/master/drivers/tty/serial/mvebu-uart.c
commit-id: c685af1108d7c303f0b901413405d68eaeac4477

Signed-off-by: Amit Singh Tomar 
---
Changes since v3:
* Dropped uart->irq > 0 checks
* Fixed coding style issue.
* Driver entry in MAINTAINERS file
* Fixed inconsistent STAT_TX_FIFO_* naming
Changes since v2:
* Addressed Andre's comments.
Changes since v1:
* Addressed Wei Liu's comments
* Addressed Andre's comments.
Changes since RFC:
* Addressed Julien's comments.
---
 MAINTAINERS   |   1 +
 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/mvebu-uart.c | 294 ++
 4 files changed, 304 insertions(+)
 create mode 100644 xen/drivers/char/mvebu-uart.c

diff --git a/MAINTAINERS b/MAINTAINERS
index eace09e..15bf5a3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -169,6 +169,7 @@ F:  xen/arch/arm/
 F: xen/drivers/char/arm-uart.c
 F: xen/drivers/char/cadence-uart.c
 F: xen/drivers/char/exynos4210-uart.c
+F: xen/drivers/char/mvebu-uart.c
 F: xen/drivers/char/omap-uart.c
 F: xen/drivers/char/pl011.c
 F: xen/drivers/char/scif-uart.c
diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index fb53dd8..a2ecd21 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -12,6 +12,14 @@ config HAS_CADENCE_UART
  This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq
  based board, say Y.

+config HAS_MVEBU
+   bool
+   default y
+   depends on ARM_64
+   help
+ This selects the Marvell MVEBU UART. If you have a ARMADA 3700
+ based board, say Y.
+
 config HAS_PL011
bool
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 0d48b16..b68c330 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
 obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
new file mode 100644
index 000..af43d76
--- /dev/null
+++ b/xen/drivers/char/mvebu-uart.c
@@ -0,0 +1,294 @@
+/*
+ * xen/drivers/char/mvebu3700-uart.c
+ *
+ * Driver for Marvell MVEBU UART.
+ *
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define UART_RX_REG 0x00
+
+#define UART_TX_REG 0x04
+
+#define UART_CTRL_REG   0x08
+#define CTRL_TXFIFO_RST BIT(15)
+#define CTRL_RXFIFO_RST BIT(14)
+#define CTRL_TX_RDY_INT BIT(5)
+#define CTRL_RX_RDY_INT BIT(4)
+#define CTRL_BRK_DET_INTBIT(3)
+#define CTRL_FRM_ERR_INTBIT(2)
+#define CTRL_PAR_ERR_INTBIT(1)
+#define CTRL_OVR_ERR_INTBIT(0)
+#define CTRL_ERR_INT(CTRL_BRK_DET_INT | CTRL_FRM_ERR_INT | \
+ CTRL_PAR_ERR_INT | CTRL_OVR_ERR_INT)
+
+#define UART_STATUS_REG 0x0c
+#define STATUS_TXFIFO_EMP   BIT(13)
+#define STATUS_TXFIFO_FUL   BIT(11)
+#define STATUS_TXFIFO_HFL   BIT(10)
+#define STATUS_TX_RDY   BIT(5)
+#define STATUS_RX_RDY   BIT(4)
+#define STATUS_BRK_DET  BIT(3)
+#define STATUS_FRM_ERR  BIT(2)
+#define STATUS_PAR_ERR  BIT(1)
+#define STATUS_OVR_ERR  BIT(0)
+#define STATUS_BRK_ERR  (STATUS_BRK_DET | STATUS_FRM_ERR | \
+ STATUS_PAR_ERR | STATUS_OVR_ERR)
+
+#define TX_FIFO_SIZE32
+
+static struct mvebu3700_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} mvebu3700_com = {0};
+
+#define mvebu3700_read(uart, off)   readl((uart)->regs + off)
+#define mvebu3700_write(uart, off, val) writel(val,

[Xen-devel] [PATCH] xen: char: Remove unnecessary (uart->irq > 0) check

2018-04-28 Thread Amit Singh Tomar
While working on MVEBU uart driver, Julien pointed out that (uart->irq > 0)
check is unnecessary during irq set up.if ever there is an invalid irq, driver
initialization itself would be bailed out from platform_get_irq.

This patch would remove similar check for other uart drivers present in XEN.

Signed-off-by: Amit Singh Tomar 
---
* This patch is only compiled tested.
---
 xen/drivers/char/cadence-uart.c | 15 ---
 xen/drivers/char/ns16550.c  | 35 ++-
 xen/drivers/char/omap-uart.c|  2 +-
 xen/drivers/char/pl011.c| 13 +++--
 4 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index 22905ba..1575787 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -72,13 +72,14 @@ static void __init cuart_init_postirq(struct serial_port 
*port)
 struct cuart *uart = port->uart;
 int rc;
 
-if ( uart->irq > 0 )
+uart->irqaction.handler = cuart_interrupt;
+uart->irqaction.name= "cadence-uart";
+uart->irqaction.dev_id  = port;
+
+if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
 {
-uart->irqaction.handler = cuart_interrupt;
-uart->irqaction.name= "cadence-uart";
-uart->irqaction.dev_id  = port;
-if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
-printk("ERROR: Failed to allocate cadence-uart IRQ %d\n", 
uart->irq);
+printk("ERROR: Failed to allocate cadence-uart IRQ %d\n", uart->irq);
+return;
 }
 
 /* Clear pending error interrupts */
@@ -130,7 +131,7 @@ static int __init cuart_irq(struct serial_port *port)
 {
 struct cuart *uart = port->uart;
 
-return ( (uart->irq > 0) ? uart->irq : -1 );
+return uart->irq;
 }
 
 static const struct vuart_info *cuart_vuart(struct serial_port *port)
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index f32dbd3..ba50a1e 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -714,18 +714,12 @@ static void __init ns16550_init_preirq(struct serial_port 
*port)
 
 static void ns16550_setup_postirq(struct ns16550 *uart)
 {
-if ( uart->irq > 0 )
-{
-/* Master interrupt enable; also keep DTR/RTS asserted. */
-ns_write_reg(uart,
- UART_MCR, UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS);
-
-/* Enable receive interrupts. */
-ns_write_reg(uart, UART_IER, UART_IER_ERDAI);
-}
+/* Master interrupt enable; also keep DTR/RTS asserted. */
+ns_write_reg(uart, UART_MCR, UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS);
+/* Enable receive interrupts. */
+ns_write_reg(uart, UART_IER, UART_IER_ERDAI);
 
-if ( uart->irq >= 0 )
-set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
+set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
 }
 
 static void __init ns16550_init_postirq(struct serial_port *port)
@@ -733,9 +727,6 @@ static void __init ns16550_init_postirq(struct serial_port 
*port)
 struct ns16550 *uart = port->uart;
 int rc, bits;
 
-if ( uart->irq < 0 )
-return;
-
 serial_async_transmit(port);
 
 init_timer(&uart->timer, ns16550_poll, port, 0);
@@ -746,13 +737,14 @@ static void __init ns16550_init_postirq(struct 
serial_port *port)
 uart->timeout_ms = max_t(
 unsigned int, 1, (bits * uart->fifo_size * 1000) / uart->baud);
 
-if ( uart->irq > 0 )
+uart->irqaction.handler = ns16550_interrupt;
+uart->irqaction.name= "ns16550";
+uart->irqaction.dev_id  = port;
+
+if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
 {
-uart->irqaction.handler = ns16550_interrupt;
-uart->irqaction.name= "ns16550";
-uart->irqaction.dev_id  = port;
-if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
-printk("ERROR: Failed to allocate ns16550 IRQ %d\n", uart->irq);
+printk("ERROR: Failed to allocate ns16550 IRQ %d\n", uart->irq);
+return;
 }
 
 ns16550_setup_postirq(uart);
@@ -874,7 +866,8 @@ static void __init ns16550_endboot(struct serial_port *port)
 static int __init ns16550_irq(struct serial_port *port)
 {
 struct ns16550 *uart = port->uart;
-return ((uart->irq > 0) ? uart->irq : -1);
+
+return uart->irq;
 }
 
 static void ns16550_start_tx(struct serial_port *port)
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index d6a5d59..2ce4e71 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -294,7 +294,7 @@ static int __init omap_uart_irq(struct serial_port *port)

[Xen-devel] [RFC PATCH] xen/arm64: Add Support for Marvell ARMADA 3700 SoC

2018-03-10 Thread Amit Singh Tomar
This patch-set is an attempt to enable XEN on ESPRESSObin[1] based on 
Marvell's ARMADA 3700 SoC

It includes simple serial port driver for ARMADA 3700 SoC.Platform itself
is discovered via device-tree.

With this patch, we can boot both Dom0 and DomU kernel on ESPRESSObin
board.

root@localhost:/home/amit/xen/tools/xl# xl list
NameID   Mem VCPUs  State   Time(s)
Domain-0 0   512 2 r-  18.1
guest-1  1   256 1 -b   6.0

Following command line is passed to XEN from bootloader.

tftp 0x250 Image;tftp 0x150 armada-3720-espressobin.dtb;tftp 0x100 
xen
setenv Image_name Image;setenv fdt_name armada-3720-espressobin.dtb
setenv kernel_addr_r 0x250;setenv fdt_addr_r 0x150;setenv xen_addr_r 
0x100
setenv fdt_high 0x;fdt addr $fdt_addr_r;fdt resize  
setenv xen_bootargs console=dtuart 
dtuart=/soc/internal-regs@d000/serial@12000 dom0_mem=512M
setenv dom0_bootargs  console=ttyMV0 console=hvc0,115200n8 earlycon=xenboot 
debug clk_ignore_unused root=/dev/mmcblk0p1 rw rootwait
fdt set /chosen xen,xen-bootargs \"$xen_bootargs\";fdt resize
fdt set /chosen xen,dom0-bootargs \"$dom0_bootargs\";fdt mknode /chosen modules
fdt set /chosen/modules '#address-cells' <1>;fdt set /chosen/modules 
'#size-cells' <1>;fdt mknode /chosen/modules module@0
fdt set /chosen/modules/module@0 compatible "multiboot,kernel", 
"multiboot,module";fdt resize
fdt set /chosen/modules/module@0 reg < $kernel_addr_r 0x180 >
booti ${xen_addr_r} - ${fdt_addr_r} 

I would really like to Thanks Andre for helping me out on this.

[1]http://wiki.espressobin.net/tiki-index.php

Amit Singh Tomar (1):
  xen/arm: Add MVEBU UART driver for Armada 3700 SoC

 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/mvebu-uart.c | 315 ++
 3 files changed, 324 insertions(+)
 create mode 100644 xen/drivers/char/mvebu-uart.c

-- 
1.9.1


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

[Xen-devel] [RFC PATCH] xen/arm: Add MVEBU UART driver for Armada 3700 SoC

2018-03-10 Thread Amit Singh Tomar
This patch adds driver for UART controller found on Armada 3700 SoC.

There is no reference manuals available for 3700 SoC in public and this
driver is derived by looking at Linux driver.

Signed-off-by: Amit Singh Tomar 
---
 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/mvebu-uart.c | 315 ++
 3 files changed, 324 insertions(+)
 create mode 100644 xen/drivers/char/mvebu-uart.c

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index fb53dd8..690eda6 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -12,6 +12,14 @@ config HAS_CADENCE_UART
  This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq
  based board, say Y.
 
+config HAS_MVEBU
+bool
+default y
+depends on ARM_64
+help
+  This selects the Marvell MVEBU UART. if you have an ARMADA 3700
+  based board, say Y.
+
 config HAS_PL011
bool
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 0d48b16..b68c330 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
 obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
new file mode 100644
index 000..fdcc153
--- /dev/null
+++ b/xen/drivers/char/mvebu-uart.c
@@ -0,0 +1,315 @@
+/*
+ * xen/drivers/char/mvebu3700-uart.c
+ *
+ * Driver for Marvell MVEBU UART.
+ *
+ * Amit Singh Tomar
+ * Copyright (c) 2018.
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define UART_RX_REG 0x00
+#define RBR_BRK_DET BIT(15)
+#define RBR_FRM_ERR_DET BIT(14)
+#define RBR_PAR_ERR_DET BIT(13)
+#define RBR_OVR_ERR_DET BIT(12)
+
+#define UART_TX_REG 0x04
+
+#define UART_CTRL_REG   0x08
+#define CTRL_SOFT_RST   BIT(31)
+#define CTRL_TXFIFO_RST BIT(15)
+#define CTRL_RXFIFO_RST BIT(14)
+#define CTRL_ST_MIRR_EN BIT(13)
+#define CTRL_LPBK_ENBIT(12)
+#define CTRL_SND_BRK_SEQBIT(11)
+#define CTRL_PAR_EN BIT(10)
+#define CTRL_TWO_STOP   BIT(9)
+#define CTRL_TX_HFL_INT BIT(8)
+#define CTRL_RX_HFL_INT BIT(7)
+#define CTRL_TX_EMP_INT BIT(6)
+#define CTRL_TX_RDY_INT BIT(5)
+#define CTRL_RX_RDY_INT BIT(4)
+#define CTRL_BRK_DET_INTBIT(3)
+#define CTRL_FRM_ERR_INTBIT(2)
+#define CTRL_PAR_ERR_INTBIT(1)
+#define CTRL_OVR_ERR_INTBIT(0)
+#define CTRL_RX_INT (CTRL_BRK_DET_INT | CTRL_FRM_ERR_INT | \
+ CTRL_PAR_ERR_INT | CTRL_OVR_ERR_INT)
+
+#define UART_STATUS_REG 0x0c
+#define STATUS_TXFIFO_EMP   BIT(13)
+#define STATUS_RXFIFO_EMP   BIT(12)
+#define STATUS_TXFIFO_FUL   BIT(11)
+#define STATUS_TXFIFO_HFL   BIT(10)
+#define STATUS_RX_TOGL  BIT(9)
+#define STATUS_RXFIFO_FUL   BIT(8)
+#define STATUS_RXFIFO_HFL   BIT(7)
+#define STATUS_TX_EMP   BIT(6)
+#define STATUS_TX_RDY   BIT(5)
+#define STATUS_RX_RDY   BIT(4)
+#define STATUS_BRK_DET  BIT(3)
+#define STATUS_FRM_ERR  BIT(2)
+#define STATUS_PAR_ERR  BIT(1)
+#define STATUS_OVR_ERR  BIT(0)
+#define STATUS_BRK_ERR  (STATUS_BRK_DET | STATUS_FRM_ERR | \
+STATUS_PAR_ERR | STATUS_OVR_ERR)
+
+#define UART_BAUD_REG   0x10
+#define UART_POSSR_REG  0x14
+
+#define TX_FIFO_SIZE32
+#define RX_FIFO_SIZE64
+
+static struct mvebu3700_uart {
+unsigned int baud, data_bits, parity, stop_bits;
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} mvebu3700_com = {0};
+
+#define PARITY_NONE  (0)
+
+#define mvebu3700_read(uart, off)   readl((uart)->regs + off)
+#define mvebu3700_write(uart, off, val) writel(val, (uart->regs) + off)
+
+static void mvebu3700_uart_interrupt(int irq, void *data, struct
+cpu_user_regs

[Xen-devel] [PATCH v1] xen/arm: Add MVEBU UART driver for Armada 3700 SoC

2018-03-16 Thread Amit Singh Tomar
This patch adds driver for UART controller found on Armada 3700 SoC.

There is no reference manuals available for 3700 SoC in public and this
driver is derived by looking at Linux driver.
https://github.com/torvalds/linux/blob/master/drivers/tty/serial/mvebu-uart.c

It allows XEN to boot on ESPRESSObin board based on Marvell's ARMADA 3700 SoC.

Signed-off-by: Amit Singh Tomar 
---
Changes since RFC:
* Addressed Julien's Comments. 
TODO:
* Wiki page to capture XEN boot info.
* earlyprintk support.
---
 xen/drivers/char/Kconfig |   8 ++
 xen/drivers/char/Makefile|   1 +
 xen/drivers/char/mvebu-uart.c| 260 +++
 xen/include/asm-arm/mvebu-uart.h |  60 +
 4 files changed, 329 insertions(+)
 create mode 100644 xen/drivers/char/mvebu-uart.c
 create mode 100644 xen/include/asm-arm/mvebu-uart.h

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index fb53dd8..690eda6 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -12,6 +12,14 @@ config HAS_CADENCE_UART
  This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq
  based board, say Y.
 
+config HAS_MVEBU
+bool
+default y
+depends on ARM_64
+help
+  This selects the Marvell MVEBU UART. if you have an ARMADA 3700
+  based board, say Y.
+
 config HAS_PL011
bool
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 0d48b16..b68c330 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
 obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
new file mode 100644
index 000..c88d5e7
--- /dev/null
+++ b/xen/drivers/char/mvebu-uart.c
@@ -0,0 +1,260 @@
+/*
+ * xen/drivers/char/mvebu3700-uart.c
+ *
+ * Driver for Marvell MVEBU UART.
+ *
+ * Amit Singh Tomar 
+ * Copyright (c) 2018.
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static struct mvebu3700_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} mvebu3700_com = {0};
+
+#define mvebu3700_read(uart, off)   readl((uart)->regs + off)
+#define mvebu3700_write(uart, off, val) writel(val, (uart->regs) + off)
+
+static void mvebu3700_uart_interrupt(int irq, void *data,
+ struct cpu_user_regs *regs)
+{
+struct serial_port *port = data;
+struct mvebu3700_uart *uart = port->uart;
+uint32_t st = mvebu3700_read(uart, UART_STATUS_REG);
+
+if ( st & STATUS_TX_RDY )
+serial_tx_interrupt(port, regs);
+
+if ( st & (STATUS_RX_RDY | STATUS_OVR_ERR | STATUS_FRM_ERR |
+   STATUS_BRK_DET) )
+serial_rx_interrupt(port, regs);
+}
+
+static void __init mvebu3700_uart_init_preirq(struct serial_port *port)
+{
+struct mvebu3700_uart *uart = port->uart;
+uint32_t reg;
+
+reg = mvebu3700_read(uart, UART_CTRL_REG);
+reg |= (CTRL_TXFIFO_RST | CTRL_RXFIFO_RST);
+mvebu3700_write(uart, UART_CTRL_REG, reg);
+
+/* Before we make IRQ request, clear the error bits of state register. */
+reg = mvebu3700_read(uart, UART_STATUS_REG);
+reg |= STATUS_BRK_ERR;
+mvebu3700_write(uart, UART_STATUS_REG, reg);
+
+/* Clear error interrupts. */
+mvebu3700_write(uart, UART_CTRL_REG, CTRL_RX_INT);
+
+/* Disable Rx/Tx interrupts. */
+reg = mvebu3700_read(uart, UART_CTRL_REG);
+reg &= ~(CTRL_RX_RDY_INT | CTRL_TX_RDY_INT);
+mvebu3700_write(uart, UART_CTRL_REG, reg);
+}
+
+static void __init mvebu3700_uart_init_postirq(struct serial_port *port)
+{
+struct mvebu3700_uart *uart = port->uart;
+uint32_t reg;
+
+if ( uart->irq > 0 )
+{
+uart->irqaction.handler = mvebu3700_uart_interrupt;
+uart->irqaction.name= "mvebu3700_uart";
+uart->irqaction.dev_id  = port;
+}
+
+if ( setup_irq(uart->irq, 0, &uart->irqaction) != 0 )
+{
+pri

[Xen-devel] [PATCH v1] xen/arm: Add Marvell ARMADA 3700 early printk support

2018-03-18 Thread Amit Singh Tomar
Signed-off-by: Amit Singh Tomar 
---
 docs/misc/arm/early-printk.txt |  1 +
 xen/arch/arm/Rules.mk  |  1 +
 xen/arch/arm/arm64/debug-mvebu.inc | 48 ++
 3 files changed, 50 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-mvebu.inc

diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt
index 20a8af8..f765f59 100644
--- a/docs/misc/arm/early-printk.txt
+++ b/docs/misc/arm/early-printk.txt
@@ -41,6 +41,7 @@ the name of the machine:
   - juno: printk with pl011 on Juno platform
   - lager: printk with SCIF0 on Renesas R-Car H2 processors
   - midway: printk with the pl011 on Calxeda Midway processors
+  - 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
diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
index b66c19f..f264592 100644
--- a/xen/arch/arm/Rules.mk
+++ b/xen/arch/arm/Rules.mk
@@ -36,6 +36,7 @@ EARLY_PRINTK_hikey960   := pl011,0xfff32000
 EARLY_PRINTK_juno   := pl011,0x7ff8
 EARLY_PRINTK_lager  := scif,0xe6e6
 EARLY_PRINTK_midway := pl011,0xfff36000
+EARLY_PRINTK_mvebu  := mvebu,0xd0012000
 EARLY_PRINTK_omap5432   := 8250,0x4802,2
 EARLY_PRINTK_rcar3  := scif,0xe6e88000
 EARLY_PRINTK_seattle:= pl011,0xe101
diff --git a/xen/arch/arm/arm64/debug-mvebu.inc 
b/xen/arch/arm/arm64/debug-mvebu.inc
new file mode 100644
index 000..67dc44d
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-mvebu.inc
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm64/debug-mvebu.inc
+ *
+ * MVEBU specific debug code
+ *
+ * Amit Singh Tomar 
+ * Copyright (C) 2018.
+ *
+ * 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 
+
+/*
+ * MVEBU UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldrh   w\c, [\xb, #UART_STATUS_REG]  /* <- status register */
+tstw\c, #(1 << 13)  /* <- Check TXFIFO EMP bit */
+beq1b/* <- Wait for the UART to be 
ready */
+.endm
+
+/*
+ * MVEBU UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+   strb  \wt, [\xb, #UART_TX_REG]
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.9.1


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

[Xen-devel] [PATCH v2] xen/arm: Fix platform name to xilinx_zynqmp from xgene_storm

2018-03-18 Thread Amit Singh Tomar
Signed-off-by: Amit Singh Tomar 
---
Changes since v1:
* Addressed Andre's comment.
---
 xen/arch/arm/platforms/xilinx-zynqmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c 
b/xen/arch/arm/platforms/xilinx-zynqmp.c
index 2adee91..d8ceded 100644
--- a/xen/arch/arm/platforms/xilinx-zynqmp.c
+++ b/xen/arch/arm/platforms/xilinx-zynqmp.c
@@ -32,7 +32,7 @@ static const struct dt_device_match zynqmp_blacklist_dev[] 
__initconst =
 { /* sentinel */ },
 };
 
-PLATFORM_START(xgene_storm, "Xilinx ZynqMP")
+PLATFORM_START(xilinx_zynqmp, "Xilinx ZynqMP")
 .compatible = zynqmp_dt_compat,
 .blacklist_dev = zynqmp_blacklist_dev,
 PLATFORM_END
-- 
1.9.1


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

[Xen-devel] [RFC PATCH 0/2] xen/arm64: Add Support for Amlogic S905 SoC

2018-08-07 Thread Amit Singh Tomar
This small series enabled XEN booting on NanoPI K2 board[1] based
on Amlogic SoC. 

It has been tested by booting Dom0 Kernel.

TODO:
   * Wiki page to capture XEN boot info.

[1]: https://www.friendlyarm.com/index.php?route=product/product&product_id=186

Amit Singh Tomar (2):
  xen/arm: Add Amlogic S905 SoC early printk support
  xen/arm: Add MESON UART driver for Amlogic S905 SoC

 docs/misc/arm/early-printk.txt |   1 +
 xen/arch/arm/Rules.mk  |   1 +
 xen/arch/arm/arm64/debug-meson.inc |  50 +++
 xen/drivers/char/Kconfig   |   8 +
 xen/drivers/char/Makefile  |   1 +
 xen/drivers/char/meson-uart.c  | 290 +
 6 files changed, 351 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc
 create mode 100644 xen/drivers/char/meson-uart.c

-- 
1.9.1


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

[Xen-devel] [RFC PATCH 1/2] xen/arm: Add Amlogic S905 SoC early printk support

2018-08-07 Thread Amit Singh Tomar
Signed-off-by: Amit Singh Tomar 
---
 docs/misc/arm/early-printk.txt |  1 +
 xen/arch/arm/Rules.mk  |  1 +
 xen/arch/arm/arm64/debug-meson.inc | 50 ++
 3 files changed, 52 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-meson.inc

diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt
index f765f59..2aa9528 100644
--- a/docs/misc/arm/early-printk.txt
+++ b/docs/misc/arm/early-printk.txt
@@ -41,6 +41,7 @@ the name of the machine:
   - juno: printk with pl011 on Juno platform
   - lager: printk with SCIF0 on Renesas R-Car H2 processors
   - midway: printk with the pl011 on Calxeda Midway processors
+  - meson: printk with the MESON for Amlogic S905 SoCs
   - mvebu: printk with the MVEBU for Marvell Armada 3700 SoCs
   - omap5432: printk with UART3 on TI OMAP5432 processors
   - rcar3: printk with SCIF2 on Renesas R-Car Gen3 processors
diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
index f264592..d4fabdc 100644
--- a/xen/arch/arm/Rules.mk
+++ b/xen/arch/arm/Rules.mk
@@ -36,6 +36,7 @@ EARLY_PRINTK_hikey960   := pl011,0xfff32000
 EARLY_PRINTK_juno   := pl011,0x7ff8
 EARLY_PRINTK_lager  := scif,0xe6e6
 EARLY_PRINTK_midway := pl011,0xfff36000
+EARLY_PRINTK_meson  := meson,0xc81004c0
 EARLY_PRINTK_mvebu  := mvebu,0xd0012000
 EARLY_PRINTK_omap5432   := 8250,0x4802,2
 EARLY_PRINTK_rcar3  := scif,0xe6e88000
diff --git a/xen/arch/arm/arm64/debug-meson.inc 
b/xen/arch/arm/arm64/debug-meson.inc
new file mode 100644
index 000..d5507d3
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-meson.inc
@@ -0,0 +1,50 @@
+/*
+ * xen/arch/arm/arm64/debug-meson.inc
+ *
+ * MESON specific debug code.
+ *
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define UART_STATUS_REG 0x0c
+#define UART_TX_REG 0x00
+
+/*
+ * MESON UART wait UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register
+ */
+.macro early_uart_ready xb c
+1:
+ldrh   w\c, [\xb, #UART_STATUS_REG] /* status register */
+tstw\c, #(1 << 21)  /* Check TXFIFO FULL bit */
+b.ne   1b   /* Wait for the UART to be ready */
+.endm
+
+/*
+ * MESON UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb wt
+   strb  \wt, [\xb, #UART_TX_REG]
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.9.1


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

[Xen-devel] [RFC PATCH 2/2] xen/arm: Add MESON UART driver for Amlogic S905 SoC

2018-08-07 Thread Amit Singh Tomar
This patch adds driver for UART controller present on Amlogic S905 SoC.
https://dn.odroid.com/S905/DataSheet/S905_Public_Datasheet_V1.1.4.pdf

Signed-off-by: Amit Singh Tomar 
---
 xen/drivers/char/Kconfig  |   8 ++
 xen/drivers/char/Makefile |   1 +
 xen/drivers/char/meson-uart.c | 290 ++
 3 files changed, 299 insertions(+)
 create mode 100644 xen/drivers/char/meson-uart.c

diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig
index cc78ec3..b9fee4e 100644
--- a/xen/drivers/char/Kconfig
+++ b/xen/drivers/char/Kconfig
@@ -20,6 +20,14 @@ config HAS_MVEBU
  This selects the Marvell MVEBU UART. If you have a ARMADA 3700
  based board, say Y.
 
+config HAS_MESON
+bool
+default y
+depends on ARM_64
+help
+  This selects the Marvell MESON UART. If you have a Amlogic S905
+  based board, say Y.
+
 config HAS_PL011
bool
default y
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index b68c330..7c646d7 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o
 obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o
 obj-$(CONFIG_HAS_PL011) += pl011.o
 obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o
+obj-$(CONFIG_HAS_MESON) += meson-uart.o
 obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c
new file mode 100644
index 000..8fe7e62
--- /dev/null
+++ b/xen/drivers/char/meson-uart.c
@@ -0,0 +1,290 @@
+/*
+ * xen/drivers/char/meson-uart.c
+ *
+ * Driver for Amlogic MESON UART
+ *
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define UART_WFIFO  0x00
+#define UART_RFIFO  0x04
+#define UART_CONTROL0x08
+#define UART_STATUS 0x0c
+#define UART_MISC   0x10
+#define UART_REG5   0x14
+
+/* UART_CONTROL bits */
+#define UART_TX_EN  BIT(12)
+#define UART_RX_EN  BIT(13)
+#define UART_TX_RST BIT(22)
+#define UART_RX_RST BIT(23)
+#define UART_CLEAR_ERR  BIT(24)
+#define UART_RX_INT_EN  BIT(27)
+#define UART_TX_INT_EN  BIT(28)
+
+/* UART_STATUS bits */
+#define UART_PARITY_ERR BIT(16)
+#define UART_FRAME_ERR  BIT(17)
+#define UART_TX_FIFO_WERR   BIT(18)
+#define UART_RX_EMPTY   BIT(20)
+#define UART_TX_FULLBIT(21)
+#define UART_TX_EMPTY   BIT(22)
+#define UART_TX_CNT_MASKGENMASK(14, 8)
+
+
+#define UART_XMIT_IRQ_CNT_MASK  GENMASK(15, 8)
+#define UART_RECV_IRQ_CNT_MASK  GENMASK(7, 0)
+
+#define TX_FIFO_SIZE64
+
+static struct meson_s905_uart {
+unsigned int irq;
+void __iomem *regs;
+struct irqaction irqaction;
+struct vuart_info vuart;
+} meson_s905_com = {0};
+
+#define meson_s905_read(uart, off)   readl((uart)->regs + off)
+#define meson_s905_write(uart, off, val) writel(val, (uart->regs) + off)
+
+static void meson_s905_uart_interrupt(int irq, void *data,
+struct cpu_user_regs *regs)
+{
+struct serial_port *port = data;
+struct meson_s905_uart *uart = port->uart;
+uint32_t st = meson_s905_read(uart, UART_STATUS);
+
+if ( !(st & UART_RX_EMPTY) )
+{
+serial_rx_interrupt(port, regs);
+}
+
+if ( !(st & UART_TX_FULL) )
+{
+if ( st & UART_TX_INT_EN )
+serial_tx_interrupt(port, regs);
+}
+
+}
+
+static void __init meson_s905_uart_init_preirq(struct serial_port *port)
+{
+struct meson_s905_uart *uart = port->uart;
+uint32_t reg;
+
+reg = meson_s905_read(uart, UART_CONTROL);
+reg &= ~(UART_RX_RST | UART_TX_RST | UART_CLEAR_ERR);
+meson_s905_write(uart, UART_CONTROL, reg);
+
+/* Disbale Rx/Tx interrupts */
+reg = meson_s905_read(uart, UART_CONTROL);
+reg &= ~(UART_RX_INT_EN | UART_TX_INT_EN);
+meson_s905_write(uart, UART_CONTROL, reg);
+}
+
+static void __init meson_s905_uart_init_postirq(struct serial_port *port)
+{
+struct meson_s905_uart *uart = port

[Xen-devel] [PATCH] xen:arm: Populate arm64 image header

2018-08-31 Thread Amit Singh Tomar
While porting XEN on Amlogic SoC we found that in absence of
image_size field of XEN image header, bootloader(U-BOOT)
relocates[1] the XEN image to an address(not appropriate
for Amlogic) derived from text_offset.

This unwanted situation can be fixed by updating image_size field
along side kernel flags so that image wouldn't relocate from initial
load address.

[1]:https://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/lib/image.c;h=699bf44e702f7a7084997406203fd7d2aaaf87fa;hb=HEAD#l50

These changes are derived from kernel v4.18 files

Signed-off-by: Amit Singh Tomar 
---
 xen/arch/arm/arm64/head.S |  5 ++-
 xen/arch/arm/arm64/lib/assembler.h| 11 +
 xen/arch/arm/xen.lds.S|  3 ++
 xen/include/asm-arm/arm64/linux_header_vars.h | 62 +++
 4 files changed, 79 insertions(+), 2 deletions(-)
 create mode 100644 xen/include/asm-arm/arm64/linux_header_vars.h

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index d63734f..ce72c95 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include "lib/assembler.h"
 
 #define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
 #define PT_MEM0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */
@@ -120,8 +121,8 @@ efi_head:
 add x13, x18, #0x16
 b   real_start   /* branch to kernel start */
 .quad   0/* Image load offset from start of RAM */
-.quad   0/* reserved */
-.quad   0/* reserved */
+le64sym _kernel_size_le  /* Effective size of kernel image, 
little-endian */
+le64sym _kernel_flags_le /* Informative flags, little-endian */
 .quad   0/* reserved */
 .quad   0/* reserved */
 .quad   0/* reserved */
diff --git a/xen/arch/arm/arm64/lib/assembler.h 
b/xen/arch/arm/arm64/lib/assembler.h
index 3f9c0dc..c0ef758 100644
--- a/xen/arch/arm/arm64/lib/assembler.h
+++ b/xen/arch/arm/arm64/lib/assembler.h
@@ -9,4 +9,15 @@
 #define CPU_BE(x...)
 #define CPU_LE(x...) x
 
+/*
+ * Emit a 64-bit absolute little endian symbol reference in a way that
+ * ensures that it will be resolved at build time, even when building a
+ * PIE binary. This requires cooperation from the linker script, which
+ * must emit the lo32/hi32 halves individually.
+ */
+.macro  le64sym, sym
+.long   \sym\()_lo32
+.long   \sym\()_hi32
+.endm
+
 #endif /* __ASM_ASSEMBLER_H__ */
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 245a0e0..0b9af9e 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 #undef ENTRY
 #undef ALIGN
 
@@ -229,6 +230,8 @@ SECTIONS
   .stab.index 0 : { *(.stab.index) }
   .stab.indexstr 0 : { *(.stab.indexstr) }
   .comment 0 : { *(.comment) }
+
+  HEAD_SYMBOLS
 }
 
 /*
diff --git a/xen/include/asm-arm/arm64/linux_header_vars.h 
b/xen/include/asm-arm/arm64/linux_header_vars.h
new file mode 100644
index 000..3eeffec
--- /dev/null
+++ b/xen/include/asm-arm/arm64/linux_header_vars.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018, Amit Singh Tomar .
+ *
+ * Derived from Linux kernel v4.18 file:
+ *
+ * arch/arm64/kernel/image.h
+ * Copyright (C) 2014 ARM Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __ASM_IMAGE_H
+#define __ASM_IMAGE_H
+
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#define DATA_LE32(data) \
+data) & 0x00ff) << 24) |\
+(((data) & 0xff00) << 8)   |\
+(((data) & 0x00ff) >> 8)   |\
+(((data) & 0xff00) >> 24))
+#else
+#define DATA_LE32(data) ((data) & 0x)
+#endif
+
+#define DEFINE_IMAGE_LE64(sym, data)\
+sym##_lo32 = DATA_LE32((data) & 0x);\
+sym##_hi32 = DATA_LE32((data) >> 32)
+
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#define __HEAD_FLAG_BE 1
+#else
+#define __HEAD_FLAG_BE 0
+#endif
+
+#define __HEAD_FLAG_PAGE_SIZE  1 /* 4K hard-coded */
+
+#define __HEAD_FLAG_PHYS_BASE  1
+
+#define __HEAD_FLAGS((__HEAD_FL

[Xen-devel] [PATCH v2] xen:arm: Populate arm64 image header

2018-09-04 Thread Amit Singh Tomar
This patch adds image size and flags to XEN image header. It uses
those fields according to the updated Linux kernel image definition.

With this patch bootloader can now place XEN image anywhere in system
RAM at 2MB aligned address without to worry about relocation.
For instance, it fixes the XEN boot on Amlogic SoC where bootloader(U-BOOT)
always relocates the XEN image to an address range reserved for firmware data.

Signed-off-by: Amit Singh Tomar 
---
Changes since v1:
* Updated commit message
* Removed endianess code
---
 xen/arch/arm/arm64/head.S  | 5 +++--
 xen/arch/arm/arm64/lib/assembler.h | 9 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index d63734f..8e35968 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include "lib/assembler.h"
 
 #define PT_PT 0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 P=1 */
 #define PT_MEM0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 P=1 */
@@ -120,8 +121,8 @@ efi_head:
 add x13, x18, #0x16
 b   real_start   /* branch to kernel start */
 .quad   0/* Image load offset from start of RAM */
-.quad   0/* reserved */
-.quad   0/* reserved */
+.quad   __KERNEL_SIZE/* Effective size of kernel image, 
little-endian */
+.quad   __HEAD_FLAGS /* Informative flags, little-endian */
 .quad   0/* reserved */
 .quad   0/* reserved */
 .quad   0/* reserved */
diff --git a/xen/arch/arm/arm64/lib/assembler.h 
b/xen/arch/arm/arm64/lib/assembler.h
index 3f9c0dc..7239c19 100644
--- a/xen/arch/arm/arm64/lib/assembler.h
+++ b/xen/arch/arm/arm64/lib/assembler.h
@@ -9,4 +9,13 @@
 #define CPU_BE(x...)
 #define CPU_LE(x...) x
 
+#define __HEAD_FLAG_PAGE_SIZE   1 /* 4K hard-coded */
+
+#define __HEAD_FLAG_PHYS_BASE   1
+
+#define __HEAD_FLAGS((__HEAD_FLAG_PAGE_SIZE << 1) |  \
+(__HEAD_FLAG_PHYS_BASE << 3))
+
+#define __KERNEL_SIZE   (_end - start)
+
 #endif /* __ASM_ASSEMBLER_H__ */
-- 
1.9.1


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

[Xen-devel] [PATCH v3] xen:arm: Populate arm64 image header

2018-09-11 Thread Amit Singh Tomar
This patch adds image size and flags to XEN image header. It uses
those fields according to the updated Linux kernel image definition.

With this patch bootloader can now place XEN image anywhere in system
RAM at 2MB aligned address without to worry about relocation.
For instance, it fixes the XEN boot on Amlogic SoC where bootloader(U-BOOT)
always relocates the XEN image to an address range reserved for firmware data.

Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* Undo changes in assembler.h(as suggested by Andre)
Changes since v1:
* Updated commit message
* Removed endianess code
---
 xen/arch/arm/arm64/head.S | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index d63734f..ef87b5c 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -32,6 +32,13 @@
 #define PT_DEV0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
 #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */
 
+#define __HEAD_FLAG_PAGE_SIZE   ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAG_PHYS_BASE   1
+
+#define __HEAD_FLAGS((__HEAD_FLAG_PAGE_SIZE << 1) | \
+ (__HEAD_FLAG_PHYS_BASE << 3))
+
 #if (defined (CONFIG_EARLY_PRINTK)) && (defined (EARLY_PRINTK_INC))
 #include EARLY_PRINTK_INC
 #endif
@@ -120,8 +127,8 @@ efi_head:
 add x13, x18, #0x16
 b   real_start   /* branch to kernel start */
 .quad   0/* Image load offset from start of RAM */
-.quad   0/* reserved */
-.quad   0/* reserved */
+.quad   _end - start /* Effective size of kernel image, 
little-endian */
+.quad   __HEAD_FLAGS /* Informative flags, little-endian */
 .quad   0/* reserved */
 .quad   0/* reserved */
 .quad   0/* reserved */
-- 
1.9.1


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

[Xen-devel] [PATCH] xen/arm: Fix platform name for Xilinx ZynqMP

2018-01-25 Thread Amit Singh Tomar
This seems to be copy/paste error.This patch simply
replace string xgene_storm with xilink_zymp for xilink
platform.

Signed-off-by: Amit Singh Tomar 
---
 xen/arch/arm/platforms/xilinx-zynqmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c 
b/xen/arch/arm/platforms/xilinx-zynqmp.c
index 2adee91..38f2c16 100644
--- a/xen/arch/arm/platforms/xilinx-zynqmp.c
+++ b/xen/arch/arm/platforms/xilinx-zynqmp.c
@@ -32,7 +32,7 @@ static const struct dt_device_match zynqmp_blacklist_dev[] 
__initconst =
 { /* sentinel */ },
 };
 
-PLATFORM_START(xgene_storm, "Xilinx ZynqMP")
+PLATFORM_START(xilink_zynqmp, "Xilinx ZynqMP")
 .compatible = zynqmp_dt_compat,
 .blacklist_dev = zynqmp_blacklist_dev,
 PLATFORM_END
-- 
1.9.1


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

[Xen-devel] [PATCH v3] xen/arm: domain_build: Black list devices using PPIs

2019-06-23 Thread Amit Singh Tomar
Currently, the vGIC is not able to cope with hardware PPIs routed to guests.
One of the solutions to this problem is to skip any device that uses PPI
source completely while building the domain itself.

This patch goes through all the interrupt sources of a device and skip it
if one of the interrupts sources is a PPI. It fixes XEN boot on i.MX8MQ by
skipping the PMU node.

Suggested-by:  Julien Grall 
Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* Update subject-line for the patch.
* Fix commit message.
* Add proper comments for changes.

Changes since v1:
* Added comment for PPIs range.
---
 xen/arch/arm/domain_build.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d983677..53935f8 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1353,7 +1353,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 { /* sentinel */ },
 };
 struct dt_device_node *child;
-int res;
+int res, i, nirq, irq_id;
 const char *name;
 const char *path;
 
@@ -1400,6 +1400,24 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
 }
 
 /*
+ * The vGIC does not support routing hardware PPIs to guest. So
+ * we need to skip any node using PPIs.
+ */
+nirq = dt_number_of_irq(node);
+
+for ( i = 0 ; i < nirq ; i++ )
+{
+irq_id = platform_get_irq(node, i);
+
+/* PPIs ranges from ID 16 to 31 */
+if ( irq_id >= 16 && irq_id < 32 )
+{
+dt_dprintk(" Skip it(using PPIs)\n");
+return 0;
+}
+}
+
+/*
  * Xen is using some path for its own purpose. Warn if a node
  * already exists with the same path.
  */
-- 
2.7.4


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