Merge tag 'iio-for-5.5b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23...
[sfrench/cifs-2.6.git] / drivers / staging / vc04_services / interface / vchi / vchi_cfg.h
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */
3
4 #ifndef VCHI_CFG_H_
5 #define VCHI_CFG_H_
6
7 /*******************************************************************************
8  * Defines in this first section are part of the VCHI API and may be examined by
9  * VCHI services.
10  ******************************************************************************/
11
12 /*
13  * Required alignment of base addresses for bulk transfer, if unaligned
14  * transfers are not enabled
15  * Really determined by the message driver, and should be available from
16  * a run-time call.
17  */
18 #ifndef VCHI_BULK_ALIGN
19 #   if __VCCOREVER__ >= 0x04000000
20 #       define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans
21 #   else
22 #       define VCHI_BULK_ALIGN 16
23 #   endif
24 #endif
25
26 /*
27  * Required length multiple for bulk transfers, if unaligned transfers are
28  * not enabled
29  * May be less than or greater than VCHI_BULK_ALIGN
30  * Really determined by the message driver, and should be available from
31  * a run-time call.
32  */
33 #ifndef VCHI_BULK_GRANULARITY
34 #   if __VCCOREVER__ >= 0x04000000
35 #       define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans
36 #   else
37 #       define VCHI_BULK_GRANULARITY 16
38 #   endif
39 #endif
40
41 /* The largest possible message to be queued with vchi_msg_queue. */
42 #ifndef VCHI_MAX_MSG_SIZE
43 #   if defined VCHI_LOCAL_HOST_PORT
44 #       define VCHI_MAX_MSG_SIZE     16384         // makes file transfers fast, but should they be using bulk?
45 #   else
46 #       define VCHI_MAX_MSG_SIZE      4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!!
47 #   endif
48 #endif
49
50 /******************************************************************************
51  * Defines below are system configuration options, and should not be used by
52  * VCHI services.
53  ******************************************************************************/
54
55 /*
56  * How many connections can we support? A localhost implementation uses
57  * 2 connections, 1 for host-app, 1 for VMCS, and these are hooked together
58  * by a loopback MPHI VCFW  driver.
59  */
60 #ifndef VCHI_MAX_NUM_CONNECTIONS
61 #   define VCHI_MAX_NUM_CONNECTIONS 3
62 #endif
63
64 /*
65  * How many services can we open per connection? Extending this doesn't cost
66  * processing time, just a small amount of static memory.
67  */
68 #ifndef VCHI_MAX_SERVICES_PER_CONNECTION
69 #  define VCHI_MAX_SERVICES_PER_CONNECTION 36
70 #endif
71
72 /* Adjust if using a message driver that supports more logical TX channels */
73 #ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION
74 #   define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels
75 #endif
76
77 /* Adjust if using a message driver that supports more logical RX channels */
78 #ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION
79 #   define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI
80 #endif
81
82 /*
83  * How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the
84  * effective receive queue space, less message headers.
85  */
86 #ifndef VCHI_NUM_READ_SLOTS
87 #  if defined(VCHI_LOCAL_HOST_PORT)
88 #     define VCHI_NUM_READ_SLOTS 4
89 #  else
90 #     define VCHI_NUM_READ_SLOTS 48
91 #  endif
92 #endif
93
94 /*
95  * Do we utilise overrun facility for receive message slots? Can aid peer
96  * transmit performance. Only define on VideoCore end, talking to host.
97  */
98 //#define VCHI_MSG_RX_OVERRUN
99
100 /*
101  * How many transmit slots do we use. Generally don't need many,
102  * as the hardware driver underneath VCHI will usually have its own buffering.
103  */
104 #ifndef VCHI_NUM_WRITE_SLOTS
105 #  define VCHI_NUM_WRITE_SLOTS 4
106 #endif
107
108 /*
109  * If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or
110  * more slots, then it's taking up too much buffer space,
111  * and the peer service will be told to stop transmitting with an XOFF message.
112  * For this to be effective, the VCHI_NUM_READ_SLOTS needs to be considerably
113  * bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency is too high.
114  */
115 #ifndef VCHI_XOFF_THRESHOLD
116 #  define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2)
117 #endif
118
119 /*
120  * After we've sent an XOFF, the peer will be told to resume transmission
121  * once the local service has dequeued/released enough messages that it's now
122  * occupying VCHI_XON_THRESHOLD slots or fewer.
123  */
124 #ifndef VCHI_XON_THRESHOLD
125 #  define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4)
126 #endif
127
128 /*
129  * A size below which a bulk transfer omits the handshake completely and always
130  * goes via the message channel, if bulk auxiliary is being sent on that
131  * service. (The user can guarantee this by enabling unaligned transmits).
132  * Not API.
133  */
134 #ifndef VCHI_MIN_BULK_SIZE
135 #  define VCHI_MIN_BULK_SIZE    (VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096)
136 #endif
137
138 /*
139  * Maximum size of bulk transmission chunks, for each interface type.
140  * A trade-off between speed and latency; the smaller the chunk size the better
141  * change of messages and other bulk transmissions getting in when big bulk
142  * transfers are happening. Set to 0 to not break transmissions into chunks.
143  */
144 #ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI
145 #  define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024)
146 #endif
147
148 /*
149  * NB Chunked CCP2 transmissions violate the letter of the CCP2 spec
150  * by using "JPEG8" mode with multiple-line frames. Only use if the receiver
151  * can cope.
152  */
153 #ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2
154 #  define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0
155 #endif
156
157 /*
158  * How many TX messages can we have pending in our transmit slots.
159  * Once exhausted, vchi_msg_queue will be blocked.
160  */
161 #ifndef VCHI_TX_MSG_QUEUE_SIZE
162 #  define VCHI_TX_MSG_QUEUE_SIZE           256
163 #endif
164
165 /*
166  * How many RX messages can we have parsed in the receive slots. Once exhausted,
167  * parsing will be suspended until older messages are dequeued/released.
168  */
169 #ifndef VCHI_RX_MSG_QUEUE_SIZE
170 #  define VCHI_RX_MSG_QUEUE_SIZE           256
171 #endif
172
173 /*
174  * Really should be able to cope if we run out of received message descriptors,
175  * by suspending parsing as the comment above says, but we don't.
176  * This sweeps the issue under the carpet.
177  */
178 #if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE / 16 + 1) * VCHI_NUM_READ_SLOTS
179 #  undef VCHI_RX_MSG_QUEUE_SIZE
180 #  define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE / 16 + 1) * VCHI_NUM_READ_SLOTS)
181 #endif
182
183 /*
184  * How many bulk transmits can we have pending. Once exhausted,
185  * vchi_bulk_queue_transmit will be blocked.
186  */
187 #ifndef VCHI_TX_BULK_QUEUE_SIZE
188 #  define VCHI_TX_BULK_QUEUE_SIZE           64
189 #endif
190
191 /*
192  * How many bulk receives can we have pending. Once exhausted,
193  *vchi_bulk_queue_receive will be blocked.
194  */
195 #ifndef VCHI_RX_BULK_QUEUE_SIZE
196 #  define VCHI_RX_BULK_QUEUE_SIZE           64
197 #endif
198
199 /*
200  * A limit on how many outstanding bulk requests we expect the peer to give us.
201  * If the peer asks for more than this, VCHI will fail and assert.
202  * The number is determined by the peer's hardware
203  * - it's the number of outstanding requests that can be queued
204  * on all bulk channels. VC3's MPHI peripheral allows 16.
205  */
206 #ifndef VCHI_MAX_PEER_BULK_REQUESTS
207 #  define VCHI_MAX_PEER_BULK_REQUESTS       32
208 #endif
209
210 /*
211  * Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2
212  * transmitter on and off.
213  */
214 /*#define VCHI_CCP2TX_MANUAL_POWER*/
215
216 #ifndef VCHI_CCP2TX_MANUAL_POWER
217
218 /*
219  * Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state.
220  * Set negative for no IDLE.
221  */
222 #  ifndef VCHI_CCP2TX_IDLE_TIMEOUT
223 #    define VCHI_CCP2TX_IDLE_TIMEOUT        5
224 #  endif
225
226 /*
227  * Timeout (in milliseconds) for putting the CCP2TX interface into OFF state.
228  * Set negative for no OFF.
229  */
230 #  ifndef VCHI_CCP2TX_OFF_TIMEOUT
231 #    define VCHI_CCP2TX_OFF_TIMEOUT         1000
232 #  endif
233
234 #endif /* VCHI_CCP2TX_MANUAL_POWER */
235
236 #endif /* VCHI_CFG_H_ */
237
238 /****************************** End of file **********************************/