xref: /openbmc/u-boot/drivers/i2c/cros_ec_tunnel.c (revision c5f18a0b)
1 /*
2  * Copyright (c) 2015 Google, Inc
3  * Written by Simon Glass <sjg@chromium.org>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <common.h>
9 #include <dm.h>
10 #include <cros_ec.h>
11 #include <errno.h>
12 #include <i2c.h>
13 
14 static int cros_ec_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
15 {
16 	return 0;
17 }
18 
19 static int cros_ec_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
20 			    int nmsgs)
21 {
22 	return cros_ec_i2c_tunnel(dev->parent, msg, nmsgs);
23 }
24 
25 static const struct dm_i2c_ops cros_ec_i2c_ops = {
26 	.xfer		= cros_ec_i2c_xfer,
27 	.set_bus_speed	= cros_ec_i2c_set_bus_speed,
28 };
29 
30 static const struct udevice_id cros_ec_i2c_ids[] = {
31 	{ .compatible = "google,cros-ec-i2c-tunnel" },
32 	{ }
33 };
34 
35 U_BOOT_DRIVER(cros_ec_tunnel) = {
36 	.name	= "cros_ec_tunnel",
37 	.id	= UCLASS_I2C,
38 	.of_match = cros_ec_i2c_ids,
39 	.per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
40 	.ops	= &cros_ec_i2c_ops,
41 };
42