1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2009 Lemote Inc.
4  * Author: Wu Zhangjin, wuzhangjin@gmail.com
5  */
6 
7 #include <linux/export.h>
8 #include <asm/bootinfo.h>
9 
10 #include <loongson.h>
11 
12 /* raw */
13 unsigned long loongson_uart_base[MAX_UARTS] = {};
14 /* ioremapped */
15 unsigned long _loongson_uart_base[MAX_UARTS] = {};
16 
17 EXPORT_SYMBOL(loongson_uart_base);
18 EXPORT_SYMBOL(_loongson_uart_base);
19 
prom_init_loongson_uart_base(void)20 void prom_init_loongson_uart_base(void)
21 {
22 	switch (mips_machtype) {
23 	case MACH_LOONGSON_GENERIC:
24 		/* The CPU provided serial port (CPU) */
25 		loongson_uart_base[0] = LOONGSON_REG_BASE + 0x1e0;
26 		break;
27 	case MACH_LEMOTE_FL2E:
28 		loongson_uart_base[0] = LOONGSON_PCIIO_BASE + 0x3f8;
29 		break;
30 	case MACH_LEMOTE_FL2F:
31 	case MACH_LEMOTE_LL2F:
32 		loongson_uart_base[0] = LOONGSON_PCIIO_BASE + 0x2f8;
33 		break;
34 	case MACH_LEMOTE_ML2F7:
35 	case MACH_LEMOTE_YL2F89:
36 	case MACH_DEXXON_GDIUM2F10:
37 	case MACH_LEMOTE_NAS:
38 	default:
39 		/* The CPU provided serial port (LPC) */
40 		loongson_uart_base[0] = LOONGSON_LIO1_BASE + 0x3f8;
41 		break;
42 	}
43 
44 	_loongson_uart_base[0] =
45 		(unsigned long)ioremap_nocache(loongson_uart_base[0], 8);
46 }
47