summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLukasz Majewski <lukma@denx.de>2017-03-21 11:08:25 (GMT)
committerHeiko Schocher <hs@denx.de>2017-03-28 04:27:54 (GMT)
commite46f8a3309fb2628940d3e2806c954d84f910165 (patch)
treefef8b56725a7613dd59bfd5f41891461cd955b48 /cmd
parentb52a3fa08b830006c1872517bdafe41160d9223d (diff)
downloadu-boot-e46f8a3309fb2628940d3e2806c954d84f910165.tar.xz
i2c: Set default I2C bus number
This patch allows using i2c commands (e.g. "i2c probe", "i2c md", etc) without the need to first select the bus number with e.g. "i2c dev 0". This is the "i2c" command behavior similar to the one from pre DM, where by default bus 0 was immediately accessible. Signed-off-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/i2c.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/i2c.c b/cmd/i2c.c
index 473153f..3dd7c6b 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -151,6 +151,16 @@ static int cmd_i2c_set_bus_num(unsigned int busnum)
static int i2c_get_cur_bus(struct udevice **busp)
{
+#ifdef CONFIG_I2C_SET_DEFAULT_BUS_NUM
+ if (!i2c_cur_bus) {
+ if (cmd_i2c_set_bus_num(CONFIG_I2C_DEFAULT_BUS_NUMBER)) {
+ printf("Default I2C bus %d not found\n",
+ CONFIG_I2C_DEFAULT_BUS_NUMBER);
+ return -ENODEV;
+ }
+ }
+#endif
+
if (!i2c_cur_bus) {
puts("No I2C bus selected\n");
return -ENODEV;