Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Greybus SVC code
0004  *
0005  * Copyright 2015 Google Inc.
0006  * Copyright 2015 Linaro Ltd.
0007  */
0008 
0009 #ifndef __SVC_H
0010 #define __SVC_H
0011 
0012 #include <linux/types.h>
0013 #include <linux/device.h>
0014 
0015 struct gb_svc_l2_timer_cfg;
0016 
0017 #define GB_SVC_CPORT_FLAG_E2EFC     BIT(0)
0018 #define GB_SVC_CPORT_FLAG_CSD_N     BIT(1)
0019 #define GB_SVC_CPORT_FLAG_CSV_N     BIT(2)
0020 
0021 enum gb_svc_state {
0022     GB_SVC_STATE_RESET,
0023     GB_SVC_STATE_PROTOCOL_VERSION,
0024     GB_SVC_STATE_SVC_HELLO,
0025 };
0026 
0027 enum gb_svc_watchdog_bite {
0028     GB_SVC_WATCHDOG_BITE_RESET_UNIPRO = 0,
0029     GB_SVC_WATCHDOG_BITE_PANIC_KERNEL,
0030 };
0031 
0032 struct gb_svc_watchdog;
0033 
0034 struct svc_debugfs_pwrmon_rail {
0035     u8 id;
0036     struct gb_svc *svc;
0037 };
0038 
0039 struct gb_svc {
0040     struct device       dev;
0041 
0042     struct gb_host_device   *hd;
0043     struct gb_connection    *connection;
0044     enum gb_svc_state   state;
0045     struct ida      device_id_map;
0046     struct workqueue_struct *wq;
0047 
0048     u16 endo_id;
0049     u8 ap_intf_id;
0050 
0051     u8 protocol_major;
0052     u8 protocol_minor;
0053 
0054     struct gb_svc_watchdog  *watchdog;
0055     enum gb_svc_watchdog_bite action;
0056 
0057     struct dentry *debugfs_dentry;
0058     struct svc_debugfs_pwrmon_rail *pwrmon_rails;
0059 };
0060 #define to_gb_svc(d) container_of(d, struct gb_svc, dev)
0061 
0062 struct gb_svc *gb_svc_create(struct gb_host_device *hd);
0063 int gb_svc_add(struct gb_svc *svc);
0064 void gb_svc_del(struct gb_svc *svc);
0065 void gb_svc_put(struct gb_svc *svc);
0066 
0067 int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id,
0068                   u8 measurement_type, u32 *value);
0069 int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id);
0070 int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id,
0071                    u8 intf2_id, u8 dev2_id);
0072 void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id);
0073 int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
0074                  u8 intf2_id, u16 cport2_id, u8 cport_flags);
0075 void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
0076                    u8 intf2_id, u16 cport2_id);
0077 int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id);
0078 int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable);
0079 int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable);
0080 int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable);
0081 int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type);
0082 int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id);
0083 
0084 int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
0085             u32 *value);
0086 int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
0087             u32 value);
0088 int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series,
0089                    u8 tx_mode, u8 tx_gear, u8 tx_nlanes,
0090                    u8 tx_amplitude, u8 tx_hs_equalizer,
0091                    u8 rx_mode, u8 rx_gear, u8 rx_nlanes,
0092                    u8 flags, u32 quirks,
0093                    struct gb_svc_l2_timer_cfg *local,
0094                    struct gb_svc_l2_timer_cfg *remote);
0095 int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id);
0096 int gb_svc_ping(struct gb_svc *svc);
0097 int gb_svc_watchdog_create(struct gb_svc *svc);
0098 void gb_svc_watchdog_destroy(struct gb_svc *svc);
0099 bool gb_svc_watchdog_enabled(struct gb_svc *svc);
0100 int gb_svc_watchdog_enable(struct gb_svc *svc);
0101 int gb_svc_watchdog_disable(struct gb_svc *svc);
0102 
0103 int gb_svc_protocol_init(void);
0104 void gb_svc_protocol_exit(void);
0105 
0106 #endif /* __SVC_H */