]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/greybus/connection.h
greybus: s/bundle_cport_id/intf_cport_id
[karo-tx-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
15 enum gb_connection_state {
16         GB_CONNECTION_STATE_INVALID     = 0,
17         GB_CONNECTION_STATE_DISABLED    = 1,
18         GB_CONNECTION_STATE_ENABLED     = 2,
19         GB_CONNECTION_STATE_ERROR       = 3,
20         GB_CONNECTION_STATE_DESTROYING  = 4,
21 };
22
23 struct gb_connection {
24         struct greybus_host_device      *hd;
25         struct gb_bundle                *bundle;
26         struct device                   dev;
27         u16                             hd_cport_id;
28         u16                             intf_cport_id;
29
30         struct list_head                hd_links;
31         struct list_head                bundle_links;
32
33         struct gb_protocol              *protocol;
34         u8                              protocol_id;
35         u8                              major;
36         u8                              minor;
37
38         enum gb_connection_state        state;
39
40         atomic_t                        op_cycle;
41         struct list_head                operations;
42
43         void                            *private;
44 };
45 #define to_gb_connection(d) container_of(d, struct gb_connection, dev)
46
47 struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
48                                 u16 cport_id, u8 protocol_id);
49 void gb_connection_destroy(struct gb_connection *connection);
50
51 int gb_connection_init(struct gb_connection *connection);
52 void gb_connection_exit(struct gb_connection *connection);
53
54 struct gb_connection *gb_connection_hd_find(struct greybus_host_device *hd,
55                                 u16 cport_id);
56
57 void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
58                         u8 *data, size_t length);
59
60 void gb_connection_bind_protocol(struct gb_connection *connection);
61
62 #endif /* __CONNECTION_H */