Skip to content

Commit 730bf31

Browse files
committed
Merge tag 'tag-chrome-platform-for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Benson Leung: "cros_ec_typec: - make the cros_ec_typec driver to use the pre-existing cros_ec_check_features() function sensorhub: - add trace events for sample misc: - cros_ec_proto - re-send commands in the event of a timeout (for the FPMCU) - fix warnings in cros_ec_trace related to format output" * tag 'tag-chrome-platform-for-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: platform/chrome: cros_ec_trace: Fix format warnings platform/chrome: cros_ec_typec: Use existing feature check platform/chrome: cros_ec_proto: Send command again when timeout occurs platform/chrome: sensorhub: Add trace events for sample
2 parents 30f3490 + 4665584 commit 730bf31

File tree

5 files changed

+123
-23
lines changed

5 files changed

+123
-23
lines changed

drivers/platform/chrome/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ obj-$(CONFIG_CROS_EC_CHARDEV) += cros_ec_chardev.o
2020
obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o
2121
obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
2222
obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o
23-
cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o
23+
cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o cros_ec_trace.o
2424
obj-$(CONFIG_CROS_EC_SENSORHUB) += cros-ec-sensorhub.o
2525
obj-$(CONFIG_CROS_EC_SYSFS) += cros_ec_sysfs.o
2626
obj-$(CONFIG_CROS_USBPD_LOGGER) += cros_usbpd_logger.o

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ static int cros_ec_host_command_proto_query(struct cros_ec_device *ec_dev,
279279
msg->insize = sizeof(struct ec_response_get_protocol_info);
280280

281281
ret = send_command(ec_dev, msg);
282+
/*
283+
* Send command once again when timeout occurred.
284+
* Fingerprint MCU (FPMCU) is restarted during system boot which
285+
* introduces small window in which FPMCU won't respond for any
286+
* messages sent by kernel. There is no need to wait before next
287+
* attempt because we waited at least EC_MSG_DEADLINE_MS.
288+
*/
289+
if (ret == -ETIMEDOUT)
290+
ret = send_command(ec_dev, msg);
282291

283292
if (ret < 0) {
284293
dev_dbg(ec_dev->dev,

drivers/platform/chrome/cros_ec_sensorhub_ring.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/sort.h>
1818
#include <linux/slab.h>
1919

20+
#include "cros_ec_trace.h"
21+
2022
/* Precision of fixed point for the m values from the filter */
2123
#define M_PRECISION BIT(23)
2224

@@ -291,6 +293,7 @@ cros_ec_sensor_ring_ts_filter_update(struct cros_ec_sensors_ts_filter_state
291293
state->median_m = 0;
292294
state->median_error = 0;
293295
}
296+
trace_cros_ec_sensorhub_filter(state, dx, dy);
294297
}
295298

296299
/**
@@ -427,6 +430,11 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
427430
if (new_timestamp - *current_timestamp > 0)
428431
*current_timestamp = new_timestamp;
429432
}
433+
trace_cros_ec_sensorhub_timestamp(in->timestamp,
434+
fifo_info->timestamp,
435+
fifo_timestamp,
436+
*current_timestamp,
437+
now);
430438
}
431439

432440
if (in->flags & MOTIONSENSE_SENSOR_FLAG_ODR) {
@@ -460,6 +468,12 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
460468

461469
/* Regular sample */
462470
out->sensor_id = in->sensor_num;
471+
trace_cros_ec_sensorhub_data(in->sensor_num,
472+
fifo_info->timestamp,
473+
fifo_timestamp,
474+
*current_timestamp,
475+
now);
476+
463477
if (*current_timestamp - now > 0) {
464478
/*
465479
* This fix is needed to overcome the timestamp filter putting

drivers/platform/chrome/cros_ec_trace.h

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/types.h>
1616
#include <linux/platform_data/cros_ec_commands.h>
1717
#include <linux/platform_data/cros_ec_proto.h>
18+
#include <linux/platform_data/cros_ec_sensorhub.h>
1819

1920
#include <linux/tracepoint.h>
2021

@@ -70,6 +71,99 @@ TRACE_EVENT(cros_ec_request_done,
7071
__entry->retval)
7172
);
7273

74+
TRACE_EVENT(cros_ec_sensorhub_timestamp,
75+
TP_PROTO(u32 ec_sample_timestamp, u32 ec_fifo_timestamp, s64 fifo_timestamp,
76+
s64 current_timestamp, s64 current_time),
77+
TP_ARGS(ec_sample_timestamp, ec_fifo_timestamp, fifo_timestamp, current_timestamp,
78+
current_time),
79+
TP_STRUCT__entry(
80+
__field(u32, ec_sample_timestamp)
81+
__field(u32, ec_fifo_timestamp)
82+
__field(s64, fifo_timestamp)
83+
__field(s64, current_timestamp)
84+
__field(s64, current_time)
85+
__field(s64, delta)
86+
),
87+
TP_fast_assign(
88+
__entry->ec_sample_timestamp = ec_sample_timestamp;
89+
__entry->ec_fifo_timestamp = ec_fifo_timestamp;
90+
__entry->fifo_timestamp = fifo_timestamp;
91+
__entry->current_timestamp = current_timestamp;
92+
__entry->current_time = current_time;
93+
__entry->delta = current_timestamp - current_time;
94+
),
95+
TP_printk("ec_ts: %9u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
96+
__entry->ec_sample_timestamp,
97+
__entry->ec_fifo_timestamp,
98+
__entry->fifo_timestamp,
99+
__entry->current_timestamp,
100+
__entry->current_time,
101+
__entry->delta
102+
)
103+
);
104+
105+
TRACE_EVENT(cros_ec_sensorhub_data,
106+
TP_PROTO(u32 ec_sensor_num, u32 ec_fifo_timestamp, s64 fifo_timestamp,
107+
s64 current_timestamp, s64 current_time),
108+
TP_ARGS(ec_sensor_num, ec_fifo_timestamp, fifo_timestamp, current_timestamp, current_time),
109+
TP_STRUCT__entry(
110+
__field(u32, ec_sensor_num)
111+
__field(u32, ec_fifo_timestamp)
112+
__field(s64, fifo_timestamp)
113+
__field(s64, current_timestamp)
114+
__field(s64, current_time)
115+
__field(s64, delta)
116+
),
117+
TP_fast_assign(
118+
__entry->ec_sensor_num = ec_sensor_num;
119+
__entry->ec_fifo_timestamp = ec_fifo_timestamp;
120+
__entry->fifo_timestamp = fifo_timestamp;
121+
__entry->current_timestamp = current_timestamp;
122+
__entry->current_time = current_time;
123+
__entry->delta = current_timestamp - current_time;
124+
),
125+
TP_printk("ec_num: %4u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
126+
__entry->ec_sensor_num,
127+
__entry->ec_fifo_timestamp,
128+
__entry->fifo_timestamp,
129+
__entry->current_timestamp,
130+
__entry->current_time,
131+
__entry->delta
132+
)
133+
);
134+
135+
TRACE_EVENT(cros_ec_sensorhub_filter,
136+
TP_PROTO(struct cros_ec_sensors_ts_filter_state *state, s64 dx, s64 dy),
137+
TP_ARGS(state, dx, dy),
138+
TP_STRUCT__entry(
139+
__field(s64, dx)
140+
__field(s64, dy)
141+
__field(s64, median_m)
142+
__field(s64, median_error)
143+
__field(s64, history_len)
144+
__field(s64, x)
145+
__field(s64, y)
146+
),
147+
TP_fast_assign(
148+
__entry->dx = dx;
149+
__entry->dy = dy;
150+
__entry->median_m = state->median_m;
151+
__entry->median_error = state->median_error;
152+
__entry->history_len = state->history_len;
153+
__entry->x = state->x_offset;
154+
__entry->y = state->y_offset;
155+
),
156+
TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %lld x: %12lld y: %12lld",
157+
__entry->dx,
158+
__entry->dy,
159+
__entry->median_m,
160+
__entry->median_error,
161+
__entry->history_len,
162+
__entry->x,
163+
__entry->y
164+
)
165+
);
166+
73167

74168
#endif /* _CROS_EC_TRACE_H_ */
75169

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,24 +1054,6 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
10541054
return 0;
10551055
}
10561056

1057-
/* Check the EC feature flags to see if TYPEC_* features are supported. */
1058-
static int cros_typec_feature_supported(struct cros_typec_data *typec, enum ec_feature_code feature)
1059-
{
1060-
struct ec_response_get_features resp = {};
1061-
int ret;
1062-
1063-
ret = cros_typec_ec_command(typec, 0, EC_CMD_GET_FEATURES, NULL, 0,
1064-
&resp, sizeof(resp));
1065-
if (ret < 0) {
1066-
dev_warn(typec->dev,
1067-
"Failed to get features, assuming typec feature=%d unsupported.\n",
1068-
feature);
1069-
return 0;
1070-
}
1071-
1072-
return resp.flags[feature / 32] & EC_FEATURE_MASK_1(feature);
1073-
}
1074-
10751057
static void cros_typec_port_work(struct work_struct *work)
10761058
{
10771059
struct cros_typec_data *typec = container_of(work, struct cros_typec_data, port_work);
@@ -1113,6 +1095,7 @@ MODULE_DEVICE_TABLE(of, cros_typec_of_match);
11131095

11141096
static int cros_typec_probe(struct platform_device *pdev)
11151097
{
1098+
struct cros_ec_dev *ec_dev = NULL;
11161099
struct device *dev = &pdev->dev;
11171100
struct cros_typec_data *typec;
11181101
struct ec_response_usb_pd_ports resp;
@@ -1132,10 +1115,10 @@ static int cros_typec_probe(struct platform_device *pdev)
11321115
return ret;
11331116
}
11341117

1135-
typec->typec_cmd_supported = !!cros_typec_feature_supported(typec,
1136-
EC_FEATURE_TYPEC_CMD);
1137-
typec->needs_mux_ack = !!cros_typec_feature_supported(typec,
1138-
EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
1118+
ec_dev = dev_get_drvdata(&typec->ec->ec->dev);
1119+
typec->typec_cmd_supported = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD);
1120+
typec->needs_mux_ack = !!cros_ec_check_features(ec_dev,
1121+
EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
11391122

11401123
ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
11411124
&resp, sizeof(resp));

0 commit comments

Comments
 (0)