card_if.m revision 69308
153855Simp#
253855Simp# Copyright (c) 1999 M. Warner Losh.
353855Simp# All rights reserved.
453855Simp#
553855Simp# Redistribution and use in source and binary forms, with or without
653855Simp# modification, are permitted provided that the following conditions
753855Simp# are met:
853855Simp# 1. Redistributions of source code must retain the above copyright
953855Simp#    notice, this list of conditions and the following disclaimer.
1053855Simp# 2. Redistributions in binary form must reproduce the above copyright
1153855Simp#    notice, this list of conditions and the following disclaimer in the
1253855Simp#    documentation and/or other materials provided with the distribution.
1353855Simp#
1453855Simp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1553855Simp# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1653855Simp# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1753855Simp# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1853855Simp# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1953855Simp# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2053855Simp# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2153855Simp# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2253855Simp# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2353855Simp# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2453855Simp# SUCH DAMAGE.
2553855Simp#
2653855Simp# $FreeBSD: head/sys/dev/pccard/card_if.m 69308 2000-11-28 15:50:13Z jon $
2753855Simp#
2853855Simp
2959272Simp#include <sys/bus.h>
3059272Simp
3153855SimpINTERFACE card;
3253855Simp
3353855Simp#
3453855Simp# Companion interface for pccard.  We need to set attributes for memory
3553855Simp# and i/o port mappings (as well as other types of attributes) that have
3653855Simp# a well defined meaning inside the pccard/cardbus system.  The bus
3753855Simp# methods are inadequate for this because this must be done at the time the
3853855Simp# resources are set for the device, which predates their activation.  Also,
3953855Simp# the driver activating the resources doesn't necessarily know or need to know
4053855Simp# these attributes.
4153855Simp#
4259193SimpMETHOD int set_res_flags {
4353855Simp	device_t dev;
4453855Simp	device_t child;
4559193Simp	int	 restype;
4658581Simp	int	 rid;
4759193Simp	u_long	 value;
4853855Simp};
4953855Simp
5059193SimpMETHOD int get_res_flags {
5153855Simp	device_t dev;
5253855Simp	device_t child;
5359193Simp	int	 restype;
5453855Simp	int	 rid;
5559193Simp	u_long	 *value;
5653855Simp};
5759193Simp
5861779Simp#
5961779Simp# Sets the memory offset of the pccard bridge's window into attribute
6061779Simp# or common memory space.
6161779Simp#
6259193SimpMETHOD int set_memory_offset {
6359193Simp	device_t  dev;
6459193Simp	device_t  child;
6559193Simp        int	  rid;
6659193Simp        u_int32_t offset;
6759193Simp}
6859193Simp
6964544SimpMETHOD int get_memory_offset {
7064544Simp	device_t  dev;
7164544Simp	device_t  child;
7264544Simp        int	  rid;
7364544Simp        u_int32_t *offset;
7464544Simp}
7564544Simp
7661779Simp#
7761779Simp# pccard bridges call this method to initate the attachment of a card
7861779Simp#
7959193SimpMETHOD int attach_card {
8059193Simp	device_t  dev;
8159193Simp}
8259193Simp
8361779Simp#
8461779Simp# pccard bridges call this to detach a card.
8561779Simp#
8659193SimpMETHOD int detach_card {
8759193Simp	device_t  dev;
8859193Simp	int	  flags;
8959193Simp}
9059193Simp
9169308SjonHEADER {
9269308Sjon	#define DETACH_FORCE 0x01
9369308Sjon}
9469308Sjon
9561779Simp#
9661779Simp# Returns the type of card this is.  Maybe we don't need this.
9761779Simp#
9859193SimpMETHOD int get_type {
9959193Simp	device_t  dev;
10059193Simp	int	  *type;
10159193Simp}
10261779Simp
10361779Simp#
10461779Simp# Returns the function number for this device.
10561779Simp#
10661779SimpMETHOD int get_function {
10761779Simp	device_t  dev;
10861779Simp	device_t  child;
10961779Simp	int	  *func;
11061779Simp}
11161779Simp
11261779Simp#
11361779Simp# Activates (and powers up if necessary) the card's nth function
11461779Simp# since each function gets its own device, there is no need to
11561779Simp# to specify a function number
11661779Simp#
11761779SimpMETHOD int activate_function {
11861779Simp	device_t  dev;
11961779Simp	device_t  child;
12061779Simp}
12161779Simp
12261779SimpMETHOD int deactivate_function {
12361779Simp	device_t  dev;
12461779Simp	device_t  child;
12561779Simp}
12666058Simp
12766058Simp#
12866058Simp# Compatibility methods for OLDCARD drivers.  We use these routines to make
12966058Simp# it possible to call the OLDCARD driver's probe routine in the context that
13066058Simp# it expects.  For OLDCARD these are implemented as pass throughs to the
13166058Simp# device_{probe,attach} routines.  For NEWCARD they are implemented such
13266058Simp# such that probe becomes strictly a matching routine and attach does both
13366058Simp# the old probe and old attach.
13466058Simp#
13566058Simp# compat devices should use the following:
13666058Simp#
13766058Simp#	/* Device interface */
13866058Simp#	DEVMETHOD(device_probe),	pccard_compat_probe),
13966058Simp#	DEVMETHOD(device_attach),	pccard_compat_attach),
14066058Simp#	/* Card interface */
14166058Simp#	DEVMETHOD(card_compat_match,	foo_match),	/* newly written */
14266058Simp#	DEVMETHOD(card_compat_probe,	foo_probe),	/* old probe */
14366058Simp#	DEVMETHOD(card_compat_attach,	foo_attach),	/* old attach */
14466058Simp#
14566058Simp# This will allow a single driver binary image to be used for both
14666058Simp# OLDCARD and NEWCARD.
14766058Simp#
14866058Simp# Drivers wishing to not retain OLDCARD compatibility needn't do this.
14966058Simp#
15066058SimpMETHOD int compat_probe {
15166058Simp	device_t dev;
15266058Simp}
15366058Simp
15466058SimpMETHOD int compat_attach {
15566058Simp	device_t dev;
15666058Simp}
15766058Simp
15866058Simp#
15966058Simp# Helper method for the above.  When a compatibility driver is converted,
16066058Simp# one must write a match routine.  This routine is unused on OLDCARD but
16166058Simp# is used as a discriminator for NEWCARD.
16266058Simp#
16366058SimpMETHOD int compat_match {
16466058Simp	device_t dev;
16566058Simp}
166