Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3ed4951 authored by Wu Zhangjin's avatar Wu Zhangjin Committed by Ralf Baechle
Browse files

MIPS: Loongson: Cleanup the serial port support



To share the same kernel image amon different machines we have added the
machtype command line support.

In the old serial port implementation the UART base address is hardcoded as
a macro in machine.h which breaks with machtype, so change that to discover
the address dynamically.  Also move the initialization of the UART base
address to uart_base.c to avoid remapping twice for early_printk.c and
serial.c.

Signed-off-by: default avatarWu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/581/
Patchwork: http://patchwork.linux-mips.org/patch/682/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 04cfb90a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ extern void __init prom_init_memory(void);
extern void __init prom_init_cmdline(void);
extern void __init prom_init_machtype(void);
extern void __init prom_init_env(void);
extern unsigned long _loongson_uart_base;
extern unsigned long uart8250_base[];
extern void prom_init_uart_base(void);

/* irq operation functions */
extern void bonito_irqdispatch(void);
+0 −2
Original line number Diff line number Diff line
@@ -13,8 +13,6 @@

#ifdef CONFIG_LEMOTE_FULOONG2E

#define LOONGSON_UART_BASE (LOONGSON_PCIIO_BASE + 0x3f8)

#define LOONGSON_MACHTYPE MACH_LEMOTE_FL2E

#endif
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
#

obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
    pci.o bonito-irq.o mem.o machtype.o
    pci.o bonito-irq.o mem.o machtype.o uart_base.o

#
# Early printk support
+7 −4
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
#include <linux/serial_reg.h>

#include <loongson.h>
#include <machine.h>

#define PORT(base, offset) (u8 *)(base + offset)

@@ -28,10 +27,14 @@ static inline void serial_out(unsigned char *base, int offset, int value)

void prom_putchar(char c)
{
	unsigned char *uart_base =
		(unsigned char *) ioremap_nocache(LOONGSON_UART_BASE, 8);
	int timeout;
	unsigned char *uart_base;

	while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0)
	uart_base = (unsigned char *)_loongson_uart_base;
	timeout = 1024;

	while (((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) &&
			(timeout-- > 0))
		;

	serial_out(uart_base, UART_TX, c);
+7 −4
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
 * Copyright (C) 2009 Lemote Inc.
 * Author: Wu Zhangjin, wuzj@lemote.com
 *
 * This program is free software; you can redistribute  it and/or modify it
@@ -10,8 +10,6 @@

#include <linux/bootmem.h>

#include <asm/bootinfo.h>

#include <loongson.h>

void __init prom_init(void)
@@ -23,6 +21,11 @@ void __init prom_init(void)
	prom_init_cmdline();
	prom_init_env();
	prom_init_memory();

	/*init the uart base address */
#if defined(CONFIG_EARLY_PRINTK) || defined(CONFIG_SERIAL_8250)
	prom_init_uart_base();
#endif
}

void __init prom_free_prom_memory(void)
Loading