2 * Copyright (c) 2014, STMicroelectronics International N.V.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
27 #include <platform_config.h>
29 #include <kernel/unwind.h>
31 #define ASC_BAUDRATE 0x00
32 #define ASC_TXBUFFER 0x04
33 #define ASC_RXBUFFER 0x08
34 #define ASC_CONTROL 0x0c
35 #define ASC_INTENABLE 0x10
36 #define ASC_STATUS 0x14
37 #define ASC_GUARDTIME 0x18
38 #define ASC_TIMEOUT 0x1c
39 #define ASC_TXRESET 0x20
40 #define ASC_RXRESET 0x24
41 #define ASC_RETRIES 0x28
47 * void __asc_flush(vaddr_t base)
54 ADD r3, r0, #ASC_STATUS
58 ANDS r1, r1, #0x02 /* AND TX FIFO EMPTY flag */
59 BEQ flush_wait /* ANDS should have set Z bit if zero */
67 * int __asc_xmit_char(char p, vaddr_t base) - Transmit a single character.
69 * R0 is the 1-byte character to be transmited
70 * R1 is the base address of the uart
73 FUNC __asc_xmit_char , :
76 ADD r2, r1, #ASC_TXBUFFER
77 ADD r3, r1, #ASC_STATUS
81 /* Spin until TX FIFO ready */
84 ANDS r1, r1, #0x04 /* AND TX FIFO HALF EMPTY flag */
85 BEQ __asc_char_crwait /* ANDS should have set Z bit if zero */
91 CMP r1, #0xa /* r1 == \n (line feed) ? */
94 /* Transmit character extra carriage return for each line feed */
98 LDR r1, =0x0a /* replace line feed */
101 /* Transmit character */
108 END_FUNC __asc_xmit_char