1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2004-2007 ARM Limited.
4 * Copyright (C) 2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 * Copyright (C) 2015 - 2016 Xilinx, Inc, Michal Simek
7 * As a special exception, if other files instantiate templates or use macros
8 * or inline functions from this file, or you compile this file and link it
9 * with other works to produce a work based on this file, this file does not
10 * by itself cause the resulting work to be covered by the GNU General Public
11 * License. However the source code for this file must still be made available
12 * in accordance with section (3) of the GNU General Public License.
14 * This exception does not invalidate any other reasons why a work based on
15 * this file might be covered by the GNU General Public License.
22 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V7A) || defined(CONFIG_CPU_V7R)
26 #define DCC_RBIT (1 << 30)
27 #define DCC_WBIT (1 << 29)
29 #define write_dcc(x) \
30 __asm__ volatile ("mcr p14, 0, %0, c0, c5, 0\n" : : "r" (x))
33 __asm__ volatile ("mrc p14, 0, %0, c0, c5, 0\n" : "=r" (x))
35 #define status_dcc(x) \
36 __asm__ volatile ("mrc p14, 0, %0, c0, c1, 0\n" : "=r" (x))
38 #elif defined(CONFIG_CPU_XSCALE)
42 #define DCC_RBIT (1 << 31)
43 #define DCC_WBIT (1 << 28)
45 #define write_dcc(x) \
46 __asm__ volatile ("mcr p14, 0, %0, c8, c0, 0\n" : : "r" (x))
49 __asm__ volatile ("mrc p14, 0, %0, c9, c0, 0\n" : "=r" (x))
51 #define status_dcc(x) \
52 __asm__ volatile ("mrc p14, 0, %0, c14, c0, 0\n" : "=r" (x))
54 #elif defined(CONFIG_CPU_ARMV8)
58 #define DCC_RBIT (1 << 30)
59 #define DCC_WBIT (1 << 29)
61 #define write_dcc(x) \
62 __asm__ volatile ("msr dbgdtrtx_el0, %0\n" : : "r" (x))
65 __asm__ volatile ("mrs %0, dbgdtrrx_el0\n" : "=r" (x))
67 #define status_dcc(x) \
68 __asm__ volatile ("mrs %0, mdccsr_el0\n" : "=r" (x))
71 #define DCC_RBIT (1 << 0)
72 #define DCC_WBIT (1 << 1)
74 #define write_dcc(x) \
75 __asm__ volatile ("mcr p14, 0, %0, c1, c0, 0\n" : : "r" (x))
78 __asm__ volatile ("mrc p14, 0, %0, c1, c0, 0\n" : "=r" (x))
80 #define status_dcc(x) \
81 __asm__ volatile ("mrc p14, 0, %0, c0, c0, 0\n" : "=r" (x))
85 #define can_read_dcc(x) do { \
90 #define can_write_dcc(x) do { \
96 #define TIMEOUT_COUNT 0x4000000
98 static int arm_dcc_getc(struct udevice *dev)
101 register unsigned int reg;
111 static int arm_dcc_putc(struct udevice *dev, char ch)
113 register unsigned int reg;
114 unsigned int timeout_count = TIMEOUT_COUNT;
116 while (--timeout_count) {
121 if (timeout_count == 0)
129 static int arm_dcc_pending(struct udevice *dev, bool input)
131 register unsigned int reg;
142 static const struct dm_serial_ops arm_dcc_ops = {
143 .putc = arm_dcc_putc,
144 .pending = arm_dcc_pending,
145 .getc = arm_dcc_getc,
148 static const struct udevice_id arm_dcc_ids[] = {
149 { .compatible = "arm,dcc", },
153 U_BOOT_DRIVER(serial_dcc) = {
156 .of_match = arm_dcc_ids,
158 .flags = DM_FLAG_PRE_RELOC,
161 #ifdef CONFIG_DEBUG_UART_ARM_DCC
163 #include <debug_uart.h>
165 static inline void _debug_uart_init(void)
169 static inline void _debug_uart_putc(int ch)
171 arm_dcc_putc(NULL, ch);