nv-oot: spi: fix kernel compilation issues

fix compilation issue when building spi slave driver
with 6.3-rc1 upstream kernel.

Bug 4014315

Change-Id: I4f8d83a5fdbc8957333034a4b8894e8e34d29ecc
Signed-off-by: Vishwaroop A <va@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2900975
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Vishwaroop A
2023-05-09 13:59:40 +00:00
committed by mobile promotions
parent 1106619f9c
commit f7fd6ebb95

View File

@@ -23,6 +23,7 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/clk/tegra.h> #include <linux/clk/tegra.h>
#include <linux/version.h>
#define SPI_COMMAND1 0x000 #define SPI_COMMAND1 0x000
#define SPI_BIT_LENGTH(x) (((x) & 0x1f) << 0) #define SPI_BIT_LENGTH(x) (((x) & 0x1f) << 0)
@@ -255,7 +256,11 @@ struct tegra_spi_platform_data {
u8 def_chip_select; u8 def_chip_select;
int rx_trig_words; int rx_trig_words;
int ls_bit; int ls_bit;
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
int gpio_slave_ready; int gpio_slave_ready;
#else
struct gpio_desc *gpio_slave_ready;
#endif
bool slave_ready_active_high; bool slave_ready_active_high;
int max_dma_buffer_size; int max_dma_buffer_size;
const char *clk_pin; const char *clk_pin;
@@ -1877,7 +1882,9 @@ static struct tegra_spi_platform_data
struct tegra_spi_platform_data *pdata; struct tegra_spi_platform_data *pdata;
const __be32 *prop; const __be32 *prop;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
enum of_gpio_flags gpio_flags; enum of_gpio_flags gpio_flags;
#endif
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) if (!pdata)
@@ -1894,6 +1901,15 @@ static struct tegra_spi_platform_data
if (of_find_property(np, "nvidia,clock-always-on", NULL)) if (of_find_property(np, "nvidia,clock-always-on", NULL))
pdata->is_clkon_always = true; pdata->is_clkon_always = true;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
pdata->gpio_slave_ready =
devm_gpiod_get_optional(&pdev->dev, "nvidia,slave-ready-gpio", 0);
if (gpiod_is_active_low(pdata->gpio_slave_ready))
pdata->slave_ready_active_high = false;
else
pdata->slave_ready_active_high = true;
#else
pdata->gpio_slave_ready = pdata->gpio_slave_ready =
of_get_named_gpio_flags(np, "nvidia,slave-ready-gpio", 0, of_get_named_gpio_flags(np, "nvidia,slave-ready-gpio", 0,
&gpio_flags); &gpio_flags);
@@ -1902,7 +1918,7 @@ static struct tegra_spi_platform_data
pdata->slave_ready_active_high = false; pdata->slave_ready_active_high = false;
else else
pdata->slave_ready_active_high = true; pdata->slave_ready_active_high = true;
#endif
return pdata; return pdata;
} }