blob: eaddfc9befd645d63e9b322d9704acaf200ec7e3 [file] [log] [blame]
Johan Hovold7bc6faa2015-11-03 18:03:22 +01001/*
2 * Greybus Host Device
3 *
4 * Copyright 2014-2015 Google Inc.
5 * Copyright 2014-2015 Linaro Ltd.
6 *
7 * Released under the GPLv2 only.
8 */
9
10#ifndef __HD_H
11#define __HD_H
12
Johan Hovold25376362015-11-03 18:03:23 +010013struct gb_host_device;
Johan Hovold7bc6faa2015-11-03 18:03:22 +010014struct gb_message;
15
Johan Hovolda8cc0202015-11-03 18:03:24 +010016struct gb_hd_driver {
Johan Hovold7bc6faa2015-11-03 18:03:22 +010017 size_t hd_priv_size;
18
Johan Hovold25376362015-11-03 18:03:23 +010019 int (*cport_enable)(struct gb_host_device *hd, u16 cport_id);
20 int (*cport_disable)(struct gb_host_device *hd, u16 cport_id);
21 int (*message_send)(struct gb_host_device *hd, u16 dest_cport_id,
Johan Hovold7bc6faa2015-11-03 18:03:22 +010022 struct gb_message *message, gfp_t gfp_mask);
23 void (*message_cancel)(struct gb_message *message);
Johan Hovold25376362015-11-03 18:03:23 +010024 int (*latency_tag_enable)(struct gb_host_device *hd, u16 cport_id);
25 int (*latency_tag_disable)(struct gb_host_device *hd, u16 cport_id);
Greg Kroah-Hartmaned4596e92015-12-22 18:21:51 -080026 int (*output)(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
27 bool async);
Fabien Parent9ed5e1b2016-02-23 18:46:08 +010028 int (*fct_flow_enable)(struct gb_host_device *hd, u16 cport_id);
29 int (*fct_flow_disable)(struct gb_host_device *hd, u16 cport_id);
Johan Hovold7bc6faa2015-11-03 18:03:22 +010030};
31
Johan Hovold25376362015-11-03 18:03:23 +010032struct gb_host_device {
Johan Hovold2adaefb2015-11-25 15:59:02 +010033 struct device dev;
34 int bus_id;
Johan Hovolda8cc0202015-11-03 18:03:24 +010035 const struct gb_hd_driver *driver;
Johan Hovold7bc6faa2015-11-03 18:03:22 +010036
37 struct list_head interfaces;
38 struct list_head connections;
39 struct ida cport_id_map;
40
41 /* Number of CPorts supported by the UniPro IP */
42 size_t num_cports;
43
44 /* Host device buffer constraints */
45 size_t buffer_size_max;
46
Johan Hovold7bc6faa2015-11-03 18:03:22 +010047 struct gb_svc *svc;
Johan Hovold7bc6faa2015-11-03 18:03:22 +010048 /* Private data for the host driver */
49 unsigned long hd_priv[0] __aligned(sizeof(s64));
50};
Johan Hovold2adaefb2015-11-25 15:59:02 +010051#define to_gb_host_device(d) container_of(d, struct gb_host_device, d)
Johan Hovold7bc6faa2015-11-03 18:03:22 +010052
Johan Hovoldd6e139b2015-11-03 18:03:25 +010053struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
54 struct device *parent,
55 size_t buffer_size_max,
56 size_t num_cports);
Johan Hovoldc1700472015-11-04 18:55:22 +010057int gb_hd_add(struct gb_host_device *hd);
58void gb_hd_del(struct gb_host_device *hd);
59void gb_hd_put(struct gb_host_device *hd);
Greg Kroah-Hartmaned4596e92015-12-22 18:21:51 -080060int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
61 bool in_irq);
Johan Hovold7bc6faa2015-11-03 18:03:22 +010062
Johan Hovold2adaefb2015-11-25 15:59:02 +010063int gb_hd_init(void);
64void gb_hd_exit(void);
65
Johan Hovold7bc6faa2015-11-03 18:03:22 +010066#endif /* __HD_H */