1178173Simp/*- 2178173Simp * Copyright (c) 2006 Wojciech A. Koszek <wkoszek@FreeBSD.org> 3178173Simp * All rights reserved. 4178173Simp * 5178173Simp * Redistribution and use in source and binary forms, with or without 6178173Simp * modification, are permitted provided that the following conditions 7178173Simp * are met: 8178173Simp * 1. Redistributions of source code must retain the above copyright 9178173Simp * notice, this list of conditions and the following disclaimer. 10178173Simp * 2. Redistributions in binary form must reproduce the above copyright 11178173Simp * notice, this list of conditions and the following disclaimer in the 12178173Simp * documentation and/or other materials provided with the distribution. 13178173Simp * 14178173Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15178173Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16178173Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17178173Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18178173Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19178173Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20178173Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21178173Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22178173Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23178173Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24178173Simp * SUCH DAMAGE. 25178173Simp * 26178173Simp * $Id$ 27178173Simp */ 28178173Simp/* 29178173Simp * Skeleton of this file was based on respective code for ARM 30178173Simp * code written by Olivier Houchard. 31178173Simp */ 32178173Simp/* 33178173Simp * XXXMIPS: This file is hacked from arm/... . XXXMIPS here means this file is 34178173Simp * experimental and was written for MIPS32 port. 35178173Simp */ 36178173Simp#include "opt_uart.h" 37178173Simp 38178173Simp#include <sys/cdefs.h> 39178173Simp__FBSDID("$FreeBSD$"); 40178173Simp 41178173Simp#include <sys/param.h> 42178173Simp#include <sys/systm.h> 43178173Simp#include <sys/bus.h> 44178173Simp#include <sys/cons.h> 45178173Simp 46178173Simp#include <machine/bus.h> 47178173Simp 48178173Simp#include <dev/uart/uart.h> 49178173Simp#include <dev/uart/uart_cpu.h> 50178173Simp 51178173Simpextern struct uart_class uart_rc32434_uart_class; 52178173Simpbus_space_tag_t uart_bus_space_io; 53178173Simpbus_space_tag_t uart_bus_space_mem; 54178173Simp 55178173Simpint 56178173Simpuart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) 57178173Simp{ 58178173Simp 59178173Simp return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); 60178173Simp} 61178173Simp 62178173Simpint 63178173Simpuart_cpu_getdev(int devtype, struct uart_devinfo *di) 64178173Simp{ 65178173Simp uint32_t maddr; 66178173Simp 67178173Simp if (resource_int_value("uart", 0, "maddr", &maddr) != 0 || 68178173Simp maddr == 0) 69178173Simp return (ENXIO); 70178173Simp 71178173Simp /* Got it. Fill in the instance and return it. */ 72178173Simp di->ops = uart_getops(&uart_ns8250_class); 73178173Simp di->bas.chan = 0; 74202027Simp di->bas.bst = mips_bus_space_generic; 75178173Simp di->bas.regshft = 2; 76178173Simp di->bas.rclk = 330000000UL/2; /* IPbus clock */ 77178173Simp di->baudrate = 115200; 78178173Simp di->databits = 8; 79178173Simp di->stopbits = 1; 80178173Simp di->parity = UART_PARITY_NONE; 81178173Simp uart_bus_space_io = 0; 82202027Simp uart_bus_space_mem = mips_bus_space_generic; 83178173Simp di->bas.bsh = MIPS_PHYS_TO_KSEG1(maddr); 84178173Simp return (0); 85178173Simp} 86