Path: blob/master/arch/mips/loongson/common/serial.c
10818 views
/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 2007 Ralf Baechle ([email protected])6*7* Copyright (C) 2009 Lemote, Inc.8* Author: Yan hua ([email protected])9* Author: Wu Zhangjin ([email protected])10*/1112#include <linux/io.h>13#include <linux/init.h>14#include <linux/serial_8250.h>1516#include <asm/bootinfo.h>1718#include <loongson.h>19#include <machine.h>2021#define PORT(int) \22{ \23.irq = int, \24.uartclk = 1843200, \25.iotype = UPIO_PORT, \26.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \27.regshift = 0, \28}2930#define PORT_M(int) \31{ \32.irq = MIPS_CPU_IRQ_BASE + (int), \33.uartclk = 3686400, \34.iotype = UPIO_MEM, \35.membase = (void __iomem *)NULL, \36.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \37.regshift = 0, \38}3940static struct plat_serial8250_port uart8250_data[][2] = {41[MACH_LOONGSON_UNKNOWN] {},42[MACH_LEMOTE_FL2E] {PORT(4), {} },43[MACH_LEMOTE_FL2F] {PORT(3), {} },44[MACH_LEMOTE_ML2F7] {PORT_M(3), {} },45[MACH_LEMOTE_YL2F89] {PORT_M(3), {} },46[MACH_DEXXON_GDIUM2F10] {PORT_M(3), {} },47[MACH_LEMOTE_NAS] {PORT_M(3), {} },48[MACH_LEMOTE_LL2F] {PORT(3), {} },49[MACH_LOONGSON_END] {},50};5152static struct platform_device uart8250_device = {53.name = "serial8250",54.id = PLAT8250_DEV_PLATFORM,55};5657static int __init serial_init(void)58{59unsigned char iotype;6061iotype = uart8250_data[mips_machtype][0].iotype;6263if (UPIO_MEM == iotype)64uart8250_data[mips_machtype][0].membase =65(void __iomem *)_loongson_uart_base;66else if (UPIO_PORT == iotype)67uart8250_data[mips_machtype][0].iobase =68loongson_uart_base - LOONGSON_PCIIO_BASE;6970uart8250_device.dev.platform_data = uart8250_data[mips_machtype];7172return platform_device_register(&uart8250_device);73}7475device_initcall(serial_init);767778