blob: b9fb93ea56beff63393fded20e451cdeae74ff7e [file] [log] [blame]
Alex Elder30c6d9d2015-05-22 13:02:08 -05001/*
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 Hovold88f7b962015-11-25 15:59:08 +010013enum gb_svc_state {
14 GB_SVC_STATE_RESET,
15 GB_SVC_STATE_PROTOCOL_VERSION,
16 GB_SVC_STATE_SVC_HELLO,
17};
18
Greg Kroah-Hartmaned7279a2016-01-20 22:51:49 -080019struct gb_svc_watchdog;
20
Johan Hovold88f7b962015-11-25 15:59:08 +010021struct gb_svc {
22 struct device dev;
23
Johan Hovoldf0960d02015-12-03 19:18:02 +010024 struct gb_host_device *hd;
Johan Hovold88f7b962015-11-25 15:59:08 +010025 struct gb_connection *connection;
26 enum gb_svc_state state;
27 struct ida device_id_map;
Johan Hovold3e48aca2015-12-02 18:23:31 +010028 struct workqueue_struct *wq;
Johan Hovold66069fb2015-11-25 15:59:09 +010029
30 u16 endo_id;
31 u8 ap_intf_id;
Johan Hovold357de002016-01-19 12:51:19 +010032
33 u8 protocol_major;
34 u8 protocol_minor;
Rui Miguel Silvaebe99d62016-01-21 01:42:17 +000035
36 struct input_dev *input;
37 char *input_phys;
Greg Kroah-Hartmaned7279a2016-01-20 22:51:49 -080038 struct gb_svc_watchdog *watchdog;
Johan Hovold88f7b962015-11-25 15:59:08 +010039};
40#define to_gb_svc(d) container_of(d, struct gb_svc, d)
Alex Elder30c6d9d2015-05-22 13:02:08 -050041
Johan Hovold7adeaae72015-12-07 15:05:37 +010042struct gb_svc *gb_svc_create(struct gb_host_device *hd);
43int gb_svc_add(struct gb_svc *svc);
44void gb_svc_del(struct gb_svc *svc);
45void gb_svc_put(struct gb_svc *svc);
46
Alex Elder30c6d9d2015-05-22 13:02:08 -050047int gb_svc_intf_reset(struct gb_svc *svc, u8 intf_id);
48int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
Viresh Kumar1575ef12015-10-07 15:40:24 -040049 u8 intf2_id, u16 cport2_id, bool boot_over_unipro);
Viresh Kumard9fcfff2015-08-31 17:21:05 +053050void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
51 u8 intf2_id, u16 cport2_id);
Rui Miguel Silvac5d55fb2016-01-11 13:46:31 +000052int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id);
Viresh Kumar19151c32015-09-09 21:08:29 +053053int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
54 u32 *value);
55int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
56 u32 value);
Laurent Pinchartaab4a1a2016-01-06 16:16:46 +020057int 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-Hartman55ec09e2016-01-19 23:30:42 -080061int gb_svc_ping(struct gb_svc *svc);
Greg Kroah-Hartmaned7279a2016-01-20 22:51:49 -080062int gb_svc_watchdog_create(struct gb_svc *svc);
63void gb_svc_watchdog_destroy(struct gb_svc *svc);
Greg Kroah-Hartmand5628532016-01-26 15:17:08 -080064bool gb_svc_watchdog_enabled(struct gb_svc *svc);
65int gb_svc_watchdog_enable(struct gb_svc *svc);
66int gb_svc_watchdog_disable(struct gb_svc *svc);
Alex Elder30c6d9d2015-05-22 13:02:08 -050067
Viresh Kumarab69c4c2015-07-03 17:00:29 +053068int gb_svc_protocol_init(void);
69void gb_svc_protocol_exit(void);
Viresh Kumard3d44842015-07-21 17:44:18 +053070
Alex Elder30c6d9d2015-05-22 13:02:08 -050071#endif /* __SVC_H */