Commit 0fd30252c840ee54d2a80475d6504766d43b8add

Authored by Wolfgang Denk
1 parent 2b75062a0f
Exists in master and in 55 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf_v2022.04, emb_lf_v2023.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

Make the serial driver framework work with CONFIG_SERIAL_MULTI enabled

Showing 6 changed files with 157 additions and 3 deletions Side-by-side Diff

... ... @@ -2,6 +2,9 @@
2 2 Changes since U-Boot 1.1.4:
3 3 ======================================================================
4 4  
  5 +* Make the serial driver framework work with CONFIG_SERIAL_MULTI
  6 + enabled
  7 +
5 8 * PCIe endpoint support for AMCC Yucca 440SPe board
6 9 Patch by Tirumala R Marri, 26 Aug 2006
7 10  
... ... @@ -42,7 +42,19 @@
42 42 return &serial_scc_device;
43 43 #elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
44 44 || defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
45   -#if defined(CONFIG_UART1_CONSOLE)
  45 +#if defined(CONFIG_CONS_INDEX) && defined(CFG_NS16550_SERIAL)
  46 +#if (CONFIG_CONS_INDEX==1)
  47 + return &eserial1_device;
  48 +#elif (CONFIG_CONS_INDEX==2)
  49 + return &eserial2_device;
  50 +#elif (CONFIG_CONS_INDEX==3)
  51 + return &eserial3_device;
  52 +#elif (CONFIG_CONS_INDEX==4)
  53 + return &eserial4_device;
  54 +#else
  55 +#error "Bad CONFIG_CONS_INDEX."
  56 +#endif
  57 +#elif defined(CONFIG_UART1_CONSOLE)
46 58 return &serial1_device;
47 59 #else
48 60 return &serial0_device;
... ... @@ -84,6 +96,20 @@
84 96 serial_register(&serial1_device);
85 97 #endif
86 98  
  99 +#if defined(CFG_NS16550_SERIAL)
  100 +#if defined(CFG_NS16550_COM1)
  101 + serial_register(&eserial1_device);
  102 +#endif
  103 +#if defined(CFG_NS16550_COM2)
  104 + serial_register(&eserial2_device);
  105 +#endif
  106 +#if defined(CFG_NS16550_COM3)
  107 + serial_register(&eserial3_device);
  108 +#endif
  109 +#if defined(CFG_NS16550_COM4)
  110 + serial_register(&eserial4_device);
  111 +#endif
  112 +#endif /* CFG_NS16550_SERIAL */
87 113 serial_assign (default_serial_console ()->name);
88 114 }
89 115  
drivers/ns9750_serial.c
... ... @@ -35,6 +35,10 @@
35 35  
36 36 DECLARE_GLOBAL_DATA_PTR;
37 37  
  38 +#if !defined(CONFIG_CONS_INDEX)
  39 +#error "No console index specified."
  40 +#endif
  41 +
38 42 #define CONSOLE CONFIG_CONS_INDEX
39 43  
40 44 static unsigned int calcBitrateRegister( void );
... ... @@ -30,10 +30,20 @@
30 30 #include <ns87308.h>
31 31 #endif
32 32  
  33 +#if defined (CONFIG_SERIAL_MULTI)
  34 +#include <serial.h>
  35 +#endif
  36 +
33 37 DECLARE_GLOBAL_DATA_PTR;
34 38  
35 39 #if !defined(CONFIG_CONS_INDEX)
  40 +#if defined (CONFIG_SERIAL_MULTI)
  41 +/* with CONFIG_SERIAL_MULTI we might have no console
  42 + * on these devices
  43 + */
  44 +#else
36 45 #error "No console index specified."
  46 +#endif /* CONFIG_SERIAL_MULTI */
37 47 #elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 4)
38 48 #error "Invalid console index value."
39 49 #endif
40 50  
41 51  
... ... @@ -75,8 +85,43 @@
75 85 };
76 86  
77 87 #define PORT serial_ports[port-1]
  88 +#if defined(CONFIG_CONS_INDEX)
