18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Serial port stubs for kernel decompress status messages
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Initially based on:
58c2ecf20Sopenharmony_ci * arch/arm/plat-omap/include/mach/uncompress.h
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Original copyrights follow.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Copyright (C) 2000 RidgeRun, Inc.
108c2ecf20Sopenharmony_ci * Author: Greg Lonnon <glonnon@ridgerun.com>
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Rewritten by:
138c2ecf20Sopenharmony_ci * Author: <source@mvista.com>
148c2ecf20Sopenharmony_ci * 2004 (c) MontaVista Software, Inc.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License
178c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any
188c2ecf20Sopenharmony_ci * kind, whether express or implied.
198c2ecf20Sopenharmony_ci */
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include <linux/types.h>
228c2ecf20Sopenharmony_ci#include <linux/serial_reg.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include <asm/mach-types.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <mach/serial.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define IOMEM(x)	((void __force __iomem *)(x))
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciu32 *uart;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* PORT_16C550A, in polled non-fifo mode */
338c2ecf20Sopenharmony_cistatic inline void putc(char c)
348c2ecf20Sopenharmony_ci{
358c2ecf20Sopenharmony_ci	if (!uart)
368c2ecf20Sopenharmony_ci		return;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	while (!(uart[UART_LSR] & UART_LSR_THRE))
398c2ecf20Sopenharmony_ci		barrier();
408c2ecf20Sopenharmony_ci	uart[UART_TX] = c;
418c2ecf20Sopenharmony_ci}
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cistatic inline void flush(void)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci	if (!uart)
468c2ecf20Sopenharmony_ci		return;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	while (!(uart[UART_LSR] & UART_LSR_THRE))
498c2ecf20Sopenharmony_ci		barrier();
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic inline void set_uart_info(u32 phys)
538c2ecf20Sopenharmony_ci{
548c2ecf20Sopenharmony_ci	uart = (u32 *)phys;
558c2ecf20Sopenharmony_ci}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define _DEBUG_LL_ENTRY(machine, phys)				\
588c2ecf20Sopenharmony_ci	{							\
598c2ecf20Sopenharmony_ci		if (machine_is_##machine()) {			\
608c2ecf20Sopenharmony_ci			set_uart_info(phys);			\
618c2ecf20Sopenharmony_ci			break;					\
628c2ecf20Sopenharmony_ci		}						\
638c2ecf20Sopenharmony_ci	}
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define DEBUG_LL_DAVINCI(machine, port)				\
668c2ecf20Sopenharmony_ci	_DEBUG_LL_ENTRY(machine, DAVINCI_UART##port##_BASE)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define DEBUG_LL_DA8XX(machine, port)				\
698c2ecf20Sopenharmony_ci	_DEBUG_LL_ENTRY(machine, DA8XX_UART##port##_BASE)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic inline void __arch_decomp_setup(unsigned long arch_id)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	/*
748c2ecf20Sopenharmony_ci	 * Initialize the port based on the machine ID from the bootloader.
758c2ecf20Sopenharmony_ci	 * Note that we're using macros here instead of switch statement
768c2ecf20Sopenharmony_ci	 * as machine_is functions are optimized out for the boards that
778c2ecf20Sopenharmony_ci	 * are not selected.
788c2ecf20Sopenharmony_ci	 */
798c2ecf20Sopenharmony_ci	do {
808c2ecf20Sopenharmony_ci		/* Davinci boards */
818c2ecf20Sopenharmony_ci		DEBUG_LL_DAVINCI(davinci_evm,		0);
828c2ecf20Sopenharmony_ci		DEBUG_LL_DAVINCI(sffsdr,		0);
838c2ecf20Sopenharmony_ci		DEBUG_LL_DAVINCI(neuros_osd2,		0);
848c2ecf20Sopenharmony_ci		DEBUG_LL_DAVINCI(davinci_dm355_evm,	0);
858c2ecf20Sopenharmony_ci		DEBUG_LL_DAVINCI(dm355_leopard,		0);
868c2ecf20Sopenharmony_ci		DEBUG_LL_DAVINCI(davinci_dm6467_evm,	0);
878c2ecf20Sopenharmony_ci		DEBUG_LL_DAVINCI(davinci_dm365_evm,	0);
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci		/* DA8xx boards */
908c2ecf20Sopenharmony_ci		DEBUG_LL_DA8XX(davinci_da830_evm,	2);
918c2ecf20Sopenharmony_ci		DEBUG_LL_DA8XX(davinci_da850_evm,	2);
928c2ecf20Sopenharmony_ci		DEBUG_LL_DA8XX(mityomapl138,		1);
938c2ecf20Sopenharmony_ci		DEBUG_LL_DA8XX(omapl138_hawkboard,	2);
948c2ecf20Sopenharmony_ci	} while (0);
958c2ecf20Sopenharmony_ci}
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define arch_decomp_setup()	__arch_decomp_setup(arch_id)
98