Merge tag 'tag-chrome-platform-for-v5.2' of ssh://gitolite.kernel.org/pub/scm/linux...
[linux-2.6-microblaze.git] / drivers / staging / greybus / hd.h
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Greybus Host Device
4  *
5  * Copyright 2014-2015 Google Inc.
6  * Copyright 2014-2015 Linaro Ltd.
7  */
8
9 #ifndef __HD_H
10 #define __HD_H
11
12 struct gb_host_device;
13 struct gb_message;
14
15 struct gb_hd_driver {
16         size_t  hd_priv_size;
17
18         int (*cport_allocate)(struct gb_host_device *hd, int cport_id,
19                                 unsigned long flags);
20         void (*cport_release)(struct gb_host_device *hd, u16 cport_id);
21         int (*cport_enable)(struct gb_host_device *hd, u16 cport_id,
22                                 unsigned long flags);
23         int (*cport_disable)(struct gb_host_device *hd, u16 cport_id);
24         int (*cport_connected)(struct gb_host_device *hd, u16 cport_id);
25         int (*cport_flush)(struct gb_host_device *hd, u16 cport_id);
26         int (*cport_shutdown)(struct gb_host_device *hd, u16 cport_id,
27                                 u8 phase, unsigned int timeout);
28         int (*cport_quiesce)(struct gb_host_device *hd, u16 cport_id,
29                                 size_t peer_space, unsigned int timeout);
30         int (*cport_clear)(struct gb_host_device *hd, u16 cport_id);
31
32         int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id,
33                         struct gb_message *message, gfp_t gfp_mask);
34         void (*message_cancel)(struct gb_message *message);
35         int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
36         int (*latency_tag_disable)(struct gb_host_device *hd, u16 cport_id);
37         int (*output)(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
38                       bool async);
39 };
40
41 struct gb_host_device {
42         struct device dev;
43         int bus_id;
44         const struct gb_hd_driver *driver;
45
46         struct list_head modules;
47         struct list_head connections;
48         struct ida cport_id_map;
49
50         /* Number of CPorts supported by the UniPro IP */
51         size_t num_cports;
52
53         /* Host device buffer constraints */
54         size_t buffer_size_max;
55
56         struct gb_svc *svc;
57         /* Private data for the host driver */
58         unsigned long hd_priv[0] __aligned(sizeof(s64));
59 };
60 #define to_gb_host_device(d) container_of(d, struct gb_host_device, dev)
61
62 int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id);
63 void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id);
64 int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,
65                                         unsigned long flags);
66 void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id);
67
68 struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
69                                         struct device *parent,
70                                         size_t buffer_size_max,
71                                         size_t num_cports);
72 int gb_hd_add(struct gb_host_device *hd);
73 void gb_hd_del(struct gb_host_device *hd);
74 void gb_hd_shutdown(struct gb_host_device *hd);
75 void gb_hd_put(struct gb_host_device *hd);
76 int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
77                  bool in_irq);
78
79 int gb_hd_init(void);
80 void gb_hd_exit(void);
81
82 #endif  /* __HD_H */