cros_ec.c 870 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include <dm.h>
  13. #include <errno.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. struct cros_ec_dev *board_get_cros_ec_dev(void)
  16. {
  17. struct udevice *dev;
  18. int ret;
  19. ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
  20. if (ret) {
  21. debug("%s: Error %d\n", __func__, ret);
  22. return NULL;
  23. }
  24. return dev_get_uclass_priv(dev);
  25. }
  26. int cros_ec_get_error(void)
  27. {
  28. struct udevice *dev;
  29. int ret;
  30. ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
  31. if (ret && ret != -ENODEV)
  32. return ret;
  33. return 0;
  34. }