spi: tegra124-slave: Fix support for Linux v6.3

Linux v6.3 updated the GPIO APIs to use GPIO descriptors instead of
indices. This broke the Tegra SPI slave driver and when compiling the
driver for Linux v6.3 various warnings are observed. Update the Tegra
SPI slave driver as necessary to fix support for Linux v6.3.

Bug 4014315
Bug 4190165

Change-Id: Idfa29f729351d2971a649ddbcf1c3e9bf658d160
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2938376
Reviewed-by: Vishwaroop A <va@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2023-07-14 12:40:34 +01:00
committed by mobile promotions
parent 9655b8c6b0
commit bc6f405401

View File

@@ -314,7 +314,11 @@ struct tegra_spi_data {
bool variable_length_transfer; bool variable_length_transfer;
/* Slave Ready Polarity (true: Active High, false: Active Low) */ /* Slave Ready Polarity (true: Active High, false: Active Low) */
#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;
struct completion rx_dma_complete; struct completion rx_dma_complete;
@@ -811,8 +815,13 @@ static inline void tegra_spi_slave_busy(struct tegra_spi_data *tspi)
deassert_val = 1; deassert_val = 1;
/* Deassert ready line to indicate Busy */ /* Deassert ready line to indicate Busy */
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
if (gpio_is_valid(tspi->gpio_slave_ready)) if (gpio_is_valid(tspi->gpio_slave_ready))
gpio_set_value(tspi->gpio_slave_ready, deassert_val); gpio_set_value(tspi->gpio_slave_ready, deassert_val);
#else
if (tspi->gpio_slave_ready)
gpiod_set_value(tspi->gpio_slave_ready, deassert_val);
#endif
} }
static inline void tegra_spi_slave_ready(struct tegra_spi_data *tspi) static inline void tegra_spi_slave_ready(struct tegra_spi_data *tspi)
@@ -825,8 +834,13 @@ static inline void tegra_spi_slave_ready(struct tegra_spi_data *tspi)
assert_val = 0; assert_val = 0;
/* Assert ready line to indicate Ready */ /* Assert ready line to indicate Ready */
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
if (gpio_is_valid(tspi->gpio_slave_ready)) if (gpio_is_valid(tspi->gpio_slave_ready))
gpio_set_value(tspi->gpio_slave_ready, assert_val); gpio_set_value(tspi->gpio_slave_ready, assert_val);
#else
if (tspi->gpio_slave_ready)
gpiod_set_value(tspi->gpio_slave_ready, assert_val);
#endif
} }
static inline int tegra_spi_ext_clk_enable(bool enable, static inline int tegra_spi_ext_clk_enable(bool enable,
@@ -2026,33 +2040,43 @@ static int tegra_spi_probe(struct platform_device *pdev)
tspi->chip_data = chip_data; tspi->chip_data = chip_data;
tspi->gpio_slave_ready = pdata->gpio_slave_ready; tspi->gpio_slave_ready = pdata->gpio_slave_ready;
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
if (gpio_is_valid(tspi->gpio_slave_ready)) if (gpio_is_valid(tspi->gpio_slave_ready))
if (gpio_cansleep(tspi->gpio_slave_ready)) { if (gpio_cansleep(tspi->gpio_slave_ready)) {
dev_err(&pdev->dev, "Slave Ready GPIO %d is unusable as it can sleep\n", #else
tspi->gpio_slave_ready); if (tspi->gpio_slave_ready)
if (gpiod_cansleep(tspi->gpio_slave_ready)) {
#endif
dev_err(&pdev->dev,
"Slave Ready GPIO is unusable as it can sleep\n");
ret = -EINVAL; ret = -EINVAL;
goto exit_free_master; goto exit_free_master;
} }
tspi->slave_ready_active_high = pdata->slave_ready_active_high; tspi->slave_ready_active_high = pdata->slave_ready_active_high;
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
if (gpio_is_valid(tspi->gpio_slave_ready)) { if (gpio_is_valid(tspi->gpio_slave_ready)) {
ret = devm_gpio_request(&pdev->dev, ret = devm_gpio_request(&pdev->dev,
tspi->gpio_slave_ready, "gpio-spi-slave-ready"); tspi->gpio_slave_ready, "gpio-spi-slave-ready");
if (!ret) { if (ret) {
if (tspi->slave_ready_active_high)
deassert_val = 0;
else
deassert_val = 1;
gpio_direction_output(tspi->gpio_slave_ready,
deassert_val);
} else {
dev_err(&pdev->dev, "Slave Ready GPIO %d is busy\n", dev_err(&pdev->dev, "Slave Ready GPIO %d is busy\n",
tspi->gpio_slave_ready); tspi->gpio_slave_ready);
goto exit_free_master; goto exit_free_master;
} }
} }
#endif
if (tspi->slave_ready_active_high)
deassert_val = 0;
else
deassert_val = 1;
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
gpio_direction_output(tspi->gpio_slave_ready, deassert_val);
#else
gpiod_direction_output(tspi->gpio_slave_ready, deassert_val);
#endif
spin_lock_init(&tspi->lock); spin_lock_init(&tspi->lock);