forked from projectara/greybus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
greybus_protocols.h
1858 lines (1576 loc) · 51.5 KB
/
greybus_protocols.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
* Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details.
*
* BSD LICENSE
*
* Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
* Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. or Linaro Ltd. nor the names of
* its contributors may be used to endorse or promote products
* derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
* LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __GREYBUS_PROTOCOLS_H
#define __GREYBUS_PROTOCOLS_H
/* Fixed IDs for control/svc protocols */
/* SVC switch-port device ids */
#define GB_SVC_DEVICE_ID_SVC 0
#define GB_SVC_DEVICE_ID_AP 1
#define GB_SVC_DEVICE_ID_MIN 2
#define GB_SVC_DEVICE_ID_MAX 31
#define GB_SVC_CPORT_ID 0
#define GB_CONTROL_BUNDLE_ID 0
#define GB_CONTROL_CPORT_ID 0
/*
* All operation messages (both requests and responses) begin with
* a header that encodes the size of the message (header included).
* This header also contains a unique identifier, that associates a
* response message with its operation. The header contains an
* operation type field, whose interpretation is dependent on what
* type of protocol is used over the connection. The high bit
* (0x80) of the operation type field is used to indicate whether
* the message is a request (clear) or a response (set).
*
* Response messages include an additional result byte, which
* communicates the result of the corresponding request. A zero
* result value means the operation completed successfully. Any
* other value indicates an error; in this case, the payload of the
* response message (if any) is ignored. The result byte must be
* zero in the header for a request message.
*
* The wire format for all numeric fields in the header is little
* endian. Any operation-specific data begins immediately after the
* header.
*/
struct gb_operation_msg_hdr {
__le16 size; /* Size in bytes of header + payload */
__le16 operation_id; /* Operation unique id */
__u8 type; /* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */
__u8 result; /* Result of request (in responses only) */
__u8 pad[2]; /* must be zero (ignore when read) */
} __packed;
/* Generic request numbers supported by all modules */
#define GB_REQUEST_TYPE_INVALID 0x00
#define GB_REQUEST_TYPE_PROTOCOL_VERSION 0x01
struct gb_protocol_version_request {
__u8 major;
__u8 minor;
} __packed;
struct gb_protocol_version_response {
__u8 major;
__u8 minor;
} __packed;
/* Control Protocol */
/* Greybus control request types */
#define GB_CONTROL_TYPE_VERSION 0x01
#define GB_CONTROL_TYPE_PROBE_AP 0x02
#define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03
#define GB_CONTROL_TYPE_GET_MANIFEST 0x04
#define GB_CONTROL_TYPE_CONNECTED 0x05
#define GB_CONTROL_TYPE_DISCONNECTED 0x06
#define GB_CONTROL_TYPE_TIMESYNC_ENABLE 0x07
#define GB_CONTROL_TYPE_TIMESYNC_DISABLE 0x08
#define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE 0x09
#define GB_CONTROL_TYPE_INTERFACE_VERSION 0x0a
#define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b
struct gb_control_version_request {
__u8 major;
__u8 minor;
} __packed;
struct gb_control_version_response {
__u8 major;
__u8 minor;
} __packed;
struct gb_control_bundle_version_request {
__u8 bundle_id;
} __packed;
struct gb_control_bundle_version_response {
__u8 major;
__u8 minor;
} __packed;
/* Control protocol manifest get size request has no payload*/
struct gb_control_get_manifest_size_response {
__le16 size;
} __packed;
/* Control protocol manifest get request has no payload */
struct gb_control_get_manifest_response {
__u8 data[0];
} __packed;
/* Control protocol [dis]connected request */
struct gb_control_connected_request {
__le16 cport_id;
} __packed;
struct gb_control_disconnected_request {
__le16 cport_id;
} __packed;
/* Control protocol [dis]connected response has no payload */
/* Control protocol interface version request has no payload */
struct gb_control_interface_version_response {
__le16 major;
__le16 minor;
} __packed;
#define GB_TIMESYNC_MAX_STROBES 0x04
struct gb_control_timesync_enable_request {
__u8 count;
__le64 frame_time;
__le32 strobe_delay;
__le32 refclk;
} __packed;
/* timesync enable response has no payload */
struct gb_control_timesync_authoritative_request {
__u64 frame_time[GB_TIMESYNC_MAX_STROBES];
} __packed;
/* timesync authoritative response has no payload */
/* APBridge protocol */
/* request APB1 log */
#define GB_APB_REQUEST_LOG 0x02
/* request to map a cport to bulk in and bulk out endpoints */
#define GB_APB_REQUEST_EP_MAPPING 0x03
/* request to get the number of cports available */
#define GB_APB_REQUEST_CPORT_COUNT 0x04
/* request to reset a cport state */
#define GB_APB_REQUEST_RESET_CPORT 0x05
/* request to time the latency of messages on a given cport */
#define GB_APB_REQUEST_LATENCY_TAG_EN 0x06
#define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07
/* request to control the CSI transmitter */
#define GB_APB_REQUEST_CSI_TX_CONTROL 0x08
/* request to control the CSI transmitter */
#define GB_APB_REQUEST_AUDIO_CONTROL 0x09
/* vendor requests to enable/disable CPort features */
#define GB_APB_REQUEST_CPORT_FEAT_EN 0x0b
#define GB_APB_REQUEST_CPORT_FEAT_DIS 0x0c
/* Firmware Protocol */
/* Version of the Greybus firmware protocol we support */
#define GB_FIRMWARE_VERSION_MAJOR 0x00
#define GB_FIRMWARE_VERSION_MINOR 0x01
/* Greybus firmware request types */
#define GB_FIRMWARE_TYPE_VERSION 0x01
#define GB_FIRMWARE_TYPE_FIRMWARE_SIZE 0x02
#define GB_FIRMWARE_TYPE_GET_FIRMWARE 0x03
#define GB_FIRMWARE_TYPE_READY_TO_BOOT 0x04
#define GB_FIRMWARE_TYPE_AP_READY 0x05 /* Request with no-payload */
#define GB_FIRMWARE_TYPE_GET_VID_PID 0x06 /* Request with no-payload */
/* Greybus firmware boot stages */
#define GB_FIRMWARE_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */
#define GB_FIRMWARE_BOOT_STAGE_TWO 0x02 /* Firmware package to be loaded by the boot ROM */
#define GB_FIRMWARE_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */
/* Greybus firmware ready to boot status */
#define GB_FIRMWARE_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */
#define GB_FIRMWARE_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */
#define GB_FIRMWARE_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */
/* Max firmware data fetch size in bytes */
#define GB_FIRMWARE_FETCH_MAX 2000
struct gb_firmware_version_request {
__u8 major;
__u8 minor;
} __packed;
struct gb_firmware_version_response {
__u8 major;
__u8 minor;
} __packed;
/* Firmware protocol firmware size request/response */
struct gb_firmware_size_request {
__u8 stage;
} __packed;
struct gb_firmware_size_response {
__le32 size;
} __packed;
/* Firmware protocol get firmware request/response */
struct gb_firmware_get_firmware_request {
__le32 offset;
__le32 size;
} __packed;
struct gb_firmware_get_firmware_response {
__u8 data[0];
} __packed;
/* Firmware protocol Ready to boot request */
struct gb_firmware_ready_to_boot_request {
__u8 status;
} __packed;
/* Firmware protocol Ready to boot response has no payload */
/* Firmware protocol get VID/PID request has no payload */
struct gb_firmware_get_vid_pid_response {
__le32 vendor_id;
__le32 product_id;
} __packed;
/* Power Supply */
/* Version of the Greybus power supply protocol we support */
#define GB_POWER_SUPPLY_VERSION_MAJOR 0x00
#define GB_POWER_SUPPLY_VERSION_MINOR 0x01
/* Greybus power supply request types */
#define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02
#define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03
#define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04
#define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05
#define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06
#define GB_POWER_SUPPLY_TYPE_EVENT 0x07
/* Should match up with battery technologies in linux/power_supply.h */
#define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000
#define GB_POWER_SUPPLY_TECH_NiMH 0x0001
#define GB_POWER_SUPPLY_TECH_LION 0x0002
#define GB_POWER_SUPPLY_TECH_LIPO 0x0003
#define GB_POWER_SUPPLY_TECH_LiFe 0x0004
#define GB_POWER_SUPPLY_TECH_NiCd 0x0005
#define GB_POWER_SUPPLY_TECH_LiMn 0x0006
/* Should match up with power supply types in linux/power_supply.h */
#define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000
#define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001
#define GB_POWER_SUPPLY_UPS_TYPE 0x0002
#define GB_POWER_SUPPLY_MAINS_TYPE 0x0003
#define GB_POWER_SUPPLY_USB_TYPE 0x0004
#define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005
#define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006
#define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007
/* Should match up with power supply health in linux/power_supply.h */
#define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000
#define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001
#define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002
#define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003
#define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004
#define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005
#define GB_POWER_SUPPLY_HEALTH_COLD 0x0006
#define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007
#define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008
/* Should match up with battery status in linux/power_supply.h */
#define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000
#define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001
#define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002
#define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003
#define GB_POWER_SUPPLY_STATUS_FULL 0x0004
struct gb_power_supply_get_supplies_response {
__u8 supplies_count;
} __packed;
struct gb_power_supply_get_description_request {
__u8 psy_id;
} __packed;
struct gb_power_supply_get_description_response {
__u8 manufacturer[32];
__u8 model[32];
__u8 serial_number[32];
__le16 type;
__u8 properties_count;
} __packed;
struct gb_power_supply_props_desc {
__u8 property;
#define GB_POWER_SUPPLY_PROP_STATUS 0x00
#define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01
#define GB_POWER_SUPPLY_PROP_HEALTH 0x02
#define GB_POWER_SUPPLY_PROP_PRESENT 0x03
#define GB_POWER_SUPPLY_PROP_ONLINE 0x04
#define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05
#define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06
#define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07
#define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08
#define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09
#define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A
#define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B
#define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C
#define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D
#define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E
#define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F
#define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10
#define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11
#define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12
#define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13
#define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14
#define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15
#define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16
#define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17
#define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18
#define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19
#define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A
#define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B
#define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C
#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D
#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E
#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F
#define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20
#define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21
#define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22
#define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23
#define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24
#define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25
#define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26
#define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27
#define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28
#define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29
#define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A
#define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B
#define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C
#define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D
#define GB_POWER_SUPPLY_PROP_TEMP 0x2E
#define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F
#define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30
#define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31
#define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32
#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33
#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34
#define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35
#define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36
#define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37
#define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38
#define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39
#define GB_POWER_SUPPLY_PROP_TYPE 0x3A
#define GB_POWER_SUPPLY_PROP_SCOPE 0x3B
#define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C
#define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D
__u8 is_writeable;
} __packed;
struct gb_power_supply_get_property_descriptors_request {
__u8 psy_id;
} __packed;
struct gb_power_supply_get_property_descriptors_response {
__u8 properties_count;
struct gb_power_supply_props_desc props[];
} __packed;
struct gb_power_supply_get_property_request {
__u8 psy_id;
__u8 property;
} __packed;
struct gb_power_supply_get_property_response {
__le32 prop_val;
};
struct gb_power_supply_set_property_request {
__u8 psy_id;
__u8 property;
__le32 prop_val;
} __packed;
struct gb_power_supply_event_request {
__u8 psy_id;
__u8 event;
#define GB_POWER_SUPPLY_UPDATE 0x01
} __packed;
/* HID */
/* Version of the Greybus hid protocol we support */
#define GB_HID_VERSION_MAJOR 0x00
#define GB_HID_VERSION_MINOR 0x01
/* Greybus HID operation types */
#define GB_HID_TYPE_GET_DESC 0x02
#define GB_HID_TYPE_GET_REPORT_DESC 0x03
#define GB_HID_TYPE_PWR_ON 0x04
#define GB_HID_TYPE_PWR_OFF 0x05
#define GB_HID_TYPE_GET_REPORT 0x06
#define GB_HID_TYPE_SET_REPORT 0x07
#define GB_HID_TYPE_IRQ_EVENT 0x08
/* Report type */
#define GB_HID_INPUT_REPORT 0
#define GB_HID_OUTPUT_REPORT 1
#define GB_HID_FEATURE_REPORT 2
/* Different request/response structures */
/* HID get descriptor response */
struct gb_hid_desc_response {
__u8 bLength;
__le16 wReportDescLength;
__le16 bcdHID;
__le16 wProductID;
__le16 wVendorID;
__u8 bCountryCode;
} __packed;
/* HID get report request/response */
struct gb_hid_get_report_request {
__u8 report_type;
__u8 report_id;
} __packed;
/* HID set report request */
struct gb_hid_set_report_request {
__u8 report_type;
__u8 report_id;
__u8 report[0];
} __packed;
/* HID input report request, via interrupt pipe */
struct gb_hid_input_report_request {
__u8 report[0];
} __packed;
/* I2C */
/* Version of the Greybus i2c protocol we support */
#define GB_I2C_VERSION_MAJOR 0x00
#define GB_I2C_VERSION_MINOR 0x01
/* Greybus i2c request types */
#define GB_I2C_TYPE_FUNCTIONALITY 0x02
#define GB_I2C_TYPE_TRANSFER 0x05
/* functionality request has no payload */
struct gb_i2c_functionality_response {
__le32 functionality;
} __packed;
/*
* Outgoing data immediately follows the op count and ops array.
* The data for each write (master -> slave) op in the array is sent
* in order, with no (e.g. pad) bytes separating them.
*
* Short reads cause the entire transfer request to fail So response
* payload consists only of bytes read, and the number of bytes is
* exactly what was specified in the corresponding op. Like
* outgoing data, the incoming data is in order and contiguous.
*/
struct gb_i2c_transfer_op {
__le16 addr;
__le16 flags;
__le16 size;
} __packed;
struct gb_i2c_transfer_request {
__le16 op_count;
struct gb_i2c_transfer_op ops[0]; /* op_count of these */
} __packed;
struct gb_i2c_transfer_response {
__u8 data[0]; /* inbound data */
} __packed;
/* GPIO */
/* Version of the Greybus GPIO protocol we support */
#define GB_GPIO_VERSION_MAJOR 0x00
#define GB_GPIO_VERSION_MINOR 0x01
/* Greybus GPIO request types */
#define GB_GPIO_TYPE_LINE_COUNT 0x02
#define GB_GPIO_TYPE_ACTIVATE 0x03
#define GB_GPIO_TYPE_DEACTIVATE 0x04
#define GB_GPIO_TYPE_GET_DIRECTION 0x05
#define GB_GPIO_TYPE_DIRECTION_IN 0x06
#define GB_GPIO_TYPE_DIRECTION_OUT 0x07
#define GB_GPIO_TYPE_GET_VALUE 0x08
#define GB_GPIO_TYPE_SET_VALUE 0x09
#define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a
#define GB_GPIO_TYPE_IRQ_TYPE 0x0b
#define GB_GPIO_TYPE_IRQ_MASK 0x0c
#define GB_GPIO_TYPE_IRQ_UNMASK 0x0d
#define GB_GPIO_TYPE_IRQ_EVENT 0x0e
#define GB_GPIO_IRQ_TYPE_NONE 0x00
#define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01
#define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
#define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
#define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
#define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
/* line count request has no payload */
struct gb_gpio_line_count_response {
__u8 count;
} __packed;
struct gb_gpio_activate_request {
__u8 which;
} __packed;
/* activate response has no payload */
struct gb_gpio_deactivate_request {
__u8 which;
} __packed;
/* deactivate response has no payload */
struct gb_gpio_get_direction_request {
__u8 which;
} __packed;
struct gb_gpio_get_direction_response {
__u8 direction;
} __packed;
struct gb_gpio_direction_in_request {
__u8 which;
} __packed;
/* direction in response has no payload */
struct gb_gpio_direction_out_request {
__u8 which;
__u8 value;
} __packed;
/* direction out response has no payload */
struct gb_gpio_get_value_request {
__u8 which;
} __packed;
struct gb_gpio_get_value_response {
__u8 value;
} __packed;
struct gb_gpio_set_value_request {
__u8 which;
__u8 value;
} __packed;
/* set value response has no payload */
struct gb_gpio_set_debounce_request {
__u8 which;
__le16 usec;
} __packed;
/* debounce response has no payload */
struct gb_gpio_irq_type_request {
__u8 which;
__u8 type;
} __packed;
/* irq type response has no payload */
struct gb_gpio_irq_mask_request {
__u8 which;
} __packed;
/* irq mask response has no payload */
struct gb_gpio_irq_unmask_request {
__u8 which;
} __packed;
/* irq unmask response has no payload */
/* irq event requests originate on another module and are handled on the AP */
struct gb_gpio_irq_event_request {
__u8 which;
} __packed;
/* irq event has no response */
/* PWM */
/* Version of the Greybus PWM protocol we support */
#define GB_PWM_VERSION_MAJOR 0x00
#define GB_PWM_VERSION_MINOR 0x01
/* Greybus PWM operation types */
#define GB_PWM_TYPE_PWM_COUNT 0x02
#define GB_PWM_TYPE_ACTIVATE 0x03
#define GB_PWM_TYPE_DEACTIVATE 0x04
#define GB_PWM_TYPE_CONFIG 0x05
#define GB_PWM_TYPE_POLARITY 0x06
#define GB_PWM_TYPE_ENABLE 0x07
#define GB_PWM_TYPE_DISABLE 0x08
/* pwm count request has no payload */
struct gb_pwm_count_response {
__u8 count;
} __packed;
struct gb_pwm_activate_request {
__u8 which;
} __packed;
struct gb_pwm_deactivate_request {
__u8 which;
} __packed;
struct gb_pwm_config_request {
__u8 which;
__le32 duty;
__le32 period;
} __packed;
struct gb_pwm_polarity_request {
__u8 which;
__u8 polarity;
} __packed;
struct gb_pwm_enable_request {
__u8 which;
} __packed;
struct gb_pwm_disable_request {
__u8 which;
} __packed;
/* SPI */
/* Version of the Greybus spi protocol we support */
#define GB_SPI_VERSION_MAJOR 0x00
#define GB_SPI_VERSION_MINOR 0x01
/* Should match up with modes in linux/spi/spi.h */
#define GB_SPI_MODE_CPHA 0x01 /* clock phase */
#define GB_SPI_MODE_CPOL 0x02 /* clock polarity */
#define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */
#define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA)
#define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0)
#define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA)
#define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */
#define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */
#define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */
#define GB_SPI_MODE_LOOP 0x20 /* loopback mode */
#define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */
#define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */
/* Should match up with flags in linux/spi/spi.h */
#define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */
#define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */
#define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */
/* Greybus spi operation types */
#define GB_SPI_TYPE_MASTER_CONFIG 0x02
#define GB_SPI_TYPE_DEVICE_CONFIG 0x03
#define GB_SPI_TYPE_TRANSFER 0x04
/* mode request has no payload */
struct gb_spi_master_config_response {
__le32 bits_per_word_mask;
__le32 min_speed_hz;
__le32 max_speed_hz;
__le16 mode;
__le16 flags;
__u8 num_chipselect;
} __packed;
struct gb_spi_device_config_request {
__u8 chip_select;
} __packed;
struct gb_spi_device_config_response {
__le16 mode;
__u8 bits_per_word;
__le32 max_speed_hz;
__u8 device_type;
#define GB_SPI_SPI_DEV 0x00
#define GB_SPI_SPI_NOR 0x01
#define GB_SPI_SPI_MODALIAS 0x02
__u8 name[32];
} __packed;
/**
* struct gb_spi_transfer - a read/write buffer pair
* @speed_hz: Select a speed other than the device default for this transfer. If
* 0 the default (from @spi_device) is used.
* @len: size of rx and tx buffers (in bytes)
* @delay_usecs: microseconds to delay after this transfer before (optionally)
* changing the chipselect status, then starting the next transfer or
* completing this spi_message.
* @cs_change: affects chipselect after this transfer completes
* @bits_per_word: select a bits_per_word other than the device default for this
* transfer. If 0 the default (from @spi_device) is used.
*/
struct gb_spi_transfer {
__le32 speed_hz;
__le32 len;
__le16 delay_usecs;
__u8 cs_change;
__u8 bits_per_word;
__u8 rdwr;
#define GB_SPI_XFER_READ 0x01
#define GB_SPI_XFER_WRITE 0x02
} __packed;
struct gb_spi_transfer_request {
__u8 chip_select; /* of the spi device */
__u8 mode; /* of the spi device */
__le16 count;
struct gb_spi_transfer transfers[0]; /* count of these */
} __packed;
struct gb_spi_transfer_response {
__u8 data[0]; /* inbound data */
} __packed;
/* Version of the Greybus SVC protocol we support */
#define GB_SVC_VERSION_MAJOR 0x00
#define GB_SVC_VERSION_MINOR 0x01
/* Greybus SVC request types */
#define GB_SVC_TYPE_SVC_HELLO 0x02
#define GB_SVC_TYPE_INTF_DEVICE_ID 0x03
#define GB_SVC_TYPE_INTF_HOTPLUG 0x04
#define GB_SVC_TYPE_INTF_HOT_UNPLUG 0x05
#define GB_SVC_TYPE_INTF_RESET 0x06
#define GB_SVC_TYPE_CONN_CREATE 0x07
#define GB_SVC_TYPE_CONN_DESTROY 0x08
#define GB_SVC_TYPE_DME_PEER_GET 0x09
#define GB_SVC_TYPE_DME_PEER_SET 0x0a
#define GB_SVC_TYPE_ROUTE_CREATE 0x0b
#define GB_SVC_TYPE_ROUTE_DESTROY 0x0c
#define GB_SVC_TYPE_TIMESYNC_ENABLE 0x0d
#define GB_SVC_TYPE_TIMESYNC_DISABLE 0x0e
#define GB_SVC_TYPE_TIMESYNC_AUTHORITATIVE 0x0f
#define GB_SVC_TYPE_INTF_SET_PWRM 0x10
#define GB_SVC_TYPE_INTF_EJECT 0x11
#define GB_SVC_TYPE_KEY_EVENT 0x12
#define GB_SVC_TYPE_PING 0x13
/*
* SVC version request/response has the same payload as
* gb_protocol_version_request/response.
*/
/* SVC protocol hello request */
struct gb_svc_hello_request {
__le16 endo_id;
__u8 interface_id;
} __packed;
/* hello response has no payload */
struct gb_svc_intf_device_id_request {
__u8 intf_id;
__u8 device_id;
} __packed;
/* device id response has no payload */
struct gb_svc_intf_hotplug_request {
__u8 intf_id;
struct {
__le32 ddbl1_mfr_id;
__le32 ddbl1_prod_id;
__le32 ara_vend_id;
__le32 ara_prod_id;
__le64 serial_number;
} data;
} __packed;
/* hotplug response has no payload */
struct gb_svc_intf_hot_unplug_request {
__u8 intf_id;
} __packed;
/* hot unplug response has no payload */
struct gb_svc_intf_reset_request {
__u8 intf_id;
} __packed;
/* interface reset response has no payload */
struct gb_svc_intf_eject_request {
__u8 intf_id;
} __packed;
/* interface eject response has no payload */
struct gb_svc_conn_create_request {
__u8 intf1_id;
__le16 cport1_id;
__u8 intf2_id;
__le16 cport2_id;
__u8 tc;
__u8 flags;
} __packed;
/* connection create response has no payload */
struct gb_svc_conn_destroy_request {
__u8 intf1_id;
__le16 cport1_id;
__u8 intf2_id;
__le16 cport2_id;
} __packed;
/* connection destroy response has no payload */
struct gb_svc_dme_peer_get_request {
__u8 intf_id;
__le16 attr;
__le16 selector;
} __packed;
struct gb_svc_dme_peer_get_response {
__le16 result_code;
__le32 attr_value;
} __packed;
struct gb_svc_dme_peer_set_request {
__u8 intf_id;
__le16 attr;
__le16 selector;
__le32 value;
} __packed;
struct gb_svc_dme_peer_set_response {
__le16 result_code;
} __packed;
/* Greybus init-status values, currently retrieved using DME peer gets. */
#define GB_INIT_SPI_BOOT_STARTED 0x02
#define GB_INIT_TRUSTED_SPI_BOOT_FINISHED 0x03
#define GB_INIT_UNTRUSTED_SPI_BOOT_FINISHED 0x04
#define GB_INIT_BOOTROM_UNIPRO_BOOT_STARTED 0x06
#define GB_INIT_BOOTROM_FALLBACK_UNIPRO_BOOT_STARTED 0x09
struct gb_svc_route_create_request {
__u8 intf1_id;
__u8 dev1_id;
__u8 intf2_id;
__u8 dev2_id;
} __packed;
/* route create response has no payload */
struct gb_svc_route_destroy_request {
__u8 intf1_id;
__u8 intf2_id;
} __packed;
/* route destroy response has no payload */
struct gb_svc_timesync_enable_request {
__u8 count;
__u64 frame_time;
__u32 strobe_delay;
__u32 strobe_mask;
__u32 refclk;
} __packed;
/* timesync enable response has no payload */
/* timesync authoritative request has no payload */
struct gb_svc_timesync_authoritative_response {
__u64 frame_time[GB_TIMESYNC_MAX_STROBES];
};
#define GB_SVC_UNIPRO_FAST_MODE 0x01
#define GB_SVC_UNIPRO_SLOW_MODE 0x02
#define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04
#define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05
#define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07
#define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11
#define GB_SVC_UNIPRO_OFF_MODE 0x12
#define GB_SVC_PWRM_RXTERMINATION 0x01
#define GB_SVC_PWRM_TXTERMINATION 0x02
#define GB_SVC_PWRM_LINE_RESET 0x04
#define GB_SVC_PWRM_SCRAMBLING 0x20
#define GB_SVC_PWRM_QUIRK_HSSER 0x00000001
#define GB_SVC_UNIPRO_HS_SERIES_A 0x01
#define GB_SVC_UNIPRO_HS_SERIES_B 0x02
struct gb_svc_intf_set_pwrm_request {
__u8 intf_id;
__u8 hs_series;
__u8 tx_mode;
__u8 tx_gear;
__u8 tx_nlanes;
__u8 rx_mode;
__u8 rx_gear;
__u8 rx_nlanes;
__u8 flags;
__le32 quirks;
} __packed;
struct gb_svc_intf_set_pwrm_response {
__le16 result_code;
} __packed;
struct gb_svc_key_event_request {
__le16 key_code;
#define GB_KEYCODE_ARA 0x00
__u8 key_event;
#define GB_SVC_KEY_RELEASED 0x00
#define GB_SVC_KEY_PRESSED 0x01
} __packed;
/* RAW */
/* Version of the Greybus raw protocol we support */
#define GB_RAW_VERSION_MAJOR 0x00
#define GB_RAW_VERSION_MINOR 0x01
/* Greybus raw request types */
#define GB_RAW_TYPE_SEND 0x02
struct gb_raw_send_request {
__le32 len;
__u8 data[0];
} __packed;
/* UART */
/* Version of the Greybus UART protocol we support */
#define GB_UART_VERSION_MAJOR 0x00
#define GB_UART_VERSION_MINOR 0x01
/* Greybus UART operation types */
#define GB_UART_TYPE_SEND_DATA 0x02
#define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */
#define GB_UART_TYPE_SET_LINE_CODING 0x04
#define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
#define GB_UART_TYPE_SEND_BREAK 0x06
#define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
/* Represents data from AP -> Module */
struct gb_uart_send_data_request {
__le16 size;
__u8 data[0];
} __packed;