Hello folks,

this patch implements the following changes/fixes:

- renamed the TX49xx KGDB driver according to the new convention
- updated the driver code to compile with the new KGDB baud rate and port 
select options
- renamed variables/functions, updated write_char handler to accept 'u8' arg
- updated the hook in the TX49xx serial driver
- got rid of the '#ifdef CONFIG_TOSHIBA_RBTX4939' in the TX49xx serial driver
- made the TX49xx driver support 4 UARTs instead of 2 max
- enabled support of the KGDB baud rate option for the TX49xx driver
- removal of unused stuff

 arch/mips/kernel/gdb-low.S                                 |  394 -------------
 arch/mips/sgi-ip22/ip22-setup.c                            |   24
 arch/mips/sibyte/sb1250/irq.c                              |    4
 arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c |    4
 arch/mips/tx4938/toshiba_rbtx4938/setup.c                  |    4
 drivers/serial/Makefile                                    |    2
 drivers/serial/kgdb_serial_txx9.c                          |  169 -----
 drivers/serial/serial_txx9.c                               |   13
 drivers/serial/serial_txx9_kgdb.c                          |  151 ++++
 9 files changed, 161 insertions(+), 604 deletions(-)

 Signed-off-by: Sergey Shtylyov <[EMAIL PROTECTED]>
 Signed-off-by: Vitaly Wool <[EMAIL PROTECTED]>

