Path: blob/master/arch/mips/boot/compressed/uart-16550.c
26493 views
// SPDX-License-Identifier: GPL-2.01/*2* 16550 compatible uart based serial debug support for zboot3*/45#include <linux/types.h>6#include <linux/serial_reg.h>78#include <asm/addrspace.h>910#include "decompress.h"1112#if defined(CONFIG_MACH_LOONGSON64) || defined(CONFIG_MIPS_MALTA)13#define UART_BASE 0x1fd003f814#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))15#endif1617#ifdef CONFIG_MACH_INGENIC18#define INGENIC_UART_BASE_ADDR (0x10030000 + 0x1000 * CONFIG_ZBOOT_INGENIC_UART)19#define PORT(offset) (CKSEG1ADDR(INGENIC_UART_BASE_ADDR) + (4 * offset))20#endif2122#ifdef CONFIG_ECONET23#define EN75_UART_BASE 0x1fbf000324#define PORT(offset) (CKSEG1ADDR(EN75_UART_BASE) + (4 * (offset)))25#endif2627#ifndef IOTYPE28#define IOTYPE char29#endif3031#ifndef PORT32#error please define the serial port address for your own machine33#endif3435static inline unsigned int serial_in(int offset)36{37return *((volatile IOTYPE *)PORT(offset)) & 0xFF;38}3940static inline void serial_out(int offset, int value)41{42*((volatile IOTYPE *)PORT(offset)) = value & 0xFF;43}4445void putc(char c)46{47int timeout = 1000000;4849while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))50;5152serial_out(UART_TX, c);53}545556