card_if.m revision 66058
1183840Sraj#
2183840Sraj# Copyright (c) 1999 M. Warner Losh.
3183840Sraj# All rights reserved.
4183840Sraj#
5183840Sraj# Redistribution and use in source and binary forms, with or without
6183840Sraj# modification, are permitted provided that the following conditions
7183840Sraj# are met:
8183840Sraj# 1. Redistributions of source code must retain the above copyright
9183840Sraj#    notice, this list of conditions and the following disclaimer.
10183840Sraj# 2. Redistributions in binary form must reproduce the above copyright
11183840Sraj#    notice, this list of conditions and the following disclaimer in the
12183840Sraj#    documentation and/or other materials provided with the distribution.
13183840Sraj#
14183840Sraj# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15183840Sraj# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16183840Sraj# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17183840Sraj# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18183840Sraj# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19183840Sraj# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20183840Sraj# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21183840Sraj# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22183840Sraj# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23183840Sraj# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24183840Sraj# SUCH DAMAGE.
25183840Sraj#
26183840Sraj# $FreeBSD: head/sys/dev/pccard/card_if.m 66058 2000-09-19 04:39:20Z imp $
27183840Sraj#
28183840Sraj
29183840Sraj#include <sys/bus.h>
30183840Sraj
31183840SrajINTERFACE card;
32183840Sraj
33183840Sraj#
34183840Sraj# Companion interface for pccard.  We need to set attributes for memory
35183840Sraj# and i/o port mappings (as well as other types of attributes) that have
36183840Sraj# a well defined meaning inside the pccard/cardbus system.  The bus
37183840Sraj# methods are inadequate for this because this must be done at the time the
38183840Sraj# resources are set for the device, which predates their activation.  Also,
39209131Sraj# the driver activating the resources doesn't necessarily know or need to know
40183840Sraj# these attributes.
41183840Sraj#
42183840SrajMETHOD int set_res_flags {
43183840Sraj	device_t dev;
44183840Sraj	device_t child;
45183840Sraj	int	 restype;
46183840Sraj	int	 rid;
47183840Sraj	u_long	 value;
48183840Sraj};
49183840Sraj
50183840SrajMETHOD int get_res_flags {
51242531Sandrew	device_t dev;
52242531Sandrew	device_t child;
53259364Sian	int	 restype;
54266084Sian	int	 rid;
55242531Sandrew	u_long	 *value;
56183840Sraj};
57209131Sraj
58183840Sraj#
59196531Sraj# Sets the memory offset of the pccard bridge's window into attribute
60183840Sraj# or common memory space.
61242531Sandrew#
62183840SrajMETHOD int set_memory_offset {
63209131Sraj	device_t  dev;
64250292Sgber	device_t  child;
65250293Sgber        int	  rid;
66250292Sgber        u_int32_t offset;
67250292Sgber}
68183840Sraj
69239277SgonzoMETHOD int get_memory_offset {
70209131Sraj	device_t  dev;
71209131Sraj	device_t  child;
72209131Sraj        int	  rid;
73209131Sraj        u_int32_t *offset;
74209131Sraj}
75209131Sraj
76209131Sraj#
77209131Sraj# pccard bridges call this method to initate the attachment of a card
78209131Sraj#
79209131SrajMETHOD int attach_card {
80209131Sraj	device_t  dev;
81209131Sraj}
82209131Sraj
83209131Sraj#
84209131Sraj# pccard bridges call this to detach a card.
85209131Sraj#
86209131SrajMETHOD int detach_card {
87209131Sraj	device_t  dev;
88209131Sraj	int	  flags;
89209131Sraj}
90209131Sraj
91209131Sraj#
92209131Sraj# Returns the type of card this is.  Maybe we don't need this.
93228201Sjchandra#
94209131SrajMETHOD int get_type {
95209131Sraj	device_t  dev;
96209131Sraj	int	  *type;
97209131Sraj}
98209131Sraj
99228201Sjchandra#
100209131Sraj# Returns the function number for this device.
101209131Sraj#
102209131SrajMETHOD int get_function {
103209131Sraj	device_t  dev;
104209131Sraj	device_t  child;
105209131Sraj	int	  *func;
106239277Sgonzo}
107239277Sgonzo
108239277Sgonzo#
109239277Sgonzo# Activates (and powers up if necessary) the card's nth function
110239277Sgonzo# since each function gets its own device, there is no need to
111209131Sraj# to specify a function number
112209131Sraj#
113209131SrajMETHOD int activate_function {
114209131Sraj	device_t  dev;
115209131Sraj	device_t  child;
116209131Sraj}
117209131Sraj
118209131SrajMETHOD int deactivate_function {
119209131Sraj	device_t  dev;
120209131Sraj	device_t  child;
121209131Sraj}
122209131Sraj
123209131Sraj#
124209131Sraj# Compatibility methods for OLDCARD drivers.  We use these routines to make
125209131Sraj# it possible to call the OLDCARD driver's probe routine in the context that
126209131Sraj# it expects.  For OLDCARD these are implemented as pass throughs to the
127209131Sraj# device_{probe,attach} routines.  For NEWCARD they are implemented such
128209131Sraj# such that probe becomes strictly a matching routine and attach does both
129209131Sraj# the old probe and old attach.
130209131Sraj#
131209131Sraj# compat devices should use the following:
132209131Sraj#
133209131Sraj#	/* Device interface */
134209131Sraj#	DEVMETHOD(device_probe),	pccard_compat_probe),
135209131Sraj#	DEVMETHOD(device_attach),	pccard_compat_attach),
136209131Sraj#	/* Card interface */
137209131Sraj#	DEVMETHOD(card_compat_match,	foo_match),	/* newly written */
138209131Sraj#	DEVMETHOD(card_compat_probe,	foo_probe),	/* old probe */
139209131Sraj#	DEVMETHOD(card_compat_attach,	foo_attach),	/* old attach */
140209131Sraj#
141209131Sraj# This will allow a single driver binary image to be used for both
142209131Sraj# OLDCARD and NEWCARD.
143209131Sraj#
144209131Sraj# Drivers wishing to not retain OLDCARD compatibility needn't do this.
145209131Sraj#
146209131SrajMETHOD int compat_probe {
147209131Sraj	device_t dev;
148209131Sraj}
149209131Sraj
150209131SrajMETHOD int compat_attach {
151209131Sraj	device_t dev;
152209131Sraj}
153209131Sraj
154209131Sraj#
155209131Sraj# Helper method for the above.  When a compatibility driver is converted,
156209131Sraj# one must write a match routine.  This routine is unused on OLDCARD but
157209131Sraj# is used as a discriminator for NEWCARD.
158209131Sraj#
159209131SrajMETHOD int compat_match {
160209131Sraj	device_t dev;
161209131Sraj}
162209131Sraj