pchb.c revision 1.1
11.1Ssoren/*	$NetBSD: pchb.c,v 1.1 2000/03/19 23:07:48 soren Exp $	*/
21.1Ssoren
31.1Ssoren/*
41.1Ssoren * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
51.1Ssoren *
61.1Ssoren * Redistribution and use in source and binary forms, with or without
71.1Ssoren * modification, are permitted provided that the following conditions
81.1Ssoren * are met:
91.1Ssoren * 1. Redistributions of source code must retain the above copyright
101.1Ssoren *    notice, this list of conditions, and the following disclaimer.
111.1Ssoren * 2. Redistributions in binary form must reproduce the above copyright
121.1Ssoren *    notice, this list of conditions and the following disclaimer in the
131.1Ssoren *    documentation and/or other materials provided with the distribution.
141.1Ssoren *
151.1Ssoren * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
161.1Ssoren * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
171.1Ssoren * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
181.1Ssoren * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
191.1Ssoren * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
201.1Ssoren * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
211.1Ssoren * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
221.1Ssoren * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
231.1Ssoren * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
241.1Ssoren * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
251.1Ssoren * SUCH DAMAGE.
261.1Ssoren */
271.1Ssoren
281.1Ssoren#include <sys/types.h>
291.1Ssoren#include <sys/param.h>
301.1Ssoren#include <sys/systm.h>
311.1Ssoren#include <sys/device.h>
321.1Ssoren
331.1Ssoren#include <machine/bus.h>
341.1Ssoren
351.1Ssoren#include <dev/pci/pcivar.h>
361.1Ssoren#include <dev/pci/pcireg.h>
371.1Ssoren
381.1Ssoren#include <dev/pci/pcidevs.h>
391.1Ssoren
401.1Ssorenstatic int	pchb_match(struct device *, struct cfdata *, void *);
411.1Ssorenstatic void	pchb_attach(struct device *, struct device *, void *);
421.1Ssoren
431.1Ssorenstruct cfattach pchb_ca = {
441.1Ssoren	sizeof(struct device), pchb_match, pchb_attach
451.1Ssoren};
461.1Ssoren
471.1Ssorenstatic int
481.1Ssorenpchb_match(parent, match, aux)
491.1Ssoren	struct device *parent;
501.1Ssoren	struct cfdata *match;
511.1Ssoren	void *aux;
521.1Ssoren{
531.1Ssoren	struct pci_attach_args *pa = aux;
541.1Ssoren
551.1Ssoren	if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_GALILEO) &&
561.1Ssoren	    (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_GALILEO_GT64011))
571.1Ssoren		return 1;
581.1Ssoren
591.1Ssoren	return 0;
601.1Ssoren}
611.1Ssoren
621.1Ssorenstatic void
631.1Ssorenpchb_attach(parent, self, aux)
641.1Ssoren	struct device *parent, *self;
651.1Ssoren	void *aux;
661.1Ssoren{
671.1Ssoren	struct pci_attach_args *pa = aux;
681.1Ssoren	char devinfo[256];
691.1Ssoren	pcireg_t bhlc;
701.1Ssoren
711.1Ssoren	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
721.1Ssoren	printf("\n%s: %s, rev %d\n", self->dv_xname, devinfo,
731.1Ssoren					PCI_REVISION(pa->pa_class));
741.1Ssoren
751.1Ssoren	/*
761.1Ssoren	 * XXX Still isn't quite right or enough.
771.1Ssoren	 */
781.1Ssoren
791.1Ssoren	bhlc = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
801.1Ssoren
811.1Ssoren	bhlc &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
821.1Ssoren	bhlc |= (0x40 << PCI_LATTIMER_SHIFT);
831.1Ssoren
841.1Ssoren	bhlc &= ~(PCI_CACHELINE_MASK << PCI_CACHELINE_SHIFT);
851.1Ssoren	bhlc |= (7 << PCI_CACHELINE_SHIFT);
861.1Ssoren
871.1Ssoren	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG, bhlc);
881.1Ssoren}
89