xref: /openbmc/linux/arch/arm/include/asm/dcc.h (revision 4061f498)
14061f498SChristopher Covington /* Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved.
24061f498SChristopher Covington  *
34061f498SChristopher Covington  * This program is free software; you can redistribute it and/or modify
44061f498SChristopher Covington  * it under the terms of the GNU General Public License version 2 and
54061f498SChristopher Covington  * only version 2 as published by the Free Software Foundation.
64061f498SChristopher Covington  *
74061f498SChristopher Covington  * This program is distributed in the hope that it will be useful,
84061f498SChristopher Covington  * but WITHOUT ANY WARRANTY; without even the implied warranty of
94061f498SChristopher Covington  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
104061f498SChristopher Covington  * GNU General Public License for more details.
114061f498SChristopher Covington  */
124061f498SChristopher Covington 
134061f498SChristopher Covington #include <asm/barrier.h>
144061f498SChristopher Covington 
154061f498SChristopher Covington static inline u32 __dcc_getstatus(void)
164061f498SChristopher Covington {
174061f498SChristopher Covington 	u32 __ret;
184061f498SChristopher Covington 	asm volatile("mrc p14, 0, %0, c0, c1, 0	@ read comms ctrl reg"
194061f498SChristopher Covington 		: "=r" (__ret) : : "cc");
204061f498SChristopher Covington 
214061f498SChristopher Covington 	return __ret;
224061f498SChristopher Covington }
234061f498SChristopher Covington 
244061f498SChristopher Covington static inline char __dcc_getchar(void)
254061f498SChristopher Covington {
264061f498SChristopher Covington 	char __c;
274061f498SChristopher Covington 
284061f498SChristopher Covington 	asm volatile("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg"
294061f498SChristopher Covington 		: "=r" (__c));
304061f498SChristopher Covington 	isb();
314061f498SChristopher Covington 
324061f498SChristopher Covington 	return __c;
334061f498SChristopher Covington }
344061f498SChristopher Covington 
354061f498SChristopher Covington static inline void __dcc_putchar(char c)
364061f498SChristopher Covington {
374061f498SChristopher Covington 	asm volatile("mcr p14, 0, %0, c0, c5, 0	@ write a char"
384061f498SChristopher Covington 		: /* no output register */
394061f498SChristopher Covington 		: "r" (c));
404061f498SChristopher Covington 	isb();
414061f498SChristopher Covington }
42