pcmciachip.h revision 1.1.2.9 1 /* $NetBSD: pcmciachip.h,v 1.1.2.9 1997/10/14 05:09:07 thorpej Exp $ */
2
3 #ifndef _PCMCIA_PCMCIACHIP_H_
4 #define _PCMCIA_PCMCIACHIP_H_
5
6 #include <machine/bus.h>
7
8 struct pcmcia_function;
9 struct pcmcia_mem_handle;
10 struct pcmcia_io_handle;
11
12 /* interfaces for pcmcia to call the chipset */
13
14 typedef struct pcmcia_chip_functions *pcmcia_chipset_tag_t;
15 typedef void *pcmcia_chipset_handle_t;
16 typedef int pcmcia_mem_handle_t;
17
18 #define PCMCIA_MEM_ATTR 1
19 #define PCMCIA_MEM_COMMON 2
20
21 #define PCMCIA_WIDTH_IO8 1
22 #define PCMCIA_WIDTH_IO16 2
23
24 struct pcmcia_chip_functions {
25 /* memory space allocation */
26 int (*mem_alloc) __P((pcmcia_chipset_handle_t, bus_size_t,
27 struct pcmcia_mem_handle *));
28 void (*mem_free) __P((pcmcia_chipset_handle_t,
29 struct pcmcia_mem_handle *));
30
31 /* memory space window mapping */
32 int (*mem_map) __P((pcmcia_chipset_handle_t, int, bus_addr_t,
33 bus_size_t, struct pcmcia_mem_handle *,
34 bus_addr_t *, int *));
35 void (*mem_unmap) __P((pcmcia_chipset_handle_t, int));
36
37 /* I/O space allocation */
38 int (*io_alloc) __P((pcmcia_chipset_handle_t, bus_addr_t,
39 bus_size_t, bus_size_t, struct pcmcia_io_handle *));
40 void (*io_free) __P((pcmcia_chipset_handle_t,
41 struct pcmcia_io_handle *));
42
43 /* I/O space window mapping */
44 int (*io_map) __P((pcmcia_chipset_handle_t, int, bus_addr_t,
45 bus_size_t, struct pcmcia_io_handle *, int *));
46 void (*io_unmap) __P((pcmcia_chipset_handle_t, int));
47
48 /* interrupt glue */
49 void *(*intr_establish) __P((pcmcia_chipset_handle_t,
50 struct pcmcia_function *, int, int (*)(void *), void *));
51 void (*intr_disestablish) __P((pcmcia_chipset_handle_t, void *));
52
53 /* card enable/disable */
54 void (*socket_enable) __P((pcmcia_chipset_handle_t));
55 void (*socket_disable) __P((pcmcia_chipset_handle_t));
56 };
57
58 /* Memory space functions. */
59 #define pcmcia_chip_mem_alloc(tag, handle, size, pcmhp) \
60 ((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
61
62 #define pcmcia_chip_mem_free(tag, handle, pcmhp) \
63 ((*(tag)->mem_free)((handle), (pcmhp)))
64
65 #define pcmcia_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp, \
66 offsetp, windowp) \
67 ((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
68 (offsetp), (windowp)))
69
70 #define pcmcia_chip_mem_unmap(tag, handle, window) \
71 ((*(tag)->mem_unmap)((handle), (window)))
72
73 /* I/O space functions. */
74 #define pcmcia_chip_io_alloc(tag, handle, start, size, align, pcihp) \
75 ((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp)))
76
77 #define pcmcia_chip_io_free(tag, handle, pcihp) \
78 ((*(tag)->io_free)((handle), (pcihp)))
79
80 #define pcmcia_chip_io_map(tag, handle, width, card_addr, size, pcihp, \
81 windowp) \
82 ((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
83 (windowp)))
84
85 #define pcmcia_chip_io_unmap(tag, handle, window) \
86 ((*(tag)->io_unmap)((handle), (window)))
87
88 /* Interrupt functions. */
89 #define pcmcia_chip_intr_establish(tag, handle, pf, ipl, fct, arg) \
90 ((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg)))
91
92 #define pcmcia_chip_intr_disestablish(tag, handle, ih) \
93 ((*(tag)->intr_disestablish)((handle), (ih)))
94
95 /* Socket functions. */
96 #define pcmcia_chip_socket_enable(tag, handle) \
97 ((*(tag)->socket_enable)((handle)))
98 #define pcmcia_chip_socket_disable(tag, handle) \
99 ((*(tag)->socket_disable)((handle)))
100
101 struct pcmciabus_attach_args {
102 pcmcia_chipset_tag_t pct;
103 pcmcia_chipset_handle_t pch;
104 };
105
106 /* interfaces for the chipset to call pcmcia */
107
108 int pcmcia_card_attach __P((struct device *));
109 void pcmcia_card_detach __P((struct device *));
110 int pcmcia_card_gettype __P((struct device *));
111
112 #endif /* _PCMCIA_PCMCIACHIP_H_ */
113