linux/drivers/staging/greybus/svc.h

103 lines
3.4 KiB
C
Raw Normal View History

/*
* Greybus SVC code
*
* Copyright 2015 Google Inc.
* Copyright 2015 Linaro Ltd.
*
* Released under the GPLv2 only.
*/
#ifndef __SVC_H
#define __SVC_H
#define GB_SVC_CPORT_FLAG_E2EFC BIT(0)
#define GB_SVC_CPORT_FLAG_CSD_N BIT(1)
#define GB_SVC_CPORT_FLAG_CSV_N BIT(2)
enum gb_svc_state {
GB_SVC_STATE_RESET,
GB_SVC_STATE_PROTOCOL_VERSION,
GB_SVC_STATE_SVC_HELLO,
};
struct gb_svc_watchdog;
struct svc_debugfs_pwrmon_rail {
u8 id;
struct gb_svc *svc;
};
struct gb_svc {
struct device dev;
struct gb_host_device *hd;
struct gb_connection *connection;
enum gb_svc_state state;
struct ida device_id_map;
struct workqueue_struct *wq;
u16 endo_id;
u8 ap_intf_id;
u8 protocol_major;
u8 protocol_minor;
struct gb_svc_watchdog *watchdog;
struct dentry *debugfs_dentry;
struct svc_debugfs_pwrmon_rail *pwrmon_rails;
};
#define to_gb_svc(d) container_of(d, struct gb_svc, dev)
struct gb_svc *gb_svc_create(struct gb_host_device *hd);
int gb_svc_add(struct gb_svc *svc);
void gb_svc_del(struct gb_svc *svc);
void gb_svc_put(struct gb_svc *svc);
int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id,
u8 measurement_type, u32 *value);
int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id);
int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id,
u8 intf2_id, u8 dev2_id);
void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id);
int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
u8 intf2_id, u16 cport2_id, u8 cport_flags);
void gb_svc_connection_quiescing(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
u8 intf2_id, u16 cport2_id);
void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
u8 intf2_id, u16 cport2_id);
int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id);
int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable);
int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable);
int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable);
int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type);
int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
u32 *value);
int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
u32 value);
int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series,
u8 tx_mode, u8 tx_gear, u8 tx_nlanes,
u8 tx_amplitude, u8 tx_hs_equalizer,
u8 rx_mode, u8 rx_gear, u8 rx_nlanes,
u8 flags, u32 quirks,
struct gb_svc_l2_timer_cfg *local,
struct gb_svc_l2_timer_cfg *remote);
int gb_svc_ping(struct gb_svc *svc);
int gb_svc_watchdog_create(struct gb_svc *svc);
void gb_svc_watchdog_destroy(struct gb_svc *svc);
bool gb_svc_watchdog_enabled(struct gb_svc *svc);
int gb_svc_watchdog_enable(struct gb_svc *svc);
int gb_svc_watchdog_disable(struct gb_svc *svc);
greybus: svc: Add TimeSync SVC commands Simple addition of the TimeSync commands defined in the specification. Adds: - svc.c::timesync_enable(u8 count, u64 frame_time, u32 strobe_delay, u32 refclk) Commands the SVC to initiate count TimeSync strobe pulses with strobe_delay microseconds delay between each strobe to the specified bit-mask of Interface IDs indicated in a previous timesync_wake_pins_acquire command. The frame_time parameter indicates the initial time the SVC should base the first strobe from. The refclk parameter indicates the APs clock rate, the SVC should ensure its own clock ticks at this rate. Once enabled the SVC may not enter a low-power mode which will result in the reference timer used to track time switching off. The SVC will capture the authoritative FrameTime at each strobe and store these values for later propagation to the AP with the timesync_authoritative request. - svc.c::timesync_disable(void) Commands the SVC to immediately halt TimeSync logic. This will allow the SVC to transition into low-power modes where the reference timer being used for TimeSync may switch off. - svc.c::timesync_authoritative(u64 *frame_time) Used by the AP Module to ask the SVC for the authoritative FrameTime as captured at each TimeSync strobe. - svc.c::timesync_ping(u64 *frame_time) Used by the AP Module to command the SVC to initiate a single strobe on a specified bit-mask of Interface IDs communicated in a previous timesync_wake_pins_acquire command. SVC will latch the FrameTime on the rising edge of the outbound pulse and will return the FrameTime to the AP Module in the response phase of the greybus transaction. - svc::timesync_wake_pins_acquire(u32 strobe_mask) Used by the AP to tell the SVC to set a bit-mask of wake lines associated with a bit-mask of Interface IDs to a known initial state prior to the SVC generating a TimeSync related pulse such as timesync-enable or timesync-ping. - svc::timesync_wake_pins_release(void) Used by the AP to tell the SVC to release all wake-detect lines in the timesync active state as previously specified in the timesync_wake_pins_acquire operation. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-12 13:43:50 +02:00
int gb_svc_timesync_enable(struct gb_svc *svc, u8 count, u64 frame_time,
u32 strobe_delay, u32 refclk);
int gb_svc_timesync_disable(struct gb_svc *svc);
int gb_svc_timesync_authoritative(struct gb_svc *svc, u64 *frame_time);
int gb_svc_timesync_ping(struct gb_svc *svc, u64 *frame_time);
int gb_svc_timesync_wake_pins_acquire(struct gb_svc *svc, u32 strobe_mask);
int gb_svc_timesync_wake_pins_release(struct gb_svc *svc);
int gb_svc_protocol_init(void);
void gb_svc_protocol_exit(void);
#endif /* __SVC_H */