2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
14 DECLARE_GLOBAL_DATA_PTR
;
16 struct cros_ec_i2c_bus
{
20 static int cros_ec_i2c_set_bus_speed(struct udevice
*dev
, unsigned int speed
)
25 static int cros_ec_i2c_xfer(struct udevice
*dev
, struct i2c_msg
*msg
,
28 struct cros_ec_i2c_bus
*i2c_bus
= dev_get_priv(dev
);
30 return cros_ec_i2c_tunnel(dev
->parent
, i2c_bus
->remote_bus
, msg
, nmsgs
);
33 static int cros_ec_i2c_ofdata_to_platdata(struct udevice
*dev
)
35 struct cros_ec_i2c_bus
*i2c_bus
= dev_get_priv(dev
);
36 const void *blob
= gd
->fdt_blob
;
37 int node
= dev_of_offset(dev
);
39 i2c_bus
->remote_bus
= fdtdec_get_uint(blob
, node
, "google,remote-bus",
45 static const struct dm_i2c_ops cros_ec_i2c_ops
= {
46 .xfer
= cros_ec_i2c_xfer
,
47 .set_bus_speed
= cros_ec_i2c_set_bus_speed
,
50 static const struct udevice_id cros_ec_i2c_ids
[] = {
51 { .compatible
= "google,cros-ec-i2c-tunnel" },
55 U_BOOT_DRIVER(cros_ec_tunnel
) = {
56 .name
= "cros_ec_tunnel",
58 .of_match
= cros_ec_i2c_ids
,
59 .ofdata_to_platdata
= cros_ec_i2c_ofdata_to_platdata
,
60 .priv_auto_alloc_size
= sizeof(struct cros_ec_i2c_bus
),
61 .ops
= &cros_ec_i2c_ops
,