1164426Ssam/*-
2164426Ssam * Copyright (c) 2006 Kevin Lo.  All rights reserved.
3164426Ssam *
4164426Ssam * Redistribution and use in source and binary forms, with or without
5164426Ssam * modification, are permitted provided that the following conditions
6164426Ssam * are met:
7164426Ssam * 1. Redistributions of source code must retain the above copyright
8164426Ssam *    notice, this list of conditions and the following disclaimer.
9164426Ssam * 2. Redistributions in binary form must reproduce the above copyright
10164426Ssam *    notice, this list of conditions and the following disclaimer in the
11164426Ssam *    documentation and/or other materials provided with the distribution.
12164426Ssam *
13164426Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14164426Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15164426Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16164426Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17164426Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18164426Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19164426Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20164426Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21164426Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22164426Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23164426Ssam */
24164426Ssam
25164426Ssam#include <sys/cdefs.h>
26164426Ssam__FBSDID("$FreeBSD: releng/10.2/sys/arm/xscale/ixp425/uart_bus_ixp425.c 194668 2009-06-22 22:46:37Z sam $");
27164426Ssam
28164426Ssam#include <sys/param.h>
29164426Ssam#include <sys/systm.h>
30164426Ssam#include <sys/bus.h>
31164426Ssam#include <sys/conf.h>
32164426Ssam#include <sys/kernel.h>
33164426Ssam#include <sys/module.h>
34164426Ssam#include <machine/bus.h>
35164426Ssam#include <sys/rman.h>
36164426Ssam#include <machine/resource.h>
37164426Ssam
38164426Ssam#include <dev/pci/pcivar.h>
39164426Ssam#include <dev/ic/ns16550.h>
40164426Ssam
41164426Ssam#include <dev/uart/uart.h>
42164426Ssam#include <dev/uart/uart_bus.h>
43164426Ssam#include <dev/uart/uart_cpu.h>
44164426Ssam
45164426Ssam#include <arm/xscale/ixp425/ixp425reg.h>
46164426Ssam#include <arm/xscale/ixp425/ixp425var.h>
47164426Ssam
48164426Ssam#include "uart_if.h"
49164426Ssam
50164426Ssamstatic int uart_ixp425_probe(device_t dev);
51164426Ssam
52164426Ssamstatic device_method_t uart_ixp425_methods[] = {
53164426Ssam	/* Device interface */
54164426Ssam	DEVMETHOD(device_probe,		uart_ixp425_probe),
55164426Ssam	DEVMETHOD(device_attach,	uart_bus_attach),
56164426Ssam	DEVMETHOD(device_detach,	uart_bus_detach),
57164426Ssam	{ 0, 0 }
58164426Ssam};
59164426Ssam
60164426Ssamstatic driver_t uart_ixp425_driver = {
61164426Ssam	uart_driver_name,
62164426Ssam	uart_ixp425_methods,
63164426Ssam	sizeof(struct uart_softc),
64164426Ssam};
65169950SsamDRIVER_MODULE(uart, ixp, uart_ixp425_driver, uart_devclass, 0, 0);
66164426Ssam
67164426Ssamstatic int
68164426Ssamuart_ixp425_probe(device_t dev)
69164426Ssam{
70164426Ssam	struct uart_softc *sc;
71194668Ssam	int unit = device_get_unit(dev);
72194668Ssam	u_int rclk;
73164426Ssam
74164426Ssam	sc = device_get_softc(dev);
75164426Ssam	sc->sc_class = &uart_ns8250_class;
76194668Ssam	if (resource_int_value("uart", unit, "rclk", &rclk))
77194668Ssam		rclk = IXP425_UART_FREQ;
78194668Ssam	if (bootverbose)
79194668Ssam		device_printf(dev, "rclk %u\n", rclk);
80169950Ssam
81194668Ssam	return uart_bus_probe(dev, 0, rclk, 0, 0);
82164426Ssam}
83