diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-25 01:54:27 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-27 13:02:59 -0400 |
| commit | ec0ad868173da8a75121f9dc116a5d5478ff614d (patch) | |
| tree | 7e43809be8ee2e9f9fb8c9ed0a80de9d1c737b18 /include/linux/greybus | |
| parent | 9c31973907fb157ac91f61f479e8bf43bb43aded (diff) | |
staging: greybus: move core include files to include/linux/greybus/
With the goal of moving the core of the greybus code out of staging, the
include files need to be moved to include/linux/greybus.h and
include/linux/greybus/
Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Alex Elder <elder@kernel.org>
Link: https://lore.kernel.org/r/20190825055429.18547-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/greybus')
| -rw-r--r-- | include/linux/greybus/bundle.h | 89 | ||||
| -rw-r--r-- | include/linux/greybus/connection.h | 128 | ||||
| -rw-r--r-- | include/linux/greybus/control.h | 57 | ||||
| -rw-r--r-- | include/linux/greybus/greybus_id.h | 27 | ||||
| -rw-r--r-- | include/linux/greybus/greybus_manifest.h | 178 | ||||
| -rw-r--r-- | include/linux/greybus/greybus_protocols.h | 2176 | ||||
| -rw-r--r-- | include/linux/greybus/hd.h | 82 | ||||
| -rw-r--r-- | include/linux/greybus/interface.h | 82 | ||||
| -rw-r--r-- | include/linux/greybus/manifest.h | 15 | ||||
| -rw-r--r-- | include/linux/greybus/module.h | 33 | ||||
| -rw-r--r-- | include/linux/greybus/operation.h | 224 | ||||
| -rw-r--r-- | include/linux/greybus/svc.h | 101 |
12 files changed, 3192 insertions, 0 deletions
diff --git a/include/linux/greybus/bundle.h b/include/linux/greybus/bundle.h new file mode 100644 index 000000000000..8734d2055657 --- /dev/null +++ b/include/linux/greybus/bundle.h | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus bundles | ||
| 4 | * | ||
| 5 | * Copyright 2014 Google Inc. | ||
| 6 | * Copyright 2014 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __BUNDLE_H | ||
| 10 | #define __BUNDLE_H | ||
| 11 | |||
| 12 | #include <linux/list.h> | ||
| 13 | |||
| 14 | #define BUNDLE_ID_NONE U8_MAX | ||
| 15 | |||
| 16 | /* Greybus "public" definitions" */ | ||
| 17 | struct gb_bundle { | ||
| 18 | struct device dev; | ||
| 19 | struct gb_interface *intf; | ||
| 20 | |||
| 21 | u8 id; | ||
| 22 | u8 class; | ||
| 23 | u8 class_major; | ||
| 24 | u8 class_minor; | ||
| 25 | |||
| 26 | size_t num_cports; | ||
| 27 | struct greybus_descriptor_cport *cport_desc; | ||
| 28 | |||
| 29 | struct list_head connections; | ||
| 30 | u8 *state; | ||
| 31 | |||
| 32 | struct list_head links; /* interface->bundles */ | ||
| 33 | }; | ||
| 34 | #define to_gb_bundle(d) container_of(d, struct gb_bundle, dev) | ||
| 35 | |||
| 36 | /* Greybus "private" definitions" */ | ||
| 37 | struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, | ||
| 38 | u8 class); | ||
| 39 | int gb_bundle_add(struct gb_bundle *bundle); | ||
| 40 | void gb_bundle_destroy(struct gb_bundle *bundle); | ||
| 41 | |||
| 42 | /* Bundle Runtime PM wrappers */ | ||
| 43 | #ifdef CONFIG_PM | ||
| 44 | static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle) | ||
| 45 | { | ||
| 46 | int retval; | ||
| 47 | |||
| 48 | retval = pm_runtime_get_sync(&bundle->dev); | ||
| 49 | if (retval < 0) { | ||
| 50 | dev_err(&bundle->dev, | ||
| 51 | "pm_runtime_get_sync failed: %d\n", retval); | ||
| 52 | pm_runtime_put_noidle(&bundle->dev); | ||
| 53 | return retval; | ||
| 54 | } | ||
| 55 | |||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | |||
| 59 | static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle) | ||
| 60 | { | ||
| 61 | int retval; | ||
| 62 | |||
| 63 | pm_runtime_mark_last_busy(&bundle->dev); | ||
| 64 | retval = pm_runtime_put_autosuspend(&bundle->dev); | ||
| 65 | |||
| 66 | return retval; | ||
| 67 | } | ||
| 68 | |||
| 69 | static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) | ||
| 70 | { | ||
| 71 | pm_runtime_get_noresume(&bundle->dev); | ||
| 72 | } | ||
| 73 | |||
| 74 | static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) | ||
| 75 | { | ||
| 76 | pm_runtime_put_noidle(&bundle->dev); | ||
| 77 | } | ||
| 78 | |||
| 79 | #else | ||
| 80 | static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle) | ||
| 81 | { return 0; } | ||
| 82 | static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle) | ||
| 83 | { return 0; } | ||
| 84 | |||
| 85 | static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {} | ||
| 86 | static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {} | ||
| 87 | #endif | ||
| 88 | |||
| 89 | #endif /* __BUNDLE_H */ | ||
diff --git a/include/linux/greybus/connection.h b/include/linux/greybus/connection.h new file mode 100644 index 000000000000..5ca3befc0636 --- /dev/null +++ b/include/linux/greybus/connection.h | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus connections | ||
| 4 | * | ||
| 5 | * Copyright 2014 Google Inc. | ||
| 6 | * Copyright 2014 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __CONNECTION_H | ||
| 10 | #define __CONNECTION_H | ||
| 11 | |||
| 12 | #include <linux/list.h> | ||
| 13 | #include <linux/kfifo.h> | ||
| 14 | |||
| 15 | #define GB_CONNECTION_FLAG_CSD BIT(0) | ||
| 16 | #define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1) | ||
| 17 | #define GB_CONNECTION_FLAG_OFFLOADED BIT(2) | ||
| 18 | #define GB_CONNECTION_FLAG_CDSI1 BIT(3) | ||
| 19 | #define GB_CONNECTION_FLAG_CONTROL BIT(4) | ||
| 20 | #define GB_CONNECTION_FLAG_HIGH_PRIO BIT(5) | ||
| 21 | |||
| 22 | #define GB_CONNECTION_FLAG_CORE_MASK GB_CONNECTION_FLAG_CONTROL | ||
| 23 | |||
| 24 | enum gb_connection_state { | ||
| 25 | GB_CONNECTION_STATE_DISABLED = 0, | ||
| 26 | GB_CONNECTION_STATE_ENABLED_TX = 1, | ||
| 27 | GB_CONNECTION_STATE_ENABLED = 2, | ||
| 28 | GB_CONNECTION_STATE_DISCONNECTING = 3, | ||
| 29 | }; | ||
| 30 | |||
| 31 | struct gb_operation; | ||
| 32 | |||
| 33 | typedef int (*gb_request_handler_t)(struct gb_operation *); | ||
| 34 | |||
| 35 | struct gb_connection { | ||
| 36 | struct gb_host_device *hd; | ||
| 37 | struct gb_interface *intf; | ||
| 38 | struct gb_bundle *bundle; | ||
| 39 | struct kref kref; | ||
| 40 | u16 hd_cport_id; | ||
| 41 | u16 intf_cport_id; | ||
| 42 | |||
| 43 | struct list_head hd_links; | ||
| 44 | struct list_head bundle_links; | ||
| 45 | |||
| 46 | gb_request_handler_t handler; | ||
| 47 | unsigned long flags; | ||
| 48 | |||
| 49 | struct mutex mutex; | ||
| 50 | spinlock_t lock; | ||
| 51 | enum gb_connection_state state; | ||
| 52 | struct list_head operations; | ||
| 53 | |||
| 54 | char name[16]; | ||
| 55 | struct workqueue_struct *wq; | ||
| 56 | |||
| 57 | atomic_t op_cycle; | ||
| 58 | |||
| 59 | void *private; | ||
| 60 | |||
| 61 | bool mode_switch; | ||
| 62 | }; | ||
| 63 | |||
| 64 | struct gb_connection *gb_connection_create_static(struct gb_host_device *hd, | ||
| 65 | u16 hd_cport_id, gb_request_handler_t handler); | ||
| 66 | struct gb_connection *gb_connection_create_control(struct gb_interface *intf); | ||
| 67 | struct gb_connection *gb_connection_create(struct gb_bundle *bundle, | ||
| 68 | u16 cport_id, gb_request_handler_t handler); | ||
| 69 | struct gb_connection *gb_connection_create_flags(struct gb_bundle *bundle, | ||
| 70 | u16 cport_id, gb_request_handler_t handler, | ||
| 71 | unsigned long flags); | ||
| 72 | struct gb_connection *gb_connection_create_offloaded(struct gb_bundle *bundle, | ||
| 73 | u16 cport_id, unsigned long flags); | ||
| 74 | void gb_connection_destroy(struct gb_connection *connection); | ||
| 75 | |||
| 76 | static inline bool gb_connection_is_static(struct gb_connection *connection) | ||
| 77 | { | ||
| 78 | return !connection->intf; | ||
| 79 | } | ||
| 80 | |||
| 81 | int gb_connection_enable(struct gb_connection *connection); | ||
| 82 | int gb_connection_enable_tx(struct gb_connection *connection); | ||
| 83 | void gb_connection_disable_rx(struct gb_connection *connection); | ||
| 84 | void gb_connection_disable(struct gb_connection *connection); | ||
| 85 | void gb_connection_disable_forced(struct gb_connection *connection); | ||
| 86 | |||
| 87 | void gb_connection_mode_switch_prepare(struct gb_connection *connection); | ||
| 88 | void gb_connection_mode_switch_complete(struct gb_connection *connection); | ||
| 89 | |||
| 90 | void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id, | ||
| 91 | u8 *data, size_t length); | ||
| 92 | |||
| 93 | void gb_connection_latency_tag_enable(struct gb_connection *connection); | ||
| 94 | void gb_connection_latency_tag_disable(struct gb_connection *connection); | ||
| 95 | |||
| 96 | static inline bool gb_connection_e2efc_enabled(struct gb_connection *connection) | ||
| 97 | { | ||
| 98 | return !(connection->flags & GB_CONNECTION_FLAG_CSD); | ||
| 99 | } | ||
| 100 | |||
| 101 | static inline bool | ||
| 102 | gb_connection_flow_control_disabled(struct gb_connection *connection) | ||
| 103 | { | ||
| 104 | return connection->flags & GB_CONNECTION_FLAG_NO_FLOWCTRL; | ||
| 105 | } | ||
| 106 | |||
| 107 | static inline bool gb_connection_is_offloaded(struct gb_connection *connection) | ||
| 108 | { | ||
| 109 | return connection->flags & GB_CONNECTION_FLAG_OFFLOADED; | ||
| 110 | } | ||
| 111 | |||
| 112 | static inline bool gb_connection_is_control(struct gb_connection *connection) | ||
| 113 | { | ||
| 114 | return connection->flags & GB_CONNECTION_FLAG_CONTROL; | ||
| 115 | } | ||
| 116 | |||
| 117 | static inline void *gb_connection_get_data(struct gb_connection *connection) | ||
| 118 | { | ||
| 119 | return connection->private; | ||
| 120 | } | ||
| 121 | |||
| 122 | static inline void gb_connection_set_data(struct gb_connection *connection, | ||
| 123 | void *data) | ||
| 124 | { | ||
| 125 | connection->private = data; | ||
| 126 | } | ||
| 127 | |||
| 128 | #endif /* __CONNECTION_H */ | ||
diff --git a/include/linux/greybus/control.h b/include/linux/greybus/control.h new file mode 100644 index 000000000000..3a29ec05f631 --- /dev/null +++ b/include/linux/greybus/control.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus CPort control protocol | ||
| 4 | * | ||
| 5 | * Copyright 2015 Google Inc. | ||
| 6 | * Copyright 2015 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __CONTROL_H | ||
| 10 | #define __CONTROL_H | ||
| 11 | |||
| 12 | struct gb_control { | ||
| 13 | struct device dev; | ||
| 14 | struct gb_interface *intf; | ||
| 15 | |||
| 16 | struct gb_connection *connection; | ||
| 17 | |||
| 18 | u8 protocol_major; | ||
| 19 | u8 protocol_minor; | ||
| 20 | |||
| 21 | bool has_bundle_activate; | ||
| 22 | bool has_bundle_version; | ||
| 23 | |||
| 24 | char *vendor_string; | ||
| 25 | char *product_string; | ||
| 26 | }; | ||
| 27 | #define to_gb_control(d) container_of(d, struct gb_control, dev) | ||
| 28 | |||
| 29 | struct gb_control *gb_control_create(struct gb_interface *intf); | ||
| 30 | int gb_control_enable(struct gb_control *control); | ||
| 31 | void gb_control_disable(struct gb_control *control); | ||
| 32 | int gb_control_suspend(struct gb_control *control); | ||
| 33 | int gb_control_resume(struct gb_control *control); | ||
| 34 | int gb_control_add(struct gb_control *control); | ||
| 35 | void gb_control_del(struct gb_control *control); | ||
| 36 | struct gb_control *gb_control_get(struct gb_control *control); | ||
| 37 | void gb_control_put(struct gb_control *control); | ||
| 38 | |||
| 39 | int gb_control_get_bundle_versions(struct gb_control *control); | ||
| 40 | int gb_control_connected_operation(struct gb_control *control, u16 cport_id); | ||
| 41 | int gb_control_disconnected_operation(struct gb_control *control, u16 cport_id); | ||
| 42 | int gb_control_disconnecting_operation(struct gb_control *control, | ||
| 43 | u16 cport_id); | ||
| 44 | int gb_control_mode_switch_operation(struct gb_control *control); | ||
| 45 | void gb_control_mode_switch_prepare(struct gb_control *control); | ||
| 46 | void gb_control_mode_switch_complete(struct gb_control *control); | ||
| 47 | int gb_control_get_manifest_size_operation(struct gb_interface *intf); | ||
| 48 | int gb_control_get_manifest_operation(struct gb_interface *intf, void *manifest, | ||
| 49 | size_t size); | ||
| 50 | int gb_control_bundle_suspend(struct gb_control *control, u8 bundle_id); | ||
| 51 | int gb_control_bundle_resume(struct gb_control *control, u8 bundle_id); | ||
| 52 | int gb_control_bundle_deactivate(struct gb_control *control, u8 bundle_id); | ||
| 53 | int gb_control_bundle_activate(struct gb_control *control, u8 bundle_id); | ||
| 54 | int gb_control_interface_suspend_prepare(struct gb_control *control); | ||
| 55 | int gb_control_interface_deactivate_prepare(struct gb_control *control); | ||
| 56 | int gb_control_interface_hibernate_abort(struct gb_control *control); | ||
| 57 | #endif /* __CONTROL_H */ | ||
diff --git a/include/linux/greybus/greybus_id.h b/include/linux/greybus/greybus_id.h new file mode 100644 index 000000000000..f4c8440093e4 --- /dev/null +++ b/include/linux/greybus/greybus_id.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* FIXME | ||
| 3 | * move this to include/linux/mod_devicetable.h when merging | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef __LINUX_GREYBUS_ID_H | ||
| 7 | #define __LINUX_GREYBUS_ID_H | ||
| 8 | |||
| 9 | #include <linux/types.h> | ||
| 10 | #include <linux/mod_devicetable.h> | ||
| 11 | |||
| 12 | |||
| 13 | struct greybus_bundle_id { | ||
| 14 | __u16 match_flags; | ||
| 15 | __u32 vendor; | ||
| 16 | __u32 product; | ||
| 17 | __u8 class; | ||
| 18 | |||
| 19 | kernel_ulong_t driver_info __aligned(sizeof(kernel_ulong_t)); | ||
| 20 | }; | ||
| 21 | |||
| 22 | /* Used to match the greybus_bundle_id */ | ||
| 23 | #define GREYBUS_ID_MATCH_VENDOR BIT(0) | ||
| 24 | #define GREYBUS_ID_MATCH_PRODUCT BIT(1) | ||
| 25 | #define GREYBUS_ID_MATCH_CLASS BIT(2) | ||
| 26 | |||
| 27 | #endif /* __LINUX_GREYBUS_ID_H */ | ||
diff --git a/include/linux/greybus/greybus_manifest.h b/include/linux/greybus/greybus_manifest.h new file mode 100644 index 000000000000..db68f7e7d5a7 --- /dev/null +++ b/include/linux/greybus/greybus_manifest.h | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus manifest definition | ||
| 4 | * | ||
| 5 | * See "Greybus Application Protocol" document (version 0.1) for | ||
| 6 | * details on these values and structures. | ||
| 7 | * | ||
| 8 | * Copyright 2014-2015 Google Inc. | ||
| 9 | * Copyright 2014-2015 Linaro Ltd. | ||
| 10 | * | ||
| 11 | * Released under the GPLv2 and BSD licenses. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef __GREYBUS_MANIFEST_H | ||
| 15 | #define __GREYBUS_MANIFEST_H | ||
| 16 | |||
| 17 | enum greybus_descriptor_type { | ||
| 18 | GREYBUS_TYPE_INVALID = 0x00, | ||
| 19 | GREYBUS_TYPE_INTERFACE = 0x01, | ||
| 20 | GREYBUS_TYPE_STRING = 0x02, | ||
| 21 | GREYBUS_TYPE_BUNDLE = 0x03, | ||
| 22 | GREYBUS_TYPE_CPORT = 0x04, | ||
| 23 | }; | ||
| 24 | |||
| 25 | enum greybus_protocol { | ||
| 26 | GREYBUS_PROTOCOL_CONTROL = 0x00, | ||
| 27 | /* 0x01 is unused */ | ||
| 28 | GREYBUS_PROTOCOL_GPIO = 0x02, | ||
| 29 | GREYBUS_PROTOCOL_I2C = 0x03, | ||
| 30 | GREYBUS_PROTOCOL_UART = 0x04, | ||
| 31 | GREYBUS_PROTOCOL_HID = 0x05, | ||
| 32 | GREYBUS_PROTOCOL_USB = 0x06, | ||
| 33 | GREYBUS_PROTOCOL_SDIO = 0x07, | ||
| 34 | GREYBUS_PROTOCOL_POWER_SUPPLY = 0x08, | ||
| 35 | GREYBUS_PROTOCOL_PWM = 0x09, | ||
| 36 | /* 0x0a is unused */ | ||
| 37 | GREYBUS_PROTOCOL_SPI = 0x0b, | ||
| 38 | GREYBUS_PROTOCOL_DISPLAY = 0x0c, | ||
| 39 | GREYBUS_PROTOCOL_CAMERA_MGMT = 0x0d, | ||
| 40 | GREYBUS_PROTOCOL_SENSOR = 0x0e, | ||
| 41 | GREYBUS_PROTOCOL_LIGHTS = 0x0f, | ||
| 42 | GREYBUS_PROTOCOL_VIBRATOR = 0x10, | ||
| 43 | GREYBUS_PROTOCOL_LOOPBACK = 0x11, | ||
| 44 | GREYBUS_PROTOCOL_AUDIO_MGMT = 0x12, | ||
| 45 | GREYBUS_PROTOCOL_AUDIO_DATA = 0x13, | ||
| 46 | GREYBUS_PROTOCOL_SVC = 0x14, | ||
| 47 | GREYBUS_PROTOCOL_BOOTROM = 0x15, | ||
| 48 | GREYBUS_PROTOCOL_CAMERA_DATA = 0x16, | ||
| 49 | GREYBUS_PROTOCOL_FW_DOWNLOAD = 0x17, | ||
| 50 | GREYBUS_PROTOCOL_FW_MANAGEMENT = 0x18, | ||
| 51 | GREYBUS_PROTOCOL_AUTHENTICATION = 0x19, | ||
| 52 | GREYBUS_PROTOCOL_LOG = 0x1a, | ||
| 53 | /* ... */ | ||
| 54 | GREYBUS_PROTOCOL_RAW = 0xfe, | ||
| 55 | GREYBUS_PROTOCOL_VENDOR = 0xff, | ||
| 56 | }; | ||
| 57 | |||
| 58 | enum greybus_class_type { | ||
| 59 | GREYBUS_CLASS_CONTROL = 0x00, | ||
| 60 | /* 0x01 is unused */ | ||
| 61 | /* 0x02 is unused */ | ||
| 62 | /* 0x03 is unused */ | ||
| 63 | /* 0x04 is unused */ | ||
| 64 | GREYBUS_CLASS_HID = 0x05, | ||
| 65 | /* 0x06 is unused */ | ||
| 66 | /* 0x07 is unused */ | ||
| 67 | GREYBUS_CLASS_POWER_SUPPLY = 0x08, | ||
| 68 | /* 0x09 is unused */ | ||
| 69 | GREYBUS_CLASS_BRIDGED_PHY = 0x0a, | ||
| 70 | /* 0x0b is unused */ | ||
| 71 | GREYBUS_CLASS_DISPLAY = 0x0c, | ||
| 72 | GREYBUS_CLASS_CAMERA = 0x0d, | ||
| 73 | GREYBUS_CLASS_SENSOR = 0x0e, | ||
| 74 | GREYBUS_CLASS_LIGHTS = 0x0f, | ||
| 75 | GREYBUS_CLASS_VIBRATOR = 0x10, | ||
| 76 | GREYBUS_CLASS_LOOPBACK = 0x11, | ||
| 77 | GREYBUS_CLASS_AUDIO = 0x12, | ||
| 78 | /* 0x13 is unused */ | ||
| 79 | /* 0x14 is unused */ | ||
| 80 | GREYBUS_CLASS_BOOTROM = 0x15, | ||
| 81 | GREYBUS_CLASS_FW_MANAGEMENT = 0x16, | ||
| 82 | GREYBUS_CLASS_LOG = 0x17, | ||
| 83 | /* ... */ | ||
| 84 | GREYBUS_CLASS_RAW = 0xfe, | ||
| 85 | GREYBUS_CLASS_VENDOR = 0xff, | ||
| 86 | }; | ||
| 87 | |||
| 88 | enum { | ||
| 89 | GREYBUS_INTERFACE_FEATURE_TIMESYNC = BIT(0), | ||
| 90 | }; | ||
| 91 | |||
| 92 | /* | ||
| 93 | * The string in a string descriptor is not NUL-terminated. The | ||
| 94 | * size of the descriptor will be rounded up to a multiple of 4 | ||
| 95 | * bytes, by padding the string with 0x00 bytes if necessary. | ||
| 96 | */ | ||
| 97 | struct greybus_descriptor_string { | ||
| 98 | __u8 length; | ||
| 99 | __u8 id; | ||
| 100 | __u8 string[0]; | ||
| 101 | } __packed; | ||
| 102 | |||
| 103 | /* | ||
| 104 | * An interface descriptor describes information about an interface as a whole, | ||
| 105 | * *not* the functions within it. | ||
| 106 | */ | ||
| 107 | struct greybus_descriptor_interface { | ||
| 108 | __u8 vendor_stringid; | ||
| 109 | __u8 product_stringid; | ||
| 110 | __u8 features; | ||
| 111 | __u8 pad; | ||
| 112 | } __packed; | ||
| 113 | |||
| 114 | /* | ||
| 115 | * An bundle descriptor defines an identification number and a class for | ||
| 116 | * each bundle. | ||
| 117 | * | ||
| 118 | * @id: Uniquely identifies a bundle within a interface, its sole purpose is to | ||
| 119 | * allow CPort descriptors to specify which bundle they are associated with. | ||
| 120 | * The first bundle will have id 0, second will have 1 and so on. | ||
| 121 | * | ||
| 122 | * The largest CPort id associated with an bundle (defined by a | ||
| 123 | * CPort descriptor in the manifest) is used to determine how to | ||
| 124 | * encode the device id and module number in UniPro packets | ||
| 125 | * that use the bundle. | ||
| 126 | * | ||
| 127 | * @class: It is used by kernel to know the functionality provided by the | ||
| 128 | * bundle and will be matched against drivers functinality while probing greybus | ||
| 129 | * driver. It should contain one of the values defined in | ||
| 130 | * 'enum greybus_class_type'. | ||
| 131 | * | ||
| 132 | */ | ||
| 133 | struct greybus_descriptor_bundle { | ||
| 134 | __u8 id; /* interface-relative id (0..) */ | ||
| 135 | __u8 class; | ||
| 136 | __u8 pad[2]; | ||
| 137 | } __packed; | ||
| 138 | |||
| 139 | /* | ||
| 140 | * A CPort descriptor indicates the id of the bundle within the | ||
| 141 | * module it's associated with, along with the CPort id used to | ||
| 142 | * address the CPort. The protocol id defines the format of messages | ||
| 143 | * exchanged using the CPort. | ||
| 144 | */ | ||
| 145 | struct greybus_descriptor_cport { | ||
| 146 | __le16 id; | ||
| 147 | __u8 bundle; | ||
| 148 | __u8 protocol_id; /* enum greybus_protocol */ | ||
| 149 | } __packed; | ||
| 150 | |||
| 151 | struct greybus_descriptor_header { | ||
| 152 | __le16 size; | ||
| 153 | __u8 type; /* enum greybus_descriptor_type */ | ||
| 154 | __u8 pad; | ||
| 155 | } __packed; | ||
| 156 | |||
| 157 | struct greybus_descriptor { | ||
| 158 | struct greybus_descriptor_header header; | ||
| 159 | union { | ||
| 160 | struct greybus_descriptor_string string; | ||
| 161 | struct greybus_descriptor_interface interface; | ||
| 162 | struct greybus_descriptor_bundle bundle; | ||
| 163 | struct greybus_descriptor_cport cport; | ||
| 164 | }; | ||
| 165 | } __packed; | ||
| 166 | |||
| 167 | struct greybus_manifest_header { | ||
| 168 | __le16 size; | ||
| 169 | __u8 version_major; | ||
| 170 | __u8 version_minor; | ||
| 171 | } __packed; | ||
| 172 | |||
| 173 | struct greybus_manifest { | ||
| 174 | struct greybus_manifest_header header; | ||
| 175 | struct greybus_descriptor descriptors[0]; | ||
| 176 | } __packed; | ||
| 177 | |||
| 178 | #endif /* __GREYBUS_MANIFEST_H */ | ||
diff --git a/include/linux/greybus/greybus_protocols.h b/include/linux/greybus/greybus_protocols.h new file mode 100644 index 000000000000..5f34d1effb59 --- /dev/null +++ b/include/linux/greybus/greybus_protocols.h | |||
| @@ -0,0 +1,2176 @@ | |||
| 1 | /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ | ||
| 2 | /* | ||
| 3 | * Copyright(c) 2014 - 2015 Google Inc. All rights reserved. | ||
| 4 | * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #ifndef __GREYBUS_PROTOCOLS_H | ||
| 8 | #define __GREYBUS_PROTOCOLS_H | ||
| 9 | |||
| 10 | /* Fixed IDs for control/svc protocols */ | ||
| 11 | |||
| 12 | /* SVC switch-port device ids */ | ||
| 13 | #define GB_SVC_DEVICE_ID_SVC 0 | ||
| 14 | #define GB_SVC_DEVICE_ID_AP 1 | ||
| 15 | #define GB_SVC_DEVICE_ID_MIN 2 | ||
| 16 | #define GB_SVC_DEVICE_ID_MAX 31 | ||
| 17 | |||
| 18 | #define GB_SVC_CPORT_ID 0 | ||
| 19 | #define GB_CONTROL_BUNDLE_ID 0 | ||
| 20 | #define GB_CONTROL_CPORT_ID 0 | ||
| 21 | |||
| 22 | |||
| 23 | /* | ||
| 24 | * All operation messages (both requests and responses) begin with | ||
| 25 | * a header that encodes the size of the message (header included). | ||
| 26 | * This header also contains a unique identifier, that associates a | ||
| 27 | * response message with its operation. The header contains an | ||
| 28 | * operation type field, whose interpretation is dependent on what | ||
| 29 | * type of protocol is used over the connection. The high bit | ||
| 30 | * (0x80) of the operation type field is used to indicate whether | ||
| 31 | * the message is a request (clear) or a response (set). | ||
| 32 | * | ||
| 33 | * Response messages include an additional result byte, which | ||
| 34 | * communicates the result of the corresponding request. A zero | ||
| 35 | * result value means the operation completed successfully. Any | ||
| 36 | * other value indicates an error; in this case, the payload of the | ||
| 37 | * response message (if any) is ignored. The result byte must be | ||
| 38 | * zero in the header for a request message. | ||
| 39 | * | ||
| 40 | * The wire format for all numeric fields in the header is little | ||
| 41 | * endian. Any operation-specific data begins immediately after the | ||
| 42 | * header. | ||
| 43 | */ | ||
| 44 | struct gb_operation_msg_hdr { | ||
| 45 | __le16 size; /* Size in bytes of header + payload */ | ||
| 46 | __le16 operation_id; /* Operation unique id */ | ||
| 47 | __u8 type; /* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */ | ||
| 48 | __u8 result; /* Result of request (in responses only) */ | ||
| 49 | __u8 pad[2]; /* must be zero (ignore when read) */ | ||
| 50 | } __packed; | ||
| 51 | |||
| 52 | |||
| 53 | /* Generic request types */ | ||
| 54 | #define GB_REQUEST_TYPE_CPORT_SHUTDOWN 0x00 | ||
| 55 | #define GB_REQUEST_TYPE_INVALID 0x7f | ||
| 56 | |||
| 57 | struct gb_cport_shutdown_request { | ||
| 58 | __u8 phase; | ||
| 59 | } __packed; | ||
| 60 | |||
| 61 | |||
| 62 | /* Control Protocol */ | ||
| 63 | |||
| 64 | /* Greybus control request types */ | ||
| 65 | #define GB_CONTROL_TYPE_VERSION 0x01 | ||
| 66 | #define GB_CONTROL_TYPE_PROBE_AP 0x02 | ||
| 67 | #define GB_CONTROL_TYPE_GET_MANIFEST_SIZE 0x03 | ||
| 68 | #define GB_CONTROL_TYPE_GET_MANIFEST 0x04 | ||
| 69 | #define GB_CONTROL_TYPE_CONNECTED 0x05 | ||
| 70 | #define GB_CONTROL_TYPE_DISCONNECTED 0x06 | ||
| 71 | #define GB_CONTROL_TYPE_TIMESYNC_ENABLE 0x07 | ||
| 72 | #define GB_CONTROL_TYPE_TIMESYNC_DISABLE 0x08 | ||
| 73 | #define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE 0x09 | ||
| 74 | /* Unused 0x0a */ | ||
| 75 | #define GB_CONTROL_TYPE_BUNDLE_VERSION 0x0b | ||
| 76 | #define GB_CONTROL_TYPE_DISCONNECTING 0x0c | ||
| 77 | #define GB_CONTROL_TYPE_TIMESYNC_GET_LAST_EVENT 0x0d | ||
| 78 | #define GB_CONTROL_TYPE_MODE_SWITCH 0x0e | ||
| 79 | #define GB_CONTROL_TYPE_BUNDLE_SUSPEND 0x0f | ||
| 80 | #define GB_CONTROL_TYPE_BUNDLE_RESUME 0x10 | ||
| 81 | #define GB_CONTROL_TYPE_BUNDLE_DEACTIVATE 0x11 | ||
| 82 | #define GB_CONTROL_TYPE_BUNDLE_ACTIVATE 0x12 | ||
| 83 | #define GB_CONTROL_TYPE_INTF_SUSPEND_PREPARE 0x13 | ||
| 84 | #define GB_CONTROL_TYPE_INTF_DEACTIVATE_PREPARE 0x14 | ||
| 85 | #define GB_CONTROL_TYPE_INTF_HIBERNATE_ABORT 0x15 | ||
| 86 | |||
| 87 | struct gb_control_version_request { | ||
| 88 | __u8 major; | ||
| 89 | __u8 minor; | ||
| 90 | } __packed; | ||
| 91 | |||
| 92 | struct gb_control_version_response { | ||
| 93 | __u8 major; | ||
| 94 | __u8 minor; | ||
| 95 | } __packed; | ||
| 96 | |||
| 97 | struct gb_control_bundle_version_request { | ||
| 98 | __u8 bundle_id; | ||
| 99 | } __packed; | ||
| 100 | |||
| 101 | struct gb_control_bundle_version_response { | ||
| 102 | __u8 major; | ||
| 103 | __u8 minor; | ||
| 104 | } __packed; | ||
| 105 | |||
| 106 | /* Control protocol manifest get size request has no payload*/ | ||
| 107 | struct gb_control_get_manifest_size_response { | ||
| 108 | __le16 size; | ||
| 109 | } __packed; | ||
| 110 | |||
| 111 | /* Control protocol manifest get request has no payload */ | ||
| 112 | struct gb_control_get_manifest_response { | ||
| 113 | __u8 data[0]; | ||
| 114 | } __packed; | ||
| 115 | |||
| 116 | /* Control protocol [dis]connected request */ | ||
| 117 | struct gb_control_connected_request { | ||
| 118 | __le16 cport_id; | ||
| 119 | } __packed; | ||
| 120 | |||
| 121 | struct gb_control_disconnecting_request { | ||
| 122 | __le16 cport_id; | ||
| 123 | } __packed; | ||
| 124 | /* disconnecting response has no payload */ | ||
| 125 | |||
| 126 | struct gb_control_disconnected_request { | ||
| 127 | __le16 cport_id; | ||
| 128 | } __packed; | ||
| 129 | /* Control protocol [dis]connected response has no payload */ | ||
| 130 | |||
| 131 | /* | ||
| 132 | * All Bundle power management operations use the same request and response | ||
| 133 | * layout and status codes. | ||
| 134 | */ | ||
| 135 | |||
| 136 | #define GB_CONTROL_BUNDLE_PM_OK 0x00 | ||
| 137 | #define GB_CONTROL_BUNDLE_PM_INVAL 0x01 | ||
| 138 | #define GB_CONTROL_BUNDLE_PM_BUSY 0x02 | ||
| 139 | #define GB_CONTROL_BUNDLE_PM_FAIL 0x03 | ||
| 140 | #define GB_CONTROL_BUNDLE_PM_NA 0x04 | ||
| 141 | |||
| 142 | struct gb_control_bundle_pm_request { | ||
| 143 | __u8 bundle_id; | ||
| 144 | } __packed; | ||
| 145 | |||
| 146 | struct gb_control_bundle_pm_response { | ||
| 147 | __u8 status; | ||
| 148 | } __packed; | ||
| 149 | |||
| 150 | /* | ||
| 151 | * Interface Suspend Prepare and Deactivate Prepare operations use the same | ||
| 152 | * response layout and error codes. Define a single response structure and reuse | ||
| 153 | * it. Both operations have no payload. | ||
| 154 | */ | ||
| 155 | |||
| 156 | #define GB_CONTROL_INTF_PM_OK 0x00 | ||
| 157 | #define GB_CONTROL_INTF_PM_BUSY 0x01 | ||
| 158 | #define GB_CONTROL_INTF_PM_NA 0x02 | ||
| 159 | |||
| 160 | struct gb_control_intf_pm_response { | ||
| 161 | __u8 status; | ||
| 162 | } __packed; | ||
| 163 | |||
| 164 | /* APBridge protocol */ | ||
| 165 | |||
| 166 | /* request APB1 log */ | ||
| 167 | #define GB_APB_REQUEST_LOG 0x02 | ||
| 168 | |||
| 169 | /* request to map a cport to bulk in and bulk out endpoints */ | ||
| 170 | #define GB_APB_REQUEST_EP_MAPPING 0x03 | ||
| 171 | |||
| 172 | /* request to get the number of cports available */ | ||
| 173 | #define GB_APB_REQUEST_CPORT_COUNT 0x04 | ||
| 174 | |||
| 175 | /* request to reset a cport state */ | ||
| 176 | #define GB_APB_REQUEST_RESET_CPORT 0x05 | ||
| 177 | |||
| 178 | /* request to time the latency of messages on a given cport */ | ||
| 179 | #define GB_APB_REQUEST_LATENCY_TAG_EN 0x06 | ||
| 180 | #define GB_APB_REQUEST_LATENCY_TAG_DIS 0x07 | ||
| 181 | |||
| 182 | /* request to control the CSI transmitter */ | ||
| 183 | #define GB_APB_REQUEST_CSI_TX_CONTROL 0x08 | ||
| 184 | |||
| 185 | /* request to control audio streaming */ | ||
| 186 | #define GB_APB_REQUEST_AUDIO_CONTROL 0x09 | ||
| 187 | |||
| 188 | /* TimeSync requests */ | ||
| 189 | #define GB_APB_REQUEST_TIMESYNC_ENABLE 0x0d | ||
| 190 | #define GB_APB_REQUEST_TIMESYNC_DISABLE 0x0e | ||
| 191 | #define GB_APB_REQUEST_TIMESYNC_AUTHORITATIVE 0x0f | ||
| 192 | #define GB_APB_REQUEST_TIMESYNC_GET_LAST_EVENT 0x10 | ||
| 193 | |||
| 194 | /* requests to set Greybus CPort flags */ | ||
| 195 | #define GB_APB_REQUEST_CPORT_FLAGS 0x11 | ||
| 196 | |||
| 197 | /* ARPC request */ | ||
| 198 | #define GB_APB_REQUEST_ARPC_RUN 0x12 | ||
| 199 | |||
| 200 | struct gb_apb_request_cport_flags { | ||
| 201 | __le32 flags; | ||
| 202 | #define GB_APB_CPORT_FLAG_CONTROL 0x01 | ||
| 203 | #define GB_APB_CPORT_FLAG_HIGH_PRIO 0x02 | ||
| 204 | } __packed; | ||
| 205 | |||
| 206 | |||
| 207 | /* Firmware Download Protocol */ | ||
| 208 | |||
| 209 | /* Request Types */ | ||
| 210 | #define GB_FW_DOWNLOAD_TYPE_FIND_FIRMWARE 0x01 | ||
| 211 | #define GB_FW_DOWNLOAD_TYPE_FETCH_FIRMWARE 0x02 | ||
| 212 | #define GB_FW_DOWNLOAD_TYPE_RELEASE_FIRMWARE 0x03 | ||
| 213 | |||
| 214 | #define GB_FIRMWARE_TAG_MAX_SIZE 10 | ||
| 215 | |||
| 216 | /* firmware download find firmware request/response */ | ||
| 217 | struct gb_fw_download_find_firmware_request { | ||
| 218 | __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; | ||
| 219 | } __packed; | ||
| 220 | |||
| 221 | struct gb_fw_download_find_firmware_response { | ||
| 222 | __u8 firmware_id; | ||
| 223 | __le32 size; | ||
| 224 | } __packed; | ||
| 225 | |||
| 226 | /* firmware download fetch firmware request/response */ | ||
| 227 | struct gb_fw_download_fetch_firmware_request { | ||
| 228 | __u8 firmware_id; | ||
| 229 | __le32 offset; | ||
| 230 | __le32 size; | ||
| 231 | } __packed; | ||
| 232 | |||
| 233 | struct gb_fw_download_fetch_firmware_response { | ||
| 234 | __u8 data[0]; | ||
| 235 | } __packed; | ||
| 236 | |||
| 237 | /* firmware download release firmware request */ | ||
| 238 | struct gb_fw_download_release_firmware_request { | ||
| 239 | __u8 firmware_id; | ||
| 240 | } __packed; | ||
| 241 | /* firmware download release firmware response has no payload */ | ||
| 242 | |||
| 243 | |||
| 244 | /* Firmware Management Protocol */ | ||
| 245 | |||
| 246 | /* Request Types */ | ||
| 247 | #define GB_FW_MGMT_TYPE_INTERFACE_FW_VERSION 0x01 | ||
| 248 | #define GB_FW_MGMT_TYPE_LOAD_AND_VALIDATE_FW 0x02 | ||
| 249 | #define GB_FW_MGMT_TYPE_LOADED_FW 0x03 | ||
| 250 | #define GB_FW_MGMT_TYPE_BACKEND_FW_VERSION 0x04 | ||
| 251 | #define GB_FW_MGMT_TYPE_BACKEND_FW_UPDATE 0x05 | ||
| 252 | #define GB_FW_MGMT_TYPE_BACKEND_FW_UPDATED 0x06 | ||
| 253 | |||
| 254 | #define GB_FW_LOAD_METHOD_UNIPRO 0x01 | ||
| 255 | #define GB_FW_LOAD_METHOD_INTERNAL 0x02 | ||
| 256 | |||
| 257 | #define GB_FW_LOAD_STATUS_FAILED 0x00 | ||
| 258 | #define GB_FW_LOAD_STATUS_UNVALIDATED 0x01 | ||
| 259 | #define GB_FW_LOAD_STATUS_VALIDATED 0x02 | ||
| 260 | #define GB_FW_LOAD_STATUS_VALIDATION_FAILED 0x03 | ||
| 261 | |||
| 262 | #define GB_FW_BACKEND_FW_STATUS_SUCCESS 0x01 | ||
| 263 | #define GB_FW_BACKEND_FW_STATUS_FAIL_FIND 0x02 | ||
| 264 | #define GB_FW_BACKEND_FW_STATUS_FAIL_FETCH 0x03 | ||
| 265 | #define GB_FW_BACKEND_FW_STATUS_FAIL_WRITE 0x04 | ||
| 266 | #define GB_FW_BACKEND_FW_STATUS_INT 0x05 | ||
| 267 | #define GB_FW_BACKEND_FW_STATUS_RETRY 0x06 | ||
| 268 | #define GB_FW_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07 | ||
| 269 | |||
| 270 | #define GB_FW_BACKEND_VERSION_STATUS_SUCCESS 0x01 | ||
| 271 | #define GB_FW_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02 | ||
| 272 | #define GB_FW_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03 | ||
| 273 | #define GB_FW_BACKEND_VERSION_STATUS_RETRY 0x04 | ||
| 274 | #define GB_FW_BACKEND_VERSION_STATUS_FAIL_INT 0x05 | ||
| 275 | |||
| 276 | /* firmware management interface firmware version request has no payload */ | ||
| 277 | struct gb_fw_mgmt_interface_fw_version_response { | ||
| 278 | __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; | ||
| 279 | __le16 major; | ||
| 280 | __le16 minor; | ||
| 281 | } __packed; | ||
| 282 | |||
| 283 | /* firmware management load and validate firmware request/response */ | ||
| 284 | struct gb_fw_mgmt_load_and_validate_fw_request { | ||
| 285 | __u8 request_id; | ||
| 286 | __u8 load_method; | ||
| 287 | __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; | ||
| 288 | } __packed; | ||
| 289 | /* firmware management load and validate firmware response has no payload*/ | ||
| 290 | |||
| 291 | /* firmware management loaded firmware request */ | ||
| 292 | struct gb_fw_mgmt_loaded_fw_request { | ||
| 293 | __u8 request_id; | ||
| 294 | __u8 status; | ||
| 295 | __le16 major; | ||
| 296 | __le16 minor; | ||
| 297 | } __packed; | ||
| 298 | /* firmware management loaded firmware response has no payload */ | ||
| 299 | |||
| 300 | /* firmware management backend firmware version request/response */ | ||
| 301 | struct gb_fw_mgmt_backend_fw_version_request { | ||
| 302 | __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; | ||
| 303 | } __packed; | ||
| 304 | |||
| 305 | struct gb_fw_mgmt_backend_fw_version_response { | ||
| 306 | __le16 major; | ||
| 307 | __le16 minor; | ||
| 308 | __u8 status; | ||
| 309 | } __packed; | ||
| 310 | |||
| 311 | /* firmware management backend firmware update request */ | ||
| 312 | struct gb_fw_mgmt_backend_fw_update_request { | ||
| 313 | __u8 request_id; | ||
| 314 | __u8 firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE]; | ||
| 315 | } __packed; | ||
| 316 | /* firmware management backend firmware update response has no payload */ | ||
| 317 | |||
| 318 | /* firmware management backend firmware updated request */ | ||
| 319 | struct gb_fw_mgmt_backend_fw_updated_request { | ||
| 320 | __u8 request_id; | ||
| 321 | __u8 status; | ||
| 322 | } __packed; | ||
| 323 | /* firmware management backend firmware updated response has no payload */ | ||
| 324 | |||
| 325 | |||
| 326 | /* Component Authentication Protocol (CAP) */ | ||
| 327 | |||
| 328 | /* Request Types */ | ||
| 329 | #define GB_CAP_TYPE_GET_ENDPOINT_UID 0x01 | ||
| 330 | #define GB_CAP_TYPE_GET_IMS_CERTIFICATE 0x02 | ||
| 331 | #define GB_CAP_TYPE_AUTHENTICATE 0x03 | ||
| 332 | |||
| 333 | /* CAP get endpoint uid request has no payload */ | ||
| 334 | struct gb_cap_get_endpoint_uid_response { | ||
| 335 | __u8 uid[8]; | ||
| 336 | } __packed; | ||
| 337 | |||
| 338 | /* CAP get endpoint ims certificate request/response */ | ||
| 339 | struct gb_cap_get_ims_certificate_request { | ||
| 340 | __le32 certificate_class; | ||
| 341 | __le32 certificate_id; | ||
| 342 | } __packed; | ||
| 343 | |||
| 344 | struct gb_cap_get_ims_certificate_response { | ||
| 345 | __u8 result_code; | ||
| 346 | __u8 certificate[0]; | ||
| 347 | } __packed; | ||
| 348 | |||
| 349 | /* CAP authenticate request/response */ | ||
| 350 | struct gb_cap_authenticate_request { | ||
| 351 | __le32 auth_type; | ||
| 352 | __u8 uid[8]; | ||
| 353 | __u8 challenge[32]; | ||
| 354 | } __packed; | ||
| 355 | |||
| 356 | struct gb_cap_authenticate_response { | ||
| 357 | __u8 result_code; | ||
| 358 | __u8 response[64]; | ||
| 359 | __u8 signature[0]; | ||
| 360 | } __packed; | ||
| 361 | |||
| 362 | |||
| 363 | /* Bootrom Protocol */ | ||
| 364 | |||
| 365 | /* Version of the Greybus bootrom protocol we support */ | ||
| 366 | #define GB_BOOTROM_VERSION_MAJOR 0x00 | ||
| 367 | #define GB_BOOTROM_VERSION_MINOR 0x01 | ||
| 368 | |||
| 369 | /* Greybus bootrom request types */ | ||
| 370 | #define GB_BOOTROM_TYPE_VERSION 0x01 | ||
| 371 | #define GB_BOOTROM_TYPE_FIRMWARE_SIZE 0x02 | ||
| 372 | #define GB_BOOTROM_TYPE_GET_FIRMWARE 0x03 | ||
| 373 | #define GB_BOOTROM_TYPE_READY_TO_BOOT 0x04 | ||
| 374 | #define GB_BOOTROM_TYPE_AP_READY 0x05 /* Request with no-payload */ | ||
| 375 | #define GB_BOOTROM_TYPE_GET_VID_PID 0x06 /* Request with no-payload */ | ||
| 376 | |||
| 377 | /* Greybus bootrom boot stages */ | ||
| 378 | #define GB_BOOTROM_BOOT_STAGE_ONE 0x01 /* Reserved for the boot ROM */ | ||
| 379 | #define GB_BOOTROM_BOOT_STAGE_TWO 0x02 /* Bootrom package to be loaded by the boot ROM */ | ||
| 380 | #define GB_BOOTROM_BOOT_STAGE_THREE 0x03 /* Module personality package loaded by Stage 2 firmware */ | ||
| 381 | |||
| 382 | /* Greybus bootrom ready to boot status */ | ||
| 383 | #define GB_BOOTROM_BOOT_STATUS_INVALID 0x00 /* Firmware blob could not be validated */ | ||
| 384 | #define GB_BOOTROM_BOOT_STATUS_INSECURE 0x01 /* Firmware blob is valid but insecure */ | ||
| 385 | #define GB_BOOTROM_BOOT_STATUS_SECURE 0x02 /* Firmware blob is valid and secure */ | ||
| 386 | |||
| 387 | /* Max bootrom data fetch size in bytes */ | ||
| 388 | #define GB_BOOTROM_FETCH_MAX 2000 | ||
| 389 | |||
| 390 | struct gb_bootrom_version_request { | ||
| 391 | __u8 major; | ||
| 392 | __u8 minor; | ||
| 393 | } __packed; | ||
| 394 | |||
| 395 | struct gb_bootrom_version_response { | ||
| 396 | __u8 major; | ||
| 397 | __u8 minor; | ||
| 398 | } __packed; | ||
| 399 | |||
| 400 | /* Bootrom protocol firmware size request/response */ | ||
| 401 | struct gb_bootrom_firmware_size_request { | ||
| 402 | __u8 stage; | ||
| 403 | } __packed; | ||
| 404 | |||
| 405 | struct gb_bootrom_firmware_size_response { | ||
| 406 | __le32 size; | ||
| 407 | } __packed; | ||
| 408 | |||
| 409 | /* Bootrom protocol get firmware request/response */ | ||
| 410 | struct gb_bootrom_get_firmware_request { | ||
| 411 | __le32 offset; | ||
| 412 | __le32 size; | ||
| 413 | } __packed; | ||
| 414 | |||
| 415 | struct gb_bootrom_get_firmware_response { | ||
| 416 | __u8 data[0]; | ||
| 417 | } __packed; | ||
| 418 | |||
| 419 | /* Bootrom protocol Ready to boot request */ | ||
| 420 | struct gb_bootrom_ready_to_boot_request { | ||
| 421 | __u8 status; | ||
| 422 | } __packed; | ||
| 423 | /* Bootrom protocol Ready to boot response has no payload */ | ||
| 424 | |||
| 425 | /* Bootrom protocol get VID/PID request has no payload */ | ||
| 426 | struct gb_bootrom_get_vid_pid_response { | ||
| 427 | __le32 vendor_id; | ||
| 428 | __le32 product_id; | ||
| 429 | } __packed; | ||
| 430 | |||
| 431 | |||
| 432 | /* Power Supply */ | ||
| 433 | |||
| 434 | /* Greybus power supply request types */ | ||
| 435 | #define GB_POWER_SUPPLY_TYPE_GET_SUPPLIES 0x02 | ||
| 436 | #define GB_POWER_SUPPLY_TYPE_GET_DESCRIPTION 0x03 | ||
| 437 | #define GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS 0x04 | ||
| 438 | #define GB_POWER_SUPPLY_TYPE_GET_PROPERTY 0x05 | ||
| 439 | #define GB_POWER_SUPPLY_TYPE_SET_PROPERTY 0x06 | ||
| 440 | #define GB_POWER_SUPPLY_TYPE_EVENT 0x07 | ||
| 441 | |||
| 442 | /* Greybus power supply battery technologies types */ | ||
| 443 | #define GB_POWER_SUPPLY_TECH_UNKNOWN 0x0000 | ||
| 444 | #define GB_POWER_SUPPLY_TECH_NiMH 0x0001 | ||
| 445 | #define GB_POWER_SUPPLY_TECH_LION 0x0002 | ||
| 446 | #define GB_POWER_SUPPLY_TECH_LIPO 0x0003 | ||
| 447 | #define GB_POWER_SUPPLY_TECH_LiFe 0x0004 | ||
| 448 | #define GB_POWER_SUPPLY_TECH_NiCd 0x0005 | ||
| 449 | #define GB_POWER_SUPPLY_TECH_LiMn 0x0006 | ||
| 450 | |||
| 451 | /* Greybus power supply types */ | ||
| 452 | #define GB_POWER_SUPPLY_UNKNOWN_TYPE 0x0000 | ||
| 453 | #define GB_POWER_SUPPLY_BATTERY_TYPE 0x0001 | ||
| 454 | #define GB_POWER_SUPPLY_UPS_TYPE 0x0002 | ||
| 455 | #define GB_POWER_SUPPLY_MAINS_TYPE 0x0003 | ||
| 456 | #define GB_POWER_SUPPLY_USB_TYPE 0x0004 | ||
| 457 | #define GB_POWER_SUPPLY_USB_DCP_TYPE 0x0005 | ||
| 458 | #define GB_POWER_SUPPLY_USB_CDP_TYPE 0x0006 | ||
| 459 | #define GB_POWER_SUPPLY_USB_ACA_TYPE 0x0007 | ||
| 460 | |||
| 461 | /* Greybus power supply health values */ | ||
| 462 | #define GB_POWER_SUPPLY_HEALTH_UNKNOWN 0x0000 | ||
| 463 | #define GB_POWER_SUPPLY_HEALTH_GOOD 0x0001 | ||
| 464 | #define GB_POWER_SUPPLY_HEALTH_OVERHEAT 0x0002 | ||
| 465 | #define GB_POWER_SUPPLY_HEALTH_DEAD 0x0003 | ||
| 466 | #define GB_POWER_SUPPLY_HEALTH_OVERVOLTAGE 0x0004 | ||
| 467 | #define GB_POWER_SUPPLY_HEALTH_UNSPEC_FAILURE 0x0005 | ||
| 468 | #define GB_POWER_SUPPLY_HEALTH_COLD 0x0006 | ||
| 469 | #define GB_POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE 0x0007 | ||
| 470 | #define GB_POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE 0x0008 | ||
| 471 | |||
| 472 | /* Greybus power supply status values */ | ||
| 473 | #define GB_POWER_SUPPLY_STATUS_UNKNOWN 0x0000 | ||
| 474 | #define GB_POWER_SUPPLY_STATUS_CHARGING 0x0001 | ||
| 475 | #define GB_POWER_SUPPLY_STATUS_DISCHARGING 0x0002 | ||
| 476 | #define GB_POWER_SUPPLY_STATUS_NOT_CHARGING 0x0003 | ||
| 477 | #define GB_POWER_SUPPLY_STATUS_FULL 0x0004 | ||
| 478 | |||
| 479 | /* Greybus power supply capacity level values */ | ||
| 480 | #define GB_POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN 0x0000 | ||
| 481 | #define GB_POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL 0x0001 | ||
| 482 | #define GB_POWER_SUPPLY_CAPACITY_LEVEL_LOW 0x0002 | ||
| 483 | #define GB_POWER_SUPPLY_CAPACITY_LEVEL_NORMAL 0x0003 | ||
| 484 | #define GB_POWER_SUPPLY_CAPACITY_LEVEL_HIGH 0x0004 | ||
| 485 | #define GB_POWER_SUPPLY_CAPACITY_LEVEL_FULL 0x0005 | ||
| 486 | |||
| 487 | /* Greybus power supply scope values */ | ||
| 488 | #define GB_POWER_SUPPLY_SCOPE_UNKNOWN 0x0000 | ||
| 489 | #define GB_POWER_SUPPLY_SCOPE_SYSTEM 0x0001 | ||
| 490 | #define GB_POWER_SUPPLY_SCOPE_DEVICE 0x0002 | ||
| 491 | |||
| 492 | struct gb_power_supply_get_supplies_response { | ||
| 493 | __u8 supplies_count; | ||
| 494 | } __packed; | ||
| 495 | |||
| 496 | struct gb_power_supply_get_description_request { | ||
| 497 | __u8 psy_id; | ||
| 498 | } __packed; | ||
| 499 | |||
| 500 | struct gb_power_supply_get_description_response { | ||
| 501 | __u8 manufacturer[32]; | ||
| 502 | __u8 model[32]; | ||
| 503 | __u8 serial_number[32]; | ||
| 504 | __le16 type; | ||
| 505 | __u8 properties_count; | ||
| 506 | } __packed; | ||
| 507 | |||
| 508 | struct gb_power_supply_props_desc { | ||
| 509 | __u8 property; | ||
| 510 | #define GB_POWER_SUPPLY_PROP_STATUS 0x00 | ||
| 511 | #define GB_POWER_SUPPLY_PROP_CHARGE_TYPE 0x01 | ||
| 512 | #define GB_POWER_SUPPLY_PROP_HEALTH 0x02 | ||
| 513 | #define GB_POWER_SUPPLY_PROP_PRESENT 0x03 | ||
| 514 | #define GB_POWER_SUPPLY_PROP_ONLINE 0x04 | ||
| 515 | #define GB_POWER_SUPPLY_PROP_AUTHENTIC 0x05 | ||
| 516 | #define GB_POWER_SUPPLY_PROP_TECHNOLOGY 0x06 | ||
| 517 | #define GB_POWER_SUPPLY_PROP_CYCLE_COUNT 0x07 | ||
| 518 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX 0x08 | ||
| 519 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN 0x09 | ||
| 520 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN 0x0A | ||
| 521 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN 0x0B | ||
| 522 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_NOW 0x0C | ||
| 523 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_AVG 0x0D | ||
| 524 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_OCV 0x0E | ||
| 525 | #define GB_POWER_SUPPLY_PROP_VOLTAGE_BOOT 0x0F | ||
| 526 | #define GB_POWER_SUPPLY_PROP_CURRENT_MAX 0x10 | ||
| 527 | #define GB_POWER_SUPPLY_PROP_CURRENT_NOW 0x11 | ||
| 528 | #define GB_POWER_SUPPLY_PROP_CURRENT_AVG 0x12 | ||
| 529 | #define GB_POWER_SUPPLY_PROP_CURRENT_BOOT 0x13 | ||
| 530 | #define GB_POWER_SUPPLY_PROP_POWER_NOW 0x14 | ||
| 531 | #define GB_POWER_SUPPLY_PROP_POWER_AVG 0x15 | ||
| 532 | #define GB_POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN 0x16 | ||
| 533 | #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN 0x17 | ||
| 534 | #define GB_POWER_SUPPLY_PROP_CHARGE_FULL 0x18 | ||
| 535 | #define GB_POWER_SUPPLY_PROP_CHARGE_EMPTY 0x19 | ||
| 536 | #define GB_POWER_SUPPLY_PROP_CHARGE_NOW 0x1A | ||
| 537 | #define GB_POWER_SUPPLY_PROP_CHARGE_AVG 0x1B | ||
| 538 | #define GB_POWER_SUPPLY_PROP_CHARGE_COUNTER 0x1C | ||
| 539 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT 0x1D | ||
| 540 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX 0x1E | ||
| 541 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE 0x1F | ||
| 542 | #define GB_POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX 0x20 | ||
| 543 | #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT 0x21 | ||
| 544 | #define GB_POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX 0x22 | ||
| 545 | #define GB_POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT 0x23 | ||
| 546 | #define GB_POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN 0x24 | ||
| 547 | #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN 0x25 | ||
| 548 | #define GB_POWER_SUPPLY_PROP_ENERGY_FULL 0x26 | ||
| 549 | #define GB_POWER_SUPPLY_PROP_ENERGY_EMPTY 0x27 | ||
| 550 | #define GB_POWER_SUPPLY_PROP_ENERGY_NOW 0x28 | ||
| 551 | #define GB_POWER_SUPPLY_PROP_ENERGY_AVG 0x29 | ||
| 552 | #define GB_POWER_SUPPLY_PROP_CAPACITY 0x2A | ||
| 553 | #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN 0x2B | ||
| 554 | #define GB_POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX 0x2C | ||
| 555 | #define GB_POWER_SUPPLY_PROP_CAPACITY_LEVEL 0x2D | ||
| 556 | #define GB_POWER_SUPPLY_PROP_TEMP 0x2E | ||
| 557 | #define GB_POWER_SUPPLY_PROP_TEMP_MAX 0x2F | ||
| 558 | #define GB_POWER_SUPPLY_PROP_TEMP_MIN 0x30 | ||
| 559 | #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MIN 0x31 | ||
| 560 | #define GB_POWER_SUPPLY_PROP_TEMP_ALERT_MAX 0x32 | ||
| 561 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT 0x33 | ||
| 562 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN 0x34 | ||
| 563 | #define GB_POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX 0x35 | ||
| 564 | #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW 0x36 | ||
| 565 | #define GB_POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG 0x37 | ||
| 566 | #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_NOW 0x38 | ||
| 567 | #define GB_POWER_SUPPLY_PROP_TIME_TO_FULL_AVG 0x39 | ||
| 568 | #define GB_POWER_SUPPLY_PROP_TYPE 0x3A | ||
| 569 | #define GB_POWER_SUPPLY_PROP_SCOPE 0x3B | ||
| 570 | #define GB_POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT 0x3C | ||
| 571 | #define GB_POWER_SUPPLY_PROP_CALIBRATE 0x3D | ||
| 572 | __u8 is_writeable; | ||
| 573 | } __packed; | ||
| 574 | |||
| 575 | struct gb_power_supply_get_property_descriptors_request { | ||
| 576 | __u8 psy_id; | ||
| 577 | } __packed; | ||
| 578 | |||
| 579 | struct gb_power_supply_get_property_descriptors_response { | ||
| 580 | __u8 properties_count; | ||
| 581 | struct gb_power_supply_props_desc props[]; | ||
| 582 | } __packed; | ||
| 583 | |||
| 584 | struct gb_power_supply_get_property_request { | ||
| 585 | __u8 psy_id; | ||
| 586 | __u8 property; | ||
| 587 | } __packed; | ||
| 588 | |||
| 589 | struct gb_power_supply_get_property_response { | ||
| 590 | __le32 prop_val; | ||
| 591 | }; | ||
| 592 | |||
| 593 | struct gb_power_supply_set_property_request { | ||
| 594 | __u8 psy_id; | ||
| 595 | __u8 property; | ||
| 596 | __le32 prop_val; | ||
| 597 | } __packed; | ||
| 598 | |||
| 599 | struct gb_power_supply_event_request { | ||
| 600 | __u8 psy_id; | ||
| 601 | __u8 event; | ||
| 602 | #define GB_POWER_SUPPLY_UPDATE 0x01 | ||
| 603 | } __packed; | ||
| 604 | |||
| 605 | |||
| 606 | /* HID */ | ||
| 607 | |||
| 608 | /* Greybus HID operation types */ | ||
| 609 | #define GB_HID_TYPE_GET_DESC 0x02 | ||
| 610 | #define GB_HID_TYPE_GET_REPORT_DESC 0x03 | ||
| 611 | #define GB_HID_TYPE_PWR_ON 0x04 | ||
| 612 | #define GB_HID_TYPE_PWR_OFF 0x05 | ||
| 613 | #define GB_HID_TYPE_GET_REPORT 0x06 | ||
| 614 | #define GB_HID_TYPE_SET_REPORT 0x07 | ||
| 615 | #define GB_HID_TYPE_IRQ_EVENT 0x08 | ||
| 616 | |||
| 617 | /* Report type */ | ||
| 618 | #define GB_HID_INPUT_REPORT 0 | ||
| 619 | #define GB_HID_OUTPUT_REPORT 1 | ||
| 620 | #define GB_HID_FEATURE_REPORT 2 | ||
| 621 | |||
| 622 | /* Different request/response structures */ | ||
| 623 | /* HID get descriptor response */ | ||
| 624 | struct gb_hid_desc_response { | ||
| 625 | __u8 bLength; | ||
| 626 | __le16 wReportDescLength; | ||
| 627 | __le16 bcdHID; | ||
| 628 | __le16 wProductID; | ||
| 629 | __le16 wVendorID; | ||
| 630 | __u8 bCountryCode; | ||
| 631 | } __packed; | ||
| 632 | |||
| 633 | /* HID get report request/response */ | ||
| 634 | struct gb_hid_get_report_request { | ||
| 635 | __u8 report_type; | ||
| 636 | __u8 report_id; | ||
| 637 | } __packed; | ||
| 638 | |||
| 639 | /* HID set report request */ | ||
| 640 | struct gb_hid_set_report_request { | ||
| 641 | __u8 report_type; | ||
| 642 | __u8 report_id; | ||
| 643 | __u8 report[0]; | ||
| 644 | } __packed; | ||
| 645 | |||
| 646 | /* HID input report request, via interrupt pipe */ | ||
| 647 | struct gb_hid_input_report_request { | ||
| 648 | __u8 report[0]; | ||
| 649 | } __packed; | ||
| 650 | |||
| 651 | |||
| 652 | /* I2C */ | ||
| 653 | |||
| 654 | /* Greybus i2c request types */ | ||
| 655 | #define GB_I2C_TYPE_FUNCTIONALITY 0x02 | ||
| 656 | #define GB_I2C_TYPE_TRANSFER 0x05 | ||
| 657 | |||
| 658 | /* functionality request has no payload */ | ||
| 659 | struct gb_i2c_functionality_response { | ||
| 660 | __le32 functionality; | ||
| 661 | } __packed; | ||
| 662 | |||
| 663 | /* | ||
| 664 | * Outgoing data immediately follows the op count and ops array. | ||
| 665 | * The data for each write (master -> slave) op in the array is sent | ||
| 666 | * in order, with no (e.g. pad) bytes separating them. | ||
| 667 | * | ||
| 668 | * Short reads cause the entire transfer request to fail So response | ||
| 669 | * payload consists only of bytes read, and the number of bytes is | ||
| 670 | * exactly what was specified in the corresponding op. Like | ||
| 671 | * outgoing data, the incoming data is in order and contiguous. | ||
| 672 | */ | ||
| 673 | struct gb_i2c_transfer_op { | ||
| 674 | __le16 addr; | ||
| 675 | __le16 flags; | ||
| 676 | __le16 size; | ||
| 677 | } __packed; | ||
| 678 | |||
| 679 | struct gb_i2c_transfer_request { | ||
| 680 | __le16 op_count; | ||
| 681 | struct gb_i2c_transfer_op ops[0]; /* op_count of these */ | ||
| 682 | } __packed; | ||
| 683 | struct gb_i2c_transfer_response { | ||
| 684 | __u8 data[0]; /* inbound data */ | ||
| 685 | } __packed; | ||
| 686 | |||
| 687 | |||
| 688 | /* GPIO */ | ||
| 689 | |||
| 690 | /* Greybus GPIO request types */ | ||
| 691 | #define GB_GPIO_TYPE_LINE_COUNT 0x02 | ||
| 692 | #define GB_GPIO_TYPE_ACTIVATE 0x03 | ||
| 693 | #define GB_GPIO_TYPE_DEACTIVATE 0x04 | ||
| 694 | #define GB_GPIO_TYPE_GET_DIRECTION 0x05 | ||
| 695 | #define GB_GPIO_TYPE_DIRECTION_IN 0x06 | ||
| 696 | #define GB_GPIO_TYPE_DIRECTION_OUT 0x07 | ||
| 697 | #define GB_GPIO_TYPE_GET_VALUE 0x08 | ||
| 698 | #define GB_GPIO_TYPE_SET_VALUE 0x09 | ||
| 699 | #define GB_GPIO_TYPE_SET_DEBOUNCE 0x0a | ||
| 700 | #define GB_GPIO_TYPE_IRQ_TYPE 0x0b | ||
| 701 | #define GB_GPIO_TYPE_IRQ_MASK 0x0c | ||
| 702 | #define GB_GPIO_TYPE_IRQ_UNMASK 0x0d | ||
| 703 | #define GB_GPIO_TYPE_IRQ_EVENT 0x0e | ||
| 704 | |||
| 705 | #define GB_GPIO_IRQ_TYPE_NONE 0x00 | ||
| 706 | #define GB_GPIO_IRQ_TYPE_EDGE_RISING 0x01 | ||
| 707 | #define GB_GPIO_IRQ_TYPE_EDGE_FALLING 0x02 | ||
| 708 | #define GB_GPIO_IRQ_TYPE_EDGE_BOTH 0x03 | ||
| 709 | #define GB_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04 | ||
| 710 | #define GB_GPIO_IRQ_TYPE_LEVEL_LOW 0x08 | ||
| 711 | |||
| 712 | /* line count request has no payload */ | ||
| 713 | struct gb_gpio_line_count_response { | ||
| 714 | __u8 count; | ||
| 715 | } __packed; | ||
| 716 | |||
| 717 | struct gb_gpio_activate_request { | ||
| 718 | __u8 which; | ||
| 719 | } __packed; | ||
| 720 | /* activate response has no payload */ | ||
| 721 | |||
| 722 | struct gb_gpio_deactivate_request { | ||
| 723 | __u8 which; | ||
| 724 | } __packed; | ||
| 725 | /* deactivate response has no payload */ | ||
| 726 | |||
| 727 | struct gb_gpio_get_direction_request { | ||
| 728 | __u8 which; | ||
| 729 | } __packed; | ||
| 730 | struct gb_gpio_get_direction_response { | ||
| 731 | __u8 direction; | ||
| 732 | } __packed; | ||
| 733 | |||
| 734 | struct gb_gpio_direction_in_request { | ||
| 735 | __u8 which; | ||
| 736 | } __packed; | ||
| 737 | /* direction in response has no payload */ | ||
| 738 | |||
| 739 | struct gb_gpio_direction_out_request { | ||
| 740 | __u8 which; | ||
| 741 | __u8 value; | ||
| 742 | } __packed; | ||
| 743 | /* direction out response has no payload */ | ||
| 744 | |||
| 745 | struct gb_gpio_get_value_request { | ||
| 746 | __u8 which; | ||
| 747 | } __packed; | ||
| 748 | struct gb_gpio_get_value_response { | ||
| 749 | __u8 value; | ||
| 750 | } __packed; | ||
| 751 | |||
| 752 | struct gb_gpio_set_value_request { | ||
| 753 | __u8 which; | ||
| 754 | __u8 value; | ||
| 755 | } __packed; | ||
| 756 | /* set value response has no payload */ | ||
| 757 | |||
| 758 | struct gb_gpio_set_debounce_request { | ||
| 759 | __u8 which; | ||
| 760 | __le16 usec; | ||
| 761 | } __packed; | ||
| 762 | /* debounce response has no payload */ | ||
| 763 | |||
| 764 | struct gb_gpio_irq_type_request { | ||
| 765 | __u8 which; | ||
| 766 | __u8 type; | ||
| 767 | } __packed; | ||
| 768 | /* irq type response has no payload */ | ||
| 769 | |||
| 770 | struct gb_gpio_irq_mask_request { | ||
| 771 | __u8 which; | ||
| 772 | } __packed; | ||
| 773 | /* irq mask response has no payload */ | ||
| 774 | |||
| 775 | struct gb_gpio_irq_unmask_request { | ||
| 776 | __u8 which; | ||
| 777 | } __packed; | ||
| 778 | /* irq unmask response has no payload */ | ||
| 779 | |||
| 780 | /* irq event requests originate on another module and are handled on the AP */ | ||
| 781 | struct gb_gpio_irq_event_request { | ||
| 782 | __u8 which; | ||
| 783 | } __packed; | ||
| 784 | /* irq event has no response */ | ||
| 785 | |||
| 786 | |||
| 787 | /* PWM */ | ||
| 788 | |||
| 789 | /* Greybus PWM operation types */ | ||
| 790 | #define GB_PWM_TYPE_PWM_COUNT 0x02 | ||
| 791 | #define GB_PWM_TYPE_ACTIVATE 0x03 | ||
| 792 | #define GB_PWM_TYPE_DEACTIVATE 0x04 | ||
| 793 | #define GB_PWM_TYPE_CONFIG 0x05 | ||
| 794 | #define GB_PWM_TYPE_POLARITY 0x06 | ||
| 795 | #define GB_PWM_TYPE_ENABLE 0x07 | ||
| 796 | #define GB_PWM_TYPE_DISABLE 0x08 | ||
| 797 | |||
| 798 | /* pwm count request has no payload */ | ||
| 799 | struct gb_pwm_count_response { | ||
| 800 | __u8 count; | ||
| 801 | } __packed; | ||
| 802 | |||
| 803 | struct gb_pwm_activate_request { | ||
| 804 | __u8 which; | ||
| 805 | } __packed; | ||
| 806 | |||
| 807 | struct gb_pwm_deactivate_request { | ||
| 808 | __u8 which; | ||
| 809 | } __packed; | ||
| 810 | |||
| 811 | struct gb_pwm_config_request { | ||
| 812 | __u8 which; | ||
| 813 | __le32 duty; | ||
| 814 | __le32 period; | ||
| 815 | } __packed; | ||
| 816 | |||
| 817 | struct gb_pwm_polarity_request { | ||
| 818 | __u8 which; | ||
| 819 | __u8 polarity; | ||
| 820 | } __packed; | ||
| 821 | |||
| 822 | struct gb_pwm_enable_request { | ||
| 823 | __u8 which; | ||
| 824 | } __packed; | ||
| 825 | |||
| 826 | struct gb_pwm_disable_request { | ||
| 827 | __u8 which; | ||
| 828 | } __packed; | ||
| 829 | |||
| 830 | /* SPI */ | ||
| 831 | |||
| 832 | /* Should match up with modes in linux/spi/spi.h */ | ||
| 833 | #define GB_SPI_MODE_CPHA 0x01 /* clock phase */ | ||
| 834 | #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */ | ||
| 835 | #define GB_SPI_MODE_MODE_0 (0 | 0) /* (original MicroWire) */ | ||
| 836 | #define GB_SPI_MODE_MODE_1 (0 | GB_SPI_MODE_CPHA) | ||
| 837 | #define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL | 0) | ||
| 838 | #define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL | GB_SPI_MODE_CPHA) | ||
| 839 | #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */ | ||
| 840 | #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */ | ||
| 841 | #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */ | ||
| 842 | #define GB_SPI_MODE_LOOP 0x20 /* loopback mode */ | ||
| 843 | #define GB_SPI_MODE_NO_CS 0x40 /* 1 dev/bus, no chipselect */ | ||
| 844 | #define GB_SPI_MODE_READY 0x80 /* slave pulls low to pause */ | ||
| 845 | |||
| 846 | /* Should match up with flags in linux/spi/spi.h */ | ||
| 847 | #define GB_SPI_FLAG_HALF_DUPLEX BIT(0) /* can't do full duplex */ | ||
| 848 | #define GB_SPI_FLAG_NO_RX BIT(1) /* can't do buffer read */ | ||
| 849 | #define GB_SPI_FLAG_NO_TX BIT(2) /* can't do buffer write */ | ||
| 850 | |||
| 851 | /* Greybus spi operation types */ | ||
| 852 | #define GB_SPI_TYPE_MASTER_CONFIG 0x02 | ||
| 853 | #define GB_SPI_TYPE_DEVICE_CONFIG 0x03 | ||
| 854 | #define GB_SPI_TYPE_TRANSFER 0x04 | ||
| 855 | |||
| 856 | /* mode request has no payload */ | ||
| 857 | struct gb_spi_master_config_response { | ||
| 858 | __le32 bits_per_word_mask; | ||
| 859 | __le32 min_speed_hz; | ||
| 860 | __le32 max_speed_hz; | ||
| 861 | __le16 mode; | ||
| 862 | __le16 flags; | ||
| 863 | __u8 num_chipselect; | ||
| 864 | } __packed; | ||
| 865 | |||
| 866 | struct gb_spi_device_config_request { | ||
| 867 | __u8 chip_select; | ||
| 868 | } __packed; | ||
| 869 | |||
| 870 | struct gb_spi_device_config_response { | ||
| 871 | __le16 mode; | ||
| 872 | __u8 bits_per_word; | ||
| 873 | __le32 max_speed_hz; | ||
| 874 | __u8 device_type; | ||
| 875 | #define GB_SPI_SPI_DEV 0x00 | ||
| 876 | #define GB_SPI_SPI_NOR 0x01 | ||
| 877 | #define GB_SPI_SPI_MODALIAS 0x02 | ||
| 878 | __u8 name[32]; | ||
| 879 | } __packed; | ||
| 880 | |||
| 881 | /** | ||
| 882 | * struct gb_spi_transfer - a read/write buffer pair | ||
| 883 | * @speed_hz: Select a speed other than the device default for this transfer. If | ||
| 884 | * 0 the default (from @spi_device) is used. | ||
| 885 | * @len: size of rx and tx buffers (in bytes) | ||
| 886 | * @delay_usecs: microseconds to delay after this transfer before (optionally) | ||
| 887 | * changing the chipselect status, then starting the next transfer or | ||
| 888 | * completing this spi_message. | ||
| 889 | * @cs_change: affects chipselect after this transfer completes | ||
| 890 | * @bits_per_word: select a bits_per_word other than the device default for this | ||
| 891 | * transfer. If 0 the default (from @spi_device) is used. | ||
| 892 | */ | ||
| 893 | struct gb_spi_transfer { | ||
| 894 | __le32 speed_hz; | ||
| 895 | __le32 len; | ||
| 896 | __le16 delay_usecs; | ||
| 897 | __u8 cs_change; | ||
| 898 | __u8 bits_per_word; | ||
| 899 | __u8 xfer_flags; | ||
| 900 | #define GB_SPI_XFER_READ 0x01 | ||
| 901 | #define GB_SPI_XFER_WRITE 0x02 | ||
| 902 | #define GB_SPI_XFER_INPROGRESS 0x04 | ||
| 903 | } __packed; | ||
| 904 | |||
| 905 | struct gb_spi_transfer_request { | ||
| 906 | __u8 chip_select; /* of the spi device */ | ||
| 907 | __u8 mode; /* of the spi device */ | ||
| 908 | __le16 count; | ||
| 909 | struct gb_spi_transfer transfers[0]; /* count of these */ | ||
| 910 | } __packed; | ||
| 911 | |||
| 912 | struct gb_spi_transfer_response { | ||
| 913 | __u8 data[0]; /* inbound data */ | ||
| 914 | } __packed; | ||
| 915 | |||
| 916 | /* Version of the Greybus SVC protocol we support */ | ||
| 917 | #define GB_SVC_VERSION_MAJOR 0x00 | ||
| 918 | #define GB_SVC_VERSION_MINOR 0x01 | ||
| 919 | |||
| 920 | /* Greybus SVC request types */ | ||
| 921 | #define GB_SVC_TYPE_PROTOCOL_VERSION 0x01 | ||
| 922 | #define GB_SVC_TYPE_SVC_HELLO 0x02 | ||
| 923 | #define GB_SVC_TYPE_INTF_DEVICE_ID 0x03 | ||
| 924 | #define GB_SVC_TYPE_INTF_RESET 0x06 | ||
| 925 | #define GB_SVC_TYPE_CONN_CREATE 0x07 | ||
| 926 | #define GB_SVC_TYPE_CONN_DESTROY 0x08 | ||
| 927 | #define GB_SVC_TYPE_DME_PEER_GET 0x09 | ||
| 928 | #define GB_SVC_TYPE_DME_PEER_SET 0x0a | ||
| 929 | #define GB_SVC_TYPE_ROUTE_CREATE 0x0b | ||
| 930 | #define GB_SVC_TYPE_ROUTE_DESTROY 0x0c | ||
| 931 | #define GB_SVC_TYPE_TIMESYNC_ENABLE 0x0d | ||
| 932 | #define GB_SVC_TYPE_TIMESYNC_DISABLE 0x0e | ||
| 933 | #define GB_SVC_TYPE_TIMESYNC_AUTHORITATIVE 0x0f | ||
| 934 | #define GB_SVC_TYPE_INTF_SET_PWRM 0x10 | ||
| 935 | #define GB_SVC_TYPE_INTF_EJECT 0x11 | ||
| 936 | #define GB_SVC_TYPE_PING 0x13 | ||
| 937 | #define GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET 0x14 | ||
| 938 | #define GB_SVC_TYPE_PWRMON_RAIL_NAMES_GET 0x15 | ||
| 939 | #define GB_SVC_TYPE_PWRMON_SAMPLE_GET 0x16 | ||
| 940 | #define GB_SVC_TYPE_PWRMON_INTF_SAMPLE_GET 0x17 | ||
| 941 | #define GB_SVC_TYPE_TIMESYNC_WAKE_PINS_ACQUIRE 0x18 | ||
| 942 | #define GB_SVC_TYPE_TIMESYNC_WAKE_PINS_RELEASE 0x19 | ||
| 943 | #define GB_SVC_TYPE_TIMESYNC_PING 0x1a | ||
| 944 | #define GB_SVC_TYPE_MODULE_INSERTED 0x1f | ||
| 945 | #define GB_SVC_TYPE_MODULE_REMOVED 0x20 | ||
| 946 | #define GB_SVC_TYPE_INTF_VSYS_ENABLE 0x21 | ||
| 947 | #define GB_SVC_TYPE_INTF_VSYS_DISABLE 0x22 | ||
| 948 | #define GB_SVC_TYPE_INTF_REFCLK_ENABLE 0x23 | ||
| 949 | #define GB_SVC_TYPE_INTF_REFCLK_DISABLE 0x24 | ||
| 950 | #define GB_SVC_TYPE_INTF_UNIPRO_ENABLE 0x25 | ||
| 951 | #define GB_SVC_TYPE_INTF_UNIPRO_DISABLE 0x26 | ||
| 952 | #define GB_SVC_TYPE_INTF_ACTIVATE 0x27 | ||
| 953 | #define GB_SVC_TYPE_INTF_RESUME 0x28 | ||
| 954 | #define GB_SVC_TYPE_INTF_MAILBOX_EVENT 0x29 | ||
| 955 | #define GB_SVC_TYPE_INTF_OOPS 0x2a | ||
| 956 | |||
| 957 | /* Greybus SVC protocol status values */ | ||
| 958 | #define GB_SVC_OP_SUCCESS 0x00 | ||
| 959 | #define GB_SVC_OP_UNKNOWN_ERROR 0x01 | ||
| 960 | #define GB_SVC_INTF_NOT_DETECTED 0x02 | ||
| 961 | #define GB_SVC_INTF_NO_UPRO_LINK 0x03 | ||
| 962 | #define GB_SVC_INTF_UPRO_NOT_DOWN 0x04 | ||
| 963 | #define GB_SVC_INTF_UPRO_NOT_HIBERNATED 0x05 | ||
| 964 | #define GB_SVC_INTF_NO_V_SYS 0x06 | ||
| 965 | #define GB_SVC_INTF_V_CHG 0x07 | ||
| 966 | #define GB_SVC_INTF_WAKE_BUSY 0x08 | ||
| 967 | #define GB_SVC_INTF_NO_REFCLK 0x09 | ||
| 968 | #define GB_SVC_INTF_RELEASING 0x0a | ||
| 969 | #define GB_SVC_INTF_NO_ORDER 0x0b | ||
| 970 | #define GB_SVC_INTF_MBOX_SET 0x0c | ||
| 971 | #define GB_SVC_INTF_BAD_MBOX 0x0d | ||
| 972 | #define GB_SVC_INTF_OP_TIMEOUT 0x0e | ||
| 973 | #define GB_SVC_PWRMON_OP_NOT_PRESENT 0x0f | ||
| 974 | |||
| 975 | struct gb_svc_version_request { | ||
| 976 | __u8 major; | ||
| 977 | __u8 minor; | ||
| 978 | } __packed; | ||
| 979 | |||
| 980 | struct gb_svc_version_response { | ||
| 981 | __u8 major; | ||
| 982 | __u8 minor; | ||
| 983 | } __packed; | ||
| 984 | |||
| 985 | /* SVC protocol hello request */ | ||
| 986 | struct gb_svc_hello_request { | ||
| 987 | __le16 endo_id; | ||
| 988 | __u8 interface_id; | ||
| 989 | } __packed; | ||
| 990 | /* hello response has no payload */ | ||
| 991 | |||
| 992 | struct gb_svc_intf_device_id_request { | ||
| 993 | __u8 intf_id; | ||
| 994 | __u8 device_id; | ||
| 995 | } __packed; | ||
| 996 | /* device id response has no payload */ | ||
| 997 | |||
| 998 | struct gb_svc_intf_reset_request { | ||
| 999 | __u8 intf_id; | ||
| 1000 | } __packed; | ||
| 1001 | /* interface reset response has no payload */ | ||
| 1002 | |||
| 1003 | struct gb_svc_intf_eject_request { | ||
| 1004 | __u8 intf_id; | ||
| 1005 | } __packed; | ||
| 1006 | /* interface eject response has no payload */ | ||
| 1007 | |||
| 1008 | struct gb_svc_conn_create_request { | ||
| 1009 | __u8 intf1_id; | ||
| 1010 | __le16 cport1_id; | ||
| 1011 | __u8 intf2_id; | ||
| 1012 | __le16 cport2_id; | ||
| 1013 | __u8 tc; | ||
| 1014 | __u8 flags; | ||
| 1015 | } __packed; | ||
| 1016 | /* connection create response has no payload */ | ||
| 1017 | |||
| 1018 | struct gb_svc_conn_destroy_request { | ||
| 1019 | __u8 intf1_id; | ||
| 1020 | __le16 cport1_id; | ||
| 1021 | __u8 intf2_id; | ||
| 1022 | __le16 cport2_id; | ||
| 1023 | } __packed; | ||
| 1024 | /* connection destroy response has no payload */ | ||
| 1025 | |||
| 1026 | struct gb_svc_dme_peer_get_request { | ||
| 1027 | __u8 intf_id; | ||
| 1028 | __le16 attr; | ||
| 1029 | __le16 selector; | ||
| 1030 | } __packed; | ||
| 1031 | |||
| 1032 | struct gb_svc_dme_peer_get_response { | ||
| 1033 | __le16 result_code; | ||
| 1034 | __le32 attr_value; | ||
| 1035 | } __packed; | ||
| 1036 | |||
| 1037 | struct gb_svc_dme_peer_set_request { | ||
| 1038 | __u8 intf_id; | ||
| 1039 | __le16 attr; | ||
| 1040 | __le16 selector; | ||
| 1041 | __le32 value; | ||
| 1042 | } __packed; | ||
| 1043 | |||
| 1044 | struct gb_svc_dme_peer_set_response { | ||
| 1045 | __le16 result_code; | ||
| 1046 | } __packed; | ||
| 1047 | |||
| 1048 | /* Greybus init-status values, currently retrieved using DME peer gets. */ | ||
| 1049 | #define GB_INIT_SPI_BOOT_STARTED 0x02 | ||
| 1050 | #define GB_INIT_TRUSTED_SPI_BOOT_FINISHED 0x03 | ||
| 1051 | #define GB_INIT_UNTRUSTED_SPI_BOOT_FINISHED 0x04 | ||
| 1052 | #define GB_INIT_BOOTROM_UNIPRO_BOOT_STARTED 0x06 | ||
| 1053 | #define GB_INIT_BOOTROM_FALLBACK_UNIPRO_BOOT_STARTED 0x09 | ||
| 1054 | #define GB_INIT_S2_LOADER_BOOT_STARTED 0x0D | ||
| 1055 | |||
| 1056 | struct gb_svc_route_create_request { | ||
| 1057 | __u8 intf1_id; | ||
| 1058 | __u8 dev1_id; | ||
| 1059 | __u8 intf2_id; | ||
| 1060 | __u8 dev2_id; | ||
| 1061 | } __packed; | ||
| 1062 | /* route create response has no payload */ | ||
| 1063 | |||
| 1064 | struct gb_svc_route_destroy_request { | ||
| 1065 | __u8 intf1_id; | ||
| 1066 | __u8 intf2_id; | ||
| 1067 | } __packed; | ||
| 1068 | /* route destroy response has no payload */ | ||
| 1069 | |||
| 1070 | /* used for svc_intf_vsys_{enable,disable} */ | ||
| 1071 | struct gb_svc_intf_vsys_request { | ||
| 1072 | __u8 intf_id; | ||
| 1073 | } __packed; | ||
| 1074 | |||
| 1075 | struct gb_svc_intf_vsys_response { | ||
| 1076 | __u8 result_code; | ||
| 1077 | #define GB_SVC_INTF_VSYS_OK 0x00 | ||
| 1078 | /* 0x01 is reserved */ | ||
| 1079 | #define GB_SVC_INTF_VSYS_FAIL 0x02 | ||
| 1080 | } __packed; | ||
| 1081 | |||
| 1082 | /* used for svc_intf_refclk_{enable,disable} */ | ||
| 1083 | struct gb_svc_intf_refclk_request { | ||
| 1084 | __u8 intf_id; | ||
| 1085 | } __packed; | ||
| 1086 | |||
| 1087 | struct gb_svc_intf_refclk_response { | ||
| 1088 | __u8 result_code; | ||
| 1089 | #define GB_SVC_INTF_REFCLK_OK 0x00 | ||
| 1090 | /* 0x01 is reserved */ | ||
| 1091 | #define GB_SVC_INTF_REFCLK_FAIL 0x02 | ||
| 1092 | } __packed; | ||
| 1093 | |||
| 1094 | /* used for svc_intf_unipro_{enable,disable} */ | ||
| 1095 | struct gb_svc_intf_unipro_request { | ||
| 1096 | __u8 intf_id; | ||
| 1097 | } __packed; | ||
| 1098 | |||
| 1099 | struct gb_svc_intf_unipro_response { | ||
| 1100 | __u8 result_code; | ||
| 1101 | #define GB_SVC_INTF_UNIPRO_OK 0x00 | ||
| 1102 | /* 0x01 is reserved */ | ||
| 1103 | #define GB_SVC_INTF_UNIPRO_FAIL 0x02 | ||
| 1104 | #define GB_SVC_INTF_UNIPRO_NOT_OFF 0x03 | ||
| 1105 | } __packed; | ||
| 1106 | |||
| 1107 | #define GB_SVC_UNIPRO_FAST_MODE 0x01 | ||
| 1108 | #define GB_SVC_UNIPRO_SLOW_MODE 0x02 | ||
| 1109 | #define GB_SVC_UNIPRO_FAST_AUTO_MODE 0x04 | ||
| 1110 | #define GB_SVC_UNIPRO_SLOW_AUTO_MODE 0x05 | ||
| 1111 | #define GB_SVC_UNIPRO_MODE_UNCHANGED 0x07 | ||
| 1112 | #define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11 | ||
| 1113 | #define GB_SVC_UNIPRO_OFF_MODE 0x12 | ||
| 1114 | |||
| 1115 | #define GB_SVC_SMALL_AMPLITUDE 0x01 | ||
| 1116 | #define GB_SVC_LARGE_AMPLITUDE 0x02 | ||
| 1117 | |||
| 1118 | #define GB_SVC_NO_DE_EMPHASIS 0x00 | ||
| 1119 | #define GB_SVC_SMALL_DE_EMPHASIS 0x01 | ||
| 1120 | #define GB_SVC_LARGE_DE_EMPHASIS 0x02 | ||
| 1121 | |||
| 1122 | #define GB_SVC_PWRM_RXTERMINATION 0x01 | ||
| 1123 | #define GB_SVC_PWRM_TXTERMINATION 0x02 | ||
| 1124 | #define GB_SVC_PWRM_LINE_RESET 0x04 | ||
| 1125 | #define GB_SVC_PWRM_SCRAMBLING 0x20 | ||
| 1126 | |||
| 1127 | #define GB_SVC_PWRM_QUIRK_HSSER 0x00000001 | ||
| 1128 | |||
| 1129 | #define GB_SVC_UNIPRO_HS_SERIES_A 0x01 | ||
| 1130 | #define GB_SVC_UNIPRO_HS_SERIES_B 0x02 | ||
| 1131 | |||
| 1132 | #define GB_SVC_SETPWRM_PWR_OK 0x00 | ||
| 1133 | #define GB_SVC_SETPWRM_PWR_LOCAL 0x01 | ||
| 1134 | #define GB_SVC_SETPWRM_PWR_REMOTE 0x02 | ||
| 1135 | #define GB_SVC_SETPWRM_PWR_BUSY 0x03 | ||
| 1136 | #define GB_SVC_SETPWRM_PWR_ERROR_CAP 0x04 | ||
| 1137 | #define GB_SVC_SETPWRM_PWR_FATAL_ERROR 0x05 | ||
| 1138 | |||
| 1139 | struct gb_svc_l2_timer_cfg { | ||
| 1140 | __le16 tsb_fc0_protection_timeout; | ||
| 1141 | __le16 tsb_tc0_replay_timeout; | ||
| 1142 | __le16 tsb_afc0_req_timeout; | ||
| 1143 | __le16 tsb_fc1_protection_timeout; | ||
| 1144 | __le16 tsb_tc1_replay_timeout; | ||
| 1145 | __le16 tsb_afc1_req_timeout; | ||
| 1146 | __le16 reserved_for_tc2[3]; | ||
| 1147 | __le16 reserved_for_tc3[3]; | ||
| 1148 | } __packed; | ||
| 1149 | |||
| 1150 | struct gb_svc_intf_set_pwrm_request { | ||
| 1151 | __u8 intf_id; | ||
| 1152 | __u8 hs_series; | ||
| 1153 | __u8 tx_mode; | ||
| 1154 | __u8 tx_gear; | ||
| 1155 | __u8 tx_nlanes; | ||
| 1156 | __u8 tx_amplitude; | ||
| 1157 | __u8 tx_hs_equalizer; | ||
| 1158 | __u8 rx_mode; | ||
| 1159 | __u8 rx_gear; | ||
| 1160 | __u8 rx_nlanes; | ||
| 1161 | __u8 flags; | ||
| 1162 | __le32 quirks; | ||
| 1163 | struct gb_svc_l2_timer_cfg local_l2timerdata, remote_l2timerdata; | ||
| 1164 | } __packed; | ||
| 1165 | |||
| 1166 | struct gb_svc_intf_set_pwrm_response { | ||
| 1167 | __u8 result_code; | ||
| 1168 | } __packed; | ||
| 1169 | |||
| 1170 | struct gb_svc_key_event_request { | ||
| 1171 | __le16 key_code; | ||
| 1172 | #define GB_KEYCODE_ARA 0x00 | ||
| 1173 | |||
| 1174 | __u8 key_event; | ||
| 1175 | #define GB_SVC_KEY_RELEASED 0x00 | ||
| 1176 | #define GB_SVC_KEY_PRESSED 0x01 | ||
| 1177 | } __packed; | ||
| 1178 | |||
| 1179 | #define GB_SVC_PWRMON_MAX_RAIL_COUNT 254 | ||
| 1180 | |||
| 1181 | struct gb_svc_pwrmon_rail_count_get_response { | ||
| 1182 | __u8 rail_count; | ||
| 1183 | } __packed; | ||
| 1184 | |||
| 1185 | #define GB_SVC_PWRMON_RAIL_NAME_BUFSIZE 32 | ||
| 1186 | |||
| 1187 | struct gb_svc_pwrmon_rail_names_get_response { | ||
| 1188 | __u8 status; | ||
| 1189 | __u8 name[0][GB_SVC_PWRMON_RAIL_NAME_BUFSIZE]; | ||
| 1190 | } __packed; | ||
| 1191 | |||
| 1192 | #define GB_SVC_PWRMON_TYPE_CURR 0x01 | ||
| 1193 | #define GB_SVC_PWRMON_TYPE_VOL 0x02 | ||
| 1194 | #define GB_SVC_PWRMON_TYPE_PWR 0x03 | ||
| 1195 | |||
| 1196 | #define GB_SVC_PWRMON_GET_SAMPLE_OK 0x00 | ||
| 1197 | #define GB_SVC_PWRMON_GET_SAMPLE_INVAL 0x01 | ||
| 1198 | #define GB_SVC_PWRMON_GET_SAMPLE_NOSUPP 0x02 | ||
| 1199 | #define GB_SVC_PWRMON_GET_SAMPLE_HWERR 0x03 | ||
| 1200 | |||
| 1201 | struct gb_svc_pwrmon_sample_get_request { | ||
| 1202 | __u8 rail_id; | ||
| 1203 | __u8 measurement_type; | ||
| 1204 | } __packed; | ||
| 1205 | |||
| 1206 | struct gb_svc_pwrmon_sample_get_response { | ||
| 1207 | __u8 result; | ||
| 1208 | __le32 measurement; | ||
| 1209 | } __packed; | ||
| 1210 | |||
| 1211 | struct gb_svc_pwrmon_intf_sample_get_request { | ||
| 1212 | __u8 intf_id; | ||
| 1213 | __u8 measurement_type; | ||
| 1214 | } __packed; | ||
| 1215 | |||
| 1216 | struct gb_svc_pwrmon_intf_sample_get_response { | ||
| 1217 | __u8 result; | ||
| 1218 | __le32 measurement; | ||
| 1219 | } __packed; | ||
| 1220 | |||
| 1221 | #define GB_SVC_MODULE_INSERTED_FLAG_NO_PRIMARY 0x0001 | ||
| 1222 | |||
| 1223 | struct gb_svc_module_inserted_request { | ||
| 1224 | __u8 primary_intf_id; | ||
| 1225 | __u8 intf_count; | ||
| 1226 | __le16 flags; | ||
| 1227 | } __packed; | ||
| 1228 | /* module_inserted response has no payload */ | ||
| 1229 | |||
| 1230 | struct gb_svc_module_removed_request { | ||
| 1231 | __u8 primary_intf_id; | ||
| 1232 | } __packed; | ||
| 1233 | /* module_removed response has no payload */ | ||
| 1234 | |||
| 1235 | struct gb_svc_intf_activate_request { | ||
| 1236 | __u8 intf_id; | ||
| 1237 | } __packed; | ||
| 1238 | |||
| 1239 | #define GB_SVC_INTF_TYPE_UNKNOWN 0x00 | ||
| 1240 | #define GB_SVC_INTF_TYPE_DUMMY 0x01 | ||
| 1241 | #define GB_SVC_INTF_TYPE_UNIPRO 0x02 | ||
| 1242 | #define GB_SVC_INTF_TYPE_GREYBUS 0x03 | ||
| 1243 | |||
| 1244 | struct gb_svc_intf_activate_response { | ||
| 1245 | __u8 status; | ||
| 1246 | __u8 intf_type; | ||
| 1247 | } __packed; | ||
| 1248 | |||
| 1249 | struct gb_svc_intf_resume_request { | ||
| 1250 | __u8 intf_id; | ||
| 1251 | } __packed; | ||
| 1252 | |||
| 1253 | struct gb_svc_intf_resume_response { | ||
| 1254 | __u8 status; | ||
| 1255 | } __packed; | ||
| 1256 | |||
| 1257 | #define GB_SVC_INTF_MAILBOX_NONE 0x00 | ||
| 1258 | #define GB_SVC_INTF_MAILBOX_AP 0x01 | ||
| 1259 | #define GB_SVC_INTF_MAILBOX_GREYBUS 0x02 | ||
| 1260 | |||
| 1261 | struct gb_svc_intf_mailbox_event_request { | ||
| 1262 | __u8 intf_id; | ||
| 1263 | __le16 result_code; | ||
| 1264 | __le32 mailbox; | ||
| 1265 | } __packed; | ||
| 1266 | /* intf_mailbox_event response has no payload */ | ||
| 1267 | |||
| 1268 | struct gb_svc_intf_oops_request { | ||
| 1269 | __u8 intf_id; | ||
| 1270 | __u8 reason; | ||
| 1271 | } __packed; | ||
| 1272 | /* intf_oops response has no payload */ | ||
| 1273 | |||
| 1274 | |||
| 1275 | /* RAW */ | ||
| 1276 | |||
| 1277 | /* Greybus raw request types */ | ||
| 1278 | #define GB_RAW_TYPE_SEND 0x02 | ||
| 1279 | |||
| 1280 | struct gb_raw_send_request { | ||
| 1281 | __le32 len; | ||
| 1282 | __u8 data[0]; | ||
| 1283 | } __packed; | ||
| 1284 | |||
| 1285 | |||
| 1286 | /* UART */ | ||
| 1287 | |||
| 1288 | /* Greybus UART operation types */ | ||
| 1289 | #define GB_UART_TYPE_SEND_DATA 0x02 | ||
| 1290 | #define GB_UART_TYPE_RECEIVE_DATA 0x03 /* Unsolicited data */ | ||
| 1291 | #define GB_UART_TYPE_SET_LINE_CODING 0x04 | ||
| 1292 | #define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05 | ||
| 1293 | #define GB_UART_TYPE_SEND_BREAK 0x06 | ||
| 1294 | #define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */ | ||
| 1295 | #define GB_UART_TYPE_RECEIVE_CREDITS 0x08 | ||
| 1296 | #define GB_UART_TYPE_FLUSH_FIFOS 0x09 | ||
| 1297 | |||
| 1298 | /* Represents data from AP -> Module */ | ||
| 1299 | struct gb_uart_send_data_request { | ||
| 1300 | __le16 size; | ||
| 1301 | __u8 data[0]; | ||
| 1302 | } __packed; | ||
| 1303 | |||
| 1304 | /* recv-data-request flags */ | ||
| 1305 | #define GB_UART_RECV_FLAG_FRAMING 0x01 /* Framing error */ | ||
| 1306 | #define GB_UART_RECV_FLAG_PARITY 0x02 /* Parity error */ | ||
| 1307 | #define GB_UART_RECV_FLAG_OVERRUN 0x04 /* Overrun error */ | ||
| 1308 | #define GB_UART_RECV_FLAG_BREAK 0x08 /* Break */ | ||
| 1309 | |||
| 1310 | /* Represents data from Module -> AP */ | ||
| 1311 | struct gb_uart_recv_data_request { | ||
| 1312 | __le16 size; | ||
| 1313 | __u8 flags; | ||
| 1314 | __u8 data[0]; | ||
| 1315 | } __packed; | ||
| 1316 | |||
| 1317 | struct gb_uart_receive_credits_request { | ||
| 1318 | __le16 count; | ||
| 1319 | } __packed; | ||
| 1320 | |||
| 1321 | struct gb_uart_set_line_coding_request { | ||
| 1322 | __le32 rate; | ||
| 1323 | __u8 format; | ||
| 1324 | #define GB_SERIAL_1_STOP_BITS 0 | ||
| 1325 | #define GB_SERIAL_1_5_STOP_BITS 1 | ||
| 1326 | #define GB_SERIAL_2_STOP_BITS 2 | ||
| 1327 | |||
| 1328 | __u8 parity; | ||
| 1329 | #define GB_SERIAL_NO_PARITY 0 | ||
| 1330 | #define GB_SERIAL_ODD_PARITY 1 | ||
| 1331 | #define GB_SERIAL_EVEN_PARITY 2 | ||
| 1332 | #define GB_SERIAL_MARK_PARITY 3 | ||
| 1333 | #define GB_SERIAL_SPACE_PARITY 4 | ||
| 1334 | |||
| 1335 | __u8 data_bits; | ||
| 1336 | |||
| 1337 | __u8 flow_control; | ||
| 1338 | #define GB_SERIAL_AUTO_RTSCTS_EN 0x1 | ||
| 1339 | } __packed; | ||
| 1340 | |||
| 1341 | /* output control lines */ | ||
| 1342 | #define GB_UART_CTRL_DTR 0x01 | ||
| 1343 | #define GB_UART_CTRL_RTS 0x02 | ||
| 1344 | |||
| 1345 | struct gb_uart_set_control_line_state_request { | ||
| 1346 | __u8 control; | ||
| 1347 | } __packed; | ||
| 1348 | |||
| 1349 | struct gb_uart_set_break_request { | ||
| 1350 | __u8 state; | ||
| 1351 | } __packed; | ||
| 1352 | |||
| 1353 | /* input control lines and line errors */ | ||
| 1354 | #define GB_UART_CTRL_DCD 0x01 | ||
| 1355 | #define GB_UART_CTRL_DSR 0x02 | ||
| 1356 | #define GB_UART_CTRL_RI 0x04 | ||
| 1357 | |||
| 1358 | struct gb_uart_serial_state_request { | ||
| 1359 | __u8 control; | ||
| 1360 | } __packed; | ||
| 1361 | |||
| 1362 | struct gb_uart_serial_flush_request { | ||
| 1363 | __u8 flags; | ||
| 1364 | #define GB_SERIAL_FLAG_FLUSH_TRANSMITTER 0x01 | ||
| 1365 | #define GB_SERIAL_FLAG_FLUSH_RECEIVER 0x02 | ||
| 1366 | } __packed; | ||
| 1367 | |||
| 1368 | /* Loopback */ | ||
| 1369 | |||
| 1370 | /* Greybus loopback request types */ | ||
| 1371 | #define GB_LOOPBACK_TYPE_PING 0x02 | ||
| 1372 | #define GB_LOOPBACK_TYPE_TRANSFER 0x03 | ||
| 1373 | #define GB_LOOPBACK_TYPE_SINK 0x04 | ||
| 1374 | |||
| 1375 | /* | ||
| 1376 | * Loopback request/response header format should be identical | ||
| 1377 | * to simplify bandwidth and data movement analysis. | ||
| 1378 | */ | ||
| 1379 | struct gb_loopback_transfer_request { | ||
| 1380 | __le32 len; | ||
| 1381 | __le32 reserved0; | ||
| 1382 | __le32 reserved1; | ||
| 1383 | __u8 data[0]; | ||
| 1384 | } __packed; | ||
| 1385 | |||
| 1386 | struct gb_loopback_transfer_response { | ||
| 1387 | __le32 len; | ||
| 1388 | __le32 reserved0; | ||
| 1389 | __le32 reserved1; | ||
| 1390 | __u8 data[0]; | ||
| 1391 | } __packed; | ||
| 1392 | |||
| 1393 | /* SDIO */ | ||
| 1394 | /* Greybus SDIO operation types */ | ||
| 1395 | #define GB_SDIO_TYPE_GET_CAPABILITIES 0x02 | ||
| 1396 | #define GB_SDIO_TYPE_SET_IOS 0x03 | ||
| 1397 | #define GB_SDIO_TYPE_COMMAND 0x04 | ||
| 1398 | #define GB_SDIO_TYPE_TRANSFER 0x05 | ||
| 1399 | #define GB_SDIO_TYPE_EVENT 0x06 | ||
| 1400 | |||
| 1401 | /* get caps response: request has no payload */ | ||
| 1402 | struct gb_sdio_get_caps_response { | ||
| 1403 | __le32 caps; | ||
| 1404 | #define GB_SDIO_CAP_NONREMOVABLE 0x00000001 | ||
| 1405 | #define GB_SDIO_CAP_4_BIT_DATA 0x00000002 | ||
| 1406 | #define GB_SDIO_CAP_8_BIT_DATA 0x00000004 | ||
| 1407 | #define GB_SDIO_CAP_MMC_HS 0x00000008 | ||
| 1408 | #define GB_SDIO_CAP_SD_HS 0x00000010 | ||
| 1409 | #define GB_SDIO_CAP_ERASE 0x00000020 | ||
| 1410 | #define GB_SDIO_CAP_1_2V_DDR 0x00000040 | ||
| 1411 | #define GB_SDIO_CAP_1_8V_DDR 0x00000080 | ||
| 1412 | #define GB_SDIO_CAP_POWER_OFF_CARD 0x00000100 | ||
| 1413 | #define GB_SDIO_CAP_UHS_SDR12 0x00000200 | ||
| 1414 | #define GB_SDIO_CAP_UHS_SDR25 0x00000400 | ||
| 1415 | #define GB_SDIO_CAP_UHS_SDR50 0x00000800 | ||
| 1416 | #define GB_SDIO_CAP_UHS_SDR104 0x00001000 | ||
| 1417 | #define GB_SDIO_CAP_UHS_DDR50 0x00002000 | ||
| 1418 | #define GB_SDIO_CAP_DRIVER_TYPE_A 0x00004000 | ||
| 1419 | #define GB_SDIO_CAP_DRIVER_TYPE_C 0x00008000 | ||
| 1420 | #define GB_SDIO_CAP_DRIVER_TYPE_D 0x00010000 | ||
| 1421 | #define GB_SDIO_CAP_HS200_1_2V 0x00020000 | ||
| 1422 | #define GB_SDIO_CAP_HS200_1_8V 0x00040000 | ||
| 1423 | #define GB_SDIO_CAP_HS400_1_2V 0x00080000 | ||
| 1424 | #define GB_SDIO_CAP_HS400_1_8V 0x00100000 | ||
| 1425 | |||
| 1426 | /* see possible values below at vdd */ | ||
| 1427 | __le32 ocr; | ||
| 1428 | __le32 f_min; | ||
| 1429 | __le32 f_max; | ||
| 1430 | __le16 max_blk_count; | ||
| 1431 | __le16 max_blk_size; | ||
| 1432 | } __packed; | ||
| 1433 | |||
| 1434 | /* set ios request: response has no payload */ | ||
| 1435 | struct gb_sdio_set_ios_request { | ||
| 1436 | __le32 clock; | ||
| 1437 | __le32 vdd; | ||
| 1438 | #define GB_SDIO_VDD_165_195 0x00000001 | ||
| 1439 | #define GB_SDIO_VDD_20_21 0x00000002 | ||
| 1440 | #define GB_SDIO_VDD_21_22 0x00000004 | ||
| 1441 | #define GB_SDIO_VDD_22_23 0x00000008 | ||
| 1442 | #define GB_SDIO_VDD_23_24 0x00000010 | ||
| 1443 | #define GB_SDIO_VDD_24_25 0x00000020 | ||
| 1444 | #define GB_SDIO_VDD_25_26 0x00000040 | ||
| 1445 | #define GB_SDIO_VDD_26_27 0x00000080 | ||
| 1446 | #define GB_SDIO_VDD_27_28 0x00000100 | ||
| 1447 | #define GB_SDIO_VDD_28_29 0x00000200 | ||
| 1448 | #define GB_SDIO_VDD_29_30 0x00000400 | ||
| 1449 | #define GB_SDIO_VDD_30_31 0x00000800 | ||
| 1450 | #define GB_SDIO_VDD_31_32 0x00001000 | ||
| 1451 | #define GB_SDIO_VDD_32_33 0x00002000 | ||
| 1452 | #define GB_SDIO_VDD_33_34 0x00004000 | ||
| 1453 | #define GB_SDIO_VDD_34_35 0x00008000 | ||
| 1454 | #define GB_SDIO_VDD_35_36 0x00010000 | ||
| 1455 | |||
| 1456 | __u8 bus_mode; | ||
| 1457 | #define GB_SDIO_BUSMODE_OPENDRAIN 0x00 | ||
| 1458 | #define GB_SDIO_BUSMODE_PUSHPULL 0x01 | ||
| 1459 | |||
| 1460 | __u8 power_mode; | ||
| 1461 | #define GB_SDIO_POWER_OFF 0x00 | ||
| 1462 | #define GB_SDIO_POWER_UP 0x01 | ||
| 1463 | #define GB_SDIO_POWER_ON 0x02 | ||
| 1464 | #define GB_SDIO_POWER_UNDEFINED 0x03 | ||
| 1465 | |||
| 1466 | __u8 bus_width; | ||
| 1467 | #define GB_SDIO_BUS_WIDTH_1 0x00 | ||
| 1468 | #define GB_SDIO_BUS_WIDTH_4 0x02 | ||
| 1469 | #define GB_SDIO_BUS_WIDTH_8 0x03 | ||
| 1470 | |||
| 1471 | __u8 timing; | ||
| 1472 | #define GB_SDIO_TIMING_LEGACY 0x00 | ||
| 1473 | #define GB_SDIO_TIMING_MMC_HS 0x01 | ||
| 1474 | #define GB_SDIO_TIMING_SD_HS 0x02 | ||
| 1475 | #define GB_SDIO_TIMING_UHS_SDR12 0x03 | ||
| 1476 | #define GB_SDIO_TIMING_UHS_SDR25 0x04 | ||
| 1477 | #define GB_SDIO_TIMING_UHS_SDR50 0x05 | ||
| 1478 | #define GB_SDIO_TIMING_UHS_SDR104 0x06 | ||
| 1479 | #define GB_SDIO_TIMING_UHS_DDR50 0x07 | ||
| 1480 | #define GB_SDIO_TIMING_MMC_DDR52 0x08 | ||
| 1481 | #define GB_SDIO_TIMING_MMC_HS200 0x09 | ||
| 1482 | #define GB_SDIO_TIMING_MMC_HS400 0x0A | ||
| 1483 | |||
| 1484 | __u8 signal_voltage; | ||
| 1485 | #define GB_SDIO_SIGNAL_VOLTAGE_330 0x00 | ||
| 1486 | #define GB_SDIO_SIGNAL_VOLTAGE_180 0x01 | ||
| 1487 | #define GB_SDIO_SIGNAL_VOLTAGE_120 0x02 | ||
| 1488 | |||
| 1489 | __u8 drv_type; | ||
| 1490 | #define GB_SDIO_SET_DRIVER_TYPE_B 0x00 | ||
| 1491 | #define GB_SDIO_SET_DRIVER_TYPE_A 0x01 | ||
| 1492 | #define GB_SDIO_SET_DRIVER_TYPE_C 0x02 | ||
| 1493 | #define GB_SDIO_SET_DRIVER_TYPE_D 0x03 | ||
| 1494 | } __packed; | ||
| 1495 | |||
| 1496 | /* command request */ | ||
| 1497 | struct gb_sdio_command_request { | ||
| 1498 | __u8 cmd; | ||
| 1499 | __u8 cmd_flags; | ||
| 1500 | #define GB_SDIO_RSP_NONE 0x00 | ||
| 1501 | #define GB_SDIO_RSP_PRESENT 0x01 | ||
| 1502 | #define GB_SDIO_RSP_136 0x02 | ||
| 1503 | #define GB_SDIO_RSP_CRC 0x04 | ||
| 1504 | #define GB_SDIO_RSP_BUSY 0x08 | ||
| 1505 | #define GB_SDIO_RSP_OPCODE 0x10 | ||
| 1506 | |||
| 1507 | __u8 cmd_type; | ||
| 1508 | #define GB_SDIO_CMD_AC 0x00 | ||
| 1509 | #define GB_SDIO_CMD_ADTC 0x01 | ||
| 1510 | #define GB_SDIO_CMD_BC 0x02 | ||
| 1511 | #define GB_SDIO_CMD_BCR 0x03 | ||
| 1512 | |||
| 1513 | __le32 cmd_arg; | ||
| 1514 | __le16 data_blocks; | ||
| 1515 | __le16 data_blksz; | ||
| 1516 | } __packed; | ||
| 1517 | |||
| 1518 | struct gb_sdio_command_response { | ||
| 1519 | __le32 resp[4]; | ||
| 1520 | } __packed; | ||
| 1521 | |||
| 1522 | /* transfer request */ | ||
| 1523 | struct gb_sdio_transfer_request { | ||
| 1524 | __u8 data_flags; | ||
| 1525 | #define GB_SDIO_DATA_WRITE 0x01 | ||
| 1526 | #define GB_SDIO_DATA_READ 0x02 | ||
| 1527 | #define GB_SDIO_DATA_STREAM 0x04 | ||
| 1528 | |||
| 1529 | __le16 data_blocks; | ||
| 1530 | __le16 data_blksz; | ||
| 1531 | __u8 data[0]; | ||
| 1532 | } __packed; | ||
| 1533 | |||
| 1534 | struct gb_sdio_transfer_response { | ||
| 1535 | __le16 data_blocks; | ||
| 1536 | __le16 data_blksz; | ||
| 1537 | __u8 data[0]; | ||
| 1538 | } __packed; | ||
| 1539 | |||
| 1540 | /* event request: generated by module and is defined as unidirectional */ | ||
| 1541 | struct gb_sdio_event_request { | ||
| 1542 | __u8 event; | ||
| 1543 | #define GB_SDIO_CARD_INSERTED 0x01 | ||
| 1544 | #define GB_SDIO_CARD_REMOVED 0x02 | ||
| 1545 | #define GB_SDIO_WP 0x04 | ||
| 1546 | } __packed; | ||
| 1547 | |||
| 1548 | /* Camera */ | ||
| 1549 | |||
| 1550 | /* Greybus Camera request types */ | ||
| 1551 | #define GB_CAMERA_TYPE_CAPABILITIES 0x02 | ||
| 1552 | #define GB_CAMERA_TYPE_CONFIGURE_STREAMS 0x03 | ||
| 1553 | #define GB_CAMERA_TYPE_CAPTURE 0x04 | ||
| 1554 | #define GB_CAMERA_TYPE_FLUSH 0x05 | ||
| 1555 | #define GB_CAMERA_TYPE_METADATA 0x06 | ||
| 1556 | |||
| 1557 | #define GB_CAMERA_MAX_STREAMS 4 | ||
| 1558 | #define GB_CAMERA_MAX_SETTINGS_SIZE 8192 | ||
| 1559 | |||
| 1560 | /* Greybus Camera Configure Streams request payload */ | ||
| 1561 | struct gb_camera_stream_config_request { | ||
| 1562 | __le16 width; | ||
| 1563 | __le16 height; | ||
| 1564 | __le16 format; | ||
| 1565 | __le16 padding; | ||
| 1566 | } __packed; | ||
| 1567 | |||
| 1568 | struct gb_camera_configure_streams_request { | ||
| 1569 | __u8 num_streams; | ||
| 1570 | __u8 flags; | ||
| 1571 | #define GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY 0x01 | ||
| 1572 | __le16 padding; | ||
| 1573 | struct gb_camera_stream_config_request config[0]; | ||
| 1574 | } __packed; | ||
| 1575 | |||
| 1576 | /* Greybus Camera Configure Streams response payload */ | ||
| 1577 | struct gb_camera_stream_config_response { | ||
| 1578 | __le16 width; | ||
| 1579 | __le16 height; | ||
| 1580 | __le16 format; | ||
| 1581 | __u8 virtual_channel; | ||
| 1582 | __u8 data_type[2]; | ||
| 1583 | __le16 max_pkt_size; | ||
| 1584 | __u8 padding; | ||
| 1585 | __le32 max_size; | ||
| 1586 | } __packed; | ||
| 1587 | |||
| 1588 | struct gb_camera_configure_streams_response { | ||
| 1589 | __u8 num_streams; | ||
| 1590 | #define GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED 0x01 | ||
| 1591 | __u8 flags; | ||
| 1592 | __u8 padding[2]; | ||
| 1593 | __le32 data_rate; | ||
| 1594 | struct gb_camera_stream_config_response config[0]; | ||
| 1595 | }; | ||
| 1596 | |||
| 1597 | /* Greybus Camera Capture request payload - response has no payload */ | ||
| 1598 | struct gb_camera_capture_request { | ||
| 1599 | __le32 request_id; | ||
| 1600 | __u8 streams; | ||
| 1601 | __u8 padding; | ||
| 1602 | __le16 num_frames; | ||
| 1603 | __u8 settings[0]; | ||
| 1604 | } __packed; | ||
| 1605 | |||
| 1606 | /* Greybus Camera Flush response payload - request has no payload */ | ||
| 1607 | struct gb_camera_flush_response { | ||
| 1608 | __le32 request_id; | ||
| 1609 | } __packed; | ||
| 1610 | |||
| 1611 | /* Greybus Camera Metadata request payload - operation has no response */ | ||
| 1612 | struct gb_camera_metadata_request { | ||
| 1613 | __le32 request_id; | ||
| 1614 | __le16 frame_number; | ||
| 1615 | __u8 stream; | ||
| 1616 | __u8 padding; | ||
| 1617 | __u8 metadata[0]; | ||
| 1618 | } __packed; | ||
| 1619 | |||
| 1620 | /* Lights */ | ||
| 1621 | |||
| 1622 | /* Greybus Lights request types */ | ||
| 1623 | #define GB_LIGHTS_TYPE_GET_LIGHTS 0x02 | ||
| 1624 | #define GB_LIGHTS_TYPE_GET_LIGHT_CONFIG 0x03 | ||
| 1625 | #define GB_LIGHTS_TYPE_GET_CHANNEL_CONFIG 0x04 | ||
| 1626 | #define GB_LIGHTS_TYPE_GET_CHANNEL_FLASH_CONFIG 0x05 | ||
| 1627 | #define GB_LIGHTS_TYPE_SET_BRIGHTNESS 0x06 | ||
| 1628 | #define GB_LIGHTS_TYPE_SET_BLINK 0x07 | ||
| 1629 | #define GB_LIGHTS_TYPE_SET_COLOR 0x08 | ||
| 1630 | #define GB_LIGHTS_TYPE_SET_FADE 0x09 | ||
| 1631 | #define GB_LIGHTS_TYPE_EVENT 0x0A | ||
| 1632 | #define GB_LIGHTS_TYPE_SET_FLASH_INTENSITY 0x0B | ||
| 1633 | #define GB_LIGHTS_TYPE_SET_FLASH_STROBE 0x0C | ||
| 1634 | #define GB_LIGHTS_TYPE_SET_FLASH_TIMEOUT 0x0D | ||
| 1635 | #define GB_LIGHTS_TYPE_GET_FLASH_FAULT 0x0E | ||
| 1636 | |||
| 1637 | /* Greybus Light modes */ | ||
| 1638 | |||
| 1639 | /* | ||
| 1640 | * if you add any specific mode below, update also the | ||
| 1641 | * GB_CHANNEL_MODE_DEFINED_RANGE value accordingly | ||
| 1642 | */ | ||
| 1643 | #define GB_CHANNEL_MODE_NONE 0x00000000 | ||
| 1644 | #define GB_CHANNEL_MODE_BATTERY 0x00000001 | ||
| 1645 | #define GB_CHANNEL_MODE_POWER 0x00000002 | ||
| 1646 | #define GB_CHANNEL_MODE_WIRELESS 0x00000004 | ||
| 1647 | #define GB_CHANNEL_MODE_BLUETOOTH 0x00000008 | ||
| 1648 | #define GB_CHANNEL_MODE_KEYBOARD 0x00000010 | ||
| 1649 | #define GB_CHANNEL_MODE_BUTTONS 0x00000020 | ||
| 1650 | #define GB_CHANNEL_MODE_NOTIFICATION 0x00000040 | ||
| 1651 | #define GB_CHANNEL_MODE_ATTENTION 0x00000080 | ||
| 1652 | #define GB_CHANNEL_MODE_FLASH 0x00000100 | ||
| 1653 | #define GB_CHANNEL_MODE_TORCH 0x00000200 | ||
| 1654 | #define GB_CHANNEL_MODE_INDICATOR 0x00000400 | ||
| 1655 | |||
| 1656 | /* Lights Mode valid bit values */ | ||
| 1657 | #define GB_CHANNEL_MODE_DEFINED_RANGE 0x000004FF | ||
| 1658 | #define GB_CHANNEL_MODE_VENDOR_RANGE 0x00F00000 | ||
| 1659 | |||
| 1660 | /* Greybus Light Channels Flags */ | ||
| 1661 | #define GB_LIGHT_CHANNEL_MULTICOLOR 0x00000001 | ||
| 1662 | #define GB_LIGHT_CHANNEL_FADER 0x00000002 | ||
| 1663 | #define GB_LIGHT_CHANNEL_BLINK 0x00000004 | ||
| 1664 | |||
| 1665 | /* get count of lights in module */ | ||
| 1666 | struct gb_lights_get_lights_response { | ||
| 1667 | __u8 lights_count; | ||
| 1668 | } __packed; | ||
| 1669 | |||
| 1670 | /* light config request payload */ | ||
| 1671 | struct gb_lights_get_light_config_request { | ||
| 1672 | __u8 id; | ||
| 1673 | } __packed; | ||
| 1674 | |||
| 1675 | /* light config response payload */ | ||
| 1676 | struct gb_lights_get_light_config_response { | ||
| 1677 | __u8 channel_count; | ||
| 1678 | __u8 name[32]; | ||
| 1679 | } __packed; | ||
| 1680 | |||
| 1681 | /* channel config request payload */ | ||
| 1682 | struct gb_lights_get_channel_config_request { | ||
| 1683 | __u8 light_id; | ||
| 1684 | __u8 channel_id; | ||
| 1685 | } __packed; | ||
| 1686 | |||
| 1687 | /* channel flash config request payload */ | ||
| 1688 | struct gb_lights_get_channel_flash_config_request { | ||
| 1689 | __u8 light_id; | ||
| 1690 | __u8 channel_id; | ||
| 1691 | } __packed; | ||
| 1692 | |||
| 1693 | /* channel config response payload */ | ||
| 1694 | struct gb_lights_get_channel_config_response { | ||
| 1695 | __u8 max_brightness; | ||
| 1696 | __le32 flags; | ||
| 1697 | __le32 color; | ||
| 1698 | __u8 color_name[32]; | ||
| 1699 | __le32 mode; | ||
| 1700 | __u8 mode_name[32]; | ||
| 1701 | } __packed; | ||
| 1702 | |||
| 1703 | /* channel flash config response payload */ | ||
| 1704 | struct gb_lights_get_channel_flash_config_response { | ||
| 1705 | __le32 intensity_min_uA; | ||
| 1706 | __le32 intensity_max_uA; | ||
| 1707 | __le32 intensity_step_uA; | ||
| 1708 | __le32 timeout_min_us; | ||
| 1709 | __le32 timeout_max_us; | ||
| 1710 | __le32 timeout_step_us; | ||
| 1711 | } __packed; | ||
| 1712 | |||
| 1713 | /* blink request payload: response have no payload */ | ||
| 1714 | struct gb_lights_blink_request { | ||
| 1715 | __u8 light_id; | ||
| 1716 | __u8 channel_id; | ||
| 1717 | __le16 time_on_ms; | ||
| 1718 | __le16 time_off_ms; | ||
| 1719 | } __packed; | ||
| 1720 | |||
| 1721 | /* set brightness request payload: response have no payload */ | ||
| 1722 | struct gb_lights_set_brightness_request { | ||
| 1723 | __u8 light_id; | ||
| 1724 | __u8 channel_id; | ||
| 1725 | __u8 brightness; | ||
| 1726 | } __packed; | ||
| 1727 | |||
| 1728 | /* set color request payload: response have no payload */ | ||
| 1729 | struct gb_lights_set_color_request { | ||
| 1730 | __u8 light_id; | ||
| 1731 | __u8 channel_id; | ||
| 1732 | __le32 color; | ||
| 1733 | } __packed; | ||
| 1734 | |||
| 1735 | /* set fade request payload: response have no payload */ | ||
| 1736 | struct gb_lights_set_fade_request { | ||
| 1737 | __u8 light_id; | ||
| 1738 | __u8 channel_id; | ||
| 1739 | __u8 fade_in; | ||
| 1740 | __u8 fade_out; | ||
| 1741 | } __packed; | ||
| 1742 | |||
| 1743 | /* event request: generated by module */ | ||
| 1744 | struct gb_lights_event_request { | ||
| 1745 | __u8 light_id; | ||
| 1746 | __u8 event; | ||
| 1747 | #define GB_LIGHTS_LIGHT_CONFIG 0x01 | ||
| 1748 | } __packed; | ||
| 1749 | |||
| 1750 | /* set flash intensity request payload: response have no payload */ | ||
| 1751 | struct gb_lights_set_flash_intensity_request { | ||
| 1752 | __u8 light_id; | ||
| 1753 | __u8 channel_id; | ||
| 1754 | __le32 intensity_uA; | ||
| 1755 | } __packed; | ||
| 1756 | |||
| 1757 | /* set flash strobe state request payload: response have no payload */ | ||
| 1758 | struct gb_lights_set_flash_strobe_request { | ||
| 1759 | __u8 light_id; | ||
| 1760 | __u8 channel_id; | ||
| 1761 | __u8 state; | ||
| 1762 | } __packed; | ||
| 1763 | |||
| 1764 | /* set flash timeout request payload: response have no payload */ | ||
| 1765 | struct gb_lights_set_flash_timeout_request { | ||
| 1766 | __u8 light_id; | ||
| 1767 | __u8 channel_id; | ||
| 1768 | __le32 timeout_us; | ||
| 1769 | } __packed; | ||
| 1770 | |||
| 1771 | /* get flash fault request payload */ | ||
| 1772 | struct gb_lights_get_flash_fault_request { | ||
| 1773 | __u8 light_id; | ||
| 1774 | __u8 channel_id; | ||
| 1775 | } __packed; | ||
| 1776 | |||
| 1777 | /* get flash fault response payload */ | ||
| 1778 | struct gb_lights_get_flash_fault_response { | ||
| 1779 | __le32 fault; | ||
| 1780 | #define GB_LIGHTS_FLASH_FAULT_OVER_VOLTAGE 0x00000000 | ||
| 1781 | #define GB_LIGHTS_FLASH_FAULT_TIMEOUT 0x00000001 | ||
| 1782 | #define GB_LIGHTS_FLASH_FAULT_OVER_TEMPERATURE 0x00000002 | ||
| 1783 | #define GB_LIGHTS_FLASH_FAULT_SHORT_CIRCUIT 0x00000004 | ||
| 1784 | #define GB_LIGHTS_FLASH_FAULT_OVER_CURRENT 0x00000008 | ||
| 1785 | #define GB_LIGHTS_FLASH_FAULT_INDICATOR 0x00000010 | ||
| 1786 | #define GB_LIGHTS_FLASH_FAULT_UNDER_VOLTAGE 0x00000020 | ||
| 1787 | #define GB_LIGHTS_FLASH_FAULT_INPUT_VOLTAGE 0x00000040 | ||
| 1788 | #define GB_LIGHTS_FLASH_FAULT_LED_OVER_TEMPERATURE 0x00000080 | ||
| 1789 | } __packed; | ||
| 1790 | |||
| 1791 | /* Audio */ | ||
| 1792 | |||
| 1793 | #define GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE 0x02 | ||
| 1794 | #define GB_AUDIO_TYPE_GET_TOPOLOGY 0x03 | ||
| 1795 | #define GB_AUDIO_TYPE_GET_CONTROL 0x04 | ||
| 1796 | #define GB_AUDIO_TYPE_SET_CONTROL 0x05 | ||
| 1797 | #define GB_AUDIO_TYPE_ENABLE_WIDGET 0x06 | ||
| 1798 | #define GB_AUDIO_TYPE_DISABLE_WIDGET 0x07 | ||
| 1799 | #define GB_AUDIO_TYPE_GET_PCM 0x08 | ||
| 1800 | #define GB_AUDIO_TYPE_SET_PCM 0x09 | ||
| 1801 | #define GB_AUDIO_TYPE_SET_TX_DATA_SIZE 0x0a | ||
| 1802 | /* 0x0b unused */ | ||
| 1803 | #define GB_AUDIO_TYPE_ACTIVATE_TX 0x0c | ||
| 1804 | #define GB_AUDIO_TYPE_DEACTIVATE_TX 0x0d | ||
| 1805 | #define GB_AUDIO_TYPE_SET_RX_DATA_SIZE 0x0e | ||
| 1806 | /* 0x0f unused */ | ||
| 1807 | #define GB_AUDIO_TYPE_ACTIVATE_RX 0x10 | ||
| 1808 | #define GB_AUDIO_TYPE_DEACTIVATE_RX 0x11 | ||
| 1809 | #define GB_AUDIO_TYPE_JACK_EVENT 0x12 | ||
| 1810 | #define GB_AUDIO_TYPE_BUTTON_EVENT 0x13 | ||
| 1811 | #define GB_AUDIO_TYPE_STREAMING_EVENT 0x14 | ||
| 1812 | #define GB_AUDIO_TYPE_SEND_DATA 0x15 | ||
| 1813 | |||
| 1814 | /* Module must be able to buffer 10ms of audio data, minimum */ | ||
| 1815 | #define GB_AUDIO_SAMPLE_BUFFER_MIN_US 10000 | ||
| 1816 | |||
| 1817 | #define GB_AUDIO_PCM_NAME_MAX 32 | ||
| 1818 | #define AUDIO_DAI_NAME_MAX 32 | ||
| 1819 | #define AUDIO_CONTROL_NAME_MAX 32 | ||
| 1820 | #define AUDIO_CTL_ELEM_NAME_MAX 44 | ||
| 1821 | #define AUDIO_ENUM_NAME_MAX 64 | ||
| 1822 | #define AUDIO_WIDGET_NAME_MAX 32 | ||
| 1823 | |||
| 1824 | /* See SNDRV_PCM_FMTBIT_* in Linux source */ | ||
| 1825 | #define GB_AUDIO_PCM_FMT_S8 BIT(0) | ||
| 1826 | #define GB_AUDIO_PCM_FMT_U8 BIT(1) | ||
| 1827 | #define GB_AUDIO_PCM_FMT_S16_LE BIT(2) | ||
| 1828 | #define GB_AUDIO_PCM_FMT_S16_BE BIT(3) | ||
| 1829 | #define GB_AUDIO_PCM_FMT_U16_LE BIT(4) | ||
| 1830 | #define GB_AUDIO_PCM_FMT_U16_BE BIT(5) | ||
| 1831 | #define GB_AUDIO_PCM_FMT_S24_LE BIT(6) | ||
| 1832 | #define GB_AUDIO_PCM_FMT_S24_BE BIT(7) | ||
| 1833 | #define GB_AUDIO_PCM_FMT_U24_LE BIT(8) | ||
| 1834 | #define GB_AUDIO_PCM_FMT_U24_BE BIT(9) | ||
| 1835 | #define GB_AUDIO_PCM_FMT_S32_LE BIT(10) | ||
| 1836 | #define GB_AUDIO_PCM_FMT_S32_BE BIT(11) | ||
| 1837 | #define GB_AUDIO_PCM_FMT_U32_LE BIT(12) | ||
| 1838 | #define GB_AUDIO_PCM_FMT_U32_BE BIT(13) | ||
| 1839 | |||
| 1840 | /* See SNDRV_PCM_RATE_* in Linux source */ | ||
| 1841 | #define GB_AUDIO_PCM_RATE_5512 BIT(0) | ||
| 1842 | #define GB_AUDIO_PCM_RATE_8000 BIT(1) | ||
| 1843 | #define GB_AUDIO_PCM_RATE_11025 BIT(2) | ||
| 1844 | #define GB_AUDIO_PCM_RATE_16000 BIT(3) | ||
| 1845 | #define GB_AUDIO_PCM_RATE_22050 BIT(4) | ||
| 1846 | #define GB_AUDIO_PCM_RATE_32000 BIT(5) | ||
| 1847 | #define GB_AUDIO_PCM_RATE_44100 BIT(6) | ||
| 1848 | #define GB_AUDIO_PCM_RATE_48000 BIT(7) | ||
| 1849 | #define GB_AUDIO_PCM_RATE_64000 BIT(8) | ||
| 1850 | #define GB_AUDIO_PCM_RATE_88200 BIT(9) | ||
| 1851 | #define GB_AUDIO_PCM_RATE_96000 BIT(10) | ||
| 1852 | #define GB_AUDIO_PCM_RATE_176400 BIT(11) | ||
| 1853 | #define GB_AUDIO_PCM_RATE_192000 BIT(12) | ||
| 1854 | |||
| 1855 | #define GB_AUDIO_STREAM_TYPE_CAPTURE 0x1 | ||
| 1856 | #define GB_AUDIO_STREAM_TYPE_PLAYBACK 0x2 | ||
| 1857 | |||
| 1858 | #define GB_AUDIO_CTL_ELEM_ACCESS_READ BIT(0) | ||
| 1859 | #define GB_AUDIO_CTL_ELEM_ACCESS_WRITE BIT(1) | ||
| 1860 | |||
| 1861 | /* See SNDRV_CTL_ELEM_TYPE_* in Linux source */ | ||
| 1862 | #define GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN 0x01 | ||
| 1863 | #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER 0x02 | ||
| 1864 | #define GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED 0x03 | ||
| 1865 | #define GB_AUDIO_CTL_ELEM_TYPE_INTEGER64 0x06 | ||
| 1866 | |||
| 1867 | /* See SNDRV_CTL_ELEM_IFACE_* in Linux source */ | ||
| 1868 | #define GB_AUDIO_CTL_ELEM_IFACE_CARD 0x00 | ||
| 1869 | #define GB_AUDIO_CTL_ELEM_IFACE_HWDEP 0x01 | ||
| 1870 | #define GB_AUDIO_CTL_ELEM_IFACE_MIXER 0x02 | ||
| 1871 | #define GB_AUDIO_CTL_ELEM_IFACE_PCM 0x03 | ||
| 1872 | #define GB_AUDIO_CTL_ELEM_IFACE_RAWMIDI 0x04 | ||
| 1873 | #define GB_AUDIO_CTL_ELEM_IFACE_TIMER 0x05 | ||
| 1874 | #define GB_AUDIO_CTL_ELEM_IFACE_SEQUENCER 0x06 | ||
| 1875 | |||
| 1876 | /* SNDRV_CTL_ELEM_ACCESS_* in Linux source */ | ||
| 1877 | #define GB_AUDIO_ACCESS_READ BIT(0) | ||
| 1878 | #define GB_AUDIO_ACCESS_WRITE BIT(1) | ||
| 1879 | #define GB_AUDIO_ACCESS_VOLATILE BIT(2) | ||
| 1880 | #define GB_AUDIO_ACCESS_TIMESTAMP BIT(3) | ||
| 1881 | #define GB_AUDIO_ACCESS_TLV_READ BIT(4) | ||
| 1882 | #define GB_AUDIO_ACCESS_TLV_WRITE BIT(5) | ||
| 1883 | #define GB_AUDIO_ACCESS_TLV_COMMAND BIT(6) | ||
| 1884 | #define GB_AUDIO_ACCESS_INACTIVE BIT(7) | ||
| 1885 | #define GB_AUDIO_ACCESS_LOCK BIT(8) | ||
| 1886 | #define GB_AUDIO_ACCESS_OWNER BIT(9) | ||
| 1887 | |||
| 1888 | /* enum snd_soc_dapm_type */ | ||
| 1889 | #define GB_AUDIO_WIDGET_TYPE_INPUT 0x0 | ||
| 1890 | #define GB_AUDIO_WIDGET_TYPE_OUTPUT 0x1 | ||
| 1891 | #define GB_AUDIO_WIDGET_TYPE_MUX 0x2 | ||
| 1892 | #define GB_AUDIO_WIDGET_TYPE_VIRT_MUX 0x3 | ||
| 1893 | #define GB_AUDIO_WIDGET_TYPE_VALUE_MUX 0x4 | ||
| 1894 | #define GB_AUDIO_WIDGET_TYPE_MIXER 0x5 | ||
| 1895 | #define GB_AUDIO_WIDGET_TYPE_MIXER_NAMED_CTL 0x6 | ||
| 1896 | #define GB_AUDIO_WIDGET_TYPE_PGA 0x7 | ||
| 1897 | #define GB_AUDIO_WIDGET_TYPE_OUT_DRV 0x8 | ||
| 1898 | #define GB_AUDIO_WIDGET_TYPE_ADC 0x9 | ||
| 1899 | #define GB_AUDIO_WIDGET_TYPE_DAC 0xa | ||
| 1900 | #define GB_AUDIO_WIDGET_TYPE_MICBIAS 0xb | ||
| 1901 | #define GB_AUDIO_WIDGET_TYPE_MIC 0xc | ||
| 1902 | #define GB_AUDIO_WIDGET_TYPE_HP 0xd | ||
| 1903 | #define GB_AUDIO_WIDGET_TYPE_SPK 0xe | ||
| 1904 | #define GB_AUDIO_WIDGET_TYPE_LINE 0xf | ||
| 1905 | #define GB_AUDIO_WIDGET_TYPE_SWITCH 0x10 | ||
| 1906 | #define GB_AUDIO_WIDGET_TYPE_VMID 0x11 | ||
| 1907 | #define GB_AUDIO_WIDGET_TYPE_PRE 0x12 | ||
| 1908 | #define GB_AUDIO_WIDGET_TYPE_POST 0x13 | ||
| 1909 | #define GB_AUDIO_WIDGET_TYPE_SUPPLY 0x14 | ||
| 1910 | #define GB_AUDIO_WIDGET_TYPE_REGULATOR_SUPPLY 0x15 | ||
| 1911 | #define GB_AUDIO_WIDGET_TYPE_CLOCK_SUPPLY 0x16 | ||
| 1912 | #define GB_AUDIO_WIDGET_TYPE_AIF_IN 0x17 | ||
| 1913 | #define GB_AUDIO_WIDGET_TYPE_AIF_OUT 0x18 | ||
| 1914 | #define GB_AUDIO_WIDGET_TYPE_SIGGEN 0x19 | ||
| 1915 | #define GB_AUDIO_WIDGET_TYPE_DAI_IN 0x1a | ||
| 1916 | #define GB_AUDIO_WIDGET_TYPE_DAI_OUT 0x1b | ||
| 1917 | #define GB_AUDIO_WIDGET_TYPE_DAI_LINK 0x1c | ||
| 1918 | |||
| 1919 | #define GB_AUDIO_WIDGET_STATE_DISABLED 0x01 | ||
| 1920 | #define GB_AUDIO_WIDGET_STATE_ENAABLED 0x02 | ||
| 1921 | |||
| 1922 | #define GB_AUDIO_JACK_EVENT_INSERTION 0x1 | ||
| 1923 | #define GB_AUDIO_JACK_EVENT_REMOVAL 0x2 | ||
| 1924 | |||
| 1925 | #define GB_AUDIO_BUTTON_EVENT_PRESS 0x1 | ||
| 1926 | #define GB_AUDIO_BUTTON_EVENT_RELEASE 0x2 | ||
| 1927 | |||
| 1928 | #define GB_AUDIO_STREAMING_EVENT_UNSPECIFIED 0x1 | ||
| 1929 | #define GB_AUDIO_STREAMING_EVENT_HALT 0x2 | ||
| 1930 | #define GB_AUDIO_STREAMING_EVENT_INTERNAL_ERROR 0x3 | ||
| 1931 | #define GB_AUDIO_STREAMING_EVENT_PROTOCOL_ERROR 0x4 | ||
| 1932 | #define GB_AUDIO_STREAMING_EVENT_FAILURE 0x5 | ||
| 1933 | #define GB_AUDIO_STREAMING_EVENT_UNDERRUN 0x6 | ||
| 1934 | #define GB_AUDIO_STREAMING_EVENT_OVERRUN 0x7 | ||
| 1935 | #define GB_AUDIO_STREAMING_EVENT_CLOCKING 0x8 | ||
| 1936 | #define GB_AUDIO_STREAMING_EVENT_DATA_LEN 0x9 | ||
| 1937 | |||
| 1938 | #define GB_AUDIO_INVALID_INDEX 0xff | ||
| 1939 | |||
| 1940 | /* enum snd_jack_types */ | ||
| 1941 | #define GB_AUDIO_JACK_HEADPHONE 0x0000001 | ||
| 1942 | #define GB_AUDIO_JACK_MICROPHONE 0x0000002 | ||
| 1943 | #define GB_AUDIO_JACK_HEADSET (GB_AUDIO_JACK_HEADPHONE | \ | ||
| 1944 | GB_AUDIO_JACK_MICROPHONE) | ||
| 1945 | #define GB_AUDIO_JACK_LINEOUT 0x0000004 | ||
| 1946 | #define GB_AUDIO_JACK_MECHANICAL 0x0000008 | ||
| 1947 | #define GB_AUDIO_JACK_VIDEOOUT 0x0000010 | ||
| 1948 | #define GB_AUDIO_JACK_AVOUT (GB_AUDIO_JACK_LINEOUT | \ | ||
| 1949 | GB_AUDIO_JACK_VIDEOOUT) | ||
| 1950 | #define GB_AUDIO_JACK_LINEIN 0x0000020 | ||
| 1951 | #define GB_AUDIO_JACK_OC_HPHL 0x0000040 | ||
| 1952 | #define GB_AUDIO_JACK_OC_HPHR 0x0000080 | ||
| 1953 | #define GB_AUDIO_JACK_MICROPHONE2 0x0000200 | ||
| 1954 | #define GB_AUDIO_JACK_ANC_HEADPHONE (GB_AUDIO_JACK_HEADPHONE | \ | ||
| 1955 | GB_AUDIO_JACK_MICROPHONE | \ | ||
| 1956 | GB_AUDIO_JACK_MICROPHONE2) | ||
| 1957 | /* Kept separate from switches to facilitate implementation */ | ||
| 1958 | #define GB_AUDIO_JACK_BTN_0 0x4000000 | ||
| 1959 | #define GB_AUDIO_JACK_BTN_1 0x2000000 | ||
| 1960 | #define GB_AUDIO_JACK_BTN_2 0x1000000 | ||
| 1961 | #define GB_AUDIO_JACK_BTN_3 0x0800000 | ||
| 1962 | |||
| 1963 | struct gb_audio_pcm { | ||
| 1964 | __u8 stream_name[GB_AUDIO_PCM_NAME_MAX]; | ||
| 1965 | __le32 formats; /* GB_AUDIO_PCM_FMT_* */ | ||
| 1966 | __le32 rates; /* GB_AUDIO_PCM_RATE_* */ | ||
| 1967 | __u8 chan_min; | ||
| 1968 | __u8 chan_max; | ||
| 1969 | __u8 sig_bits; /* number of bits of content */ | ||
| 1970 | } __packed; | ||
| 1971 | |||
| 1972 | struct gb_audio_dai { | ||
| 1973 | __u8 name[AUDIO_DAI_NAME_MAX]; | ||
| 1974 | __le16 data_cport; | ||
| 1975 | struct gb_audio_pcm capture; | ||
| 1976 | struct gb_audio_pcm playback; | ||
| 1977 | } __packed; | ||
| 1978 | |||
| 1979 | struct gb_audio_integer { | ||
| 1980 | __le32 min; | ||
| 1981 | __le32 max; | ||
| 1982 | __le32 step; | ||
| 1983 | } __packed; | ||
| 1984 | |||
| 1985 | struct gb_audio_integer64 { | ||
| 1986 | __le64 min; | ||
| 1987 | __le64 max; | ||
| 1988 | __le64 step; | ||
| 1989 | } __packed; | ||
| 1990 | |||
| 1991 | struct gb_audio_enumerated { | ||
| 1992 | __le32 items; | ||
| 1993 | __le16 names_length; | ||
| 1994 | __u8 names[0]; | ||
| 1995 | } __packed; | ||
| 1996 | |||
| 1997 | struct gb_audio_ctl_elem_info { /* See snd_ctl_elem_info in Linux source */ | ||
| 1998 | __u8 type; /* GB_AUDIO_CTL_ELEM_TYPE_* */ | ||
| 1999 | __le16 dimen[4]; | ||
| 2000 | union { | ||
| 2001 | struct gb_audio_integer integer; | ||
| 2002 | struct gb_audio_integer64 integer64; | ||
| 2003 | struct gb_audio_enumerated enumerated; | ||
| 2004 | } value; | ||
| 2005 | } __packed; | ||
| 2006 | |||
| 2007 | struct gb_audio_ctl_elem_value { /* See snd_ctl_elem_value in Linux source */ | ||
| 2008 | __le64 timestamp; /* XXX needed? */ | ||
| 2009 | union { | ||
| 2010 | __le32 integer_value[2]; /* consider CTL_DOUBLE_xxx */ | ||
| 2011 | __le64 integer64_value[2]; | ||
| 2012 | __le32 enumerated_item[2]; | ||
| 2013 | } value; | ||
| 2014 | } __packed; | ||
| 2015 | |||
| 2016 | struct gb_audio_control { | ||
| 2017 | __u8 name[AUDIO_CONTROL_NAME_MAX]; | ||
| 2018 | __u8 id; /* 0-63 */ | ||
| 2019 | __u8 iface; /* GB_AUDIO_IFACE_* */ | ||
| 2020 | __le16 data_cport; | ||
| 2021 | __le32 access; /* GB_AUDIO_ACCESS_* */ | ||
| 2022 | __u8 count; /* count of same elements */ | ||
| 2023 | __u8 count_values; /* count of values, max=2 for CTL_DOUBLE_xxx */ | ||
| 2024 | struct gb_audio_ctl_elem_info info; | ||
| 2025 | } __packed; | ||
| 2026 | |||
| 2027 | struct gb_audio_widget { | ||
| 2028 | __u8 name[AUDIO_WIDGET_NAME_MAX]; | ||
| 2029 | __u8 sname[AUDIO_WIDGET_NAME_MAX]; | ||
| 2030 | __u8 id; | ||
| 2031 | __u8 type; /* GB_AUDIO_WIDGET_TYPE_* */ | ||
| 2032 | __u8 state; /* GB_AUDIO_WIDGET_STATE_* */ | ||
| 2033 | __u8 ncontrols; | ||
| 2034 | struct gb_audio_control ctl[0]; /* 'ncontrols' entries */ | ||
| 2035 | } __packed; | ||
| 2036 | |||
| 2037 | struct gb_audio_route { | ||
| 2038 | __u8 source_id; /* widget id */ | ||
| 2039 | __u8 destination_id; /* widget id */ | ||
| 2040 | __u8 control_id; /* 0-63 */ | ||
| 2041 | __u8 index; /* Selection within the control */ | ||
| 2042 | } __packed; | ||
| 2043 | |||
| 2044 | struct gb_audio_topology { | ||
| 2045 | __u8 num_dais; | ||
| 2046 | __u8 num_controls; | ||
| 2047 | __u8 num_widgets; | ||
| 2048 | __u8 num_routes; | ||
| 2049 | __le32 size_dais; | ||
| 2050 | __le32 size_controls; | ||
| 2051 | __le32 size_widgets; | ||
| 2052 | __le32 size_routes; | ||
| 2053 | __le32 jack_type; | ||
| 2054 | /* | ||
| 2055 | * struct gb_audio_dai dai[num_dais]; | ||
| 2056 | * struct gb_audio_control controls[num_controls]; | ||
| 2057 | * struct gb_audio_widget widgets[num_widgets]; | ||
| 2058 | * struct gb_audio_route routes[num_routes]; | ||
| 2059 | */ | ||
| 2060 | __u8 data[0]; | ||
| 2061 | } __packed; | ||
| 2062 | |||
| 2063 | struct gb_audio_get_topology_size_response { | ||
| 2064 | __le16 size; | ||
| 2065 | } __packed; | ||
| 2066 | |||
| 2067 | struct gb_audio_get_topology_response { | ||
| 2068 | struct gb_audio_topology topology; | ||
| 2069 | } __packed; | ||
| 2070 | |||
| 2071 | struct gb_audio_get_control_request { | ||
| 2072 | __u8 control_id; | ||
| 2073 | __u8 index; | ||
| 2074 | } __packed; | ||
| 2075 | |||
| 2076 | struct gb_audio_get_control_response { | ||
| 2077 | struct gb_audio_ctl_elem_value value; | ||
| 2078 | } __packed; | ||
| 2079 | |||
| 2080 | struct gb_audio_set_control_request { | ||
| 2081 | __u8 control_id; | ||
| 2082 | __u8 index; | ||
| 2083 | struct gb_audio_ctl_elem_value value; | ||
| 2084 | } __packed; | ||
| 2085 | |||
| 2086 | struct gb_audio_enable_widget_request { | ||
| 2087 | __u8 widget_id; | ||
| 2088 | } __packed; | ||
| 2089 | |||
| 2090 | struct gb_audio_disable_widget_request { | ||
| 2091 | __u8 widget_id; | ||
| 2092 | } __packed; | ||
| 2093 | |||
| 2094 | struct gb_audio_get_pcm_request { | ||
| 2095 | __le16 data_cport; | ||
| 2096 | } __packed; | ||
| 2097 | |||
| 2098 | struct gb_audio_get_pcm_response { | ||
| 2099 | __le32 format; | ||
| 2100 | __le32 rate; | ||
| 2101 | __u8 channels; | ||
| 2102 | __u8 sig_bits; | ||
| 2103 | } __packed; | ||
| 2104 | |||
| 2105 | struct gb_audio_set_pcm_request { | ||
| 2106 | __le16 data_cport; | ||
| 2107 | __le32 format; | ||
| 2108 | __le32 rate; | ||
| 2109 | __u8 channels; | ||
| 2110 | __u8 sig_bits; | ||
| 2111 | } __packed; | ||
| 2112 | |||
| 2113 | struct gb_audio_set_tx_data_size_request { | ||
| 2114 | __le16 data_cport; | ||
| 2115 | __le16 size; | ||
| 2116 | } __packed; | ||
| 2117 | |||
| 2118 | struct gb_audio_activate_tx_request { | ||
| 2119 | __le16 data_cport; | ||
| 2120 | } __packed; | ||
| 2121 | |||
| 2122 | struct gb_audio_deactivate_tx_request { | ||
| 2123 | __le16 data_cport; | ||
| 2124 | } __packed; | ||
| 2125 | |||
| 2126 | struct gb_audio_set_rx_data_size_request { | ||
| 2127 | __le16 data_cport; | ||
| 2128 | __le16 size; | ||
| 2129 | } __packed; | ||
| 2130 | |||
| 2131 | struct gb_audio_activate_rx_request { | ||
| 2132 | __le16 data_cport; | ||
| 2133 | } __packed; | ||
| 2134 | |||
| 2135 | struct gb_audio_deactivate_rx_request { | ||
| 2136 | __le16 data_cport; | ||
| 2137 | } __packed; | ||
| 2138 | |||
| 2139 | struct gb_audio_jack_event_request { | ||
| 2140 | __u8 widget_id; | ||
| 2141 | __u8 jack_attribute; | ||
| 2142 | __u8 event; | ||
| 2143 | } __packed; | ||
| 2144 | |||
| 2145 | struct gb_audio_button_event_request { | ||
| 2146 | __u8 widget_id; | ||
| 2147 | __u8 button_id; | ||
| 2148 | __u8 event; | ||
| 2149 | } __packed; | ||
| 2150 | |||
| 2151 | struct gb_audio_streaming_event_request { | ||
| 2152 | __le16 data_cport; | ||
| 2153 | __u8 event; | ||
| 2154 | } __packed; | ||
| 2155 | |||
| 2156 | struct gb_audio_send_data_request { | ||
| 2157 | __le64 timestamp; | ||
| 2158 | __u8 data[0]; | ||
| 2159 | } __packed; | ||
| 2160 | |||
| 2161 | |||
| 2162 | /* Log */ | ||
| 2163 | |||
| 2164 | /* operations */ | ||
| 2165 | #define GB_LOG_TYPE_SEND_LOG 0x02 | ||
| 2166 | |||
| 2167 | /* length */ | ||
| 2168 | #define GB_LOG_MAX_LEN 1024 | ||
| 2169 | |||
| 2170 | struct gb_log_send_log_request { | ||
| 2171 | __le16 len; | ||
| 2172 | __u8 msg[0]; | ||
| 2173 | } __packed; | ||
| 2174 | |||
| 2175 | #endif /* __GREYBUS_PROTOCOLS_H */ | ||
| 2176 | |||
diff --git a/include/linux/greybus/hd.h b/include/linux/greybus/hd.h new file mode 100644 index 000000000000..348b76fabc9a --- /dev/null +++ b/include/linux/greybus/hd.h | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus Host Device | ||
| 4 | * | ||
| 5 | * Copyright 2014-2015 Google Inc. | ||
| 6 | * Copyright 2014-2015 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __HD_H | ||
| 10 | #define __HD_H | ||
| 11 | |||
| 12 | struct gb_host_device; | ||
| 13 | struct gb_message; | ||
| 14 | |||
| 15 | struct gb_hd_driver { | ||
| 16 | size_t hd_priv_size; | ||
| 17 | |||
| 18 | int (*cport_allocate)(struct gb_host_device *hd, int cport_id, | ||
| 19 | unsigned long flags); | ||
| 20 | void (*cport_release)(struct gb_host_device *hd, u16 cport_id); | ||
| 21 | int (*cport_enable)(struct gb_host_device *hd, u16 cport_id, | ||
| 22 | unsigned long flags); | ||
| 23 | int (*cport_disable)(struct gb_host_device *hd, u16 cport_id); | ||
| 24 | int (*cport_connected)(struct gb_host_device *hd, u16 cport_id); | ||
| 25 | int (*cport_flush)(struct gb_host_device *hd, u16 cport_id); | ||
| 26 | int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id, | ||
| 27 | u8 phase, unsigned int timeout); | ||
| 28 | int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id, | ||
| 29 | size_t peer_space, unsigned int timeout); | ||
| 30 | int (*cport_clear)(struct gb_host_device *hd, u16 cport_id); | ||
| 31 | |||
| 32 | int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id, | ||
| 33 | struct gb_message *message, gfp_t gfp_mask); | ||
| 34 | void (*message_cancel)(struct gb_message *message); | ||
| 35 | int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id); | ||
| 36 | int (*latency_tag_disable)(struct gb_host_device *hd, u16 cport_id); | ||
| 37 | int (*output)(struct gb_host_device *hd, void *req, u16 size, u8 cmd, | ||
| 38 | bool async); | ||
| 39 | }; | ||
| 40 | |||
| 41 | struct gb_host_device { | ||
| 42 | struct device dev; | ||
| 43 | int bus_id; | ||
| 44 | const struct gb_hd_driver *driver; | ||
| 45 | |||
| 46 | struct list_head modules; | ||
| 47 | struct list_head connections; | ||
| 48 | struct ida cport_id_map; | ||
| 49 | |||
| 50 | /* Number of CPorts supported by the UniPro IP */ | ||
| 51 | size_t num_cports; | ||
| 52 | |||
| 53 | /* Host device buffer constraints */ | ||
| 54 | size_t buffer_size_max; | ||
| 55 | |||
| 56 | struct gb_svc *svc; | ||
| 57 | /* Private data for the host driver */ | ||
| 58 | unsigned long hd_priv[0] __aligned(sizeof(s64)); | ||
| 59 | }; | ||
| 60 | #define to_gb_host_device(d) container_of(d, struct gb_host_device, dev) | ||
| 61 | |||
| 62 | int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id); | ||
| 63 | void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id); | ||
| 64 | int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id, | ||
| 65 | unsigned long flags); | ||
| 66 | void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id); | ||
| 67 | |||
| 68 | struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver, | ||
| 69 | struct device *parent, | ||
| 70 | size_t buffer_size_max, | ||
| 71 | size_t num_cports); | ||
| 72 | int gb_hd_add(struct gb_host_device *hd); | ||
| 73 | void gb_hd_del(struct gb_host_device *hd); | ||
| 74 | void gb_hd_shutdown(struct gb_host_device *hd); | ||
| 75 | void gb_hd_put(struct gb_host_device *hd); | ||
| 76 | int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd, | ||
| 77 | bool in_irq); | ||
| 78 | |||
| 79 | int gb_hd_init(void); | ||
| 80 | void gb_hd_exit(void); | ||
| 81 | |||
| 82 | #endif /* __HD_H */ | ||
diff --git a/include/linux/greybus/interface.h b/include/linux/greybus/interface.h new file mode 100644 index 000000000000..8fb1eacda302 --- /dev/null +++ b/include/linux/greybus/interface.h | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus Interface Block code | ||
| 4 | * | ||
| 5 | * Copyright 2014 Google Inc. | ||
| 6 | * Copyright 2014 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __INTERFACE_H | ||
| 10 | #define __INTERFACE_H | ||
| 11 | |||
| 12 | enum gb_interface_type { | ||
| 13 | GB_INTERFACE_TYPE_INVALID = 0, | ||
| 14 | GB_INTERFACE_TYPE_UNKNOWN, | ||
| 15 | GB_INTERFACE_TYPE_DUMMY, | ||
| 16 | GB_INTERFACE_TYPE_UNIPRO, | ||
| 17 | GB_INTERFACE_TYPE_GREYBUS, | ||
| 18 | }; | ||
| 19 | |||
| 20 | #define GB_INTERFACE_QUIRK_NO_CPORT_FEATURES BIT(0) | ||
| 21 | #define GB_INTERFACE_QUIRK_NO_INIT_STATUS BIT(1) | ||
| 22 | #define GB_INTERFACE_QUIRK_NO_GMP_IDS BIT(2) | ||
| 23 | #define GB_INTERFACE_QUIRK_FORCED_DISABLE BIT(3) | ||
| 24 | #define GB_INTERFACE_QUIRK_LEGACY_MODE_SWITCH BIT(4) | ||
| 25 | #define GB_INTERFACE_QUIRK_NO_BUNDLE_ACTIVATE BIT(5) | ||
| 26 | #define GB_INTERFACE_QUIRK_NO_PM BIT(6) | ||
| 27 | |||
| 28 | struct gb_interface { | ||
| 29 | struct device dev; | ||
| 30 | struct gb_control *control; | ||
| 31 | |||
| 32 | struct list_head bundles; | ||
| 33 | struct list_head module_node; | ||
| 34 | struct list_head manifest_descs; | ||
| 35 | u8 interface_id; /* Physical location within the Endo */ | ||
| 36 | u8 device_id; | ||
| 37 | u8 features; /* Feature flags set in the manifest */ | ||
| 38 | |||
| 39 | enum gb_interface_type type; | ||
| 40 | |||
| 41 | u32 ddbl1_manufacturer_id; | ||
| 42 | u32 ddbl1_product_id; | ||
| 43 | u32 vendor_id; | ||
| 44 | u32 product_id; | ||
| 45 | u64 serial_number; | ||
| 46 | |||
| 47 | struct gb_host_device *hd; | ||
| 48 | struct gb_module *module; | ||
| 49 | |||
| 50 | unsigned long quirks; | ||
| 51 | |||
| 52 | struct mutex mutex; | ||
| 53 | |||
| 54 | bool disconnected; | ||
| 55 | |||
| 56 | bool ejected; | ||
| 57 | bool removed; | ||
| 58 | bool active; | ||
| 59 | bool enabled; | ||
| 60 | bool mode_switch; | ||
| 61 | bool dme_read; | ||
| 62 | |||
| 63 | struct work_struct mode_switch_work; | ||
| 64 | struct completion mode_switch_completion; | ||
| 65 | }; | ||
| 66 | #define to_gb_interface(d) container_of(d, struct gb_interface, dev) | ||
| 67 | |||
| 68 | struct gb_interface *gb_interface_create(struct gb_module *module, | ||
| 69 | u8 interface_id); | ||
| 70 | int gb_interface_activate(struct gb_interface *intf); | ||
| 71 | void gb_interface_deactivate(struct gb_interface *intf); | ||
| 72 | int gb_interface_enable(struct gb_interface *intf); | ||
| 73 | void gb_interface_disable(struct gb_interface *intf); | ||
| 74 | int gb_interface_add(struct gb_interface *intf); | ||
| 75 | void gb_interface_del(struct gb_interface *intf); | ||
| 76 | void gb_interface_put(struct gb_interface *intf); | ||
| 77 | void gb_interface_mailbox_event(struct gb_interface *intf, u16 result, | ||
| 78 | u32 mailbox); | ||
| 79 | |||
| 80 | int gb_interface_request_mode_switch(struct gb_interface *intf); | ||
| 81 | |||
| 82 | #endif /* __INTERFACE_H */ | ||
diff --git a/include/linux/greybus/manifest.h b/include/linux/greybus/manifest.h new file mode 100644 index 000000000000..88aa7e44cad5 --- /dev/null +++ b/include/linux/greybus/manifest.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus manifest parsing | ||
| 4 | * | ||
| 5 | * Copyright 2014 Google Inc. | ||
| 6 | * Copyright 2014 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __MANIFEST_H | ||
| 10 | #define __MANIFEST_H | ||
| 11 | |||
| 12 | struct gb_interface; | ||
| 13 | bool gb_manifest_parse(struct gb_interface *intf, void *data, size_t size); | ||
| 14 | |||
| 15 | #endif /* __MANIFEST_H */ | ||
diff --git a/include/linux/greybus/module.h b/include/linux/greybus/module.h new file mode 100644 index 000000000000..2a27e520ee94 --- /dev/null +++ b/include/linux/greybus/module.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus Module code | ||
| 4 | * | ||
| 5 | * Copyright 2016 Google Inc. | ||
| 6 | * Copyright 2016 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __MODULE_H | ||
| 10 | #define __MODULE_H | ||
| 11 | |||
| 12 | struct gb_module { | ||
| 13 | struct device dev; | ||
| 14 | struct gb_host_device *hd; | ||
| 15 | |||
| 16 | struct list_head hd_node; | ||
| 17 | |||
| 18 | u8 module_id; | ||
| 19 | size_t num_interfaces; | ||
| 20 | |||
| 21 | bool disconnected; | ||
| 22 | |||
| 23 | struct gb_interface *interfaces[0]; | ||
| 24 | }; | ||
| 25 | #define to_gb_module(d) container_of(d, struct gb_module, dev) | ||
| 26 | |||
| 27 | struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id, | ||
| 28 | size_t num_interfaces); | ||
| 29 | int gb_module_add(struct gb_module *module); | ||
| 30 | void gb_module_del(struct gb_module *module); | ||
| 31 | void gb_module_put(struct gb_module *module); | ||
| 32 | |||
| 33 | #endif /* __MODULE_H */ | ||
diff --git a/include/linux/greybus/operation.h b/include/linux/greybus/operation.h new file mode 100644 index 000000000000..17ba3daf111b --- /dev/null +++ b/include/linux/greybus/operation.h | |||
| @@ -0,0 +1,224 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus operations | ||
| 4 | * | ||
| 5 | * Copyright 2014 Google Inc. | ||
| 6 | * Copyright 2014 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __OPERATION_H | ||
| 10 | #define __OPERATION_H | ||
| 11 | |||
| 12 | #include <linux/completion.h> | ||
| 13 | |||
| 14 | struct gb_operation; | ||
| 15 | |||
| 16 | /* The default amount of time a request is given to complete */ | ||
| 17 | #define GB_OPERATION_TIMEOUT_DEFAULT 1000 /* milliseconds */ | ||
| 18 | |||
| 19 | /* | ||
| 20 | * The top bit of the type in an operation message header indicates | ||
| 21 | * whether the message is a request (bit clear) or response (bit set) | ||
| 22 | */ | ||
| 23 | #define GB_MESSAGE_TYPE_RESPONSE ((u8)0x80) | ||
| 24 | |||
| 25 | enum gb_operation_result { | ||
| 26 | GB_OP_SUCCESS = 0x00, | ||
| 27 | GB_OP_INTERRUPTED = 0x01, | ||
| 28 | GB_OP_TIMEOUT = 0x02, | ||
| 29 | GB_OP_NO_MEMORY = 0x03, | ||
| 30 | GB_OP_PROTOCOL_BAD = 0x04, | ||
| 31 | GB_OP_OVERFLOW = 0x05, | ||
| 32 | GB_OP_INVALID = 0x06, | ||
| 33 | GB_OP_RETRY = 0x07, | ||
| 34 | GB_OP_NONEXISTENT = 0x08, | ||
| 35 | GB_OP_UNKNOWN_ERROR = 0xfe, | ||
| 36 | GB_OP_MALFUNCTION = 0xff, | ||
| 37 | }; | ||
| 38 | |||
| 39 | #define GB_OPERATION_MESSAGE_SIZE_MIN sizeof(struct gb_operation_msg_hdr) | ||
| 40 | #define GB_OPERATION_MESSAGE_SIZE_MAX U16_MAX | ||
| 41 | |||
| 42 | /* | ||
| 43 | * Protocol code should only examine the payload and payload_size fields, and | ||
| 44 | * host-controller drivers may use the hcpriv field. All other fields are | ||
| 45 | * intended to be private to the operations core code. | ||
| 46 | */ | ||
| 47 | struct gb_message { | ||
| 48 | struct gb_operation *operation; | ||
| 49 | struct gb_operation_msg_hdr *header; | ||
| 50 | |||
| 51 | void *payload; | ||
| 52 | size_t payload_size; | ||
| 53 | |||
| 54 | void *buffer; | ||
| 55 | |||
| 56 | void *hcpriv; | ||
| 57 | }; | ||
| 58 | |||
| 59 | #define GB_OPERATION_FLAG_INCOMING BIT(0) | ||
| 60 | #define GB_OPERATION_FLAG_UNIDIRECTIONAL BIT(1) | ||
| 61 | #define GB_OPERATION_FLAG_SHORT_RESPONSE BIT(2) | ||
| 62 | #define GB_OPERATION_FLAG_CORE BIT(3) | ||
| 63 | |||
| 64 | #define GB_OPERATION_FLAG_USER_MASK (GB_OPERATION_FLAG_SHORT_RESPONSE | \ | ||
| 65 | GB_OPERATION_FLAG_UNIDIRECTIONAL) | ||
| 66 | |||
| 67 | /* | ||
| 68 | * A Greybus operation is a remote procedure call performed over a | ||
| 69 | * connection between two UniPro interfaces. | ||
| 70 | * | ||
| 71 | * Every operation consists of a request message sent to the other | ||
| 72 | * end of the connection coupled with a reply message returned to | ||
| 73 | * the sender. Every operation has a type, whose interpretation is | ||
| 74 | * dependent on the protocol associated with the connection. | ||
| 75 | * | ||
| 76 | * Only four things in an operation structure are intended to be | ||
| 77 | * directly usable by protocol handlers: the operation's connection | ||
| 78 | * pointer; the operation type; the request message payload (and | ||
| 79 | * size); and the response message payload (and size). Note that a | ||
| 80 | * message with a 0-byte payload has a null message payload pointer. | ||
| 81 | * | ||
| 82 | * In addition, every operation has a result, which is an errno | ||
| 83 | * value. Protocol handlers access the operation result using | ||
| 84 | * gb_operation_result(). | ||
| 85 | */ | ||
| 86 | typedef void (*gb_operation_callback)(struct gb_operation *); | ||
| 87 | struct gb_operation { | ||
| 88 | struct gb_connection *connection; | ||
| 89 | struct gb_message *request; | ||
| 90 | struct gb_message *response; | ||
| 91 | |||
| 92 | unsigned long flags; | ||
| 93 | u8 type; | ||
| 94 | u16 id; | ||
| 95 | int errno; /* Operation result */ | ||
| 96 | |||
| 97 | struct work_struct work; | ||
| 98 | gb_operation_callback callback; | ||
| 99 | struct completion completion; | ||
| 100 | struct timer_list timer; | ||
| 101 | |||
| 102 | struct kref kref; | ||
| 103 | atomic_t waiters; | ||
| 104 | |||
| 105 | int active; | ||
| 106 | struct list_head links; /* connection->operations */ | ||
| 107 | |||
| 108 | void *private; | ||
| 109 | }; | ||
| 110 | |||
| 111 | static inline bool | ||
| 112 | gb_operation_is_incoming(struct gb_operation *operation) | ||
| 113 | { | ||
| 114 | return operation->flags & GB_OPERATION_FLAG_INCOMING; | ||
| 115 | } | ||
| 116 | |||
| 117 | static inline bool | ||
| 118 | gb_operation_is_unidirectional(struct gb_operation *operation) | ||
| 119 | { | ||
| 120 | return operation->flags & GB_OPERATION_FLAG_UNIDIRECTIONAL; | ||
| 121 | } | ||
| 122 | |||
| 123 | static inline bool | ||
| 124 | gb_operation_short_response_allowed(struct gb_operation *operation) | ||
| 125 | { | ||
| 126 | return operation->flags & GB_OPERATION_FLAG_SHORT_RESPONSE; | ||
| 127 | } | ||
| 128 | |||
| 129 | static inline bool gb_operation_is_core(struct gb_operation *operation) | ||
| 130 | { | ||
| 131 | return operation->flags & GB_OPERATION_FLAG_CORE; | ||
| 132 | } | ||
| 133 | |||
| 134 | void gb_connection_recv(struct gb_connection *connection, | ||
| 135 | void *data, size_t size); | ||
| 136 | |||
| 137 | int gb_operation_result(struct gb_operation *operation); | ||
| 138 | |||
| 139 | size_t gb_operation_get_payload_size_max(struct gb_connection *connection); | ||
| 140 | struct gb_operation * | ||
| 141 | gb_operation_create_flags(struct gb_connection *connection, | ||
| 142 | u8 type, size_t request_size, | ||
| 143 | size_t response_size, unsigned long flags, | ||
| 144 | gfp_t gfp); | ||
| 145 | |||
| 146 | static inline struct gb_operation * | ||
| 147 | gb_operation_create(struct gb_connection *connection, | ||
| 148 | u8 type, size_t request_size, | ||
| 149 | size_t response_size, gfp_t gfp) | ||
| 150 | { | ||
| 151 | return gb_operation_create_flags(connection, type, request_size, | ||
| 152 | response_size, 0, gfp); | ||
| 153 | } | ||
| 154 | |||
| 155 | struct gb_operation * | ||
| 156 | gb_operation_create_core(struct gb_connection *connection, | ||
| 157 | u8 type, size_t request_size, | ||
| 158 | size_t response_size, unsigned long flags, | ||
| 159 | gfp_t gfp); | ||
| 160 | |||
| 161 | void gb_operation_get(struct gb_operation *operation); | ||
| 162 | void gb_operation_put(struct gb_operation *operation); | ||
| 163 | |||
| 164 | bool gb_operation_response_alloc(struct gb_operation *operation, | ||
| 165 | size_t response_size, gfp_t gfp); | ||
| 166 | |||
| 167 | int gb_operation_request_send(struct gb_operation *operation, | ||
| 168 | gb_operation_callback callback, | ||
| 169 | unsigned int timeout, | ||
| 170 | gfp_t gfp); | ||
| 171 | int gb_operation_request_send_sync_timeout(struct gb_operation *operation, | ||
| 172 | unsigned int timeout); | ||
| 173 | static inline int | ||
| 174 | gb_operation_request_send_sync(struct gb_operation *operation) | ||
| 175 | { | ||
| 176 | return gb_operation_request_send_sync_timeout(operation, | ||
| 177 | GB_OPERATION_TIMEOUT_DEFAULT); | ||
| 178 | } | ||
| 179 | |||
| 180 | void gb_operation_cancel(struct gb_operation *operation, int errno); | ||
| 181 | void gb_operation_cancel_incoming(struct gb_operation *operation, int errno); | ||
| 182 | |||
| 183 | void greybus_message_sent(struct gb_host_device *hd, | ||
| 184 | struct gb_message *message, int status); | ||
| 185 | |||
| 186 | int gb_operation_sync_timeout(struct gb_connection *connection, int type, | ||
| 187 | void *request, int request_size, | ||
| 188 | void *response, int response_size, | ||
| 189 | unsigned int timeout); | ||
| 190 | int gb_operation_unidirectional_timeout(struct gb_connection *connection, | ||
| 191 | int type, void *request, int request_size, | ||
| 192 | unsigned int timeout); | ||
| 193 | |||
| 194 | static inline int gb_operation_sync(struct gb_connection *connection, int type, | ||
| 195 | void *request, int request_size, | ||
| 196 | void *response, int response_size) | ||
| 197 | { | ||
| 198 | return gb_operation_sync_timeout(connection, type, | ||
| 199 | request, request_size, response, response_size, | ||
| 200 | GB_OPERATION_TIMEOUT_DEFAULT); | ||
| 201 | } | ||
| 202 | |||
| 203 | static inline int gb_operation_unidirectional(struct gb_connection *connection, | ||
| 204 | int type, void *request, int request_size) | ||
| 205 | { | ||
| 206 | return gb_operation_unidirectional_timeout(connection, type, | ||
| 207 | request, request_size, GB_OPERATION_TIMEOUT_DEFAULT); | ||
| 208 | } | ||
| 209 | |||
| 210 | static inline void *gb_operation_get_data(struct gb_operation *operation) | ||
| 211 | { | ||
| 212 | return operation->private; | ||
| 213 | } | ||
| 214 | |||
| 215 | static inline void gb_operation_set_data(struct gb_operation *operation, | ||
| 216 | void *data) | ||
| 217 | { | ||
| 218 | operation->private = data; | ||
| 219 | } | ||
| 220 | |||
| 221 | int gb_operation_init(void); | ||
| 222 | void gb_operation_exit(void); | ||
| 223 | |||
| 224 | #endif /* !__OPERATION_H */ | ||
diff --git a/include/linux/greybus/svc.h b/include/linux/greybus/svc.h new file mode 100644 index 000000000000..e7452057cfe4 --- /dev/null +++ b/include/linux/greybus/svc.h | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | /* | ||
| 3 | * Greybus SVC code | ||
| 4 | * | ||
| 5 | * Copyright 2015 Google Inc. | ||
| 6 | * Copyright 2015 Linaro Ltd. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef __SVC_H | ||
| 10 | #define __SVC_H | ||
| 11 | |||
| 12 | #define GB_SVC_CPORT_FLAG_E2EFC BIT(0) | ||
| 13 | #define GB_SVC_CPORT_FLAG_CSD_N BIT(1) | ||
| 14 | #define GB_SVC_CPORT_FLAG_CSV_N BIT(2) | ||
| 15 | |||
| 16 | enum gb_svc_state { | ||
| 17 | GB_SVC_STATE_RESET, | ||
| 18 | GB_SVC_STATE_PROTOCOL_VERSION, | ||
| 19 | GB_SVC_STATE_SVC_HELLO, | ||
| 20 | }; | ||
| 21 | |||
| 22 | enum gb_svc_watchdog_bite { | ||
| 23 | GB_SVC_WATCHDOG_BITE_RESET_UNIPRO = 0, | ||
| 24 | GB_SVC_WATCHDOG_BITE_PANIC_KERNEL, | ||
| 25 | }; | ||
| 26 | |||
| 27 | struct gb_svc_watchdog; | ||
| 28 | |||
| 29 | struct svc_debugfs_pwrmon_rail { | ||
| 30 | u8 id; | ||
| 31 | struct gb_svc *svc; | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct gb_svc { | ||
| 35 | struct device dev; | ||
| 36 | |||
| 37 | struct gb_host_device *hd; | ||
| 38 | struct gb_connection *connection; | ||
| 39 | enum gb_svc_state state; | ||
| 40 | struct ida device_id_map; | ||
| 41 | struct workqueue_struct *wq; | ||
| 42 | |||
| 43 | u16 endo_id; | ||
| 44 | u8 ap_intf_id; | ||
| 45 | |||
| 46 | u8 protocol_major; | ||
| 47 | u8 protocol_minor; | ||
| 48 | |||
| 49 | struct gb_svc_watchdog *watchdog; | ||
| 50 | enum gb_svc_watchdog_bite action; | ||
| 51 | |||
| 52 | struct dentry *debugfs_dentry; | ||
| 53 | struct svc_debugfs_pwrmon_rail *pwrmon_rails; | ||
| 54 | }; | ||
| 55 | #define to_gb_svc(d) container_of(d, struct gb_svc, dev) | ||
| 56 | |||
| 57 | struct gb_svc *gb_svc_create(struct gb_host_device *hd); | ||
| 58 | int gb_svc_add(struct gb_svc *svc); | ||
| 59 | void gb_svc_del(struct gb_svc *svc); | ||
| 60 | void gb_svc_put(struct gb_svc *svc); | ||
| 61 | |||
| 62 | int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id, | ||
| 63 | u8 measurement_type, u32 *value); | ||
| 64 | int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id); | ||
| 65 | int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id, | ||
| 66 | u8 intf2_id, u8 dev2_id); | ||
| 67 | void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id); | ||
| 68 | int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, | ||
| 69 | u8 intf2_id, u16 cport2_id, u8 cport_flags); | ||
| 70 | void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, | ||
| 71 | u8 intf2_id, u16 cport2_id); | ||
| 72 | int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id); | ||
| 73 | int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable); | ||
| 74 | int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable); | ||
| 75 | int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable); | ||
| 76 | int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type); | ||
| 77 | int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id); | ||
| 78 | |||
| 79 | int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, | ||
| 80 | u32 *value); | ||
| 81 | int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, | ||
| 82 | u32 value); | ||
| 83 | int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series, | ||
| 84 | u8 tx_mode, u8 tx_gear, u8 tx_nlanes, | ||
| 85 | u8 tx_amplitude, u8 tx_hs_equalizer, | ||
| 86 | u8 rx_mode, u8 rx_gear, u8 rx_nlanes, | ||
| 87 | u8 flags, u32 quirks, | ||
| 88 | struct gb_svc_l2_timer_cfg *local, | ||
| 89 | struct gb_svc_l2_timer_cfg *remote); | ||
| 90 | int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id); | ||
| 91 | int gb_svc_ping(struct gb_svc *svc); | ||
| 92 | int gb_svc_watchdog_create(struct gb_svc *svc); | ||
| 93 | void gb_svc_watchdog_destroy(struct gb_svc *svc); | ||
| 94 | bool gb_svc_watchdog_enabled(struct gb_svc *svc); | ||
| 95 | int gb_svc_watchdog_enable(struct gb_svc *svc); | ||
| 96 | int gb_svc_watchdog_disable(struct gb_svc *svc); | ||
| 97 | |||
| 98 | int gb_svc_protocol_init(void); | ||
| 99 | void gb_svc_protocol_exit(void); | ||
| 100 | |||
| 101 | #endif /* __SVC_H */ | ||
