greybus: gpbridge.h: whitespace cleanups
[cascardo/linux.git] / drivers / staging / greybus / gpbridge.h
1 /*
2  * This file is provided under a dual BSD/GPLv2 license.  When using or
3  * redistributing this file, you may do so under either license.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
8  * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of version 2 of the GNU General Public License as
12  * published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License version 2 for more details.
18  *
19  * BSD LICENSE
20  *
21  * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
22  * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  *  * Redistributions of source code must retain the above copyright
29  *    notice, this list of conditions and the following disclaimer.
30  *  * Redistributions in binary form must reproduce the above copyright
31  *    notice, this list of conditions and the following disclaimer in
32  *    the documentation and/or other materials provided with the
33  *    distribution.
34  *  * Neither the name of Google Inc. or Linaro Ltd. nor the names of
35  *    its contributors may be used to endorse or promote products
36  *    derived from this software without specific prior written
37  *    permission.
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
43  * LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
45  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
47  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50  */
51
52 #ifndef __GB_GPBRIDGE_H__
53 #define __GB_GPBRIDGE_H__
54
55 /* I2C */
56
57 /* Version of the Greybus i2c protocol we support */
58 #define GB_I2C_VERSION_MAJOR            0x00
59 #define GB_I2C_VERSION_MINOR            0x01
60
61 /* Greybus i2c request types */
62 #define GB_I2C_TYPE_INVALID             0x00
63 #define GB_I2C_TYPE_PROTOCOL_VERSION    0x01
64 #define GB_I2C_TYPE_FUNCTIONALITY       0x02
65 #define GB_I2C_TYPE_TIMEOUT             0x03
66 #define GB_I2C_TYPE_RETRIES             0x04
67 #define GB_I2C_TYPE_TRANSFER            0x05
68 #define GB_I2C_TYPE_RESPONSE            0x80    /* OR'd with rest */
69
70 #define GB_I2C_RETRIES_DEFAULT          3
71 #define GB_I2C_TIMEOUT_DEFAULT          1000    /* milliseconds */
72
73 /* functionality request has no payload */
74 struct gb_i2c_functionality_response {
75         __le32  functionality;
76 };
77
78 struct gb_i2c_timeout_request {
79         __le16  msec;
80 };
81 /* timeout response has no payload */
82
83 struct gb_i2c_retries_request {
84         __u8    retries;
85 };
86 /* retries response has no payload */
87
88 /*
89  * Outgoing data immediately follows the op count and ops array.
90  * The data for each write (master -> slave) op in the array is sent
91  * in order, with no (e.g. pad) bytes separating them.
92  *
93  * Short reads cause the entire transfer request to fail So response
94  * payload consists only of bytes read, and the number of bytes is
95  * exactly what was specified in the corresponding op.  Like
96  * outgoing data, the incoming data is in order and contiguous.
97  */
98 struct gb_i2c_transfer_op {
99         __le16  addr;
100         __le16  flags;
101         __le16  size;
102 };
103
104 struct gb_i2c_transfer_request {
105         __le16                          op_count;
106         struct gb_i2c_transfer_op       ops[0];         /* op_count of these */
107 };
108 struct gb_i2c_transfer_response {
109         __u8                            data[0];        /* inbound data */
110 };
111
112
113 /* GPIO */
114
115 /* Version of the Greybus GPIO protocol we support */
116 #define GB_GPIO_VERSION_MAJOR           0x00
117 #define GB_GPIO_VERSION_MINOR           0x01
118
119 /* Greybus GPIO request types */
120 #define GB_GPIO_TYPE_INVALID            0x00
121 #define GB_GPIO_TYPE_PROTOCOL_VERSION   0x01
122 #define GB_GPIO_TYPE_LINE_COUNT         0x02
123 #define GB_GPIO_TYPE_ACTIVATE           0x03
124 #define GB_GPIO_TYPE_DEACTIVATE         0x04
125 #define GB_GPIO_TYPE_GET_DIRECTION      0x05
126 #define GB_GPIO_TYPE_DIRECTION_IN       0x06
127 #define GB_GPIO_TYPE_DIRECTION_OUT      0x07
128 #define GB_GPIO_TYPE_GET_VALUE          0x08
129 #define GB_GPIO_TYPE_SET_VALUE          0x09
130 #define GB_GPIO_TYPE_SET_DEBOUNCE       0x0a
131 #define GB_GPIO_TYPE_IRQ_TYPE           0x0b
132 #define GB_GPIO_TYPE_IRQ_ACK            0x0c
133 #define GB_GPIO_TYPE_IRQ_MASK           0x0d
134 #define GB_GPIO_TYPE_IRQ_UNMASK         0x0e
135 #define GB_GPIO_TYPE_IRQ_EVENT          0x0f
136 #define GB_GPIO_TYPE_RESPONSE           0x80    /* OR'd with rest */
137
138 #define GB_GPIO_DEBOUNCE_USEC_DEFAULT   0       /* microseconds */
139
140 /* line count request has no payload */
141 struct gb_gpio_line_count_response {
142         __u8    count;
143 };
144
145 struct gb_gpio_activate_request {
146         __u8    which;
147 };
148 /* activate response has no payload */
149
150 struct gb_gpio_deactivate_request {
151         __u8    which;
152 };
153 /* deactivate response has no payload */
154
155 struct gb_gpio_get_direction_request {
156         __u8    which;
157 };
158 struct gb_gpio_get_direction_response {
159         __u8    direction;
160 };
161
162 struct gb_gpio_direction_in_request {
163         __u8    which;
164 };
165 /* direction in response has no payload */
166
167 struct gb_gpio_direction_out_request {
168         __u8    which;
169         __u8    value;
170 };
171 /* direction out response has no payload */
172
173 struct gb_gpio_get_value_request {
174         __u8    which;
175 };
176 struct gb_gpio_get_value_response {
177         __u8    value;
178 };
179
180 struct gb_gpio_set_value_request {
181         __u8    which;
182         __u8    value;
183 };
184 /* set value response has no payload */
185
186 struct gb_gpio_set_debounce_request {
187         __u8    which;
188         __le16  usec __packed;
189 };
190 /* debounce response has no payload */
191
192 struct gb_gpio_irq_type_request {
193         __u8    which;
194         __u8    type;
195 };
196 /* irq type response has no payload */
197
198 struct gb_gpio_irq_mask_request {
199         __u8    which;
200 };
201 /* irq mask response has no payload */
202
203 struct gb_gpio_irq_unmask_request {
204         __u8    which;
205 };
206 /* irq unmask response has no payload */
207
208 struct gb_gpio_irq_ack_request {
209         __u8    which;
210 };
211 /* irq ack response has no payload */
212
213 /* irq event requests originate on another module and are handled on the AP */
214 struct gb_gpio_irq_event_request {
215         __u8    which;
216 };
217 /* irq event response has no payload */
218
219
220 /* PWM */
221
222 /* Version of the Greybus PWM protocol we support */
223 #define GB_PWM_VERSION_MAJOR            0x00
224 #define GB_PWM_VERSION_MINOR            0x01
225
226 /* Greybus PWM request types */
227 #define GB_PWM_TYPE_INVALID             0x00
228 #define GB_PWM_TYPE_PROTOCOL_VERSION    0x01
229 #define GB_PWM_TYPE_PWM_COUNT           0x02
230 #define GB_PWM_TYPE_ACTIVATE            0x03
231 #define GB_PWM_TYPE_DEACTIVATE          0x04
232 #define GB_PWM_TYPE_CONFIG              0x05
233 #define GB_PWM_TYPE_POLARITY            0x06
234 #define GB_PWM_TYPE_ENABLE              0x07
235 #define GB_PWM_TYPE_DISABLE             0x08
236 #define GB_PWM_TYPE_RESPONSE            0x80    /* OR'd with rest */
237
238 /* pwm count request has no payload */
239 struct gb_pwm_count_response {
240         __u8    count;
241 };
242
243 struct gb_pwm_activate_request {
244         __u8    which;
245 };
246
247 struct gb_pwm_deactivate_request {
248         __u8    which;
249 };
250
251 struct gb_pwm_config_request {
252         __u8    which;
253         __le32  duty __packed;
254         __le32  period __packed;
255 };
256
257 struct gb_pwm_polarity_request {
258         __u8    which;
259         __u8    polarity;
260 };
261
262 struct gb_pwm_enable_request {
263         __u8    which;
264 };
265
266 struct gb_pwm_disable_request {
267         __u8    which;
268 };
269
270 /* I2S */
271 #ifndef BIT
272 #define BIT(n) (1UL << (n))
273 #endif
274
275 #define GB_I2S_MGMT_TYPE_PROTOCOL_VERSION               0x01
276 #define GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS   0x02
277 #define GB_I2S_MGMT_TYPE_SET_CONFIGURATION              0x03
278 #define GB_I2S_MGMT_TYPE_SET_SAMPLES_PER_MESSAGE        0x04
279 #define GB_I2S_MGMT_TYPE_GET_PROCESSING_DELAY           0x05
280 #define GB_I2S_MGMT_TYPE_SET_START_DELAY                0x06
281 #define GB_I2S_MGMT_TYPE_ACTIVATE_CPORT                 0x07
282 #define GB_I2S_MGMT_TYPE_DEACTIVATE_CPORT               0x08
283 #define GB_I2S_MGMT_TYPE_REPORT_EVENT                   0x09
284
285 #define GB_I2S_MGMT_BYTE_ORDER_NA                       BIT(0)
286 #define GB_I2S_MGMT_BYTE_ORDER_BE                       BIT(1)
287 #define GB_I2S_MGMT_BYTE_ORDER_LE                       BIT(2)
288
289 #define GB_I2S_MGMT_SPATIAL_LOCATION_FL                 BIT(0)
290 #define GB_I2S_MGMT_SPATIAL_LOCATION_FR                 BIT(1)
291 #define GB_I2S_MGMT_SPATIAL_LOCATION_FC                 BIT(2)
292 #define GB_I2S_MGMT_SPATIAL_LOCATION_LFE                BIT(3)
293 #define GB_I2S_MGMT_SPATIAL_LOCATION_BL                 BIT(4)
294 #define GB_I2S_MGMT_SPATIAL_LOCATION_BR                 BIT(5)
295 #define GB_I2S_MGMT_SPATIAL_LOCATION_FLC                BIT(6)
296 #define GB_I2S_MGMT_SPATIAL_LOCATION_FRC                BIT(7)
297 #define GB_I2S_MGMT_SPATIAL_LOCATION_C                  BIT(8) /* BC in USB */
298 #define GB_I2S_MGMT_SPATIAL_LOCATION_SL                 BIT(9)
299 #define GB_I2S_MGMT_SPATIAL_LOCATION_SR                 BIT(10)
300 #define GB_I2S_MGMT_SPATIAL_LOCATION_TC                 BIT(11)
301 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFL                BIT(12)
302 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFC                BIT(13)
303 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFR                BIT(14)
304 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBL                BIT(15)
305 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBC                BIT(16)
306 #define GB_I2S_MGMT_SPATIAL_LOCATION_TBR                BIT(17)
307 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFLC               BIT(18)
308 #define GB_I2S_MGMT_SPATIAL_LOCATION_TFRC               BIT(19)
309 #define GB_I2S_MGMT_SPATIAL_LOCATION_LLFE               BIT(20)
310 #define GB_I2S_MGMT_SPATIAL_LOCATION_RLFE               BIT(21)
311 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSL                BIT(22)
312 #define GB_I2S_MGMT_SPATIAL_LOCATION_TSR                BIT(23)
313 #define GB_I2S_MGMT_SPATIAL_LOCATION_BC                 BIT(24)
314 #define GB_I2S_MGMT_SPATIAL_LOCATION_BLC                BIT(25)
315 #define GB_I2S_MGMT_SPATIAL_LOCATION_BRC                BIT(26)
316 #define GB_I2S_MGMT_SPATIAL_LOCATION_RD                 BIT(31)
317
318 #define GB_I2S_MGMT_PROTOCOL_PCM                        BIT(0)
319 #define GB_I2S_MGMT_PROTOCOL_I2S                        BIT(1)
320 #define GB_I2S_MGMT_PROTOCOL_LR_STEREO                  BIT(2)
321
322 #define GB_I2S_MGMT_ROLE_MASTER                         BIT(0)
323 #define GB_I2S_MGMT_ROLE_SLAVE                          BIT(1)
324
325 #define GB_I2S_MGMT_POLARITY_NORMAL                     BIT(0)
326 #define GB_I2S_MGMT_POLARITY_REVERSED                   BIT(1)
327
328 #define GB_I2S_MGMT_EDGE_RISING                         BIT(0)
329 #define GB_I2S_MGMT_EDGE_FALLING                        BIT(1)
330
331 #define GB_I2S_MGMT_EVENT_UNSPECIFIED                   0x1
332 #define GB_I2S_MGMT_EVENT_HALT                          0x2
333 #define GB_I2S_MGMT_EVENT_INTERNAL_ERROR                0x3
334 #define GB_I2S_MGMT_EVENT_PROTOCOL_ERROR                0x4
335 #define GB_I2S_MGMT_EVENT_FAILURE                       0x5
336 #define GB_I2S_MGMT_EVENT_OUT_OF_SEQUENCE               0x6
337 #define GB_I2S_MGMT_EVENT_UNDERRUN                      0x7
338 #define GB_I2S_MGMT_EVENT_OVERRUN                       0x8
339 #define GB_I2S_MGMT_EVENT_CLOCKING                      0x9
340 #define GB_I2S_MGMT_EVENT_DATA_LEN                      0xa
341
342 struct gb_i2s_mgmt_configuration {
343         __le32  sample_frequency;
344         __u8    num_channels;
345         __u8    bytes_per_channel;
346         __u8    byte_order;
347         __u8    pad;
348         __le32  spatial_locations;
349         __le32  ll_protocol;
350         __u8    ll_bclk_role;
351         __u8    ll_wclk_role;
352         __u8    ll_wclk_polarity;
353         __u8    ll_wclk_change_edge;
354         __u8    ll_wclk_tx_edge;
355         __u8    ll_wclk_rx_edge;
356         __u8    ll_data_offset;
357         __u8    ll_pad;
358 };
359
360 /* get supported configurations request has no payload */
361 struct gb_i2s_mgmt_get_supported_configurations_response {
362         __u8                                    config_count;
363         __u8                                    pad[3];
364         struct gb_i2s_mgmt_configuration        config[0];
365 };
366
367 struct gb_i2s_mgmt_set_configuration_request {
368         struct gb_i2s_mgmt_configuration        config;
369 };
370 /* set configuration response has no payload */
371
372 struct gb_i2s_mgmt_set_samples_per_message_request {
373         __le16  samples_per_message;
374 };
375 /* set samples per message response has no payload */
376
377 /* get processing request delay has no payload */
378 struct gb_i2s_mgmt_get_processing_delay_response {
379         __le32  microseconds;
380 };
381
382 struct gb_i2s_mgmt_set_start_delay_request {
383         __le32  microseconds;
384 };
385 /* set start delay response has no payload */
386
387 struct gb_i2s_mgmt_activate_cport_request {
388         __le16  cport;
389 };
390 /* activate cport response has no payload */
391
392 struct gb_i2s_mgmt_deactivate_cport_request {
393         __le16  cport;
394 };
395 /* deactivate cport response has no payload */
396
397 struct gb_i2s_mgmt_report_event_request {
398         __u8    event;
399 };
400 /* report event response has no payload */
401
402 #define GB_I2S_DATA_TYPE_PROTOCOL_VERSION               0x01
403 #define GB_I2S_DATA_TYPE_SEND_DATA                      0x02
404
405 struct gb_i2s_send_data_request {
406         __le32  sample_number;
407         __le32  size;
408         __u8    data[0];
409 };
410 /* send data has no response at all */
411
412 #endif /* __GB_GPBRIDGE_H__ */