mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-24 12:44:23 +08:00
Make the serial driver framework work with CONFIG_SERIAL_MULTI enabled
This commit is contained in:
parent
2b75062a0f
commit
0fd30252c8
@ -2,6 +2,9 @@
|
||||
Changes since U-Boot 1.1.4:
|
||||
======================================================================
|
||||
|
||||
* Make the serial driver framework work with CONFIG_SERIAL_MULTI
|
||||
enabled
|
||||
|
||||
* PCIe endpoint support for AMCC Yucca 440SPe board
|
||||
Patch by Tirumala R Marri, 26 Aug 2006
|
||||
|
||||
|
@ -42,7 +42,19 @@ struct serial_device *default_serial_console (void)
|
||||
return &serial_scc_device;
|
||||
#elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
|
||||
|| defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
|
||||
#if defined(CONFIG_UART1_CONSOLE)
|
||||
#if defined(CONFIG_CONS_INDEX) && defined(CFG_NS16550_SERIAL)
|
||||
#if (CONFIG_CONS_INDEX==1)
|
||||
return &eserial1_device;
|
||||
#elif (CONFIG_CONS_INDEX==2)
|
||||
return &eserial2_device;
|
||||
#elif (CONFIG_CONS_INDEX==3)
|
||||
return &eserial3_device;
|
||||
#elif (CONFIG_CONS_INDEX==4)
|
||||
return &eserial4_device;
|
||||
#else
|
||||
#error "Bad CONFIG_CONS_INDEX."
|
||||
#endif
|
||||
#elif defined(CONFIG_UART1_CONSOLE)
|
||||
return &serial1_device;
|
||||
#else
|
||||
return &serial0_device;
|
||||
@ -84,6 +96,20 @@ void serial_initialize (void)
|
||||
serial_register(&serial1_device);
|
||||
#endif
|
||||
|
||||
#if defined(CFG_NS16550_SERIAL)
|
||||
#if defined(CFG_NS16550_COM1)
|
||||
serial_register(&eserial1_device);
|
||||
#endif
|
||||
#if defined(CFG_NS16550_COM2)
|
||||
serial_register(&eserial2_device);
|
||||
#endif
|
||||
#if defined(CFG_NS16550_COM3)
|
||||
serial_register(&eserial3_device);
|
||||
#endif
|
||||
#if defined(CFG_NS16550_COM4)
|
||||
serial_register(&eserial4_device);
|
||||
#endif
|
||||
#endif /* CFG_NS16550_SERIAL */
|
||||
serial_assign (default_serial_console ()->name);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,10 @@
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#if !defined(CONFIG_CONS_INDEX)
|
||||
#error "No console index specified."
|
||||
#endif
|
||||
|
||||
#define CONSOLE CONFIG_CONS_INDEX
|
||||
|
||||
static unsigned int calcBitrateRegister( void );
|
||||
|
111
drivers/serial.c
111
drivers/serial.c
@ -30,10 +30,20 @@
|
||||
#include <ns87308.h>
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_SERIAL_MULTI)
|
||||
#include <serial.h>
|
||||
#endif
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#if !defined(CONFIG_CONS_INDEX)
|
||||
#if defined (CONFIG_SERIAL_MULTI)
|
||||
/* with CONFIG_SERIAL_MULTI we might have no console
|
||||
* on these devices
|
||||
*/
|
||||
#else
|
||||
#error "No console index specified."
|
||||
#endif /* CONFIG_SERIAL_MULTI */
|
||||
#elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 4)
|
||||
#error "Invalid console index value."
|
||||
#endif
|
||||
@ -75,7 +85,42 @@ static NS16550_t serial_ports[4] = {
|
||||
};
|
||||
|
||||
#define PORT serial_ports[port-1]
|
||||
#if defined(CONFIG_CONS_INDEX)
|
||||
#define CONSOLE (serial_ports[CONFIG_CONS_INDEX-1])
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
|
||||
/* Multi serial device functions */
|
||||
#define DECLARE_ESERIAL_FUNCTIONS(port) \
|
||||
int eserial##port##_init (void) {\
|
||||
int clock_divisor; \
|
||||
clock_divisor = calc_divisor(serial_ports[port-1]); \
|
||||
NS16550_init(serial_ports[port-1], clock_divisor); \
|
||||
return(0);}\
|
||||
void eserial##port##_setbrg (void) {\
|
||||
serial_setbrg_dev(port);}\
|
||||
int eserial##port##_getc (void) {\
|
||||
return serial_getc_dev(port);}\
|
||||
int eserial##port##_tstc (void) {\
|
||||
return serial_tstc_dev(port);}\
|
||||
void eserial##port##_putc (const char c) {\
|
||||
serial_putc_dev(port, c);}\
|
||||
void eserial##port##_puts (const char *s) {\
|
||||
serial_puts_dev(port, s);}
|
||||
|
||||
/* Serial device descriptor */
|
||||
#define INIT_ESERIAL_STRUCTURE(port,name,bus) {\
|
||||
name,\
|
||||
bus,\
|
||||
eserial##port##_init,\
|
||||
eserial##port##_setbrg,\
|
||||
eserial##port##_getc,\
|
||||
eserial##port##_tstc,\
|
||||
eserial##port##_putc,\
|
||||
eserial##port##_puts, }
|
||||
|
||||
#endif /* CONFIG_SERIAL_MULTI */
|
||||
|
||||
static int calc_divisor (NS16550_t port)
|
||||
{
|
||||
@ -103,6 +148,7 @@ static int calc_divisor (NS16550_t port)
|
||||
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_SERIAL_MULTI)
|
||||
int serial_init (void)
|
||||
{
|
||||
int clock_divisor;
|
||||
@ -130,6 +176,7 @@ int serial_init (void)
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
_serial_putc(const char c,const int port)
|
||||
@ -176,40 +223,104 @@ _serial_setbrg (const int port)
|
||||
NS16550_reinit(PORT, clock_divisor);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
static inline void
|
||||
serial_putc_dev(unsigned int dev_index,const char c)
|
||||
{
|
||||
_serial_putc(c,dev_index);
|
||||
}
|
||||
#else
|
||||
void
|
||||
serial_putc(const char c)
|
||||
{
|
||||
_serial_putc(c,CONFIG_CONS_INDEX);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
static inline void
|
||||
serial_putc_raw_dev(unsigned int dev_index,const char c)
|
||||
{
|
||||
_serial_putc_raw(c,dev_index);
|
||||
}
|
||||
#else
|
||||
void
|
||||
serial_putc_raw(const char c)
|
||||
{
|
||||
_serial_putc_raw(c,CONFIG_CONS_INDEX);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
static inline void
|
||||
serial_puts_dev(unsigned int dev_index,const char *s)
|
||||
{
|
||||
_serial_puts(s,dev_index);
|
||||
}
|
||||
#else
|
||||
void
|
||||
serial_puts(const char *s)
|
||||
{
|
||||
_serial_puts(s,CONFIG_CONS_INDEX);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
static inline int
|
||||
serial_getc_dev(unsigned int dev_index)
|
||||
{
|
||||
return _serial_getc(dev_index);
|
||||
}
|
||||
#else
|
||||
int
|
||||
serial_getc(void)
|
||||
{
|
||||
return _serial_getc(CONFIG_CONS_INDEX);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
static inline int
|
||||
serial_tstc_dev(unsigned int dev_index)
|
||||
{
|
||||
return _serial_tstc(dev_index);
|
||||
}
|
||||
#else
|
||||
int
|
||||
serial_tstc(void)
|
||||
{
|
||||
return _serial_tstc(CONFIG_CONS_INDEX);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
static inline void
|
||||
serial_setbrg_dev(unsigned int dev_index)
|
||||
{
|
||||
_serial_setbrg(dev_index);
|
||||
}
|
||||
#else
|
||||
void
|
||||
serial_setbrg(void)
|
||||
{
|
||||
_serial_setbrg(CONFIG_CONS_INDEX);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SERIAL_MULTI)
|
||||
|
||||
DECLARE_ESERIAL_FUNCTIONS(1);
|
||||
struct serial_device eserial1_device =
|
||||
INIT_ESERIAL_STRUCTURE(1,"eserial0","EUART1");
|
||||
DECLARE_ESERIAL_FUNCTIONS(2);
|
||||
struct serial_device eserial2_device =
|
||||
INIT_ESERIAL_STRUCTURE(2,"eserial1","EUART2");
|
||||
DECLARE_ESERIAL_FUNCTIONS(3);
|
||||
struct serial_device eserial3_device =
|
||||
INIT_ESERIAL_STRUCTURE(3,"eserial2","EUART3");
|
||||
DECLARE_ESERIAL_FUNCTIONS(4);
|
||||
struct serial_device eserial4_device =
|
||||
INIT_ESERIAL_STRUCTURE(4,"eserial3","EUART4");
|
||||
#endif /* CONFIG_SERIAL_MULTI */
|
||||
|
||||
#endif
|
||||
|
@ -72,12 +72,15 @@
|
||||
*/
|
||||
#if !defined(CONFIG_PRS200)
|
||||
/* MCC200 configuration: */
|
||||
#undef CONFIG_PSC_CONSOLE
|
||||
#define CONFIG_SERIAL_MULTI 1
|
||||
#define CONFIG_PSC_CONSOLE 1 /* PSC1 may be COM */
|
||||
#define CONFIG_PSC_CONSOLE2 2 /* PSC2 is PSoC */
|
||||
#else
|
||||
/* PRS200 configuration: */
|
||||
#define CONFIG_PSC_CONSOLE 1 /* console is on PSC1 */
|
||||
#endif
|
||||
#if defined(CONFIG_QUART_CONSOLE) && defined(CONFIG_PSC_CONSOLE)
|
||||
#if defined(CONFIG_QUART_CONSOLE) && defined(CONFIG_PSC_CONSOLE) && \
|
||||
!defined(CONFIG_SERIAL_MULTI)
|
||||
#error "Select only one console device!"
|
||||
#endif
|
||||
#define CONFIG_BAUDRATE 115200
|
||||
|
@ -26,6 +26,13 @@ extern struct serial_device * default_serial_console (void);
|
||||
|| defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
|
||||
extern struct serial_device serial0_device;
|
||||
extern struct serial_device serial1_device;
|
||||
#if defined(CFG_NS16550_SERIAL)
|
||||
extern struct serial_device eserial1_device;
|
||||
extern struct serial_device eserial2_device;
|
||||
extern struct serial_device eserial3_device;
|
||||
extern struct serial_device eserial4_device;
|
||||
#endif /* CFG_NS16550_SERIAL */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user