1187514Sgonzo/*- 2187514Sgonzo * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3187514Sgonzo * All rights reserved. 4187514Sgonzo * 5187514Sgonzo * Redistribution and use in source and binary forms, with or without 6187514Sgonzo * modification, are permitted provided that the following conditions 7187514Sgonzo * are met: 8187514Sgonzo * 1. Redistributions of source code must retain the above copyright 9187514Sgonzo * notice, this list of conditions and the following disclaimer. 10187514Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 11187514Sgonzo * notice, this list of conditions and the following disclaimer in the 12187514Sgonzo * documentation and/or other materials provided with the distribution. 13187514Sgonzo * 14187514Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15187514Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16187514Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17187514Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18187514Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19187514Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20187514Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21187514Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22187514Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23187514Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24187514Sgonzo */ 25187514Sgonzo#include "opt_uart.h" 26187514Sgonzo 27187514Sgonzo#include <sys/cdefs.h> 28187514Sgonzo__FBSDID("$FreeBSD: releng/11.0/sys/mips/atheros/uart_bus_ar71xx.c 253509 2013-07-21 03:54:39Z adrian $"); 29187514Sgonzo 30187514Sgonzo#include <sys/param.h> 31187514Sgonzo#include <sys/systm.h> 32187514Sgonzo#include <sys/bus.h> 33187514Sgonzo#include <sys/conf.h> 34187514Sgonzo#include <sys/kernel.h> 35187514Sgonzo#include <sys/module.h> 36187514Sgonzo 37187514Sgonzo#include <machine/bus.h> 38187514Sgonzo 39187514Sgonzo#include <dev/uart/uart.h> 40187514Sgonzo#include <dev/uart/uart_cpu.h> 41187514Sgonzo#include <dev/uart/uart_bus.h> 42187514Sgonzo 43187514Sgonzo#include <mips/atheros/ar71xxreg.h> 44211476Sadrian#include <mips/atheros/ar71xx_cpudef.h> 45187514Sgonzo 46187514Sgonzo#include "uart_if.h" 47187514Sgonzo 48187514Sgonzostatic int uart_ar71xx_probe(device_t dev); 49187514Sgonzoextern struct uart_class uart_ar71xx_uart_class; 50187514Sgonzo 51187514Sgonzostatic device_method_t uart_ar71xx_methods[] = { 52187514Sgonzo /* Device interface */ 53187514Sgonzo DEVMETHOD(device_probe, uart_ar71xx_probe), 54187514Sgonzo DEVMETHOD(device_attach, uart_bus_attach), 55187514Sgonzo DEVMETHOD(device_detach, uart_bus_detach), 56187514Sgonzo { 0, 0 } 57187514Sgonzo}; 58187514Sgonzo 59187514Sgonzostatic driver_t uart_ar71xx_driver = { 60187514Sgonzo uart_driver_name, 61187514Sgonzo uart_ar71xx_methods, 62187514Sgonzo sizeof(struct uart_softc), 63187514Sgonzo}; 64187514Sgonzo 65187514Sgonzoextern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 66187514Sgonzo 67187514Sgonzostatic int 68187514Sgonzouart_ar71xx_probe(device_t dev) 69187514Sgonzo{ 70187514Sgonzo struct uart_softc *sc; 71192656Sgonzo uint64_t freq; 72187514Sgonzo 73253509Sadrian freq = ar71xx_uart_freq(); 74192656Sgonzo 75187514Sgonzo sc = device_get_softc(dev); 76187514Sgonzo sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); 77187514Sgonzo sc->sc_class = &uart_ns8250_class; 78187514Sgonzo bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); 79191840Sgonzo sc->sc_sysdev->bas.regshft = 2; 80191840Sgonzo sc->sc_sysdev->bas.bst = mips_bus_space_generic; 81191840Sgonzo sc->sc_sysdev->bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR) + 3; 82191840Sgonzo sc->sc_bas.regshft = 2; 83191840Sgonzo sc->sc_bas.bst = mips_bus_space_generic; 84191840Sgonzo sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR) + 3; 85187514Sgonzo 86192656Sgonzo return (uart_bus_probe(dev, 2, freq, 0, 0)); 87187514Sgonzo} 88187514Sgonzo 89187514SgonzoDRIVER_MODULE(uart, apb, uart_ar71xx_driver, uart_devclass, 0, 0); 90