blob: a38325474a0745b32afd1c8daa3bba60130ed848 [file] [log] [blame]
Steven J. Hill30700332012-05-30 21:02:49 +00001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 */
Steven J. Hill30700332012-05-30 21:02:49 +00008#include <linux/init.h>
Andrew Bresticker4060bbe2014-10-20 12:03:53 -07009#include <linux/irqchip/mips-gic.h>
Steven J. Hill30700332012-05-30 21:02:49 +000010#include <linux/serial_8250.h>
11
Andrew Bresticker18743d22014-09-18 14:47:24 -070012#include <asm/mips-boards/sead3int.h>
13
14#define UART(base) \
Steven J. Hill30700332012-05-30 21:02:49 +000015{ \
16 .mapbase = base, \
Andrew Bresticker18743d22014-09-18 14:47:24 -070017 .irq = -1, \
Steven J. Hill30700332012-05-30 21:02:49 +000018 .uartclk = 14745600, \
19 .iotype = UPIO_MEM32, \
20 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \
21 .regshift = 2, \
22}
23
24static struct plat_serial8250_port uart8250_data[] = {
Andrew Bresticker18743d22014-09-18 14:47:24 -070025 UART(0x1f000900), /* ttyS0 = USB */
26 UART(0x1f000800), /* ttyS1 = RS232 */
Steven J. Hill30700332012-05-30 21:02:49 +000027 { },
28};
29
30static struct platform_device uart8250_device = {
31 .name = "serial8250",
32 .id = PLAT8250_DEV_PLATFORM2,
33 .dev = {
34 .platform_data = uart8250_data,
35 },
36};
37
38static int __init uart8250_init(void)
39{
Andrew Bresticker18743d22014-09-18 14:47:24 -070040 if (gic_present) {
41 uart8250_data[0].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART0;
42 uart8250_data[1].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART1;
43 } else {
44 uart8250_data[0].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART0;
45 uart8250_data[1].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART1;
46 }
Steven J. Hill30700332012-05-30 21:02:49 +000047 return platform_device_register(&uart8250_device);
48}
49
Ralf Baechle85f215c2015-04-02 16:20:04 +020050device_initcall(uart8250_init);