aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/platform_data
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-11 21:45:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-11 21:45:29 -0400
commitd7d170a8e357bd9926cc6bfea5c2385c2eac65b2 (patch)
treecb66ba886b0c0b92d3e41ae551b4bc90e219a913 /include/linux/platform_data
parentd06e4156430e7c5eb4f04dabcaa0d9e2fba335e3 (diff)
parent8c3166e17cf10161d2871dfb1d017287c7b79ff1 (diff)
Merge tag 'tag-chrome-platform-for-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Benson Leung "CrOS EC: - Add new CrOS ISHTP transport protocol - Add proper documentation for debugfs entries and expose resume and uptime files - Select LPC transport protocol variant at runtime. - Add lid angle sensor driver - Fix oops on suspend/resume for lightbar driver - Set CrOS SPI transport protol in realtime Wilco EC: - Add telemetry char device interface - Add support for event handling - Add new sysfs attributes Misc: - Contains ib-mfd-cros-v5.3 immutable branch from mfd, with cros_ec_commands.h header freshly synced with Chrome OS's EC project" * tag 'tag-chrome-platform-for-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: (54 commits) mfd / platform: cros_ec_debugfs: Expose resume result via debugfs platform/chrome: lightbar: Get drvdata from parent in suspend/resume iio: cros_ec: Add lid angle driver platform/chrome: wilco_ec: Add circular buffer as event queue platform/chrome: cros_ec_lpc_mec: Fix kernel-doc comment first line platform/chrome: cros_ec_lpc: Choose Microchip EC at runtime platform/chrome: cros_ec_lpc: Merge cros_ec_lpc and cros_ec_lpc_reg Input: cros_ec_keyb: mask out extra flags in event_type platform/chrome: wilco_ec: Fix unreleased lock in event_read() platform/chrome: cros_ec_debugfs: cros_ec_uptime_fops can be static platform/chrome: cros_ec_debugfs: Add debugfs ABI documentation platform/chrome: cros_ec_debugfs: Fix kernel-doc comment first line platform/chrome: cros_ec_debugfs: Add debugfs entry to retrieve EC uptime mfd: cros_ec: Update I2S API mfd: cros_ec: Add Management API entry points mfd: cros_ec: Add SKU ID and Secure storage API mfd: cros_ec: Add API for rwsig mfd: cros_ec: Add API for Fingerprint support mfd: cros_ec: Add API for Touchpad support mfd: cros_ec: Add API for EC-EC communication ...
Diffstat (limited to 'include/linux/platform_data')
-rw-r--r--include/linux/platform_data/wilco-ec.h94
1 files changed, 87 insertions, 7 deletions
diff --git a/include/linux/platform_data/wilco-ec.h b/include/linux/platform_data/wilco-ec.h
index 1ff224793c99..ad03b586a095 100644
--- a/include/linux/platform_data/wilco-ec.h
+++ b/include/linux/platform_data/wilco-ec.h
@@ -13,12 +13,9 @@
13 13
14/* Message flags for using the mailbox() interface */ 14/* Message flags for using the mailbox() interface */
15#define WILCO_EC_FLAG_NO_RESPONSE BIT(0) /* EC does not respond */ 15#define WILCO_EC_FLAG_NO_RESPONSE BIT(0) /* EC does not respond */
16#define WILCO_EC_FLAG_EXTENDED_DATA BIT(1) /* EC returns 256 data bytes */
17 16
18/* Normal commands have a maximum 32 bytes of data */ 17/* Normal commands have a maximum 32 bytes of data */
19#define EC_MAILBOX_DATA_SIZE 32 18#define EC_MAILBOX_DATA_SIZE 32
20/* Extended commands have 256 bytes of response data */
21#define EC_MAILBOX_DATA_SIZE_EXTENDED 256
22 19
23/** 20/**
24 * struct wilco_ec_device - Wilco Embedded Controller handle. 21 * struct wilco_ec_device - Wilco Embedded Controller handle.
@@ -32,6 +29,7 @@
32 * @data_size: Size of the data buffer used for EC communication. 29 * @data_size: Size of the data buffer used for EC communication.
33 * @debugfs_pdev: The child platform_device used by the debugfs sub-driver. 30 * @debugfs_pdev: The child platform_device used by the debugfs sub-driver.
34 * @rtc_pdev: The child platform_device used by the RTC sub-driver. 31 * @rtc_pdev: The child platform_device used by the RTC sub-driver.
32 * @telem_pdev: The child platform_device used by the telemetry sub-driver.
35 */ 33 */
36struct wilco_ec_device { 34struct wilco_ec_device {
37 struct device *dev; 35 struct device *dev;
@@ -43,6 +41,7 @@ struct wilco_ec_device {
43 size_t data_size; 41 size_t data_size;
44 struct platform_device *debugfs_pdev; 42 struct platform_device *debugfs_pdev;
45 struct platform_device *rtc_pdev; 43 struct platform_device *rtc_pdev;
44 struct platform_device *telem_pdev;
46}; 45};
47 46
48/** 47/**
@@ -85,14 +84,12 @@ struct wilco_ec_response {
85 * enum wilco_ec_msg_type - Message type to select a set of command codes. 84 * enum wilco_ec_msg_type - Message type to select a set of command codes.
86 * @WILCO_EC_MSG_LEGACY: Legacy EC messages for standard EC behavior. 85 * @WILCO_EC_MSG_LEGACY: Legacy EC messages for standard EC behavior.
87 * @WILCO_EC_MSG_PROPERTY: Get/Set/Sync EC controlled NVRAM property. 86 * @WILCO_EC_MSG_PROPERTY: Get/Set/Sync EC controlled NVRAM property.
88 * @WILCO_EC_MSG_TELEMETRY_SHORT: 32 bytes of telemetry data provided by the EC. 87 * @WILCO_EC_MSG_TELEMETRY: Request telemetry data from the EC.
89 * @WILCO_EC_MSG_TELEMETRY_LONG: 256 bytes of telemetry data provided by the EC.
90 */ 88 */
91enum wilco_ec_msg_type { 89enum wilco_ec_msg_type {
92 WILCO_EC_MSG_LEGACY = 0x00f0, 90 WILCO_EC_MSG_LEGACY = 0x00f0,
93 WILCO_EC_MSG_PROPERTY = 0x00f2, 91 WILCO_EC_MSG_PROPERTY = 0x00f2,
94 WILCO_EC_MSG_TELEMETRY_SHORT = 0x00f5, 92 WILCO_EC_MSG_TELEMETRY = 0x00f5,
95 WILCO_EC_MSG_TELEMETRY_LONG = 0x00f6,
96}; 93};
97 94
98/** 95/**
@@ -123,4 +120,87 @@ struct wilco_ec_message {
123 */ 120 */
124int wilco_ec_mailbox(struct wilco_ec_device *ec, struct wilco_ec_message *msg); 121int wilco_ec_mailbox(struct wilco_ec_device *ec, struct wilco_ec_message *msg);
125 122
123/*
124 * A Property is typically a data item that is stored to NVRAM
125 * by the EC. Each of these data items has an index associated
126 * with it, known as the Property ID (PID). Properties may have
127 * variable lengths, up to a max of WILCO_EC_PROPERTY_MAX_SIZE
128 * bytes. Properties can be simple integers, or they may be more
129 * complex binary data.
130 */
131
132#define WILCO_EC_PROPERTY_MAX_SIZE 4
133
134/**
135 * struct ec_property_set_msg - Message to get or set a property.
136 * @property_id: Which property to get or set.
137 * @length: Number of bytes of |data| that are used.
138 * @data: Actual property data.
139 */
140struct wilco_ec_property_msg {
141 u32 property_id;
142 int length;
143 u8 data[WILCO_EC_PROPERTY_MAX_SIZE];
144};
145
146/**
147 * wilco_ec_get_property() - Retrieve a property from the EC.
148 * @ec: Embedded Controller device.
149 * @prop_msg: Message for request and response.
150 *
151 * The property_id field of |prop_msg| should be filled before calling this
152 * function. The result will be stored in the data and length fields.
153 *
154 * Return: 0 on success, negative error code on failure.
155 */
156int wilco_ec_get_property(struct wilco_ec_device *ec,
157 struct wilco_ec_property_msg *prop_msg);
158
159/**
160 * wilco_ec_set_property() - Store a property on the EC.
161 * @ec: Embedded Controller device.
162 * @prop_msg: Message for request and response.
163 *
164 * The property_id, length, and data fields of |prop_msg| should be
165 * filled before calling this function.
166 *
167 * Return: 0 on success, negative error code on failure.
168 */
169int wilco_ec_set_property(struct wilco_ec_device *ec,
170 struct wilco_ec_property_msg *prop_msg);
171
172/**
173 * wilco_ec_get_byte_property() - Retrieve a byte-size property from the EC.
174 * @ec: Embedded Controller device.
175 * @property_id: Which property to retrieve.
176 * @val: The result value, will be filled by this function.
177 *
178 * Return: 0 on success, negative error code on failure.
179 */
180int wilco_ec_get_byte_property(struct wilco_ec_device *ec, u32 property_id,
181 u8 *val);
182
183/**
184 * wilco_ec_get_byte_property() - Store a byte-size property on the EC.
185 * @ec: Embedded Controller device.
186 * @property_id: Which property to store.
187 * @val: Value to store.
188 *
189 * Return: 0 on success, negative error code on failure.
190 */
191int wilco_ec_set_byte_property(struct wilco_ec_device *ec, u32 property_id,
192 u8 val);
193
194/**
195 * wilco_ec_add_sysfs() - Create sysfs entries
196 * @ec: Wilco EC device
197 *
198 * wilco_ec_remove_sysfs() needs to be called afterwards
199 * to perform the necessary cleanup.
200 *
201 * Return: 0 on success or negative error code on failure.
202 */
203int wilco_ec_add_sysfs(struct wilco_ec_device *ec);
204void wilco_ec_remove_sysfs(struct wilco_ec_device *ec);
205
126#endif /* WILCO_EC_H */ 206#endif /* WILCO_EC_H */