platform/chrome: cros-ec: Record event timestamp in the hard irq
To improve sensor timestamp precision, given EC and AP are in different time domains, the AP needs to try to record the exact moment an event was signalled to the AP by the EC as soon as possible after it happens. First thing in the hard irq is the best place for this. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Acked-by: Jonathan Cameron <Jonathan.Cameron@kernel.org> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
This commit is contained in:

committed by
Enric Balletbo i Serra

parent
d60ac88a62
commit
05a3c420ea
@@ -122,6 +122,8 @@ struct cros_ec_command {
|
||||
* @event_data: Raw payload transferred with the MKBP event.
|
||||
* @event_size: Size in bytes of the event data.
|
||||
* @host_event_wake_mask: Mask of host events that cause wake from suspend.
|
||||
* @last_event_time: exact time from the hard irq when we got notified of
|
||||
* a new event.
|
||||
* @ec: The platform_device used by the mfd driver to interface with the
|
||||
* main EC.
|
||||
* @pd: The platform_device used by the mfd driver to interface with the
|
||||
@@ -162,6 +164,7 @@ struct cros_ec_device {
|
||||
int event_size;
|
||||
u32 host_event_wake_mask;
|
||||
u32 last_resume_result;
|
||||
ktime_t last_event_time;
|
||||
|
||||
/* The platform devices used by the mfd driver */
|
||||
struct platform_device *ec;
|
||||
@@ -210,4 +213,17 @@ int cros_ec_check_features(struct cros_ec_dev *ec, int feature);
|
||||
|
||||
int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
|
||||
|
||||
/**
|
||||
* cros_ec_get_time_ns() - Return time in ns.
|
||||
*
|
||||
* This is the function used to record the time for last_event_time in struct
|
||||
* cros_ec_device during the hard irq.
|
||||
*
|
||||
* Return: ktime_t format since boot.
|
||||
*/
|
||||
static inline ktime_t cros_ec_get_time_ns(void)
|
||||
{
|
||||
return ktime_get_boottime_ns();
|
||||
}
|
||||
|
||||
#endif /* __LINUX_CROS_EC_PROTO_H */
|
||||
|
Reference in New Issue
Block a user