pcmciachip.h revision 1.1.2.4 1 #ifndef _PCMCIA_PCMCIACHIP_H_
2 #define _PCMCIA_PCMCIACHIP_H_
3
4 #include <machine/bus.h>
5
6 struct pcmcia_mem_handle;
7 struct pcmcia_io_handle;
8
9 /* interfaces for pcmcia to call the chipset */
10
11 typedef struct pcmcia_chip_functions *pcmcia_chipset_tag_t;
12 typedef void *pcmcia_chipset_handle_t;
13 typedef int pcmcia_mem_handle_t;
14
15 #define PCMCIA_MEM_ATTR 1
16 #define PCMCIA_MEM_COMMON 2
17
18 #define PCMCIA_WIDTH_IO8 1
19 #define PCMCIA_WIDTH_IO16 2
20
21 struct pcmcia_chip_functions {
22 /* memory space allocation */
23 int (*mem_alloc) __P((pcmcia_chipset_handle_t, bus_size_t,
24 struct pcmcia_mem_handle *));
25 void (*mem_free) __P((pcmcia_chipset_handle_t,
26 struct pcmcia_mem_handle *));
27
28 /* memory space window mapping */
29 int (*mem_map) __P((pcmcia_chipset_handle_t, int, bus_addr_t,
30 bus_size_t, struct pcmcia_mem_handle *,
31 bus_addr_t *, int *));
32 void (*mem_unmap) __P((pcmcia_chipset_handle_t, int));
33
34 /* I/O space allocation */
35 int (*io_alloc) __P((pcmcia_chipset_handle_t, bus_addr_t, bus_size_t,
36 struct pcmcia_io_handle *));
37 void (*io_free) __P((pcmcia_chipset_handle_t,
38 struct pcmcia_io_handle *));
39
40 /* I/O space window mapping */
41 int (*io_map) __P((pcmcia_chipset_handle_t, int, bus_addr_t,
42 bus_size_t, struct pcmcia_io_handle *, int *));
43 void (*io_unmap) __P((pcmcia_chipset_handle_t, int));
44
45 /* interrupt glue */
46 void *(*intr_establish) __P((pcmcia_chipset_handle_t, u_int16_t, int,
47 int (*)(void *), void *));
48 void (*intr_disestablish) __P((pcmcia_chipset_handle_t, void *));
49 };
50
51 #define pcmcia_chip_mem_alloc(tag, handle, size, pcmhp) \
52 ((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
53 #define pcmcia_chip_mem_free(tag, handle, pcmhp) \
54 ((*(tag)->mem_free)((handle), (pcmhp)))
55 #define pcmcia_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp, \
56 offsetp, windowp) \
57 ((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
58 (offsetp), (windowp)))
59 #define pcmcia_chip_mem_unmap(tag, handle, window) \
60 ((*(tag)->mem_unmap)((handle), (window)))
61
62 #define pcmcia_chip_io_alloc(tag, handle, start, size, pcihp) \
63 ((*(tag)->io_alloc)((handle), (start), (size), (pcihp)))
64 #define pcmcia_chip_io_free(tag, handle, pcihp) \
65 ((*(tag)->io_free)((handle), (pcihp)))
66 #define pcmcia_chip_io_map(tag, handle, width, card_addr, size, pcihp, \
67 windowp) \
68 ((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
69 (windowp)))
70 #define pcmcia_chip_io_unmap(tag, handle, window) \
71 ((*(tag)->io_unmap)((handle), (window)))
72
73 #define pcmcia_chip_intr_establish(tag, handle, irqmask, ipl, fct, arg) \
74 ((*(tag)->intr_establish)((handle), (irqmask), (ipl), (fct), (arg)))
75 #define pcmcia_chip_intr_disestablish(tag, handle, ih) \
76 ((*(tag)->intr_disestablish)((handle), (ih)))
77
78 struct pcmciabus_attach_args {
79 pcmcia_chipset_tag_t pct;
80 pcmcia_chipset_handle_t pch;
81 };
82
83 /* interfaces for the chipset to call pcmcia */
84
85 int pcmcia_attach_card __P((struct device *, int *));
86 void pcmcia_detach_card __P((struct device *));
87
88 #endif /* _PCMCIA_PCMCIACHIP_H_ */
89