2 * Copyright (C) 2004-2007 ARM Limited.
3 * Copyright (C) 2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
4 * Copyright (C) 2015 - 2016 Xilinx, Inc, Michal Simek
6 * SPDX-License-Identifier: GPL-2.0
8 * As a special exception, if other files instantiate templates or use macros
9 * or inline functions from this file, or you compile this file and link it
10 * with other works to produce a work based on this file, this file does not
11 * by itself cause the resulting work to be covered by the GNU General Public
12 * License. However the source code for this file must still be made available
13 * in accordance with section (3) of the GNU General Public License.
15 * This exception does not invalidate any other reasons why a work based on
16 * this file might be covered by the GNU General Public License.
23 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V7)
27 #define DCC_RBIT (1 << 30)
28 #define DCC_WBIT (1 << 29)
30 #define write_dcc(x) \
31 __asm__ volatile ("mcr p14, 0, %0, c0, c5, 0\n" : : "r" (x))
34 __asm__ volatile ("mrc p14, 0, %0, c0, c5, 0\n" : "=r" (x))
36 #define status_dcc(x) \
37 __asm__ volatile ("mrc p14, 0, %0, c0, c1, 0\n" : "=r" (x))
39 #elif defined(CONFIG_CPU_XSCALE)
43 #define DCC_RBIT (1 << 31)
44 #define DCC_WBIT (1 << 28)
46 #define write_dcc(x) \
47 __asm__ volatile ("mcr p14, 0, %0, c8, c0, 0\n" : : "r" (x))
50 __asm__ volatile ("mrc p14, 0, %0, c9, c0, 0\n" : "=r" (x))
52 #define status_dcc(x) \
53 __asm__ volatile ("mrc p14, 0, %0, c14, c0, 0\n" : "=r" (x))
55 #elif defined(CONFIG_CPU_ARMV8)
59 #define DCC_RBIT (1 << 30)
60 #define DCC_WBIT (1 << 29)
62 #define write_dcc(x) \
63 __asm__ volatile ("msr dbgdtrtx_el0, %0\n" : : "r" (x))
66 __asm__ volatile ("mrs %0, dbgdtrrx_el0\n" : "=r" (x))
68 #define status_dcc(x) \
69 __asm__ volatile ("mrs %0, mdccsr_el0\n" : "=r" (x))
72 #define DCC_RBIT (1 << 0)
73 #define DCC_WBIT (1 << 1)
75 #define write_dcc(x) \
76 __asm__ volatile ("mcr p14, 0, %0, c1, c0, 0\n" : : "r" (x))
79 __asm__ volatile ("mrc p14, 0, %0, c1, c0, 0\n" : "=r" (x))
81 #define status_dcc(x) \
82 __asm__ volatile ("mrc p14, 0, %0, c0, c0, 0\n" : "=r" (x))
86 #define can_read_dcc(x) do { \
91 #define can_write_dcc(x) do { \
97 #define TIMEOUT_COUNT 0x4000000
99 static int arm_dcc_getc(struct udevice *dev)
102 register unsigned int reg;
112 static int arm_dcc_putc(struct udevice *dev, char ch)
114 register unsigned int reg;
115 unsigned int timeout_count = TIMEOUT_COUNT;
117 while (--timeout_count) {
122 if (timeout_count == 0)
130 static int arm_dcc_pending(struct udevice *dev, bool input)
132 register unsigned int reg;
143 static const struct dm_serial_ops arm_dcc_ops = {
144 .putc = arm_dcc_putc,
145 .pending = arm_dcc_pending,
146 .getc = arm_dcc_getc,
149 static const struct udevice_id arm_dcc_ids[] = {
150 { .compatible = "arm,dcc", },
154 U_BOOT_DRIVER(serial_dcc) = {
157 .of_match = arm_dcc_ids,
159 .flags = DM_FLAG_PRE_RELOC,
162 #ifdef CONFIG_DEBUG_UART_ARM_DCC
164 #include <debug_uart.h>
166 static inline void _debug_uart_init(void)
170 static inline void _debug_uart_putc(int ch)
172 arm_dcc_putc(NULL, ch);