1139749Simp#-
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$
2753855Simp#
2853855Simp
2959272Simp#include <sys/bus.h>
30129798Simp#include <machine/bus.h>
3197613Stakawata#include <dev/pccard/pccardvar.h>
3259272Simp
3353855SimpINTERFACE card;
3453855Simp
3553855Simp#
3653855Simp# Companion interface for pccard.  We need to set attributes for memory
3753855Simp# and i/o port mappings (as well as other types of attributes) that have
38201453Simp# a well defined meaning inside the PC Card/CardBus system.  The bus
3953855Simp# methods are inadequate for this because this must be done at the time the
4053855Simp# resources are set for the device, which predates their activation.  Also,
4153855Simp# the driver activating the resources doesn't necessarily know or need to know
4253855Simp# these attributes.
4353855Simp#
4459193SimpMETHOD int set_res_flags {
4553855Simp	device_t dev;
4653855Simp	device_t child;
4759193Simp	int	 restype;
4858581Simp	int	 rid;
4959193Simp	u_long	 value;
5053855Simp};
5153855Simp
5259193SimpMETHOD int get_res_flags {
5353855Simp	device_t dev;
5453855Simp	device_t child;
5559193Simp	int	 restype;
5653855Simp	int	 rid;
5759193Simp	u_long	 *value;
5853855Simp};
5959193Simp
6061779Simp#
6161779Simp# Sets the memory offset of the pccard bridge's window into attribute
6261779Simp# or common memory space.
6361779Simp#
6459193SimpMETHOD int set_memory_offset {
6559193Simp	device_t  dev;
6659193Simp	device_t  child;
6782376Sjon	int	  rid;
68140692Simp	uint32_t cardaddr;
69140692Simp	uint32_t *deltap;
7059193Simp}
7159193Simp
7264544SimpMETHOD int get_memory_offset {
7364544Simp	device_t  dev;
7464544Simp	device_t  child;
7582376Sjon	int	  rid;
76140692Simp	uint32_t *offset;
7764544Simp}
7864544Simp
7961779Simp#
8061779Simp# pccard bridges call this method to initate the attachment of a card
8161779Simp#
8259193SimpMETHOD int attach_card {
8359193Simp	device_t  dev;
8459193Simp}
8559193Simp
8661779Simp#
8761779Simp# pccard bridges call this to detach a card.
8861779Simp#
8959193SimpMETHOD int detach_card {
9059193Simp	device_t  dev;
9159193Simp}
9259193Simp
9361779Simp#
94100218Simp# Find "dev" in the passed table of devices.  Return it or NULL.
95100218Simp#
96188180SimpMETHOD const struct pccard_product * do_product_lookup {
9797613Stakawata	device_t bus;
9897613Stakawata	device_t dev;
9997613Stakawata	const struct pccard_product *tab;
10097613Stakawata	size_t ent_size;
10197613Stakawata	pccard_product_match_fn matchfn;
10297613Stakawata}
103100218Simp
10466058Simp#
105147711Simp# Scanning function for accessing the CIS of a card in its driver.
106147711Simp#
107147711SimpMETHOD int cis_scan {
108147711Simp	device_t bus;
109150098Simp	device_t dev;
110147711Simp        pccard_scan_t fnp;
111147711Simp	void *argp;
112147711Simp};
113150098Simp
114150098Simp#
115150098Simp# Convenience function to read attribute memory.
116150098Simp#
117150098SimpMETHOD int attr_read {
118150098Simp	device_t bus;
119150098Simp	device_t dev;
120150098Simp	uint32_t offset;
121150098Simp	uint8_t *val;
122150098Simp}
123150098Simp
124150098Simp#
125150098Simp# Convenience function to write attribute memory.
126150098Simp#
127150098SimpMETHOD int attr_write {
128150098Simp	device_t bus;
129150098Simp	device_t dev;
130150098Simp	uint32_t offset;
131150098Simp	uint8_t val;
132150098Simp}
133150098Simp
134150098Simp#
135150098Simp# Read the CCR register
136150098Simp#
137150098SimpMETHOD int ccr_read {
138150098Simp	device_t bus;
139150098Simp	device_t dev;
140150098Simp	uint32_t offset;
141150098Simp	uint8_t *val;
142150098Simp}
143150098Simp
144150098Simp#
145150098Simp# Write the CCR register
146150098Simp#
147150098SimpMETHOD int ccr_write {
148150098Simp	device_t bus;
149150098Simp	device_t dev;
150150098Simp	uint32_t offset;
151150098Simp	uint8_t val;
152150098Simp}
153