2 * Copyright (C) 2004-2007 ARM Limited.
3 * Copyright (C) 2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 * SPDX-License-Identifier: GPL-2.0
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.
21 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V7)
25 #define DCC_RBIT (1 << 30)
26 #define DCC_WBIT (1 << 29)
28 #define write_dcc(x) \
29 __asm__ volatile ("mcr p14, 0, %0, c0, c5, 0\n" : : "r" (x))
32 __asm__ volatile ("mrc p14, 0, %0, c0, c5, 0\n" : "=r" (x))
34 #define status_dcc(x) \
35 __asm__ volatile ("mrc p14, 0, %0, c0, c1, 0\n" : "=r" (x))
37 #elif defined(CONFIG_CPU_XSCALE)
41 #define DCC_RBIT (1 << 31)
42 #define DCC_WBIT (1 << 28)
44 #define write_dcc(x) \
45 __asm__ volatile ("mcr p14, 0, %0, c8, c0, 0\n" : : "r" (x))
48 __asm__ volatile ("mrc p14, 0, %0, c9, c0, 0\n" : "=r" (x))
50 #define status_dcc(x) \
51 __asm__ volatile ("mrc p14, 0, %0, c14, c0, 0\n" : "=r" (x))
53 #elif defined(CONFIG_CPU_ARMV8)
57 #define DCC_RBIT (1 << 30)
58 #define DCC_WBIT (1 << 29)
60 #define write_dcc(x) \
61 __asm__ volatile ("msr dbgdtrtx_el0, %0\n" : : "r" (x))
64 __asm__ volatile ("mrs %0, dbgdtrrx_el0\n" : "=r" (x))
66 #define status_dcc(x) \
67 __asm__ volatile ("mrs %0, mdccsr_el0\n" : "=r" (x))
70 #define DCC_RBIT (1 << 0)
71 #define DCC_WBIT (1 << 1)
73 #define write_dcc(x) \
74 __asm__ volatile ("mcr p14, 0, %0, c1, c0, 0\n" : : "r" (x))
77 __asm__ volatile ("mrc p14, 0, %0, c1, c0, 0\n" : "=r" (x))
79 #define status_dcc(x) \
80 __asm__ volatile ("mrc p14, 0, %0, c0, c0, 0\n" : "=r" (x))
84 #define can_read_dcc(x) do { \
89 #define can_write_dcc(x) do { \
95 #define TIMEOUT_COUNT 0x4000000
97 static int arm_dcc_init(void)
102 static int arm_dcc_getc(void)
105 register unsigned int reg;
115 static void arm_dcc_putc(char ch)
117 register unsigned int reg;
118 unsigned int timeout_count = TIMEOUT_COUNT;
120 while (--timeout_count) {
125 if (timeout_count == 0)
131 static int arm_dcc_tstc(void)
133 register unsigned int reg;
140 static void arm_dcc_setbrg(void)
144 static struct serial_device arm_dcc_drv = {
146 .start = arm_dcc_init,
148 .setbrg = arm_dcc_setbrg,
149 .putc = arm_dcc_putc,
150 .puts = default_serial_puts,
151 .getc = arm_dcc_getc,
152 .tstc = arm_dcc_tstc,
155 void arm_dcc_initialize(void)
157 serial_register(&arm_dcc_drv);
160 __weak struct serial_device *default_serial_console(void)