]> git.sur5r.net Git - u-boot/blobdiff - drivers/serial/arm_dcc.c
Merge branch 'master' of git://git.denx.de/u-boot-net
[u-boot] / drivers / serial / arm_dcc.c
index 812dcf0787c03591c9722c6b8bfa224dff99c659..4624666e8a2c776d2eb56933d7968407f03962f8 100644 (file)
@@ -2,18 +2,7 @@
  * Copyright (C) 2004-2007 ARM Limited.
  * Copyright (C) 2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * SPDX-License-Identifier:    GPL-2.0
  *
  * As a special exception, if other files instantiate templates or use macros
  * or inline functions from this file, or you compile this file and link it
  */
 
 #include <common.h>
-#include <stdio_dev.h>
+#include <serial.h>
 
-#if defined(CONFIG_CPU_V6)
+#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V7)
 /*
- * ARMV6
+ * ARMV6 & ARMV7
  */
 #define DCC_RBIT       (1 << 30)
 #define DCC_WBIT       (1 << 29)
 #define status_dcc(x)  \
                __asm__ volatile ("mrc p14, 0, %0, c14, c0, 0\n" : "=r" (x))
 
+#elif defined(CONFIG_CPU_ARMV8)
+/*
+ * ARMV8
+ */
+#define DCC_RBIT       (1 << 30)
+#define DCC_WBIT       (1 << 29)
+
+#define write_dcc(x)   \
+               __asm__ volatile ("msr dbgdtrtx_el0, %0\n" : : "r" (x))
+
+#define read_dcc(x)    \
+               __asm__ volatile ("mrs %0, dbgdtrrx_el0\n" : "=r" (x))
+
+#define status_dcc(x)  \
+               __asm__ volatile ("mrs %0, mdccsr_el0\n" : "=r" (x))
+
 #else
 #define DCC_RBIT       (1 << 0)
 #define DCC_WBIT       (1 << 1)
 
 #define TIMEOUT_COUNT 0x4000000
 
-int arm_dcc_init(void)
+static int arm_dcc_init(void)
 {
        return 0;
 }
 
-int arm_dcc_getc(void)
+static int arm_dcc_getc(void)
 {
        int ch;
        register unsigned int reg;
@@ -107,7 +112,7 @@ int arm_dcc_getc(void)
        return ch;
 }
 
-void arm_dcc_putc(char ch)
+static void arm_dcc_putc(char ch)
 {
        register unsigned int reg;
        unsigned int timeout_count = TIMEOUT_COUNT;
@@ -123,13 +128,7 @@ void arm_dcc_putc(char ch)
                write_dcc(ch);
 }
 
-void arm_dcc_puts(const char *s)
-{
-       while (*s)
-               arm_dcc_putc(*s++);
-}
-
-int arm_dcc_tstc(void)
+static int arm_dcc_tstc(void)
 {
        register unsigned int reg;
 
@@ -138,27 +137,27 @@ int arm_dcc_tstc(void)
        return reg;
 }
 
-static struct stdio_dev arm_dcc_dev;
-
-int drv_arm_dcc_init(void)
+static void arm_dcc_setbrg(void)
 {
-       int rc;
-
-       /* Device initialization */
-       memset(&arm_dcc_dev, 0, sizeof(arm_dcc_dev));
-
-       strcpy(arm_dcc_dev.name, "dcc");
-       arm_dcc_dev.ext = 0;    /* No extensions */
-       arm_dcc_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_OUTPUT;
-       arm_dcc_dev.tstc = arm_dcc_tstc;        /* 'tstc' function */
-       arm_dcc_dev.getc = arm_dcc_getc;        /* 'getc' function */
-       arm_dcc_dev.putc = arm_dcc_putc;        /* 'putc' function */
-       arm_dcc_dev.puts = arm_dcc_puts;        /* 'puts' function */
+}
 
-       return stdio_register(&arm_dcc_dev);
+static struct serial_device arm_dcc_drv = {
+       .name   = "arm_dcc",
+       .start  = arm_dcc_init,
+       .stop   = NULL,
+       .setbrg = arm_dcc_setbrg,
+       .putc   = arm_dcc_putc,
+       .puts   = default_serial_puts,
+       .getc   = arm_dcc_getc,
+       .tstc   = arm_dcc_tstc,
+};
+
+void arm_dcc_initialize(void)
+{
+       serial_register(&arm_dcc_drv);
 }
 
 __weak struct serial_device *default_serial_console(void)
 {
-       return NULL;
+       return &arm_dcc_drv;
 }