1187423Sgonzo/*- 2187423Sgonzo * Copyright (c) 2009 Oleksandr Tymoshenko 3187423Sgonzo * All rights reserved. 4187423Sgonzo * 5187423Sgonzo * Redistribution and use in source and binary forms, with or without 6187423Sgonzo * modification, are permitted provided that the following conditions 7187423Sgonzo * are met: 8187423Sgonzo * 1. Redistributions of source code must retain the above copyright 9187423Sgonzo * notice, this list of conditions and the following disclaimer. 10187423Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 11187423Sgonzo * notice, this list of conditions and the following disclaimer in the 12187423Sgonzo * documentation and/or other materials provided with the distribution. 13187423Sgonzo * 14187423Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15187423Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16187423Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17187423Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18187423Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19187423Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20187423Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21187423Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22187423Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23187423Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24187423Sgonzo * SUCH DAMAGE. 25187423Sgonzo * 26187423Sgonzo */ 27187423Sgonzo#include "opt_uart.h" 28187423Sgonzo 29187423Sgonzo#include <sys/cdefs.h> 30187423Sgonzo__FBSDID("$FreeBSD$"); 31187423Sgonzo 32187423Sgonzo#include <sys/param.h> 33187423Sgonzo#include <sys/systm.h> 34187423Sgonzo#include <sys/bus.h> 35187423Sgonzo 36187423Sgonzo#include <machine/bus.h> 37187423Sgonzo 38187423Sgonzo#include <dev/uart/uart.h> 39187423Sgonzo#include <dev/uart/uart_cpu.h> 40187423Sgonzo 41187456Sgonzo#include <mips/atheros/ar71xxreg.h> 42211476Sadrian#include <mips/atheros/ar71xx_cpudef.h> 43191289Sgonzo#include <mips/atheros/ar71xx_bus_space_reversed.h> 44187423Sgonzo 45187423Sgonzobus_space_tag_t uart_bus_space_io; 46187423Sgonzobus_space_tag_t uart_bus_space_mem; 47187423Sgonzo 48187423Sgonzoint 49187423Sgonzouart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) 50187423Sgonzo{ 51187423Sgonzo return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); 52187423Sgonzo} 53187423Sgonzo 54187423Sgonzoint 55187423Sgonzouart_cpu_getdev(int devtype, struct uart_devinfo *di) 56187423Sgonzo{ 57192133Sgonzo uint64_t freq; 58192133Sgonzo 59253509Sadrian freq = ar71xx_uart_freq(); 60192133Sgonzo 61187423Sgonzo di->ops = uart_getops(&uart_ns8250_class); 62187423Sgonzo di->bas.chan = 0; 63191293Sgonzo di->bas.bst = ar71xx_bus_space_reversed; 64187423Sgonzo di->bas.regshft = 2; 65192133Sgonzo di->bas.rclk = freq; 66187423Sgonzo di->baudrate = 115200; 67187423Sgonzo di->databits = 8; 68187423Sgonzo di->stopbits = 1; 69192133Sgonzo 70187423Sgonzo di->parity = UART_PARITY_NONE; 71187423Sgonzo 72191289Sgonzo uart_bus_space_io = NULL; 73191293Sgonzo uart_bus_space_mem = ar71xx_bus_space_reversed; 74191289Sgonzo di->bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR); 75187423Sgonzo return (0); 76187423Sgonzo} 77