2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/config.h>
21 #include <linux/linkage.h>
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <asm/gdb-stub.h>
25 #include <asm/rm9k-ocd.h>
28 #if defined(CONFIG_SERIAL_8250) && CONFIG_SERIAL_8250_NR_UARTS > 1
29 #error Debug port used by serial driver
32 #define UART_CLK 25000000
33 #define BASE_BAUD (UART_CLK / 16)
34 #define REGISTER_BASE_0 0x0208UL
35 #define REGISTER_BASE_1 0x0238UL
37 #define REGISTER_BASE_DBG REGISTER_BASE_1
42 #define UARBR (REGISTER_BASE_DBG + 0x0000)
43 #define UATHR (REGISTER_BASE_DBG + 0x0004)
44 #define UADLL (REGISTER_BASE_DBG + 0x0008)
45 #define UAIER (REGISTER_BASE_DBG + 0x000c)
46 #define UADLH (REGISTER_BASE_DBG + 0x0010)
47 #define UAIIR (REGISTER_BASE_DBG + 0x0014)
48 #define UAFCR (REGISTER_BASE_DBG + 0x0018)
49 #define UALCR (REGISTER_BASE_DBG + 0x001c)
50 #define UAMCR (REGISTER_BASE_DBG + 0x0020)
51 #define UALSR (REGISTER_BASE_DBG + 0x0024)
52 #define UAMSR (REGISTER_BASE_DBG + 0x0028)
53 #define UASCR (REGISTER_BASE_DBG + 0x002c)
56 #define PARITY_ODD 0x08
57 #define PARITY_EVEN 0x18
58 #define PARITY_MARK 0x28
59 #define PARITY_SPACE 0x38
69 #define BAUD_DBG 57600
70 #define PARITY_DBG PARITY_NONE
71 #define DATA_DBG DATA_8BIT
72 #define STOP_DBG STOP_1BIT
74 /* Initialize the serial port for KGDB debugging */
75 void __init excite_kgdb_init(void)
77 const u32 divisor = BASE_BAUD / BAUD_DBG;
79 /* Take the UART out of reset */
80 titan_writel(0x00ff1cff, CPRR);
81 titan_writel(0x00000000, UACFG);
82 titan_writel(0x00000002, UACFG);
84 titan_writel(0x0, UALCR);
85 titan_writel(0x0, UAIER);
88 titan_writel(0x00, UAFCR);
90 titan_writel(0x80, UALCR);
91 titan_writel(divisor & 0xff, UADLL);
92 titan_writel((divisor & 0xff00) >> 8, UADLH);
93 titan_writel(0x0, UALCR);
95 titan_writel(DATA_DBG | PARITY_DBG | STOP_DBG, UALCR);
97 /* Enable receiver interrupt */
99 titan_writel(0x1, UAIER);
102 int getDebugChar(void)
104 while (!(titan_readl(UALSR) & 0x1));
105 return titan_readl(UARBR);
108 int putDebugChar(int data)
110 while (!(titan_readl(UALSR) & 0x20));
111 titan_writel(data, UATHR);
115 /* KGDB interrupt handler */
116 asmlinkage void excite_kgdb_inthdl(struct pt_regs *regs)
119 ((titan_readl(UAIIR) & 0x7) == 4)
120 && ((titan_readl(UARBR) & 0xff) == 0x3)))
121 set_async_breakpoint(®s->cp0_epc);