2 * Copyright (C) 2004-2007 ARM Limited.
3 * Copyright (C) 2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * As a special exception, if other files instantiate templates or use macros
19 * or inline functions from this file, or you compile this file and link it
20 * with other works to produce a work based on this file, this file does not
21 * by itself cause the resulting work to be covered by the GNU General Public
22 * License. However the source code for this file must still be made available
23 * in accordance with section (3) of the GNU General Public License.
25 * This exception does not invalidate any other reasons why a work based on
26 * this file might be covered by the GNU General Public License.
32 #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V7)
36 #define DCC_RBIT (1 << 30)
37 #define DCC_WBIT (1 << 29)
39 #define write_dcc(x) \
40 __asm__ volatile ("mcr p14, 0, %0, c0, c5, 0\n" : : "r" (x))
43 __asm__ volatile ("mrc p14, 0, %0, c0, c5, 0\n" : "=r" (x))
45 #define status_dcc(x) \
46 __asm__ volatile ("mrc p14, 0, %0, c0, c1, 0\n" : "=r" (x))
48 #elif defined(CONFIG_CPU_XSCALE)
52 #define DCC_RBIT (1 << 31)
53 #define DCC_WBIT (1 << 28)
55 #define write_dcc(x) \
56 __asm__ volatile ("mcr p14, 0, %0, c8, c0, 0\n" : : "r" (x))
59 __asm__ volatile ("mrc p14, 0, %0, c9, c0, 0\n" : "=r" (x))
61 #define status_dcc(x) \
62 __asm__ volatile ("mrc p14, 0, %0, c14, c0, 0\n" : "=r" (x))
64 #elif defined(CONFIG_CPU_ARMV8)
68 #define DCC_RBIT (1 << 30)
69 #define DCC_WBIT (1 << 29)
71 #define write_dcc(x) \
72 __asm__ volatile ("msr dbgdtrtx_el0, %0\n" : : "r" (x))
75 __asm__ volatile ("mrs %0, dbgdtrrx_el0\n" : "=r" (x))
77 #define status_dcc(x) \
78 __asm__ volatile ("mrs %0, mdccsr_el0\n" : "=r" (x))
81 #define DCC_RBIT (1 << 0)
82 #define DCC_WBIT (1 << 1)
84 #define write_dcc(x) \
85 __asm__ volatile ("mcr p14, 0, %0, c1, c0, 0\n" : : "r" (x))
88 __asm__ volatile ("mrc p14, 0, %0, c1, c0, 0\n" : "=r" (x))
90 #define status_dcc(x) \
91 __asm__ volatile ("mrc p14, 0, %0, c0, c0, 0\n" : "=r" (x))
95 #define can_read_dcc(x) do { \
100 #define can_write_dcc(x) do { \
106 #define TIMEOUT_COUNT 0x4000000
108 static int arm_dcc_init(void)
113 static int arm_dcc_getc(void)
116 register unsigned int reg;
126 static void arm_dcc_putc(char ch)
128 register unsigned int reg;
129 unsigned int timeout_count = TIMEOUT_COUNT;
131 while (--timeout_count) {
136 if (timeout_count == 0)
142 static int arm_dcc_tstc(void)
144 register unsigned int reg;
151 static void arm_dcc_setbrg(void)
155 static struct serial_device arm_dcc_drv = {
157 .start = arm_dcc_init,
159 .setbrg = arm_dcc_setbrg,
160 .putc = arm_dcc_putc,
161 .puts = default_serial_puts,
162 .getc = arm_dcc_getc,
163 .tstc = arm_dcc_tstc,
166 void arm_dcc_initialize(void)
168 serial_register(&arm_dcc_drv);
171 __weak struct serial_device *default_serial_console(void)