Vadim Bendebury | 41364f0 | 2014-02-27 13:26:02 -0700 | [diff] [blame] | 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 | |
| 11 | #include <common.h> |
| 12 | #include <cros_ec.h> |
Simon Glass | 84d6cbd | 2014-10-13 23:42:14 -0600 | [diff] [blame] | 13 | #include <dm.h> |
| 14 | #include <errno.h> |
| 15 | |
Vadim Bendebury | 41364f0 | 2014-02-27 13:26:02 -0700 | [diff] [blame] | 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Vadim Bendebury | 41364f0 | 2014-02-27 13:26:02 -0700 | [diff] [blame] | 18 | struct cros_ec_dev *board_get_cros_ec_dev(void) |
| 19 | { |
Simon Glass | 84d6cbd | 2014-10-13 23:42:14 -0600 | [diff] [blame] | 20 | struct udevice *dev; |
| 21 | int ret; |
| 22 | |
| 23 | ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev); |
| 24 | if (ret) { |
| 25 | debug("%s: Error %d\n", __func__, ret); |
| 26 | return NULL; |
| 27 | } |
Simon Glass | e564f05 | 2015-03-05 12:25:20 -0700 | [diff] [blame] | 28 | return dev_get_uclass_priv(dev); |
Vadim Bendebury | 41364f0 | 2014-02-27 13:26:02 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | int cros_ec_board_init(void) |
| 32 | { |
Simon Glass | 60f37fc | 2015-03-26 09:29:32 -0600 | [diff] [blame^] | 33 | return 0; |
Vadim Bendebury | 41364f0 | 2014-02-27 13:26:02 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | int cros_ec_get_error(void) |
| 37 | { |
Simon Glass | 84d6cbd | 2014-10-13 23:42:14 -0600 | [diff] [blame] | 38 | struct udevice *dev; |
| 39 | int ret; |
| 40 | |
| 41 | ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev); |
| 42 | if (ret && ret != -ENODEV) |
| 43 | return ret; |
| 44 | |
| 45 | return 0; |
Vadim Bendebury | 41364f0 | 2014-02-27 13:26:02 -0700 | [diff] [blame] | 46 | } |