History

Merge tag 'staging-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging and IIO driver updates from Greg KH: "Here is the big staging/iio driver update for 5.4-rc1. Lots of churn here, with a few driver/filesystems moving out of staging finally: - erofs moved out of staging - greybus core code moved out of staging Along with that, a new filesytem has been added: - extfat to provide support for those devices requiring that filesystem (i.e. transfer devices to/from windows systems or printers) Other than that, there a number of new IIO drivers, and lots and lots and lots of staging driver cleanups and minor fixes as people continue to dig into those for easy changes. All of these have been in linux-next for a while with no reported issues" * tag 'staging-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (453 commits) Staging: gasket: Use temporaries to reduce line length. Staging: octeon: Avoid several usecases of strcpy staging: vhciq_core: replace snprintf with scnprintf staging: wilc1000: avoid twice IRQ handler execution for each single interrupt staging: wilc1000: remove unused interrupt status handling code staging: fbtft: make several arrays static const, makes object smaller staging: rtl8188eu: make two arrays static const, makes object smaller staging: rtl8723bs: core: Remove Macro "IS_MAC_ADDRESS_BROADCAST" dt-bindings: anybus-controller: move to staging/ tree staging: emxx_udc: remove local TRUE/FALSE definition staging: wilc1000: look for rtc_clk clock staging: dt-bindings: wilc1000: add optional rtc_clk property staging: nvec: make use of devm_platform_ioremap_resource staging: exfat: drop unused function parameter Staging: exfat: Avoid use of strcpy staging: exfat: use integer constants staging: exfat: cleanup spacing for casts staging: exfat: cleanup spacing for operators staging: rtl8723bs: hal: remove redundant variable n staging: pi433: Fix typo in documentation ...

Linus Torvalds committed 7 years ago

Commit e6874fc2 parents e444d51 3fb73ed448 files · +20318 −12333Browse files

Showing the changes to include/linux (18 of 448 files). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t