xref: /OK3568_Linux_fs/u-boot/common/cros_ec.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
3*4882a593Smuzhiyun  * Use of this source code is governed by a BSD-style license that can be
4*4882a593Smuzhiyun  * found in the LICENSE file.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Alternatively, this software may be distributed under the terms of the
7*4882a593Smuzhiyun  * GNU General Public License ("GPL") version 2 as published by the Free
8*4882a593Smuzhiyun  * Software Foundation.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <common.h>
12*4882a593Smuzhiyun #include <cros_ec.h>
13*4882a593Smuzhiyun #include <dm.h>
14*4882a593Smuzhiyun #include <errno.h>
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun DECLARE_GLOBAL_DATA_PTR;
17*4882a593Smuzhiyun 
board_get_cros_ec_dev(void)18*4882a593Smuzhiyun struct cros_ec_dev *board_get_cros_ec_dev(void)
19*4882a593Smuzhiyun {
20*4882a593Smuzhiyun 	struct udevice *dev;
21*4882a593Smuzhiyun 	int ret;
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun 	ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
24*4882a593Smuzhiyun 	if (ret) {
25*4882a593Smuzhiyun 		debug("%s: Error %d\n", __func__, ret);
26*4882a593Smuzhiyun 		return NULL;
27*4882a593Smuzhiyun 	}
28*4882a593Smuzhiyun 	return dev_get_uclass_priv(dev);
29*4882a593Smuzhiyun }
30*4882a593Smuzhiyun 
cros_ec_get_error(void)31*4882a593Smuzhiyun int cros_ec_get_error(void)
32*4882a593Smuzhiyun {
33*4882a593Smuzhiyun 	struct udevice *dev;
34*4882a593Smuzhiyun 	int ret;
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun 	ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
37*4882a593Smuzhiyun 	if (ret && ret != -ENODEV)
38*4882a593Smuzhiyun 		return ret;
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun 	return 0;
41*4882a593Smuzhiyun }
42