From: David Given Date: Sun, 26 May 2013 17:58:54 +0000 (+0100) Subject: Allow reading from the mini UART. Add a check to not touch the UART unless it's been... X-Git-Tag: release-6-0-pre-5~10^2~27 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e01f00e3205360b767a56aea03bf51b74c0a00d4;p=ack.git Allow reading from the mini UART. Add a check to not touch the UART unless it's been initialised (in case of accidents when running in kernel mode). --HG-- branch : dtrg-videocore --- diff --git a/plat/rpi/libsys/pi_uart.s b/plat/rpi/libsys/pi_uart.s index caa9f6f89..0cfed4a67 100644 --- a/plat/rpi/libsys/pi_uart.s +++ b/plat/rpi/libsys/pi_uart.s @@ -113,12 +113,19 @@ delay2: mov r0, #3 st r0, (r1) + ! Mark the uart as being initialised. + mov r0, #1 + stb r0, __uart_status + b lr ! Send a single byte. .define __sys_rawwrite __sys_rawwrite: + ldb r0, __uart_status + b.eq r0, #0, 1f + ld r0, (sp) mov r1, #AUX_MU_LSR_REG ! loop until space available in Tx buffer @@ -131,5 +138,27 @@ sendwait: mov r1, #AUX_MU_IO_REG stb r0, (r1) +1: + b lr + +! Receive a single byte. + +.define __sys_rawread +__sys_rawread: + ldb r0, __uart_status + b.eq r0, #0, 1b + + ! receive 1 byte (returned in r0) + mov r1, #AUX_MU_LSR_REG + mov r2, #AUX_MU_IO_REG + ! loop until char available +recvwait: + ld r3, (r1) + and r3, #0x1 + b.ne r3, #0x1, recvwait + + ldb r0, (r2) +1: b lr +.comm __uart_status, 1