blob: 1a0caf80dde09551133f882df5c34fb9608e5461 [file] [log] [blame]
Vadim Bendebury41364f02014-02-27 13:26:02 -07001/*
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
11#include <common.h>
12#include <cros_ec.h>
Simon Glass84d6cbd2014-10-13 23:42:14 -060013#include <dm.h>
14#include <errno.h>
15
Vadim Bendebury41364f02014-02-27 13:26:02 -070016struct cros_ec_dev *board_get_cros_ec_dev(void)
17{
Simon Glass84d6cbd2014-10-13 23:42:14 -060018 struct udevice *dev;
19 int ret;
20
21 ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
22 if (ret) {
23 debug("%s: Error %d\n", __func__, ret);
24 return NULL;
25 }
Simon Glasse564f052015-03-05 12:25:20 -070026 return dev_get_uclass_priv(dev);
Vadim Bendebury41364f02014-02-27 13:26:02 -070027}
28
Vadim Bendebury41364f02014-02-27 13:26:02 -070029int cros_ec_get_error(void)
30{
Simon Glass84d6cbd2014-10-13 23:42:14 -060031 struct udevice *dev;
32 int ret;
33
34 ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
35 if (ret && ret != -ENODEV)
36 return ret;
37
38 return 0;
Vadim Bendebury41364f02014-02-27 13:26:02 -070039}