/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Gregory McGarry.
*
* 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.
*/
static int cs80bus_alloc(struct cs80bus_softc *, int, int);
static int cs80bussearch(device_t, cfdata_t,
const int *, void *);
static int cs80busprint(void *, const char *);
/*
* HP's CS80/SS80 command set can be found on `newer' devices, while
* the HP's Amigo command set is used on before-you-were-born
* devices. Devices that respond to CS80/SS80 (and probably Amigo, too)
* are tagged with a 16-bit ID.
*
* CS80/SS80 has a 2-level addressing scheme; slave, the analog
* of a SCSI ID, and punit, the analog of a SCSI LUN. Unforunately,
* IDs are on a per-slave basis; punits are often used for disk
* drives that have an accompanying tape drive on the second punit.
*
* We treat CS80/SS80 as an indirect bus. However, since we are given
* some ID information, it is unreasonable to disallow cloning of
* CS80/SS80 devices.
*
* To deal with all of this, we use the semi-twisted scheme
* in cs80bus_attach_children(). For each GPIB slave, we loop
* through all of the possibly-configured children, allowing
* them to modify the punit parameter (but NOT the slave!).
*
*/
int
cs80busmatch(device_t parent, cfdata_t match, void *aux)
{
/*
* The device probe has succeeded, and filled in
* the punit information. Make sure the configuration
* allows for this slave/punit combination.
*/
if (cf->cs80buscf_slave != CS80BUSCF_SLAVE_DEFAULT &&
cf->cs80buscf_slave != ca->ca_slave)
goto out;
if (cf->cs80buscf_punit != CS80BUSCF_PUNIT_DEFAULT &&
cf->cs80buscf_punit != ca->ca_punit)
goto out;
/*
* Allocate the device's address from the bus's
* resource map.
*/
if (cs80bus_alloc(sc, ca->ca_slave, ca->ca_punit))
goto out;
/*
* This device is allowed; attach it.
*/
config_attach(parent, cf, ca, cs80busprint, CFARGS_NONE);
}
out:
return (0);
}