Path: blob/master/arch/mips/loongson2ef/common/serial.c
26481 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/module.h>14#include <linux/serial_8250.h>1516#include <asm/bootinfo.h>1718#include <loongson.h>19#include <machine.h>2021#define PORT(int, clk) \22{ \23.irq = int, \24.uartclk = clk, \25.iotype = UPIO_PORT, \26.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \27.regshift = 0, \28}2930#define PORT_M(int, clk) \31{ \32.irq = MIPS_CPU_IRQ_BASE + (int), \33.uartclk = clk, \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[MACH_LOONGSON_END + 1] = {41[MACH_LOONGSON_UNKNOWN] = {},42[MACH_LEMOTE_FL2E] = PORT(4, 1843200),43[MACH_LEMOTE_FL2F] = PORT(3, 1843200),44[MACH_LEMOTE_ML2F7] = PORT_M(3, 3686400),45[MACH_LEMOTE_YL2F89] = PORT_M(3, 3686400),46[MACH_DEXXON_GDIUM2F10] = PORT_M(3, 3686400),47[MACH_LEMOTE_NAS] = PORT_M(3, 3686400),48[MACH_LEMOTE_LL2F] = PORT(3, 1843200),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].iotype;6263if (UPIO_MEM == iotype) {64uart8250_data[mips_machtype].mapbase =65loongson_uart_base;66uart8250_data[mips_machtype].membase =67(void __iomem *)_loongson_uart_base;68}69else if (UPIO_PORT == iotype)70uart8250_data[mips_machtype].iobase =71loongson_uart_base - LOONGSON_PCIIO_BASE;7273memset(&uart8250_data[mips_machtype + 1], 0,74sizeof(struct plat_serial8250_port));75uart8250_device.dev.platform_data = &uart8250_data[mips_machtype];7677return platform_device_register(&uart8250_device);78}79module_init(serial_init);8081static void __exit serial_exit(void)82{83platform_device_unregister(&uart8250_device);84}85module_exit(serial_exit);868788