/* $NetBSD: cardbusvar.h,v 1.56 2012/02/18 00:36:57 matt Exp $ */
/*
* Copyright (c) 1998, 1999 and 2000
* HAYAKAWA Koichi. 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.
*
* 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.
*/
/*
* struct cbslot_attach_args is the attach argument for Cardbus cardslot.
*/
struct cbslot_attach_args {
bus_space_tag_t cba_iot; /* cardbus i/o space tag */
bus_space_tag_t cba_memt; /* cardbus mem space tag */
bus_dma_tag_t cba_dmat; /* DMA tag */
rbus_tag_t cba_rbus_iot; /* CardBus i/o rbus tag */
rbus_tag_t cba_rbus_memt; /* CardBus mem rbus tag */
int cba_cacheline; /* cache line size */
int cba_max_lattimer; /* No card's latency timer may
* exceed this. On a PCI-Cardbus
* bridge, I let the latency timer on
* the primary bus (PCI bus) set
* the maximum. That is kind of an
* arbitrary choice. A more sensible
* choice may be either the
* latency timer on the primary bus,
* or the bridge's buffer size,
* whichever is larger.
*/
};
struct cardbus_devfunc;
/*
* struct cardbus_softc is the softc for cardbus card.
*/
struct cardbus_softc {
device_t sc_dev; /* fundamental device structure */
int sc_bus; /* cardbus bus number */
bus_space_tag_t sc_iot; /* CardBus I/O space tag */
bus_space_tag_t sc_memt; /* CardBus MEM space tag */
bus_dma_tag_t sc_dmat; /* DMA tag */
rbus_tag_t sc_rbus_iot; /* CardBus i/o rbus tag */
rbus_tag_t sc_rbus_memt; /* CardBus mem rbus tag */
int sc_cacheline; /* cache line size */
int sc_max_lattimer; /* No card's latency timer
* may exceed this. On a PCI-Cardbus
* bridge, the latency timer on
* the primary bus (PCI bus) sets
* the maximum.
*/
int sc_poweron_func;
struct cardbus_devfunc *sc_funcs[8]; /* list of cardbus device functions */
};
struct cardbus_conf_state {
pcireg_t reg[16];
};
/*
* struct cardbus_devfunc:
*
* This is the data deposit for each function of a CardBus device.
* This structure is used for memory or i/o space allocation and
* disallocation.
*/
typedef struct cardbus_devfunc {
cardbus_chipset_tag_t ct_cc;
cardbus_function_tag_t ct_cf;
struct cardbus_softc *ct_sc; /* pointer to the parent */
int ct_bus; /* bus number */
int ct_func; /* function number */
pcireg_t ct_bhlc; /* Latency timer and cache line size */
/* u_int32_t ct_cisreg; */ /* CIS reg: is it needed??? */
device_t ct_device; /* pointer to the device */
/* some data structure needed for tuple??? */
} *cardbus_devfunc_t;
/* XXX various things extracted from CIS */
struct cardbus_cis_info {
int32_t manufacturer;
int32_t product;
char cis1_info_buf[256];
char* cis1_info[4];
struct cb_bar_info {
unsigned int flags;
unsigned int size;
} bar[7];
unsigned int funcid;
union {
struct {
int uart_type;
int uart_present;
} serial;
struct {
char netid[6];
char netid_present;
char __filler;
} network;
} funce;
};
int cardbus_function_enable(struct cardbus_softc *, int);
int cardbus_function_disable(struct cardbus_softc *, int);
int cardbus_get_capability(cardbus_chipset_tag_t, cardbus_function_tag_t,
pcitag_t, int, int *, pcireg_t *);
int cardbus_get_powerstate(cardbus_devfunc_t, pcitag_t, pcireg_t *);
int cardbus_set_powerstate(cardbus_devfunc_t, pcitag_t, pcireg_t);