summaryrefslogtreecommitdiff
path: root/doc/driver-model/UDM-serial.txt
blob: 279e941fc03b69d43f368add25c45711c1f0c874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
The U-Boot Driver Model Project
===============================
Serial I/O analysis
===================
Marek Vasut <marek.vasut@gmail.com>
2012-02-20

I) Overview
-----------

The serial port support currently requires the driver to export the following
functions:

  serial_putc() ...... Output a character
  serial_puts() ...... Output string, often done using serial_putc()
  serial_tstc() ...... Test if incoming character is in a buffer
  serial_getc() ...... Retrieve incoming character
  serial_setbrg() .... Configure port options
  serial_init() ...... Initialize the hardware

The simpliest implementation, supporting only one port, simply defines these six
functions and calls them. Such calls are scattered all around U-Boot, especiall
serial_putc(), serial_puts(), serial_tstc() and serial_getc(). The serial_init()
and serial_setbrg() are often called from platform-dependent places.

It's important to consider current implementation of CONFIG_SERIAL_MULTI though.
This resides in common/serial.c and behaves as a multiplexer for serial ports.
This, by calling serial_assign(), allows user to switch I/O from one serial port
to another. Though the environmental variables "stdin", "stdout", "stderr"
remain set to "serial".

These variables are managed by the IOMUX. This resides in common/iomux.c and
manages all console input/output from U-Boot. For serial port, only one IOMUX is
always registered, called "serial" and the switching of different serial ports
is done by code in common/serial.c.

On a final note, it's important to mention function default_serial_console(),
which is platform specific and reports the default serial console for the
platform, unless proper environment variable overrides this.

II) Approach
------------

Drivers not using CONFIG_SERIAL_MULTI already will have to be converted to
similar approach. The probe() function of a driver will call a function
registering the driver with a STDIO subsystem core, stdio_device_register().

The serial_init() function will now be replaced by probe() function of the
driver, the rest of the components of the driver will be converted to standard
STDIO driver calls. See [ UDM-stdio.txt ] for details.

The serial_setbrg() function depends on global data pointer. This is wrong,
since there is likely to be user willing to configure different baudrate on two
different serial ports. The function will be replaced with STDIO's "conf()"
call, with STDIO_CONFIG_SERIAL_BAUDRATE argument.

III) Analysis of in-tree drivers
--------------------------------

  altera_jtag_uart.c
  ------------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  altera_uart.c
  -------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  arm_dcc.c
  ---------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible, unless used
  with CONFIG_ARM_DCC_MULTI. Then it registers another separate IOMUX.

  atmel_usart.c
  -------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  mcfuart.c
  ---------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  ns16550.c
  ---------
  This driver seems complicated and certain consideration will need to be made
  during conversion. This driver is implemented in very universal manner,
  therefore it'll be necessary to properly design it's platform_data.

  opencores_yanu.c
  ----------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  sandbox.c
  ---------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial.c
  --------
  This is a complementary part of NS16550 UART driver, see above.

  serial_imx.c
  ------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible. This driver
  might be removed in favor of serial_mxc.c .

  serial_ixp.c
  ------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial_ks8695.c
  ---------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial_max3100.c
  ----------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial_mxc.c
  ------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial_pl01x.c
  --------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible, though this
  driver in fact contains two drivers in total.

  serial_pxa.c
  ------------
  This driver is a bit complicated, but due to clean support for
  CONFIG_SERIAL_MULTI, there are no expected obstructions throughout the
  conversion process.

  serial_s3c24x0.c
  ----------------
  This driver, being quite ad-hoc might need some work to bring back to shape.

  serial_s5p.c
  ------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial_sa1100.c
  ---------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial_sh.c
  -----------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  serial_xuartlite.c
  ------------------
  No support for CONFIG_SERIAL_MULTI. Simple conversion possible.

  usbtty.c
  --------
  This driver seems very complicated and entangled with USB framework. The
  conversion might be complicated here.

  arch/powerpc/cpu/mpc512x/serial.c
  ---------------------------------
  This driver supports CONFIG_SERIAL_MULTI. This driver will need to be moved to
  proper place.