1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
13 DECLARE_GLOBAL_DATA_PTR;
15 struct cros_ec_i2c_bus {
19 static int cros_ec_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
24 static int cros_ec_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
27 struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev);
29 return cros_ec_i2c_tunnel(dev->parent, i2c_bus->remote_bus, msg, nmsgs);
32 static int cros_ec_i2c_ofdata_to_platdata(struct udevice *dev)
34 struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev);
35 const void *blob = gd->fdt_blob;
36 int node = dev_of_offset(dev);
38 i2c_bus->remote_bus = fdtdec_get_uint(blob, node, "google,remote-bus",
44 static const struct dm_i2c_ops cros_ec_i2c_ops = {
45 .xfer = cros_ec_i2c_xfer,
46 .set_bus_speed = cros_ec_i2c_set_bus_speed,
49 static const struct udevice_id cros_ec_i2c_ids[] = {
50 { .compatible = "google,cros-ec-i2c-tunnel" },
54 U_BOOT_DRIVER(cros_ec_tunnel) = {
55 .name = "cros_ec_tunnel",
57 .of_match = cros_ec_i2c_ids,
58 .ofdata_to_platdata = cros_ec_i2c_ofdata_to_platdata,
59 .priv_auto_alloc_size = sizeof(struct cros_ec_i2c_bus),
60 .ops = &cros_ec_i2c_ops,