summaryrefslogtreecommitdiff
path: root/drivers/serial
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-14 22:38:09 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:56 -0700
commit0dd9b84908469332c655361682507ad05736b4dc (patch)
tree25b94fed059bd9cb34e48162fa4c841f680b4b78 /drivers/serial
parenta943472c23d8ff71888aed033cc8b51c7bfb282a (diff)
downloadu-boot-imx-0dd9b84908469332c655361682507ad05736b4dc.zip
u-boot-imx-0dd9b84908469332c655361682507ad05736b4dc.tar.gz
u-boot-imx-0dd9b84908469332c655361682507ad05736b4dc.tar.bz2
serial: arm: Implement CONFIG_SERIAL_MULTI into netarm serial driver
Implement support for CONFIG_SERIAL_MULTI into netarm serial driver. This driver was so far only usable directly, but this patch also adds support for the multi method. This allows using more than one serial driver alongside the netarm driver. Also, add a weak implementation of default_serial_console() returning this driver. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Marek Vasut <marek.vasut@gmail.com> Cc: Tom Rini <trini@ti.com> Cc: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/serial_netarm.c65
1 files changed, 59 insertions, 6 deletions
diff --git a/drivers/serial/serial_netarm.c b/drivers/serial/serial_netarm.c
index d04790d..ff6612d 100644
--- a/drivers/serial/serial_netarm.c
+++ b/drivers/serial/serial_netarm.c
@@ -59,7 +59,7 @@ extern void _netarm_led_FAIL1(void);
/*
* Setup both serial i/f with given baudrate
*/
-void serial_setbrg (void)
+static void netarm_serial_setbrg(void)
{
/* set 0 ... make sure pins are configured for serial */
#if !defined(CONFIG_NETARM_NS7520)
@@ -108,7 +108,7 @@ void serial_setbrg (void)
* Initialise the serial port with the given baudrate. The settings
* are always 8 data bits, no parity, 1 stop bit, no start bits.
*/
-int serial_init (void)
+static int netarm_serial_init(void)
{
serial_setbrg ();
return 0;
@@ -118,7 +118,7 @@ int serial_init (void)
/*
* Output a single byte to the serial port.
*/
-void serial_putc (const char c)
+static void netarm_serial_putc(const char c)
{
volatile unsigned char *fifo;
@@ -135,7 +135,7 @@ void serial_putc (const char c)
* Test of a single byte from the serial port. Returns 1 on success, 0
* otherwise.
*/
-int serial_tstc(void)
+static int netarm_serial_tstc(void)
{
return serial_reg_ch1->status_a & NETARM_SER_STATA_RX_RDY;
}
@@ -144,7 +144,7 @@ int serial_tstc(void)
* Read a single byte from the serial port. Returns 1 on success, 0
* otherwise.
*/
-int serial_getc (void)
+static int netarm_serial_getc(void)
{
unsigned int ch_uint;
volatile unsigned int *fifo;
@@ -182,9 +182,62 @@ int serial_getc (void)
return ch_uint & 0xff;
}
-void serial_puts (const char *s)
+static void netarm_serial_puts(const char *s)
{
while (*s) {
serial_putc (*s++);
}
}
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device netarm_serial_drv = {
+ .name = "netarm_serial",
+ .start = netarm_serial_init,
+ .stop = NULL,
+ .setbrg = netarm_serial_setbrg,
+ .putc = netarm_serial_putc,
+ .puts = netarm_serial_puts,
+ .getc = netarm_serial_getc,
+ .tstc = netarm_serial_tstc,
+};
+
+void netarm_serial_initialize(void)
+{
+ serial_register(&netarm_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &netarm_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return netarm_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ netarm_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ netarm_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ netarm_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return netarm_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return netarm_serial_tstc();
+}
+#endif