c25bf28361eaa920ae2b444568f441a18320227d
[kernel/u-boot.git] / recovery / serial.c
1 /*
2  * Copyright (C) 2010 Samsung Electronics
3  * Sanghee Kim <sh0130.kim@samsung.com>
4  */
5
6 #include <common.h>
7 #include <serial.h>
8
9 static struct serial_device *serial_current = NULL;
10
11 struct serial_device *__default_serial_console(void)
12 {
13         return &s5pc1xx_serial2_device;
14 }
15
16 struct serial_device *default_serial_console(void)
17         __attribute__((weak, alias("__default_serial_console")));
18
19 void serial_putc(const char c)
20 {
21         if (!serial_current) {
22                 struct serial_device *dev = default_serial_console();
23
24                 dev->putc(c);
25                 return;
26         }
27
28         serial_current->putc(c);
29 }
30
31 void serial_puts(const char *s)
32 {
33         if (!serial_current) {
34                 struct serial_device *dev = default_serial_console();
35
36                 dev->puts(s);
37                 return;
38         }
39
40         serial_current->puts(s);
41 }
42
43 int serial_init(void)
44 {
45         if (!serial_current) {
46                 struct serial_device *dev = default_serial_console();
47
48                 return dev->init();
49         }
50
51         return serial_current->init();
52 }