1178173Simp/*-
2178173Simp * Copyright (c) 2007 Bruce M. Simpson.
3178173Simp * All rights reserved.
4178173Simp *
5178173Simp * Redistribution and use in source and binary forms, with or without
6178173Simp * modification, are permitted provided that the following conditions
7178173Simp * are met:
8178173Simp * 1. Redistributions of source code must retain the above copyright
9178173Simp *    notice, this list of conditions and the following disclaimer.
10178173Simp * 2. Redistributions in binary form must reproduce the above copyright
11178173Simp *    notice, this list of conditions and the following disclaimer in the
12178173Simp *    documentation and/or other materials provided with the distribution.
13178173Simp *
14178173Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15178173Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16178173Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17178173Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18178173Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19178173Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20178173Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21178173Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22178173Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23178173Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24178173Simp * $Id$
25178173Simp */
26178173Simp/*
27178173Simp * Skeleton of this file was based on respective code for ARM
28178173Simp * code written by Olivier Houchard.
29178173Simp */
30178173Simp
31178173Simp/*
32178173Simp * XXXMIPS: This file is hacked from arm/... . XXXMIPS here means this file is
33178173Simp * experimental and was written for MIPS32 port.
34178173Simp */
35178173Simp#include "opt_uart.h"
36178173Simp
37178173Simp#include <sys/cdefs.h>
38178173Simp__FBSDID("$FreeBSD: stable/11/sys/mips/adm5120/uart_bus_adm5120.c 340145 2018-11-04 23:28:56Z mmacy $");
39178173Simp
40178173Simp#include <sys/param.h>
41178173Simp#include <sys/systm.h>
42178173Simp#include <sys/bus.h>
43178173Simp#include <sys/conf.h>
44178173Simp#include <sys/kernel.h>
45178173Simp#include <sys/module.h>
46178173Simp#include <machine/bus.h>
47178173Simp#include <sys/rman.h>
48178173Simp#include <machine/resource.h>
49178173Simp
50178173Simp#include <dev/pci/pcivar.h>
51178173Simp
52178173Simp#include <dev/uart/uart.h>
53178173Simp#include <dev/uart/uart_bus.h>
54178173Simp#include <dev/uart/uart_cpu.h>
55178173Simp
56182901Sgonzo#include <mips/adm5120/adm5120reg.h>
57178173Simp
58178173Simp#include "uart_if.h"
59178173Simp
60178173Simpstatic int uart_adm5120_probe(device_t dev);
61178173Simp
62178173Simpextern struct uart_class uart_adm5120_uart_class;
63178173Simp
64178173Simpstatic device_method_t uart_adm5120_methods[] = {
65178173Simp	/* Device interface */
66178173Simp	DEVMETHOD(device_probe,		uart_adm5120_probe),
67178173Simp	DEVMETHOD(device_attach,	uart_bus_attach),
68178173Simp	DEVMETHOD(device_detach,	uart_bus_detach),
69178173Simp	{ 0, 0 }
70178173Simp};
71178173Simp
72178173Simpstatic driver_t uart_adm5120_driver = {
73178173Simp	uart_driver_name,
74178173Simp	uart_adm5120_methods,
75178173Simp	sizeof(struct uart_softc),
76178173Simp};
77178173Simp
78178173Simpextern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs;
79178173Simp
80178173Simpstatic int
81178173Simpuart_adm5120_probe(device_t dev)
82178173Simp{
83178173Simp	struct uart_softc *sc;
84178173Simp
85178173Simp	sc = device_get_softc(dev);
86178173Simp	sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs);
87178173Simp	sc->sc_class = &uart_adm5120_uart_class;
88178173Simp	bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas));
89178173Simp
90340145Smmacy	return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0));
91178173Simp}
92178173Simp
93178173SimpDRIVER_MODULE(uart, obio, uart_adm5120_driver, uart_devclass, 0, 0);
94