Commit 0809a9ccac4a ("spi: remove {devm_}spi_alloc_master/slave()")
removed devm_spi_alloc_master() and this breaks building the Tegra124
and Tegra210 SPI drivers for Linux v6.13. Commit b8d3b056a78d ("spi:
introduce new helpers with using modern naming") previously added new
helpers in Linux v6.2 which should be instead. Add a test for conftest
to detect if the kernel supports the function devm_spi_alloc_host()
and if so use this function.
Bug 4991705
Change-Id: I1d639297ef7adfdcde50927360607639b45a4a60
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3261698
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Update the misc register programming for T264
for slave.
Bug 4711327
Change-Id: Ia6409bbee66e9984f83ad792d67c730fa637f58d
Signed-off-by: Vishwaroop A <va@nvidia.com>
For Linux v6.9 the compatibility layer that existed for transitioning
SPI drivers from using the legacy 'master' based naming to the
'controller' based naming for functions, structures and variables has
been removed. This is causing the various SPI driver build failures.
The compatibility layer was first introduced in Linux v4.13 by commit
8caab75fd2c2 ("spi: Generalize SPI "master" to "controller"") and given
that the newer "controller" based naming works for kernels from v4.13,
update the various SPI drivers to use the new naming for all current
supported kernels.
Bug 4471899
Change-Id: I5d9fcc429ab4262eb2827b61eb5aec729059f4b5
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3109504
Reviewed-by: Paritosh Dixit <paritoshd@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Reviewed-by: svc-sw-mobile-l4t <svc-sw-mobile-l4t@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
For Linux v6.8, commit ef175b29a242 ("of: Stop circularly including
of_device.h and of_platform.h") updated the OF headers included by these
header files. This breaks the build for various drivers and so fix this
by including the headers that are actually needed for each driver.
Bug 4448428
Change-Id: Ia40ab13f865d5631c96855ecc49145848f99c996
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3032442
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
For Linux v6.8, support for SPI controllers with multiple chip-selects
was added to the SPI core and this updated the 'chip_select' member of
the 'spi_device' structure to be an array. This breaks building the
Tegra124 SPI Slave driver and Tegra210 QUAD SPI driver.
A helper function, spi_get_chipselect(), was added for Linux v6.3 to
retrieve the chip-select for a SPI device and can be used for retrieving
the chip-select for all Linux v6.3+ kernels.
Add a conftest rule to detecting if spi_get_chipselect() is present and
if so use this for getting the chip-select. This fixes the build issues
for Linux v6.8.
Bug 4448428
Change-Id: Ia4f95ed96b9a18cc7da7a4a52305fc64bc31905c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3050146
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Use conftest to determine the return type of .remove() of
struct spi_driver is int or void type instead of kernel version.
The return type got changed with commit a0386bba7093
("spi: make remove callback a void function") in Linux 5.18
Bug 4387902
Change-Id: I644fe0610a76fbc4cea547c3295670599ae919bc
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3037038
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
The Tegra124 SPI slave driver declares a prototype for the function
tegra_spi_slave_register_callback() that does not exist. The correct
function name is tegra124_spi_slave_register_callback() and so fix the
prototype accordingly. Move the prototype to an actual header because
this is the correct place for defining prototypes for other drivers to
reference. This was caught by enabling the compiler flag
-Wmissing-prototype.
Bug 4404965
Change-Id: I765723d0a5ed6369784e5f6c480a6f03500659f3
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3027487
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
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 <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3013911
Reviewed-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
The new Tegra Prod APIs are to be used for NVIDIA Linux kernels v5.16+.
Building the MTTCAN and QUAD SPI driver currently fail for upstream
Linux v5.16 because the various version definitions are not correct.
Some definitions have greater than v5.16.0 instead of greater than OR
equal to v5.16.0. This means that the new APIs will only be used
starting with v5.16.1+ and not v5.16.0 as inteaded.
Other definitions have less than or equal to v5.16.0 instead of just
less than v5.16.0. This means that we will still use the legacy APIs for
v5.16.0.
Fix this by correcting the definition that the drivers can be built for
upstream Linux v5.16.
Bug 4097475
Change-Id: I7d8dd04911a7d6426c67e82396c8a6f1b372875d
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3006521
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Add new prod setting support which is the
property based on device tree. The prod
setting of each register field are new property
in DT and prod configurations are configured
via these new properties.
Bug 4097475
Change-Id: Iac61ddd20ceb5b1ea588519ab031275a926f5c41
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2996302
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Rather than using kernel version checks to determine which kernel APIs
to use, add the necessary tests to the conftest script to determine
which kernel APIs are present in the kernel.
This is beneficial for working with 3rd party Linux kernels that may
have back-ported upstream changes into their kernel and so the kernel
version checks do not work.
Bug 4221847
Change-Id: I159cd7d5feca050c8a8014d9c2a3b43e8974fdfd
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2993807
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Since Linux v6.3, legacy GPIO support has been dropped from the Linux
kernel and the gpiod_xxx functions have been supported for a long time
going back to Linux v3.x kernels. Therefore, drop support for the legacy
GPIO functions.
This is beneficial for working with 3rd party Linux kernels that may
have back-ported upstream changes into their kernel and so the kernel
version checks do not work.
Bug 4119327
Change-Id: Ib84e70b27645032108b2c25ce5d4ea3977f6cae1
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2993098
Reviewed-by: Vishwaroop A <va@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Add runtime auto suspend support and provide
a dt option to set this delay for each bus.
Perf drop is seen due to clock switching during
write operation. QSPI flash device write page size
is 256 KB so clock switching was being done for every
256KB due to pm_runtime_put(&pdev->dev) call.
pm_runtime_put() function is called, the Linux kernel
will begin to power down the device. This may involve
disabling clocks, powering down voltage regulators, and
releasing other resources etc.
pm_runtime_set_autosuspend_delay function sets the
autosuspend delay for a device. The autosuspend delay
is the amount of time that the device will remain active
after it has been idle before it is automatically suspended.
The pm_runtime_set_autosuspend_delay() function can be used to
reduce power consumption by automatically suspending devices
when they are not in use.
Bug 4229700
Change-Id: Ib49b02c78ad25957c80d22f5cc316afa55aa24dd
Signed-off-by: Vishwaroop A <va@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2985140
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
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>
Tegra spi slave driver for T124 and later chips.
Fix build error as
"'fpclk_name' may be used uninitialized".
Check and avoid divide by zero where clock rate
can be zero while selecting best clock.
SPI slave controller clock should be between 1.5 times to 4 times
of interface clock. Currently it is set to 4 times.
Change it to 3 times to avoid border cases where actual clock is not
same as what is requested.
Ex: master is set to .99MHz when 1MHz is requested and
slave is set to 4MHz as requested. Here above rule is violated.
SPI slave controller clock should be 1.5x of interface clock.
Change it to 2x to avoid border cases where actual clock set
is not same as what is requested.
Ex: master is set to 1MHz and slave is set to 1.48MHz instead
of 1.5MHz as requested. Here above rule is violated.
Set max buffer size to dma buffer size if dma init is
successful
Change based on below commits from linux-5.10
9de18723 spi: handle dma_slave_config error.
3a33b5fb spi: fix mem leak in spi slave driver
4b9b15ae drivers: Fix compile errors seen while merging 'v5.10-rc2'
Change based on below commits from linux-4.9
76a47a65 spi: tegra124-slave: tegra124 spi slave driver
2c341aa0 drivers: spi: fix -werror
b511c6f4 spi: tegra: Avoid divide by zero error
fdd18c3f spi: slave: Fix controller clock multiplier
829c57d6 spi: slave: Fix controller clock multiplier
85f8f7c2 spi: tegra: fix max buffer size
Bug 200021334
Bug 1899778
bug 1745660
Bug 200304626
Bug 200106113
Bug 200112595
bug 200054134
bug 1585361
Bug 200157229
bug 200116059
Bug 200063654
Bug 200045563
Bug 200084260
Bug 200141432
bug 200194538
bug 200129610
Bug 200319741
Coverity ID: 29578
Bug 200319815
Bug 200379969
Change-Id: Ibfadb40469f30b21350ed0fb7ee5daf96047197d
Signed-off-by: Vishwaroop A <va@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2888151
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Add check to switch to non combined sequence for
transfers if transfer length is greater than
DMA buffer size. Combined sequence cannot handle
split transfers so anything above dma_buf_size fails.
In case the transfers are beyond 64KB add a mechanism to
switch to non combined sequence of transfers.
Bug 3754288
Change-Id: I4d4eda56dcefdd9e35c19cdaf770783b99650c2c
Signed-off-by: Vishwaroop A <va@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2886311
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
The Aurix SPI driver fails to build with Linux v5.18 because the return
type of the remove function is not correct. This was previously fixed
for the Linux v5.19 build, but the change in the upstream kernel
actually occurred in Linux v5.18.
Bug 3820317
Change-Id: I2588fe33af6877c1c5c61a2a1d9195248066bbd1
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2792537
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
The spi device remove callback is modified to return as
void type in K5.19. Modify the callback implementation
accordingly.
Bug 3733730
Change-Id: I4ac90af3a87c2f77e3626bff043a5fdb63b2d7c1
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2755816
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit
The function do_exit() is exiting from the thread so
it is more appropriate to use the function complete_and_exit().
This function is also chnaged to more appropriate name as
kthread_complete_and_exit() for the K5.17 and beyond.
Use appropriate function name based on the kernel version.
Bug 3604749
Change-Id: I3e72d99a414317b782da2170163519eb2f1cfff3
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2730029
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Add SPI Aurix protocol driver which communicates to the Aurix based on
SPI communication.
Currently, the hv_pm_ctrl APIs are implemented as dummy till
virtual HV driver is available.
Bug 3583584
Change-Id: I5b786b566cbf77f5627d518f8c98cb1fdd55dfa8
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2708696
GVS: Gerrit_Virtual_Submit