Annotation of sys/dev/pcmcia/pcmciachip.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: pcmciachip.h,v 1.8 2005/11/23 11:39:37 mickey Exp $ */
! 2: /* $NetBSD: pcmciachip.h,v 1.5 2000/01/13 08:58:51 joda Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1997 Marc Horowitz. All rights reserved.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: * 1. Redistributions of source code must retain the above copyright
! 11: * notice, this list of conditions and the following disclaimer.
! 12: * 2. Redistributions in binary form must reproduce the above copyright
! 13: * notice, this list of conditions and the following disclaimer in the
! 14: * documentation and/or other materials provided with the distribution.
! 15: * 3. All advertising materials mentioning features or use of this software
! 16: * must display the following acknowledgement:
! 17: * This product includes software developed by Marc Horowitz.
! 18: * 4. The name of the author may not be used to endorse or promote products
! 19: * derived from this software without specific prior written permission.
! 20: *
! 21: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 22: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 23: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 24: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 25: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 26: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 27: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 28: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 29: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 30: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 31: */
! 32:
! 33: #ifndef _PCMCIA_PCMCIACHIP_H_
! 34: #define _PCMCIA_PCMCIACHIP_H_
! 35:
! 36: #include <machine/bus.h>
! 37:
! 38: struct pcmcia_function;
! 39: struct pcmcia_mem_handle;
! 40: struct pcmcia_io_handle;
! 41:
! 42: /* interfaces for pcmcia to call the chipset */
! 43:
! 44: typedef struct pcmcia_chip_functions *pcmcia_chipset_tag_t;
! 45: typedef void *pcmcia_chipset_handle_t;
! 46: typedef int pcmcia_mem_handle_t;
! 47:
! 48: #define PCMCIA_MEM_ATTR 1
! 49: #define PCMCIA_MEM_COMMON 2
! 50:
! 51: #define PCMCIA_WIDTH_MEM8 8
! 52: #define PCMCIA_WIDTH_MEM16 16
! 53:
! 54: #define PCMCIA_WIDTH_MEM_MASK 24
! 55:
! 56: #define PCMCIA_WIDTH_AUTO 0
! 57: #define PCMCIA_WIDTH_IO8 1
! 58: #define PCMCIA_WIDTH_IO16 2
! 59:
! 60: struct pcmcia_chip_functions {
! 61: /* memory space allocation */
! 62: int (*mem_alloc)(pcmcia_chipset_handle_t, bus_size_t,
! 63: struct pcmcia_mem_handle *);
! 64: void (*mem_free)(pcmcia_chipset_handle_t,
! 65: struct pcmcia_mem_handle *);
! 66:
! 67: /* memory space window mapping */
! 68: int (*mem_map)(pcmcia_chipset_handle_t, int, bus_addr_t,
! 69: bus_size_t, struct pcmcia_mem_handle *,
! 70: bus_size_t *, int *);
! 71: void (*mem_unmap)(pcmcia_chipset_handle_t, int);
! 72:
! 73: /* I/O space allocation */
! 74: int (*io_alloc)(pcmcia_chipset_handle_t, bus_addr_t,
! 75: bus_size_t, bus_size_t, struct pcmcia_io_handle *);
! 76: void (*io_free)(pcmcia_chipset_handle_t,
! 77: struct pcmcia_io_handle *);
! 78:
! 79: /* I/O space window mapping */
! 80: int (*io_map)(pcmcia_chipset_handle_t, int, bus_addr_t,
! 81: bus_size_t, struct pcmcia_io_handle *, int *);
! 82: void (*io_unmap)(pcmcia_chipset_handle_t, int);
! 83:
! 84: /* interrupt glue */
! 85: void *(*intr_establish)(pcmcia_chipset_handle_t,
! 86: struct pcmcia_function *, int, int (*)(void *), void *, char *);
! 87: void (*intr_disestablish)(pcmcia_chipset_handle_t, void *);
! 88: const char *(*intr_string)(pcmcia_chipset_handle_t, void *);
! 89:
! 90: /* card enable/disable */
! 91: void (*socket_enable)(pcmcia_chipset_handle_t);
! 92: void (*socket_disable)(pcmcia_chipset_handle_t);
! 93:
! 94: /* card detection */
! 95: int (*card_detect)(pcmcia_chipset_handle_t);
! 96: };
! 97:
! 98: /* Memory space functions. */
! 99: #define pcmcia_chip_mem_alloc(tag, handle, size, pcmhp) \
! 100: ((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
! 101:
! 102: #define pcmcia_chip_mem_free(tag, handle, pcmhp) \
! 103: ((*(tag)->mem_free)((handle), (pcmhp)))
! 104:
! 105: #define pcmcia_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp, \
! 106: offsetp, windowp) \
! 107: ((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
! 108: (offsetp), (windowp)))
! 109:
! 110: #define pcmcia_chip_mem_unmap(tag, handle, window) \
! 111: ((*(tag)->mem_unmap)((handle), (window)))
! 112:
! 113: /* I/O space functions. */
! 114: #define pcmcia_chip_io_alloc(tag, handle, start, size, align, pcihp) \
! 115: ((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp)))
! 116:
! 117: #define pcmcia_chip_io_free(tag, handle, pcihp) \
! 118: ((*(tag)->io_free)((handle), (pcihp)))
! 119:
! 120: #define pcmcia_chip_io_map(tag, handle, width, card_addr, size, pcihp, \
! 121: windowp) \
! 122: ((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
! 123: (windowp)))
! 124:
! 125: #define pcmcia_chip_io_unmap(tag, handle, window) \
! 126: ((*(tag)->io_unmap)((handle), (window)))
! 127:
! 128: /* Interrupt functions. */
! 129: #define pcmcia_chip_intr_establish(tag, handle, pf, ipl, fct, arg, xname) \
! 130: ((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg), (xname)))
! 131:
! 132: #define pcmcia_chip_intr_disestablish(tag, handle, ih) \
! 133: ((*(tag)->intr_disestablish)((handle), (ih)))
! 134:
! 135: #define pcmcia_chip_intr_string(tag, handle, ih) \
! 136: ((*(tag)->intr_string)((handle), (ih)))
! 137:
! 138: /* Socket functions. */
! 139: #define pcmcia_chip_socket_enable(tag, handle) \
! 140: ((*(tag)->socket_enable)((handle)))
! 141: #define pcmcia_chip_socket_disable(tag, handle) \
! 142: ((*(tag)->socket_disable)((handle)))
! 143:
! 144: struct pcmciabus_attach_args {
! 145: char *paa_busname; /* Bus name */
! 146: pcmcia_chipset_tag_t pct;
! 147: pcmcia_chipset_handle_t pch;
! 148: bus_addr_t iobase; /* start i/o space allocation here */
! 149: bus_size_t iosize; /* size of the i/o space range */
! 150: };
! 151:
! 152: /* interfaces for the chipset to call pcmcia */
! 153:
! 154: int pcmcia_card_attach(struct device *);
! 155: void pcmcia_card_detach(struct device *, int);
! 156: void pcmcia_card_deactivate(struct device *);
! 157: int pcmcia_card_gettype(struct device *);
! 158:
! 159: #endif /* _PCMCIA_PCMCIACHIP_H_ */
CVSweb