]> Git Repo - J-u-boot.git/blame - drivers/i2c/cros_ec_tunnel.c
Merge tag 'u-boot-imx-master-20250127' of https://gitlab.denx.de/u-boot/custodians...
[J-u-boot.git] / drivers / i2c / cros_ec_tunnel.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
cc456bd7
SG
2/*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <[email protected]>
cc456bd7
SG
5 */
6
cc456bd7
SG
7#include <dm.h>
8#include <cros_ec.h>
9#include <errno.h>
10#include <i2c.h>
401d1c4f 11#include <asm/global_data.h>
cc456bd7 12
6d1a718f
MF
13DECLARE_GLOBAL_DATA_PTR;
14
15struct cros_ec_i2c_bus {
16 int remote_bus;
17};
18
cc456bd7
SG
19static int cros_ec_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
20{
21 return 0;
22}
23
24static int cros_ec_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
25 int nmsgs)
26{
6d1a718f
MF
27 struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev);
28
29 return cros_ec_i2c_tunnel(dev->parent, i2c_bus->remote_bus, msg, nmsgs);
30}
31
d1998a9f 32static int cros_ec_i2c_of_to_plat(struct udevice *dev)
6d1a718f
MF
33{
34 struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev);
35 const void *blob = gd->fdt_blob;
e160f7d4 36 int node = dev_of_offset(dev);
6d1a718f
MF
37
38 i2c_bus->remote_bus = fdtdec_get_uint(blob, node, "google,remote-bus",
39 0);
40
41 return 0;
cc456bd7
SG
42}
43
44static 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,
47};
48
49static const struct udevice_id cros_ec_i2c_ids[] = {
50 { .compatible = "google,cros-ec-i2c-tunnel" },
51 { }
52};
53
54U_BOOT_DRIVER(cros_ec_tunnel) = {
55 .name = "cros_ec_tunnel",
56 .id = UCLASS_I2C,
57 .of_match = cros_ec_i2c_ids,
d1998a9f 58 .of_to_plat = cros_ec_i2c_of_to_plat,
41575d8e 59 .priv_auto = sizeof(struct cros_ec_i2c_bus),
cc456bd7
SG
60 .ops = &cros_ec_i2c_ops,
61};
This page took 0.34459 seconds and 5 git commands to generate.