/*
* Copyright (c) 2002 Takeshi Shibagaki All rights reserved.
*
* mac68k OBIO-IDE attachment created by Takeshi Shibagaki
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Charles M. Hannum.
* 4. 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.
*/
int
wdc_obio_match(device_t parent, cfdata_t match, void *aux)
{
struct obio_attach_args *oa = (struct obio_attach_args *) aux;
struct wdc_regs *wdr;
int i, result = 0;
wdr = kmem_alloc(sizeof(*wdr), KM_SLEEP);
switch (current_mac_model->machineid) {
case MACH_MACPB150:
case MACH_MACPB190:
case MACH_MACPB190CS:
case MACH_MACP580:
case MACH_MACQ630:
wdr->cmd_iot = wdr->ctl_iot = oa->oa_tag;
if (bus_space_map(wdr->cmd_iot, IDEBase, WDC_OBIO_REG_NPORTS,
0, &wdr->cmd_baseioh))
goto out;
for (i = 0; i < WDC_NREG; i++) {
if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
i * 4, 4, &wdr->cmd_iohs[i]) != 0)
goto unmap;
}
wdc_init_shadow_regs(wdr);
if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_NPORTS,
&wdr->ctl_ioh))
goto unmap;
for (i = 0; i < WDC_NREG; i++) {
if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
i * 4, 4, &wdr->cmd_iohs[i]) != 0) {
aprint_error(
": unable to subregion control register\n");
goto err;
}
}
if (bus_space_subregion(wdr->cmd_iot, wdr->cmd_baseioh,
WDC_OBIO_AUXREG_OFFSET, WDC_OBIO_AUXREG_NPORTS, &wdr->ctl_ioh)) {
aprint_error(": unable to subregion aux register\n");
goto err;
}
wdc_obio_isr_tag = oa->oa_tag;
if (bus_space_map(wdc_obio_isr_tag, oa->oa_addr + WDC_OBIO_ISR_OFFSET,
WDC_OBIO_ISR_NPORTS, 0, &wdc_obio_isr_hdl)) {
aprint_error(": couldn't map intr status register\n");
goto err;
}
switch (current_mac_model->machineid) {
case MACH_MACP580:
case MACH_MACQ630:
/*
* Quadra/Performa IDE generates pseudo Nubus intr at slot F
*/
aprint_normal(" (Quadra/Performa series IDE interface)");
add_nubus_intr(0xf, wdc_obio_intr, sc);
break;
case MACH_MACPB150:
case MACH_MACPB190:
case MACH_MACPB190CS:
/*
* PowerBook IDE generates pseudo NuBus intr at slot C
*/
aprint_normal(" (PowerBook series IDE interface)");