virtual i2c mux support for other Hawks

* Add virtual i2c bus support for 2nd, 3rd
& 4th Hawks to read/write EEPROM data
while streaming
* Move MAX96712 function declarations to
a proper header file instead of using extern
declarations in .c files. This fixes checkpatch
warnings about externs in .c files and improves
code organization

Bug 4807682

Change-Id: Ie4e7f7b9adc6fe6255a517cd5f076afdc754384a
Signed-off-by: Praveen AC <pac@nvidia.com>
(cherry picked from commit 57dc20f5a8)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3365540
Reviewed-by: Narendra Kondapalli <nkondapalli@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Ankur Pawar <ankurp@nvidia.com>
This commit is contained in:
Praveen AC
2024-09-09 18:58:23 +00:00
committed by Jon Hunter
parent 5de17f758a
commit 459e781d79
2 changed files with 59 additions and 23 deletions

View File

@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES.
* All rights reserved.
*/
/*
* MAX96712 deserializer driver header
*/
#ifndef __MAX96712_H__
#define __MAX96712_H__
int max96712_write_reg_Dser(int slaveAddr, int channel, u16 addr, u8 val);
int max96712_read_reg_Dser(int slaveAddr, int channel, u16 addr, unsigned int *val);
#endif /* __MAX96712_H__ */

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/* /*
* virtual_i2c_mux.c - virtual i2c mux driver for P3762 & P3783 GMSL boards. * virtual_i2c_mux.c - virtual i2c mux driver for P3762 & P3783 GMSL boards.
*/ */
@@ -13,25 +13,47 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/version.h> #include <linux/version.h>
#include "max96712.h"
#define DESER_A (0) #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 ENABLE_ALL_CC (0xAA)
#define DESER_ADDR (0x52) #define DESER_ADDR (0x52)
#define DESER_CC_REG (0x0003) #define DESER_CC_REG (0x0003)
extern int max96712_write_reg_Dser(int slaveAddr,int channel,
u16 addr, u8 val);
static int virtual_i2c_mux_select(struct i2c_mux_core *muxc, u32 chan) static int virtual_i2c_mux_select(struct i2c_mux_core *muxc, u32 chan)
{ {
int ret = 0; int ret = 0;
/* Do select 1st channel, to access IMUs from 1st Hawk */ /* Do select 1st channel, to access IMUs from 1st Hawk */
if (!chan) { switch (chan) {
ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_IMU); case 0:
ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_CC1);
if (ret) if (ret)
pr_err("%s: Failed to do i2c address trans for IMUs\n",__func__); 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; return ret;
} }
@@ -41,11 +63,10 @@ static int virtual_i2c_mux_deselect(struct i2c_mux_core *muxc, u32 chan)
int ret = 0; int ret = 0;
/* Enable all control channels */ /* Enable all control channels */
if (!chan) {
ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_ALL_CC); ret = max96712_write_reg_Dser(DESER_ADDR, DESER_A, DESER_CC_REG, ENABLE_ALL_CC);
if (ret) if (ret)
pr_err("%s: Failed to do i2c address trans for IMUs\n", __func__); pr_err("%s: Failed to do i2c address trans for IMUs\n", __func__);
}
return ret; return ret;
} }