greybus: hd: rename host-device structure
[cascardo/linux.git] / drivers / staging / greybus / connection.h
1 /*
2  * Greybus connections
3  *
4  * Copyright 2014 Google Inc.
5  * Copyright 2014 Linaro Ltd.
6  *
7  * Released under the GPLv2 only.
8  */
9
10 #ifndef __CONNECTION_H
11 #define __CONNECTION_H
12
13 #include <linux/list.h>
14 #include <linux/kfifo.h>
15
16 enum gb_connection_state {
17         GB_CONNECTION_STATE_INVALID     = 0,
18         GB_CONNECTION_STATE_DISABLED    = 1,
19         GB_CONNECTION_STATE_ENABLED     = 2,
20         GB_CONNECTION_STATE_ERROR       = 3,
21         GB_CONNECTION_STATE_DESTROYING  = 4,
22 };
23
24 struct gb_connection {
25         struct gb_host_device           *hd;
26         struct gb_bundle                *bundle;
27         struct kref                     kref;
28         u16                             hd_cport_id;
29         u16                             intf_cport_id;
30
31         struct list_head                hd_links;
32         struct list_head                bundle_links;
33
34         struct gb_protocol              *protocol;
35         u8                              protocol_id;
36         u8                              major;
37         u8                              minor;
38         u8                              module_major;
39         u8                              module_minor;
40
41         spinlock_t                      lock;
42         enum gb_connection_state        state;
43         struct list_head                operations;
44
45         struct workqueue_struct         *wq;
46
47         atomic_t                        op_cycle;
48
49         void                            *private;
50 };
51
52 int svc_update_connection(struct gb_interface *intf,
53                           struct gb_connection *connection);
54 struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
55                                 u16 cport_id, u8 protocol_id);
56 struct gb_connection *gb_connection_create_range(struct gb_host_device *hd,
57                            struct gb_bundle *bundle, struct device *parent,
58                            u16 cport_id, u8 protocol_id, u32 ida_start,
59                            u32 ida_end);
60 void gb_connection_destroy(struct gb_connection *connection);
61
62 void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
63                         u8 *data, size_t length);
64
65 int gb_connection_bind_protocol(struct gb_connection *connection);
66
67 void gb_connection_latency_tag_enable(struct gb_connection *connection);
68 void gb_connection_latency_tag_disable(struct gb_connection *connection);
69
70 #endif /* __CONNECTION_H */