From f9272713da615e51ea14f70872fec46fbd88e938 Mon Sep 17 00:00:00 2001 From: Vijay Hiremath Date: Mon, 3 Aug 2015 23:37:54 -0700 Subject: i2c: Add i2ctest console command Added i2ctest console command to test the reliability of the I2C. By reading/writing to the known registers this tests provides the number of successful read and writes. BUG=chrome-os-partner:57487 TEST=Enabled the i2ctest config on Reef and tested the i2c read/writes. BRANCH=none Change-Id: I9e27ff96f2b85422933bc590d112a083990e2dfb Signed-off-by: Vijay Hiremath Reviewed-on: https://chromium-review.googlesource.com/290427 Commit-Ready: Vijay P Hiremath Tested-by: Vijay P Hiremath Reviewed-by: Shawn N --- driver/charger/bd9995x.c | 22 ++++++++++++++++++++++ driver/charger/bd9995x.h | 4 ++++ 2 files changed, 26 insertions(+) (limited to 'driver/charger') diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index cbc8d04132..0dd5da99de 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -1231,3 +1231,25 @@ DECLARE_CONSOLE_COMMAND(amonbmon, console_command_amon_bmon, "amonbmon [a|b]", "Get charger AMON/BMON voltage diff, current"); #endif /* CONFIG_CMD_CHARGER_ADC_AMON_BMON */ + +#ifdef CONFIG_CMD_I2C_STRESS_TEST_CHARGER +static int bd9995x_i2c_read(const int reg, int *data) +{ + return ch_raw_read16(reg, data, BD9995X_EXTENDED_COMMAND); +} + +static int bd9995x_i2c_write(const int reg, int data) +{ + return ch_raw_write16(reg, data, BD9995X_EXTENDED_COMMAND); +} + +struct i2c_stress_test_dev bd9995x_i2c_stress_test_dev = { + .reg_info = { + .read_reg = BD9995X_CMD_CHIP_ID, + .read_val = BD9995X_CHIP_ID, + .write_reg = BD9995X_CMD_ITRICH_SET, + }, + .i2c_read_dev = &bd9995x_i2c_read, + .i2c_write_dev = &bd9995x_i2c_write, +}; +#endif /* CONFIG_CMD_I2C_STRESS_TEST_CHARGER */ diff --git a/driver/charger/bd9995x.h b/driver/charger/bd9995x.h index 91a0ac1bbd..baef184d09 100644 --- a/driver/charger/bd9995x.h +++ b/driver/charger/bd9995x.h @@ -359,4 +359,8 @@ void bd9995x_vbus_interrupt(enum gpio_signal signal); /* Read temperature measurement value (in Celsius) */ int bd9995x_get_battery_temp(int *temp_ptr); +#ifdef CONFIG_CMD_I2C_STRESS_TEST_CHARGER +extern struct i2c_stress_test_dev bd9995x_i2c_stress_test_dev; +#endif + #endif /* __CROS_EC_BD9995X_H */ -- cgit v1.2.1