1/* 2 * setup serial port in SCC 3 * 4 * (C) Copyright 2006 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 */ 31static int txx9_serial_bitmap = 0; 32 33static struct { 34 uint32_t offset; 35 uint32_t index; 36} txx9_scc_tab[3] = { 37 { 0x300, 0 }, /* 0xFFF300 */ 38 { 0x400, 0 }, /* 0xFFF400 */ 39 { 0x800, 1 } /* 0xFF2800 */ 40}; 41 42static int 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_irq irq; 49 struct resource res; 50 51 node = of_find_node_by_path("/ioif1/sio"); 52 if (!node) 53 return 0; 54 55 for(i = 0; i < sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) { 56 if (!(txx9_serial_bitmap & (1<<i))) 57 continue; 58 59 if (of_irq_map_one(node, i, &irq)) 60 continue; 61 if (of_address_to_resource(node, txx9_scc_tab[i].index, &res)) 62 continue; 63 64 memset(&req, 0, sizeof(req)); 65 req.line = i; 66 req.iotype = UPIO_MEM; 67 req.mapbase = res.start + txx9_scc_tab[i].offset; 68#ifdef CONFIG_SERIAL_TXX9_CONSOLE 69 req.membase = ioremap(req.mapbase, 0x24); 70#endif 71 req.irq = irq_create_of_mapping(irq.controller, 72 irq.specifier, irq.size); 73 req.flags |= UPF_IOREMAP | UPF_BUGGY_UART /*HAVE_CTS_LINE*/; 74 req.uartclk = 83300000; 75 early_serial_txx9_setup(&req); 76 } 77 78 of_node_put(node); 79 return 0; 80} 81 82static int txx9_serial_config(char *ptr) 83{ 84 int i; 85 86 for (;;) { 87 switch(get_option(&ptr, &i)) { 88 default: 89 return 0; 90 case 2: 91 txx9_serial_bitmap |= 1 << i; 92 break; 93 case 1: 94 txx9_serial_bitmap |= 1 << i; 95 return 0; 96 } 97 } 98} 99__setup("txx9_serial=", txx9_serial_config); 100 101console_initcall(txx9_serial_init); 102