xref: /freebsd/sys/dev/ppc/ppc_puc.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
1a3732274SDoug Ambrisko /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
464220a7eSMarcel Moolenaar  * Copyright (c) 2006 Marcel Moolenaar
5a3732274SDoug Ambrisko  * Copyright (c) 1997-2000 Nicolas Souchu
6a3732274SDoug Ambrisko  * Copyright (c) 2001 Alcove - Nicolas Souchu
7a3732274SDoug Ambrisko  * All rights reserved.
8a3732274SDoug Ambrisko  *
9a3732274SDoug Ambrisko  * Redistribution and use in source and binary forms, with or without
10a3732274SDoug Ambrisko  * modification, are permitted provided that the following conditions
11a3732274SDoug Ambrisko  * are met:
12a3732274SDoug Ambrisko  * 1. Redistributions of source code must retain the above copyright
13a3732274SDoug Ambrisko  *    notice, this list of conditions and the following disclaimer.
14a3732274SDoug Ambrisko  * 2. Redistributions in binary form must reproduce the above copyright
15a3732274SDoug Ambrisko  *    notice, this list of conditions and the following disclaimer in the
16a3732274SDoug Ambrisko  *    documentation and/or other materials provided with the distribution.
17a3732274SDoug Ambrisko  *
18a3732274SDoug Ambrisko  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19a3732274SDoug Ambrisko  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20a3732274SDoug Ambrisko  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21a3732274SDoug Ambrisko  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22a3732274SDoug Ambrisko  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23a3732274SDoug Ambrisko  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24a3732274SDoug Ambrisko  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25a3732274SDoug Ambrisko  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26a3732274SDoug Ambrisko  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27a3732274SDoug Ambrisko  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28a3732274SDoug Ambrisko  * SUCH DAMAGE.
29a3732274SDoug Ambrisko  */
30a3732274SDoug Ambrisko 
31a3732274SDoug Ambrisko #include <sys/param.h>
32a3732274SDoug Ambrisko #include <sys/kernel.h>
33fe12f24bSPoul-Henning Kamp #include <sys/module.h>
34a3732274SDoug Ambrisko #include <sys/bus.h>
35a3732274SDoug Ambrisko 
36a3732274SDoug Ambrisko #include <machine/bus.h>
37a3732274SDoug Ambrisko 
3864220a7eSMarcel Moolenaar #include <dev/puc/puc_bus.h>
3964220a7eSMarcel Moolenaar 
40a3732274SDoug Ambrisko #include <dev/ppbus/ppbconf.h>
41a3732274SDoug Ambrisko #include <dev/ppbus/ppb_msq.h>
42a3732274SDoug Ambrisko #include <dev/ppc/ppcvar.h>
43a3732274SDoug Ambrisko #include <dev/ppc/ppcreg.h>
44a3732274SDoug Ambrisko 
45a3732274SDoug Ambrisko #include "ppbus_if.h"
46a3732274SDoug Ambrisko 
47a3732274SDoug Ambrisko static int ppc_puc_probe(device_t dev);
48a3732274SDoug Ambrisko 
49a3732274SDoug Ambrisko static device_method_t ppc_puc_methods[] = {
50a3732274SDoug Ambrisko 	/* device interface */
51a3732274SDoug Ambrisko 	DEVMETHOD(device_probe,		ppc_puc_probe),
52a3732274SDoug Ambrisko 	DEVMETHOD(device_attach,	ppc_attach),
5364220a7eSMarcel Moolenaar 	DEVMETHOD(device_detach,	ppc_detach),
54a3732274SDoug Ambrisko 
55a3732274SDoug Ambrisko 	/* bus interface */
56a3732274SDoug Ambrisko 	DEVMETHOD(bus_read_ivar,	ppc_read_ivar),
572067d312SJohn Baldwin 	DEVMETHOD(bus_write_ivar,	ppc_write_ivar),
58ca3d3795SJohn Baldwin 	DEVMETHOD(bus_alloc_resource,	ppc_alloc_resource),
59ca3d3795SJohn Baldwin 	DEVMETHOD(bus_release_resource,	ppc_release_resource),
60a3732274SDoug Ambrisko 
61a3732274SDoug Ambrisko 	/* ppbus interface */
62a3732274SDoug Ambrisko 	DEVMETHOD(ppbus_io,		ppc_io),
63a3732274SDoug Ambrisko 	DEVMETHOD(ppbus_exec_microseq,	ppc_exec_microseq),
64a3732274SDoug Ambrisko 	DEVMETHOD(ppbus_reset_epp,	ppc_reset_epp),
65a3732274SDoug Ambrisko 	DEVMETHOD(ppbus_setmode,	ppc_setmode),
66a3732274SDoug Ambrisko 	DEVMETHOD(ppbus_ecp_sync,	ppc_ecp_sync),
67a3732274SDoug Ambrisko 	DEVMETHOD(ppbus_read,		ppc_read),
68a3732274SDoug Ambrisko 	DEVMETHOD(ppbus_write,		ppc_write),
69a3732274SDoug Ambrisko 	{ 0, 0 }
70a3732274SDoug Ambrisko };
71a3732274SDoug Ambrisko 
72a3732274SDoug Ambrisko static driver_t ppc_puc_driver = {
73cea4d875SMarcel Moolenaar 	ppc_driver_name,
74a3732274SDoug Ambrisko 	ppc_puc_methods,
75a3732274SDoug Ambrisko 	sizeof(struct ppc_data),
76a3732274SDoug Ambrisko };
77a3732274SDoug Ambrisko 
78a3732274SDoug Ambrisko static int
ppc_puc_probe(device_t dev)79df5fea7cSMarcel Moolenaar ppc_puc_probe(device_t dev)
80a3732274SDoug Ambrisko {
8164220a7eSMarcel Moolenaar 	device_t parent;
8264220a7eSMarcel Moolenaar 	uintptr_t type;
8364220a7eSMarcel Moolenaar 
8464220a7eSMarcel Moolenaar 	parent = device_get_parent(dev);
8564220a7eSMarcel Moolenaar 	if (BUS_READ_IVAR(parent, dev, PUC_IVAR_TYPE, &type))
8664220a7eSMarcel Moolenaar 		return (ENXIO);
8764220a7eSMarcel Moolenaar 	if (type != PUC_TYPE_PARALLEL)
8864220a7eSMarcel Moolenaar 		return (ENXIO);
8964220a7eSMarcel Moolenaar 
90a3732274SDoug Ambrisko 	device_set_desc(dev, "Parallel port");
91cea4d875SMarcel Moolenaar 	return (ppc_probe(dev, 0));
92a3732274SDoug Ambrisko }
93a3732274SDoug Ambrisko 
946d588090SJohn Baldwin DRIVER_MODULE(ppc, puc, ppc_puc_driver, 0, 0);
95