fvp_console.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2020-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <platform_def.h>
  8. #include <common/debug.h>
  9. #include <drivers/arm/pl011.h>
  10. #include <drivers/console.h>
  11. #include <fconf_hw_config_getter.h>
  12. #include <plat/arm/common/plat_arm.h>
  13. static console_t fvp_runtime_console;
  14. /* Initialize the runtime console */
  15. void arm_console_runtime_init(void)
  16. {
  17. uintptr_t uart_base;
  18. uint32_t uart_clk;
  19. /*
  20. * fconf APIs are not supported for RESET_TO_SP_MIN, RESET_TO_BL31 and
  21. * RESET_TO_BL2 systems.
  22. */
  23. #if RESET_TO_SP_MIN || RESET_TO_BL31 || RESET_TO_BL2
  24. uart_base = PLAT_ARM_RUN_UART_BASE;
  25. uart_clk = PLAT_ARM_RUN_UART_CLK_IN_HZ;
  26. #else
  27. uart_base = FCONF_GET_PROPERTY(hw_config, uart_serial_config,
  28. uart_base);
  29. uart_clk = FCONF_GET_PROPERTY(hw_config, uart_serial_config,
  30. uart_clk);
  31. #endif
  32. int rc = console_pl011_register(uart_base, uart_clk,
  33. ARM_CONSOLE_BAUDRATE,
  34. &fvp_runtime_console);
  35. if (rc == 0) {
  36. panic();
  37. }
  38. console_set_scope(&fvp_runtime_console, CONSOLE_FLAG_RUNTIME);
  39. }
  40. void arm_console_runtime_end(void)
  41. {
  42. console_flush();
  43. (void)console_unregister(&fvp_runtime_console);
  44. }