xref: /freebsd/sys/dev/ppc/ppc_acpi.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
1cea4d875SMarcel Moolenaar /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
4cea4d875SMarcel Moolenaar  * Copyright (c) 2006 Marcel Moolenaar
5cea4d875SMarcel Moolenaar  * All rights reserved.
6cea4d875SMarcel Moolenaar  *
7cea4d875SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
8cea4d875SMarcel Moolenaar  * modification, are permitted provided that the following conditions
9cea4d875SMarcel Moolenaar  * are met:
10cea4d875SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
11cea4d875SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
12cea4d875SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
13cea4d875SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
14cea4d875SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
15cea4d875SMarcel Moolenaar  *
16cea4d875SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17cea4d875SMarcel Moolenaar  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18cea4d875SMarcel Moolenaar  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19cea4d875SMarcel Moolenaar  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20cea4d875SMarcel Moolenaar  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21cea4d875SMarcel Moolenaar  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22cea4d875SMarcel Moolenaar  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23cea4d875SMarcel Moolenaar  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24cea4d875SMarcel Moolenaar  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25cea4d875SMarcel Moolenaar  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26cea4d875SMarcel Moolenaar  * SUCH DAMAGE.
27cea4d875SMarcel Moolenaar  */
28cea4d875SMarcel Moolenaar 
29cea4d875SMarcel Moolenaar #include <sys/cdefs.h>
30cea4d875SMarcel Moolenaar #include "opt_isa.h"
31cea4d875SMarcel Moolenaar 
32cea4d875SMarcel Moolenaar #include <sys/param.h>
33cea4d875SMarcel Moolenaar #include <sys/kernel.h>
34cea4d875SMarcel Moolenaar #include <sys/module.h>
35cea4d875SMarcel Moolenaar #include <sys/bus.h>
36cea4d875SMarcel Moolenaar 
37cea4d875SMarcel Moolenaar #include <machine/bus.h>
38cea4d875SMarcel Moolenaar 
39cea4d875SMarcel Moolenaar #include <isa/isareg.h>
40cea4d875SMarcel Moolenaar #include <isa/isavar.h>
41cea4d875SMarcel Moolenaar 
42cea4d875SMarcel Moolenaar #include <dev/ppbus/ppbconf.h>
43cea4d875SMarcel Moolenaar #include <dev/ppbus/ppb_msq.h>
44cea4d875SMarcel Moolenaar #include <dev/ppc/ppcvar.h>
45cea4d875SMarcel Moolenaar #include <dev/ppc/ppcreg.h>
46cea4d875SMarcel Moolenaar 
47cea4d875SMarcel Moolenaar #include "ppbus_if.h"
48cea4d875SMarcel Moolenaar 
49cea4d875SMarcel Moolenaar static int ppc_acpi_probe(device_t dev);
50cea4d875SMarcel Moolenaar 
51cea4d875SMarcel Moolenaar int ppc_isa_attach(device_t dev);
52cea4d875SMarcel Moolenaar int ppc_isa_write(device_t, char *, int, int);
53cea4d875SMarcel Moolenaar 
54cea4d875SMarcel Moolenaar static device_method_t ppc_acpi_methods[] = {
55cea4d875SMarcel Moolenaar 	/* device interface */
56cea4d875SMarcel Moolenaar 	DEVMETHOD(device_probe,		ppc_acpi_probe),
57cea4d875SMarcel Moolenaar #ifdef DEV_ISA
58cea4d875SMarcel Moolenaar 	DEVMETHOD(device_attach,	ppc_isa_attach),
59cea4d875SMarcel Moolenaar #else
60cea4d875SMarcel Moolenaar 	DEVMETHOD(device_attach,	ppc_attach),
61cea4d875SMarcel Moolenaar #endif
6219ab530dSJohn Baldwin 	DEVMETHOD(device_detach,	ppc_detach),
63cea4d875SMarcel Moolenaar 
64cea4d875SMarcel Moolenaar 	/* bus interface */
65cea4d875SMarcel Moolenaar 	DEVMETHOD(bus_read_ivar,	ppc_read_ivar),
662067d312SJohn Baldwin 	DEVMETHOD(bus_write_ivar,	ppc_write_ivar),
67ca3d3795SJohn Baldwin 	DEVMETHOD(bus_alloc_resource,	ppc_alloc_resource),
68ca3d3795SJohn Baldwin 	DEVMETHOD(bus_release_resource,	ppc_release_resource),
69cea4d875SMarcel Moolenaar 
70cea4d875SMarcel Moolenaar 	/* ppbus interface */
71cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_io,		ppc_io),
72cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_exec_microseq,	ppc_exec_microseq),
73cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_reset_epp,	ppc_reset_epp),
74cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_setmode,	ppc_setmode),
75cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_ecp_sync,	ppc_ecp_sync),
76cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_read,		ppc_read),
77cea4d875SMarcel Moolenaar #ifdef DEV_ISA
78cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_write,		ppc_isa_write),
79cea4d875SMarcel Moolenaar #else
80cea4d875SMarcel Moolenaar 	DEVMETHOD(ppbus_write,		ppc_write),
81cea4d875SMarcel Moolenaar #endif
82cea4d875SMarcel Moolenaar 	{ 0, 0 }
83cea4d875SMarcel Moolenaar };
84cea4d875SMarcel Moolenaar 
85cea4d875SMarcel Moolenaar static driver_t ppc_acpi_driver = {
86cea4d875SMarcel Moolenaar 	ppc_driver_name,
87cea4d875SMarcel Moolenaar 	ppc_acpi_methods,
88cea4d875SMarcel Moolenaar 	sizeof(struct ppc_data),
89cea4d875SMarcel Moolenaar };
90cea4d875SMarcel Moolenaar 
91cea4d875SMarcel Moolenaar static struct isa_pnp_id lpc_ids[] = {
92cea4d875SMarcel Moolenaar 	{ 0x0004d041, "Standard parallel printer port" },	/* PNP0400 */
93cea4d875SMarcel Moolenaar 	{ 0x0104d041, "ECP parallel printer port" },		/* PNP0401 */
94cea4d875SMarcel Moolenaar 	{ 0 }
95cea4d875SMarcel Moolenaar };
96cea4d875SMarcel Moolenaar 
97cea4d875SMarcel Moolenaar static int
ppc_acpi_probe(device_t dev)98cea4d875SMarcel Moolenaar ppc_acpi_probe(device_t dev)
99cea4d875SMarcel Moolenaar {
100cea4d875SMarcel Moolenaar 	device_t parent;
101cea4d875SMarcel Moolenaar 	int error;
102cea4d875SMarcel Moolenaar 
103cea4d875SMarcel Moolenaar 	parent = device_get_parent(dev);
104cea4d875SMarcel Moolenaar 
105cea4d875SMarcel Moolenaar 	error = ISA_PNP_PROBE(parent, dev, lpc_ids);
106cea4d875SMarcel Moolenaar 	if (error)
107cea4d875SMarcel Moolenaar 		return (ENXIO);
108cea4d875SMarcel Moolenaar 
109cea4d875SMarcel Moolenaar 	device_set_desc(dev, "Parallel port");
110cea4d875SMarcel Moolenaar 	return (ppc_probe(dev, 0));
111cea4d875SMarcel Moolenaar }
112cea4d875SMarcel Moolenaar 
1136d588090SJohn Baldwin DRIVER_MODULE(ppc, acpi, ppc_acpi_driver, 0, 0);
114