History

Merge tag 'tag-ib-chrome-mfd-iio-input-5.5' into chrome-platform-5.5

IB between mfd, iio, input and chrome platform for cros-ec-sensorhub

Enric Balletbo i Serra committed 6 years ago

Commit 5ec966d2 parents c2ce4d2 99cdb2417 files · +636 −421Browse files

Showing the changes to include/linux (2 of 17 files). Show all

Unified · Split

2 files
  1. include/linux/platform_data/cros_ec_proto.h +27 −111
  2. include/linux/platform_data/cros_ec_sensorhub.h +30 −0
include/linux/platform_data/cros_ec_proto.h+27−111
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/mutex.h>
1313 #include <linux/notifier.h>
1414
15+#include <linux/mfd/cros_ec.h>
1516 #include <linux/platform_data/cros_ec_commands.h>
1617
1718 #define CROS_EC_DEV_NAME "cros_ec"
@@ -115,12 +116,16 @@ struct cros_ec_command { · 97 unmodified lines
115116 * code.
116117 * @pkt_xfer: Send packet to EC and get response.
117118 * @lock: One transaction at a time.
118− * @mkbp_event_supported: True if this EC supports the MKBP event protocol.
119+ * @mkbp_event_supported: 0 if MKBP not supported. Otherwise its value is
120+ * the maximum supported version of the MKBP host event
121+ * command + 1.
119122 * @host_sleep_v1: True if this EC supports the sleep v1 command.
120123 * @event_notifier: Interrupt event notifier for transport devices.
121124 * @event_data: Raw payload transferred with the MKBP event.
122125 * @event_size: Size in bytes of the event data.
123126 * @host_event_wake_mask: Mask of host events that cause wake from suspend.
127+ * @last_event_time: exact time from the hard irq when we got notified of
128+ * a new event.
124129 * @ec: The platform_device used by the mfd driver to interface with the
125130 * main EC.
126131 * @pd: The platform_device used by the mfd driver to interface with the
@@ -153,7 +158,7 @@ struct cros_ec_device { · 26 unmodified lines
153158 int (*pkt_xfer)(struct cros_ec_device *ec,
154159 struct cros_ec_command *msg);
155160 struct mutex lock;
156− bool mkbp_event_supported;
161+ u8 mkbp_event_supported;
157162 bool host_sleep_v1;
158163 struct blocking_notifier_head event_notifier;
159164
@@ -161,20 +166,13 @@ struct cros_ec_device { · 1 unmodified line
161166 int event_size;
162167 u32 host_event_wake_mask;
163168 u32 last_resume_result;
169+ ktime_t last_event_time;
164170
165171 /* The platform devices used by the mfd driver */
166172 struct platform_device *ec;
167173 struct platform_device *pd;
168174 };
169175
170−/**
171− * struct cros_ec_sensor_platform - ChromeOS EC sensor platform information.
172− * @sensor_num: Id of the sensor, as reported by the EC.
173− */
174−struct cros_ec_sensor_platform {
175− u8 sensor_num;
176−};
177−
178176 /**
179177 * struct cros_ec_platform - ChromeOS EC platform information.
180178 * @ec_name: Name of EC device (e.g. 'cros-ec', 'cros-pd', ...)
@@ -187,133 +185,51 @@ struct cros_ec_platform { · 6 unmodified lines
187185 u16 cmd_offset;
188186 };
189187
190−/**
191− * cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device.
192− * @ec_dev: Device to suspend.
193− *
194− * This can be called by drivers to handle a suspend event.
195− *
196− * Return: 0 on success or negative error code.
197− */
198188 int cros_ec_suspend(struct cros_ec_device *ec_dev);
199189
200−/**
201− * cros_ec_resume() - Handle a resume operation for the ChromeOS EC device.
202− * @ec_dev: Device to resume.
203− *
204− * This can be called by drivers to handle a resume event.
205− *
206− * Return: 0 on success or negative error code.
207− */
208190 int cros_ec_resume(struct cros_ec_device *ec_dev);
209191
210−/**
211− * cros_ec_prepare_tx() - Prepare an outgoing message in the output buffer.
212− * @ec_dev: Device to register.
213− * @msg: Message to write.
214− *
215− * This is intended to be used by all ChromeOS EC drivers, but at present
216− * only SPI uses it. Once LPC uses the same protocol it can start using it.
217− * I2C could use it now, with a refactor of the existing code.
218− *
219− * Return: 0 on success or negative error code.
220− */
221192 int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
222193 struct cros_ec_command *msg);
223194
224−/**
225− * cros_ec_check_result() - Check ec_msg->result.
226− * @ec_dev: EC device.
227− * @msg: Message to check.
228− *
229− * This is used by ChromeOS EC drivers to check the ec_msg->result for
230− * errors and to warn about them.
231− *
232− * Return: 0 on success or negative error code.
233− */
234195 int cros_ec_check_result(struct cros_ec_device *ec_dev,
235196 struct cros_ec_command *msg);
236197
237−/**
238− * cros_ec_cmd_xfer() - Send a command to the ChromeOS EC.
239− * @ec_dev: EC device.
240− * @msg: Message to write.
241− *
242− * Call this to send a command to the ChromeOS EC. This should be used
243− * instead of calling the EC's cmd_xfer() callback directly.
244− *
245− * Return: 0 on success or negative error code.
246− */
247198 int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
248199 struct cros_ec_command *msg);
249200
250−/**
251− * cros_ec_cmd_xfer_status() - Send a command to the ChromeOS EC.
252− * @ec_dev: EC device.
253− * @msg: Message to write.
254− *
255− * This function is identical to cros_ec_cmd_xfer, except it returns success
256− * status only if both the command was transmitted successfully and the EC
257− * replied with success status. It's not necessary to check msg->result when
258− * using this function.
259− *
260− * Return: The number of bytes transferred on success or negative error code.
261− */
262201 int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
263202 struct cros_ec_command *msg);
264203
265−/**
266− * cros_ec_register() - Register a new ChromeOS EC, using the provided info.
267− * @ec_dev: Device to register.
268− *
269− * Before calling this, allocate a pointer to a new device and then fill
270− * in all the fields up to the --private-- marker.
271− *
272− * Return: 0 on success or negative error code.
273− */
274204 int cros_ec_register(struct cros_ec_device *ec_dev);
275205
276−/**
277− * cros_ec_unregister() - Remove a ChromeOS EC.
278− * @ec_dev: Device to unregister.
279− *
280− * Call this to deregister a ChromeOS EC, then clean up any private data.
281− *
282− * Return: 0 on success or negative error code.
283− */
284206 int cros_ec_unregister(struct cros_ec_device *ec_dev);
285207
286−/**
287− * cros_ec_query_all() - Query the protocol version supported by the
288− * ChromeOS EC.
289− * @ec_dev: Device to register.
290− *
291− * Return: 0 on success or negative error code.
292− */
293208 int cros_ec_query_all(struct cros_ec_device *ec_dev);
294209
295−/**
296− * cros_ec_get_next_event() - Fetch next event from the ChromeOS EC.
297− * @ec_dev: Device to fetch event from.
298− * @wake_event: Pointer to a bool set to true upon return if the event might be
299− * treated as a wake event. Ignored if null.
300− *
301− * Return: negative error code on errors; 0 for no data; or else number of
302− * bytes received (i.e., an event was retrieved successfully). Event types are
303− * written out to @ec_dev->event_data.event_type on success.
304− */
305−int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event);
210+int cros_ec_get_next_event(struct cros_ec_device *ec_dev,
211+ bool *wake_event,
212+ bool *has_more_events);
213+
214+u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);
215+
216+int cros_ec_check_features(struct cros_ec_dev *ec, int feature);
217+
218+int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
219+
220+bool cros_ec_handle_event(struct cros_ec_device *ec_dev);
306221
307222 /**
308− * cros_ec_get_host_event() - Return a mask of event set by the ChromeOS EC.
309− * @ec_dev: Device to fetch event from.
223+ * cros_ec_get_time_ns() - Return time in ns.
310224 *
311− * When MKBP is supported, when the EC raises an interrupt, we collect the
312− * events raised and call the functions in the ec notifier. This function
313− * is a helper to know which events are raised.
225+ * This is the function used to record the time for last_event_time in struct
226+ * cros_ec_device during the hard irq.
314227 *
315− * Return: 0 on error or non-zero bitmask of one or more EC_HOST_EVENT_*.
228+ * Return: ktime_t format since boot.
316229 */
317−u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev);
230+static inline ktime_t cros_ec_get_time_ns(void)
231+{
232+ return ktime_get_boottime_ns();
233+}
318234
319235 #endif /* __LINUX_CROS_EC_PROTO_H */
include/linux/platform_data/cros_ec_sensorhub.h+30−0
@@ -0,0 +1,30 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * Chrome OS EC MEMS Sensor Hub driver.
4+ *
5+ * Copyright 2019 Google LLC
6+ */
7+
8+#ifndef __LINUX_PLATFORM_DATA_CROS_EC_SENSORHUB_H
9+#define __LINUX_PLATFORM_DATA_CROS_EC_SENSORHUB_H
10+
11+#include <linux/platform_data/cros_ec_commands.h>
12+
13+/**
14+ * struct cros_ec_sensor_platform - ChromeOS EC sensor platform information.
15+ * @sensor_num: Id of the sensor, as reported by the EC.
16+ */
17+struct cros_ec_sensor_platform {
18+ u8 sensor_num;
19+};
20+
21+/**
22+ * struct cros_ec_sensorhub - Sensor Hub device data.
23+ *
24+ * @ec: Embedded Controller where the hub is located.
25+ */
26+struct cros_ec_sensorhub {
27+ struct cros_ec_dev *ec;
28+};
29+
30+#endif /* __LINUX_PLATFORM_DATA_CROS_EC_SENSORHUB_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t