1157873Simp/*-
2157873Simp * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
3157873Simp *
4157873Simp * Redistribution and use in source and binary forms, with or without
5157873Simp * modification, are permitted provided that the following conditions
6157873Simp * are met:
7157873Simp * 1. Redistributions of source code must retain the above copyright
8157873Simp *    notice, this list of conditions and the following disclaimer.
9157873Simp * 2. Redistributions in binary form must reproduce the above copyright
10157873Simp *    notice, this list of conditions and the following disclaimer in the
11157873Simp *    documentation and/or other materials provided with the distribution.
12157873Simp *
13157873Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14157873Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15157873Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16157873Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17157873Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18157873Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19157873Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20157873Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21157873Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22157873Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23157873Simp *
24157873Simp * This software is derived from software provided by kwikbyte without
25157873Simp * copyright as follows:
26157873Simp *
27157873Simp * No warranty, expressed or implied, is included with this software.  It is
28157873Simp * provided "AS IS" and no warranty of any kind including statutory or aspects
29157873Simp * relating to merchantability or fitness for any purpose is provided.  All
30157873Simp * intellectual property rights of others is maintained with the respective
31157873Simp * owners.  This software is not copyrighted and is intended for reference
32157873Simp * only.
33157873Simp *
34157873Simp * $FreeBSD: releng/11.0/sys/boot/arm/at91/libat91/putchar.c 163533 2006-10-20 09:12:05Z imp $
35157873Simp */
36157873Simp
37157873Simp#include "at91rm9200.h"
38157873Simp#include "at91rm9200_lowlevel.h"
39157873Simp#include "lib.h"
40157873Simp
41157873Simp/*
42157873Simp * void putchar(int ch)
43157873Simp * Writes a character to the DBGU port.  It assumes that DBGU has
44157873Simp * already been initialized.
45157873Simp */
46157873Simpvoid
47157873Simpputchar(int ch)
48157873Simp{
49157873Simp	AT91PS_USART pUSART = (AT91PS_USART)AT91C_BASE_DBGU;
50157873Simp
51157873Simp	while (!(pUSART->US_CSR & AT91C_US_TXRDY))
52157873Simp		continue;
53157873Simp	pUSART->US_THR = (ch & 0xFF);
54157873Simp}
55163533Simp
56163533Simpvoid
57163533Simpxputchar(int ch)
58163533Simp{
59163533Simp    if (ch == '\n')
60163533Simp	putchar('\r');
61163533Simp    putchar(ch);
62163533Simp}
63