rpi3_console_dual.c 876 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2024, Mario Bălănică <mariobalanica02@gmail.com>
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #include <drivers/arm/pl011.h>
  8. #include <drivers/console.h>
  9. #include <drivers/rpi3/gpio/rpi3_gpio.h>
  10. #include <drivers/ti/uart/uart_16550.h>
  11. #include <platform_def.h>
  12. #include <rpi_shared.h>
  13. static bool rpi3_use_mini_uart(void)
  14. {
  15. return rpi3_gpio_get_select(14) == RPI3_GPIO_FUNC_ALT5;
  16. }
  17. int rpi3_register_used_uart(console_t *console)
  18. {
  19. rpi3_gpio_init();
  20. if (rpi3_use_mini_uart())
  21. return console_16550_register(PLAT_RPI_MINI_UART_BASE,
  22. 0,
  23. PLAT_RPI_UART_BAUDRATE,
  24. console);
  25. else
  26. return console_pl011_register(PLAT_RPI_PL011_UART_BASE,
  27. PLAT_RPI_PL011_UART_CLOCK,
  28. PLAT_RPI_UART_BAUDRATE,
  29. console);
  30. }