ppc_pci.c revision 183053
1158005Smarcel/*-
2158005Smarcel * Copyright (c) 2006 Marcel Moolenaar
3158005Smarcel * All rights reserved.
4158005Smarcel *
5158005Smarcel * Redistribution and use in source and binary forms, with or without
6158005Smarcel * modification, are permitted provided that the following conditions
7158005Smarcel * are met:
8158005Smarcel * 1. Redistributions of source code must retain the above copyright
9158005Smarcel *    notice, this list of conditions and the following disclaimer.
10158005Smarcel * 2. Redistributions in binary form must reproduce the above copyright
11158005Smarcel *    notice, this list of conditions and the following disclaimer in the
12158005Smarcel *    documentation and/or other materials provided with the distribution.
13158005Smarcel *
14158005Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15158005Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16158005Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17158005Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18158005Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19158005Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20158005Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21158005Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22158005Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23158005Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24158005Smarcel * SUCH DAMAGE.
25158005Smarcel */
26158005Smarcel
27158005Smarcel#include <sys/cdefs.h>
28158005Smarcel__FBSDID("$FreeBSD: head/sys/dev/ppc/ppc_pci.c 183053 2008-09-15 22:26:32Z jhb $");
29158005Smarcel
30158005Smarcel#include <sys/param.h>
31158005Smarcel#include <sys/kernel.h>
32158005Smarcel#include <sys/module.h>
33158005Smarcel#include <sys/bus.h>
34158005Smarcel
35158005Smarcel#include <machine/bus.h>
36158005Smarcel
37158005Smarcel#include <dev/pci/pcivar.h>
38158005Smarcel
39158005Smarcel#include <dev/ppbus/ppbconf.h>
40158005Smarcel#include <dev/ppbus/ppb_msq.h>
41158005Smarcel#include <dev/ppc/ppcvar.h>
42158005Smarcel#include <dev/ppc/ppcreg.h>
43158005Smarcel
44158005Smarcel#include "ppbus_if.h"
45158005Smarcel
46158005Smarcelstatic int ppc_pci_probe(device_t dev);
47158005Smarcel
48158005Smarcelstatic device_method_t ppc_pci_methods[] = {
49158005Smarcel	/* device interface */
50158005Smarcel	DEVMETHOD(device_probe,		ppc_pci_probe),
51158005Smarcel	DEVMETHOD(device_attach,	ppc_attach),
52158005Smarcel	DEVMETHOD(device_detach,	ppc_detach),
53158005Smarcel
54158005Smarcel	/* bus interface */
55158005Smarcel	DEVMETHOD(bus_read_ivar,	ppc_read_ivar),
56158005Smarcel	DEVMETHOD(bus_setup_intr,	ppc_setup_intr),
57158005Smarcel	DEVMETHOD(bus_teardown_intr,	ppc_teardown_intr),
58183053Sjhb	DEVMETHOD(bus_alloc_resource,	ppc_alloc_resource),
59183053Sjhb	DEVMETHOD(bus_release_resource,	ppc_release_resource),
60158005Smarcel
61158005Smarcel	/* ppbus interface */
62158005Smarcel	DEVMETHOD(ppbus_io,		ppc_io),
63158005Smarcel	DEVMETHOD(ppbus_exec_microseq,	ppc_exec_microseq),
64158005Smarcel	DEVMETHOD(ppbus_reset_epp,	ppc_reset_epp),
65158005Smarcel	DEVMETHOD(ppbus_setmode,	ppc_setmode),
66158005Smarcel	DEVMETHOD(ppbus_ecp_sync,	ppc_ecp_sync),
67158005Smarcel	DEVMETHOD(ppbus_read,		ppc_read),
68158005Smarcel	DEVMETHOD(ppbus_write,		ppc_write),
69158005Smarcel
70158005Smarcel	{ 0, 0 }
71158005Smarcel};
72158005Smarcel
73158005Smarcelstatic driver_t ppc_pci_driver = {
74158005Smarcel	ppc_driver_name,
75158005Smarcel	ppc_pci_methods,
76158005Smarcel	sizeof(struct ppc_data),
77158005Smarcel};
78158005Smarcel
79158005Smarcelstruct pci_id {
80158005Smarcel	uint32_t	type;
81158005Smarcel	const char	*desc;
82158005Smarcel	int		rid;
83158005Smarcel};
84158005Smarcel
85158005Smarcelstatic struct pci_id pci_ids[] = {
86158005Smarcel	{ 0x1020131f, "SIIG Cyber Parallel PCI (10x family)", 0x18 },
87158005Smarcel	{ 0x2020131f, "SIIG Cyber Parallel PCI (20x family)", 0x10 },
88158005Smarcel	{ 0x80001407, "Lava Computers 2SP-PCI parallel port", 0x10 },
89158005Smarcel	{ 0x84031415, "Oxford Semiconductor OX12PCI840 Parallel port", 0x10 },
90158005Smarcel	{ 0x95131415, "Oxford Semiconductor OX16PCI954 Parallel port", 0x10 },
91158005Smarcel	{ 0x98059710, "NetMos NM9805 1284 Printer port", 0x10 },
92158005Smarcel	{ 0xffff }
93158005Smarcel};
94158005Smarcel
95158005Smarcelstatic int
96158005Smarcelppc_pci_probe(device_t dev)
97158005Smarcel{
98158005Smarcel	struct pci_id *id;
99158005Smarcel	uint32_t type;
100158005Smarcel
101158005Smarcel	type = pci_get_devid(dev);
102158005Smarcel	id = pci_ids;
103158005Smarcel	while (id->type != 0xffff && id->type != type)
104158005Smarcel		id++;
105158005Smarcel	if (id->type == 0xffff)
106158005Smarcel		return (ENXIO);
107158005Smarcel	device_set_desc(dev, id->desc);
108158005Smarcel	return (ppc_probe(dev, id->rid));
109158005Smarcel}
110158005Smarcel
111158005SmarcelDRIVER_MODULE(ppc, pci, ppc_pci_driver, ppc_devclass, 0, 0);
112