1257648Sian/*-
2257648Sian * Copyright (C) 2009 Yohanes Nugroho <yohanes@gmail.com>
3257648Sian * All rights reserved.
4257648Sian *
5257648Sian * Developed by Semihalf.
6257648Sian *
7257648Sian * Redistribution and use in source and binary forms, with or without
8257648Sian * modification, are permitted provided that the following conditions
9257648Sian * are met:
10257648Sian * 1. Redistributions of source code must retain the above copyright
11257648Sian *    notice, this list of conditions and the following disclaimer.
12257648Sian * 2. Redistributions in binary form must reproduce the above copyright
13257648Sian *    notice, this list of conditions and the following disclaimer in the
14257648Sian *    documentation and/or other materials provided with the distribution.
15257648Sian *
16257648Sian * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17257648Sian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18257648Sian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19257648Sian * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20257648Sian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21257648Sian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22257648Sian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23257648Sian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24257648Sian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25257648Sian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26257648Sian * SUCH DAMAGE.
27257648Sian */
28257648Sian
29257648Sian#include "opt_uart.h"
30257648Sian
31257648Sian#include <sys/cdefs.h>
32257648Sian__FBSDID("$FreeBSD: releng/11.0/sys/arm/cavium/cns11xx/uart_cpu_ec.c 264219 2014-04-07 05:33:30Z rpaulo $");
33259364Sian
34259364Sian#include <sys/param.h>
35259364Sian#include <sys/systm.h>
36259364Sian#include <sys/bus.h>
37259364Sian#include <sys/cons.h>
38259364Sian
39259364Sian#include <machine/bus.h>
40259364Sian
41259364Sian#include <dev/uart/uart.h>
42259364Sian#include <dev/uart/uart_cpu.h>
43259364Sian
44259364Sian#include <sys/rman.h>
45259365Sian
46259365Sian#include <arm/cavium/cns11xx/econa_reg.h>
47259365Sian#include <arm/cavium/cns11xx//econa_var.h>
48259365Sian
49259365Sianbus_space_tag_t uart_bus_space_io;
50259365Sianbus_space_tag_t uart_bus_space_mem;
51259365Sian
52259365Sianint
53259365Sianuart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
54259365Sian{
55259365Sian
56259365Sian	return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0);
57259365Sian}
58259365Sian
59259365Sianint
60259365Sianuart_cpu_getdev(int devtype, struct uart_devinfo *di)
61259364Sian{
62259364Sian	struct uart_class *class = &uart_ns8250_class;
63259364Sian
64259364Sian	di->ops = uart_getops(class);
65259364Sian	di->bas.chan = 0;
66259364Sian	di->bas.bst = obio_tag;
67259364Sian
68259365Sian	if (bus_space_map(di->bas.bst, ECONA_IO_BASE + ECONA_UART_BASE,
69259365Sian	    ECONA_UART_SIZE,
70259365Sian	    0, &di->bas.bsh) != 0) {
71259365Sian		return (ENXIO);
72259364Sian	}
73259364Sian
74259364Sian	di->baudrate = 0;
75259364Sian	di->bas.regshft = EC_UART_REGSHIFT;
76259364Sian	di->bas.rclk = EC_UART_CLOCK ;
77259365Sian	di->databits = 8;
78259365Sian	di->stopbits = 1;
79257648Sian	di->parity = UART_PARITY_NONE;
80257648Sian	uart_bus_space_mem = obio_tag;
81257648Sian	uart_bus_space_io = NULL;
82257648Sian
83257648Sian	return (0);
84257648Sian}
85257648Sian