lpuart_console.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2015-2020, ARM Limited and Contributors. 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 <assert_macros.S>
  10. #include "imx8_lpuart.h"
  11. .globl console_lpuart_register
  12. .globl console_lpuart_init
  13. .globl console_lpuart_putc
  14. .globl console_lpuart_getc
  15. .globl console_lpuart_flush
  16. func console_lpuart_register
  17. mov x7, x30
  18. mov x6, x3
  19. cbz x6, register_fail
  20. str x0, [x6, #CONSOLE_T_BASE]
  21. bl console_lpuart_init
  22. cbz x0, register_fail
  23. mov x0, x6
  24. mov x30, x7
  25. finish_console_register lpuart putc=1, getc=ENABLE_CONSOLE_GETC, flush=1
  26. register_fail:
  27. ret x7
  28. endfunc console_lpuart_register
  29. func console_lpuart_init
  30. mov w0, #1
  31. ret
  32. endfunc console_lpuart_init
  33. func console_lpuart_putc
  34. ldr x1, [x1, #CONSOLE_T_BASE]
  35. cbz x1, putc_error
  36. /* Prepare '\r' to '\n' */
  37. cmp w0, #0xA
  38. b.ne 2f
  39. 1:
  40. /* Check if the transmit FIFO is full */
  41. ldr w2, [x1, #STAT]
  42. tbz w2, #23, 1b
  43. mov w2, #0xD
  44. str w2, [x1, #DATA]
  45. 2:
  46. /* Check if the transmit FIFO is full */
  47. ldr w2, [x1, #STAT]
  48. tbz w2, #23, 2b
  49. str w0, [x1, #DATA]
  50. ret
  51. putc_error:
  52. mov w0, #-1
  53. ret
  54. endfunc console_lpuart_putc
  55. func console_lpuart_getc
  56. ldr x0, [x0, #CONSOLE_T_BASE]
  57. cbz x0, getc_error
  58. /* Check if the receive FIFO state */
  59. ret
  60. getc_error:
  61. mov w0, #-1
  62. ret
  63. endfunc console_lpuart_getc
  64. func console_lpuart_flush
  65. ret
  66. endfunc console_lpuart_flush