78 89 #define CONSOLE (serial_ports[CONFIG_CONS_INDEX-1])
  90 +#endif
79 91  
  92 +#if defined(CONFIG_SERIAL_MULTI)
  93 +
  94 +/* Multi serial device functions */
  95 +#define DECLARE_ESERIAL_FUNCTIONS(port) \
  96 + int eserial##port##_init (void) {\
  97 + int clock_divisor; \
  98 + clock_divisor = calc_divisor(serial_ports[port-1]); \
  99 + NS16550_init(serial_ports[port-1], clock_divisor); \
  100 + return(0);}\
  101 + void eserial##port##_setbrg (void) {\
  102 + serial_setbrg_dev(port);}\
  103 + int eserial##port##_getc (void) {\
  104 + return serial_getc_dev(port);}\
  105 + int eserial##port##_tstc (void) {\
  106 + return serial_tstc_dev(port);}\
  107 + void eserial##port##_putc (const char c) {\
  108 + serial_putc_dev(port, c);}\
  109 + void eserial##port##_puts (const char *s) {\
  110 + serial_puts_dev(port, s);}
  111 +
  112 +/* Serial device descriptor */
  113 +#define INIT_ESERIAL_STRUCTURE(port,name,bus) {\
  114 + name,\
  115 + bus,\
  116 + eserial##port##_init,\
  117 + eserial##port##_setbrg,\
  118 + eserial##port##_getc,\
  119 + eserial##port##_tstc,\
  120 + eserial##port##_putc,\
  121 + eserial##port##_puts, }
  122 +
  123 +#endif /* CONFIG_SERIAL_MULTI */
  124 +
80 125 static int calc_divisor (NS16550_t port)
81 126 {
82 127 #ifdef CONFIG_OMAP1510
... ... @@ -103,6 +148,7 @@
103 148  
104 149 }
105 150  
  151 +#if !defined(CONFIG_SERIAL_MULTI)
106 152 int serial_init (void)
107 153 {
108 154 int clock_divisor;
... ... @@ -130,6 +176,7 @@
130 176  
131 177 return (0);
132 178 }
  179 +#endif
133 180  
134 181 void
135 182 _serial_putc(const char c,const int port)
136 183  
137 184  
138 185  
139 186  
140 187  
141 188  
142 189  
143 190  
144 191  
145 192  
146 193  
... ... @@ -176,41 +223,105 @@
176 223 NS16550_reinit(PORT, clock_divisor);
177 224 }
178 225  
  226 +#if defined(CONFIG_SERIAL_MULTI)
  227 +static inline void
  228 +serial_putc_dev(unsigned int dev_index,const char c)
  229 +{
  230 + _serial_putc(c,dev_index);
  231 +}
  232 +#else
179 233 void
180 234 serial_putc(const char c)
181 235 {
182 236 _serial_putc(c,CONFIG_CONS_INDEX);
183 237 }
  238 +#endif
184 239  
  240 +#if defined(CONFIG_SERIAL_MULTI)
  241 +static inline void
  242 +serial_putc_raw_dev(unsigned int dev_index,const char c)
  243 +{
  244 + _serial_putc_raw(c,dev_index);
  245 +}
  246 +#else
185 247 void
186 248 serial_putc_raw(const char c)
187 249 {
188 250 _serial_putc_raw(c,CONFIG_CONS_INDEX);
189 251 }
  252 +#endif
190 253  
  254 +#if defined(CONFIG_SERIAL_MULTI)
  255 +static inline void
  256 +serial_puts_dev(unsigned int dev_index,const char *s)
  257 +{
  258 + _serial_puts(s,dev_index);
  259 +}
  260 +#else
191 261 void
192 262 serial_puts(const char *s)
193 263 {
194 264 _serial_puts(s,CONFIG_CONS_INDEX);
195 265 }
  266 +#endif
