From 3e519762265b40a421cc5b89cabb7737afc7d983 Mon Sep 17 00:00:00 2001 From: Aniket Bahadarpurkar Date: Thu, 27 Jul 2023 08:21:18 +0000 Subject: [PATCH] tegra: cdi: Add delay while setting gpio On p3898 platform, VCC_CAM can't handle high inrush current when gpios are set in parallel. Hence, a SW WAR is required to add a delay of 5ms after a gpio is set. Bug 4125801 Change-Id: Ib235cb00b5ef42c7255be5d212dd9e190630d7bc Signed-off-by: Aniket Bahadarpurkar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2943541 (cherry picked from commit 6e44996aae022c9e46fb431b75d60c8499bcd874) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2953356 Reviewed-by: Dipesh Gandhi Reviewed-by: Frank Chen --- drivers/media/platform/tegra/cdi/cdi-mgr-priv.h | 1 + drivers/media/platform/tegra/cdi/cdi_mgr.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/tegra/cdi/cdi-mgr-priv.h b/drivers/media/platform/tegra/cdi/cdi-mgr-priv.h index 39b722ba..c5ef8e43 100644 --- a/drivers/media/platform/tegra/cdi/cdi-mgr-priv.h +++ b/drivers/media/platform/tegra/cdi/cdi-mgr-priv.h @@ -78,6 +78,7 @@ struct cdi_mgr_priv { u8 cim_ver; /* 1 - P3714 A01, 2 - P3714 A02/A03 */ u32 cim_frsync[3]; /* FRSYNC source selection for each muxer */ u8 pre_suspend_tca9539_regvals[CDI_MGR_TCA9539_REGISTER_COUNT]; + bool isP3898; }; int cdi_mgr_power_up(struct cdi_mgr_priv *cdi_mgr, unsigned long arg); diff --git a/drivers/media/platform/tegra/cdi/cdi_mgr.c b/drivers/media/platform/tegra/cdi/cdi_mgr.c index 95227d3c..290dd326 100644 --- a/drivers/media/platform/tegra/cdi/cdi_mgr.c +++ b/drivers/media/platform/tegra/cdi/cdi_mgr.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2015-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. - #include #include #include @@ -709,6 +708,11 @@ int cdi_mgr_power_up(struct cdi_mgr_priv *cdi_mgr, unsigned long arg) dev_dbg(cdi_mgr->pdev, " - %d, %d\n", pd->pwr_gpios[i], PW_ON(pd->pwr_flags[i])); gpio_set_value(pd->pwr_gpios[i], PW_ON(pd->pwr_flags[i])); + /* SW WAR for platform issue */ + /* Add 5ms delay between two gpio toggles */ + /* Bug 4125801*/ + if (cdi_mgr->isP3898) + mdelay(5); cdi_mgr->pwr_state |= BIT(i); } @@ -1739,6 +1743,8 @@ static int cdi_mgr_probe(struct platform_device *pdev) struct cam_gpio_config *pin = NULL; struct device_node *child = NULL; struct device_node *child_tca9539 = NULL; + struct device_node *root_node = NULL; + const char *model; dev_info(&pdev->dev, "%sing...\n", __func__); @@ -1778,6 +1784,15 @@ static int cdi_mgr_probe(struct platform_device *pdev) return -EFAULT; } + cdi_mgr->isP3898 = false; + root_node = of_root; + if (root_node) { + model = of_get_property(root_node, "model", NULL); + dev_info(&pdev->dev, "platform name: %s\n", model); + if (!strcmp(model, "p3898-0010")) + cdi_mgr->isP3898 = true; + } + if (of_property_read_bool(pdev->dev.of_node, "pwms")) { cdi_mgr->pwm = devm_pwm_get(&pdev->dev, NULL); if (!IS_ERR(cdi_mgr->pwm)) {