diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2020-03-31 11:47:05 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-04-01 07:46:10 +0200 |
commit | 450d2389c4f923a7fa91bf704e8ee32c0074364b (patch) | |
tree | b1a11d5cb95321754b01b5d57170ba78a8806940 | |
parent | 1437676f8cdf8fafd3269e364fc06f996acc0aad (diff) | |
download | barebox-450d2389c4f923a7fa91bf704e8ee32c0074364b.tar.gz barebox-450d2389c4f923a7fa91bf704e8ee32c0074364b.tar.xz |
ARM: zii-common: Find switch watchdog via DT
Use of_find_i2c_device_by_node() in swith reset code in order to be
able to support other devices that have this MCU on a different I2C
busses.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | arch/arm/boards/zii-common/switch-cmd.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/arch/arm/boards/zii-common/switch-cmd.c b/arch/arm/boards/zii-common/switch-cmd.c index 5e39d8fc69..02802ff860 100644 --- a/arch/arm/boards/zii-common/switch-cmd.c +++ b/arch/arm/boards/zii-common/switch-cmd.c @@ -18,33 +18,40 @@ static int do_rdu2_switch_reset(void) { - struct i2c_client client; + struct device_node *np; + struct i2c_client *client; int ret; u8 reg; - client.adapter = i2c_get_adapter(1); - if (!client.adapter) + np = of_find_compatible_node(NULL, NULL, "zii,rave-wdt"); + if (!np) { + pr_err("No switch watchdog node found\n"); return -ENODEV; + } + + client = of_find_i2c_device_by_node(np); + if (!client) { + pr_err("No switch watchdog I2C device found\n"); + return -ENODEV; + } - /* address of the switch watchdog microcontroller */ - client.addr = 0x38; reg = 0x78; - /* set switch reset time to 100ms */ - ret = i2c_write_reg(&client, 0x0a, ®, 1); + /* set switch reset time to 100ms */ + ret = i2c_write_reg(client, 0x0a, ®, 1); if (ret < 0) { pr_err("Failed to set switch reset time\n"); return ret; } /* reset the switch */ reg = 0x01; - ret = i2c_write_reg(&client, 0x0d, ®, 1); + ret = i2c_write_reg(client, 0x0d, ®, 1); if (ret < 0) { pr_err("Failed to reset the switch\n"); return ret; } /* issue dummy command to work around firmware bug */ - ret = i2c_read_reg(&client, 0x01, ®, 1); + ret = i2c_read_reg(client, 0x01, ®, 1); if (ret < 0) { pr_err("Failed to issue a dummy command\n"); return ret; |