11.15Scegger/* $NetBSD: p64h2apic.c,v 1.15 2009/05/04 12:15:51 cegger Exp $ */
21.4Sthorpej
31.4Sthorpej/*-
41.4Sthorpej * Copyright (c) 2002 The NetBSD Foundation, Inc.
51.4Sthorpej * All rights reserved.
61.4Sthorpej *
71.4Sthorpej * This code is derived from software contributed to The NetBSD Foundation
81.4Sthorpej * by Bill Sommerfeld.
91.4Sthorpej *
101.4Sthorpej * Redistribution and use in source and binary forms, with or without
111.4Sthorpej * modification, are permitted provided that the following conditions
121.4Sthorpej * are met:
131.4Sthorpej * 1. Redistributions of source code must retain the above copyright
141.4Sthorpej *    notice, this list of conditions and the following disclaimer.
151.4Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
161.4Sthorpej *    notice, this list of conditions and the following disclaimer in the
171.4Sthorpej *    documentation and/or other materials provided with the distribution.
181.4Sthorpej *
191.4Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.4Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.4Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.4Sthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.4Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.4Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.4Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.4Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.4Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.4Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.4Sthorpej * POSSIBILITY OF SUCH DAMAGE.
301.4Sthorpej */
311.4Sthorpej
321.2Sfvdl/*
331.2Sfvdl * Driver for P64H2 IOxAPIC
341.2Sfvdl *
351.2Sfvdl * This is an ioapic which appears in PCI space.
361.2Sfvdl * This driver currently does nothing useful but will eventually
371.2Sfvdl * thwak the ioapic into working correctly.
381.2Sfvdl */
391.5Slukem
401.5Slukem#include <sys/cdefs.h>
411.15Scegger__KERNEL_RCSID(0, "$NetBSD: p64h2apic.c,v 1.15 2009/05/04 12:15:51 cegger Exp $");
421.2Sfvdl
431.2Sfvdl#include <sys/param.h>
441.2Sfvdl#include <sys/systm.h>
451.2Sfvdl#include <sys/kernel.h>
461.2Sfvdl#include <sys/device.h>
471.2Sfvdl
481.2Sfvdl#include <dev/pci/pcireg.h>
491.2Sfvdl#include <dev/pci/pcivar.h>
501.2Sfvdl#include <dev/pci/pcidevs.h>
511.2Sfvdl
521.15Sceggerstatic int	p64h2match(device_t, cfdata_t, void *);
531.15Sceggerstatic void	p64h2attach(device_t, device_t, void *);
541.2Sfvdl
551.4Sthorpejstruct p64h2apic_softc {
561.2Sfvdl	pcitag_t sc_tag;
571.2Sfvdl};
581.2Sfvdl
591.14SjoergCFATTACH_DECL_NEW(p64h2apic, sizeof(struct p64h2apic_softc),
601.3Sthorpej    p64h2match, p64h2attach, NULL, NULL);
611.2Sfvdl
621.2Sfvdlstatic int
631.14Sjoergp64h2match(device_t parent, cfdata_t match, void *aux)
641.2Sfvdl{
651.2Sfvdl	struct pci_attach_args *pa = aux;
661.2Sfvdl
671.2Sfvdl	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL &&
681.2Sfvdl	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82870P2_IOxAPIC)
691.2Sfvdl		return (1);
701.2Sfvdl
711.2Sfvdl	return (0);
721.2Sfvdl}
731.2Sfvdl
741.2Sfvdlstatic void
751.14Sjoergp64h2attach(device_t parent, device_t self, void *aux)
761.2Sfvdl{
771.14Sjoerg	struct p64h2apic_softc *sc = device_private(self);
781.2Sfvdl	struct pci_attach_args *pa = aux;
791.2Sfvdl	char devinfo[256];
801.2Sfvdl
811.9Sthorpej	aprint_naive("\n");
821.9Sthorpej	aprint_normal("\n");
831.9Sthorpej
841.6Sitojun	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
851.14Sjoerg	aprint_normal_dev(self, "%s (rev. 0x%02x)\n", devinfo,
861.9Sthorpej	    PCI_REVISION(pa->pa_class));
871.2Sfvdl
881.2Sfvdl	sc->sc_tag = pa->pa_tag;
891.2Sfvdl}
90