Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Greybus connections |
| 3 | * |
| 4 | * Copyright 2014 Google Inc. |
Alex Elder | a46e967 | 2014-12-12 12:08:42 -0600 | [diff] [blame^] | 5 | * Copyright 2014 Linaro Ltd. |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 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 | #include "greybus.h" |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 16 | |
Alex Elder | 36561f2 | 2014-10-22 02:04:30 -0500 | [diff] [blame] | 17 | enum gb_connection_state { |
| 18 | GB_CONNECTION_STATE_INVALID = 0, |
| 19 | GB_CONNECTION_STATE_DISABLED = 1, |
| 20 | GB_CONNECTION_STATE_ENABLED = 2, |
| 21 | GB_CONNECTION_STATE_ERROR = 3, |
| 22 | GB_CONNECTION_STATE_DESTROYING = 4, |
| 23 | }; |
| 24 | |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 25 | struct gb_connection { |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 26 | struct greybus_host_device *hd; |
Alex Elder | cd34507 | 2014-10-02 12:30:05 -0500 | [diff] [blame] | 27 | struct gb_interface *interface; |
Greg Kroah-Hartman | f0f61b9 | 2014-10-24 17:34:46 +0800 | [diff] [blame] | 28 | struct device dev; |
Alex Elder | cd34507 | 2014-10-02 12:30:05 -0500 | [diff] [blame] | 29 | u16 hd_cport_id; |
| 30 | u16 interface_cport_id; |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 31 | |
Alex Elder | 2c43ce4 | 2014-11-17 08:08:44 -0600 | [diff] [blame] | 32 | struct list_head hd_links; |
Alex Elder | cd34507 | 2014-10-02 12:30:05 -0500 | [diff] [blame] | 33 | struct list_head interface_links; |
Alex Elder | 4ccb6b7 | 2014-10-28 19:36:00 -0500 | [diff] [blame] | 34 | |
| 35 | struct gb_protocol *protocol; |
Alex Elder | 7fba007 | 2014-10-28 19:35:59 -0500 | [diff] [blame] | 36 | |
Alex Elder | 36561f2 | 2014-10-22 02:04:30 -0500 | [diff] [blame] | 37 | enum gb_connection_state state; |
Alex Elder | e88afa5 | 2014-10-01 21:54:15 -0500 | [diff] [blame] | 38 | |
Alex Elder | 4afb7fd | 2014-12-03 08:35:08 -0600 | [diff] [blame] | 39 | atomic_t op_cycle; |
Alex Elder | e88afa5 | 2014-10-01 21:54:15 -0500 | [diff] [blame] | 40 | struct list_head operations; |
Alex Elder | 8a30672 | 2014-10-03 15:05:21 -0500 | [diff] [blame] | 41 | |
| 42 | void *private; |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 43 | }; |
Greg Kroah-Hartman | f0f61b9 | 2014-10-24 17:34:46 +0800 | [diff] [blame] | 44 | #define to_gb_connection(d) container_of(d, struct gb_connection, dev) |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 45 | |
Alex Elder | cd34507 | 2014-10-02 12:30:05 -0500 | [diff] [blame] | 46 | struct gb_connection *gb_connection_create(struct gb_interface *interface, |
Alex Elder | 7fba007 | 2014-10-28 19:35:59 -0500 | [diff] [blame] | 47 | u16 cport_id, u8 protocol_id); |
Alex Elder | b05890d | 2014-10-02 12:30:01 -0500 | [diff] [blame] | 48 | void gb_connection_destroy(struct gb_connection *connection); |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 49 | |
Alex Elder | 574341c | 2014-10-16 06:35:35 -0500 | [diff] [blame] | 50 | int gb_connection_init(struct gb_connection *connection); |
Alex Elder | 697e55d | 2014-10-20 23:01:04 -0500 | [diff] [blame] | 51 | void gb_connection_exit(struct gb_connection *connection); |
Alex Elder | 574341c | 2014-10-16 06:35:35 -0500 | [diff] [blame] | 52 | |
Alex Elder | ee9ebe4 | 2014-10-06 06:53:08 -0500 | [diff] [blame] | 53 | struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd, |
| 54 | u16 cport_id); |
| 55 | |
Alex Elder | de3557d | 2014-11-20 16:09:18 -0600 | [diff] [blame] | 56 | void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id, |
Alex Elder | 374e6a2 | 2014-11-17 18:08:37 -0600 | [diff] [blame] | 57 | u8 *data, size_t length); |
Alex Elder | eeeed42 | 2014-10-03 15:05:22 -0500 | [diff] [blame] | 58 | __printf(2, 3) |
| 59 | void gb_connection_err(struct gb_connection *connection, const char *fmt, ...); |
| 60 | |
Alex Elder | c68adb2 | 2014-10-01 21:54:14 -0500 | [diff] [blame] | 61 | #endif /* __CONNECTION_H */ |