cros_ec.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
  3. * Use of this source code is governed by a BSD-style license that can be
  4. * found in the LICENSE file.
  5. *
  6. * Alternatively, this software may be distributed under the terms of the
  7. * GNU General Public License ("GPL") version 2 as published by the Free
  8. * Software Foundation.
  9. */
  10. #include <common.h>
  11. #include <cros_ec.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. struct local_info {
  14. struct cros_ec_dev *cros_ec_dev; /* Pointer to cros_ec device */
  15. int cros_ec_err; /* Error for cros_ec, 0 if ok */
  16. };
  17. static struct local_info local;
  18. struct cros_ec_dev *board_get_cros_ec_dev(void)
  19. {
  20. return local.cros_ec_dev;
  21. }
  22. static int board_init_cros_ec_devices(const void *blob)
  23. {
  24. local.cros_ec_err = cros_ec_init(blob, &local.cros_ec_dev);
  25. if (local.cros_ec_err)
  26. return -1; /* Will report in board_late_init() */
  27. return 0;
  28. }
  29. int cros_ec_board_init(void)
  30. {
  31. return board_init_cros_ec_devices(gd->fdt_blob);
  32. }
  33. int cros_ec_get_error(void)
  34. {
  35. return local.cros_ec_err;
  36. }