Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 1 | /* |
| 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 Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 13 | struct gb_host_device; |
Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 14 | struct gb_message; |
| 15 | |
Johan Hovold | a8cc020 | 2015-11-03 18:03:24 +0100 | [diff] [blame] | 16 | struct gb_hd_driver { |
Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 17 | size_t hd_priv_size; |
| 18 | |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 19 | 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 Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 22 | struct gb_message *message, gfp_t gfp_mask); |
| 23 | void (*message_cancel)(struct gb_message *message); |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 24 | 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-Hartman | ed4596e9 | 2015-12-22 18:21:51 -0800 | [diff] [blame] | 26 | int (*output)(struct gb_host_device *hd, void *req, u16 size, u8 cmd, |
| 27 | bool async); |
Fabien Parent | 9ed5e1b | 2016-02-23 18:46:08 +0100 | [diff] [blame] | 28 | 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 Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 30 | }; |
| 31 | |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 32 | struct gb_host_device { |
Johan Hovold | 2adaefb | 2015-11-25 15:59:02 +0100 | [diff] [blame] | 33 | struct device dev; |
| 34 | int bus_id; |
Johan Hovold | a8cc020 | 2015-11-03 18:03:24 +0100 | [diff] [blame] | 35 | const struct gb_hd_driver *driver; |
Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 36 | |
| 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 Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 47 | struct gb_svc *svc; |
Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 48 | /* Private data for the host driver */ |
| 49 | unsigned long hd_priv[0] __aligned(sizeof(s64)); |
| 50 | }; |
Johan Hovold | 2adaefb | 2015-11-25 15:59:02 +0100 | [diff] [blame] | 51 | #define to_gb_host_device(d) container_of(d, struct gb_host_device, d) |
Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 52 | |
Johan Hovold | d6e139b | 2015-11-03 18:03:25 +0100 | [diff] [blame] | 53 | struct 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 Hovold | c170047 | 2015-11-04 18:55:22 +0100 | [diff] [blame] | 57 | int gb_hd_add(struct gb_host_device *hd); |
| 58 | void gb_hd_del(struct gb_host_device *hd); |
| 59 | void gb_hd_put(struct gb_host_device *hd); |
Greg Kroah-Hartman | ed4596e9 | 2015-12-22 18:21:51 -0800 | [diff] [blame] | 60 | int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd, |
| 61 | bool in_irq); |
Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 62 | |
Johan Hovold | 2adaefb | 2015-11-25 15:59:02 +0100 | [diff] [blame] | 63 | int gb_hd_init(void); |
| 64 | void gb_hd_exit(void); |
| 65 | |
Johan Hovold | 7bc6faa | 2015-11-03 18:03:22 +0100 | [diff] [blame] | 66 | #endif /* __HD_H */ |