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 { |
Matt Porter | e390b19 | 2014-10-22 02:06:08 -0400 | [diff] [blame^] | 51 | __u8 device_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | struct svc_function_unipro_link_up { |
Matt Porter | 6232b07 | 2014-10-21 22:43:31 -0400 | [diff] [blame] | 55 | __u8 module_id; |
| 56 | __u8 interface_id; |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 57 | __u8 device_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
Matt Porter | 98f4ab2 | 2014-10-21 01:52:27 -0400 | [diff] [blame] | 60 | struct svc_function_ap_device_id { |
| 61 | __u8 device_id; |
| 62 | }; |
| 63 | |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 64 | enum svc_function_management_event { |
| 65 | SVC_MANAGEMENT_SET_ROUTE = 0x00, |
| 66 | SVC_MANAGEMENT_LINK_UP = 0x01, |
Matt Porter | 98f4ab2 | 2014-10-21 01:52:27 -0400 | [diff] [blame] | 67 | SVC_MANAGEMENT_AP_DEVICE_ID = 0x02, |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | struct svc_function_unipro_management { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 71 | __u8 management_packet_type; /* enum svc_function_management_event */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 72 | union { |
| 73 | struct svc_function_unipro_set_route set_route; |
| 74 | struct svc_function_unipro_link_up link_up; |
Matt Porter | 98f4ab2 | 2014-10-21 01:52:27 -0400 | [diff] [blame] | 75 | struct svc_function_ap_device_id ap_device_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 76 | }; |
| 77 | }; |
| 78 | |
| 79 | enum svc_function_hotplug_event { |
| 80 | SVC_HOTPLUG_EVENT = 0x00, |
| 81 | SVC_HOTUNPLUG_EVENT = 0x01, |
| 82 | }; |
| 83 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 84 | /* XXX |
| 85 | * Does a hotplug come from module insertion, or from detection |
| 86 | * of each interface block (UniPro device) in a module? Assume |
| 87 | * the former for now. |
| 88 | */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 89 | struct svc_function_hotplug { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 90 | __u8 hotplug_event; /* enum svc_function_hotplug_event */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 91 | __u8 module_id; |
Greg Kroah-Hartman | 798ea88 | 2014-09-21 18:16:41 -0700 | [diff] [blame] | 92 | __u8 data[0]; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | enum svc_function_ddb_type { |
| 96 | SVC_DDB_GET = 0x00, |
| 97 | SVC_DDB_RESPONSE = 0x01, |
| 98 | }; |
| 99 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 100 | /* XXX |
| 101 | * Will only the first interface block in a module be responsible |
| 102 | * for this? If a module has two interface blocks, will both supply |
| 103 | * the same information, or will it be partitioned? For now assume |
| 104 | * it's a per-module thing. |
| 105 | */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 106 | struct svc_function_ddb_get { |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 107 | __u8 module_id; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 108 | __u8 message_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | struct svc_function_ddb_response { |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 112 | __u8 module_id; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 113 | __u8 message_id; |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 114 | __le16 descriptor_length; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 115 | __u8 ddb[0]; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | struct svc_function_ddb { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 119 | __u8 ddb_type; /* enum svc_function_ddb_type */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 120 | union { |
| 121 | struct svc_function_ddb_get ddb_get; |
| 122 | struct svc_function_ddb_response ddb_response; |
| 123 | }; |
| 124 | }; |
| 125 | |
| 126 | enum svc_function_power_type { |
| 127 | SVC_POWER_BATTERY_STATUS = 0x00, |
| 128 | SVC_POWER_BATTERY_STATUS_REQUEST = 0x01, |
| 129 | }; |
| 130 | |
| 131 | enum svc_function_battery_status { |
| 132 | SVC_BATTERY_UNKNOWN = 0x00, |
| 133 | SVC_BATTERY_CHARGING = 0x01, |
| 134 | SVC_BATTERY_DISCHARGING = 0x02, |
| 135 | SVC_BATTERY_NOT_CHARGING = 0x03, |
| 136 | SVC_BATTERY_FULL = 0x04, |
| 137 | }; |
| 138 | |
| 139 | struct svc_function_power_battery_status { |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 140 | __le16 charge_full; |
| 141 | __le16 charge_now; |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 142 | __u8 status; /* enum svc_function_battery_status */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | struct svc_function_power_battery_status_request { |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 146 | }; |
| 147 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 148 | /* XXX |
| 149 | * Each interface block carries power, so it's possible these things |
| 150 | * are associated with each UniPro device and not just the module. |
| 151 | * For now it's safe to assume it's per-module. |
| 152 | */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 153 | struct svc_function_power { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 154 | __u8 power_type; /* enum svc_function_power_type */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 155 | __u8 module_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 156 | union { |
| 157 | struct svc_function_power_battery_status status; |
| 158 | struct svc_function_power_battery_status_request request; |
| 159 | }; |
| 160 | }; |
| 161 | |
| 162 | enum svc_function_epm_command_type { |
| 163 | SVC_EPM_ENABLE = 0x00, |
| 164 | SVC_EPM_DISABLE = 0x01, |
| 165 | }; |
| 166 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 167 | /* EPM's are associated with the module */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 168 | struct svc_function_epm { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 169 | __u8 epm_command_type; /* enum svc_function_epm_command_type */ |
Greg Kroah-Hartman | d587780 | 2014-09-01 10:59:08 -0700 | [diff] [blame] | 170 | __u8 module_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | enum svc_function_suspend_command_type { |
| 174 | SVC_SUSPEND_FIXME_1 = 0x00, // FIXME |
| 175 | SVC_SUSPEND_FIXME_2 = 0x01, |
| 176 | }; |
| 177 | |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 178 | /* We'll want independent control for multi-interface block modules */ |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 179 | struct svc_function_suspend { |
Greg Kroah-Hartman | 3772f16 | 2014-09-01 09:51:33 -0700 | [diff] [blame] | 180 | __u8 suspend_command_type; /* enum function_suspend_command_type */ |
Alex Elder | 9c852d2 | 2014-09-30 19:25:22 -0500 | [diff] [blame] | 181 | __u8 device_id; |
Greg Kroah-Hartman | b9b2a46 | 2014-08-31 17:43:38 -0700 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | struct svc_msg { |
| 185 | struct svc_msg_header header; |
| 186 | union { |
| 187 | struct svc_function_handshake handshake; |
| 188 | struct svc_function_unipro_management management; |
| 189 | struct svc_function_hotplug hotplug; |
| 190 | struct svc_function_ddb ddb; |
| 191 | struct svc_function_power power; |
| 192 | struct svc_function_epm epm; |
| 193 | struct svc_function_suspend suspend; |
| 194 | }; |
| 195 | }; |
| 196 | |
Greg Kroah-Hartman | 48123e0 | 2014-09-02 10:51:56 -0700 | [diff] [blame] | 197 | #pragma pack(pop) |
| 198 | |
Greg Kroah-Hartman | 80ebe8a | 2014-08-31 18:08:52 -0700 | [diff] [blame] | 199 | #endif /* __SVC_MSG_H */ |