Index: linux-2.6-kgdb-testing/arch/mips/kernel/gdb-low.S
===================================================================
--- linux-2.6-kgdb-testing.orig/arch/mips/kernel/gdb-low.S
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * gdb-low.S contains the low-level trap handler for the GDB stub.
- *
- * Copyright (C) 1995 Andreas Busse
- */
-#include <linux/sys.h>
-
-#include <asm/asm.h>
-#include <asm/errno.h>
-#include <asm/irqflags.h>
-#include <asm/mipsregs.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-#include <asm/gdb-stub.h>
-
-#ifdef CONFIG_32BIT
-#define DMFC0  mfc0
-#define DMTC0  mtc0
-#define LDC1   lwc1
-#define SDC1   lwc1
-#endif
-#ifdef CONFIG_64BIT
-#define DMFC0  dmfc0
-#define DMTC0  dmtc0
-#define LDC1   ldc1
-#define SDC1   ldc1
-#endif
-
-/*
- * [jsun] We reserves about 2x GDB_FR_SIZE in stack.  The lower (addressed)
- * part is used to store registers and passed to exception handler.
- * The upper part is reserved for "call func" feature where gdb client
- * saves some of the regs, setups call frame and passes args.
- *
- * A trace shows about 200 bytes are used to store about half of all regs.
- * The rest should be big enough for frame setup and passing args.
- */
-
-/*
- * The low level trap handler
- */
-               .align  5
-               NESTED(trap_low, GDB_FR_SIZE, sp)
-               .set    noat
-               .set    noreorder
-
-               mfc0    k0, CP0_STATUS
-               sll     k0, 3                   /* extract cu0 bit */
-               bltz    k0, 1f
-               move    k1, sp
-
-               /*
-                * Called from user mode, go somewhere else.
-                */
-               mfc0    k0, CP0_CAUSE
-               andi    k0, k0, 0x7c
-#ifdef CONFIG_64BIT
-               dsll    k0, k0, 1
-#endif
-               PTR_L   k1, saved_vectors(k0)
-               jr      k1
-               nop
-1:
-               move    k0, sp
-               PTR_SUBU sp, k1, GDB_FR_SIZE*2  # see comment above
-               LONG_S  k0, GDB_FR_REG29(sp)
-               LONG_S  $2, GDB_FR_REG2(sp)
-
-/*
- * First save the CP0 and special registers
- */
-
-               mfc0    v0, CP0_STATUS
-               LONG_S  v0, GDB_FR_STATUS(sp)
-               mfc0    v0, CP0_CAUSE
-               LONG_S  v0, GDB_FR_CAUSE(sp)
-               DMFC0   v0, CP0_EPC
-               LONG_S  v0, GDB_FR_EPC(sp)
-               DMFC0   v0, CP0_BADVADDR
-               LONG_S  v0, GDB_FR_BADVADDR(sp)
-               mfhi    v0
-               LONG_S  v0, GDB_FR_HI(sp)
-               mflo    v0
-               LONG_S  v0, GDB_FR_LO(sp)
-
-/*
- * Now the integer registers
- */
-
-               LONG_S  zero, GDB_FR_REG0(sp)           /* I know... */
-               LONG_S  $1, GDB_FR_REG1(sp)
-               /* v0 already saved */
-               LONG_S  $3, GDB_FR_REG3(sp)
-               LONG_S  $4, GDB_FR_REG4(sp)
-               LONG_S  $5, GDB_FR_REG5(sp)
-               LONG_S  $6, GDB_FR_REG6(sp)
-               LONG_S  $7, GDB_FR_REG7(sp)
-               LONG_S  $8, GDB_FR_REG8(sp)
-               LONG_S  $9, GDB_FR_REG9(sp)
-               LONG_S  $10, GDB_FR_REG10(sp)
-               LONG_S  $11, GDB_FR_REG11(sp)
-               LONG_S  $12, GDB_FR_REG12(sp)
-               LONG_S  $13, GDB_FR_REG13(sp)
-               LONG_S  $14, GDB_FR_REG14(sp)
-               LONG_S  $15, GDB_FR_REG15(sp)
-               LONG_S  $16, GDB_FR_REG16(sp)
-               LONG_S  $17, GDB_FR_REG17(sp)
-               LONG_S  $18, GDB_FR_REG18(sp)
-               LONG_S  $19, GDB_FR_REG19(sp)
-               LONG_S  $20, GDB_FR_REG20(sp)
-               LONG_S  $21, GDB_FR_REG21(sp)
-               LONG_S  $22, GDB_FR_REG22(sp)
-               LONG_S  $23, GDB_FR_REG23(sp)
-               LONG_S  $24, GDB_FR_REG24(sp)
-               LONG_S  $25, GDB_FR_REG25(sp)
-               LONG_S  $26, GDB_FR_REG26(sp)
-               LONG_S  $27, GDB_FR_REG27(sp)
-               LONG_S  $28, GDB_FR_REG28(sp)
-               /* sp already saved */
-               LONG_S  $30, GDB_FR_REG30(sp)
-               LONG_S  $31, GDB_FR_REG31(sp)
-
-               CLI                             /* disable interrupts */
-               TRACE_IRQS_OFF
-
-/*
- * Followed by the floating point registers
- */
-               mfc0    v0, CP0_STATUS          /* FPU enabled? */
-               srl     v0, v0, 16
-               andi    v0, v0, (ST0_CU1 >> 16)
-
-               beqz    v0,2f                   /* disabled, skip */
-                nop
-
-               SDC1    $0, GDB_FR_FPR0(sp)
-               SDC1    $1, GDB_FR_FPR1(sp)
-               SDC1    $2, GDB_FR_FPR2(sp)
-               SDC1    $3, GDB_FR_FPR3(sp)
-               SDC1    $4, GDB_FR_FPR4(sp)
-               SDC1    $5, GDB_FR_FPR5(sp)
-               SDC1    $6, GDB_FR_FPR6(sp)
-               SDC1    $7, GDB_FR_FPR7(sp)
-               SDC1    $8, GDB_FR_FPR8(sp)
-               SDC1    $9, GDB_FR_FPR9(sp)
-               SDC1    $10, GDB_FR_FPR10(sp)
-               SDC1    $11, GDB_FR_FPR11(sp)
-               SDC1    $12, GDB_FR_FPR12(sp)
-               SDC1    $13, GDB_FR_FPR13(sp)
-               SDC1    $14, GDB_FR_FPR14(sp)
-               SDC1    $15, GDB_FR_FPR15(sp)
-               SDC1    $16, GDB_FR_FPR16(sp)
-               SDC1    $17, GDB_FR_FPR17(sp)
-               SDC1    $18, GDB_FR_FPR18(sp)
-               SDC1    $19, GDB_FR_FPR19(sp)
-               SDC1    $20, GDB_FR_FPR20(sp)
-               SDC1    $21, GDB_FR_FPR21(sp)
-               SDC1    $22, GDB_FR_FPR22(sp)
-               SDC1    $23, GDB_FR_FPR23(sp)
-               SDC1    $24, GDB_FR_FPR24(sp)
-               SDC1    $25, GDB_FR_FPR25(sp)
-               SDC1    $26, GDB_FR_FPR26(sp)
-               SDC1    $27, GDB_FR_FPR27(sp)
-               SDC1    $28, GDB_FR_FPR28(sp)
-               SDC1    $29, GDB_FR_FPR29(sp)
-               SDC1    $30, GDB_FR_FPR30(sp)
-               SDC1    $31, GDB_FR_FPR31(sp)
-
-/*
- * FPU control registers
- */
-
-               cfc1    v0, CP1_STATUS
-               LONG_S  v0, GDB_FR_FSR(sp)
-               cfc1    v0, CP1_REVISION
-               LONG_S  v0, GDB_FR_FIR(sp)
-
-/*
- * Current stack frame ptr
- */
-
-2:
-               LONG_S  sp, GDB_FR_FRP(sp)
-
-/*
- * CP0 registers (R4000/R4400 unused registers skipped)
- */
-
-               mfc0    v0, CP0_INDEX
-               LONG_S  v0, GDB_FR_CP0_INDEX(sp)
-               mfc0    v0, CP0_RANDOM
-               LONG_S  v0, GDB_FR_CP0_RANDOM(sp)
-               DMFC0   v0, CP0_ENTRYLO0
-               LONG_S  v0, GDB_FR_CP0_ENTRYLO0(sp)
-               DMFC0   v0, CP0_ENTRYLO1
-               LONG_S  v0, GDB_FR_CP0_ENTRYLO1(sp)
-               DMFC0   v0, CP0_CONTEXT
-               LONG_S  v0, GDB_FR_CP0_CONTEXT(sp)
-               mfc0    v0, CP0_PAGEMASK
-               LONG_S  v0, GDB_FR_CP0_PAGEMASK(sp)
-               mfc0    v0, CP0_WIRED
-               LONG_S  v0, GDB_FR_CP0_WIRED(sp)
-               DMFC0   v0, CP0_ENTRYHI
-               LONG_S  v0, GDB_FR_CP0_ENTRYHI(sp)
-               mfc0    v0, CP0_PRID
-               LONG_S  v0, GDB_FR_CP0_PRID(sp)
-
-               .set    at
-
-/*
- * Continue with the higher level handler
- */
-
-               move    a0,sp
-
-               jal     handle_exception
-                nop
-
-/*
- * Restore all writable registers, in reverse order
- */
-
-               .set    noat
-
-               LONG_L  v0, GDB_FR_CP0_ENTRYHI(sp)
-               LONG_L  v1, GDB_FR_CP0_WIRED(sp)
-               DMTC0   v0, CP0_ENTRYHI
-               mtc0    v1, CP0_WIRED
-               LONG_L  v0, GDB_FR_CP0_PAGEMASK(sp)
-               LONG_L  v1, GDB_FR_CP0_ENTRYLO1(sp)
-               mtc0    v0, CP0_PAGEMASK
-               DMTC0   v1, CP0_ENTRYLO1
-               LONG_L  v0, GDB_FR_CP0_ENTRYLO0(sp)
-               LONG_L  v1, GDB_FR_CP0_INDEX(sp)
-               DMTC0   v0, CP0_ENTRYLO0
-               LONG_L  v0, GDB_FR_CP0_CONTEXT(sp)
-               mtc0    v1, CP0_INDEX
-               DMTC0   v0, CP0_CONTEXT
-
-
-/*
- * Next, the floating point registers
- */
-               mfc0    v0, CP0_STATUS          /* check if the FPU is enabled 
*/
-               srl     v0, v0, 16
-               andi    v0, v0, (ST0_CU1 >> 16)
-
-               beqz    v0, 3f                  /* disabled, skip */
-                nop
-
-               LDC1    $31, GDB_FR_FPR31(sp)
-               LDC1    $30, GDB_FR_FPR30(sp)
-               LDC1    $29, GDB_FR_FPR29(sp)
-               LDC1    $28, GDB_FR_FPR28(sp)
-               LDC1    $27, GDB_FR_FPR27(sp)
-               LDC1    $26, GDB_FR_FPR26(sp)
-               LDC1    $25, GDB_FR_FPR25(sp)
-               LDC1    $24, GDB_FR_FPR24(sp)
-               LDC1    $23, GDB_FR_FPR23(sp)
-               LDC1    $22, GDB_FR_FPR22(sp)
-               LDC1    $21, GDB_FR_FPR21(sp)
-               LDC1    $20, GDB_FR_FPR20(sp)
-               LDC1    $19, GDB_FR_FPR19(sp)
-               LDC1    $18, GDB_FR_FPR18(sp)
-               LDC1    $17, GDB_FR_FPR17(sp)
-               LDC1    $16, GDB_FR_FPR16(sp)
-               LDC1    $15, GDB_FR_FPR15(sp)
-               LDC1    $14, GDB_FR_FPR14(sp)
-               LDC1    $13, GDB_FR_FPR13(sp)
-               LDC1    $12, GDB_FR_FPR12(sp)
-               LDC1    $11, GDB_FR_FPR11(sp)
-               LDC1    $10, GDB_FR_FPR10(sp)
-               LDC1    $9, GDB_FR_FPR9(sp)
-               LDC1    $8, GDB_FR_FPR8(sp)
-               LDC1    $7, GDB_FR_FPR7(sp)
-               LDC1    $6, GDB_FR_FPR6(sp)
-               LDC1    $5, GDB_FR_FPR5(sp)
-               LDC1    $4, GDB_FR_FPR4(sp)
-               LDC1    $3, GDB_FR_FPR3(sp)
-               LDC1    $2, GDB_FR_FPR2(sp)
-               LDC1    $1, GDB_FR_FPR1(sp)
-               LDC1    $0, GDB_FR_FPR0(sp)
-
-/*
- * Now the CP0 and integer registers
- */
-
-3:
-#ifdef CONFIG_MIPS_MT_SMTC
-               /* Read-modify write of Status must be atomic */
-               mfc0    t2, CP0_TCSTATUS
-               ori     t1, t2, TCSTATUS_IXMT
-               mtc0    t1, CP0_TCSTATUS
-               andi    t2, t2, TCSTATUS_IXMT
-               _ehb
-               DMT     9                               # dmt   t1
-               jal     mips_ihb
-               nop
-#endif /* CONFIG_MIPS_MT_SMTC */
-               mfc0    t0, CP0_STATUS
-               ori     t0, 0x1f
-               xori    t0, 0x1f
-               mtc0    t0, CP0_STATUS
-#ifdef CONFIG_MIPS_MT_SMTC
-               andi    t1, t1, VPECONTROL_TE
-               beqz    t1, 9f
-               nop
-               EMT                                     # emt
-9:
-               mfc0    t1, CP0_TCSTATUS
-               xori    t1, t1, TCSTATUS_IXMT
-               or      t1, t1, t2
-               mtc0    t1, CP0_TCSTATUS
-               _ehb
-#endif /* CONFIG_MIPS_MT_SMTC */
-               LONG_L  v0, GDB_FR_STATUS(sp)
-               LONG_L  v1, GDB_FR_EPC(sp)
-               mtc0    v0, CP0_STATUS
-               DMTC0   v1, CP0_EPC
-               LONG_L  v0, GDB_FR_HI(sp)
-               LONG_L  v1, GDB_FR_LO(sp)
-               mthi    v0
-               mtlo    v1
-               LONG_L  $31, GDB_FR_REG31(sp)
-               LONG_L  $30, GDB_FR_REG30(sp)
-               LONG_L  $28, GDB_FR_REG28(sp)
-               LONG_L  $27, GDB_FR_REG27(sp)
-               LONG_L  $26, GDB_FR_REG26(sp)
-               LONG_L  $25, GDB_FR_REG25(sp)
-               LONG_L  $24, GDB_FR_REG24(sp)
-               LONG_L  $23, GDB_FR_REG23(sp)
-               LONG_L  $22, GDB_FR_REG22(sp)
-               LONG_L  $21, GDB_FR_REG21(sp)
-               LONG_L  $20, GDB_FR_REG20(sp)
-               LONG_L  $19, GDB_FR_REG19(sp)
-               LONG_L  $18, GDB_FR_REG18(sp)
-               LONG_L  $17, GDB_FR_REG17(sp)
-               LONG_L  $16, GDB_FR_REG16(sp)
-               LONG_L  $15, GDB_FR_REG15(sp)
-               LONG_L  $14, GDB_FR_REG14(sp)
-               LONG_L  $13, GDB_FR_REG13(sp)
-               LONG_L  $12, GDB_FR_REG12(sp)
-               LONG_L  $11, GDB_FR_REG11(sp)
-               LONG_L  $10, GDB_FR_REG10(sp)
-               LONG_L  $9, GDB_FR_REG9(sp)
-               LONG_L  $8, GDB_FR_REG8(sp)
-               LONG_L  $7, GDB_FR_REG7(sp)
-               LONG_L  $6, GDB_FR_REG6(sp)
-               LONG_L  $5, GDB_FR_REG5(sp)
-               LONG_L  $4, GDB_FR_REG4(sp)
-               LONG_L  $3, GDB_FR_REG3(sp)
-               LONG_L  $2, GDB_FR_REG2(sp)
-               LONG_L  $1, GDB_FR_REG1(sp)
-#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
-               LONG_L  k0, GDB_FR_EPC(sp)
-               LONG_L  $29, GDB_FR_REG29(sp)           /* Deallocate stack */
-               jr      k0
-               rfe
-#else
-               LONG_L  sp, GDB_FR_REG29(sp)            /* Deallocate stack */
-
-               .set    mips3
-               eret
-               .set    mips0
-#endif
-               .set    at
-               .set    reorder
-               END(trap_low)
-
-LEAF(kgdb_read_byte)
-4:             lb      t0, (a0)
-               sb      t0, (a1)
-               li      v0, 0
-               jr      ra
-               .section __ex_table,"a"
-               PTR     4b, kgdbfault
-               .previous
-               END(kgdb_read_byte)
-
-LEAF(kgdb_write_byte)
-5:             sb      a0, (a1)
-               li      v0, 0
-               jr      ra
-               .section __ex_table,"a"
-               PTR     5b, kgdbfault
-               .previous
-               END(kgdb_write_byte)
-
-               .type   [EMAIL PROTECTED]
-               .ent    kgdbfault
-
-kgdbfault:     li      v0, -EFAULT
-               jr      ra
-               .end    kgdbfault
Index: linux-2.6-kgdb-testing/arch/mips/sgi-ip22/ip22-setup.c
===================================================================
--- linux-2.6-kgdb-testing.orig/arch/mips/sgi-ip22/ip22-setup.c
+++ linux-2.6-kgdb-testing/arch/mips/sgi-ip22/ip22-setup.c
@@ -101,30 +101,6 @@ void __init plat_mem_setup(void)
                add_preferred_console("arc", 0, NULL);
        }
 
