From 57dc20f5a8ce3e8de9d1a396980d631581b015ad Mon Sep 17 00:00:00 2001 From: Praveen AC Date: Mon, 9 Sep 2024 18:58:23 +0000 Subject: [PATCH] virtual_i2c_mux:Add virtual i2c mux support for other Hawks. Add virtual i2c bus support for 2nd,3rd & 4th Hawks to read/write EEPROM data while streaming. Bug 4807682 Change-Id: I3cd05718a38ed11dd23fd67fee1efb8c7054af71 Signed-off-by: Praveen AC Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3210317 Reviewed-by: Bibek Basu GVS: buildbot_gerritrpt Reviewed-by: Ankur Pawar --- drivers/media/i2c/virtual_i2c_mux.c | 43 ++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/virtual_i2c_mux.c b/drivers/media/i2c/virtual_i2c_mux.c index 8e461108..d2c1b8be 100644 --- a/drivers/media/i2c/virtual_i2c_mux.c +++ b/drivers/media/i2c/virtual_i2c_mux.c @@ -15,7 +15,10 @@ #include #define DESER_A (0) -#define ENABLE_IMU (0xFE) +#define ENABLE_CC1 (0xFE) +#define ENABLE_CC2 (0xFB) +#define ENABLE_CC3 (0xEF) +#define ENABLE_CC4 (0xBF) #define ENABLE_ALL_CC (0xAA) #define DESER_ADDR (0x52) #define DESER_CC_REG (0x0003) @@ -27,10 +30,31 @@ static int virtual_i2c_mux_select(struct i2c_mux_core *muxc, u32 chan) int ret = 0; /* Do select 1st channel, to access IMUs from 1st Hawk */ - if (!chan) { - ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_IMU); - if (ret) - pr_err("%s: Failed to do i2c address trans for IMUs\n",__func__); + switch (chan) { + case 0: + ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_CC1); + if (ret) + pr_err("%s: Failed to do i2c address trans for CC1\n", __func__); + break; + case 1: + ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_CC2); + if (ret) + pr_err("%s: Failed to do i2c address trans for CC2\n", __func__); + break; + case 2: + ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_CC3); + if (ret) + pr_err("%s: Failed to do i2c address trans for CC3\n", __func__); + break; + case 3: + ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_CC4); + if (ret) + pr_err("%s: Failed to do i2c address trans for CC4\n", __func__); + break; + default: + pr_err("%s: No channels matched chan = %d\n", __func__, chan); + ret = -EINVAL; + break; } return ret; @@ -41,11 +65,10 @@ static int virtual_i2c_mux_deselect(struct i2c_mux_core *muxc, u32 chan) int ret = 0; /* Enable all control channels */ - if (!chan) { - ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_ALL_CC); - if (ret) - pr_err("%s: Failed to do i2c address trans for IMUs\n",__func__); - } + ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_ALL_CC); + if (ret) + pr_err("%s: Failed to do i2c address trans for IMUs\n",__func__); + return ret; }