Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Greybus AP <-> SVC message structure format. |
| 3 | * |
Alex Elder | cb705e0 | 2014-09-24 05:16:17 -0500 | [diff] [blame] | 4 | * See "Greybus Application Protocol" document (version 0.1) for |
Alex Elder | 908a85d | 2014-09-24 05:16:16 -0500 | [diff] [blame] | 5 | * details on these values and structures. |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 6 | * |
| 7 | * Copyright 2014 Google Inc. |
Alex Elder | 908a85d | 2014-09-24 05:16:16 -0500 | [diff] [blame] | 8 | * |
Greg Kroah-Hartman | 62e120f | 2014-10-06 20:37:18 -0700 | [diff] [blame] | 9 | * Released under the GPLv2 and BSD license. |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 10 | */ |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 11 | |
| 12 | #ifndef __SVC_MSG_H |
| 13 | #define __SVC_MSG_H |
| 14 | |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 15 | #pragma pack(push, 1) |
| 16 | |
Matt Porter | 710ecb0 | 2014-09-18 15:25:41 -0400 | [diff] [blame] | 17 | enum svc_function_id { |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 18 | SVC_FUNCTION_HANDSHAKE = 0x00, |
| 19 | SVC_FUNCTION_UNIPRO_NETWORK_MANAGEMENT = 0x01, |
| 20 | SVC_FUNCTION_HOTPLUG = 0x02, |
| 21 | SVC_FUNCTION_DDB = 0x03, |
| 22 | SVC_FUNCTION_POWER = 0x04, |
| 23 | SVC_FUNCTION_EPM = 0x05, |
| 24 | SVC_FUNCTION_SUSPEND = 0x06, |
| 25 | }; |
| 26 | |
Matt Porter | 710ecb0 | 2014-09-18 15:25:41 -0400 | [diff] [blame] | 27 | enum svc_msg_type { |
| 28 | SVC_MSG_DATA = 0x00, |
| 29 | SVC_MSG_ERROR = 0xff, |
| 30 | }; |
| 31 | |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 32 | struct svc_msg_header { |
Matt Porter | 710ecb0 | 2014-09-18 15:25:41 -0400 | [diff] [blame] | 33 | __u8 function_id; /* enum svc_function_id */ |
| 34 | __u8 message_type; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 35 | __le16 payload_length; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | enum svc_function_handshake_type { |
| 39 | SVC_HANDSHAKE_SVC_HELLO = 0x00, |
| 40 | SVC_HANDSHAKE_AP_HELLO = 0x01, |
| 41 | SVC_HANDSHAKE_MODULE_HELLO = 0x02, |
| 42 | }; |
| 43 | |
| 44 | struct svc_function_handshake { |
Matt Porter | e94e171 | 2014-09-18 15:25:42 -0400 | [diff] [blame] | 45 | __u8 version_major; |
| 46 | __u8 version_minor; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 47 | __u8 handshake_type; /* enum svc_function_handshake_type */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | struct svc_function_unipro_set_route { |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 51 | __u8 source_device_id; |
Alex Elder | 1cfc667 | 2014-09-30 19:25:21 -0500 | [diff] [blame] | 52 | __u8 source_cport_id; /* bottom 8 bits */ |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 53 | __u8 destination_device_id; |
Alex Elder | 1cfc667 | 2014-09-30 19:25:21 -0500 | [diff] [blame] | 54 | __u8 destination_cport_id; /* bottom 8 bits */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | struct svc_function_unipro_link_up { |
Matt Porter | 6232b07 | 2014-10-21 22:43:31 -0400 | [diff] [blame^] | 58 | __u8 module_id; |
| 59 | __u8 interface_id; |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 60 | __u8 device_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Matt Porter | 98f4ab2 | 2014-10-21 01:52:27 -0400 | [diff] [blame] | 63 | struct svc_function_ap_device_id { |
| 64 | __u8 device_id; |
| 65 | }; |
| 66 | |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 67 | enum svc_function_management_event { |
| 68 | SVC_MANAGEMENT_SET_ROUTE = 0x00, |
| 69 | SVC_MANAGEMENT_LINK_UP = 0x01, |
Matt Porter | 98f4ab2 | 2014-10-21 01:52:27 -0400 | [diff] [blame] | 70 | SVC_MANAGEMENT_AP_DEVICE_ID = 0x02, |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | struct svc_function_unipro_management { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 74 | __u8 management_packet_type; /* enum svc_function_management_event */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 75 | union { |
| 76 | struct svc_function_unipro_set_route set_route; |
| 77 | struct svc_function_unipro_link_up link_up; |
Matt Porter | 98f4ab2 | 2014-10-21 01:52:27 -0400 | [diff] [blame] | 78 | struct svc_function_ap_device_id ap_device_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 79 | }; |
| 80 | }; |
| 81 | |
| 82 | enum svc_function_hotplug_event { |
| 83 | SVC_HOTPLUG_EVENT = 0x00, |
| 84 | SVC_HOTUNPLUG_EVENT = 0x01, |
| 85 | }; |
| 86 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 87 | /* XXX |
| 88 | * Does a hotplug come from module insertion, or from detection |
| 89 | * of each interface block (UniPro device) in a module? Assume |
| 90 | * the former for now. |
| 91 | */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 92 | struct svc_function_hotplug { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 93 | __u8 hotplug_event; /* enum svc_function_hotplug_event */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 94 | __u8 module_id; |
Greg Kroah-Hartman | 798ea88 | 2014-09-21 18:16:41 -0700 | [diff] [blame] | 95 | __u8 data[0]; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | enum svc_function_ddb_type { |
| 99 | SVC_DDB_GET = 0x00, |
| 100 | SVC_DDB_RESPONSE = 0x01, |
| 101 | }; |
| 102 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 103 | /* XXX |
| 104 | * Will only the first interface block in a module be responsible |
| 105 | * for this? If a module has two interface blocks, will both supply |
| 106 | * the same information, or will it be partitioned? For now assume |
| 107 | * it's a per-module thing. |
| 108 | */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 109 | struct svc_function_ddb_get { |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 110 | __u8 module_id; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 111 | __u8 message_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | struct svc_function_ddb_response { |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 115 | __u8 module_id; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 116 | __u8 message_id; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 117 | __le16 descriptor_length; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 118 | __u8 ddb[0]; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | struct svc_function_ddb { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 122 | __u8 ddb_type; /* enum svc_function_ddb_type */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 123 | union { |
| 124 | struct svc_function_ddb_get ddb_get; |
| 125 | struct svc_function_ddb_response ddb_response; |
| 126 | }; |
| 127 | }; |
| 128 | |
| 129 | enum svc_function_power_type { |
| 130 | SVC_POWER_BATTERY_STATUS = 0x00, |
| 131 | SVC_POWER_BATTERY_STATUS_REQUEST = 0x01, |
| 132 | }; |
| 133 | |
| 134 | enum svc_function_battery_status { |
| 135 | SVC_BATTERY_UNKNOWN = 0x00, |
| 136 | SVC_BATTERY_CHARGING = 0x01, |
| 137 | SVC_BATTERY_DISCHARGING = 0x02, |
| 138 | SVC_BATTERY_NOT_CHARGING = 0x03, |
| 139 | SVC_BATTERY_FULL = 0x04, |
| 140 | }; |
| 141 | |
| 142 | struct svc_function_power_battery_status { |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 143 | __le16 charge_full; |
| 144 | __le16 charge_now; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 145 | __u8 status; /* enum svc_function_battery_status */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | struct svc_function_power_battery_status_request { |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 151 | /* XXX |
| 152 | * Each interface block carries power, so it's possible these things |
| 153 | * are associated with each UniPro device and not just the module. |
| 154 | * For now it's safe to assume it's per-module. |
| 155 | */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 156 | struct svc_function_power { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 157 | __u8 power_type; /* enum svc_function_power_type */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 158 | __u8 module_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 159 | union { |
| 160 | struct svc_function_power_battery_status status; |
| 161 | struct svc_function_power_battery_status_request request; |
| 162 | }; |
| 163 | }; |
| 164 | |
| 165 | enum svc_function_epm_command_type { |
| 166 | SVC_EPM_ENABLE = 0x00, |
| 167 | SVC_EPM_DISABLE = 0x01, |
| 168 | }; |
| 169 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 170 | /* EPM's are associated with the module */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 171 | struct svc_function_epm { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 172 | __u8 epm_command_type; /* enum svc_function_epm_command_type */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 173 | __u8 module_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | enum svc_function_suspend_command_type { |
| 177 | SVC_SUSPEND_FIXME_1 = 0x00, // FIXME |
| 178 | SVC_SUSPEND_FIXME_2 = 0x01, |
| 179 | }; |
| 180 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 181 | /* We'll want independent control for multi-interface block modules */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 182 | struct svc_function_suspend { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 183 | __u8 suspend_command_type; /* enum function_suspend_command_type */ |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 184 | __u8 device_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | struct svc_msg { |
| 188 | struct svc_msg_header header; |
| 189 | union { |
| 190 | struct svc_function_handshake handshake; |
| 191 | struct svc_function_unipro_management management; |
| 192 | struct svc_function_hotplug hotplug; |
| 193 | struct svc_function_ddb ddb; |
| 194 | struct svc_function_power power; |
| 195 | struct svc_function_epm epm; |
| 196 | struct svc_function_suspend suspend; |
| 197 | }; |
| 198 | }; |
| 199 | |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 200 | #pragma pack(pop) |
| 201 | |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 202 | #endif /* __SVC_MSG_H */ |