196 267  
  268 +#if defined(CONFIG_SERIAL_MULTI)
  269 +static inline int
  270 +serial_getc_dev(unsigned int dev_index)
  271 +{
  272 + return _serial_getc(dev_index);
  273 +}
  274 +#else
197 275 int
198 276 serial_getc(void)
199 277 {
200 278 return _serial_getc(CONFIG_CONS_INDEX);
201 279 }
  280 +#endif
202 281  
  282 +#if defined(CONFIG_SERIAL_MULTI)
  283 +static inline int
  284 +serial_tstc_dev(unsigned int dev_index)
  285 +{
  286 + return _serial_tstc(dev_index);
  287 +}
  288 +#else
203 289 int
204 290 serial_tstc(void)
205 291 {
206 292 return _serial_tstc(CONFIG_CONS_INDEX);
207 293 }
  294 +#endif
208 295  
  296 +#if defined(CONFIG_SERIAL_MULTI)
  297 +static inline void
  298 +serial_setbrg_dev(unsigned int dev_index)
  299 +{
  300 + _serial_setbrg(dev_index);
  301 +}
  302 +#else
209 303 void
210 304 serial_setbrg(void)
211 305 {
212 306 _serial_setbrg(CONFIG_CONS_INDEX);
213 307 }
  308 +#endif
  309 +
  310 +#if defined(CONFIG_SERIAL_MULTI)
  311 +
  312 +DECLARE_ESERIAL_FUNCTIONS(1);
  313 +struct serial_device eserial1_device =
  314 + INIT_ESERIAL_STRUCTURE(1,"eserial0","EUART1");
  315 +DECLARE_ESERIAL_FUNCTIONS(2);
  316 +struct serial_device eserial2_device =
  317 + INIT_ESERIAL_STRUCTURE(2,"eserial1","EUART2");
  318 +DECLARE_ESERIAL_FUNCTIONS(3);
  319 +struct serial_device eserial3_device =
  320 + INIT_ESERIAL_STRUCTURE(3,"eserial2","EUART3");
  321 +DECLARE_ESERIAL_FUNCTIONS(4);
  322 +struct serial_device eserial4_device =
  323 + INIT_ESERIAL_STRUCTURE(4,"eserial3","EUART4");
  324 +#endif /* CONFIG_SERIAL_MULTI */
214 325  
215 326 #endif
include/configs/mcc200.h
... ... @@ -72,12 +72,15 @@
72 72 */
73 73 #if !defined(CONFIG_PRS200)
74 74 /* MCC200 configuration: */
75   -#undef CONFIG_PSC_CONSOLE
  75 +#define CONFIG_SERIAL_MULTI 1
  76 +#define CONFIG_PSC_CONSOLE 1 /* PSC1 may be COM */
  77 +#define CONFIG_PSC_CONSOLE2 2 /* PSC2 is PSoC */
76 78 #else
77 79 /* PRS200 configuration: */
78 80 #define CONFIG_PSC_CONSOLE 1 /* console is on PSC1 */
79 81 #endif
80   -#if defined(CONFIG_QUART_CONSOLE) && defined(CONFIG_PSC_CONSOLE)
  82 +#if defined(CONFIG_QUART_CONSOLE) && defined(CONFIG_PSC_CONSOLE) && \
  83 + !defined(CONFIG_SERIAL_MULTI)
81 84 #error "Select only one console device!"
82 85 #endif
83 86 #define CONFIG_BAUDRATE 115200
... ... @@ -26,6 +26,13 @@
26 26 || defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
27 27 extern struct serial_device serial0_device;
28 28 extern struct serial_device serial1_device;
  29 +#if defined(CFG_NS16550_SERIAL)
  30 +extern struct serial_device eserial1_device;
  31 +extern struct serial_device eserial2_device;
  32 +extern struct serial_device eserial3_device;
  33 +extern struct serial_device eserial4_device;
  34 +#endif /* CFG_NS16550_SERIAL */
  35 +
29 36 #endif
30 37  
31 38