1#- 2# Copyright (c) 1999 M. Warner Losh. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26# $FreeBSD$ 27# 28 29#include <sys/bus.h> 30#include <machine/bus.h> 31#include <dev/pccard/pccardvar.h> 32 33INTERFACE card; 34 35# 36# Companion interface for pccard. We need to set attributes for memory 37# and i/o port mappings (as well as other types of attributes) that have 38# a well defined meaning inside the PC Card/CardBus system. The bus 39# methods are inadequate for this because this must be done at the time the 40# resources are set for the device, which predates their activation. Also, 41# the driver activating the resources doesn't necessarily know or need to know 42# these attributes. 43# 44METHOD int set_res_flags { 45 device_t dev; 46 device_t child; 47 int restype; 48 int rid; 49 u_long value; 50}; 51 52METHOD int get_res_flags { 53 device_t dev; 54 device_t child; 55 int restype; 56 int rid; 57 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# Scanning function for accessing the CIS of a card in its driver. 106# 107METHOD int cis_scan { 108 device_t bus; 109 device_t dev; 110 pccard_scan_t fnp; 111 void *argp; 112}; 113 114# 115# Convenience function to read attribute memory. 116# 117METHOD int attr_read { 118 device_t bus; 119 device_t dev; 120 uint32_t offset; 121 uint8_t *val; 122} 123 124# 125# Convenience function to write attribute memory. 126# 127METHOD int attr_write { 128 device_t bus; 129 device_t dev; 130 uint32_t offset; 131 uint8_t val; 132} 133 134# 135# Read the CCR register 136# 137METHOD int ccr_read { 138 device_t bus; 139 device_t dev; 140 uint32_t offset; 141 uint8_t *val; 142} 143 144# 145# Write the CCR register 146# 147METHOD int ccr_write { 148 device_t bus; 149 device_t dev; 150 uint32_t offset; 151 uint8_t val; 152} 153