From 3713d89fdb8e77c1afeee10b3d49db018645be49 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Thu, 9 Nov 2023 14:27:21 +0000 Subject: [PATCH] prod: Add support for legacy and next-gen prod via config Instead of using the Linux kernel version, use the configs coming from core kernel to find out whether legacy or next-gen prod configuration method is used. This will help on porting changes on any kernel and configuring via core kernel configs. Bug 3389584 Change-Id: I19c242c573dd63c7dbecbf87d4ba807857dcf4fb Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3013911 (cherry picked from commit 1dd2ef3473fcbffc4ac9fc02267c7e0a3f50f134) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3087161 Reviewed-by: Jon Hunter Reviewed-by: Brad Griffis Tested-by: Jon Hunter GVS: buildbot_gerritrpt --- drivers/net/can/mttcan/hal/m_ttcan.c | 2 +- drivers/net/can/mttcan/include/m_ttcan.h | 2 +- drivers/net/can/mttcan/native/m_ttcan_linux.c | 4 ++-- drivers/spi/spi-tegra210-quad.c | 12 ++++++------ include/linux/tegra-oot-prod.h | 12 +++--------- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/net/can/mttcan/hal/m_ttcan.c b/drivers/net/can/mttcan/hal/m_ttcan.c index 1d3037a2..9114c27f 100644 --- a/drivers/net/can/mttcan/hal/m_ttcan.c +++ b/drivers/net/can/mttcan/hal/m_ttcan.c @@ -291,7 +291,7 @@ inline u32 ttcan_read_ecr(struct ttcan_controller *ttcan) return ttcan_read32(ttcan, ADR_MTTCAN_ECR); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(CONFIG_TEGRA_PROD_NEXT_GEN) static void tegra_mttcan_config_prod_settings(struct mttcan_priv *priv) { struct ttcan_controller *ttcan = priv->ttcan; diff --git a/drivers/net/can/mttcan/include/m_ttcan.h b/drivers/net/can/mttcan/include/m_ttcan.h index 9155f8ee..6f55f49f 100644 --- a/drivers/net/can/mttcan/include/m_ttcan.h +++ b/drivers/net/can/mttcan/include/m_ttcan.h @@ -287,7 +287,7 @@ struct ttcan_controller { struct list_head rx_q1; struct list_head rx_b; struct list_head tx_evt; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(CONFIG_TEGRA_PROD_NEXT_GEN) struct tegra_prod *prod_list; #else struct tegra_prod_cfg_list *prod_list; diff --git a/drivers/net/can/mttcan/native/m_ttcan_linux.c b/drivers/net/can/mttcan/native/m_ttcan_linux.c index 4fa87d49..ec7d9dd0 100644 --- a/drivers/net/can/mttcan/native/m_ttcan_linux.c +++ b/drivers/net/can/mttcan/native/m_ttcan_linux.c @@ -10,7 +10,7 @@ #define CAN_MSG_FLUSH_TIMEOUT 100 static void mttcan_start(struct net_device *dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) +#if defined(CONFIG_TEGRA_PROD_NEXT_GEN) #define MTTCAN_PROD_FIELD(name, rindex, roffset, fname) \ { \ .field_name = name, \ @@ -1877,7 +1877,7 @@ static int mttcan_probe(struct platform_device *pdev) if (ret) goto exit_free_device; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(CONFIG_TEGRA_PROD_NEXT_GEN) priv->ttcan->prod_list = devm_tegra_prod_get(&pdev->dev); #else priv->ttcan->prod_list = devm_tegra_prod_get_list(&pdev->dev, &mttcan_prod_dev_info); diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index 7383bd18..1cb6a0af 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -255,14 +255,14 @@ struct tegra_qspi { dma_addr_t tx_dma_phys; struct dma_async_tx_descriptor *tx_dma_desc; const struct tegra_qspi_soc_data *soc_data; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) +#if defined(CONFIG_TEGRA_PROD_NEXT_GEN) struct tegra_prod_cfg_list *prod_list; #else struct tegra_prod *prod_list; #endif }; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) +#if defined(CONFIG_TEGRA_PROD_NEXT_GEN) #define QSPI_PROD_FIELD(name, rindex, roffset, fname) \ { \ .field_name = name, \ @@ -967,7 +967,7 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tran return command1; } -#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 16, 0) +#if defined(CONFIG_TEGRA_PROD_NEXT_GEN) static void tegra_qspi_write_prod_settings(struct tegra_qspi *tqspi, const char *prod_name) { struct tegra_prod_reg_info *reg_info; @@ -991,7 +991,7 @@ static void tegra_qspi_write_prod_settings(struct tegra_qspi *tqspi, const char static void tegra_qspi_set_gr_registers(struct tegra_qspi *tqspi) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(CONFIG_TEGRA_PROD_NEXT_GEN) int err; #endif @@ -1001,7 +1001,7 @@ static void tegra_qspi_set_gr_registers(struct tegra_qspi *tqspi) /* If available, initialise the config registers * for QSPI with the values mentioned in prod list. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(CONFIG_TEGRA_PROD_NEXT_GEN) err = tegra_prod_set_by_name(&tqspi->base, "prod", tqspi->prod_list); if (err < 0) dev_info_once(tqspi->dev, @@ -1741,7 +1741,7 @@ static int tegra_qspi_probe(struct platform_device *pdev) tqspi->controller = controller; tqspi->dev = &pdev->dev; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(CONFIG_TEGRA_PROD_NEXT_GEN) tqspi->prod_list = devm_tegra_prod_get(&pdev->dev); #else tqspi->prod_list = devm_tegra_prod_get_list(&pdev->dev, &qspi_prod_dev_info); diff --git a/include/linux/tegra-oot-prod.h b/include/linux/tegra-oot-prod.h index 19b7ec17..74c59553 100644 --- a/include/linux/tegra-oot-prod.h +++ b/include/linux/tegra-oot-prod.h @@ -8,19 +8,13 @@ #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) -#ifdef CONFIG_TEGRA_PROD_LEGACY +#if defined(CONFIG_TEGRA_PROD_NEXT_GEN) #include -#include -#else -#include #include -#endif -#else /* LINUX_VERSION_CODE */ -#ifdef CONFIG_TEGRA_PROD_LEGACY +#elif defined(CONFIG_TEGRA_PROD_LEGACY) #include #else #include #endif -#endif /* LINUX_VERSION_CODE */ + #endif /* _TEGRA_OOT_PRODS_H */