Commit 6d1a718fdffc92e5d1622d6892384328f5f73d03
Committed by
Tom Rini
1 parent
1053a769fb
Exists in
v2017.01-smarct4x
and in
25 other branches
cros_ec: Honor the google,remote-bus dt property
Boards where ECs that use a I2C port != 0 specify this in the devicetree file via the google,remote-bus property. Previously this was ignored and hardcoded to port 0. Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com> Cc: Simon Glass <sjg@chromium.org> Cc: Heiko Schocher <hs@denx.de> Cc: u-boot@lists.denx.de Acked-by: Simon Glass <sjg@chromium.org>
Showing 3 changed files with 29 additions and 4 deletions Side-by-side Diff
drivers/i2c/cros_ec_tunnel.c
... | ... | @@ -11,6 +11,12 @@ |
11 | 11 | #include <errno.h> |
12 | 12 | #include <i2c.h> |
13 | 13 | |
14 | +DECLARE_GLOBAL_DATA_PTR; | |
15 | + | |
16 | +struct cros_ec_i2c_bus { | |
17 | + int remote_bus; | |
18 | +}; | |
19 | + | |
14 | 20 | static int cros_ec_i2c_set_bus_speed(struct udevice *dev, unsigned int speed) |
15 | 21 | { |
16 | 22 | return 0; |
17 | 23 | |
... | ... | @@ -19,9 +25,23 @@ |
19 | 25 | static int cros_ec_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, |
20 | 26 | int nmsgs) |
21 | 27 | { |
22 | - return cros_ec_i2c_tunnel(dev->parent, msg, nmsgs); | |
28 | + struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev); | |
29 | + | |
30 | + return cros_ec_i2c_tunnel(dev->parent, i2c_bus->remote_bus, msg, nmsgs); | |
23 | 31 | } |
24 | 32 | |
33 | +static int cros_ec_i2c_ofdata_to_platdata(struct udevice *dev) | |
34 | +{ | |
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; | |
38 | + | |
39 | + i2c_bus->remote_bus = fdtdec_get_uint(blob, node, "google,remote-bus", | |
40 | + 0); | |
41 | + | |
42 | + return 0; | |
43 | +} | |
44 | + | |
25 | 45 | static const struct dm_i2c_ops cros_ec_i2c_ops = { |
26 | 46 | .xfer = cros_ec_i2c_xfer, |
27 | 47 | .set_bus_speed = cros_ec_i2c_set_bus_speed, |
... | ... | @@ -36,6 +56,8 @@ |
36 | 56 | .name = "cros_ec_tunnel", |
37 | 57 | .id = UCLASS_I2C, |
38 | 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), | |
39 | 61 | .ops = &cros_ec_i2c_ops, |
40 | 62 | }; |
drivers/misc/cros_ec.c
... | ... | @@ -1058,7 +1058,8 @@ |
1058 | 1058 | return 0; |
1059 | 1059 | } |
1060 | 1060 | |
1061 | -int cros_ec_i2c_tunnel(struct udevice *dev, struct i2c_msg *in, int nmsgs) | |
1061 | +int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *in, | |
1062 | + int nmsgs) | |
1062 | 1063 | { |
1063 | 1064 | struct cros_ec_dev *cdev = dev_get_uclass_priv(dev); |
1064 | 1065 | union { |
... | ... | @@ -1078,7 +1079,7 @@ |
1078 | 1079 | int rv; |
1079 | 1080 | int i; |
1080 | 1081 | |
1081 | - p->port = 0; | |
1082 | + p->port = port; | |
1082 | 1083 | |
1083 | 1084 | p->num_msgs = nmsgs; |
1084 | 1085 | size = sizeof(*p) + p->num_msgs * sizeof(*msg); |
include/cros_ec.h
... | ... | @@ -395,10 +395,12 @@ |
395 | 395 | * Tunnel an I2C transfer to the EC |
396 | 396 | * |
397 | 397 | * @param dev CROS-EC device |
398 | + * @param port The remote port on EC to use | |
398 | 399 | * @param msg List of messages to transfer |
399 | 400 | * @param nmsgs Number of messages to transfer |
400 | 401 | */ |
401 | -int cros_ec_i2c_tunnel(struct udevice *dev, struct i2c_msg *msg, int nmsgs); | |
402 | +int cros_ec_i2c_tunnel(struct udevice *dev, int port, struct i2c_msg *msg, | |
403 | + int nmsgs); | |
402 | 404 | |
403 | 405 | #endif |