105-serial-ns16550-bugfix-ns16550-fifo-not-enabled.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. From 17fa032671f7981628fe16b30399638842a4b1bb Mon Sep 17 00:00:00 2001
  2. From: Heiko Schocher <[email protected]>
  3. Date: Wed, 18 Jan 2017 08:05:49 +0100
  4. Subject: [PATCH] serial, ns16550: bugfix: ns16550 fifo not enabled
  5. commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
  6. breaks u-boot commandline working with long commands
  7. sending to the board.
  8. Since the above patch, you have to setup the fcr register.
  9. For board/archs which enable OF_PLATDATA, the new field
  10. fcr in struct ns16550_platdata is not filled with a
  11. default value ...
  12. This leads in not setting up the uarts fifo, which ends
  13. in problems, when you send long commands to u-boots
  14. commandline.
  15. Detected this issue with automated tbot tests on am335x
  16. based shc board.
  17. The error does not popup, if you type commands. You need
  18. to copy&paste a long command to u-boots commandshell
  19. (or send a long command with tbot)
  20. Possible boards/plattforms with problems:
  21. ./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
  22. ./arch/arm/mach-tegra/board.c
  23. ./board/overo/overo.c
  24. ./board/quipos/cairo/cairo.c
  25. ./board/logicpd/omap3som/omap3logic.c
  26. ./board/logicpd/zoom1/zoom1.c
  27. ./board/timll/devkit8000/devkit8000.c
  28. ./board/lg/sniper/sniper.c
  29. ./board/ti/beagle/beagle.c
  30. ./drivers/serial/serial_rockchip.c
  31. Signed-off-by: Heiko Schocher <[email protected]>
  32. Signed-off-by: Ladislav Michl <[email protected]>
  33. Tested-by: Adam Ford <[email protected]>
  34. Reviewed-by: Tom Rini <[email protected]>
  35. ---
  36. arch/arm/cpu/arm926ejs/lpc32xx/devices.c | 12 ++++++++----
  37. arch/arm/mach-omap2/am33xx/board.c | 18 ++++++++++++------
  38. arch/arm/mach-tegra/board.c | 1 +
  39. board/isee/igep00x0/igep00x0.c | 3 ++-
  40. board/lg/sniper/sniper.c | 3 ++-
  41. board/logicpd/omap3som/omap3logic.c | 3 ++-
  42. board/logicpd/zoom1/zoom1.c | 3 ++-
  43. board/overo/overo.c | 3 ++-
  44. board/quipos/cairo/cairo.c | 3 ++-
  45. board/ti/beagle/beagle.c | 3 ++-
  46. board/timll/devkit8000/devkit8000.c | 3 ++-
  47. drivers/serial/ns16550.c | 9 +++------
  48. drivers/serial/serial_rockchip.c | 1 +
  49. include/ns16550.h | 5 +++++
  50. 14 files changed, 46 insertions(+), 24 deletions(-)
  51. diff --git a/arch/arm/cpu/arm926ejs/lpc32xx/devices.c b/arch/arm/cpu/arm926ejs/lpc32xx/devices.c
  52. index 399b07c5420a..f744398ca7ad 100644
  53. --- a/arch/arm/cpu/arm926ejs/lpc32xx/devices.c
  54. +++ b/arch/arm/cpu/arm926ejs/lpc32xx/devices.c
  55. @@ -45,10 +45,14 @@ void lpc32xx_uart_init(unsigned int uart_id)
  56. #if !CONFIG_IS_ENABLED(OF_CONTROL)
  57. static const struct ns16550_platdata lpc32xx_uart[] = {
  58. - { .base = UART3_BASE, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  59. - { .base = UART4_BASE, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  60. - { .base = UART5_BASE, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  61. - { .base = UART6_BASE, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  62. + { .base = UART3_BASE, .reg_shift = 2,
  63. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  64. + { .base = UART4_BASE, .reg_shift = 2,
  65. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  66. + { .base = UART5_BASE, .reg_shift = 2,
  67. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  68. + { .base = UART6_BASE, .reg_shift = 2,
  69. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  70. };
  71. #if defined(CONFIG_LPC32XX_HSUART)
  72. diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c
  73. index 73824df18fa7..190310fd0079 100644
  74. --- a/arch/arm/mach-omap2/am33xx/board.c
  75. +++ b/arch/arm/mach-omap2/am33xx/board.c
  76. @@ -40,14 +40,20 @@ DECLARE_GLOBAL_DATA_PTR;
  77. #if !CONFIG_IS_ENABLED(OF_CONTROL)
  78. static const struct ns16550_platdata am33xx_serial[] = {
  79. - { .base = CONFIG_SYS_NS16550_COM1, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  80. + { .base = CONFIG_SYS_NS16550_COM1, .reg_shift = 2,
  81. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  82. # ifdef CONFIG_SYS_NS16550_COM2
  83. - { .base = CONFIG_SYS_NS16550_COM2, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  84. + { .base = CONFIG_SYS_NS16550_COM2, .reg_shift = 2,
  85. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  86. # ifdef CONFIG_SYS_NS16550_COM3
  87. - { .base = CONFIG_SYS_NS16550_COM3, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  88. - { .base = CONFIG_SYS_NS16550_COM4, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  89. - { .base = CONFIG_SYS_NS16550_COM5, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  90. - { .base = CONFIG_SYS_NS16550_COM6, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK },
  91. + { .base = CONFIG_SYS_NS16550_COM3, .reg_shift = 2,
  92. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  93. + { .base = CONFIG_SYS_NS16550_COM4, .reg_shift = 2,
  94. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  95. + { .base = CONFIG_SYS_NS16550_COM5, .reg_shift = 2,
  96. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  97. + { .base = CONFIG_SYS_NS16550_COM6, .reg_shift = 2,
  98. + .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  99. # endif
  100. # endif
  101. };
  102. diff --git a/arch/arm/mach-tegra/board.c b/arch/arm/mach-tegra/board.c
  103. index 3d1d26d13d13..b3a041b539af 100644
  104. --- a/arch/arm/mach-tegra/board.c
  105. +++ b/arch/arm/mach-tegra/board.c
  106. @@ -219,6 +219,7 @@ static struct ns16550_platdata ns16550_com1_pdata = {
  107. .base = CONFIG_SYS_NS16550_COM1,
  108. .reg_shift = 2,
  109. .clock = CONFIG_SYS_NS16550_CLK,
  110. + .fcr = UART_FCR_DEFVAL,
  111. };
  112. U_BOOT_DEVICE(ns16550_com1) = {
  113. diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
  114. index ae7959b1eb6e..5a3498f570a6 100644
  115. --- a/board/isee/igep00x0/igep00x0.c
  116. +++ b/board/isee/igep00x0/igep00x0.c
  117. @@ -32,7 +32,8 @@ DECLARE_GLOBAL_DATA_PTR;
  118. static const struct ns16550_platdata igep_serial = {
  119. .base = OMAP34XX_UART3,
  120. .reg_shift = 2,
  121. - .clock = V_NS16550_CLK
  122. + .clock = V_NS16550_CLK,
  123. + .fcr = UART_FCR_DEFVAL,
  124. };
  125. U_BOOT_DEVICE(igep_uart) = {
  126. diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c
  127. index 0662449c3875..b2b8f8861f11 100644
  128. --- a/board/lg/sniper/sniper.c
  129. +++ b/board/lg/sniper/sniper.c
  130. @@ -31,7 +31,8 @@ const omap3_sysinfo sysinfo = {
  131. static const struct ns16550_platdata serial_omap_platdata = {
  132. .base = OMAP34XX_UART3,
  133. .reg_shift = 2,
  134. - .clock = V_NS16550_CLK
  135. + .clock = V_NS16550_CLK,
  136. + .fcr = UART_FCR_DEFVAL,
  137. };
  138. U_BOOT_DEVICE(sniper_serial) = {
  139. diff --git a/board/logicpd/omap3som/omap3logic.c b/board/logicpd/omap3som/omap3logic.c
  140. index 21b3fdcf49cf..b2fcc28f8b4b 100644
  141. --- a/board/logicpd/omap3som/omap3logic.c
  142. +++ b/board/logicpd/omap3som/omap3logic.c
  143. @@ -49,7 +49,8 @@ DECLARE_GLOBAL_DATA_PTR;
  144. static const struct ns16550_platdata omap3logic_serial = {
  145. .base = OMAP34XX_UART1,
  146. .reg_shift = 2,
  147. - .clock = V_NS16550_CLK
  148. + .clock = V_NS16550_CLK,
  149. + .fcr = UART_FCR_DEFVAL,
  150. };
  151. U_BOOT_DEVICE(omap3logic_uart) = {
  152. diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
  153. index 2821ee22674f..0fad23af62f6 100644
  154. --- a/board/logicpd/zoom1/zoom1.c
  155. +++ b/board/logicpd/zoom1/zoom1.c
  156. @@ -47,7 +47,8 @@ static const u32 gpmc_lab_enet[] = {
  157. static const struct ns16550_platdata zoom1_serial = {
  158. .base = OMAP34XX_UART3,
  159. .reg_shift = 2,
  160. - .clock = V_NS16550_CLK
  161. + .clock = V_NS16550_CLK,
  162. + .fcr = UART_FCR_DEFVAL,
  163. };
  164. U_BOOT_DEVICE(zoom1_uart) = {
  165. diff --git a/board/overo/overo.c b/board/overo/overo.c
  166. index 40f13e5876cc..5e447262bcfd 100644
  167. --- a/board/overo/overo.c
  168. +++ b/board/overo/overo.c
  169. @@ -70,7 +70,8 @@ static struct {
  170. static const struct ns16550_platdata overo_serial = {
  171. .base = OMAP34XX_UART3,
  172. .reg_shift = 2,
  173. - .clock = V_NS16550_CLK
  174. + .clock = V_NS16550_CLK,
  175. + .fcr = UART_FCR_DEFVAL,
  176. };
  177. U_BOOT_DEVICE(overo_uart) = {
  178. diff --git a/board/quipos/cairo/cairo.c b/board/quipos/cairo/cairo.c
  179. index 77e4482906f0..793aa9023150 100644
  180. --- a/board/quipos/cairo/cairo.c
  181. +++ b/board/quipos/cairo/cairo.c
  182. @@ -93,7 +93,8 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
  183. static const struct ns16550_platdata cairo_serial = {
  184. .base = OMAP34XX_UART2,
  185. .reg_shift = 2,
  186. - .clock = V_NS16550_CLK
  187. + .clock = V_NS16550_CLK,
  188. + .fcr = UART_FCR_DEFVAL,
  189. };
  190. U_BOOT_DEVICE(cairo_uart) = {
  191. diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
  192. index cfdab3e34253..23c79333a223 100644
  193. --- a/board/ti/beagle/beagle.c
  194. +++ b/board/ti/beagle/beagle.c
  195. @@ -75,7 +75,8 @@ static struct {
  196. static const struct ns16550_platdata beagle_serial = {
  197. .base = OMAP34XX_UART3,
  198. .reg_shift = 2,
  199. - .clock = V_NS16550_CLK
  200. + .clock = V_NS16550_CLK,
  201. + .fcr = UART_FCR_DEFVAL,
  202. };
  203. U_BOOT_DEVICE(beagle_uart) = {
  204. diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
  205. index f785dbe6d732..b2f060b2ddbf 100644
  206. --- a/board/timll/devkit8000/devkit8000.c
  207. +++ b/board/timll/devkit8000/devkit8000.c
  208. @@ -48,7 +48,8 @@ static u32 gpmc_net_config[GPMC_MAX_REG] = {
  209. static const struct ns16550_platdata devkit8000_serial = {
  210. .base = OMAP34XX_UART3,
  211. .reg_shift = 2,
  212. - .clock = V_NS16550_CLK
  213. + .clock = V_NS16550_CLK,
  214. + .fcr = UART_FCR_DEFVAL,
  215. };
  216. U_BOOT_DEVICE(devkit8000_uart) = {
  217. diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
  218. index 9b423a591d8a..2df4a1f04fe5 100644
  219. --- a/drivers/serial/ns16550.c
  220. +++ b/drivers/serial/ns16550.c
  221. @@ -20,9 +20,6 @@ DECLARE_GLOBAL_DATA_PTR;
  222. #define UART_LCRVAL UART_LCR_8N1 /* 8 data, 1 stop, no parity */
  223. #define UART_MCRVAL (UART_MCR_DTR | \
  224. UART_MCR_RTS) /* RTS/DTR */
  225. -#define UART_FCRVAL (UART_FCR_FIFO_EN | \
  226. - UART_FCR_RXSR | \
  227. - UART_FCR_TXSR) /* Clear & enable FIFOs */
  228. #ifndef CONFIG_DM_SERIAL
  229. #ifdef CONFIG_SYS_NS16550_PORT_MAPPED
  230. @@ -138,7 +135,7 @@ static u32 ns16550_getfcr(NS16550_t port)
  231. #else
  232. static u32 ns16550_getfcr(NS16550_t port)
  233. {
  234. - return UART_FCRVAL;
  235. + return UART_FCR_DEFVAL;
  236. }
  237. #endif
  238. @@ -275,7 +272,7 @@ static inline void _debug_uart_init(void)
  239. CONFIG_BAUDRATE);
  240. serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER);
  241. serial_dout(&com_port->mcr, UART_MCRVAL);
  242. - serial_dout(&com_port->fcr, UART_FCRVAL);
  243. + serial_dout(&com_port->fcr, UART_FCR_DEFVAL);
  244. serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL);
  245. serial_dout(&com_port->dll, baud_divisor & 0xff);
  246. @@ -440,7 +437,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
  247. return -EINVAL;
  248. }
  249. - plat->fcr = UART_FCRVAL;
  250. + plat->fcr = UART_FCR_DEFVAL;
  251. if (port_type == PORT_JZ4780)
  252. plat->fcr |= UART_FCR_UME;
  253. diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c
  254. index 6bac95a414ce..c06afc58f7ea 100644
  255. --- a/drivers/serial/serial_rockchip.c
  256. +++ b/drivers/serial/serial_rockchip.c
  257. @@ -27,6 +27,7 @@ static int rockchip_serial_probe(struct udevice *dev)
  258. plat->plat.base = plat->dtplat.reg[0];
  259. plat->plat.reg_shift = plat->dtplat.reg_shift;
  260. plat->plat.clock = plat->dtplat.clock_frequency;
  261. + plat->plat.fcr = UART_FCR_DEFVAL;
  262. dev->platdata = &plat->plat;
  263. return ns16550_serial_probe(dev);
  264. diff --git a/include/ns16550.h b/include/ns16550.h
  265. index 7c9703683109..5fcbcd2e74e3 100644
  266. --- a/include/ns16550.h
  267. +++ b/include/ns16550.h
  268. @@ -121,6 +121,11 @@ typedef struct NS16550 *NS16550_t;
  269. /* Ingenic JZ47xx specific UART-enable bit. */
  270. #define UART_FCR_UME 0x10
  271. +/* Clear & enable FIFOs */
  272. +#define UART_FCR_DEFVAL (UART_FCR_FIFO_EN | \
  273. + UART_FCR_RXSR | \
  274. + UART_FCR_TXSR)
  275. +
  276. /*
  277. * These are the definitions for the Modem Control Register
  278. */
  279. --
  280. 2.17.0