card_if.m revision 188180
10Sduke#-
20Sduke# Copyright (c) 1999 M. Warner Losh.
30Sduke# All rights reserved.
40Sduke#
50Sduke# Redistribution and use in source and binary forms, with or without
60Sduke# modification, are permitted provided that the following conditions
70Sduke# are met:
868Sjjg# 1. Redistributions of source code must retain the above copyright
968Sjjg#    notice, this list of conditions and the following disclaimer.
10610Sjjg# 2. Redistributions in binary form must reproduce the above copyright
110Sduke#    notice, this list of conditions and the following disclaimer in the
120Sduke#    documentation and/or other materials provided with the distribution.
130Sduke#
140Sduke# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
150Sduke# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
160Sduke# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
170Sduke# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
180Sduke# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
190Sduke# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
200Sduke# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
210Sduke# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
220Sduke# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
230Sduke# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
240Sduke# SUCH DAMAGE.
250Sduke#
260Sduke# $FreeBSD: head/sys/dev/pccard/card_if.m 188180 2009-02-05 19:39:07Z imp $
270Sduke#
280Sduke
290Sduke#include <sys/bus.h>
300Sduke#include <machine/bus.h>
310Sduke#include <dev/pccard/pccardvar.h>
320Sduke
330SdukeINTERFACE card;
340Sduke
350Sduke#
360Sduke# Companion interface for pccard.  We need to set attributes for memory
370Sduke# and i/o port mappings (as well as other types of attributes) that have
380Sduke# a well defined meaning inside the pccard/cardbus system.  The bus
390Sduke# methods are inadequate for this because this must be done at the time the
400Sduke# resources are set for the device, which predates their activation.  Also,
410Sduke# the driver activating the resources doesn't necessarily know or need to know
420Sduke# these attributes.
430Sduke#
440SdukeMETHOD int set_res_flags {
450Sduke	device_t dev;
460Sduke	device_t child;
470Sduke	int	 restype;
480Sduke	int	 rid;
490Sduke	u_long	 value;
500Sduke};
510Sduke
520SdukeMETHOD int get_res_flags {
530Sduke	device_t dev;
540Sduke	device_t child;
550Sduke	int	 restype;
560Sduke	int	 rid;
570Sduke	u_long	 *value;
58};
59
60#
61# Sets the memory offset of the pccard bridge's window into attribute
62# or common memory space.
63#
64METHOD int set_memory_offset {
65	device_t  dev;
66	device_t  child;
67	int	  rid;
68	uint32_t cardaddr;
69	uint32_t *deltap;
70}
71
72METHOD int get_memory_offset {
73	device_t  dev;
74	device_t  child;
75	int	  rid;
76	uint32_t *offset;
77}
78
79#
80# pccard bridges call this method to initate the attachment of a card
81#
82METHOD int attach_card {
83	device_t  dev;
84}
85
86#
87# pccard bridges call this to detach a card.
88#
89METHOD int detach_card {
90	device_t  dev;
91}
92
93#
94# Find "dev" in the passed table of devices.  Return it or NULL.
95#
96METHOD const struct pccard_product * do_product_lookup {
97	device_t bus;
98	device_t dev;
99	const struct pccard_product *tab;
100	size_t ent_size;
101	pccard_product_match_fn matchfn;
102}
103
104#
105# Helper method for the above.  When a compatibility driver is converted,
106# one must write a match routine.  This routine is unused on OLDCARD but
107# is used as a discriminator for NEWCARD.
108#
109METHOD int compat_match {
110	device_t dev;
111}
112
113#
114# Scanning function for accessing the CIS of a card in its driver.
115#
116METHOD int cis_scan {
117	device_t bus;
118	device_t dev;
119        pccard_scan_t fnp;
120	void *argp;
121};
122
123#
124# Convenience function to read attribute memory.
125#
126METHOD int attr_read {
127	device_t bus;
128	device_t dev;
129	uint32_t offset;
130	uint8_t *val;
131}
132
133#
134# Convenience function to write attribute memory.
135#
136METHOD int attr_write {
137	device_t bus;
138	device_t dev;
139	uint32_t offset;
140	uint8_t val;
141}
142
143#
144# Read the CCR register
145#
146METHOD int ccr_read {
147	device_t bus;
148	device_t dev;
149	uint32_t offset;
150	uint8_t *val;
151}
152
153#
154# Write the CCR register
155#
156METHOD int ccr_write {
157	device_t bus;
158	device_t dev;
159	uint32_t offset;
160	uint8_t val;
161}
162