rcar_console.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2018-2021, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <console_macros.S>
  9. #include <drivers/renesas/rcar/console/console.h>
  10. .globl console_rcar_register
  11. .globl console_rcar_init
  12. .globl console_rcar_putc
  13. .globl console_rcar_flush
  14. .extern rcar_log_init
  15. .extern rcar_set_log_data
  16. /* -----------------------------------------------
  17. * int console_rcar_register(
  18. * uintptr_t base, uint32_t clk, uint32_t baud,
  19. * console_t *console)
  20. * Function to initialize and register a new rcar
  21. * console. Storage passed in for the console struct
  22. * *must* be persistent (i.e. not from the stack).
  23. * In: x0 - UART register base address
  24. * w1 - UART clock in Hz
  25. * w2 - Baud rate
  26. * x3 - pointer to empty console_t struct
  27. * Out: return 1 on success, 0 on error
  28. * Clobber list : x0, x1, x2, x6, x7, x14
  29. * -----------------------------------------------
  30. */
  31. func console_rcar_register
  32. mov x7, x30
  33. mov x6, x3
  34. cbz x6, register_fail
  35. str x0, [x6, #CONSOLE_T_BASE]
  36. bl rcar_log_init
  37. cbz x0, register_fail
  38. mov x0, x6
  39. mov x30, x7
  40. finish_console_register rcar, putc=1, getc=0, flush=1
  41. register_fail:
  42. ret x7
  43. endfunc console_rcar_register
  44. /* ---------------------------------------------
  45. * int console_rcar_init(unsigned long base_addr,
  46. * unsigned int uart_clk, unsigned int baud_rate)
  47. * Function to initialize the console without a
  48. * C Runtime to print debug information. This
  49. * function will be accessed by crash reporting.
  50. * In: x0 - console base address
  51. * w1 - Uart clock in Hz
  52. * w2 - Baud rate
  53. * Out: return 1 on success
  54. * Clobber list : x1, x2
  55. * ---------------------------------------------
  56. */
  57. func console_rcar_init
  58. mov w0, #1
  59. ret
  60. endfunc console_rcar_init
  61. /* --------------------------------------------------------
  62. * int console_rcar_putc(int c, console_t *console)
  63. * Function to output a character over the console. It
  64. * returns the character printed on success or -1 on error.
  65. * In : w0 - character to be printed
  66. * x1 - pointer to console_t structure
  67. * Out : return -1 on error else return character.
  68. * Clobber list : x2
  69. * --------------------------------------------------------
  70. */
  71. func console_rcar_putc
  72. b rcar_set_log_data
  73. endfunc console_rcar_putc
  74. /* ---------------------------------------------
  75. * void console_rcar_flush(void)
  76. * Function to force a write of all buffered
  77. * data that hasn't been output. It returns void
  78. * Clobber list : x0, x1
  79. * ---------------------------------------------
  80. */
  81. func console_rcar_flush
  82. ret
  83. endfunc console_rcar_flush