nvidia/tegra*: check bus number for i2c driver APIs
BRANCH=None BUG=None TEST=emerge-foster coreboot Change-Id: I383d2b5f269ed348065a9f270f80514a2ff45742 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: fba6973c304e1612a9869c2e78a08650b6e5fe66 Original-Change-Id: I6d5d0098db8dbfb21529bf112a04b97779a0f381 Original-Signed-off-by: Yen Lin <yelin@nvidia.com> Original-Reviewed-on: https://chromium-review.googlesource.com/264027 Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/9913 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
e197748263
commit
cb6bb3bc47
|
@ -194,8 +194,14 @@ static int i2c_transfer_segment(unsigned bus, unsigned chip, int restart,
|
|||
int platform_i2c_transfer(unsigned bus, struct i2c_seg *segments, int count)
|
||||
{
|
||||
struct i2c_seg *seg = segments;
|
||||
|
||||
int i;
|
||||
|
||||
if (bus >= g_num_i2c_buses) {
|
||||
printk(BIOS_ERR, "%s: ERROR: invalid I2C bus (%u)\n", __func__,
|
||||
bus);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; seg++, i++) {
|
||||
if (i2c_transfer_segment(bus, seg->chip, i < count - 1,
|
||||
seg->read, seg->buf, seg->len))
|
||||
|
@ -206,7 +212,15 @@ int platform_i2c_transfer(unsigned bus, struct i2c_seg *segments, int count)
|
|||
|
||||
void i2c_init(unsigned bus)
|
||||
{
|
||||
struct tegra_i2c_regs * const regs = tegra_i2c_info[bus].base;
|
||||
struct tegra_i2c_regs *regs;
|
||||
|
||||
if (bus >= g_num_i2c_buses) {
|
||||
printk(BIOS_ERR, "%s: ERROR: invalid I2C bus (%u)\n", __func__,
|
||||
bus);
|
||||
return;
|
||||
}
|
||||
|
||||
regs = tegra_i2c_info[bus].base;
|
||||
|
||||
write32(®s->cnfg, I2C_CNFG_PACKET_MODE_EN);
|
||||
}
|
||||
|
|
|
@ -172,4 +172,6 @@ struct tegra_i2c_regs {
|
|||
};
|
||||
check_member(tegra_i2c_regs, config_load, 0x8C);
|
||||
|
||||
extern unsigned g_num_i2c_buses;
|
||||
|
||||
#endif /* __SOC_NVIDIA_TEGRA_I2C_H__ */
|
||||
|
|
|
@ -53,3 +53,5 @@ struct tegra_i2c_bus_info tegra_i2c_info[] = {
|
|||
.reset_func = &clock_reset_x
|
||||
}
|
||||
};
|
||||
|
||||
unsigned g_num_i2c_buses = ARRAY_SIZE(tegra_i2c_info);
|
||||
|
|
|
@ -53,3 +53,5 @@ struct tegra_i2c_bus_info tegra_i2c_info[] = {
|
|||
.reset_func = &clock_reset_x
|
||||
}
|
||||
};
|
||||
|
||||
unsigned g_num_i2c_buses = ARRAY_SIZE(tegra_i2c_info);
|
||||
|
|
Loading…
Reference in New Issue