UDM-serial.txt 5.9 KB

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