uart_bus_acpi.c revision 200820
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: head/sys/dev/uart/uart_bus_acpi.c 200820 2009-12-21 22:57:40Z gavin $"); 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), 50119815Smarcel { 0, 0 } 51119815Smarcel}; 52119815Smarcel 53119815Smarcelstatic driver_t uart_acpi_driver = { 54119815Smarcel uart_driver_name, 55119815Smarcel uart_acpi_methods, 56119815Smarcel sizeof(struct uart_softc), 57119815Smarcel}; 58119815Smarcel 59119815Smarcelstatic struct isa_pnp_id acpi_ns8250_ids[] = { 60119815Smarcel {0x0005d041, "Standard PC COM port"}, /* PNP0500 */ 61119815Smarcel {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */ 62200820Sgavin {0x04f0235c, "Wacom Tablet PC Screen"}, /* WACF004 */ 63119815Smarcel {0} 64119815Smarcel}; 65119815Smarcel 66119815Smarcelstatic int 67119815Smarceluart_acpi_probe(device_t dev) 68119815Smarcel{ 69119815Smarcel struct uart_softc *sc; 70119815Smarcel device_t parent; 71119815Smarcel 72119815Smarcel parent = device_get_parent(dev); 73119815Smarcel sc = device_get_softc(dev); 74119815Smarcel 75119815Smarcel if (!ISA_PNP_PROBE(parent, dev, acpi_ns8250_ids)) { 76119815Smarcel sc->sc_class = &uart_ns8250_class; 77120452Smarcel return (uart_bus_probe(dev, 0, 0, 0, 0)); 78119815Smarcel } 79119815Smarcel 80119815Smarcel /* Add checks for non-ns8250 IDs here. */ 81119815Smarcel return (ENXIO); 82119815Smarcel} 83119815Smarcel 84119815SmarcelDRIVER_MODULE(uart, acpi, uart_acpi_driver, uart_devclass, 0, 0); 85