/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* XXX
* UniNorth Firewire controller commonly found in Pismo G3 PowerBooks,
* G4 Titanium PowerBooks and some iMac G3s, hang the system
* when trying to discover devices - don't attach to those for now
* until someone with the right hardware can investigate.
* These controllers are based on the Ti TSB41AB1 chipset.
*/
if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE) &&
(PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_UNINORTH_FW))
return 0;
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_SERIALBUS &&
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_SERIALBUS_FIREWIRE &&
PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_OHCI)
return 1;
/*
* Some Sun FireWire controllers have their intpin register
* bogusly set to 0, although it should be 3. Correct that.
*/
if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN) &&
(PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_FIREWIRE))
if (pa->pa_intrpin == 0)
pa->pa_intrpin = 3;
/* Map and establish the interrupt. */
if (pci_intr_map(pa, &ih)) {
aprint_error_dev(self, "couldn't map interrupt\n");
goto fail;
}
intrstr = pci_intr_string(pa->pa_pc, ih, intrbuf, sizeof(intrbuf));
psc->psc_ih = pci_intr_establish_xname(pa->pa_pc, ih, IPL_BIO,
fwohci_intr, &psc->psc_sc, device_xname(self));
if (psc->psc_ih == NULL) {
aprint_error_dev(self, "couldn't establish interrupt");
if (intrstr != NULL)
aprint_error(" at %s", intrstr);
aprint_error("\n");
goto fail;
}
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
if (fwohci_attach(&psc->psc_sc) != 0)
goto fail;
if (!pmf_device_register(self, fwohci_pci_suspend, fwohci_pci_resume))
aprint_error_dev(self, "couldn't establish power handler\n");
return;
fail:
/* In the event that we fail to attach, register a null pnp handler */
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
return;
}
static int
fwohci_pci_detach(device_t self, int flags)
{
struct fwohci_pci_softc *psc = device_private(self);
int rv;
pmf_device_deregister(self);
rv = fwohci_detach(&psc->psc_sc, flags);
if (rv)
return rv;