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.
7 * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
8 * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
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.
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.
21 * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
22 * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
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
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
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.
52 #ifndef __GB_GPBRIDGE_H__
53 #define __GB_GPBRIDGE_H__
57 /* Version of the Greybus i2c protocol we support */
58 #define GB_I2C_VERSION_MAJOR 0x00
59 #define GB_I2C_VERSION_MINOR 0x01
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 */
70 #define GB_I2C_RETRIES_DEFAULT 3
71 #define GB_I2C_TIMEOUT_DEFAULT 1000 /* milliseconds */
73 /* functionality request has no payload */
74 struct gb_i2c_functionality_response {
78 struct gb_i2c_timeout_request {
81 /* timeout response has no payload */
83 struct gb_i2c_retries_request {
86 /* retries response has no payload */
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.
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.
98 struct gb_i2c_transfer_op {
104 struct gb_i2c_transfer_request {
106 struct gb_i2c_transfer_op ops[0]; /* op_count of these */
108 struct gb_i2c_transfer_response {
109 __u8 data[0]; /* inbound data */
115 /* Version of the Greybus GPIO protocol we support */
116 #define GB_GPIO_VERSION_MAJOR 0x00
117 #define GB_GPIO_VERSION_MINOR 0x01
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 */
138 #define GB_GPIO_DEBOUNCE_USEC_DEFAULT 0 /* microseconds */
140 /* line count request has no payload */
141 struct gb_gpio_line_count_response {
145 struct gb_gpio_activate_request {
148 /* activate response has no payload */
150 struct gb_gpio_deactivate_request {
153 /* deactivate response has no payload */
155 struct gb_gpio_get_direction_request {
158 struct gb_gpio_get_direction_response {
162 struct gb_gpio_direction_in_request {
165 /* direction in response has no payload */
167 struct gb_gpio_direction_out_request {
171 /* direction out response has no payload */
173 struct gb_gpio_get_value_request {
176 struct gb_gpio_get_value_response {
180 struct gb_gpio_set_value_request {
184 /* set value response has no payload */
186 struct gb_gpio_set_debounce_request {
188 __le16 usec __packed;
190 /* debounce response has no payload */
192 struct gb_gpio_irq_type_request {
196 /* irq type response has no payload */
198 struct gb_gpio_irq_mask_request {
201 /* irq mask response has no payload */
203 struct gb_gpio_irq_unmask_request {
206 /* irq unmask response has no payload */
208 struct gb_gpio_irq_ack_request {
211 /* irq ack response has no payload */
213 /* irq event requests originate on another module and are handled on the AP */
214 struct gb_gpio_irq_event_request {
217 /* irq event response has no payload */
222 /* Version of the Greybus PWM protocol we support */
223 #define GB_PWM_VERSION_MAJOR 0x00
224 #define GB_PWM_VERSION_MINOR 0x01
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 */
238 /* pwm count request has no payload */
239 struct gb_pwm_count_response {
243 struct gb_pwm_activate_request {
247 struct gb_pwm_deactivate_request {
251 struct gb_pwm_config_request {
253 __le32 duty __packed;
254 __le32 period __packed;
257 struct gb_pwm_polarity_request {
262 struct gb_pwm_enable_request {
266 struct gb_pwm_disable_request {
272 #define BIT(n) (1UL << (n))
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
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)
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)
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)
322 #define GB_I2S_MGMT_ROLE_MASTER BIT(0)
323 #define GB_I2S_MGMT_ROLE_SLAVE BIT(1)
325 #define GB_I2S_MGMT_POLARITY_NORMAL BIT(0)
326 #define GB_I2S_MGMT_POLARITY_REVERSED BIT(1)
328 #define GB_I2S_MGMT_EDGE_RISING BIT(0)
329 #define GB_I2S_MGMT_EDGE_FALLING BIT(1)
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
342 struct gb_i2s_mgmt_configuration {
343 __le32 sample_frequency;
345 __u8 bytes_per_channel;
348 __le32 spatial_locations;
352 __u8 ll_wclk_polarity;
353 __u8 ll_wclk_change_edge;
354 __u8 ll_wclk_tx_edge;
355 __u8 ll_wclk_rx_edge;
360 /* get supported configurations request has no payload */
361 struct gb_i2s_mgmt_get_supported_configurations_response {
364 struct gb_i2s_mgmt_configuration config[0];
367 struct gb_i2s_mgmt_set_configuration_request {
368 struct gb_i2s_mgmt_configuration config;
370 /* set configuration response has no payload */
372 struct gb_i2s_mgmt_set_samples_per_message_request {
373 __le16 samples_per_message;
375 /* set samples per message response has no payload */
377 /* get processing request delay has no payload */
378 struct gb_i2s_mgmt_get_processing_delay_response {
382 struct gb_i2s_mgmt_set_start_delay_request {
385 /* set start delay response has no payload */
387 struct gb_i2s_mgmt_activate_cport_request {
390 /* activate cport response has no payload */
392 struct gb_i2s_mgmt_deactivate_cport_request {
395 /* deactivate cport response has no payload */
397 struct gb_i2s_mgmt_report_event_request {
400 /* report event response has no payload */
402 #define GB_I2S_DATA_TYPE_PROTOCOL_VERSION 0x01
403 #define GB_I2S_DATA_TYPE_SEND_DATA 0x02
405 struct gb_i2s_send_data_request {
406 __le32 sample_number;
410 /* send data has no response at all */
412 #endif /* __GB_GPBRIDGE_H__ */