Cardbus, cardbus_attach_card, cardbus_detach_card,
cardbus_function_enable, cardbus_function_disable, cardbus_mapreg_map,
cardbus_mapreg_unmap, cardbus_get_capability, cardbus_make_tag,
cardbus_free_tag, cardbus_conf_read, cardbus_conf_write,
cardbus_intr_establish, cardbus_intr_disestablish, CARDBUS_VENDOR,
CARDBUS_PRODUCT, Cardbus_function_enable, Cardbus_function_disable,
Cardbus_mapreg_map, Cardbus_mapreg_unmap, Cardbus_make_tag,
Cardbus_free_tag, Cardbus_conf_read, Cardbus_conf_write - support for
Cardbus PC-Card devices
#include <machine/bus.h>
#include <dev/cardbus/cardbusvar.h>
#include <dev/cardbus/cardbusdevs.h>
int
cardbus_attach_card(struct cardbus_softc *csc);
void
cardbus_detach_card(struct cardbus_softc *csc);
int
cardbus_function_enable(struct cardbus_softc *csc, int function);
int
cardbus_function_disable(struct cardbus_softc *csc, int function);
int
cardbus_mapreg_map(struct cardbus_softc *csc, int cf, int reg,
cardbusreg_t type, int busflags, bus_space_tag_t *tagp,
bus_space_handle_t *handlep, bus_addr_t *basep,
bus_size_t *sizep);
int
cardbus_mapreg_unmap(struct cardbus_softc *csc, int cf, int reg,
bus_space_tag_t tag, bus_space_handle_t handle, bus_size_t size);
int
cardbus_get_capability(cardbus_chipset_tag_t cc,
cardbus_function_tag_t cf, cardbustag_t tag, int capid,
int *offsetp, cardbusreg_t *valuep);
cardbustag_t
cardbus_make_tag(cardbus_chipset_tag_t cc, int cf, int bus, int device,
int function);
void
cardbus_free_tag(cardbus_chipset_tag_t cc, int cf, cardbustag_t tag);
cardbusreg_t
cardbus_conf_read(cardbus_chipset_tag_t cc, int cf, cardbustag_t tag,
int offs);
void
cardbus_conf_write(cardbus_chipset_tag_t cc, int cf, cardbustag_t tag,
int offs, busreg_t val);
void *
cardbus_intr_establish(cardbus_chipset_tag_t cc,
cardbus_function_tag_t cf, cardbus_intr_handle_t irq, int level,
int (*handler)(void *), void *arg);
void
cardbus_intr_disestablish(cardbus_chipset_tag_t cc,
cardbus_function_tag_t cf, void *ih);
int
CARDBUS_VENDOR(cardbusreg_t id);
int
CARDBUS_PRODUCT(cardbusreg_t id);
int
Cardbus_function_enable(cardbus_devfunc_t ct);
int
Cardbus_function_disable(cardbus_devfunc_t ct);
int
Cardbus_mapreg_map(cardbus_devfunc_t ct, int reg, cardbusreg_t type,
int busflags, bus_space_tag_t *tagp, bus_space_handle_t *handlep,
bus_addr_t *basep, bus_size_t *sizep);
int
Cardbus_mapreg_unmap(cardbus_devfunc_t ct, int reg, bus_space_tag_t tag,
bus_space_handle_t handle, bus_size_t size);
cardbustag_t
Cardbus_make_tag(cardbus_devfunc_t ct);
void
Cardbus_free_tag(cardbus_devfunc_t ct, cardbustag_t tag);
cardbusreg_t
Cardbus_conf_read(cardbus_devfunc_t ct, cardbustag_t tag, int offs);
void
Cardbus_conf_write(cardbus_devfunc_t ct, cardbustag_t tag, int offs,
busreg_t val);
The machine-independent Cardbus subsystem provides support for Cardbus
devices.
The Cardbus interface is an improvement to the PC-Card interface supported
by pcmcia(9). It introduces several new capabilities such as
32-bit addressing, 33MHz operation, busmaster operation and 3.3 volt lowvoltage
power. It remains compatible with all features of the PC-Card
standard.
The Cardbus interface signaling protocol is derived from the PCI signaling
protocol. There are some differences between PCI and Cardbus, however
operations are identical for most functions implemented. Since a
32-bit Cardbus interface is also defined for 16-bit PC-Cards, the same
Card Services client to be used to manage both Cardbus and PCMCIA PCCards.
By interrogating the card upon detection of an insertion event,
NetBSD determines whether the card requires Cardbus support or not, and
then applies the appropriate power and signaling protocol requirements.
Drivers attached to the Cardbus bus will make use of the following data
types:
struct cardbus_attach_args
Devices have their identity recorded in this structure. It contains
the following members:
cardbus_devfunc_t ca_ct;
bus_space_tag_t ca_iot; /* Cardbus I/O space tag */
bus_space_tag_t ca_memt; /* Cardbus MEM space tag */
bus_dma_tag_t ca_dmat; /* DMA tag */
u_int ca_device;
cardbustag_t ca_tag;
cardbusreg_t ca_id;
cardbusreg_t ca_class;
cardbus_intr_line_t ca_intrline; /* interrupt info */
struct cardbus_cis_info ca_cis;
cardbus_attach_card(csc)
Attaches the card on the slot by turning on the power, read and
analyse the tuple and sets configuration index. This function
returns the number of recognised device functions. If no device
functions are recognised it returns zero.
cardbus_detach_card(csc)
Detaches the card on the slot by release resources and turning
off the power. This function must not be called under interrupt
context.
cardbus_function_enable(csc, function)
Enables device function function on the card. Power will be
applied if it hasn't already.
cardbus_function_disable(csc, function)
Disables device function function on the card. When no device
functions are enabled, the turn is turned off.
cardbus_mapreg_map( Maps bus-space on the value of Base Address
Register (BAR) indexed by reg for device function cf. The busspace
configuration is returned in tagp, handlep, basep, and
sizep.
cardbus_mapreg_unmap(csc, cf, reg, tag, handle, bus_size_t size)
Releases bus-space region for device function cf specified by
tag, handle and size. reg is the offset of the BAR register.
cardbus_get_capability(cc, cf, tag, capid, offsetp, valuep)
Find the PCI capability for the device function cf specified by
capid. Returns the capability in offsetp and valuep.
cardbus_make_tag(cc, cf, bus, device, function)
Make a tag to access config space of a Cardbus card. It works
the same as pci_make_tag().
cardbus_free_tag(cc, cf, tag)
Release a tag used to access the config space of a Cardbus card.
It works the same as pci_free_tag().
cardbus_conf_read(cc, cf, tag, offs)
Read the config space of a Cardbus card. It works the same as
pci_conf_read().
cardbus_conf_write(cc, cf, tag, offs, val)
Write to the config space of a Cardbus card. It works same as
pci_conf_write().
cardbus_intr_establish(cc, cf, irq, level, handler, arg)
Establish an interrupt handler for device function cf. The priority
of the interrupt is specified by level. When the interrupt
occurs the function handler is called with argument arg.
The return value is a handle for the interrupt handler.
cardbus_intr_establish() returns an opaque handle to an event
descriptor if it succeeds, and returns NULL on failure.
cardbus_intr_disestablish(cc, cf, ih)
Dis-establish the interrupt handler for device function cf with
handle ih. The handle was returned from
cardbus_intr_establish().
CARDBUS_VENDOR(id)
Return the Cardbus vendor id for device id.
CARDBUS_PRODUCT(id)
Return the Cardbus product id for device id.
The Cardbus_*() functions are convenience functions taking a
cardbus_devfunc_t argument and perform the same operation as their namesake
described above.
During autoconfiguration, a Cardbus driver will receive a pointer to
struct isapnp_attach_args describing the device attaches to the Cardbus
bus. Drivers match the device using the ca_id member using
CARDBUS_VENDOR() and CARDBUS_PRODUCT().
During the driver attach step, drivers should initially map the device
I/O and memory resources using cardbus_mapreg_map() or
Cardbus_mapreg_map(). Upon successful allocation of resources, power can
be applied to the device with cardbus_function_enable() or
Cardbus_function_enable(). so that device-specific interrogation can be
performed. Finally, power should be removed from the device using
cardbus_function_disable() or Cardbus_function_disable().
Since Cardbus devices support dynamic configuration, drivers should make
use of powerhook_establish(9). Power can be applied and the interrupt
handler should be established through this interface.
No additional support is provided for Cardbus DMA beyond the facilities
provided by the bus_dma(9) interface.
This section describes places within the NetBSD source tree where actual
code implementing or utilising the machine-independent Cardbus subsystem
can be found. All pathnames are relative to /usr/src.
The Cardbus subsystem itself is implemented within the files
sys/dev/cardbus/cardbus.c, sys/dev/cardbus/cardbus_map.c and
sys/dev/cardbus/cardslot.c. The database of known devices exists within
the file sys/dev/cardbus/cardbus_data.h and is generated automatically
from the file sys/dev/cardbus/cardbusdevs. New vendor and product identifiers
should be added to this file. The database can be regenerated
using the Makefile sys/dev/cardbus/Makefile.cardbusdevs.
cardbus(4), pcmcia(4), autoconf(9), bus_dma(9), bus_space(9), driver(9),
pci(9), pcmcia(9)
The machine-independent Cardbus subsystem appeared in NetBSD 1.5.
BSD June 20, 2001 BSD
[ Back ] |