1299994Sadrian/*- 2299994Sadrian * Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com> 3299994Sadrian * 4299994Sadrian * All rights reserved. 5299994Sadrian * 6299994Sadrian * Redistribution and use in source and binary forms, with or without 7299994Sadrian * modification, are permitted provided that the following conditions 8299994Sadrian * are met: 9299994Sadrian * 1. Redistributions of source code must retain the above copyright 10299994Sadrian * notice, this list of conditions and the following disclaimer. 11299994Sadrian * 2. Redistributions in binary form must reproduce the above copyright 12299994Sadrian * notice, this list of conditions and the following disclaimer in the 13299994Sadrian * documentation and/or other materials provided with the distribution. 14299994Sadrian * 15299994Sadrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16299994Sadrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17299994Sadrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18299994Sadrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19299994Sadrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20299994Sadrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21299994Sadrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22299994Sadrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23299994Sadrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24299994Sadrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25299994Sadrian * SUCH DAMAGE. 26299994Sadrian */ 27299994Sadrian 28299994Sadrian#include <sys/cdefs.h> 29299994Sadrian__FBSDID("$FreeBSD: stable/11/sys/mips/broadcom/uart_bus_chipc.c 340145 2018-11-04 23:28:56Z mmacy $"); 30299994Sadrian 31299994Sadrian#include "opt_uart.h" 32299994Sadrian 33299994Sadrian#include <sys/param.h> 34299994Sadrian#include <sys/systm.h> 35299994Sadrian#include <sys/bus.h> 36299994Sadrian#include <sys/conf.h> 37299994Sadrian#include <sys/kernel.h> 38299994Sadrian#include <sys/module.h> 39299994Sadrian#include <sys/rman.h> 40299994Sadrian 41299994Sadrian#include <machine/bus.h> 42299994Sadrian#include <machine/resource.h> 43299994Sadrian 44299994Sadrian#include <dev/uart/uart.h> 45299994Sadrian#include <dev/uart/uart_bus.h> 46299994Sadrian#include <dev/uart/uart_cpu.h> 47299994Sadrian 48299994Sadrian#include "uart_if.h" 49299994Sadrian#include "bhnd_chipc_if.h" 50299994Sadrian 51302189Slandonf#include "bcm_socinfo.h" 52301409Slandonf 53299994Sadrian 54299994Sadrianstatic int 55299994Sadrianuart_chipc_probe(device_t dev) 56299994Sadrian{ 57299994Sadrian struct uart_softc *sc; 58302189Slandonf struct bcm_socinfo *socinfo; 59299994Sadrian 60299994Sadrian sc = device_get_softc(dev); 61299994Sadrian sc->sc_class = &uart_ns8250_class; 62299994Sadrian 63302189Slandonf /* TODO: UART rate should be calculated from CPU clock speed 64302189Slandonf * as fetched from bhnd bus */ 65302189Slandonf socinfo = bcm_get_socinfo(); 66340145Smmacy return (uart_bus_probe(dev, 0, 0, socinfo->uartrate, 0, 0, 0)); 67299994Sadrian} 68299994Sadrian 69299994Sadrianstatic device_method_t uart_chipc_methods[] = { 70299994Sadrian /* Device interface */ 71299994Sadrian DEVMETHOD(device_probe, uart_chipc_probe), 72299994Sadrian DEVMETHOD(device_attach, uart_bus_attach), 73299994Sadrian DEVMETHOD(device_detach, uart_bus_detach), 74299994Sadrian { 0, 0 } 75299994Sadrian}; 76299994Sadrian 77299994Sadrianstatic driver_t uart_chipc_driver = { 78299994Sadrian uart_driver_name, 79299994Sadrian uart_chipc_methods, 80299994Sadrian sizeof(struct uart_softc), 81299994Sadrian}; 82299994Sadrian 83299994SadrianDRIVER_MODULE(uart, bhnd_chipc, uart_chipc_driver, uart_devclass, 0, 0); 84