1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 16:52:14 +02:00

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>
This commit is contained in:
Lukasz Majewski
2017-03-21 12:08:25 +01:00
committed by Heiko Schocher
parent b52a3fa08b
commit e46f8a3309
2 changed files with 24 additions and 0 deletions

View File

@@ -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;