xref: /netbsd-src/sys/dev/pci/wsdisplay_pci.c (revision e28cc170ed38fae2f454e4d982e7754a94b3e1d3)
1*e28cc170Scegger /*	$NetBSD: wsdisplay_pci.c,v 1.1 2011/01/22 15:14:28 cegger Exp $ */
2*e28cc170Scegger /*
3*e28cc170Scegger  * Copyright (c) 2011 The NetBSD Foundation, Inc.
4*e28cc170Scegger  * All rights reserved.
5*e28cc170Scegger  *
6*e28cc170Scegger  * This code is derived from software contributed to The NetBSD Foundation
7*e28cc170Scegger  * by Christoph Egger.
8*e28cc170Scegger  *
9*e28cc170Scegger  * Redistribution and use in source and binary forms, with or without
10*e28cc170Scegger  * modification, are permitted provided that the following conditions
11*e28cc170Scegger  * are met:
12*e28cc170Scegger  * 1. Redistributions of source code must retain the above copyright
13*e28cc170Scegger  *    notice, this list of conditions and the following disclaimer.
14*e28cc170Scegger  * 2. Redistributions in binary form must reproduce the above copyright
15*e28cc170Scegger  *    notice, this list of conditions and the following disclaimer in the
16*e28cc170Scegger  *    documentation and/or other materials provided with the distribution.
17*e28cc170Scegger  *
18*e28cc170Scegger  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19*e28cc170Scegger  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20*e28cc170Scegger  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21*e28cc170Scegger  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22*e28cc170Scegger  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*e28cc170Scegger  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*e28cc170Scegger  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*e28cc170Scegger  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*e28cc170Scegger  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*e28cc170Scegger  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*e28cc170Scegger  * POSSIBILITY OF SUCH DAMAGE.
29*e28cc170Scegger  */
30*e28cc170Scegger 
31*e28cc170Scegger #include <sys/cdefs.h>
32*e28cc170Scegger __KERNEL_RCSID(0, "$NetBSD: wsdisplay_pci.c,v 1.1 2011/01/22 15:14:28 cegger Exp $");
33*e28cc170Scegger 
34*e28cc170Scegger #include <sys/param.h>
35*e28cc170Scegger #include <sys/bus.h>
36*e28cc170Scegger #include <dev/pci/pcivar.h>
37*e28cc170Scegger #include <dev/wscons/wsconsio.h>
38*e28cc170Scegger #include <dev/pci/wsdisplay_pci.h>
39*e28cc170Scegger 
40*e28cc170Scegger int
wsdisplayio_busid_pci(device_t self,pci_chipset_tag_t pc,pcitag_t tag,void * data)41*e28cc170Scegger wsdisplayio_busid_pci(device_t self, pci_chipset_tag_t pc,
42*e28cc170Scegger     pcitag_t tag, void *data)
43*e28cc170Scegger {
44*e28cc170Scegger 	struct wsdisplayio_bus_id *busid = data;
45*e28cc170Scegger 
46*e28cc170Scegger 	KASSERT(device_is_a(device_parent(self), "pci"));
47*e28cc170Scegger 	busid->bus_type = WSDISPLAYIO_BUS_PCI;
48*e28cc170Scegger 	busid->ubus.pci.domain = device_unit(device_parent(self));
49*e28cc170Scegger 	pci_decompose_tag(pc, tag,
50*e28cc170Scegger 	    &busid->ubus.pci.bus, &busid->ubus.pci.device,
51*e28cc170Scegger 	    &busid->ubus.pci.function);
52*e28cc170Scegger 	return 0;
53*e28cc170Scegger }
54