1
2
3
4
5
6
7
8 #ifndef __HPILO_H
9 #define __HPILO_H
10
11 #define ILO_NAME "hpilo"
12
13
14 #define MAX_CCB 24
15
16 #define MIN_CCB 8
17
18 #define MAX_ILO_DEV 1
19
20 #define MAX_OPEN (MAX_CCB * MAX_ILO_DEV)
21
22 #define MAX_WAIT_TIME 10000
23
24 #define WAIT_TIME 10
25
26 #define MAX_WAIT (MAX_WAIT_TIME / WAIT_TIME)
27
28
29
30
31 struct ilo_hwinfo {
32
33 char __iomem *mmio_vaddr;
34
35
36 char __iomem *db_vaddr;
37
38
39 char __iomem *ram_vaddr;
40
41
42 struct ccb_data *ccb_alloc[MAX_CCB];
43
44 struct pci_dev *ilo_dev;
45
46
47
48
49
50
51
52
53
54
55
56
57 spinlock_t open_lock;
58 spinlock_t alloc_lock;
59 spinlock_t fifo_lock;
60
61 struct cdev cdev;
62 };
63
64
65 #define DB_IRQ 0xB2
66
67 #define DB_OUT 0xD4
68
69 #define DB_RESET 26
70
71
72
73
74
75
76 #define ILOSW_CCB_SZ 64
77 #define ILOHW_CCB_SZ 128
78 struct ccb {
79 union {
80 char *send_fifobar;
81 u64 send_fifobar_pa;
82 } ccb_u1;
83 union {
84 char *send_desc;
85 u64 send_desc_pa;
86 } ccb_u2;
87 u64 send_ctrl;
88
89 union {
90 char *recv_fifobar;
91 u64 recv_fifobar_pa;
92 } ccb_u3;
93 union {
94 char *recv_desc;
95 u64 recv_desc_pa;
96 } ccb_u4;
97 u64 recv_ctrl;
98
99 union {
100 char __iomem *db_base;
101 u64 padding5;
102 } ccb_u5;
103
104 u64 channel;
105
106
107 };
108
109
110 #define SENDQ 1
111 #define RECVQ 2
112 #define NR_QENTRY 4
113 #define L2_QENTRY_SZ 12
114
115
116 #define CTRL_BITPOS_L2SZ 0
117 #define CTRL_BITPOS_FIFOINDEXMASK 4
118 #define CTRL_BITPOS_DESCLIMIT 18
119 #define CTRL_BITPOS_A 30
120 #define CTRL_BITPOS_G 31
121
122
123 #define L2_DB_SIZE 14
124 #define ONE_DB_SIZE (1 << L2_DB_SIZE)
125
126
127
128
129 struct ccb_data {
130
131 struct ccb driver_ccb;
132
133
134 struct ccb ilo_ccb;
135
136
137 struct ccb __iomem *mapped_ccb;
138
139
140 void *dma_va;
141 dma_addr_t dma_pa;
142 size_t dma_size;
143
144
145 struct ilo_hwinfo *ilo_hw;
146
147
148 wait_queue_head_t ccb_waitq;
149
150
151 int ccb_cnt;
152
153
154 int ccb_excl;
155 };
156
157
158
159
160 #define ILO_START_ALIGN 4096
161 #define ILO_CACHE_SZ 128
162 struct fifo {
163 u64 nrents;
164 u64 imask;
165 u64 merge;
166 u64 reset;
167 u8 pad_0[ILO_CACHE_SZ - (sizeof(u64) * 4)];
168
169 u64 head;
170 u8 pad_1[ILO_CACHE_SZ - (sizeof(u64))];
171
172 u64 tail;
173 u8 pad_2[ILO_CACHE_SZ - (sizeof(u64))];
174
175 u64 fifobar[1];
176 };
177
178
179 #define FIFOHANDLESIZE (sizeof(struct fifo) - sizeof(u64))
180 #define FIFOBARTOHANDLE(_fifo) \
181 ((struct fifo *)(((char *)(_fifo)) - FIFOHANDLESIZE))
182
183
184 #define ENTRY_BITPOS_QWORDS 0
185
186 #define ENTRY_BITPOS_DESCRIPTOR 10
187
188 #define ENTRY_BITPOS_C 22
189
190 #define ENTRY_BITPOS_O 23
191
192 #define ENTRY_BITS_QWORDS 10
193 #define ENTRY_BITS_DESCRIPTOR 12
194 #define ENTRY_BITS_C 1
195 #define ENTRY_BITS_O 1
196 #define ENTRY_BITS_TOTAL \
197 (ENTRY_BITS_C + ENTRY_BITS_O + \
198 ENTRY_BITS_QWORDS + ENTRY_BITS_DESCRIPTOR)
199
200
201 #define ENTRY_MASK ((1 << ENTRY_BITS_TOTAL) - 1)
202 #define ENTRY_MASK_C (((1 << ENTRY_BITS_C) - 1) << ENTRY_BITPOS_C)
203 #define ENTRY_MASK_O (((1 << ENTRY_BITS_O) - 1) << ENTRY_BITPOS_O)
204 #define ENTRY_MASK_QWORDS \
205 (((1 << ENTRY_BITS_QWORDS) - 1) << ENTRY_BITPOS_QWORDS)
206 #define ENTRY_MASK_DESCRIPTOR \
207 (((1 << ENTRY_BITS_DESCRIPTOR) - 1) << ENTRY_BITPOS_DESCRIPTOR)
208
209 #define ENTRY_MASK_NOSTATE (ENTRY_MASK >> (ENTRY_BITS_C + ENTRY_BITS_O))
210
211 #endif