1118292Sambrisko/*- 2158124Smarcel * Copyright (c) 2006 Marcel Moolenaar 3118292Sambrisko * Copyright (c) 1997-2000 Nicolas Souchu 4118292Sambrisko * Copyright (c) 2001 Alcove - Nicolas Souchu 5118292Sambrisko * All rights reserved. 6118292Sambrisko * 7118292Sambrisko * Redistribution and use in source and binary forms, with or without 8118292Sambrisko * modification, are permitted provided that the following conditions 9118292Sambrisko * are met: 10118292Sambrisko * 1. Redistributions of source code must retain the above copyright 11118292Sambrisko * notice, this list of conditions and the following disclaimer. 12118292Sambrisko * 2. Redistributions in binary form must reproduce the above copyright 13118292Sambrisko * notice, this list of conditions and the following disclaimer in the 14118292Sambrisko * documentation and/or other materials provided with the distribution. 15118292Sambrisko * 16118292Sambrisko * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17118292Sambrisko * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18118292Sambrisko * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19118292Sambrisko * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20118292Sambrisko * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21118292Sambrisko * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22118292Sambrisko * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23118292Sambrisko * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24118292Sambrisko * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25118292Sambrisko * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26118292Sambrisko * SUCH DAMAGE. 27118292Sambrisko */ 28118292Sambrisko 29158057Smarcel#include <sys/cdefs.h> 30158057Smarcel__FBSDID("$FreeBSD: releng/10.3/sys/dev/ppc/ppc_puc.c 187576 2009-01-21 23:10:06Z jhb $"); 31158057Smarcel 32118292Sambrisko#include <sys/param.h> 33118292Sambrisko#include <sys/kernel.h> 34129879Sphk#include <sys/module.h> 35118292Sambrisko#include <sys/bus.h> 36158057Smarcel 37118292Sambrisko#include <machine/bus.h> 38118292Sambrisko 39158124Smarcel#include <dev/puc/puc_bus.h> 40158124Smarcel 41118292Sambrisko#include <dev/ppbus/ppbconf.h> 42118292Sambrisko#include <dev/ppbus/ppb_msq.h> 43118292Sambrisko#include <dev/ppc/ppcvar.h> 44118292Sambrisko#include <dev/ppc/ppcreg.h> 45118292Sambrisko 46118292Sambrisko#include "ppbus_if.h" 47118292Sambrisko 48118292Sambriskostatic int ppc_puc_probe(device_t dev); 49118292Sambrisko 50118292Sambriskostatic device_method_t ppc_puc_methods[] = { 51118292Sambrisko /* device interface */ 52158057Smarcel DEVMETHOD(device_probe, ppc_puc_probe), 53158057Smarcel DEVMETHOD(device_attach, ppc_attach), 54158124Smarcel DEVMETHOD(device_detach, ppc_detach), 55118292Sambrisko 56118292Sambrisko /* bus interface */ 57118292Sambrisko DEVMETHOD(bus_read_ivar, ppc_read_ivar), 58187576Sjhb DEVMETHOD(bus_write_ivar, ppc_write_ivar), 59183053Sjhb DEVMETHOD(bus_alloc_resource, ppc_alloc_resource), 60183053Sjhb DEVMETHOD(bus_release_resource, ppc_release_resource), 61118292Sambrisko 62118292Sambrisko /* ppbus interface */ 63118292Sambrisko DEVMETHOD(ppbus_io, ppc_io), 64118292Sambrisko DEVMETHOD(ppbus_exec_microseq, ppc_exec_microseq), 65118292Sambrisko DEVMETHOD(ppbus_reset_epp, ppc_reset_epp), 66118292Sambrisko DEVMETHOD(ppbus_setmode, ppc_setmode), 67118292Sambrisko DEVMETHOD(ppbus_ecp_sync, ppc_ecp_sync), 68118292Sambrisko DEVMETHOD(ppbus_read, ppc_read), 69118292Sambrisko DEVMETHOD(ppbus_write, ppc_write), 70118292Sambrisko 71158057Smarcel { 0, 0 } 72158057Smarcel}; 73158057Smarcel 74118292Sambriskostatic driver_t ppc_puc_driver = { 75158005Smarcel ppc_driver_name, 76118292Sambrisko ppc_puc_methods, 77118292Sambrisko sizeof(struct ppc_data), 78118292Sambrisko}; 79118292Sambrisko 80118292Sambriskostatic int 81158057Smarcelppc_puc_probe(device_t dev) 82118292Sambrisko{ 83158124Smarcel device_t parent; 84158124Smarcel uintptr_t type; 85158124Smarcel 86158124Smarcel parent = device_get_parent(dev); 87158124Smarcel if (BUS_READ_IVAR(parent, dev, PUC_IVAR_TYPE, &type)) 88158124Smarcel return (ENXIO); 89158124Smarcel if (type != PUC_TYPE_PARALLEL) 90158124Smarcel return (ENXIO); 91158124Smarcel 92118292Sambrisko device_set_desc(dev, "Parallel port"); 93158005Smarcel return (ppc_probe(dev, 0)); 94118292Sambrisko} 95118292Sambrisko 96118292SambriskoDRIVER_MODULE(ppc, puc, ppc_puc_driver, ppc_devclass, 0, 0); 97