-#ifdef CONFIG_KGDB
-       {
-       char *kgdb_ttyd = prom_getcmdline();
-
-       if ((kgdb_ttyd = strstr(kgdb_ttyd, "kgdb=ttyd")) != NULL) {
-               int line;
-               kgdb_ttyd += strlen("kgdb=ttyd");
-               if (*kgdb_ttyd != '1' && *kgdb_ttyd != '2')
-                       printk(KERN_INFO "KGDB: Uknown serial line /dev/ttyd%c"
-                              ", falling back to /dev/ttyd1\n", *kgdb_ttyd);
-               line = *kgdb_ttyd == '2' ? 0 : 1;
-               printk(KERN_INFO "KGDB: Using serial line /dev/ttyd%d for "
-                      "session\n", line ? 1 : 2);
-               rs_kgdb_hook(line);
-
-               printk(KERN_INFO "KGDB: Using serial line /dev/ttyd%d for "
-                      "session, please connect your debugger\n", line ? 1:2);
-
-               kgdb_enabled = 1;
-               /* Breakpoints and stuff are in sgi_irq_setup() */
-       }
-       }
-#endif
-
 #if defined(CONFIG_VT) && defined(CONFIG_SGI_NEWPORT_CONSOLE)
        {
                ULONG *gfxinfo;
Index: linux-2.6-kgdb-testing/arch/mips/sibyte/sb1250/irq.c
===================================================================
--- linux-2.6-kgdb-testing.orig/arch/mips/sibyte/sb1250/irq.c
+++ linux-2.6-kgdb-testing/arch/mips/sibyte/sb1250/irq.c
@@ -61,10 +61,6 @@ extern unsigned long ldt_eoi_space;
 #endif
 
 #ifdef CONFIG_KGDB
-static int kgdb_irq;
-
-/* Default to UART1 */
-int kgdb_port = 1;
 #ifdef CONFIG_SIBYTE_SB1250_DUART
 extern char sb1250_duart_present[];
 #endif
Index: 
linux-2.6-kgdb-testing/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
===================================================================
--- 
linux-2.6-kgdb-testing.orig/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ 
linux-2.6-kgdb-testing/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
@@ -977,7 +977,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++) {
@@ -993,7 +993,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-kgdb-testing/arch/mips/tx4938/toshiba_rbtx4938/setup.c
===================================================================
--- linux-2.6-kgdb-testing.orig/arch/mips/tx4938/toshiba_rbtx4938/setup.c
+++ linux-2.6-kgdb-testing/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-kgdb-testing/drivers/serial/kgdb_serial_txx9.c
===================================================================
--- linux-2.6-kgdb-testing.orig/drivers/serial/kgdb_serial_txx9.c
+++ /dev/null
@@ -1,169 +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/config.h>
-#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-kgdb-testing/drivers/serial/Makefile
===================================================================
--- linux-2.6-kgdb-testing.orig/drivers/serial/Makefile
+++ linux-2.6-kgdb-testing/drivers/serial/Makefile
@@ -53,10 +53,10 @@ 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
 obj-$(CONFIG_SERIAL_AT91) += at91_serial.o
 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
 obj-$(CONFIG_KGDB_8250) += 8250_kgdb.o
-obj-$(CONFIG_KGDB_TXX9) += kgdb_serial_txx9.o
Index: linux-2.6-kgdb-testing/drivers/serial/serial_txx9.c
===================================================================
--- linux-2.6-kgdb-testing.orig/drivers/serial/serial_txx9.c
+++ linux-2.6-kgdb-testing/drivers/serial/serial_txx9.c
@@ -63,11 +63,8 @@
 static char *serial_version = "1.06";
 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
@@ -485,7 +482,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;
 
        /*
@@ -840,7 +837,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;
@@ -1045,7 +1042,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-kgdb-testing/drivers/serial/serial_txx9_kgdb.c
===================================================================
--- /dev/null
+++ linux-2.6-kgdb-testing/drivers/serial/serial_txx9_kgdb.c
@@ -0,0 +1,151 @@
+/*
+ * 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/config.h>
+#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
+};

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Kgdb-bugreport mailing list
Kgdb-bugreport@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to