cros_ec.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Chromium OS cros_ec driver
  4. *
  5. * Copyright (c) 2012 The Chromium OS Authors.
  6. */
  7. #ifndef _CROS_EC_H
  8. #define _CROS_EC_H
  9. #include <linux/compiler.h>
  10. #include <ec_commands.h>
  11. #include <cros_ec_message.h>
  12. #include <asm/gpio.h>
  13. #include <dm/of_extra.h>
  14. /* Our configuration information */
  15. struct cros_ec_dev {
  16. struct udevice *dev; /* Transport device */
  17. struct gpio_desc ec_int; /* GPIO used as EC interrupt line */
  18. int protocol_version; /* Protocol version to use */
  19. int optimise_flash_write; /* Don't write erased flash blocks */
  20. /*
  21. * These two buffers will always be dword-aligned and include enough
  22. * space for up to 7 word-alignment bytes also, so we can ensure that
  23. * the body of the message is always dword-aligned (64-bit).
  24. *
  25. * We use this alignment to keep ARM and x86 happy. Probably word
  26. * alignment would be OK, there might be a small performance advantage
  27. * to using dword.
  28. */
  29. uint8_t din[ALIGN(MSG_BYTES + sizeof(int64_t), sizeof(int64_t))]
  30. __aligned(sizeof(int64_t));
  31. uint8_t dout[ALIGN(MSG_BYTES + sizeof(int64_t), sizeof(int64_t))]
  32. __aligned(sizeof(int64_t));
  33. };
  34. /*
  35. * Hard-code the number of columns we happen to know we have right now. It
  36. * would be more correct to call cros_ec_info() at startup and determine the
  37. * actual number of keyboard cols from there.
  38. */
  39. #define CROS_EC_KEYSCAN_COLS 13
  40. /* Information returned by a key scan */
  41. struct mbkp_keyscan {
  42. uint8_t data[CROS_EC_KEYSCAN_COLS];
  43. };
  44. /* Holds information about the Chrome EC */
  45. struct fdt_cros_ec {
  46. struct fmap_entry flash; /* Address and size of EC flash */
  47. /*
  48. * Byte value of erased flash, or -1 if not known. It is normally
  49. * 0xff but some flash devices use 0 (e.g. STM32Lxxx)
  50. */
  51. int flash_erase_value;
  52. struct fmap_entry region[EC_FLASH_REGION_COUNT];
  53. };
  54. /**
  55. * Read the ID of the CROS-EC device
  56. *
  57. * The ID is a string identifying the CROS-EC device.
  58. *
  59. * @param dev CROS-EC device
  60. * @param id Place to put the ID
  61. * @param maxlen Maximum length of the ID field
  62. * @return 0 if ok, -1 on error
  63. */
  64. int cros_ec_read_id(struct udevice *dev, char *id, int maxlen);
  65. /**
  66. * Read a keyboard scan from the CROS-EC device
  67. *
  68. * Send a message requesting a keyboard scan and return the result
  69. *
  70. * @param dev CROS-EC device
  71. * @param scan Place to put the scan results
  72. * @return 0 if ok, -1 on error
  73. */
  74. int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan);
  75. /**
  76. * Get the next pending MKBP event from the ChromeOS EC device.
  77. *
  78. * Send a message requesting the next event and return the result.
  79. *
  80. * @param event Place to put the event.
  81. * @return 0 if ok, <0 on error.
  82. */
  83. int cros_ec_get_next_event(struct udevice *dev,
  84. struct ec_response_get_next_event *event);
  85. /**
  86. * Read which image is currently running on the CROS-EC device.
  87. *
  88. * @param dev CROS-EC device
  89. * @param image Destination for image identifier
  90. * @return 0 if ok, <0 on error
  91. */
  92. int cros_ec_read_current_image(struct udevice *dev,
  93. enum ec_current_image *image);
  94. /**
  95. * Read the hash of the CROS-EC device firmware.
  96. *
  97. * @param dev CROS-EC device
  98. * @param hash_offset Offset in flash to read from
  99. * @param hash Destination for hash information
  100. * @return 0 if ok, <0 on error
  101. */
  102. int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
  103. struct ec_response_vboot_hash *hash);
  104. /**
  105. * Send a reboot command to the CROS-EC device.
  106. *
  107. * Note that some reboot commands (such as EC_REBOOT_COLD) also reboot the AP.
  108. *
  109. * @param dev CROS-EC device
  110. * @param cmd Reboot command
  111. * @param flags Flags for reboot command (EC_REBOOT_FLAG_*)
  112. * @return 0 if ok, <0 on error
  113. */
  114. int cros_ec_reboot(struct udevice *dev, enum ec_reboot_cmd cmd, uint8_t flags);
  115. /**
  116. * Check if the CROS-EC device has an interrupt pending.
  117. *
  118. * Read the status of the external interrupt connected to the CROS-EC device.
  119. * If no external interrupt is configured, this always returns 1.
  120. *
  121. * @param dev CROS-EC device
  122. * @return 0 if no interrupt is pending
  123. */
  124. int cros_ec_interrupt_pending(struct udevice *dev);
  125. enum {
  126. CROS_EC_OK,
  127. CROS_EC_ERR = 1,
  128. CROS_EC_ERR_FDT_DECODE,
  129. CROS_EC_ERR_CHECK_VERSION,
  130. CROS_EC_ERR_READ_ID,
  131. CROS_EC_ERR_DEV_INIT,
  132. };
  133. /**
  134. * Initialise the Chromium OS EC driver
  135. *
  136. * @param blob Device tree blob containing setup information
  137. * @param cros_ecp Returns pointer to the cros_ec device, or NULL if none
  138. * @return 0 if we got an cros_ec device and all is well (or no cros_ec is
  139. * expected), -ve if we should have an cros_ec device but failed to find
  140. * one, or init failed (-CROS_EC_ERR_...).
  141. */
  142. int cros_ec_init(const void *blob, struct udevice**cros_ecp);
  143. /**
  144. * Read information about the keyboard matrix
  145. *
  146. * @param dev CROS-EC device
  147. * @param info Place to put the info structure
  148. */
  149. int cros_ec_info(struct udevice *dev, struct ec_response_mkbp_info *info);
  150. /**
  151. * Read the host event flags
  152. *
  153. * @param dev CROS-EC device
  154. * @param events_ptr Destination for event flags. Not changed on error.
  155. * @return 0 if ok, <0 on error
  156. */
  157. int cros_ec_get_host_events(struct udevice *dev, uint32_t *events_ptr);
  158. /**
  159. * Clear the specified host event flags
  160. *
  161. * @param dev CROS-EC device
  162. * @param events Event flags to clear
  163. * @return 0 if ok, <0 on error
  164. */
  165. int cros_ec_clear_host_events(struct udevice *dev, uint32_t events);
  166. /**
  167. * Get/set flash protection
  168. *
  169. * @param dev CROS-EC device
  170. * @param set_mask Mask of flags to set; if 0, just retrieves existing
  171. * protection state without changing it.
  172. * @param set_flags New flag values; only bits in set_mask are applied;
  173. * ignored if set_mask=0.
  174. * @param prot Destination for updated protection state from EC.
  175. * @return 0 if ok, <0 on error
  176. */
  177. int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
  178. uint32_t set_flags,
  179. struct ec_response_flash_protect *resp);
  180. /**
  181. * Run internal tests on the cros_ec interface.
  182. *
  183. * @param dev CROS-EC device
  184. * @return 0 if ok, <0 if the test failed
  185. */
  186. int cros_ec_test(struct udevice *dev);
  187. /**
  188. * Update the EC RW copy.
  189. *
  190. * @param dev CROS-EC device
  191. * @param image the content to write
  192. * @param imafge_size content length
  193. * @return 0 if ok, <0 if the test failed
  194. */
  195. int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t *image,
  196. int image_size);
  197. /**
  198. * Return a pointer to the board's CROS-EC device
  199. *
  200. * @return pointer to CROS-EC device, or NULL if none is available
  201. */
  202. struct udevice *board_get_cros_ec_dev(void);
  203. struct dm_cros_ec_ops {
  204. /**
  205. * check_version() - Check the protocol version being used (optional)
  206. *
  207. * If provided, this function should check that the EC can be supported
  208. * by the driver. If not provided, HELLO messages will be sent to try
  209. * to determine the protocol version.
  210. *
  211. * @dev: Device to check
  212. * @return 0 if the protocol is valid, -ve if not supported
  213. */
  214. int (*check_version)(struct udevice *dev);
  215. /**
  216. * command() - Old-style command interface
  217. *
  218. * This sends a command and receives a response (deprecated, use
  219. * packet())
  220. *
  221. * @dev: Device to use
  222. * @cmd: Command to send (only supports 0-0xff)
  223. * @cmd_version: Version of command to send (often 0)
  224. * @dout: Output data (may be NULL If dout_len=0)
  225. * @dout_len: Length of output data excluding 4-byte header
  226. * @dinp: On input, set to point to input data, often struct
  227. * cros_ec_dev->din - typically this is left alone but may be
  228. * updated by the driver
  229. * @din_len: Maximum length of response
  230. * @return number of bytes in response, or -ve on error
  231. */
  232. int (*command)(struct udevice *dev, uint8_t cmd, int cmd_version,
  233. const uint8_t *dout, int dout_len,
  234. uint8_t **dinp, int din_len);
  235. /**
  236. * packet() - New-style command interface
  237. *
  238. * This interface is preferred over command(), since it is typically
  239. * easier to implement.
  240. *
  241. * @dev: Device to use
  242. * @out_bytes: Number of bytes to send (from struct cros_ec_dev->dout)
  243. * @in_bytes: Maximum number of bytes to expect in response
  244. * @return number of bytes in response, or -ve on error
  245. */
  246. int (*packet)(struct udevice *dev, int out_bytes, int in_bytes);
  247. /**
  248. * get_switches() - Get value of EC switches
  249. *
  250. * This is currently supported on the LPC EC.
  251. *
  252. * @dev: Device to use
  253. * @return current switches value, or -ENOSYS if not supported
  254. */
  255. int (*get_switches)(struct udevice *dev);
  256. };
  257. #define dm_cros_ec_get_ops(dev) \
  258. ((struct dm_cros_ec_ops *)(dev)->driver->ops)
  259. int cros_ec_register(struct udevice *dev);
  260. /**
  261. * Dump a block of data for a command.
  262. *
  263. * @param name Name for data (e.g. 'in', 'out')
  264. * @param cmd Command number associated with data, or -1 for none
  265. * @param data Data block to dump
  266. * @param len Length of data block to dump
  267. */
  268. void cros_ec_dump_data(const char *name, int cmd, const uint8_t *data, int len);
  269. /**
  270. * Calculate a simple 8-bit checksum of a data block
  271. *
  272. * @param data Data block to checksum
  273. * @param size Size of data block in bytes
  274. * @return checksum value (0 to 255)
  275. */
  276. int cros_ec_calc_checksum(const uint8_t *data, int size);
  277. int cros_ec_flash_erase(struct udevice *dev, uint32_t offset, uint32_t size);
  278. /**
  279. * Read data from the flash
  280. *
  281. * Read an arbitrary amount of data from the EC flash, by repeatedly reading
  282. * small blocks.
  283. *
  284. * The offset starts at 0. You can obtain the region information from
  285. * cros_ec_flash_offset() to find out where to read for a particular region.
  286. *
  287. * @param dev CROS-EC device
  288. * @param data Pointer to data buffer to read into
  289. * @param offset Offset within flash to read from
  290. * @param size Number of bytes to read
  291. * @return 0 if ok, -1 on error
  292. */
  293. int cros_ec_flash_read(struct udevice *dev, uint8_t *data, uint32_t offset,
  294. uint32_t size);
  295. /**
  296. * Read back flash parameters
  297. *
  298. * This function reads back parameters of the flash as reported by the EC
  299. *
  300. * @param dev Pointer to device
  301. * @param info Pointer to output flash info struct
  302. */
  303. int cros_ec_read_flashinfo(struct udevice *dev,
  304. struct ec_response_flash_info *info);
  305. /**
  306. * Write data to the flash
  307. *
  308. * Write an arbitrary amount of data to the EC flash, by repeatedly writing
  309. * small blocks.
  310. *
  311. * The offset starts at 0. You can obtain the region information from
  312. * cros_ec_flash_offset() to find out where to write for a particular region.
  313. *
  314. * Attempting to write to the region where the EC is currently running from
  315. * will result in an error.
  316. *
  317. * @param dev CROS-EC device
  318. * @param data Pointer to data buffer to write
  319. * @param offset Offset within flash to write to.
  320. * @param size Number of bytes to write
  321. * @return 0 if ok, -1 on error
  322. */
  323. int cros_ec_flash_write(struct udevice *dev, const uint8_t *data,
  324. uint32_t offset, uint32_t size);
  325. /**
  326. * Obtain position and size of a flash region
  327. *
  328. * @param dev CROS-EC device
  329. * @param region Flash region to query
  330. * @param offset Returns offset of flash region in EC flash
  331. * @param size Returns size of flash region
  332. * @return 0 if ok, -1 on error
  333. */
  334. int cros_ec_flash_offset(struct udevice *dev, enum ec_flash_region region,
  335. uint32_t *offset, uint32_t *size);
  336. /**
  337. * cros_ec_get_sku_id() - Read the SKU ID
  338. *
  339. * @dev: CROS-EC device
  340. * return SKU ID, or -ve on error
  341. */
  342. int cros_ec_get_sku_id(struct udevice *dev);
  343. /**
  344. * Read/write non-volatile data from/to a CROS-EC device.
  345. *
  346. * @param dev CROS-EC device
  347. * @param block Buffer of VbNvContext to be read/write
  348. * @return 0 if ok, -1 on error
  349. */
  350. int cros_ec_read_nvdata(struct udevice *dev, uint8_t *block, int size);
  351. int cros_ec_write_nvdata(struct udevice *dev, const uint8_t *block, int size);
  352. /**
  353. * Read the version information for the EC images
  354. *
  355. * @param dev CROS-EC device
  356. * @param versionp This is set to point to the version information
  357. * @return 0 if ok, -1 on error
  358. */
  359. int cros_ec_read_version(struct udevice *dev,
  360. struct ec_response_get_version **versionp);
  361. /**
  362. * Read the build information for the EC
  363. *
  364. * @param dev CROS-EC device
  365. * @param versionp This is set to point to the build string
  366. * @return 0 if ok, -1 on error
  367. */
  368. int cros_ec_read_build_info(struct udevice *dev, char **strp);
  369. /**
  370. * Switch on/off a LDO / FET.
  371. *
  372. * @param dev CROS-EC device
  373. * @param index index of the LDO/FET to switch
  374. * @param state new state of the LDO/FET : EC_LDO_STATE_ON|OFF
  375. * @return 0 if ok, -1 on error
  376. */
  377. int cros_ec_set_ldo(struct udevice *dev, uint8_t index, uint8_t state);
  378. /**
  379. * Read back a LDO / FET current state.
  380. *
  381. * @param dev CROS-EC device
  382. * @param index index of the LDO/FET to switch
  383. * @param state current state of the LDO/FET : EC_LDO_STATE_ON|OFF
  384. * @return 0 if ok, -1 on error
  385. */
  386. int cros_ec_get_ldo(struct udevice *dev, uint8_t index, uint8_t *state);
  387. /**
  388. * Get access to the error reported when cros_ec_board_init() was called
  389. *
  390. * This permits delayed reporting of the EC error if it failed during
  391. * early init.
  392. *
  393. * @return error (0 if there was no error, -ve if there was an error)
  394. */
  395. int cros_ec_get_error(void);
  396. /**
  397. * Returns information from the FDT about the Chrome EC flash
  398. *
  399. * @param dev Device to read from
  400. * @param config Structure to use to return information
  401. */
  402. int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config);
  403. /**
  404. * Check the current keyboard state, in case recovery mode is requested.
  405. * This function is for sandbox only.
  406. *
  407. * @param ec CROS-EC device
  408. */
  409. void cros_ec_check_keyboard(struct udevice *dev);
  410. struct i2c_msg;
  411. /*
  412. * Tunnel an I2C transfer to the EC
  413. *
  414. * @param dev CROS-EC device
  415. * @param port The remote port on EC to use
  416. * @param msg List of messages to transfer
  417. * @param nmsgs Number of messages to transfer
  418. */
  419. int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *msg,
  420. int nmsgs);
  421. /**
  422. * cros_ec_get_events_b() - Get event mask B
  423. *
  424. * @return value of event mask, default value of 0 if it could not be read
  425. */
  426. uint64_t cros_ec_get_events_b(struct udevice *dev);
  427. /**
  428. * cros_ec_clear_events_b() - Clear even mask B
  429. *
  430. * Any pending events in the B range are cleared
  431. *
  432. * @return 0 if OK, -ve on error
  433. */
  434. int cros_ec_clear_events_b(struct udevice *dev, uint64_t mask);
  435. /**
  436. * cros_ec_efs_verify() - tell the EC to verify one of its images
  437. *
  438. * @param dev CROS-EC device
  439. * @param region Flash region to query
  440. * @return 0 if OK, -ve on error
  441. */
  442. int cros_ec_efs_verify(struct udevice *dev, enum ec_flash_region region);
  443. /**
  444. * cros_ec_battery_cutoff() - Request that the battery be cut off
  445. *
  446. * This tells the battery to stop supplying power. This is used before shipping
  447. * a device to ensure that the battery remains charged while the device is
  448. * shipped or sitting on the shelf waiting to be purchased.
  449. *
  450. * @param dev CROS-EC device
  451. * @param flags Flags to use (EC_BATTERY_CUTOFF_FLAG_...)
  452. * @return 0 if OK, -ve on error
  453. */
  454. int cros_ec_battery_cutoff(struct udevice *dev, uint8_t flags);
  455. /**
  456. * cros_ec_set_pwm_duty() - Set duty cycle of a generic pwm
  457. *
  458. * Note that duty value needs to be passed to the EC as a 16 bit number
  459. * for increased precision.
  460. *
  461. * @param dev CROS-EC device
  462. * @param index Index of the pwm
  463. * @param duty Desired duty cycle, in 0..EC_PWM_MAX_DUTY range.
  464. * @return 0 if OK, -ve on error
  465. */
  466. int cros_ec_set_pwm_duty(struct udevice *dev, uint8_t index, uint16_t duty);
  467. /**
  468. * cros_ec_read_limit_power() - Check if power is limited by batter/charger
  469. *
  470. * Sometimes the battery is low and / or the device is connected to a charger
  471. * that cannot supply much power.
  472. *
  473. * @param dev CROS-EC device
  474. * @param limit_powerp Returns whether power is limited (0 or 1)
  475. * @return 0 if OK, -ENOSYS if the EC does not support this comment, -EINVAL
  476. * if the EC returned an invalid response
  477. */
  478. int cros_ec_read_limit_power(struct udevice *dev, int *limit_powerp);
  479. /**
  480. * cros_ec_config_powerbtn() - Configure the behaviour of the power button
  481. *
  482. * @param dev CROS-EC device
  483. * @param flags Flags to use (EC_POWER_BUTTON_...)
  484. * @return 0 if OK, -ve on error
  485. */
  486. int cros_ec_config_powerbtn(struct udevice *dev, uint32_t flags);
  487. /**
  488. * cros_ec_get_lid_shutdown_mask() - Set the lid shutdown mask
  489. *
  490. * Determines whether a lid close event is reported
  491. *
  492. * @param dev CROS-EC device
  493. * @return shufdown mas if OK, -ve on error
  494. */
  495. int cros_ec_get_lid_shutdown_mask(struct udevice *dev);
  496. /**
  497. * cros_ec_set_lid_shutdown_mask() - Set the lid shutdown mask
  498. *
  499. * Set whether a lid close event is reported
  500. *
  501. * @param dev CROS-EC device
  502. * @param enable true to enable reporting, false to disable
  503. * @return shufdown mas if OK, -ve on error
  504. */
  505. int cros_ec_set_lid_shutdown_mask(struct udevice *dev, int enable);
  506. /**
  507. * cros_ec_hello() - Send a hello message
  508. *
  509. * Sends a message with a fixed input value and checks that the expected output
  510. * value is received
  511. *
  512. * @dev: CROS-EC device
  513. * @handshakep: If non-NULL, returns received handshake value on error
  514. * @return 0 if OK, -ve on error
  515. */
  516. int cros_ec_hello(struct udevice *dev, uint *handshakep);
  517. /**
  518. * cros_ec_get_features() - Get the set of features provided by the EC
  519. *
  520. * See enum ec_feature_code for the list of available features
  521. *
  522. * @dev: CROS-EC device
  523. * @featuresp: Returns a bitmask of supported features
  524. * @return 0 if OK, -ve on error
  525. */
  526. int cros_ec_get_features(struct udevice *dev, u64 *featuresp);
  527. /**
  528. * cros_ec_check_feature() - Check if a feature is supported
  529. *
  530. * @dev: CROS-EC device
  531. * @feature: Feature number to check (enum ec_feature_code)
  532. * @return true if supported, false if not, -ve on error
  533. */
  534. int cros_ec_check_feature(struct udevice *dev, uint feature);
  535. /**
  536. * cros_ec_get_switches() - Get switches value
  537. *
  538. * @dev: CROS-EC device
  539. * @return switches value, or -ENOSYS if not supported, or other -ve value on
  540. * other error
  541. */
  542. int cros_ec_get_switches(struct udevice *dev);
  543. /**
  544. * cros_ec_vstore_supported() - Check if vstore is supported
  545. *
  546. * @dev: CROS-EC device
  547. * @return false if not supported, true if supported, -ve on error
  548. */
  549. int cros_ec_vstore_supported(struct udevice *dev);
  550. /**
  551. * cros_ec_vstore_info() - Get vstore information
  552. *
  553. * @dev: CROS-EC device
  554. * @lockedp: mask of locked slots
  555. * @return number of vstore slots supported by the EC,, -ve on error
  556. */
  557. int cros_ec_vstore_info(struct udevice *dev, u32 *lockedp);
  558. /**
  559. * cros_ec_vstore_read() - Read data from EC vstore slot
  560. *
  561. * @dev: CROS-EC device
  562. * @slot: vstore slot to read from
  563. * @data: buffer to store read data, must be EC_VSTORE_SLOT_SIZE bytes
  564. * @return 0 if OK, -ve on error
  565. */
  566. int cros_ec_vstore_read(struct udevice *dev, int slot, uint8_t *data);
  567. /**
  568. * cros_ec_vstore_write() - Save data into EC vstore slot
  569. *
  570. * The maximum size of data is EC_VSTORE_SLOT_SIZE. It is the caller's
  571. * responsibility to check the number of implemented slots by querying the
  572. * vstore info.
  573. *
  574. * @dev: CROS-EC device
  575. * @slot: vstore slot to write into
  576. * @data: data to write
  577. * @size: size of data in bytes
  578. * @return 0 if OK, -ve on error
  579. */
  580. int cros_ec_vstore_write(struct udevice *dev, int slot, const uint8_t *data,
  581. size_t size);
  582. /**
  583. * cros_ec_read_batt_charge() - Read the battery-charge state
  584. *
  585. * @dev: CROS-EC device
  586. * @chargep: Return battery-charge state as a percentage
  587. */
  588. int cros_ec_read_batt_charge(struct udevice *dev, uint *chargep);
  589. #endif