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;
47 enum gb_connection_state state;
48 struct list_head operations;
51 struct workqueue_struct *wq;
58 struct gb_connection *gb_connection_create_static(struct gb_host_device *hd,
59 u16 hd_cport_id, u8 protocol_id);
60 struct gb_connection *gb_connection_create_dynamic(struct gb_interface *intf,
61 struct gb_bundle *bundle, u16 cport_id,
63 void gb_connection_destroy(struct gb_connection *connection);
65 static inline bool gb_connection_is_static(struct gb_connection *connection)
67 return !connection->intf;
70 int gb_connection_enable(struct gb_connection *connection,
71 gb_request_handler_t handler);
72 static inline int gb_connection_enable_tx(struct gb_connection *connection)
74 return gb_connection_enable(connection, NULL);
76 void gb_connection_disable_rx(struct gb_connection *connection);
77 void gb_connection_disable(struct gb_connection *connection);
79 void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
80 u8 *data, size_t length);
82 void gb_connection_latency_tag_enable(struct gb_connection *connection);
83 void gb_connection_latency_tag_disable(struct gb_connection *connection);
85 #endif /* __CONNECTION_H */