xref: /linux/arch/arm/include/debug/renesas-scif.S (revision 7a2071c58f36450fbf44a27d2e5d371c18534a25)
1*7a2071c5SGeert Uytterhoeven/*
2*7a2071c5SGeert Uytterhoeven * Renesas SCIF(A) debugging macro include header
3*7a2071c5SGeert Uytterhoeven *
4*7a2071c5SGeert Uytterhoeven * Based on r8a7790.S
5*7a2071c5SGeert Uytterhoeven *
6*7a2071c5SGeert Uytterhoeven * Copyright (C) 2012-2013 Renesas Electronics Corporation
7*7a2071c5SGeert Uytterhoeven * Copyright (C) 1994-1999 Russell King
8*7a2071c5SGeert Uytterhoeven *
9*7a2071c5SGeert Uytterhoeven * This program is free software; you can redistribute it and/or modify
10*7a2071c5SGeert Uytterhoeven * it under the terms of the GNU General Public License version 2 as
11*7a2071c5SGeert Uytterhoeven * published by the Free Software Foundation.
12*7a2071c5SGeert Uytterhoeven */
13*7a2071c5SGeert Uytterhoeven
14*7a2071c5SGeert Uytterhoeven#define SCIF_PHYS	CONFIG_DEBUG_UART_PHYS
15*7a2071c5SGeert Uytterhoeven#define SCIF_VIRT	((SCIF_PHYS & 0x00ffffff) | 0xfd000000)
16*7a2071c5SGeert Uytterhoeven
17*7a2071c5SGeert Uytterhoeven#if CONFIG_DEBUG_UART_PHYS < 0xe6e00000
18*7a2071c5SGeert Uytterhoeven/* SCIFA */
19*7a2071c5SGeert Uytterhoeven#define FTDR		0x20
20*7a2071c5SGeert Uytterhoeven#define FSR		0x14
21*7a2071c5SGeert Uytterhoeven#else
22*7a2071c5SGeert Uytterhoeven/* SCIF */
23*7a2071c5SGeert Uytterhoeven#define FTDR		0x0c
24*7a2071c5SGeert Uytterhoeven#define FSR		0x10
25*7a2071c5SGeert Uytterhoeven#endif
26*7a2071c5SGeert Uytterhoeven
27*7a2071c5SGeert Uytterhoeven#define TDFE	(1 << 5)
28*7a2071c5SGeert Uytterhoeven#define TEND	(1 << 6)
29*7a2071c5SGeert Uytterhoeven
30*7a2071c5SGeert Uytterhoeven	.macro	addruart, rp, rv, tmp
31*7a2071c5SGeert Uytterhoeven	ldr	\rp, =SCIF_PHYS
32*7a2071c5SGeert Uytterhoeven	ldr	\rv, =SCIF_VIRT
33*7a2071c5SGeert Uytterhoeven	.endm
34*7a2071c5SGeert Uytterhoeven
35*7a2071c5SGeert Uytterhoeven	.macro	waituart, rd, rx
36*7a2071c5SGeert Uytterhoeven1001:	ldrh	\rd, [\rx, #FSR]
37*7a2071c5SGeert Uytterhoeven	tst	\rd, #TDFE
38*7a2071c5SGeert Uytterhoeven	beq	1001b
39*7a2071c5SGeert Uytterhoeven	.endm
40*7a2071c5SGeert Uytterhoeven
41*7a2071c5SGeert Uytterhoeven	.macro	senduart, rd, rx
42*7a2071c5SGeert Uytterhoeven	strb	\rd, [\rx, #FTDR]
43*7a2071c5SGeert Uytterhoeven	ldrh	\rd, [\rx, #FSR]
44*7a2071c5SGeert Uytterhoeven	bic	\rd, \rd, #TEND
45*7a2071c5SGeert Uytterhoeven	strh	\rd, [\rx, #FSR]
46*7a2071c5SGeert Uytterhoeven	.endm
47*7a2071c5SGeert Uytterhoeven
48*7a2071c5SGeert Uytterhoeven	.macro	busyuart, rd, rx
49*7a2071c5SGeert Uytterhoeven1001:	ldrh	\rd, [\rx, #FSR]
50*7a2071c5SGeert Uytterhoeven	tst	\rd, #TEND
51*7a2071c5SGeert Uytterhoeven	beq	1001b
52*7a2071c5SGeert Uytterhoeven	.endm
53