Update KGDB serial driver for Toshiba TX49xx:
- rename it according to the new convention, with _kgdb prefix;
- enable support for the new baud rate option, removing the obsolete #ifdef
cruft;
- enable support for the serial port selection;
- fix write_char method to accept 'u8' arg;
- rename some variables/functions;
- get rid of #ifdef CONFIG_TOSHIBA_RBTX4939 (this platform isn't supported in
the mainline anyway) but make the driver support 4 UARTs instead of 2 max.
While at it, fix Kconfig option description/help for both this driver and
Broadcom SB1xxx...
Signed-off-by: Sergey Shtylyov <[EMAIL PROTECTED]>
---
This patch is against linux2_6_21_uprev branch...
drivers/serial/kgdb_serial_txx9.c | 168 -------------
arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c | 4
arch/mips/tx4938/toshiba_rbtx4938/setup.c | 4
drivers/serial/Makefile | 2
drivers/serial/serial_txx9.c | 13 -
drivers/serial/serial_txx9_kgdb.c | 150 +++++++++++
lib/Kconfig.kgdb | 11
7 files changed, 165 insertions(+), 187 deletions(-)
Index: linux-2.6/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
===================================================================
--- linux-2.6.orig/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ linux-2.6/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
@@ -976,7 +976,7 @@ void __init toshiba_rbtx4927_setup(void)
#if defined (CONFIG_SERIAL_TXX9) || defined(CONFIG_KGDB_TXX9)
{
extern int early_serial_txx9_setup(struct uart_port *port);
- extern int kgdb_serial_txx9_setup(struct uart_port *port, int
num);
+ extern int txx9_kgdb_add_port(int n, struct uart_port *port);
int i;
struct uart_port req;
for(i = 0; i < 2; i++) {
@@ -992,7 +992,7 @@ void __init toshiba_rbtx4927_setup(void)
early_serial_txx9_setup(&req);
#endif
#ifdef CONFIG_KGDB_TXX9
- kgdb_serial_txx9_setup(&req, i);
+ txx9_kgdb_add_port(i, &req);
#endif
}
}
Index: linux-2.6/arch/mips/tx4938/toshiba_rbtx4938/setup.c
===================================================================
--- linux-2.6.orig/arch/mips/tx4938/toshiba_rbtx4938/setup.c
+++ linux-2.6/arch/mips/tx4938/toshiba_rbtx4938/setup.c
@@ -926,7 +926,7 @@ void __init toshiba_rbtx4938_setup(void)
#if defined (CONFIG_SERIAL_TXX9) || defined (CONFIG_KGDB_TXX9)
{
extern int early_serial_txx9_setup(struct uart_port *port);
- extern int kgdb_serial_txx9_setup(struct uart_port *port, int
num);
+ extern int txx9_kgdb_add_port(int n, struct uart_port *port);
int i;
struct uart_port req;
for(i = 0; i < 2; i++) {
@@ -942,7 +942,7 @@ void __init toshiba_rbtx4938_setup(void)
early_serial_txx9_setup(&req);
#endif
#ifdef CONFIG_KGDB_TXX9
- kgdb_serial_txx9_setup(&req, i);
+ txx9_kgdb_add_port(i, &req);
#endif
}
}
Index: linux-2.6/drivers/serial/kgdb_serial_txx9.c
===================================================================
--- linux-2.6.orig/drivers/serial/kgdb_serial_txx9.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * drivers/serial/kgdb_serial_txx9.c
- *
- * kgdb interface for gdb
- *
- * Author: MontaVista Software, Inc.
- * [EMAIL PROTECTED]
- *
- * Copyright 2005-2006 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/delay.h>
-#include <linux/init.h>
-#include <linux/kgdb.h>
-#include <asm/io.h>
-
-/* Speed of the UART. */
-#if defined(CONFIG_KGDB_9600BAUD)
-static unsigned int kgdb_txx9_baud = 9600;
-#elif defined(CONFIG_KGDB_19200BAUD)
-static unsigned int kgdb_txx9_baud = 19200;
-#elif defined(CONFIG_KGDB_38400BAUD)
-static unsigned int kgdb_txx9_baud = 38400;
-#elif defined(CONFIG_KGDB_57600BAUD)
-static unsigned int kgdb_txx9_baud = 57600;
-#else
-static unsigned int kgdb_txx9_baud = 115200; /* Start with this if not given */
-#endif
-
-int kgdb_txx9_ttyS = 1;
-
-#if defined(CONFIG_TOSHIBA_RBTX4939)
-#define TXX9_NPORT 4
-#else
-#define TXX9_NPORT 2
-#endif
-
-static struct uart_port uart_txx9_port[TXX9_NPORT];
-
-/* TXX9 Serial Registers */
-#define TXX9_SILCR 0x00
-#define TXX9_SIDISR 0x08
-#define TXX9_SISCISR 0x0c
-#define TXX9_SIFCR 0x10
-#define TXX9_SIFLCR 0x14
-#define TXX9_SIBGR 0x18
-#define TXX9_SITFIFO 0x1c
-#define TXX9_SIRFIFO 0x20
-
-/* SILCR : Line Control */
-#define TXX9_SILCR_SCS_IMCLK_BG 0x00000020
-#define TXX9_SILCR_SCS_SCLK_BG 0x00000060
-#define TXX9_SILCR_USBL_1BIT 0x00000000
-#define TXX9_SILCR_UMODE_8BIT 0x00000000
-
-/* SIDISR : DMA/Int. Status */
-#define TXX9_SIDISR_RFDN_MASK 0x0000001f
-
-/* SISCISR : Status Change Int. Status */
-#define TXX9_SISCISR_TRDY 0x00000004
-
-/* SIFCR : FIFO Control */
-#define TXX9_SIFCR_SWRST 0x00008000
-
-/* SIBGR : Baud Rate Control */
-#define TXX9_SIBGR_BCLK_T0 0x00000000
-#define TXX9_SIBGR_BCLK_T2 0x00000100
-#define TXX9_SIBGR_BCLK_T4 0x00000200
-#define TXX9_SIBGR_BCLK_T6 0x00000300
-
-static inline unsigned int sio_in(struct uart_port *port, int offset)
-{
- return *(volatile u32 *)(port->membase + offset);
-}
-
-static inline void sio_out(struct uart_port *port, int offset, unsigned int
value)
-{
- *(volatile u32 *)(port->membase + offset) = value;
-}
-
-void kgdb_serial_txx9_setup(struct uart_port *port, int num)
-{
- memcpy(&uart_txx9_port[num], port, sizeof(struct uart_port));
-}
-
-static int txx9_sio_kgdb_init(void)
-{
- struct uart_port *port = &uart_txx9_port[kgdb_txx9_ttyS];
- unsigned int quot, sibgr;
-
- if (port->iotype != UPIO_MEM && port->iotype != UPIO_MEM32)
- return -1;
-
- /* Reset the UART. */
- sio_out(port, TXX9_SIFCR, TXX9_SIFCR_SWRST);
-#ifdef CONFIG_CPU_TX49XX
- /*
- * TX4925 BUG WORKAROUND. Accessing SIOC register
- * immediately after soft reset causes bus error.
- */
- iob();
- udelay(1);
-#endif
- /* Wait until reset is complete. */
- while (sio_in(port, TXX9_SIFCR) & TXX9_SIFCR_SWRST);
-
- /* Select the frame format and input clock. */
- sio_out(port, TXX9_SILCR,
- TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT |
- ((port->flags & UPF_MAGIC_MULTIPLIER) ?
- TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG));
-
- /* Select the input clock prescaler that fits the baud rate. */
- quot = (port->uartclk + 8 * kgdb_txx9_baud) / (16 * kgdb_txx9_baud);
- if (quot < (256 << 1))
- sibgr = (quot >> 1) | TXX9_SIBGR_BCLK_T0;
- else if (quot < ( 256 << 3))
- sibgr = (quot >> 3) | TXX9_SIBGR_BCLK_T2;
- else if (quot < ( 256 << 5))
- sibgr = (quot >> 5) | TXX9_SIBGR_BCLK_T4;
- else if (quot < ( 256 << 7))
- sibgr = (quot >> 7) | TXX9_SIBGR_BCLK_T6;
- else
- sibgr = 0xff | TXX9_SIBGR_BCLK_T6;
-
- sio_out(port, TXX9_SIBGR, sibgr);
-
- /* Enable receiver and transmitter. */
- sio_out(port, TXX9_SIFLCR, 0);
-
- return 0;
-}
-
-static void txx9_sio_kgdb_late_init(void)
-{
- request_mem_region(uart_txx9_port[kgdb_txx9_ttyS].mapbase, 0x40,
- "serial_txx9(debug)");
-}
-
-static int txx9_sio_kgdb_read(void)
-{
- struct uart_port *port = &uart_txx9_port[kgdb_txx9_ttyS];
-
- while (!(sio_in(port, TXX9_SIDISR) & TXX9_SIDISR_RFDN_MASK));
-
- return sio_in(port, TXX9_SIRFIFO);
-}
-
-static void txx9_sio_kgdb_write(int ch)
-{
- struct uart_port *port = &uart_txx9_port[kgdb_txx9_ttyS];
-
- while (!(sio_in(port, TXX9_SISCISR) & TXX9_SISCISR_TRDY));
-
- sio_out(port, TXX9_SITFIFO, ch);
-}
-
-struct kgdb_io kgdb_io_ops = {
- .read_char = txx9_sio_kgdb_read,
- .write_char = txx9_sio_kgdb_write,
- .init = txx9_sio_kgdb_init,
- .late_init = txx9_sio_kgdb_late_init
-};
Index: linux-2.6/drivers/serial/Makefile
===================================================================
--- linux-2.6.orig/drivers/serial/Makefile
+++ linux-2.6/drivers/serial/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_SERIAL_MPSC) += mpsc.o
obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o
obj-$(CONFIG_SERIAL_JSM) += jsm/
obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o
+obj-$(CONFIG_KGDB_TXX9) += serial_txx9_kgdb.o
obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
@@ -63,4 +64,3 @@ obj-$(CONFIG_SERIAL_UARTLITE) += uartlit
obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
obj-$(CONFIG_KGDB_8250) += 8250_kgdb.o
-obj-$(CONFIG_KGDB_TXX9) += kgdb_serial_txx9.o
Index: linux-2.6/drivers/serial/serial_txx9.c
===================================================================
--- linux-2.6.orig/drivers/serial/serial_txx9.c
+++ linux-2.6/drivers/serial/serial_txx9.c
@@ -65,11 +65,8 @@
static char *serial_version = "1.08";
static char *serial_name = "TX39/49 Serial driver";
-#ifdef CONFIG_KGDB_TXX9
-extern int kgdb_txx9_ttyS;
-#else
-/* Stubs for when KGDB_TXX9 is not set. */
-#define kgdb_txx9_ttyS -1
+#ifndef CONFIG_KGDB_TXX9
+#define CONFIG_KGDB_PORT_NUM -1
#endif
#define PASS_LIMIT 256
@@ -502,7 +499,7 @@ static int serial_txx9_startup(struct ua
unsigned long flags;
int retval;
- if (up->port.line == kgdb_txx9_ttyS)
+ if (up->port.line == CONFIG_KGDB_PORT_NUM)
return -EBUSY;
/*
@@ -833,7 +830,7 @@ static void __init serial_txx9_register_
for (i = 0; i < UART_NR; i++) {
struct uart_txx9_port *up = &serial_txx9_ports[i];
- if (up->port.line == kgdb_txx9_ttyS)
+ if (up->port.line == CONFIG_KGDB_PORT_NUM)
continue;
up->port.line = i;
@@ -1004,7 +1001,7 @@ static int __devinit serial_txx9_registe
mutex_lock(&serial_txx9_mutex);
for (i = 0; i < UART_NR; i++) {
- if (i == kgdb_txx9_ttyS)
+ if (i == CONFIG_KGDB_PORT_NUM)
continue;
uart = &serial_txx9_ports[i];
Index: linux-2.6/drivers/serial/serial_txx9_kgdb.c
===================================================================
--- /dev/null
+++ linux-2.6/drivers/serial/serial_txx9_kgdb.c
@@ -0,0 +1,150 @@
+/*
+ * drivers/serial/serial_txx9_kgdb.c
+ *
+ * kgdb interface for gdb
+ *
+ * Author: MontaVista Software, Inc.
+ * [EMAIL PROTECTED]
+ *
+ * Copyright (C) 2005-2006 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/delay.h>
+#include <linux/init.h>
+#include <linux/kgdb.h>
+#include <asm/io.h>
+
+/* Speed of the UART. */
+static unsigned int kgdb_txx9_baud = CONFIG_KGDB_BAUDRATE;
+
+#define TXX9_NPORT 4 /* TX4939 has 4 UARTs, others only have 2 */
+
+static struct uart_port kgdb_txx9_ports[TXX9_NPORT];
+static struct uart_port *kgdb_port;
+
+/* TXX9 Serial Registers */
+#define TXX9_SILCR 0x00
+#define TXX9_SIDISR 0x08
+#define TXX9_SISCISR 0x0c
+#define TXX9_SIFCR 0x10
+#define TXX9_SIFLCR 0x14
+#define TXX9_SIBGR 0x18
+#define TXX9_SITFIFO 0x1c
+#define TXX9_SIRFIFO 0x20
+
+/* SILCR : Line Control */
+#define TXX9_SILCR_SCS_IMCLK_BG 0x00000020
+#define TXX9_SILCR_SCS_SCLK_BG 0x00000060
+#define TXX9_SILCR_USBL_1BIT 0x00000000
+#define TXX9_SILCR_UMODE_8BIT 0x00000000
+
+/* SIDISR : DMA/Int. Status */
+#define TXX9_SIDISR_RFDN_MASK 0x0000001f
+
+/* SISCISR : Status Change Int. Status */
+#define TXX9_SISCISR_TRDY 0x00000004
+
+/* SIFCR : FIFO Control */
+#define TXX9_SIFCR_SWRST 0x00008000
+
+/* SIBGR : Baud Rate Control */
+#define TXX9_SIBGR_BCLK_T0 0x00000000
+#define TXX9_SIBGR_BCLK_T2 0x00000100
+#define TXX9_SIBGR_BCLK_T4 0x00000200
+#define TXX9_SIBGR_BCLK_T6 0x00000300
+
+static inline unsigned int sio_in(struct uart_port *port, int offset)
+{
+ return *(volatile u32 *)(port->membase + offset);
+}
+
+static inline void sio_out(struct uart_port *port, int offset, unsigned int
value)
+{
+ *(volatile u32 *)(port->membase + offset) = value;
+}
+
+void __init txx9_kgdb_add_port(int n, struct uart_port *port)
+{
+ memcpy(&kgdb_txx9_ports[n], port, sizeof(struct uart_port));
+}
+
+static int txx9_kgdb_init(void)
+{
+ unsigned int quot, sibgr;
+
+ kgdb_port = &kgdb_txx9_ports[CONFIG_KGDB_PORT_NUM];
+
+ if (kgdb_port->iotype != UPIO_MEM &&
+ kgdb_port->iotype != UPIO_MEM32)
+ return -1;
+
+ /* Reset the UART. */
+ sio_out(kgdb_port, TXX9_SIFCR, TXX9_SIFCR_SWRST);
+#ifdef CONFIG_CPU_TX49XX
+ /*
+ * TX4925 BUG WORKAROUND. Accessing SIOC register
+ * immediately after soft reset causes bus error.
+ */
+ iob();
+ udelay(1);
+#endif
+ /* Wait until reset is complete. */
+ while (sio_in(kgdb_port, TXX9_SIFCR) & TXX9_SIFCR_SWRST);
+
+ /* Select the frame format and input clock. */
+ sio_out(kgdb_port, TXX9_SILCR,
+ TXX9_SILCR_UMODE_8BIT | TXX9_SILCR_USBL_1BIT |
+ ((kgdb_port->flags & UPF_MAGIC_MULTIPLIER) ?
+ TXX9_SILCR_SCS_SCLK_BG : TXX9_SILCR_SCS_IMCLK_BG));
+
+ /* Select the input clock prescaler that fits the baud rate. */
+ quot = (kgdb_port->uartclk + 8 * kgdb_txx9_baud) / (16 *
kgdb_txx9_baud);
+ if (quot < (256 << 1))
+ sibgr = (quot >> 1) | TXX9_SIBGR_BCLK_T0;
+ else if (quot < ( 256 << 3))
+ sibgr = (quot >> 3) | TXX9_SIBGR_BCLK_T2;
+ else if (quot < ( 256 << 5))
+ sibgr = (quot >> 5) | TXX9_SIBGR_BCLK_T4;
+ else if (quot < ( 256 << 7))
+ sibgr = (quot >> 7) | TXX9_SIBGR_BCLK_T6;
+ else
+ sibgr = 0xff | TXX9_SIBGR_BCLK_T6;
+
+ sio_out(kgdb_port, TXX9_SIBGR, sibgr);
+
+ /* Enable receiver and transmitter. */
+ sio_out(kgdb_port, TXX9_SIFLCR, 0);
+
+ return 0;
+}
+
+static void txx9_kgdb_late_init(void)
+{
+ request_mem_region(kgdb_port->mapbase, 0x40, "serial_txx9(debug)");
+}
+
+static int txx9_kgdb_read(void)
+{
+ while (!(sio_in(kgdb_port, TXX9_SIDISR) & TXX9_SIDISR_RFDN_MASK));
+
+ return sio_in(kgdb_port, TXX9_SIRFIFO);
+}
+
+static void txx9_kgdb_write(u8 ch)
+{
+ while (!(sio_in(kgdb_port, TXX9_SISCISR) & TXX9_SISCISR_TRDY));
+
+ sio_out(kgdb_port, TXX9_SITFIFO, ch);
+}
+
+struct kgdb_io kgdb_io_ops = {
+ .read_char = txx9_kgdb_read,
+ .write_char = txx9_kgdb_write,
+ .init = txx9_kgdb_init,
+ .late_init = txx9_kgdb_late_init
+};
Index: linux-2.6/lib/Kconfig.kgdb
===================================================================
--- linux-2.6.orig/lib/Kconfig.kgdb
+++ linux-2.6/lib/Kconfig.kgdb
@@ -102,15 +102,14 @@ config KGDB_CPM_UART
Uses CPM UART to communicate with the host GDB.
config KGDB_SIBYTE
- bool "KGDB: On the Broadcom SWARM serial port"
+ bool "KGDB: On Broadcom SB1xxx serial port"
depends on MIPS && SIBYTE_SB1xxx_SOC
config KGDB_TXX9
- bool "KGDB: On the TX4927/TX4937/TX4938 serial port"
+ bool "KGDB: On TX49xx serial port"
depends on MIPS && CPU_TX49XX
help
- Uses TX4927/TX4937/TX4938 serial port to communicate with
- the host KGDB
+ Uses TX49xx serial port to communicate with the host KGDB.
config KGDB_SH_SCI
bool "KGDB: On SH SCI(F) serial port"
@@ -165,7 +164,7 @@ config KGDB_SIMPLE_SERIAL
config KGDB_BAUDRATE
int "Debug serial port baud rate"
- depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL)
+ depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_TXX9
default "115200"
help
gdb and the kernel stub need to agree on the baud rate to be
@@ -176,7 +175,7 @@ config KGDB_PORT_NUM
int "Serial port number for KGDB"
range 0 1 if KGDB_MPSC
range 0 3
- depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_MPSC
+ depends on (KGDB_8250 && KGDB_SIMPLE_SERIAL) || KGDB_MPSC || KGDB_TXX9
default "1"
help
Pick the port number (0 based) for KGDB to use.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport