Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Greybus SVC code |
| 3 | * |
| 4 | * Copyright 2015 Google Inc. |
| 5 | * Copyright 2015 Linaro Ltd. |
| 6 | * |
| 7 | * Released under the GPLv2 only. |
| 8 | */ |
| 9 | |
| 10 | #ifndef __SVC_H |
| 11 | #define __SVC_H |
| 12 | |
Johan Hovold | 88f7b96 | 2015-11-25 15:59:08 +0100 | [diff] [blame] | 13 | enum gb_svc_state { |
| 14 | GB_SVC_STATE_RESET, |
| 15 | GB_SVC_STATE_PROTOCOL_VERSION, |
| 16 | GB_SVC_STATE_SVC_HELLO, |
| 17 | }; |
| 18 | |
Greg Kroah-Hartman | ed7279a | 2016-01-20 22:51:49 -0800 | [diff] [blame] | 19 | struct gb_svc_watchdog; |
| 20 | |
Johan Hovold | 88f7b96 | 2015-11-25 15:59:08 +0100 | [diff] [blame] | 21 | struct gb_svc { |
| 22 | struct device dev; |
| 23 | |
Johan Hovold | f0960d0 | 2015-12-03 19:18:02 +0100 | [diff] [blame] | 24 | struct gb_host_device *hd; |
Johan Hovold | 88f7b96 | 2015-11-25 15:59:08 +0100 | [diff] [blame] | 25 | struct gb_connection *connection; |
| 26 | enum gb_svc_state state; |
| 27 | struct ida device_id_map; |
Johan Hovold | 3e48aca | 2015-12-02 18:23:31 +0100 | [diff] [blame] | 28 | struct workqueue_struct *wq; |
Johan Hovold | 66069fb | 2015-11-25 15:59:09 +0100 | [diff] [blame] | 29 | |
| 30 | u16 endo_id; |
| 31 | u8 ap_intf_id; |
Johan Hovold | 357de00 | 2016-01-19 12:51:19 +0100 | [diff] [blame] | 32 | |
| 33 | u8 protocol_major; |
| 34 | u8 protocol_minor; |
Rui Miguel Silva | ebe99d6 | 2016-01-21 01:42:17 +0000 | [diff] [blame] | 35 | |
| 36 | struct input_dev *input; |
| 37 | char *input_phys; |
Greg Kroah-Hartman | ed7279a | 2016-01-20 22:51:49 -0800 | [diff] [blame] | 38 | struct gb_svc_watchdog *watchdog; |
Johan Hovold | 88f7b96 | 2015-11-25 15:59:08 +0100 | [diff] [blame] | 39 | }; |
| 40 | #define to_gb_svc(d) container_of(d, struct gb_svc, d) |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 41 | |
Johan Hovold | 7adeaae7 | 2015-12-07 15:05:37 +0100 | [diff] [blame] | 42 | struct gb_svc *gb_svc_create(struct gb_host_device *hd); |
| 43 | int gb_svc_add(struct gb_svc *svc); |
| 44 | void gb_svc_del(struct gb_svc *svc); |
| 45 | void gb_svc_put(struct gb_svc *svc); |
| 46 | |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 47 | int gb_svc_intf_reset(struct gb_svc *svc, u8 intf_id); |
| 48 | int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, |
Viresh Kumar | 1575ef1 | 2015-10-07 15:40:24 -0400 | [diff] [blame] | 49 | u8 intf2_id, u16 cport2_id, bool boot_over_unipro); |
Viresh Kumar | d9fcfff | 2015-08-31 17:21:05 +0530 | [diff] [blame] | 50 | void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, |
| 51 | u8 intf2_id, u16 cport2_id); |
Rui Miguel Silva | c5d55fb | 2016-01-11 13:46:31 +0000 | [diff] [blame] | 52 | int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id); |
Viresh Kumar | 19151c3 | 2015-09-09 21:08:29 +0530 | [diff] [blame] | 53 | int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, |
| 54 | u32 *value); |
| 55 | int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, |
| 56 | u32 value); |
Laurent Pinchart | aab4a1a | 2016-01-06 16:16:46 +0200 | [diff] [blame] | 57 | int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series, |
| 58 | u8 tx_mode, u8 tx_gear, u8 tx_nlanes, |
| 59 | u8 rx_mode, u8 rx_gear, u8 rx_nlanes, |
| 60 | u8 flags, u32 quirks); |
Greg Kroah-Hartman | 55ec09e | 2016-01-19 23:30:42 -0800 | [diff] [blame] | 61 | int gb_svc_ping(struct gb_svc *svc); |
Greg Kroah-Hartman | ed7279a | 2016-01-20 22:51:49 -0800 | [diff] [blame] | 62 | int gb_svc_watchdog_create(struct gb_svc *svc); |
| 63 | void gb_svc_watchdog_destroy(struct gb_svc *svc); |
Greg Kroah-Hartman | d562853 | 2016-01-26 15:17:08 -0800 | [diff] [blame] | 64 | bool gb_svc_watchdog_enabled(struct gb_svc *svc); |
| 65 | int gb_svc_watchdog_enable(struct gb_svc *svc); |
| 66 | int gb_svc_watchdog_disable(struct gb_svc *svc); |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 67 | |
Viresh Kumar | ab69c4c | 2015-07-03 17:00:29 +0530 | [diff] [blame] | 68 | int gb_svc_protocol_init(void); |
| 69 | void gb_svc_protocol_exit(void); |
Viresh Kumar | d3d4484 | 2015-07-21 17:44:18 +0530 | [diff] [blame] | 70 | |
Alex Elder | 30c6d9d | 2015-05-22 13:02:08 -0500 | [diff] [blame] | 71 | #endif /* __SVC_H */ |