Here's the KGDB serial driver for the Alchemy SOC based boards. The baudrate is
configurable; however, the port number is not, always being designated DBAU1xx0
boards' "debug" UART, i.e. UART1 for Au1200 SOC and UART3 on other SOCs. Also,
there is no aynchronous breakpoint support (due to IRQ numbers changing with
each UART :-).
Signed-off-by: Konstantin Baydarov <[EMAIL PROTECTED]>
Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>
---
The patch is against the linux2_6_24_uprev branch.
The driver works for the kernels *before* 2.6.24 -- that version has uncovered
a big issue with MIPS KGDB port due to that continuing from an early breakpoint
locks the machine up. As a workaround for now, replace cal_r4koff() call with
'return -1' -- that way at least the late breakpoints work...
drivers/serial/Makefile | 1
drivers/serial/au1x00_kgdb.c | 95 +++++++++++++++++++++++++++++++++++++++++++
lib/Kconfig.kgdb | 9 +++-
3 files changed, 104 insertions(+), 1 deletion(-)
Index: linux-2.6/drivers/serial/Makefile
===================================================================
--- linux-2.6.orig/drivers/serial/Makefile
+++ linux-2.6/drivers/serial/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554)
obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o
+obj-$(CONFIG_KGDB_AU1X00) += au1x00_kgdb.o
obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
obj-$(CONFIG_KGDB_AMBA_PL011) += pl011_kgdb.o
Index: linux-2.6/drivers/serial/au1x00_kgdb.c
===================================================================
--- /dev/null
+++ linux-2.6/drivers/serial/au1x00_kgdb.c
@@ -0,0 +1,95 @@
+/*
+ * drivers/serial/au1x00_kgdb.c
+ * Based on arch/mips/au1000/common/dbg_io.c
+ *
+ * KGDB interface for gdb
+ *
+ * Author: MontaVista Software, Inc. <[EMAIL PROTECTED]>
+ *
+ * Copyright 2005-2006, 2008 MontaVista Software Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/kgdb.h>
+#include <asm/mach-au1x00/au1000.h>
+
+/* memory-mapped read/write of the port */
+#define UART_READ(reg) (au_readl (UART_DEBUG_BASE + reg))
+#define UART_WRITE(reg,val) (au_writel(val, UART_DEBUG_BASE + reg))
+
+unsigned long cal_r4koff(void);
+
+static void au1x00_uart_init(void)
+{
+ u32 divisor = get_au1x00_uart_baud_base() / CONFIG_KGDB_BAUDRATE;
+
+ if (UART_READ(UART_MOD_CNTRL) != (UART_MCR_DTR | UART_MCR_RTS))
+ UART_WRITE(UART_MOD_CNTRL, UART_MCR_DTR | UART_MCR_RTS);
+
+ /* disable interrupts */
+ UART_WRITE(UART_IER, 0);
+
+ /* set up baud rate */
+ UART_WRITE(UART_CLK, divisor & 0xffff);
+
+ /* set data format */
+ UART_WRITE(UART_LCR, UART_LCR_WLEN8);
+}
+
+static int au1x00_kgdb_init(void)
+{
+ /*
+ * If the CPU clock from which UART clock derives hasn't been
+ * calculated yet, do it now...
+ */
+ if (!get_au1x00_uart_baud_base())
+ cal_r4koff();
+
+ au1x00_uart_init();
+
+ return 0;
+}
+
+static void au1x00_kgdb_late_init(void)
+{
+#ifdef CONFIG_SERIAL_8250_AU1X00
+ struct uart_port port = {
+ .iotype = UPIO_AU,
+ .mapbase = CPHYSADDR(UART_DEBUG_BASE)
+ };
+
+ /* Take the port away from the main driver. */
+ serial8250_unregister_by_port(&port);
+
+ /* Now reinit the port as the above has disabled things. */
+ au1x00_uart_init();
+#endif
+ request_mem_region(CPHYSADDR(UART_DEBUG_BASE), 0x100000,
+ "Au1x00 UART(debug)");
+}
+
+static int au1x00_kgdb_read_char(void)
+{
+ while (!(UART_READ(UART_LSR) & UART_LSR_DR));
+
+ return UART_READ(UART_RX) & 0xff;
+}
+
+
+static void au1x00_kgdb_write_char(u8 byte)
+{
+ while (!(UART_READ(UART_LSR) & UART_LSR_TEMT));
+
+ UART_WRITE(UART_TX, byte);
+}
+
+struct kgdb_io kgdb_io_ops = {
+ .read_char = au1x00_kgdb_read_char,
+ .write_char = au1x00_kgdb_write_char,
+ .init = au1x00_kgdb_init,
+ .late_init = au1x00_kgdb_late_init
+};
Index: linux-2.6/lib/Kconfig.kgdb
===================================================================
--- linux-2.6.orig/lib/Kconfig.kgdb
+++ linux-2.6/lib/Kconfig.kgdb
@@ -44,6 +44,7 @@ choice
default KGDB_CPM_UART if (CPM2 || 8xx)
default KGDB_SIBYTE if SIBYTE_SB1xxx_SOC
default KGDB_TXX9 if CPU_TX49XX
+ default KGDB_AU1X00 if SOC_AU1X00
default KGDB_SH_SCI if SERIAL_SH_SCI
default KGDB_PXA_SERIAL if ARCH_PXA
default KGDB_AMBA_PL011 if ARM_AMBA
@@ -108,6 +109,12 @@ config KGDB_TXX9
help
Uses TX49xx serial port to communicate with the host GDB.
+config KGDB_AU1X00
+ bool "KGDB: On Au1x00 serial port"
+ depends on SOC_AU1X00
+ help
+ Uses Au1x00 serial port to communicate with the host GDB.
+
config KGDB_SH_SCI
bool "KGDB: On SH SCI(F) serial port"
depends on SUPERH && SERIAL_SH_SCI
@@ -209,7 +216,7 @@ config KGDB_BAUDRATE
int "Debug serial port baud rate"
depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || \
KGDB_MPSC || KGDB_CPM_UART || \
- KGDB_TXX9 || KGDB_PXA_SERIAL || KGDB_AMBA_PL011
+ KGDB_TXX9 || KGDB_AU1X00 || KGDB_PXA_SERIAL || KGDB_AMBA_PL011
default "115200"
help
gdb and the kernel stub need to agree on the baud rate to be
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport