1171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin/*
2171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin *  This program is free software; you can redistribute it and/or modify it
3171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin *  under the terms of the GNU General Public License version 2 as published
4171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin *  by the Free Software Foundation.
5171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin *
6171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin */
8171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin
9171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin#include <linux/cpu.h>
10171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin#include <lantiq_soc.h>
11171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin
12171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin#define ASC_BUF		1024
137705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer#define LTQ_ASC_FSTAT	((u32 *)(LTQ_EARLY_ASC + 0x0048))
147705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer#ifdef __BIG_ENDIAN
157705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer#define LTQ_ASC_TBUF	((u32 *)(LTQ_EARLY_ASC + 0x0020 + 3))
167705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer#else
177705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer#define LTQ_ASC_TBUF	((u32 *)(LTQ_EARLY_ASC + 0x0020))
187705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer#endif
19171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin#define TXMASK		0x3F00
20171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin#define TXOFFSET	8
21171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin
22171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispinvoid prom_putchar(char c)
23171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin{
24171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin	unsigned long flags;
25171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin
26171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin	local_irq_save(flags);
27171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin	do { } while ((ltq_r32(LTQ_ASC_FSTAT) & TXMASK) >> TXOFFSET);
28171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin	if (c == '\n')
297705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer		ltq_w8('\r', LTQ_ASC_TBUF);
307705f6867bfc6f2ea42c3965a85df72abf070c86Thomas Langer	ltq_w8(c, LTQ_ASC_TBUF);
31171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin	local_irq_restore(flags);
32171bb2f19ed6f3627f4f783f658f2f475b2fbd50John Crispin}
33