1139749Simp/*-
2119815Smarcel * Copyright (c) 2001 M. Warner Losh.  All rights reserved.
3119815Smarcel *
4119815Smarcel * Redistribution and use in source and binary forms, with or without
5119815Smarcel * modification, are permitted provided that the following conditions
6119815Smarcel * are met:
7119815Smarcel * 1. Redistributions of source code must retain the above copyright
8119815Smarcel *    notice, this list of conditions and the following disclaimer.
9119815Smarcel * 2. Redistributions in binary form must reproduce the above copyright
10119815Smarcel *    notice, this list of conditions and the following disclaimer in the
11119815Smarcel *    documentation and/or other materials provided with the distribution.
12119815Smarcel *
13119815Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14119815Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15119815Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16119815Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17119815Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18119815Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19119815Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20119815Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21119815Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22119815Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23119815Smarcel */
24119815Smarcel
25119815Smarcel#include <sys/cdefs.h>
26119815Smarcel__FBSDID("$FreeBSD: releng/10.2/sys/dev/uart/uart_bus_acpi.c 246243 2013-02-02 11:38:26Z avg $");
27119815Smarcel
28119815Smarcel#include <sys/param.h>
29119815Smarcel#include <sys/systm.h>
30119815Smarcel#include <sys/bus.h>
31119815Smarcel#include <sys/conf.h>
32119815Smarcel#include <sys/kernel.h>
33119815Smarcel#include <sys/module.h>
34119815Smarcel#include <machine/bus.h>
35119815Smarcel#include <sys/rman.h>
36119815Smarcel#include <machine/resource.h>
37119815Smarcel
38119815Smarcel#include <isa/isavar.h>
39119815Smarcel
40119815Smarcel#include <dev/uart/uart.h>
41119815Smarcel#include <dev/uart/uart_bus.h>
42119815Smarcel
43119815Smarcelstatic int uart_acpi_probe(device_t dev);
44119815Smarcel
45119815Smarcelstatic device_method_t uart_acpi_methods[] = {
46119815Smarcel	/* Device interface */
47119815Smarcel	DEVMETHOD(device_probe,		uart_acpi_probe),
48119815Smarcel	DEVMETHOD(device_attach,	uart_bus_attach),
49119815Smarcel	DEVMETHOD(device_detach,	uart_bus_detach),
50246243Savg	DEVMETHOD(device_resume,	uart_bus_resume),
51119815Smarcel	{ 0, 0 }
52119815Smarcel};
53119815Smarcel
54119815Smarcelstatic driver_t uart_acpi_driver = {
55119815Smarcel	uart_driver_name,
56119815Smarcel	uart_acpi_methods,
57119815Smarcel	sizeof(struct uart_softc),
58119815Smarcel};
59119815Smarcel
60119815Smarcelstatic struct isa_pnp_id acpi_ns8250_ids[] = {
61119815Smarcel	{0x0005d041, "Standard PC COM port"},		/* PNP0500 */
62119815Smarcel	{0x0105d041, "16550A-compatible COM port"},	/* PNP0501 */
63242583Seadler	{0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */
64242583Seadler	{0x1005d041, "Generic IRDA-compatible device"},	/* PNP0510 */
65242583Seadler	{0x1105d041, "Generic IRDA-compatible device"},	/* PNP0511 */
66200820Sgavin	{0x04f0235c, "Wacom Tablet PC Screen"},		/* WACF004 */
67242583Seadler	{0xe502aa1a, "Wacom Tablet at FuS Lifebook T"},	/* FUJ02E5 */
68119815Smarcel	{0}
69119815Smarcel};
70119815Smarcel
71119815Smarcelstatic int
72119815Smarceluart_acpi_probe(device_t dev)
73119815Smarcel{
74119815Smarcel	struct uart_softc *sc;
75119815Smarcel	device_t parent;
76119815Smarcel
77119815Smarcel	parent = device_get_parent(dev);
78119815Smarcel	sc = device_get_softc(dev);
79119815Smarcel
80119815Smarcel	if (!ISA_PNP_PROBE(parent, dev, acpi_ns8250_ids)) {
81119815Smarcel		sc->sc_class = &uart_ns8250_class;
82120452Smarcel		return (uart_bus_probe(dev, 0, 0, 0, 0));
83119815Smarcel	}
84119815Smarcel
85119815Smarcel	/* Add checks for non-ns8250 IDs here. */
86119815Smarcel	return (ENXIO);
87119815Smarcel}
88119815Smarcel
89119815SmarcelDRIVER_MODULE(uart, acpi, uart_acpi_driver, uart_devclass, 0, 0);
90