• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * setup serial port in SCC
3  *
4  * (C) Copyright 2006-2007 TOSHIBA CORPORATION
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include <linux/tty.h>
22 #include <linux/serial.h>
23 #include <linux/serial_core.h>
24 #include <linux/console.h>
25 
26 #include <asm/io.h>
27 #include <asm/prom.h>
28 
29 /* sio irq0=0xb00010022 irq0=0xb00010023 irq2=0xb00010024
30     mmio=0xfff000-0x1000,0xff2000-0x1000 */
31 static int txx9_serial_bitmap __initdata;
32 
33 static struct {
34 	uint32_t offset;
35 	uint32_t index;
36 } txx9_scc_tab[3] __initdata = {
37 	{ 0x300, 0 },	/* 0xFFF300 */
38 	{ 0x400, 0 },	/* 0xFFF400 */
39 	{ 0x800, 1 }	/* 0xFF2800 */
40 };
41 
txx9_serial_init(void)42 static int __init txx9_serial_init(void)
43 {
44 	extern int early_serial_txx9_setup(struct uart_port *port);
45 	struct device_node *node;
46 	int i;
47 	struct uart_port req;
48 	struct of_phandle_args irq;
49 	struct resource res;
50 
51 	for_each_compatible_node(node, "serial", "toshiba,sio-scc") {
52 		for (i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) {
53 			if (!(txx9_serial_bitmap & (1<<i)))
54 				continue;
55 
56 			if (of_irq_parse_one(node, i, &irq))
57 				continue;
58 			if (of_address_to_resource(node,
59 				txx9_scc_tab[i].index, &res))
60 				continue;
61 
62 			memset(&req, 0, sizeof(req));
63 			req.line = i;
64 			req.iotype = UPIO_MEM;
65 			req.mapbase = res.start + txx9_scc_tab[i].offset;
66 #ifdef CONFIG_SERIAL_TXX9_CONSOLE
67 			req.membase = ioremap(req.mapbase, 0x24);
68 #endif
69 			req.irq = irq_create_of_mapping(&irq);
70 			req.flags |= UPF_IOREMAP | UPF_BUGGY_UART
71 				/*HAVE_CTS_LINE*/;
72 			req.uartclk = 83300000;
73 			early_serial_txx9_setup(&req);
74 		}
75 	}
76 
77 	return 0;
78 }
79 
txx9_serial_config(char * ptr)80 static int __init txx9_serial_config(char *ptr)
81 {
82 	int	i;
83 
84 	for (;;) {
85 		switch (get_option(&ptr, &i)) {
86 		default:
87 			return 0;
88 		case 2:
89 			txx9_serial_bitmap |= 1 << i;
90 			break;
91 		case 1:
92 			txx9_serial_bitmap |= 1 << i;
93 			return 0;
94 		}
95 	}
96 }
97 __setup("txx9_serial=", txx9_serial_config);
98 
99 console_initcall(txx9_serial_init);
100