uniphier_console.S 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <drivers/console.h>
  8. #include "uniphier_console.h"
  9. /*
  10. * In: w0 - character to be printed
  11. * x1 - pointer to console structure
  12. * Out: return the character written (always succeeds)
  13. * Clobber: x2
  14. */
  15. .globl uniphier_console_putc
  16. func uniphier_console_putc
  17. ldr x1, [x1, #CONSOLE_T_BASE]
  18. /* Wait until the transmitter FIFO gets empty */
  19. 0: ldr w2, [x1, #UNIPHIER_UART_LSR]
  20. tbz w2, #UNIPHIER_UART_LSR_THRE_BIT, 0b
  21. str w0, [x1, #UNIPHIER_UART_TX]
  22. ret
  23. endfunc uniphier_console_putc
  24. /*
  25. * In: x0 - pointer to console structure
  26. * Out: return the character read, or ERROR_NO_PENDING_CHAR if no character
  27. is available
  28. * Clobber: x1
  29. */
  30. .globl uniphier_console_getc
  31. func uniphier_console_getc
  32. ldr x0, [x0, #CONSOLE_T_BASE]
  33. ldr w1, [x0, #UNIPHIER_UART_LSR]
  34. tbz w1, #UNIPHIER_UART_LSR_DR_BIT, 0f
  35. ldr w0, [x0, #UNIPHIER_UART_RX]
  36. ret
  37. 0: mov w0, #ERROR_NO_PENDING_CHAR
  38. ret
  39. endfunc uniphier_console_getc
  40. /*
  41. * In: x0 - pointer to console structure
  42. * Out: return 0 (always succeeds)
  43. * Clobber: x1
  44. */
  45. .global uniphier_console_flush
  46. func uniphier_console_flush
  47. ldr x0, [x0, #CONSOLE_T_BASE]
  48. /* wait until the transmitter gets empty */
  49. 0: ldr w1, [x0, #UNIPHIER_UART_LSR]
  50. tbz w1, #UNIPHIER_UART_LSR_TEMT_BIT, 0b
  51. ret
  52. endfunc uniphier_console_flush