2 * serial.c, Serial Interface Unit routines for NEC VR4100 series.
4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2003-2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com>
25 * - New creation, NEC VR4122 and VR4131 are supported.
26 * - Added support for NEC VR4111 and VR4121.
28 * Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
29 * - Added support for NEC VR4133.
31 #include <linux/init.h>
32 #include <linux/types.h>
33 #include <linux/tty.h>
34 #include <linux/serial.h>
35 #include <linux/serial_core.h>
36 #include <linux/smp.h>
38 #include <asm/addrspace.h>
41 #include <asm/vr41xx/vr41xx.h>
43 /* VR4111 and VR4121 SIU Registers */
44 #define SIURB_TYPE1 KSEG1ADDR(0x0c000000)
45 #define SIUIRSEL_TYPE1 KSEG1ADDR(0x0c000008)
47 /* VR4122, VR4131 and VR4133 SIU Registers */
48 #define SIURB_TYPE2 KSEG1ADDR(0x0f000800)
49 #define SIUIRSEL_TYPE2 KSEG1ADDR(0x0f000808)
51 #define USE_RS232C 0x00
53 #define SIU_USES_IRDA 0x00
54 #define FIR_USES_IRDA 0x02
55 #define IRDA_MODULE_SHARP 0x00
56 #define IRDA_MODULE_TEMIC 0x04
57 #define IRDA_MODULE_HP 0x08
61 #define SIU_BASE_BAUD 1152000
63 /* VR4122 and VR4131 DSIU Registers */
64 #define DSIURB KSEG1ADDR(0x0f000820)
66 #define MDSIUINTREG KSEG1ADDR(0x0f000096)
67 #define INTDSIU 0x0800
69 #define DSIU_BASE_BAUD 1152000
71 int vr41xx_serial_ports = 0;
73 void vr41xx_siu_ifselect(int interface, int module)
75 u16 val = USE_RS232C; /* Select RS-232C */
78 if (interface == SIU_IRDA) {
81 val = IRDA_MODULE_SHARP;
84 val = IRDA_MODULE_TEMIC;
90 val |= USE_IRDA | SIU_USES_IRDA;
93 switch (current_cpu_data.cputype) {
96 writew(val, SIUIRSEL_TYPE1);
101 writew(val, SIUIRSEL_TYPE2);
104 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
109 void __init vr41xx_siu_init(int interface, int module)
111 struct uart_port port;
113 vr41xx_siu_ifselect(interface, module);
115 memset(&port, 0, sizeof(port));
117 port.line = vr41xx_serial_ports;
118 port.uartclk = SIU_BASE_BAUD;
120 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
121 switch (current_cpu_data.cputype) {
124 port.membase = (char *)SIURB_TYPE1;
129 port.membase = (char *)SIURB_TYPE2;
132 panic("Unexpected CPU of NEC VR4100 series");
136 port.iotype = UPIO_MEM;
137 if (early_serial_setup(&port) != 0)
138 printk(KERN_ERR "SIU setup failed!\n");
140 vr41xx_supply_clock(SIU_CLOCK);
142 vr41xx_serial_ports++;
145 void __init vr41xx_dsiu_init(void)
147 struct uart_port port;
149 if (current_cpu_data.cputype != CPU_VR4122 &&
150 current_cpu_data.cputype != CPU_VR4131 &&
151 current_cpu_data.cputype != CPU_VR4133)
154 memset(&port, 0, sizeof(port));
156 port.line = vr41xx_serial_ports;
157 port.uartclk = DSIU_BASE_BAUD;
159 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
160 port.membase = (char *)DSIURB;
162 port.iotype = UPIO_MEM;
163 if (early_serial_setup(&port) != 0)
164 printk(KERN_ERR "DSIU setup failed!\n");
166 vr41xx_supply_clock(DSIU_CLOCK);
168 writew(INTDSIU, MDSIUINTREG);
170 vr41xx_serial_ports++;