Path: blob/master/arch/powerpc/platforms/cell/celleb_scc_sio.c
10818 views
/*1* setup serial port in SCC2*3* (C) Copyright 2006-2007 TOSHIBA CORPORATION4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License along16* with this program; if not, write to the Free Software Foundation, Inc.,17* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.18*/1920#include <linux/tty.h>21#include <linux/serial.h>22#include <linux/serial_core.h>23#include <linux/console.h>2425#include <asm/io.h>26#include <asm/prom.h>2728/* sio irq0=0xb00010022 irq0=0xb00010023 irq2=0xb0001002429mmio=0xfff000-0x1000,0xff2000-0x1000 */30static int txx9_serial_bitmap __initdata;3132static struct {33uint32_t offset;34uint32_t index;35} txx9_scc_tab[3] __initdata = {36{ 0x300, 0 }, /* 0xFFF300 */37{ 0x400, 0 }, /* 0xFFF400 */38{ 0x800, 1 } /* 0xFF2800 */39};4041static int __init txx9_serial_init(void)42{43extern int early_serial_txx9_setup(struct uart_port *port);44struct device_node *node = NULL;45int i;46struct uart_port req;47struct of_irq irq;48struct resource res;4950while ((node = of_find_compatible_node(node,51"serial", "toshiba,sio-scc")) != NULL) {52for (i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) {53if (!(txx9_serial_bitmap & (1<<i)))54continue;5556if (of_irq_map_one(node, i, &irq))57continue;58if (of_address_to_resource(node,59txx9_scc_tab[i].index, &res))60continue;6162memset(&req, 0, sizeof(req));63req.line = i;64req.iotype = UPIO_MEM;65req.mapbase = res.start + txx9_scc_tab[i].offset;66#ifdef CONFIG_SERIAL_TXX9_CONSOLE67req.membase = ioremap(req.mapbase, 0x24);68#endif69req.irq = irq_create_of_mapping(irq.controller,70irq.specifier, irq.size);71req.flags |= UPF_IOREMAP | UPF_BUGGY_UART72/*HAVE_CTS_LINE*/;73req.uartclk = 83300000;74early_serial_txx9_setup(&req);75}76}7778return 0;79}8081static int __init txx9_serial_config(char *ptr)82{83int i;8485for (;;) {86switch (get_option(&ptr, &i)) {87default:88return 0;89case 2:90txx9_serial_bitmap |= 1 << i;91break;92case 1:93txx9_serial_bitmap |= 1 << i;94return 0;95}96}97}98__setup("txx9_serial=", txx9_serial_config);99100console_initcall(txx9_serial_init);101102103