marvell_console.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2018-2020, 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/console.h>
  10. #include <plat_marvell.h>
  11. #ifdef PLAT_a3700
  12. #include <drivers/marvell/uart/a3700_console.h>
  13. #define PLAT_MARVELL_UART_CLK_IN_HZ (get_ref_clk() * 1000000)
  14. #define console_marvell_register console_a3700_register
  15. #else
  16. #include <drivers/ti/uart/uart_16550.h>
  17. #define console_marvell_register console_16550_register
  18. #endif
  19. static console_t marvell_boot_console;
  20. static console_t marvell_runtime_console;
  21. /*******************************************************************************
  22. * Functions that set up the console
  23. ******************************************************************************/
  24. /* Initialize the console to provide early debug support */
  25. void marvell_console_boot_init(void)
  26. {
  27. int rc =
  28. console_marvell_register(PLAT_MARVELL_UART_BASE,
  29. PLAT_MARVELL_UART_CLK_IN_HZ,
  30. MARVELL_CONSOLE_BAUDRATE,
  31. &marvell_boot_console);
  32. if (rc == 0) {
  33. /*
  34. * The crash console doesn't use the multi console API, it uses
  35. * the core console functions directly. It is safe to call panic
  36. * and let it print debug information.
  37. */
  38. panic();
  39. }
  40. console_set_scope(&marvell_boot_console, CONSOLE_FLAG_BOOT);
  41. }
  42. void marvell_console_boot_end(void)
  43. {
  44. console_flush();
  45. (void)console_unregister(&marvell_boot_console);
  46. }
  47. /* Initialize the runtime console */
  48. void marvell_console_runtime_init(void)
  49. {
  50. int rc =
  51. console_marvell_register(PLAT_MARVELL_UART_BASE,
  52. PLAT_MARVELL_UART_CLK_IN_HZ,
  53. MARVELL_CONSOLE_BAUDRATE,
  54. &marvell_runtime_console);
  55. if (rc == 0)
  56. panic();
  57. console_set_scope(&marvell_runtime_console, CONSOLE_FLAG_RUNTIME);
  58. }
  59. void marvell_console_runtime_end(void)
  60. {
  61. console_flush();
  62. (void)console_unregister(&marvell_runtime_console);
  63. }