/*
* Copyright (c) 2000 Johan Danielsson
* 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. Neither the name of author nor the names of any contributors may
* be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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.
*/
/* A driver for CardBus based serial devices.
If the CardBus device only has one BAR (that is not also the CIS
BAR) listed in the CIS, it is assumed to be the one to use. For
devices with more than one BAR, the list of known devices has to be
updated below. */
/* known devices are ok */
if(find_csdev(ca) != NULL)
return 10;
/* as are serial devices with a known UART */
if(ca->ca_cis.funcid == PCMCIA_FUNCTION_SERIAL &&
ca->ca_cis.funce.serial.uart_present != 0 &&
(ca->ca_cis.funce.serial.uart_type == 0 || /* 8250 */
ca->ca_cis.funce.serial.uart_type == 1 || /* 16450 */
ca->ca_cis.funce.serial.uart_type == 2)) /* 16550 */
return 1;
return 0;
}
static int
gofigure(struct cardbus_attach_args *ca, struct com_cardbus_softc *csc)
{
int i, index = -1;
pcireg_t cis_ptr;
struct csdev *cp;
/* If this device is listed above, use the known values, */
cp = find_csdev(ca);
if(cp != NULL) {
csc->cc_reg = cp->reg;
csc->cc_type = cp->type;
return 0;
}
/* otherwise try to deduce which BAR and type to use from CIS. If
there is only one BAR, it must be the one we should use, if
there are more, we're out of luck. */
for(i = 0; i < 7; i++) {
/* ignore zero sized BARs */
if(ca->ca_cis.bar[i].size == 0)
continue;
/* ignore the CIS BAR */
if(CARDBUS_CIS_ASI_BAR(cis_ptr) ==
CARDBUS_CIS_ASI_BAR(ca->ca_cis.bar[i].flags))
continue;
if(index != -1)
goto multi_bar;
index = i;
}
if(index == -1) {
aprint_error(": couldn't find any base address tuple\n");
return 1;
}
csc->cc_reg = CARDBUS_CIS_ASI_BAR(ca->ca_cis.bar[index].flags);
if ((ca->ca_cis.bar[index].flags & 0x10) == 0)
csc->cc_type = PCI_MAPREG_TYPE_MEM;
else
csc->cc_type = PCI_MAPREG_TYPE_IO;
return 0;
multi_bar:
aprint_error(": there are more than one possible base\n");
aprint_error_dev(DEVICET(csc), "address for this device, "
"please report the following information\n");
aprint_error_dev(DEVICET(csc), "vendor 0x%x product 0x%x\n",
PCI_VENDOR(ca->ca_id), PCI_PRODUCT(ca->ca_id));
for(i = 0; i < 7; i++) {
/* ignore zero sized BARs */
if(ca->ca_cis.bar[i].size == 0)
continue;
/* ignore the CIS BAR */
if(CARDBUS_CIS_ASI_BAR(cis_ptr) ==
CARDBUS_CIS_ASI_BAR(ca->ca_cis.bar[i].flags))
continue;
aprint_error_dev(DEVICET(csc),
"base address %x type %s size %x\n",
CARDBUS_CIS_ASI_BAR(ca->ca_cis.bar[i].flags),
(ca->ca_cis.bar[i].flags & 0x10) ? "i/o" : "mem",
ca->ca_cis.bar[i].size);
}
return 1;
}