Commit f4e7c1c1 authored by Tom Rini's avatar Tom Rini

PPC32: Add a backend for standard (ns1655x) UARTs for debugers.

parent 685bf7cb
......@@ -64,5 +64,8 @@ obj-$(CONFIG_SPRUCE) += cpc700_pic.o indirect_pci.o pci_auto.o \
obj-$(CONFIG_ZX4500) += indirect_pci.o pci_auto.o mpc10x_common.o \
i8259.o open_pic.o
obj-$(CONFIG_8260) += m8260_setup.o ppc8260_pic.o
ifeq ($(CONFIG_SERIAL_8250)$(CONFIG_PPC_GEN550),yy)
obj-$(CONFIG_KGDB) += gen550_kgdb.o gen550_dbg.o
obj-$(CONFIG_SERIAL_TEXT_DEBUG) += gen550_dbg.o
endif
obj-$(CONFIG_BOOTX_TEXT) += btext.o
/*
* arch/ppc/syslib/gen550_dbg.c
*
* A library of polled 16550 serial routines. These are intended to
* be used to support progress messages, xmon, kgdb, etc. on a
* variety of platforms.
*
* Adapted from lots of code ripped from the arch/ppc/boot/ polled
* 16550 support.
*
* Author: Matt Porter <mporter@mvista.com>
*
* 2002-2003 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#include <linux/config.h>
#include <linux/tty.h> /* For linux/serial_core.h */
#include <linux/serial_core.h>
#include <linux/serialP.h>
#include <linux/serial_reg.h>
#include <asm/machdep.h>
#include <asm/serial.h>
#include <asm/io.h>
#define SERIAL_BAUD 9600
static struct serial_state rs_table[RS_TABLE_SIZE] = {
SERIAL_PORT_DFNS /* defined in <asm/serial.h> */
};
static void (*serial_outb)(unsigned long, unsigned char);
static unsigned long (*serial_inb)(unsigned long);
static int shift;
unsigned long direct_inb(unsigned long addr)
{
return readb(addr);
}
void direct_outb(unsigned long addr, unsigned char val)
{
writeb(val, addr);
}
unsigned long io_inb(unsigned long port)
{
return inb(port);
}
void io_outb(unsigned long port, unsigned char val)
{
outb(val, port);
}
unsigned long serial_init(int chan, void *ignored)
{
unsigned long com_port;
unsigned char lcr, dlm;
/* We need to find out which type io we're expecting. If it's
* 'SERIAL_IO_PORT', we get an offset from the isa_io_base.
* If it's 'SERIAL_IO_MEM', we can the exact location. -- Tom */
switch (rs_table[chan].io_type) {
case SERIAL_IO_PORT:
com_port = rs_table[chan].port;
serial_outb = io_outb;
serial_inb = io_inb;
break;
case SERIAL_IO_MEM:
com_port = (unsigned long)rs_table[chan].iomem_base;
serial_outb = direct_outb;
serial_inb = direct_inb;
break;
default:
/* We can't deal with it. */
return -1;
}
/* How far apart the registers are. */
shift = rs_table[chan].iomem_reg_shift;
/* save the LCR */
lcr = serial_inb(com_port + (UART_LCR << shift));
/* Access baud rate */
serial_outb(com_port + (UART_LCR << shift), UART_LCR_DLAB);
dlm = serial_inb(com_port + (UART_DLM << shift));
/*
* Test if serial port is unconfigured
* We assume that no-one uses less than 110 baud or
* less than 7 bits per character these days.
* -- paulus.
*/
if ((dlm <= 4) && (lcr & 2)) {
/* port is configured, put the old LCR back */
serial_outb(com_port + (UART_LCR << shift), lcr);
}
else {
/* Input clock. */
serial_outb(com_port + (UART_DLL << shift),
(rs_table[chan].baud_base / SERIAL_BAUD) & 0xFF);
serial_outb(com_port + (UART_DLM << shift),
(rs_table[chan].baud_base / SERIAL_BAUD) >> 8);
/* 8 data, 1 stop, no parity */
serial_outb(com_port + (UART_LCR << shift), 0x03);
/* RTS/DTR */
serial_outb(com_port + (UART_MCR << shift), 0x03);
/* Clear & enable FIFOs */
serial_outb(com_port + (UART_FCR << shift), 0x07);
}
return (com_port);
}
void
serial_putc(unsigned long com_port, unsigned char c)
{
while ((serial_inb(com_port + (UART_LSR << shift)) & UART_LSR_THRE) == 0)
;
serial_outb(com_port, c);
}
unsigned char
serial_getc(unsigned long com_port)
{
while ((serial_inb(com_port + (UART_LSR << shift)) & UART_LSR_DR) == 0)
;
return serial_inb(com_port);
}
int
serial_tstc(unsigned long com_port)
{
return ((serial_inb(com_port + (UART_LSR << shift)) & UART_LSR_DR) != 0);
}
void
serial_close(unsigned long com_port)
{
}
void
gen550_init(int i, struct uart_port *serial_req)
{
rs_table[i].io_type = serial_req->iotype;
rs_table[i].port = serial_req->line;
rs_table[i].iomem_base = serial_req->membase;
rs_table[i].iomem_reg_shift = serial_req->regshift;
}
#ifdef CONFIG_SERIAL_TEXT_DEBUG
void
gen550_progress(char *s, unsigned short hex)
{
volatile unsigned int progress_debugport;
volatile char c;
progress_debugport = serial_init(0, NULL);
serial_putc(progress_debugport, '\r');
while ((c = *s++) != 0)
serial_putc(progress_debugport, c);
serial_putc(progress_debugport, '\n');
serial_putc(progress_debugport, '\r');
}
#endif /* CONFIG_SERIAL_TEXT_DEBUG */
/*
* arch/ppc/syslib/gen550_kgdb.c
*
* Generic 16550 kgdb support intended to be useful on a variety
* of platforms. To enable this support, it is necessary to set
* the CONFIG_GEN550 option. Any virtual mapping of the serial
* port(s) to be used can be accomplished by setting
* ppc_md.early_serial_map to a platform-specific mapping function.
*
* Adapted from ppc4xx_kgdb.c.
*
* Author: Matt Porter <mporter@mvista.com>
*
* 2002-2003 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/machdep.h>
extern unsigned long serial_init(int, void *);
extern unsigned long serial_getc(unsigned long);
extern unsigned long serial_putc(unsigned long, unsigned char);
#if defined(CONFIG_KGDB_TTYS0)
#define KGDB_PORT 0
#elif defined(CONFIG_KGDB_TTYS1)
#define KGDB_PORT 1
#elif defined(CONFIG_KGDB_TTYS2)
#define KGDB_PORT 2
#elif defined(CONFIG_KGDB_TTYS3)
#define KGDB_PORT 3
#else
#error "invalid kgdb_tty port"
#endif
static volatile unsigned int kgdb_debugport;
void putDebugChar(unsigned char c)
{
if (kgdb_debugport == 0)
kgdb_debugport = serial_init(KGDB_PORT, NULL);
serial_putc(kgdb_debugport, c);
}
int getDebugChar(void)
{
if (kgdb_debugport == 0)
kgdb_debugport = serial_init(KGDB_PORT, NULL);
return(serial_getc(kgdb_debugport));
}
void kgdb_interruptible(int enable)
{
return;
}
void putDebugString(char* str)
{
while (*str != '\0') {
putDebugChar(*str);
str++;
}
putDebugChar('\r');
return;
}
/*
* Note: gen550_init() must be called already on the port we are going
* to use.
*/
void
kgdb_map_scc(void)
{
printk(KERN_DEBUG "kgdb init\n");
kgdb_debugport = serial_init(KGDB_PORT, NULL);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment