Path: blob/master/arch/mips/pmc-sierra/msp71xx/msp_serial.c
15118 views
/*1* The setup file for serial related hardware on PMC-Sierra MSP processors.2*3* Copyright 2005 PMC-Sierra, Inc.4*5* This program is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License as published by the7* Free Software Foundation; either version 2 of the License, or (at your8* option) any later version.9*10* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED11* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN13* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,14* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT15* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF16* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON17* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT18* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF19* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.20*21* You should have received a copy of the GNU General Public License along22* with this program; if not, write to the Free Software Foundation, Inc.,23* 675 Mass Ave, Cambridge, MA 02139, USA.24*/2526#include <linux/serial.h>27#include <linux/serial_core.h>28#include <linux/serial_reg.h>2930#include <asm/bootinfo.h>31#include <asm/io.h>32#include <asm/processor.h>33#include <asm/serial.h>34#include <linux/serial_8250.h>3536#include <msp_prom.h>37#include <msp_int.h>38#include <msp_regs.h>3940void __init msp_serial_setup(void)41{42char *s;43char *endp;44struct uart_port up;45unsigned int uartclk;4647memset(&up, 0, sizeof(up));4849/* Check if clock was specified in environment */50s = prom_getenv("uartfreqhz");51if(!(s && *s && (uartclk = simple_strtoul(s, &endp, 10)) && *endp == 0))52uartclk = MSP_BASE_BAUD;53ppfinit("UART clock set to %d\n", uartclk);5455/* Initialize first serial port */56up.mapbase = MSP_UART0_BASE;57up.membase = ioremap_nocache(up.mapbase, MSP_UART_REG_LEN);58up.irq = MSP_INT_UART0;59up.uartclk = uartclk;60up.regshift = 2;61up.iotype = UPIO_DWAPB; /* UPIO_MEM like */62up.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;63up.type = PORT_16550A;64up.line = 0;65up.private_data = (void*)UART0_STATUS_REG;66if (early_serial_setup(&up))67printk(KERN_ERR "Early serial init of port 0 failed\n");6869/* Initialize the second serial port, if one exists */70switch (mips_machtype) {71case MACH_MSP4200_EVAL:72case MACH_MSP4200_GW:73case MACH_MSP4200_FPGA:74case MACH_MSP7120_EVAL:75case MACH_MSP7120_GW:76case MACH_MSP7120_FPGA:77/* Enable UART1 on MSP4200 and MSP7120 */78*GPIO_CFG2_REG = 0x00002299;79break;8081default:82return; /* No second serial port, good-bye. */83}8485up.mapbase = MSP_UART1_BASE;86up.membase = ioremap_nocache(up.mapbase, MSP_UART_REG_LEN);87up.irq = MSP_INT_UART1;88up.line = 1;89up.private_data = (void*)UART1_STATUS_REG;90if (early_serial_setup(&up))91printk(KERN_ERR "Early serial init of port 1 failed\n");92}939495