Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 1 | The U-Boot Driver Model Project |
| 2 | =============================== |
| 3 | Serial I/O analysis |
| 4 | =================== |
| 5 | Marek Vasut <marek.vasut@gmail.com> |
| 6 | 2012-02-20 |
| 7 | |
| 8 | I) Overview |
| 9 | ----------- |
| 10 | |
| 11 | The serial port support currently requires the driver to export the following |
| 12 | functions: |
| 13 | |
| 14 | serial_putc() ...... Output a character |
| 15 | serial_puts() ...... Output string, often done using serial_putc() |
| 16 | serial_tstc() ...... Test if incoming character is in a buffer |
| 17 | serial_getc() ...... Retrieve incoming character |
| 18 | serial_setbrg() .... Configure port options |
| 19 | serial_init() ...... Initialize the hardware |
| 20 | |
| 21 | The simpliest implementation, supporting only one port, simply defines these six |
| 22 | functions and calls them. Such calls are scattered all around U-Boot, especiall |
| 23 | serial_putc(), serial_puts(), serial_tstc() and serial_getc(). The serial_init() |
| 24 | and serial_setbrg() are often called from platform-dependent places. |
| 25 | |
| 26 | It's important to consider current implementation of CONFIG_SERIAL_MULTI though. |
| 27 | This resides in common/serial.c and behaves as a multiplexer for serial ports. |
| 28 | This, by calling serial_assign(), allows user to switch I/O from one serial port |
| 29 | to another. Though the environmental variables "stdin", "stdout", "stderr" |
| 30 | remain set to "serial". |
| 31 | |
| 32 | These variables are managed by the IOMUX. This resides in common/iomux.c and |
| 33 | manages all console input/output from U-Boot. For serial port, only one IOMUX is |
| 34 | always registered, called "serial" and the switching of different serial ports |
| 35 | is done by code in common/serial.c. |
| 36 | |
| 37 | On a final note, it's important to mention function default_serial_console(), |
| 38 | which is platform specific and reports the default serial console for the |
| 39 | platform, unless proper environment variable overrides this. |
| 40 | |
| 41 | II) Approach |
| 42 | ------------ |
| 43 | |
| 44 | Drivers not using CONFIG_SERIAL_MULTI already will have to be converted to |
| 45 | similar approach. The probe() function of a driver will call a function |
| 46 | registering the driver with a STDIO subsystem core, stdio_device_register(). |
| 47 | |
| 48 | The serial_init() function will now be replaced by probe() function of the |
| 49 | driver, the rest of the components of the driver will be converted to standard |
| 50 | STDIO driver calls. See [ UDM-stdio.txt ] for details. |
| 51 | |
| 52 | The serial_setbrg() function depends on global data pointer. This is wrong, |
| 53 | since there is likely to be user willing to configure different baudrate on two |
| 54 | different serial ports. The function will be replaced with STDIO's "conf()" |
| 55 | call, with STDIO_CONFIG_SERIAL_BAUDRATE argument. |
| 56 | |
| 57 | III) Analysis of in-tree drivers |
| 58 | -------------------------------- |
| 59 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 60 | altera_jtag_uart.c |
| 61 | ------------------ |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 62 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 63 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 64 | altera_uart.c |
| 65 | ------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 66 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 67 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 68 | arm_dcc.c |
| 69 | --------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 70 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible, unless used |
| 71 | with CONFIG_ARM_DCC_MULTI. Then it registers another separate IOMUX. |
| 72 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 73 | atmel_usart.c |
| 74 | ------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 75 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 76 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 77 | mcfuart.c |
| 78 | --------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 79 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 80 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 81 | ns16550.c |
| 82 | --------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 83 | This driver seems complicated and certain consideration will need to be made |
| 84 | during conversion. This driver is implemented in very universal manner, |
| 85 | therefore it'll be necessary to properly design it's platform_data. |
| 86 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 87 | opencores_yanu.c |
| 88 | ---------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 89 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 90 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 91 | sandbox.c |
| 92 | --------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 93 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 94 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 95 | serial.c |
| 96 | -------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 97 | This is a complementary part of NS16550 UART driver, see above. |
| 98 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 99 | serial_imx.c |
| 100 | ------------ |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 101 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. This driver |
| 102 | might be removed in favor of serial_mxc.c . |
| 103 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 104 | serial_ixp.c |
| 105 | ------------ |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 106 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 107 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 108 | serial_ks8695.c |
| 109 | --------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 110 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 111 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 112 | serial_max3100.c |
| 113 | ---------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 114 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 115 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 116 | serial_mxc.c |
| 117 | ------------ |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 118 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 119 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 120 | serial_pl01x.c |
| 121 | -------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 122 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible, though this |
| 123 | driver in fact contains two drivers in total. |
| 124 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 125 | serial_pxa.c |
| 126 | ------------ |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 127 | This driver is a bit complicated, but due to clean support for |
| 128 | CONFIG_SERIAL_MULTI, there are no expected obstructions throughout the |
| 129 | conversion process. |
| 130 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 131 | serial_s3c24x0.c |
| 132 | ---------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 133 | This driver, being quite ad-hoc might need some work to bring back to shape. |
| 134 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 135 | serial_s5p.c |
| 136 | ------------ |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 137 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 138 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 139 | serial_sa1100.c |
| 140 | --------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 141 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 142 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 143 | serial_sh.c |
| 144 | ----------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 145 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 146 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 147 | serial_xuartlite.c |
| 148 | ------------------ |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 149 | No support for CONFIG_SERIAL_MULTI. Simple conversion possible. |
| 150 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 151 | usbtty.c |
| 152 | -------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 153 | This driver seems very complicated and entangled with USB framework. The |
| 154 | conversion might be complicated here. |
| 155 | |
Masahiro Yamada | a756da9 | 2013-09-24 10:32:04 +0900 | [diff] [blame] | 156 | arch/powerpc/cpu/mpc512x/serial.c |
| 157 | --------------------------------- |
Marek Vasut | 909bbcc | 2012-08-08 01:42:17 +0000 | [diff] [blame] | 158 | This driver supports CONFIG_SERIAL_MULTI. This driver will need to be moved to |
| 159 | proper place. |