]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/staging/greybus/svc.h
staging: greybus: add SPDX identifiers to all greybus driver files
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / greybus / svc.h
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Greybus SVC code
4 *
5 * Copyright 2015 Google Inc.
6 * Copyright 2015 Linaro Ltd.
7 *
8 * Released under the GPLv2 only.
9 */
10
11 #ifndef __SVC_H
12 #define __SVC_H
13
14 #define GB_SVC_CPORT_FLAG_E2EFC BIT(0)
15 #define GB_SVC_CPORT_FLAG_CSD_N BIT(1)
16 #define GB_SVC_CPORT_FLAG_CSV_N BIT(2)
17
18 enum gb_svc_state {
19 GB_SVC_STATE_RESET,
20 GB_SVC_STATE_PROTOCOL_VERSION,
21 GB_SVC_STATE_SVC_HELLO,
22 };
23
24 enum gb_svc_watchdog_bite {
25 GB_SVC_WATCHDOG_BITE_RESET_UNIPRO = 0,
26 GB_SVC_WATCHDOG_BITE_PANIC_KERNEL,
27 };
28
29 struct gb_svc_watchdog;
30
31 struct svc_debugfs_pwrmon_rail {
32 u8 id;
33 struct gb_svc *svc;
34 };
35
36 struct gb_svc {
37 struct device dev;
38
39 struct gb_host_device *hd;
40 struct gb_connection *connection;
41 enum gb_svc_state state;
42 struct ida device_id_map;
43 struct workqueue_struct *wq;
44
45 u16 endo_id;
46 u8 ap_intf_id;
47
48 u8 protocol_major;
49 u8 protocol_minor;
50
51 struct gb_svc_watchdog *watchdog;
52 enum gb_svc_watchdog_bite action;
53
54 struct dentry *debugfs_dentry;
55 struct svc_debugfs_pwrmon_rail *pwrmon_rails;
56 };
57 #define to_gb_svc(d) container_of(d, struct gb_svc, dev)
58
59 struct gb_svc *gb_svc_create(struct gb_host_device *hd);
60 int gb_svc_add(struct gb_svc *svc);
61 void gb_svc_del(struct gb_svc *svc);
62 void gb_svc_put(struct gb_svc *svc);
63
64 int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id,
65 u8 measurement_type, u32 *value);
66 int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id);
67 int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id,
68 u8 intf2_id, u8 dev2_id);
69 void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id);
70 int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
71 u8 intf2_id, u16 cport2_id, u8 cport_flags);
72 void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
73 u8 intf2_id, u16 cport2_id);
74 int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id);
75 int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable);
76 int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable);
77 int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable);
78 int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type);
79 int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id);
80
81 int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
82 u32 *value);
83 int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
84 u32 value);
85 int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series,
86 u8 tx_mode, u8 tx_gear, u8 tx_nlanes,
87 u8 tx_amplitude, u8 tx_hs_equalizer,
88 u8 rx_mode, u8 rx_gear, u8 rx_nlanes,
89 u8 flags, u32 quirks,
90 struct gb_svc_l2_timer_cfg *local,
91 struct gb_svc_l2_timer_cfg *remote);
92 int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id);
93 int gb_svc_ping(struct gb_svc *svc);
94 int gb_svc_watchdog_create(struct gb_svc *svc);
95 void gb_svc_watchdog_destroy(struct gb_svc *svc);
96 bool gb_svc_watchdog_enabled(struct gb_svc *svc);
97 int gb_svc_watchdog_enable(struct gb_svc *svc);
98 int gb_svc_watchdog_disable(struct gb_svc *svc);
99
100 int gb_svc_protocol_init(void);
101 void gb_svc_protocol_exit(void);
102
103 #endif /* __SVC_H */