Lines Matching +full:boot +full:- +full:serial +full:- +full:test

1 // SPDX-License-Identifier: GPL-2.0+
9 #include <serial.h>
25 * serial_null() - Void registration routine of a serial driver
27 * This routine implements a void registration routine of a serial
30 * U-Boot.
37 * on_baudrate() - Update the actual baudrate when the env var changes
64 if (gd->baudrate == baudrate) in on_baudrate()
83 gd->baudrate = baudrate; in on_baudrate()
106 * serial_initfunc() - Forward declare of driver registration routine
129 * serial_register() - Register serial driver with serial driver core
130 * @dev: Pointer to the serial driver structure
132 * This function registers the serial driver supplied via @dev with
133 * serial driver core, thus making U-Boot aware of it and making it
134 * available for U-Boot to use. On platforms that still require manual
141 if (dev->start) in serial_register()
142 dev->start += gd->reloc_off; in serial_register()
143 if (dev->stop) in serial_register()
144 dev->stop += gd->reloc_off; in serial_register()
145 if (dev->setbrg) in serial_register()
146 dev->setbrg += gd->reloc_off; in serial_register()
147 if (dev->getc) in serial_register()
148 dev->getc += gd->reloc_off; in serial_register()
149 if (dev->tstc) in serial_register()
150 dev->tstc += gd->reloc_off; in serial_register()
151 if (dev->putc) in serial_register()
152 dev->putc += gd->reloc_off; in serial_register()
153 if (dev->puts) in serial_register()
154 dev->puts += gd->reloc_off; in serial_register()
157 dev->next = serial_devices; in serial_register()
162 * serial_initialize() - Register all compiled-in serial port drivers
164 * This function registers all serial port drivers that are compiled
165 * into the U-Boot binary with the serial core, thus making them
166 * available to U-Boot to use. Lastly, this function assigns a default
167 * serial port to the serial core. That serial port is then used as a
181 serial_assign(default_serial_console()->name); in serial_initialize()
186 struct serial_device *dev = sdev->priv; in serial_stub_start()
188 return dev->start(); in serial_stub_start()
193 struct serial_device *dev = sdev->priv; in serial_stub_stop()
195 return dev->stop(); in serial_stub_stop()
200 struct serial_device *dev = sdev->priv; in serial_stub_putc()
202 dev->putc(ch); in serial_stub_putc()
207 struct serial_device *dev = sdev->priv; in serial_stub_puts()
209 dev->puts(str); in serial_stub_puts()
214 struct serial_device *dev = sdev->priv; in serial_stub_getc()
216 return dev->getc(); in serial_stub_getc()
221 struct serial_device *dev = sdev->priv; in serial_stub_tstc()
223 return dev->tstc(); in serial_stub_tstc()
227 * serial_stdio_init() - Register serial ports with STDIO core
229 * This function generates a proxy driver for each serial port driver.
231 * serial drivers available as STDIO devices.
241 strcpy(dev.name, s->name); in serial_stdio_init()
254 s = s->next; in serial_stdio_init()
259 * serial_assign() - Select the serial output device by name
260 * @name: Name of the serial driver to be used as default output
262 * This function configures the serial output multiplexing by
263 * selecting which serial device will be used as default. In case
264 * the STDIO "serial" device is selected as stdin/stdout/stderr,
265 * the serial device previously configured by this function will be
274 for (s = serial_devices; s; s = s->next) { in serial_assign()
275 if (strcmp(s->name, name)) in serial_assign()
281 return -EINVAL; in serial_assign()
285 * serial_reinit_all() - Reinitialize all compiled-in serial ports
287 * This function reinitializes all serial ports that are compiled
288 * into U-Boot by calling their serial_start() functions.
294 for (s = serial_devices; s; s = s->next) in serial_reinit_all()
295 s->start(); in serial_reinit_all()
299 * get_current() - Return pointer to currently selected serial port
301 * This function returns a pointer to currently selected serial port.
302 * The currently selected serial port is altered by serial_assign()
305 * In case this function is called before relocation or before any serial
307 * determine the serial port. Otherwise, the configured serial port is
310 * Returns pointer to the currently selected serial port on success,
317 if (!(gd->flags & GD_FLG_RELOC)) in get_current()
338 * serial_init() - Initialize currently selected serial port
340 * This function initializes the currently selected serial port. This
349 gd->flags |= GD_FLG_SERIAL_READY; in serial_init()
350 return get_current()->start(); in serial_init()
354 * serial_setbrg() - Configure baud-rate of currently selected serial port
356 * This function configures the baud-rate of the currently selected
357 * serial port. The baud-rate is retrieved from global data within
358 * the serial port driver. This function uses the get_current() call
365 get_current()->setbrg(); in serial_setbrg()
369 * serial_getc() - Read character from currently selected serial port
371 * This function retrieves a character from currently selected serial
372 * port. In case there is no character waiting on the serial port,
381 return get_current()->getc(); in serial_getc()
385 * serial_tstc() - Test if data is available on currently selected serial port
388 * currently selected serial port. This function never blocks. This
396 return get_current()->tstc(); in serial_tstc()
400 * serial_putc() - Output character via currently selected serial port
401 * @c: Single character to be output from the serial port.
403 * This function outputs a character via currently selected serial
404 * port. This character is passed to the serial port driver responsible
412 get_current()->putc(c); in serial_putc()
416 * serial_puts() - Output string via currently selected serial port
417 * @s: Zero-terminated string to be output from the serial port.
419 * This function outputs a zero-terminated string via currently
420 * selected serial port. This function behaves as an accelerator
430 get_current()->puts(s); in serial_puts()
434 * default_serial_puts() - Output string by calling serial_putc() in loop
435 * @s: Zero-terminated string to be output from the serial port.
437 * This function outputs a zero-terminated string by calling serial_putc()
449 dev->putc(*s++); in default_serial_puts()
456 * uart_post_test() - Test the currently selected serial port using POST
459 * Do a loopback test of the currently selected serial port. This
461 * The serial port is first configured into loopback mode and then
474 /* Save current serial state */ in uart_post_test()
477 saved_baud = gd->baudrate; in uart_post_test()
479 for (s = serial_devices; s; s = s->next) { in uart_post_test()
481 if (!s->loop) in uart_post_test()
484 /* Test the next device */ in uart_post_test()
496 s->loop(1); in uart_post_test()
498 /* Test every available baud rate */ in uart_post_test()
500 gd->baudrate = bauds[b]; in uart_post_test()
505 * - terminal corruption in uart_post_test()
506 * - serial program reacting to sequences and sending in uart_post_test()
508 * - most serial drivers add in extra chars (like \r\n) in uart_post_test()
517 s->loop(0); in uart_post_test()
525 s->loop(0); in uart_post_test()
532 s->loop(0); in uart_post_test()
535 if (s->stop) in uart_post_test()
536 s->stop(); in uart_post_test()
540 /* Restore previous serial state */ in uart_post_test()
542 gd->baudrate = saved_baud; in uart_post_test()