1225394Sjchandra/*-
2225394Sjchandra * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights
3225394Sjchandra * reserved.
4225394Sjchandra *
5225394Sjchandra * Redistribution and use in source and binary forms, with or without
6225394Sjchandra * modification, are permitted provided that the following conditions are
7225394Sjchandra * met:
8225394Sjchandra *
9225394Sjchandra * 1. Redistributions of source code must retain the above copyright
10225394Sjchandra *    notice, this list of conditions and the following disclaimer.
11225394Sjchandra * 2. Redistributions in binary form must reproduce the above copyright
12225394Sjchandra *    notice, this list of conditions and the following disclaimer in
13225394Sjchandra *    the documentation and/or other materials provided with the
14225394Sjchandra *    distribution.
15225394Sjchandra *
16225394Sjchandra * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND
17225394Sjchandra * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18225394Sjchandra * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19225394Sjchandra * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE
20225394Sjchandra * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21225394Sjchandra * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22225394Sjchandra * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23225394Sjchandra * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24225394Sjchandra * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25225394Sjchandra * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26225394Sjchandra * THE POSSIBILITY OF SUCH DAMAGE.
27225394Sjchandra *
28225394Sjchandra * NETLOGIC_BSD */
29225394Sjchandra
30225394Sjchandra/*
31225394Sjchandra * Skeleton of this file was based on respective code for ARM
32225394Sjchandra * code written by Olivier Houchard.
33225394Sjchandra */
34225394Sjchandra/*
35225394Sjchandra * XLRMIPS: This file is hacked from arm/...
36225394Sjchandra */
37226501Sjchandra#include "opt_platform.h"
38226501Sjchandra
39226501Sjchandra#ifndef	FDT			/* use FDT uart when fdt is enable */
40225394Sjchandra#include "opt_uart.h"
41225394Sjchandra
42225394Sjchandra#include <sys/cdefs.h>
43225394Sjchandra__FBSDID("$FreeBSD: releng/10.3/sys/mips/nlm/uart_cpu_xlp.c 233549 2012-03-27 14:48:40Z jchandra $");
44225394Sjchandra
45225394Sjchandra#include <sys/param.h>
46225394Sjchandra#include <sys/systm.h>
47225394Sjchandra#include <sys/bus.h>
48225394Sjchandra#include <sys/cons.h>
49225394Sjchandra#include <sys/kdb.h>
50225394Sjchandra#include <sys/kernel.h>
51225394Sjchandra#include <sys/lock.h>
52225394Sjchandra#include <sys/mutex.h>
53225394Sjchandra
54225394Sjchandra#include <machine/bus.h>
55225394Sjchandra
56225394Sjchandra#include <dev/uart/uart.h>
57225394Sjchandra#include <dev/uart/uart_cpu.h>
58225394Sjchandra
59225394Sjchandra#include <mips/nlm/hal/haldefs.h>
60225394Sjchandra#include <mips/nlm/hal/iomap.h>
61233549Sjchandra#include <mips/nlm/hal/mips-extns.h>
62225394Sjchandra#include <mips/nlm/hal/uart.h>
63225394Sjchandra
64233549Sjchandra#include <mips/nlm/board.h>
65233549Sjchandra
66225394Sjchandrabus_space_tag_t uart_bus_space_io;
67225394Sjchandrabus_space_tag_t uart_bus_space_mem;
68225394Sjchandra
69225394Sjchandraint
70225394Sjchandrauart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
71225394Sjchandra{
72233549Sjchandra	return (b1->bsh == b2->bsh && b1->bst == b2->bst);
73225394Sjchandra}
74225394Sjchandra
75225394Sjchandraint
76225394Sjchandrauart_cpu_getdev(int devtype, struct uart_devinfo *di)
77225394Sjchandra{
78225394Sjchandra	di->ops = uart_getops(&uart_ns8250_class);
79225394Sjchandra	di->bas.chan = 0;
80226501Sjchandra	di->bas.bst = rmi_uart_bus_space;
81233549Sjchandra	di->bas.bsh = nlm_get_uart_regbase(0, BOARD_CONSOLE_UART);
82225394Sjchandra
83225394Sjchandra	di->bas.regshft = 2;
84225394Sjchandra	/* divisor = rclk / (baudrate * 16); */
85233549Sjchandra	di->bas.rclk = XLP_IO_CLK;
86233549Sjchandra	di->baudrate = BOARD_CONSOLE_SPEED;
87225394Sjchandra	di->databits = 8;
88225394Sjchandra	di->stopbits = 1;
89225394Sjchandra	di->parity = UART_PARITY_NONE;
90225394Sjchandra
91225394Sjchandra	uart_bus_space_io = NULL;
92226501Sjchandra	uart_bus_space_mem = rmi_uart_bus_space;
93225394Sjchandra	return (0);
94225394Sjchandra}
95226501Sjchandra#endif
96