4 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd.
7 * Released under the GPLv2 only.
10 #ifndef __CONNECTION_H
11 #define __CONNECTION_H
13 #include <linux/list.h>
14 #include <linux/kfifo.h>
16 enum gb_connection_state {
17 GB_CONNECTION_STATE_INVALID = 0,
18 GB_CONNECTION_STATE_DISABLED = 1,
19 GB_CONNECTION_STATE_ENABLED_TX = 2,
20 GB_CONNECTION_STATE_ENABLED = 3,
25 typedef int (*gb_request_handler_t)(struct gb_operation *);
27 struct gb_connection {
28 struct gb_host_device *hd;
29 struct gb_interface *intf;
30 struct gb_bundle *bundle;
35 struct list_head hd_links;
36 struct list_head bundle_links;
38 gb_request_handler_t handler;
40 struct gb_protocol *protocol;
49 enum gb_connection_state state;
50 struct list_head operations;
53 struct workqueue_struct *wq;
60 struct gb_connection *gb_connection_create_static(struct gb_host_device *hd,
61 u16 hd_cport_id, u8 protocol_id);
62 struct gb_connection *gb_connection_create_dynamic(struct gb_interface *intf,
63 struct gb_bundle *bundle, u16 cport_id,
65 void gb_connection_destroy(struct gb_connection *connection);
67 static inline bool gb_connection_is_static(struct gb_connection *connection)
69 return !connection->intf;
72 int gb_connection_enable(struct gb_connection *connection,
73 gb_request_handler_t handler);
74 static inline int gb_connection_enable_tx(struct gb_connection *connection)
76 return gb_connection_enable(connection, NULL);
78 void gb_connection_disable(struct gb_connection *connection);
80 int gb_connection_legacy_init(struct gb_connection *connection);
81 void gb_connection_legacy_exit(struct gb_connection *connection);
83 void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
84 u8 *data, size_t length);
86 void gb_connection_latency_tag_enable(struct gb_connection *connection);
87 void gb_connection_latency_tag_disable(struct gb_connection *connection);
89 #endif /* __CONNECTION_H */