blob: d1d7ef967385201f7dbdcfcf9f95c3fca6d2ce92 [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 Hovold9ba486e2016-03-29 18:55:59 -040013#define GB_SVC_CPORT_FLAG_E2EFC BIT(0)
14#define GB_SVC_CPORT_FLAG_CSD_N BIT(1)
15#define GB_SVC_CPORT_FLAG_CSV_N BIT(2)
Johan Hovold27f25c12016-03-03 13:34:38 +010016
Johan Hovold88f7b962015-11-25 15:59:08 +010017enum gb_svc_state {
18 GB_SVC_STATE_RESET,
19 GB_SVC_STATE_PROTOCOL_VERSION,
20 GB_SVC_STATE_SVC_HELLO,
21};
22
David Lin7c4a0ed2016-07-26 16:27:28 -070023enum gb_svc_watchdog_bite {
24 GB_SVC_WATCHDOG_BITE_RESET_UNIPRO = 0,
25 GB_SVC_WATCHDOG_BITE_PANIC_KERNEL,
26};
27
Greg Kroah-Hartmaned7279a2016-01-20 22:51:49 -080028struct gb_svc_watchdog;
29
David Lin95046772016-04-20 16:55:08 -070030struct svc_debugfs_pwrmon_rail {
31 u8 id;
32 struct gb_svc *svc;
33};
34
Johan Hovold88f7b962015-11-25 15:59:08 +010035struct gb_svc {
36 struct device dev;
37
Johan Hovoldf0960d02015-12-03 19:18:02 +010038 struct gb_host_device *hd;
Johan Hovold88f7b962015-11-25 15:59:08 +010039 struct gb_connection *connection;
40 enum gb_svc_state state;
41 struct ida device_id_map;
Johan Hovold3e48aca2015-12-02 18:23:31 +010042 struct workqueue_struct *wq;
Johan Hovold66069fb2015-11-25 15:59:09 +010043
44 u16 endo_id;
45 u8 ap_intf_id;
Johan Hovold357de002016-01-19 12:51:19 +010046
47 u8 protocol_major;
48 u8 protocol_minor;
Rui Miguel Silvaebe99d62016-01-21 01:42:17 +000049
Greg Kroah-Hartmaned7279a2016-01-20 22:51:49 -080050 struct gb_svc_watchdog *watchdog;
David Lin7c4a0ed2016-07-26 16:27:28 -070051 enum gb_svc_watchdog_bite action;
David Lin95046772016-04-20 16:55:08 -070052
53 struct dentry *debugfs_dentry;
54 struct svc_debugfs_pwrmon_rail *pwrmon_rails;
Johan Hovold88f7b962015-11-25 15:59:08 +010055};
Johan Hovoldb77e3e52016-03-30 16:53:17 -040056#define to_gb_svc(d) container_of(d, struct gb_svc, dev)
Alex Elder30c6d9d2015-05-22 13:02:08 -050057
Johan Hovold7adeaae72015-12-07 15:05:37 +010058struct gb_svc *gb_svc_create(struct gb_host_device *hd);
59int gb_svc_add(struct gb_svc *svc);
60void gb_svc_del(struct gb_svc *svc);
61void gb_svc_put(struct gb_svc *svc);
62
David Linddb10c82016-04-07 20:15:30 -070063int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id,
64 u8 measurement_type, u32 *value);
Johan Hovold4d5f6212016-03-29 18:56:04 -040065int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id);
66int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id,
67 u8 intf2_id, u8 dev2_id);
68void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id);
Alex Elder30c6d9d2015-05-22 13:02:08 -050069int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
Johan Hovold27f25c12016-03-03 13:34:38 +010070 u8 intf2_id, u16 cport2_id, u8 cport_flags);
Viresh Kumard9fcfff2015-08-31 17:21:05 +053071void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
72 u8 intf2_id, u16 cport2_id);
Rui Miguel Silvac5d55fb2016-01-11 13:46:31 +000073int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id);
Johan Hovold017482b2016-04-23 18:47:27 +020074int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable);
75int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable);
76int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable);
Johan Hovold1e8e22b2016-04-23 18:47:28 +020077int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type);
David Linfc8a4022016-07-07 22:07:00 -050078int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id);
79
Viresh Kumar19151c32015-09-09 21:08:29 +053080int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
81 u32 *value);
82int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
83 u32 value);
Laurent Pinchartaab4a1a2016-01-06 16:16:46 +020084int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series,
85 u8 tx_mode, u8 tx_gear, u8 tx_nlanes,
Eli Sennesh8c2522d2016-06-03 11:24:44 -040086 u8 tx_amplitude, u8 tx_hs_equalizer,
Laurent Pinchartaab4a1a2016-01-06 16:16:46 +020087 u8 rx_mode, u8 rx_gear, u8 rx_nlanes,
Eli Sennesh8c2522d2016-06-03 11:24:44 -040088 u8 flags, u32 quirks,
89 struct gb_svc_l2_timer_cfg *local,
90 struct gb_svc_l2_timer_cfg *remote);
David Linc7dc28f2016-07-07 22:07:00 -050091int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id);
Greg Kroah-Hartman55ec09e2016-01-19 23:30:42 -080092int gb_svc_ping(struct gb_svc *svc);
Greg Kroah-Hartmaned7279a2016-01-20 22:51:49 -080093int gb_svc_watchdog_create(struct gb_svc *svc);
94void gb_svc_watchdog_destroy(struct gb_svc *svc);
Greg Kroah-Hartmand5628532016-01-26 15:17:08 -080095bool gb_svc_watchdog_enabled(struct gb_svc *svc);
96int gb_svc_watchdog_enable(struct gb_svc *svc);
97int gb_svc_watchdog_disable(struct gb_svc *svc);
Bryan O'Donoghue57050202016-05-12 12:43:50 +010098int gb_svc_timesync_enable(struct gb_svc *svc, u8 count, u64 frame_time,
99 u32 strobe_delay, u32 refclk);
100int gb_svc_timesync_disable(struct gb_svc *svc);
101int gb_svc_timesync_authoritative(struct gb_svc *svc, u64 *frame_time);
102int gb_svc_timesync_ping(struct gb_svc *svc, u64 *frame_time);
103int gb_svc_timesync_wake_pins_acquire(struct gb_svc *svc, u32 strobe_mask);
104int gb_svc_timesync_wake_pins_release(struct gb_svc *svc);
Alex Elder30c6d9d2015-05-22 13:02:08 -0500105
Viresh Kumarab69c4c2015-07-03 17:00:29 +0530106int gb_svc_protocol_init(void);
107void gb_svc_protocol_exit(void);
Viresh Kumard3d44842015-07-21 17:44:18 +0530108
Alex Elder30c6d9d2015-05-22 13:02:08 -0500109#endif /* __SVC_H */