xref: /OK3568_Linux_fs/u-boot/include/cros_ec.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Chromium OS cros_ec driver
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (c) 2012 The Chromium OS Authors.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #ifndef _CROS_EC_H
10*4882a593Smuzhiyun #define _CROS_EC_H
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <linux/compiler.h>
13*4882a593Smuzhiyun #include <ec_commands.h>
14*4882a593Smuzhiyun #include <cros_ec_message.h>
15*4882a593Smuzhiyun #include <asm/gpio.h>
16*4882a593Smuzhiyun #include <dm/of_extra.h>
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /* Our configuration information */
19*4882a593Smuzhiyun struct cros_ec_dev {
20*4882a593Smuzhiyun 	struct udevice *dev;		/* Transport device */
21*4882a593Smuzhiyun 	struct gpio_desc ec_int;	/* GPIO used as EC interrupt line */
22*4882a593Smuzhiyun 	int protocol_version;           /* Protocol version to use */
23*4882a593Smuzhiyun 	int optimise_flash_write;	/* Don't write erased flash blocks */
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun 	/*
26*4882a593Smuzhiyun 	 * These two buffers will always be dword-aligned and include enough
27*4882a593Smuzhiyun 	 * space for up to 7 word-alignment bytes also, so we can ensure that
28*4882a593Smuzhiyun 	 * the body of the message is always dword-aligned (64-bit).
29*4882a593Smuzhiyun 	 *
30*4882a593Smuzhiyun 	 * We use this alignment to keep ARM and x86 happy. Probably word
31*4882a593Smuzhiyun 	 * alignment would be OK, there might be a small performance advantage
32*4882a593Smuzhiyun 	 * to using dword.
33*4882a593Smuzhiyun 	 */
34*4882a593Smuzhiyun 	uint8_t din[ALIGN(MSG_BYTES + sizeof(int64_t), sizeof(int64_t))]
35*4882a593Smuzhiyun 		__aligned(sizeof(int64_t));
36*4882a593Smuzhiyun 	uint8_t dout[ALIGN(MSG_BYTES + sizeof(int64_t), sizeof(int64_t))]
37*4882a593Smuzhiyun 		__aligned(sizeof(int64_t));
38*4882a593Smuzhiyun };
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun /*
41*4882a593Smuzhiyun  * Hard-code the number of columns we happen to know we have right now.  It
42*4882a593Smuzhiyun  * would be more correct to call cros_ec_info() at startup and determine the
43*4882a593Smuzhiyun  * actual number of keyboard cols from there.
44*4882a593Smuzhiyun  */
45*4882a593Smuzhiyun #define CROS_EC_KEYSCAN_COLS 13
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun /* Information returned by a key scan */
48*4882a593Smuzhiyun struct mbkp_keyscan {
49*4882a593Smuzhiyun 	uint8_t data[CROS_EC_KEYSCAN_COLS];
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun /* Holds information about the Chrome EC */
53*4882a593Smuzhiyun struct fdt_cros_ec {
54*4882a593Smuzhiyun 	struct fmap_entry flash;	/* Address and size of EC flash */
55*4882a593Smuzhiyun 	/*
56*4882a593Smuzhiyun 	 * Byte value of erased flash, or -1 if not known. It is normally
57*4882a593Smuzhiyun 	 * 0xff but some flash devices use 0 (e.g. STM32Lxxx)
58*4882a593Smuzhiyun 	 */
59*4882a593Smuzhiyun 	int flash_erase_value;
60*4882a593Smuzhiyun 	struct fmap_entry region[EC_FLASH_REGION_COUNT];
61*4882a593Smuzhiyun };
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun /**
64*4882a593Smuzhiyun  * Read the ID of the CROS-EC device
65*4882a593Smuzhiyun  *
66*4882a593Smuzhiyun  * The ID is a string identifying the CROS-EC device.
67*4882a593Smuzhiyun  *
68*4882a593Smuzhiyun  * @param dev		CROS-EC device
69*4882a593Smuzhiyun  * @param id		Place to put the ID
70*4882a593Smuzhiyun  * @param maxlen	Maximum length of the ID field
71*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
72*4882a593Smuzhiyun  */
73*4882a593Smuzhiyun int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen);
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun /**
76*4882a593Smuzhiyun  * Read a keyboard scan from the CROS-EC device
77*4882a593Smuzhiyun  *
78*4882a593Smuzhiyun  * Send a message requesting a keyboard scan and return the result
79*4882a593Smuzhiyun  *
80*4882a593Smuzhiyun  * @param dev		CROS-EC device
81*4882a593Smuzhiyun  * @param scan		Place to put the scan results
82*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
83*4882a593Smuzhiyun  */
84*4882a593Smuzhiyun int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan);
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun /**
87*4882a593Smuzhiyun  * Read which image is currently running on the CROS-EC device.
88*4882a593Smuzhiyun  *
89*4882a593Smuzhiyun  * @param dev		CROS-EC device
90*4882a593Smuzhiyun  * @param image		Destination for image identifier
91*4882a593Smuzhiyun  * @return 0 if ok, <0 on error
92*4882a593Smuzhiyun  */
93*4882a593Smuzhiyun int cros_ec_read_current_image(struct cros_ec_dev *dev,
94*4882a593Smuzhiyun 		enum ec_current_image *image);
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun /**
97*4882a593Smuzhiyun  * Read the hash of the CROS-EC device firmware.
98*4882a593Smuzhiyun  *
99*4882a593Smuzhiyun  * @param dev		CROS-EC device
100*4882a593Smuzhiyun  * @param hash		Destination for hash information
101*4882a593Smuzhiyun  * @return 0 if ok, <0 on error
102*4882a593Smuzhiyun  */
103*4882a593Smuzhiyun int cros_ec_read_hash(struct cros_ec_dev *dev,
104*4882a593Smuzhiyun 		struct ec_response_vboot_hash *hash);
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun /**
107*4882a593Smuzhiyun  * Send a reboot command to the CROS-EC device.
108*4882a593Smuzhiyun  *
109*4882a593Smuzhiyun  * Note that some reboot commands (such as EC_REBOOT_COLD) also reboot the AP.
110*4882a593Smuzhiyun  *
111*4882a593Smuzhiyun  * @param dev		CROS-EC device
112*4882a593Smuzhiyun  * @param cmd		Reboot command
113*4882a593Smuzhiyun  * @param flags         Flags for reboot command (EC_REBOOT_FLAG_*)
114*4882a593Smuzhiyun  * @return 0 if ok, <0 on error
115*4882a593Smuzhiyun  */
116*4882a593Smuzhiyun int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
117*4882a593Smuzhiyun 		uint8_t flags);
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun /**
120*4882a593Smuzhiyun  * Check if the CROS-EC device has an interrupt pending.
121*4882a593Smuzhiyun  *
122*4882a593Smuzhiyun  * Read the status of the external interrupt connected to the CROS-EC device.
123*4882a593Smuzhiyun  * If no external interrupt is configured, this always returns 1.
124*4882a593Smuzhiyun  *
125*4882a593Smuzhiyun  * @param dev		CROS-EC device
126*4882a593Smuzhiyun  * @return 0 if no interrupt is pending
127*4882a593Smuzhiyun  */
128*4882a593Smuzhiyun int cros_ec_interrupt_pending(struct udevice *dev);
129*4882a593Smuzhiyun 
130*4882a593Smuzhiyun enum {
131*4882a593Smuzhiyun 	CROS_EC_OK,
132*4882a593Smuzhiyun 	CROS_EC_ERR = 1,
133*4882a593Smuzhiyun 	CROS_EC_ERR_FDT_DECODE,
134*4882a593Smuzhiyun 	CROS_EC_ERR_CHECK_VERSION,
135*4882a593Smuzhiyun 	CROS_EC_ERR_READ_ID,
136*4882a593Smuzhiyun 	CROS_EC_ERR_DEV_INIT,
137*4882a593Smuzhiyun };
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun /**
140*4882a593Smuzhiyun  * Initialise the Chromium OS EC driver
141*4882a593Smuzhiyun  *
142*4882a593Smuzhiyun  * @param blob		Device tree blob containing setup information
143*4882a593Smuzhiyun  * @param cros_ecp        Returns pointer to the cros_ec device, or NULL if none
144*4882a593Smuzhiyun  * @return 0 if we got an cros_ec device and all is well (or no cros_ec is
145*4882a593Smuzhiyun  *	expected), -ve if we should have an cros_ec device but failed to find
146*4882a593Smuzhiyun  *	one, or init failed (-CROS_EC_ERR_...).
147*4882a593Smuzhiyun  */
148*4882a593Smuzhiyun int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp);
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun /**
151*4882a593Smuzhiyun  * Read information about the keyboard matrix
152*4882a593Smuzhiyun  *
153*4882a593Smuzhiyun  * @param dev		CROS-EC device
154*4882a593Smuzhiyun  * @param info		Place to put the info structure
155*4882a593Smuzhiyun  */
156*4882a593Smuzhiyun int cros_ec_info(struct cros_ec_dev *dev,
157*4882a593Smuzhiyun 		struct ec_response_mkbp_info *info);
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun /**
160*4882a593Smuzhiyun  * Read the host event flags
161*4882a593Smuzhiyun  *
162*4882a593Smuzhiyun  * @param dev		CROS-EC device
163*4882a593Smuzhiyun  * @param events_ptr	Destination for event flags.  Not changed on error.
164*4882a593Smuzhiyun  * @return 0 if ok, <0 on error
165*4882a593Smuzhiyun  */
166*4882a593Smuzhiyun int cros_ec_get_host_events(struct cros_ec_dev *dev, uint32_t *events_ptr);
167*4882a593Smuzhiyun 
168*4882a593Smuzhiyun /**
169*4882a593Smuzhiyun  * Clear the specified host event flags
170*4882a593Smuzhiyun  *
171*4882a593Smuzhiyun  * @param dev		CROS-EC device
172*4882a593Smuzhiyun  * @param events	Event flags to clear
173*4882a593Smuzhiyun  * @return 0 if ok, <0 on error
174*4882a593Smuzhiyun  */
175*4882a593Smuzhiyun int cros_ec_clear_host_events(struct cros_ec_dev *dev, uint32_t events);
176*4882a593Smuzhiyun 
177*4882a593Smuzhiyun /**
178*4882a593Smuzhiyun  * Get/set flash protection
179*4882a593Smuzhiyun  *
180*4882a593Smuzhiyun  * @param dev		CROS-EC device
181*4882a593Smuzhiyun  * @param set_mask	Mask of flags to set; if 0, just retrieves existing
182*4882a593Smuzhiyun  *                      protection state without changing it.
183*4882a593Smuzhiyun  * @param set_flags	New flag values; only bits in set_mask are applied;
184*4882a593Smuzhiyun  *                      ignored if set_mask=0.
185*4882a593Smuzhiyun  * @param prot          Destination for updated protection state from EC.
186*4882a593Smuzhiyun  * @return 0 if ok, <0 on error
187*4882a593Smuzhiyun  */
188*4882a593Smuzhiyun int cros_ec_flash_protect(struct cros_ec_dev *dev,
189*4882a593Smuzhiyun 		       uint32_t set_mask, uint32_t set_flags,
190*4882a593Smuzhiyun 		       struct ec_response_flash_protect *resp);
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun /**
194*4882a593Smuzhiyun  * Run internal tests on the cros_ec interface.
195*4882a593Smuzhiyun  *
196*4882a593Smuzhiyun  * @param dev		CROS-EC device
197*4882a593Smuzhiyun  * @return 0 if ok, <0 if the test failed
198*4882a593Smuzhiyun  */
199*4882a593Smuzhiyun int cros_ec_test(struct cros_ec_dev *dev);
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun /**
202*4882a593Smuzhiyun  * Update the EC RW copy.
203*4882a593Smuzhiyun  *
204*4882a593Smuzhiyun  * @param dev		CROS-EC device
205*4882a593Smuzhiyun  * @param image		the content to write
206*4882a593Smuzhiyun  * @param imafge_size	content length
207*4882a593Smuzhiyun  * @return 0 if ok, <0 if the test failed
208*4882a593Smuzhiyun  */
209*4882a593Smuzhiyun int cros_ec_flash_update_rw(struct cros_ec_dev *dev,
210*4882a593Smuzhiyun 			 const uint8_t  *image, int image_size);
211*4882a593Smuzhiyun 
212*4882a593Smuzhiyun /**
213*4882a593Smuzhiyun  * Return a pointer to the board's CROS-EC device
214*4882a593Smuzhiyun  *
215*4882a593Smuzhiyun  * This should be implemented by board files.
216*4882a593Smuzhiyun  *
217*4882a593Smuzhiyun  * @return pointer to CROS-EC device, or NULL if none is available
218*4882a593Smuzhiyun  */
219*4882a593Smuzhiyun struct cros_ec_dev *board_get_cros_ec_dev(void);
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun struct dm_cros_ec_ops {
222*4882a593Smuzhiyun 	int (*check_version)(struct udevice *dev);
223*4882a593Smuzhiyun 	int (*command)(struct udevice *dev, uint8_t cmd, int cmd_version,
224*4882a593Smuzhiyun 		       const uint8_t *dout, int dout_len,
225*4882a593Smuzhiyun 		       uint8_t **dinp, int din_len);
226*4882a593Smuzhiyun 	int (*packet)(struct udevice *dev, int out_bytes, int in_bytes);
227*4882a593Smuzhiyun };
228*4882a593Smuzhiyun 
229*4882a593Smuzhiyun #define dm_cros_ec_get_ops(dev) \
230*4882a593Smuzhiyun 		((struct dm_cros_ec_ops *)(dev)->driver->ops)
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun int cros_ec_register(struct udevice *dev);
233*4882a593Smuzhiyun 
234*4882a593Smuzhiyun /**
235*4882a593Smuzhiyun  * Dump a block of data for a command.
236*4882a593Smuzhiyun  *
237*4882a593Smuzhiyun  * @param name	Name for data (e.g. 'in', 'out')
238*4882a593Smuzhiyun  * @param cmd	Command number associated with data, or -1 for none
239*4882a593Smuzhiyun  * @param data	Data block to dump
240*4882a593Smuzhiyun  * @param len	Length of data block to dump
241*4882a593Smuzhiyun  */
242*4882a593Smuzhiyun void cros_ec_dump_data(const char *name, int cmd, const uint8_t *data, int len);
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun /**
245*4882a593Smuzhiyun  * Calculate a simple 8-bit checksum of a data block
246*4882a593Smuzhiyun  *
247*4882a593Smuzhiyun  * @param data	Data block to checksum
248*4882a593Smuzhiyun  * @param size	Size of data block in bytes
249*4882a593Smuzhiyun  * @return checksum value (0 to 255)
250*4882a593Smuzhiyun  */
251*4882a593Smuzhiyun int cros_ec_calc_checksum(const uint8_t *data, int size);
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset,
254*4882a593Smuzhiyun 		uint32_t size);
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun /**
257*4882a593Smuzhiyun  * Read data from the flash
258*4882a593Smuzhiyun  *
259*4882a593Smuzhiyun  * Read an arbitrary amount of data from the EC flash, by repeatedly reading
260*4882a593Smuzhiyun  * small blocks.
261*4882a593Smuzhiyun  *
262*4882a593Smuzhiyun  * The offset starts at 0. You can obtain the region information from
263*4882a593Smuzhiyun  * cros_ec_flash_offset() to find out where to read for a particular region.
264*4882a593Smuzhiyun  *
265*4882a593Smuzhiyun  * @param dev		CROS-EC device
266*4882a593Smuzhiyun  * @param data		Pointer to data buffer to read into
267*4882a593Smuzhiyun  * @param offset	Offset within flash to read from
268*4882a593Smuzhiyun  * @param size		Number of bytes to read
269*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
270*4882a593Smuzhiyun  */
271*4882a593Smuzhiyun int cros_ec_flash_read(struct cros_ec_dev *dev, uint8_t *data, uint32_t offset,
272*4882a593Smuzhiyun 		    uint32_t size);
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun /**
275*4882a593Smuzhiyun  * Read back flash parameters
276*4882a593Smuzhiyun  *
277*4882a593Smuzhiyun  * This function reads back parameters of the flash as reported by the EC
278*4882a593Smuzhiyun  *
279*4882a593Smuzhiyun  * @param dev  Pointer to device
280*4882a593Smuzhiyun  * @param info Pointer to output flash info struct
281*4882a593Smuzhiyun  */
282*4882a593Smuzhiyun int cros_ec_read_flashinfo(struct cros_ec_dev *dev,
283*4882a593Smuzhiyun 			  struct ec_response_flash_info *info);
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun /**
286*4882a593Smuzhiyun  * Write data to the flash
287*4882a593Smuzhiyun  *
288*4882a593Smuzhiyun  * Write an arbitrary amount of data to the EC flash, by repeatedly writing
289*4882a593Smuzhiyun  * small blocks.
290*4882a593Smuzhiyun  *
291*4882a593Smuzhiyun  * The offset starts at 0. You can obtain the region information from
292*4882a593Smuzhiyun  * cros_ec_flash_offset() to find out where to write for a particular region.
293*4882a593Smuzhiyun  *
294*4882a593Smuzhiyun  * Attempting to write to the region where the EC is currently running from
295*4882a593Smuzhiyun  * will result in an error.
296*4882a593Smuzhiyun  *
297*4882a593Smuzhiyun  * @param dev		CROS-EC device
298*4882a593Smuzhiyun  * @param data		Pointer to data buffer to write
299*4882a593Smuzhiyun  * @param offset	Offset within flash to write to.
300*4882a593Smuzhiyun  * @param size		Number of bytes to write
301*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
302*4882a593Smuzhiyun  */
303*4882a593Smuzhiyun int cros_ec_flash_write(struct cros_ec_dev *dev, const uint8_t *data,
304*4882a593Smuzhiyun 		     uint32_t offset, uint32_t size);
305*4882a593Smuzhiyun 
306*4882a593Smuzhiyun /**
307*4882a593Smuzhiyun  * Obtain position and size of a flash region
308*4882a593Smuzhiyun  *
309*4882a593Smuzhiyun  * @param dev		CROS-EC device
310*4882a593Smuzhiyun  * @param region	Flash region to query
311*4882a593Smuzhiyun  * @param offset	Returns offset of flash region in EC flash
312*4882a593Smuzhiyun  * @param size		Returns size of flash region
313*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
314*4882a593Smuzhiyun  */
315*4882a593Smuzhiyun int cros_ec_flash_offset(struct cros_ec_dev *dev, enum ec_flash_region region,
316*4882a593Smuzhiyun 		      uint32_t *offset, uint32_t *size);
317*4882a593Smuzhiyun 
318*4882a593Smuzhiyun /**
319*4882a593Smuzhiyun  * Read/write VbNvContext from/to a CROS-EC device.
320*4882a593Smuzhiyun  *
321*4882a593Smuzhiyun  * @param dev		CROS-EC device
322*4882a593Smuzhiyun  * @param block		Buffer of VbNvContext to be read/write
323*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
324*4882a593Smuzhiyun  */
325*4882a593Smuzhiyun int cros_ec_read_vbnvcontext(struct cros_ec_dev *dev, uint8_t *block);
326*4882a593Smuzhiyun int cros_ec_write_vbnvcontext(struct cros_ec_dev *dev, const uint8_t *block);
327*4882a593Smuzhiyun 
328*4882a593Smuzhiyun /**
329*4882a593Smuzhiyun  * Read the version information for the EC images
330*4882a593Smuzhiyun  *
331*4882a593Smuzhiyun  * @param dev		CROS-EC device
332*4882a593Smuzhiyun  * @param versionp	This is set to point to the version information
333*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
334*4882a593Smuzhiyun  */
335*4882a593Smuzhiyun int cros_ec_read_version(struct cros_ec_dev *dev,
336*4882a593Smuzhiyun 		       struct ec_response_get_version **versionp);
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun /**
339*4882a593Smuzhiyun  * Read the build information for the EC
340*4882a593Smuzhiyun  *
341*4882a593Smuzhiyun  * @param dev		CROS-EC device
342*4882a593Smuzhiyun  * @param versionp	This is set to point to the build string
343*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
344*4882a593Smuzhiyun  */
345*4882a593Smuzhiyun int cros_ec_read_build_info(struct cros_ec_dev *dev, char **strp);
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun /**
348*4882a593Smuzhiyun  * Switch on/off a LDO / FET.
349*4882a593Smuzhiyun  *
350*4882a593Smuzhiyun  * @param dev		CROS-EC device
351*4882a593Smuzhiyun  * @param index		index of the LDO/FET to switch
352*4882a593Smuzhiyun  * @param state		new state of the LDO/FET : EC_LDO_STATE_ON|OFF
353*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
354*4882a593Smuzhiyun  */
355*4882a593Smuzhiyun int cros_ec_set_ldo(struct udevice *dev, uint8_t index, uint8_t state);
356*4882a593Smuzhiyun 
357*4882a593Smuzhiyun /**
358*4882a593Smuzhiyun  * Read back a LDO / FET current state.
359*4882a593Smuzhiyun  *
360*4882a593Smuzhiyun  * @param dev		CROS-EC device
361*4882a593Smuzhiyun  * @param index		index of the LDO/FET to switch
362*4882a593Smuzhiyun  * @param state		current state of the LDO/FET : EC_LDO_STATE_ON|OFF
363*4882a593Smuzhiyun  * @return 0 if ok, -1 on error
364*4882a593Smuzhiyun  */
365*4882a593Smuzhiyun int cros_ec_get_ldo(struct udevice *dev, uint8_t index, uint8_t *state);
366*4882a593Smuzhiyun 
367*4882a593Smuzhiyun /**
368*4882a593Smuzhiyun  * Get access to the error reported when cros_ec_board_init() was called
369*4882a593Smuzhiyun  *
370*4882a593Smuzhiyun  * This permits delayed reporting of the EC error if it failed during
371*4882a593Smuzhiyun  * early init.
372*4882a593Smuzhiyun  *
373*4882a593Smuzhiyun  * @return error (0 if there was no error, -ve if there was an error)
374*4882a593Smuzhiyun  */
375*4882a593Smuzhiyun int cros_ec_get_error(void);
376*4882a593Smuzhiyun 
377*4882a593Smuzhiyun /**
378*4882a593Smuzhiyun  * Returns information from the FDT about the Chrome EC flash
379*4882a593Smuzhiyun  *
380*4882a593Smuzhiyun  * @param dev		Device to read from
381*4882a593Smuzhiyun  * @param config	Structure to use to return information
382*4882a593Smuzhiyun  */
383*4882a593Smuzhiyun int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config);
384*4882a593Smuzhiyun 
385*4882a593Smuzhiyun /**
386*4882a593Smuzhiyun  * Check the current keyboard state, in case recovery mode is requested.
387*4882a593Smuzhiyun  * This function is for sandbox only.
388*4882a593Smuzhiyun  *
389*4882a593Smuzhiyun  * @param ec		CROS-EC device
390*4882a593Smuzhiyun  */
391*4882a593Smuzhiyun void cros_ec_check_keyboard(struct cros_ec_dev *dev);
392*4882a593Smuzhiyun 
393*4882a593Smuzhiyun struct i2c_msg;
394*4882a593Smuzhiyun /*
395*4882a593Smuzhiyun  * Tunnel an I2C transfer to the EC
396*4882a593Smuzhiyun  *
397*4882a593Smuzhiyun  * @param dev		CROS-EC device
398*4882a593Smuzhiyun  * @param port		The remote port on EC to use
399*4882a593Smuzhiyun  * @param msg		List of messages to transfer
400*4882a593Smuzhiyun  * @param nmsgs		Number of messages to transfer
401*4882a593Smuzhiyun  */
402*4882a593Smuzhiyun int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *msg,
403*4882a593Smuzhiyun 		       int nmsgs);
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun #endif
406