]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/greybus/connection.h
greybus: connection: Save major/minor supported by module
[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         u8                              module_major;
38         u8                              module_minor;
39
40         spinlock_t                      lock;
41         enum gb_connection_state        state;
42         struct list_head                operations;
43
44         struct workqueue_struct         *wq;
45
46         atomic_t                        op_cycle;
47
48         void                            *private;
49 };
50 #define to_gb_connection(d) container_of(d, struct gb_connection, dev)
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 greybus_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 int gb_connection_init(struct gb_connection *connection);
63 void gb_connection_exit(struct gb_connection *connection);
64 void gb_hd_connections_exit(struct greybus_host_device *hd);
65
66 void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
67                         u8 *data, size_t length);
68
69 void gb_connection_bind_protocol(struct gb_connection *connection);
70
71 #endif /* __CONNECTION_H */