]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
sparc: leon3: Add debug_uart support to LEON3 serial driver.
authorFrancois Retief <fgretief@spaceteq.co.za>
Thu, 29 Oct 2015 10:55:34 +0000 (12:55 +0200)
committerFrancois Retief <fgretief@spaceteq.co.za>
Fri, 13 Nov 2015 08:23:33 +0000 (10:23 +0200)
Signed-off-by: Francois Retief <fgretief@spaceteq.co.za>
arch/sparc/cpu/leon3/cpu_init.c
arch/sparc/cpu/leon3/serial.c
configs/grsim_defconfig
drivers/serial/Kconfig

index 40d1751fcb0130fc013f8c05fa7f7b1988be34a1..b140da31b13bfe6077464190a514eb0a3e81ecae 100644 (file)
@@ -13,6 +13,7 @@
 #include <ambapp.h>
 #include <grlib/irqmp.h>
 #include <grlib/gptimer.h>
+#include <debug_uart.h>
 
 #include <config.h>
 
@@ -50,7 +51,9 @@ struct {
  */
 void cpu_init_f(void)
 {
-
+#ifdef CONFIG_DEBUG_UART
+       debug_uart_init();
+#endif
 }
 
 /* Routine called from start.S,
index cefb9d2c3611fc131207b28129d5c2856faf4407..66b377302700f39a93755ecebd186ab93012cd3f 100644 (file)
@@ -28,8 +28,10 @@ static int leon3_serial_init(void)
 
        /* find UART */
        if (ambapp_apb_find(&ambapp_plb, VENDOR_GAISLER, GAISLER_APBUART,
-               CONFIG_SYS_GRLIB_APBUART_INDEX, &apbdev) != 1)
+               CONFIG_SYS_GRLIB_APBUART_INDEX, &apbdev) != 1) {
+               panic("%s: apbuart not found!\n", __func__);
                return -1; /* didn't find hardware */
+       }
 
        /* found apbuart, let's init .. */
        uart = (ambapp_dev_apbuart *) apbdev.address;
@@ -145,3 +147,26 @@ __weak struct serial_device *default_serial_console(void)
 {
        return &leon3_serial_drv;
 }
+
+#ifdef CONFIG_DEBUG_UART_APBUART
+
+#include <debug_uart.h>
+
+static inline void _debug_uart_init(void)
+{
+       ambapp_dev_apbuart *uart = (ambapp_dev_apbuart *)CONFIG_DEBUG_UART_BASE;
+       uart->scaler = (((CONFIG_DEBUG_UART_CLOCK*10) / (CONFIG_BAUDRATE*8)) - 5)/10;
+       uart->ctrl = APBUART_CTRL_RE | APBUART_CTRL_TE;
+}
+
+static inline void _debug_uart_putc(int ch)
+{
+       ambapp_dev_apbuart *uart = (ambapp_dev_apbuart *)CONFIG_DEBUG_UART_BASE;
+       while (!(readl(&uart->status) & APBUART_STATUS_THE))
+               WATCHDOG_RESET();
+       writel(ch, &uart->data);
+}
+
+DEBUG_UART_FUNCS
+
+#endif
index a5ea7ab8d83afbc6db59e99c08edc9c2e9fa9aea..d2f709f834efffd6f88f64e17b8d63f0ca337853 100644 (file)
@@ -14,3 +14,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000
 # CONFIG_CMD_NET is not set
 # CONFIG_CMD_NFS is not set
 CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_APBUART=y
+CONFIG_DEBUG_UART_BASE=0x80000100
+CONFIG_DEBUG_UART_CLOCK=40000000
index d462244a04555de761b122a4f59c0a2a2e1021e3..eba96f4a80d328b05cd2b6332b4550b176ca3061 100644 (file)
@@ -98,6 +98,14 @@ config DEBUG_UART_ZYNQ
          will need to provide parameters to make this work. The driver will
          be available until the real driver-model serial is running.
 
+config DEBUG_UART_APBUART
+       depends on LEON3
+       bool "Gaisler APBUART"
+       help
+         Select this to enable a debug UART using the serial_leon3 driver. You
+         will need to provide parameters to make this work. The driver will
+         be available until the real driver model serial is running.
+
 endchoice
 
 config DEBUG_UART_BASE