/*-
* Copyright (c) 2003 Tsubai Masanari. All rights reserved.
*
* 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.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE) {
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_APPLE_KAUAI:
case PCI_PRODUCT_APPLE_UNINORTH_ATA:
case PCI_PRODUCT_APPLE_INTREPID2_ATA:
case PCI_PRODUCT_APPLE_SHASTA_ATA:
case PCI_PRODUCT_APPLE_K2_UATA:
return 5;
}
}
/*
* XXX PCI_INTERRUPT_REG seems to be wired to 0.
* XXX So use fixed intrpin and intrline values if the interrupts
* XXX property contains no IRQ line
*/
intr = 0;
pa->pa_intrpin = 1;
if (OF_getprop(node, "interrupts", intrs, sizeof(intrs)) >= 4) {
intr = intrs[0];
/*
* the interrupts property on my iBook G4's kauai contains
* 0x00000001 0x00000000, so fix that up here
* TODO: use parent's interrupt-map property to do this right
*/
if (intr < 10)
intr = 0;
aprint_debug_dev(self,
"got %d from interrupts property\n", intr);
}
if (intr == 0) {
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_SHASTA_ATA) {
intr = 38;
} else
intr = 39;
}
pa->pa_intrline = intr;
if (pci_intr_map(pa, &ih)) {
aprint_error(": unable to map interrupt\n");
return;
}
aprint_normal(": interrupting at %s\n", pci_intr_string(pa->pa_pc, ih,
buf, sizeof(buf)));
sc->sc_wdcdev.regs = wdr = &sc->sc_wdc_regs;
wdr->cmd_iot = wdr->ctl_iot = pa->pa_memt;
if (bus_space_map(wdr->cmd_iot, regbase, WDC_REG_NPORTS << 4, 0,
&wdr->cmd_baseioh) ||
bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_AUXREG_OFFSET << 4, 1, &wdr->ctl_ioh)) {
aprint_error_dev(self, "couldn't map registers\n");
return;
}
for (i = 0; i < WDC_NREG; i++) {
if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh, i << 4,
i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0) {
bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_REG_NPORTS << 4);
aprint_error_dev(self,
"couldn't subregion registers\n");
return;
}
}
if (pci_intr_establish_xname(pa->pa_pc, ih, IPL_BIO, wdcintr, chp,
device_xname(self)) == NULL) {
aprint_error_dev(self, "unable to establish interrupt\n");
return;
}