mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
Add support for CONFIG_SERIAL_MULTI on MPC5xxx
Patch by Martin Krause, 8 Jun 2006 This patch supports two serial consoles on boards with a MPC5xxx CPU. The console can be switched at runtime by setting stdin, stdout and stderr to the desired serial interface (serial0 or serial1). The PSCs to be used as console port are definded by CONFIG_PSC_CONSOLE and CONFIG_PSC_CONSOLE2. See README.serial_multi for details.
This commit is contained in:
parent
30a43cc2ae
commit
c12cffc543
5 changed files with 211 additions and 13 deletions
11
CHANGELOG
11
CHANGELOG
|
@ -2,6 +2,17 @@
|
||||||
Changes since U-Boot 1.1.4:
|
Changes since U-Boot 1.1.4:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
|
* Add support for CONFIG_SERIAL_MULTI on MPC5xxx
|
||||||
|
Patch by Martin Krause, 8 Jun 2006
|
||||||
|
|
||||||
|
This patch supports two serial consoles on boards with
|
||||||
|
a MPC5xxx CPU. The console can be switched at runtime
|
||||||
|
by setting stdin, stdout and stderr to the desired serial
|
||||||
|
interface (serial0 or serial1). The PSCs to be used as
|
||||||
|
console port are definded by CONFIG_PSC_CONSOLE
|
||||||
|
and CONFIG_PSC_CONSOLE2.
|
||||||
|
See README.serial_multi for details.
|
||||||
|
|
||||||
* Bugfix in I2C initialisation on S3C2400.
|
* Bugfix in I2C initialisation on S3C2400.
|
||||||
If the bus is blocked because of a previously interrupted
|
If the bus is blocked because of a previously interrupted
|
||||||
transfer, up to eleven clocks are generated on the I2CSCL
|
transfer, up to eleven clocks are generated on the I2CSCL
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct serial_device *default_serial_console (void)
|
||||||
|| defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
|
|| defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
|
||||||
return &serial_scc_device;
|
return &serial_scc_device;
|
||||||
#elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
|
#elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
|
||||||
|| defined(CONFIG_405EP)
|
|| defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
|
||||||
return &serial0_device;
|
return &serial0_device;
|
||||||
#else
|
#else
|
||||||
#error No default console
|
#error No default console
|
||||||
|
@ -75,7 +75,7 @@ void serial_initialize (void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
|
#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
|
||||||
|| defined(CONFIG_405EP)
|
|| defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
|
||||||
serial_register(&serial0_device);
|
serial_register(&serial0_device);
|
||||||
serial_register(&serial1_device);
|
serial_register(&serial1_device);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
* Hacked for MPC8260 by Murray.Jensen@cmst.csiro.au, 19-Oct-00, with
|
* Hacked for MPC8260 by Murray.Jensen@cmst.csiro.au, 19-Oct-00, with
|
||||||
* changes based on the file arch/ppc/mbxboot/m8260_tty.c from the
|
* changes based on the file arch/ppc/mbxboot/m8260_tty.c from the
|
||||||
* Linux/PPC sources (m8260_tty.c had no copyright info in it).
|
* Linux/PPC sources (m8260_tty.c had no copyright info in it).
|
||||||
|
*
|
||||||
|
* Martin Krause, 8 Jun 2006
|
||||||
|
* Added CONFIG_SERIAL_MULTI support
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -33,6 +36,10 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <mpc5xxx.h>
|
#include <mpc5xxx.h>
|
||||||
|
|
||||||
|
#if defined (CONFIG_SERIAL_MULTI)
|
||||||
|
#include <serial.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#if defined(CONFIG_PSC_CONSOLE)
|
#if defined(CONFIG_PSC_CONSOLE)
|
||||||
|
@ -55,9 +62,41 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
#error CONFIG_PSC_CONSOLE must be in 1 ... 6
|
#error CONFIG_PSC_CONSOLE must be in 1 ... 6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI) && !defined(CONFIG_PSC_CONSOLE2)
|
||||||
|
#error you must define CONFIG_PSC_CONSOLE2 if CONFIG_SERIAL_MULTI is set
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
#if CONFIG_PSC_CONSOLE2 == 1
|
||||||
|
#define PSC_BASE2 MPC5XXX_PSC1
|
||||||
|
#elif CONFIG_PSC_CONSOLE2 == 2
|
||||||
|
#define PSC_BASE2 MPC5XXX_PSC2
|
||||||
|
#elif CONFIG_PSC_CONSOLE2 == 3
|
||||||
|
#define PSC_BASE2 MPC5XXX_PSC3
|
||||||
|
#elif defined(CONFIG_MGT5100)
|
||||||
|
#error CONFIG_PSC_CONSOLE2 must be in 1, 2 or 3
|
||||||
|
#elif CONFIG_PSC_CONSOLE2 == 4
|
||||||
|
#define PSC_BASE2 MPC5XXX_PSC4
|
||||||
|
#elif CONFIG_PSC_CONSOLE2 == 5
|
||||||
|
#define PSC_BASE2 MPC5XXX_PSC5
|
||||||
|
#elif CONFIG_PSC_CONSOLE2 == 6
|
||||||
|
#define PSC_BASE2 MPC5XXX_PSC6
|
||||||
|
#else
|
||||||
|
#error CONFIG_PSC_CONSOLE2 must be in 1 ... 6
|
||||||
|
#endif
|
||||||
|
#endif /* CONFIG_SERIAL_MULTI */
|
||||||
|
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
int serial_init_dev (unsigned long dev_base)
|
||||||
|
#else
|
||||||
int serial_init (void)
|
int serial_init (void)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
|
||||||
|
#else
|
||||||
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
||||||
|
#endif
|
||||||
unsigned long baseclk;
|
unsigned long baseclk;
|
||||||
int div;
|
int div;
|
||||||
|
|
||||||
|
@ -100,13 +139,24 @@ int serial_init (void)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
serial_putc(const char c)
|
void serial_putc_dev (unsigned long dev_base, const char c)
|
||||||
|
#else
|
||||||
|
void serial_putc(const char c)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
|
||||||
|
#else
|
||||||
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
serial_putc_dev (dev_base, '\r');
|
||||||
|
#else
|
||||||
serial_putc('\r');
|
serial_putc('\r');
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Wait for last character to go. */
|
/* Wait for last character to go. */
|
||||||
while (!(psc->psc_status & PSC_SR_TXEMP))
|
while (!(psc->psc_status & PSC_SR_TXEMP))
|
||||||
|
@ -115,18 +165,32 @@ serial_putc(const char c)
|
||||||
psc->psc_buffer_8 = c;
|
psc->psc_buffer_8 = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
serial_puts (const char *s)
|
void serial_puts_dev (unsigned long dev_base, const char *s)
|
||||||
|
#else
|
||||||
|
void serial_puts (const char *s)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
while (*s) {
|
while (*s) {
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
serial_putc_dev (dev_base, *s++);
|
||||||
|
#else
|
||||||
serial_putc (*s++);
|
serial_putc (*s++);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
serial_getc(void)
|
int serial_getc_dev (unsigned long dev_base)
|
||||||
|
#else
|
||||||
|
int serial_getc(void)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
|
||||||
|
#else
|
||||||
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Wait for a character to arrive. */
|
/* Wait for a character to arrive. */
|
||||||
while (!(psc->psc_status & PSC_SR_RXRDY))
|
while (!(psc->psc_status & PSC_SR_RXRDY))
|
||||||
|
@ -135,18 +199,32 @@ serial_getc(void)
|
||||||
return psc->psc_buffer_8;
|
return psc->psc_buffer_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
serial_tstc(void)
|
int serial_tstc_dev (unsigned long dev_base)
|
||||||
|
#else
|
||||||
|
int serial_tstc(void)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
|
||||||
|
#else
|
||||||
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
||||||
|
#endif
|
||||||
|
|
||||||
return (psc->psc_status & PSC_SR_RXRDY);
|
return (psc->psc_status & PSC_SR_RXRDY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
serial_setbrg(void)
|
void serial_setbrg_dev (unsigned long dev_base)
|
||||||
|
#else
|
||||||
|
void serial_setbrg(void)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
|
||||||
|
#else
|
||||||
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
|
||||||
|
#endif
|
||||||
unsigned long baseclk, div;
|
unsigned long baseclk, div;
|
||||||
|
|
||||||
#if defined(CONFIG_MGT5100)
|
#if defined(CONFIG_MGT5100)
|
||||||
|
@ -160,4 +238,87 @@ serial_setbrg(void)
|
||||||
psc->ctur = (div >> 8) & 0xFF;
|
psc->ctur = (div >> 8) & 0xFF;
|
||||||
psc->ctlr = div & 0xff;
|
psc->ctlr = div & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_SERIAL_MULTI)
|
||||||
|
int serial0_init(void)
|
||||||
|
{
|
||||||
|
return (serial_init_dev(PSC_BASE));
|
||||||
|
}
|
||||||
|
|
||||||
|
int serial1_init(void)
|
||||||
|
{
|
||||||
|
return (serial_init_dev(PSC_BASE2));
|
||||||
|
}
|
||||||
|
void serial0_setbrg (void)
|
||||||
|
{
|
||||||
|
serial_setbrg_dev(PSC_BASE);
|
||||||
|
}
|
||||||
|
void serial1_setbrg (void)
|
||||||
|
{
|
||||||
|
serial_setbrg_dev(PSC_BASE2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial0_putc(const char c)
|
||||||
|
{
|
||||||
|
serial_putc_dev(PSC_BASE,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial1_putc(const char c)
|
||||||
|
{
|
||||||
|
serial_putc_dev(PSC_BASE2, c);
|
||||||
|
}
|
||||||
|
void serial0_puts(const char *s)
|
||||||
|
{
|
||||||
|
serial_puts_dev(PSC_BASE, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial1_puts(const char *s)
|
||||||
|
{
|
||||||
|
serial_puts_dev(PSC_BASE2, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int serial0_getc(void)
|
||||||
|
{
|
||||||
|
return(serial_getc_dev(PSC_BASE));
|
||||||
|
}
|
||||||
|
|
||||||
|
int serial1_getc(void)
|
||||||
|
{
|
||||||
|
return(serial_getc_dev(PSC_BASE2));
|
||||||
|
}
|
||||||
|
int serial0_tstc(void)
|
||||||
|
{
|
||||||
|
return (serial_tstc_dev(PSC_BASE));
|
||||||
|
}
|
||||||
|
|
||||||
|
int serial1_tstc(void)
|
||||||
|
{
|
||||||
|
return (serial_tstc_dev(PSC_BASE2));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct serial_device serial0_device =
|
||||||
|
{
|
||||||
|
"serial0",
|
||||||
|
"UART0",
|
||||||
|
serial0_init,
|
||||||
|
serial0_setbrg,
|
||||||
|
serial0_getc,
|
||||||
|
serial0_tstc,
|
||||||
|
serial0_putc,
|
||||||
|
serial0_puts,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct serial_device serial1_device =
|
||||||
|
{
|
||||||
|
"serial1",
|
||||||
|
"UART1",
|
||||||
|
serial1_init,
|
||||||
|
serial1_setbrg,
|
||||||
|
serial1_getc,
|
||||||
|
serial1_tstc,
|
||||||
|
serial1_putc,
|
||||||
|
serial1_puts,
|
||||||
|
};
|
||||||
|
#endif /* CONFIG_SERIAL_MULTI */
|
||||||
|
|
||||||
#endif /* CONFIG_PSC_CONSOLE */
|
#endif /* CONFIG_PSC_CONSOLE */
|
||||||
|
|
|
@ -52,3 +52,29 @@ PPC4XX Specific
|
||||||
setenv stdout serial0
|
setenv stdout serial0
|
||||||
setenv stderr serial0
|
setenv stderr serial0
|
||||||
setenv stdin serial0
|
setenv stdin serial0
|
||||||
|
|
||||||
|
MPC5xxx Specific
|
||||||
|
================
|
||||||
|
|
||||||
|
Up to two PSCs can be used as console.
|
||||||
|
|
||||||
|
Support for hardware handshake has not been implemented yet.
|
||||||
|
|
||||||
|
*) The first (default) console port is defined by:
|
||||||
|
#define CONFIG_PSC_CONSOLE <PSC number>
|
||||||
|
|
||||||
|
*) The second (alternative) console port is defined by:
|
||||||
|
#define CONFIG_PSC_CONSOLE2 <PSC number>
|
||||||
|
|
||||||
|
*) Commands to switch to the second console:
|
||||||
|
setenv stdout serial1
|
||||||
|
setenv stderr serial1
|
||||||
|
setenv stdin serial1
|
||||||
|
|
||||||
|
*) Commands to switch to the first console:
|
||||||
|
setenv stdout serial0
|
||||||
|
setenv stderr serial0
|
||||||
|
setenv stdin serial0
|
||||||
|
|
||||||
|
*) If a file descriptor is set to "serial" then the
|
||||||
|
current serial device will be used.
|
||||||
|
|
|
@ -23,7 +23,7 @@ extern struct serial_device serial_scc_device;
|
||||||
extern struct serial_device * default_serial_console (void);
|
extern struct serial_device * default_serial_console (void);
|
||||||
|
|
||||||
#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
|
#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
|
||||||
|| defined(CONFIG_405EP)
|
|| defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
|
||||||
extern struct serial_device serial0_device;
|
extern struct serial_device serial0_device;
|
||||||
extern struct serial_device serial1_device;
|
extern struct serial_device serial1_device;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue