i82365var.h revision 1.1.2.3 1 1.1.2.1 marc #include <sys/device.h>
2 1.1.2.1 marc
3 1.1.2.1 marc #include <dev/pcmcia/pcmciareg.h>
4 1.1.2.1 marc #include <dev/pcmcia/pcmciachip.h>
5 1.1.2.1 marc
6 1.1.2.1 marc #include <dev/ic/i82365reg.h>
7 1.1.2.1 marc
8 1.1.2.1 marc struct pcic_handle {
9 1.1.2.1 marc struct pcic_softc *sc;
10 1.1.2.1 marc int vendor;
11 1.1.2.1 marc int sock;
12 1.1.2.1 marc int flags;
13 1.1.2.1 marc int memalloc;
14 1.1.2.2 marc struct {
15 1.1.2.2 marc bus_addr_t addr;
16 1.1.2.2 marc bus_size_t size;
17 1.1.2.2 marc long offset;
18 1.1.2.2 marc int kind;
19 1.1.2.2 marc } mem[PCIC_MEM_WINS];
20 1.1.2.1 marc int ioalloc;
21 1.1.2.2 marc struct {
22 1.1.2.2 marc bus_addr_t addr;
23 1.1.2.2 marc bus_size_t size;
24 1.1.2.2 marc int width;
25 1.1.2.2 marc } io[PCIC_IO_WINS];
26 1.1.2.2 marc int ih_irq;
27 1.1.2.1 marc struct device *pcmcia;
28 1.1.2.1 marc };
29 1.1.2.1 marc
30 1.1.2.2 marc #define PCIC_FLAG_SOCKETP 0x0001
31 1.1.2.2 marc #define PCIC_FLAG_CARDP 0x0002
32 1.1.2.2 marc
33 1.1.2.1 marc #define C0SA PCIC_CHIP0_BASE+PCIC_SOCKETA_INDEX
34 1.1.2.1 marc #define C0SB PCIC_CHIP0_BASE+PCIC_SOCKETB_INDEX
35 1.1.2.1 marc #define C1SA PCIC_CHIP1_BASE+PCIC_SOCKETA_INDEX
36 1.1.2.1 marc #define C1SB PCIC_CHIP1_BASE+PCIC_SOCKETB_INDEX
37 1.1.2.1 marc
38 1.1.2.1 marc /* This is sort of arbitrary. It merely needs to be "enough".
39 1.1.2.1 marc It can be overridden in the conf file, anyway. */
40 1.1.2.1 marc
41 1.1.2.1 marc #define PCIC_MEM_PAGES 4
42 1.1.2.1 marc #define PCIC_MEMSIZE PCIC_MEM_PAGES*PCIC_MEM_PAGESIZE
43 1.1.2.1 marc
44 1.1.2.1 marc #define PCIC_NSLOTS 4
45 1.1.2.1 marc
46 1.1.2.1 marc struct pcic_softc {
47 1.1.2.1 marc struct device dev;
48 1.1.2.1 marc
49 1.1.2.1 marc bus_space_tag_t memt;
50 1.1.2.1 marc bus_space_handle_t memh;
51 1.1.2.1 marc bus_space_tag_t iot;
52 1.1.2.1 marc bus_space_handle_t ioh;
53 1.1.2.1 marc
54 1.1.2.1 marc /* XXX isa_chipset_tag_t, pci_chipset_tag_t, etc. */
55 1.1.2.1 marc caddr_t intr_est;
56 1.1.2.1 marc
57 1.1.2.1 marc pcmcia_chipset_tag_t pct;
58 1.1.2.1 marc
59 1.1.2.1 marc /* this needs to be large enough to hold PCIC_MEM_PAGES bits */
60 1.1.2.1 marc int subregionmask;
61 1.1.2.1 marc
62 1.1.2.1 marc /* used by memory window mapping functions */
63 1.1.2.1 marc bus_addr_t membase;
64 1.1.2.2 marc
65 1.1.2.2 marc /* used by io window mapping functions. These can actually overlap
66 1.1.2.2 marc with another pcic, since the underlying extent mapper will deal
67 1.1.2.2 marc with individual allocations. This is here to deal with the fact
68 1.1.2.2 marc that different busses have different real widths (different pc
69 1.1.2.2 marc hardware seems to use 10 or 12 bits for the I/O bus). */
70 1.1.2.2 marc bus_addr_t iobase;
71 1.1.2.2 marc bus_addr_t iosize;
72 1.1.2.1 marc
73 1.1.2.1 marc int irq;
74 1.1.2.1 marc void *ih;
75 1.1.2.1 marc
76 1.1.2.1 marc struct pcic_handle handle[PCIC_NSLOTS];
77 1.1.2.1 marc };
78 1.1.2.1 marc
79 1.1.2.1 marc
80 1.1.2.1 marc int pcic_ident_ok __P((int));
81 1.1.2.1 marc int pcic_vendor __P((struct pcic_handle *));
82 1.1.2.1 marc char *pcic_vendor_to_string __P((int));
83 1.1.2.1 marc
84 1.1.2.1 marc void pcic_attach __P((struct pcic_softc *));
85 1.1.2.1 marc void pcic_attach_sockets __P((struct pcic_softc *));
86 1.1.2.1 marc int pcic_intr __P((void *arg));
87 1.1.2.1 marc
88 1.1.2.1 marc static inline int pcic_read __P((struct pcic_handle *, int));
89 1.1.2.1 marc static inline void pcic_write __P((struct pcic_handle *, int, int));
90 1.1.2.1 marc static inline void pcic_wait_ready __P((struct pcic_handle *));
91 1.1.2.1 marc
92 1.1.2.1 marc int pcic_chip_mem_alloc __P((pcmcia_chipset_handle_t, bus_size_t,
93 1.1.2.1 marc struct pcmcia_mem_handle *));
94 1.1.2.1 marc void pcic_chip_mem_free __P((pcmcia_chipset_handle_t,
95 1.1.2.1 marc struct pcmcia_mem_handle *));
96 1.1.2.1 marc int pcic_chip_mem_map __P((pcmcia_chipset_handle_t, int, bus_addr_t,
97 1.1.2.1 marc bus_size_t, struct pcmcia_mem_handle *,
98 1.1.2.1 marc bus_addr_t *, int *));
99 1.1.2.1 marc void pcic_chip_mem_unmap __P((pcmcia_chipset_handle_t, int));
100 1.1.2.1 marc
101 1.1.2.1 marc int pcic_chip_io_alloc __P((pcmcia_chipset_handle_t, bus_addr_t, bus_size_t,
102 1.1.2.3 thorpej bus_size_t, struct pcmcia_io_handle *));
103 1.1.2.1 marc void pcic_chip_io_free __P((pcmcia_chipset_handle_t,
104 1.1.2.1 marc struct pcmcia_io_handle *));
105 1.1.2.1 marc int pcic_chip_io_map __P((pcmcia_chipset_handle_t, int, bus_addr_t, bus_size_t,
106 1.1.2.1 marc struct pcmcia_io_handle *, int *));
107 1.1.2.1 marc void pcic_chip_io_unmap __P((pcmcia_chipset_handle_t, int));
108 1.1.2.1 marc
109 1.1.2.1 marc void pcic_chip_socket_enable __P((pcmcia_chipset_handle_t));
110 1.1.2.1 marc void pcic_chip_socket_disable __P((pcmcia_chipset_handle_t));
111 1.1.2.1 marc
112 1.1.2.1 marc static inline int
113 1.1.2.1 marc pcic_read(h, idx)
114 1.1.2.1 marc struct pcic_handle *h;
115 1.1.2.1 marc int idx;
116 1.1.2.1 marc {
117 1.1.2.1 marc if (idx != -1)
118 1.1.2.1 marc bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX, h->sock+idx);
119 1.1.2.1 marc return(bus_space_read_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA));
120 1.1.2.1 marc }
121 1.1.2.1 marc
122 1.1.2.1 marc static inline void
123 1.1.2.1 marc pcic_write(h, idx, data)
124 1.1.2.1 marc struct pcic_handle *h;
125 1.1.2.1 marc int idx;
126 1.1.2.1 marc int data;
127 1.1.2.1 marc {
128 1.1.2.1 marc if (idx != -1)
129 1.1.2.1 marc bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX, h->sock+idx);
130 1.1.2.1 marc bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA, (data));
131 1.1.2.1 marc }
132 1.1.2.1 marc
133 1.1.2.1 marc static inline void
134 1.1.2.1 marc pcic_wait_ready(h)
135 1.1.2.1 marc struct pcic_handle *h;
136 1.1.2.1 marc {
137 1.1.2.1 marc int i;
138 1.1.2.1 marc
139 1.1.2.1 marc for (i=0; i<10000; i++) {
140 1.1.2.1 marc if (pcic_read(h, PCIC_IF_STATUS) & PCIC_IF_STATUS_READY)
141 1.1.2.1 marc return;
142 1.1.2.1 marc delay(500);
143 1.1.2.1 marc }
144 1.1.2.1 marc
145 1.1.2.1 marc #ifdef DIAGNOSTIC
146 1.1.2.1 marc printf("pcic_wait_ready ready never happened\n");
147 1.1.2.1 marc #endif
148 1.1.2.1 marc }
149 1.1.2.1 marc
150