Commit Graph

678 Commits

Author SHA1 Message Date
Sameer Pujar
576a3a348a ASoC: tegra: Simplify various API usage (Tegra210 and later)
Some of the upstream comments on intitial driver upstream phase were
generic and are equally applicable to remianing set of drivers. Thus
following changes are made based on this:

  - Remove explicit of_match_device() from drivers which don't have to
    maintain chip specific data.
  - Replace both platform_get_resource() and devm_ioremap_resource() with
    a single API devm_platform_ioremap_resource().
  - Use devm_snd_soc_register_component() and re-order pm_runtime_enable()
    in probe() function. The remove() path need not explicitly unregister
    the component.
  - Use 'err' variable instead of 'ret' for function returns and error
    checking.
  - Remove explicit runtime_suspend() call from remove() path.
  - Use consistent error print patterns across drivers
  - Some cosmetic changes

Bug 200698314

Change-Id: Id53420aab863062d7a5cf4aa5171b1af038ce83f
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:50:28 +05:30
Sameer Pujar
b32bd99824 ASoC: tegra: Trivial cleanup (Tegra210 and later)
This performs following trivial cleanup:
  - Remove explicit THIS_MODULE assignment in platform_driver struct.
  - Remove DRV_NAME macro and assign the name directly in platform_driver
    struct.
  - Add SPDX-License-Identifier to header files
  - Sort header file inclusions

Bug 200698314

Change-Id: Ic1e2166b6a8257cd3b462cc8b2a9719e25c7bbb8
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:50:28 +05:30
Sameer Pujar
12f7c17644 ASoC: tegra: Make AUD_MCLK an optional clock
Currently AUD_MCLK is controlled by kernel driver and it remains active
as long as an audio use case is running. This is the case most platforms
or audio codecs require. But some external codecs, depending on specific
platform, may want AUD_MCLK clock to be running always and do not require
a runtime control. Since kernel is common, we need a provision in DT to
differentiate both of the above requirements.

This can be achieved by making AUD_MCLK clock an optional property.
Platforms which don't require kernel control can simply exclude AUD_MCLK
clock entry. Respective call in kernel will not have any effect.

Note: We are using upstream utils driver now and update the references
wherever applicable. The changes need not be considered for upstream
because there is plan to use audio-graph-card based driver for Tegra210
and later, which already treats AUD_MCLK clock as optional. Thus no
explicit AUD_MCLK management is necessary. Also it is recommended that
codec driver should take the control of AUD_MCLK. Hence current change
is needed till mentioned transition happens.

Bug 200694208

Change-Id: I87e496515e02db4ded6209a336f6cfbaec034fa1
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2474868
(manually cherry picked from commit 8b2965341c1611b5984ff412f1d5001673396476)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2518783
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:50:28 +05:30
Bitan Biswas
c69eaecfd0 sound: tegra: isomgr: fix external profile build
Fix l4t k5.10 external profile build errors in isomgr

bug 200705253

Change-Id: I59fed5a5dbd31d5167a4d995bbc41d21d9e55dea
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2503928
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:50:28 +05:30
Sameer Pujar
d4d56e2908 ASoC: tegra: Expose ack() callback for component
On later kernels 'snd_pcm_ops' structure is removed from the
'snd_soc_component_driver' and instead explicit callbacks were
provided in the component driver structure. In doing so ack()
callback was left out for PCM interface. This was probably
intentional because there are currently no users for this
callback in upstream.

But in downstream we have ADSP audio driver which relies on
this callback to communicate buffer positions with ADSP and
currently DMA transfer is not happening due to missing ack()
callback. Issue is fixed by exposing ack() callback from the
core.

Bug 200568556

Change-Id: I76e9fcf21e087bb2c470868a2bd1eb668345e382
Reported-by: Asha Talambedu <atalambedu@nvidia.com>
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2414392
Tested-by: Asha Talambedu <atalambedu@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:50:28 +05:30
Sameer Pujar
e834adbfba ASoC: tegra: Fix build warnings in ADMAIF driver
Following build warnings have popped up after 'is_isomgr_client' flag
is cleaned up from the ADMAIF driver.

  tegra210_admaif.c: In function ‘tegra_admaif_prepare’:
  tegra210_admaif.c:271:23: warning: unused variable ‘admaif'
    struct tegra_admaif *admaif = snd_soc_dai_get_drvdata(dai);
                       ^~~~~~
  tegra210_admaif.c: In function ‘tegra_admaif_shutdown’:
  tegra210_admaif.c:281:23: warning: unused variable ‘admaif’
    struct tegra_admaif *admaif = snd_soc_dai_get_drvdata(dai);
                       ^~~~~~
  tegra210_admaif.c: In function ‘tegra_admaif_remove’:
  tegra210_admaif.c:1141:23: warning: unused variable ‘admaif’
    struct tegra_admaif *admaif = dev_get_drvdata(&pdev->dev);
                       ^~~~~~

Fix these by removing unused variable ‘admaif' from above functions.

Jira TAS-1059

Change-Id: I323df87415727b3deae0e5ba2aa05ef735c047da
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2414632
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:50:28 +05:30
Mohan Kumar
30706b0cef ASoC: tegra: Add Interconnect support for ADMA
Add Interconnect API support for ADMA Memory bandwidth requirement
handling.

From Kernel 4.14 and beyond
- On T23X and newer platforms, the interconnects driver will be initialized
  and calls to BWMGR will be stubbed out.
- On T194 and earlier platforms, BWMGR driver will be initialized and calls
  to interconnect framework will be stubbed out.

Jira TAS-1059

Change-Id: I7a26f61517937ac3103222a43f08ee7c4e4ad484
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2408552
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:50:28 +05:30
Sameer Pujar
79d734adb3 ASoC: tegra: Rebase drivers with v5.9-rc4
Some of the audio drivers have been upstreamed recently as part of
following series, https://lkml.org/lkml/2020/7/21/1357.

In upstream, DPCM solution is proposed which is different from what
is currently used in downstream. Hence there are conflicts related
to audio routing. To resolve the differences use 'CONFIG_TEGRA_DPCM'
checks. Once the DPCM proposal gets accepted and all remaining
drivers are updated to work with DPCM, the config and legacy routing
can be dropped.

K5.9 removes snd_soc_component_read and uses prototype
of snd_soc_component_read32. Hence update the call in tegra210_ahub.c

Bug 200597174

Change-Id: I9e563e3d8a62f335ba8c22397c0750bf29810d3d
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:50:28 +05:30
Bitan Biswas
4701ef0763 Merge tag 'v5.9-rc4' into dev-main-5.9
Linux 5.9-rc4

Change-Id: If605aee594aacf04e2e27863abf7bfddf3127dd3
2022-09-29 15:50:28 +05:30
Sameer Pujar
9f4e9f0c9b ASoC: tegra: Fix card registration failure on Tegra210
Commit cd6917c3e602 ("ASoC: tegra: Add admaif routes relevant to adsp")
added missing routes required for ADSP. This causes card registration
failure on Tegra210 platforms and probe() fails with following errors.

 ASoC: no source widget found for ADMAIF11 FIFO Transmit
 ASoC: Failed to add route ADMAIF11 FIFO Transmit -> direct -> ADMAIF11 FIFO RX
 ASoC: no sink widget found for ADMAIF11 CIF Receive
 ASoC: Failed to add route ADMAIF11 CIF TX -> direct -> ADMAIF11 CIF Receive
 ASoC: no source widget found for ADMAIF11 CIF Transmit
 ASoC: Failed to add route ADMAIF11 CIF Transmit -> direct -> ADMAIF11 CIF RX
 ASoC: no sink widget found for ADMAIF11 FIFO Receive
 ASoC: Failed to add route ADMAIF11 FIFO TX -> direct -> ADMAIF11 FIFO Receive
 ...
 (Similarly errors are seen for ADMAIF12, ADMAIF13 ... ADMAIF20)

This happens because a common structure is used for routes between Tegra210 and
Tegra186. Fix this problem by using appropriate size for routes which takes into
account of maximum available ADMAIF channels for a given SoC. This is inline
with what we have for previous kernels.

Bug 200628802

Change-Id: I18305e99781a0f91dc7886d3e06f2acaa5b69d9b
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2407491
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:48:19 +05:30
Sameer Pujar
998afc8211 ASoC: tegra: Fix build error for MODS
MODS build has 'CONFIG_TEGRA_ISOMGR' enabled and it is resulting in
following build errors.

 ERROR: modpost: "tegra_isomgr_register"
     [sound/soc/tegra/snd-soc-tegra-utils.ko] undefined!
 ERROR: modpost: "tegra_set_latency_allowance"
     [sound/soc/tegra/snd-soc-tegra-utils.ko] undefined!
 ERROR: modpost: "tegra_isomgr_realize"
     [sound/soc/tegra/snd-soc-tegra-utils.ko] undefined!
 ERROR: modpost: "tegra_isomgr_reserve"
     [sound/soc/tegra/snd-soc-tegra-utils.ko] undefined!
 ERROR: modpost: "tegra_isomgr_unregister"
     [sound/soc/tegra/snd-soc-tegra-utils.ko] undefined!

This happens because TEGRA_ISOMGR is not functionally up on v5.9.
Actually it has dependency over 'CONFIG_NV_TEGRA_MC' and thus build
issue is fixed by adding an explicit check for it. On L4T this issue
is not seen because 'CONFIG_TEGRA_ISOMGR' is not enabled.

Bug 200622929

Change-Id: Iceebf0df6e33386a5df06c5263a4a46b5bcd5d42
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2404198
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Rajesh Gumasta <rgumasta@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Rajesh Gumasta <rgumasta@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:48:19 +05:30
Asha Talambedu
8692668188 ASoC: tegra: Add admaif routes relevant to adsp
dapm routes in admaif driver used in ADSP audio path is enabled
through this patch

Bug 200568556

Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Change-Id: I4a351a011172222f71d691706c5b2bc8031e25fe
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2403773
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:48:19 +05:30
Sameer Pujar
196ee992c4 Revert "ASoC: tegra: disable jack detect (WAR)"
This reverts commit 45e13cf2a7c4e3f0b6e4e88050b93a4481b08bfa.

The original commit was earlier done to unblock kernel 5.9 bringup.
Revert the same to enable jack functionality now.

Bug 200610798

Change-Id: I7838e92f64140b5e563188d6f52455443685b116
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2370730
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:46:21 +05:30
Takashi Iwai
d2d05a7f3c ASoC: tegra: tegra210_i2s: Fix compile warning with CONFIG_PM=n
Fix trivial compile warnings wrt unused functions by adding
__maybe_unused prefix:
  sound/soc/tegra/tegra210_i2s.c:167:12: warning: 'tegra210_i2s_runtime_suspend' defined but not used [-Wunused-function]
  sound/soc/tegra/tegra210_i2s.c:179:12: warning: 'tegra210_i2s_runtime_resume' defined but not used [-Wunused-function]

Fixes: c0bfa98349d1 ("ASoC: tegra: Add Tegra210 based I2S driver")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200803141850.23713-6-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:46:21 +05:30
Takashi Iwai
52135cf29e ASoC: tegra: tegra210_dmic: Fix compile warning with CONFIG_PM=n
Fix trivial compile warnings wrt unused functions by adding
__maybe_unused prefix:
  sound/soc/tegra/tegra210_dmic.c:43:12: warning: 'tegra210_dmic_runtime_suspend' defined but not used [-Wunused-function]
  sound/soc/tegra/tegra210_dmic.c:55:12: warning: 'tegra210_dmic_runtime_resume' defined but not used [-Wunused-function]

Fixes: 8c8ff982e9e2 ("ASoC: tegra: Add Tegra210 based DMIC driver")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200803141850.23713-5-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:46:21 +05:30
Takashi Iwai
e70092016e ASoC: tegra: tegra210_ahub: Fix compile warning with CONFIG_PM=n
Fix trivial compile warnings wrt unused functions by adding
__maybe_unused prefix:
  sound/soc/tegra/tegra210_ahub.c:567:12: warning: 'tegra_ahub_runtime_suspend' defined but not used [-Wunused-function]
  sound/soc/tegra/tegra210_ahub.c:579:12: warning: 'tegra_ahub_runtime_resume' defined but not used [-Wunused-function]

Fixes: 16e1bcc2caf4 ("ASoC: tegra: Add Tegra210 based AHUB driver")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200803141850.23713-4-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:46:21 +05:30
Takashi Iwai
0c06d02af4 ASoC: tegra: tegra210_admaif: Fix compile warning with CONFIG_PM=n
Fix trivial compile warnings wrt unused functions by adding
__maybe_unused prefix:
  sound/soc/tegra/tegra210_admaif.c:232:12: warning: 'tegra_admaif_runtime_resume' defined but not used [-Wunused-function]
  sound/soc/tegra/tegra210_ahub.c:567:12: warning: 'tegra_ahub_runtime_suspend' defined but not used [-Wunused-function]

Fixes: f74028e159bb ("ASoC: tegra: Add Tegra210 based ADMAIF driver")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200803141850.23713-3-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:46:21 +05:30
Takashi Iwai
1e04318390 ASoC: tegra: tegra186_dspk: Fix compile warning with CONFIG_PM=n
Fix trivial compile warnings wrt unused functions by adding
__maybe_unused prefix:
  sound/soc/tegra/tegra186_dspk.c:74:12: warning: 'tegra186_dspk_runtime_suspend' defined but not used [-Wunused-function]
  sound/soc/tegra/tegra186_dspk.c:86:12: warning: 'tegra186_dspk_runtime_resume' defined but not used [-Wunused-function]

Fixes: 327ef6470266 ("ASoC: tegra: Add Tegra186 based DSPK driver")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200803141850.23713-2-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:46:21 +05:30
Sameer Pujar
8a0b5bc4f8 ASoC: tegra: Fix build error due to 64-by-32 division
Build errors are seen on 32-bit platforms because of a plain 64-by-32
division. For example, following build erros were reported.

"ERROR: modpost: "__udivdi3" [sound/soc/tegra/snd-soc-tegra210-dmic.ko]
 undefined!"
"ERROR: modpost: "__divdi3" [sound/soc/tegra/snd-soc-tegra210-dmic.ko]
 undefined!"

This can be fixed by using div_u64() helper from 'math64.h' header.

Fixes: 8c8ff982e9e2 ("ASoC: tegra: Add Tegra210 based DMIC driver")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595492011-2411-1-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:46:21 +05:30
Sameer Pujar
2b34b94604 ASoC: tegra: Add Tegra210 based ADMAIF driver
ADMAIF is the interface between ADMA and AHUB. Each ADMA channel that
sends/receives data to/from AHUB must intreface through an ADMAIF channel.
ADMA channel sending data to AHUB pairs with an ADMAIF Tx channel and
similarly ADMA channel receiving data from AHUB pairs with an ADMAIF Rx
channel. Buffer size is configurable for each ADMAIF channel, but currently
SW uses default values.

This patch registers ADMAIF driver with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes ADMAIF interfaces, which can be used to connect different
components in the ASoC layer. Makefile and Kconfig support is added to
allow to build the driver. The ADMAIF device can be enabled in the DT via
"nvidia,tegra210-admaif" compatible binding.

Tegra PCM driver is updated to expose required PCM interfaces and
snd_pcm_ops callbacks.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-8-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:46:21 +05:30
Sameer Pujar
34386d7e14 ASoC: tegra: Add Tegra186 based DSPK driver
The Digital Speaker Controller (DSPK) converts the multi-bit Pulse Code
Modulation (PCM) audio input to oversampled 1-bit Pulse Density Modulation
(PDM) output. From the signal flow perpsective, the DSPK can be viewed as
a PDM transmitter that up-samples the input to the desired sampling rate
by interpolation then converts the oversampled PCM input to the desired
1-bit output via Delta Sigma Modulation (DSM).

This patch registers DSPK component with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes DSPK interfaces, which can be used to connect different
components in the ASoC layer. Makefile and Kconfig support is added to
allow to build the driver. The DSPK devices can be enabled in the DT via
"nvidia,tegra186-dspk" compatible binding. This driver can be used
on Tegra194 chip as well.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-7-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:44:08 +05:30
Sameer Pujar
28e5d4400a ASoC: tegra: Add Tegra210 based AHUB driver
The Audio Hub (AHUB) comprises a collection of hardware accelerators for
audio pre/post-processing and a programmable full crossbar (XBAR) for
routing audio data across these accelerators in time and in parallel.
AHUB supports multiple interfaces to I2S, DSPK, DMIC etc., XBAR is a
switch used to configure or modify audio routing between HW accelerators
present inside AHUB.

This patch registers AHUB component with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes AHUB interfaces, which can be used to connect different
components in the ASoC layer. Currently the driver takes care of XBAR
programming to allow audio data flow through various clients of the AHUB.
Makefile and Kconfig support is added to allow to build the driver. The
AHUB component can be enabled in the DT via below compatible bindings.
  - "nvidia,tegra210-ahub" for Tegra210
  - "nvidia,tegra186-ahub" for Tegra186 and Tegra194

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-6-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:42:22 +05:30
Sameer Pujar
4c6034066a ASoC: tegra: Add Tegra210 based I2S driver
The Inter-IC Sound (I2S) controller implements full-duplex, bi-directional
and single direction point to point serial interface. It can interface
with I2S compatible devices. Tegra I2S controller can operate as both
master and slave.

This patch registers I2S controller with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes I2S interfaces, which can be used to connect different
components in the ASoC layer. Makefile and Kconfig support is added to
allow to build the driver. The I2S devices can be enabled in the DT via
"nvidia,tegra210-i2s" compatible binding.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-5-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:40:40 +05:30
Sameer Pujar
dfc3d8db24 ASoC: tegra: Add Tegra210 based DMIC driver
The Digital MIC (DMIC) Controller is used to interface with Pulse Density
Modulation (PDM) input devices. The DMIC controller implements a converter
to convert PDM signals to Pulse Code Modulation (PCM) signals. From signal
flow perspective, the DMIC can be viewed as a PDM receiver.

This patch registers DMIC component with ASoC framework. The component
driver exposes DAPM widgets, routes and kcontrols for the device. The DAI
driver exposes DMIC interfaces, which can be used to connect different
components in the ASoC layer. Makefile and Kconfig support is added to
allow to build the driver. The DMIC devices can be enabled in the DT via
"nvidia,tegra210-dmic" compatible string. This driver can be used for
Tegra186 and Tegra194 chips as well.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1595134890-16470-4-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 15:38:45 +05:30
Bitan Biswas
8e36d59756 k5.9: Fix linux-5.8-rc3 merge build
Resolve linux-5.8-rc3 merge conflicts in k5.9 branch
(currently tracking mainline with linux-5.7.0)
Fix build errors in k5.9 branch after merge of linux-5.8-rc3

bug 200617764

Change-Id: I3a358fef6e8b7c5926fd0de05a03cee539547e8f
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
2022-09-29 15:37:14 +05:30
Bitan Biswas
ffea8c683b Merge tag 'v5.8-rc3' into dev-main-5.9
Linux 5.8-rc3

Change-Id: Ie053381bcc551ded4bbbeed07bc33e284f921771
2022-09-29 15:37:14 +05:30
Sameer Pujar
41ff9ddcfe ASoC: tegra: remove 'tegra-alt' directory
As part of upstream alignment all audio drivers have been moved to
'tegra' path and are upgraded to work with 5.9 kernel. References
to older versions can be removed now. Earlier these were moved to
retain the commit history.

Summary on files that are being removed:
 * Legacy FPGA code is dropped
 * PCM driver changes already integrated
 * ASoC Utils changes already integrated
 * Makefile/Kconfig changes are aligned as per upstream plan

Bug 2845498

Change-Id: I645f94852d7137915ff4045be31e5a943a3fa6b3
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2364087
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
07de08349a ASoC: tegra: fix kernel warnings during suspend
Following kernel warning is seen during suspend entry.

[  100.031806] ------------[ cut here ]------------
[  100.031844] WARNING: CPU: 5 PID: 1829 at
.../kernel-5.9/kernel/workqueue.c:3036 __flush_work.isra.40+0x21c/0x238
...
[  100.031965] Hardware name: Jetson-AGX (DT)
[  100.031973] pstate: 60400009 (nZCv daif +PAN -UAO)
[  100.031986] pc : __flush_work.isra.40+0x21c/0x238
[  100.031997] lr : flush_delayed_work+0x48/0x58
[  100.032024] sp : ffff80001bf8faa0
[  100.032029] x29: ffff80001bf8faa0 x28: ffff800010d24230
[  100.032038] x27: ffff0003c11bf490 x26: 0000000000000000
[  100.032046] x25: ffff80001111c550 x24: ffff800011eb0000
[  100.032054] x23: ffff80000a470000 x22: ffff800011f67000
[  100.032061] x21: ffff800011cf5000 x20: ffff0003c98906b0
[  100.032069] x19: ffff800011f67a08 x18: ffffffffffffffff
[  100.032077] x17: 0000000000000018 x16: ffff800016240920
[  100.032084] x15: ffff800011d0e000 x14: 00000000000001e6
[  100.032115] x13: 00000000000001e6 x12: 0000000000000000
[  100.032124] x11: 0000000000000000 x10: 0000000000000a20
[  100.032132] x9 : ffff80001bf8fac0 x8 : ffff0003ffba6540
[  100.032140] x7 : 0000000000000400 x6 : ffff80000a520018
[  100.032148] x5 : ffff0003c9ece6b8 x4 : 0000000000000000
[  100.032156] x3 : 0000000000000000 x2 : 0000000000000000
[  100.032156] x3 : 0000000000000000 x2 : 0000000000000000
[  100.032168] x1 : ffff800011cf5948 x0 : 0000000000000000
[  100.032177] Call trace:
[  100.032192]  __flush_work.isra.40+0x21c/0x238
[  100.032202]  flush_delayed_work+0x48/0x58
[  100.032217]  snd_soc_suspend+0x148/0x2a8
[  100.032249]  dpm_prepare+0x110/0x2b0
[  100.032260]  dpm_suspend_start+0x20/0xa0
[  100.032296]  suspend_devices_and_enter+0x120/0x520
[  100.032304]  pm_suspend+0x250/0x2a0
[  100.032311]  state_store+0x8c/0x118
[  100.032320]  kobj_attr_store+0x18/0x30
[  100.032329]  sysfs_kf_write+0x40/0x58
[  100.032336]  kernfs_fop_write+0x148/0x240
[  100.032345]  __vfs_write+0x1c/0x40

It happens because of a warning check that is added in workqueue.c
which expects non-zero work function. Following are the references
to upstream commits.
 * https://lkml.org/lkml/2019/4/30/608
 * commit 4d43d395fed1 ("workqueue: Try to catch flush_work() without
                        INIT_WORK()")

Upstream commit exposes a bug in the machine driver where INIT_DELAYED_WORK()
is done with NULL work->func. This was originally added to resolve
a kernel crash during v3.10 time frame as part of following change.
 * commit 6d1c2577c068 ("ASoC: tegra-alt: Improvement of t210 drivers")

Above downstream commit is no more required on newer kernels and hence
issue is fixed by removing explicit INIT_DELAYED_WORK() from machine
driver. Core already takes care of this for 'rtd->delayed_work'.

Bug 200627501

Change-Id: I20ed108dd90a321323005e8c389f5c1116b937b6
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2362032
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Viswanath L
f79c4d54ef ASoC: tegra: remove channel hard coding in SFC
Hardcoding of CIF channels based on stereo/mono conversion settings is
removed and individual controls are provided for setting audio/client
channels. This is in line with the approach adopted for upstream.

Bug 200528522
Bug 2845498

Change-Id: If26b365d6f79f961ef3deeadbd61dbf0dd42f35e
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2263865
(manually cherry picked from commit 404f9fa1f37f5389fa8de685e6581db23b7dba10)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2361551
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Sameer Pujar <spujar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Asha Talambedu
24a60cd984 ASoC: tegra: Support for ReSpeaker 4-Mic
- Supports capture through Respeaker 4 Mic Array that
has ac108 codec when patched with appropriate codec driver.
- Codec driver that needs to be patched can be found here:
https://github.com/AshaTalambedu/seeed-voicecard/tree/jetson-respeaker-4mic-array-compatible
- Refer README-jetson from above github tree for more details
on patching the codec driver

Bug 200526593
Bug 2845498

Change-Id: Iaf2e6204d644ffab17ac4b9844440448fbf23d86
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2325124
(manually cherry picked from commit ac8b6d6fcd6b46bce27c694e46c93a1aa1fd151f)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2361550
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Sameer Pujar <spujar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
bcd452f7b1 ASoC: tegra: propagate slave_id info to DMA engine
ADMAIF default channel FIFO size is different depending on Tegra210 and
Tegra186 (and later). There is a guideline from HW that FIFO size of
ADMAIF channel should be same as the corrpsonding mapped DMA channel.
Commit 8c0d5ea47d21 ("dmaengine: tegra210-adma: override ADMA FIFO size")
updates FIFO size based on 'slave_id' info. Current patch passes the
'slave_id' information to DMA engine.

Following are the original commits from where the changes have been
manually cherry picked.
 - commit 34aa1f405069 ("ASoC: tegra-alt: T210 AHUB drivers")
 - commit 938afdfeea42 ("ASoC: tegra-alt: Alternative DAPM-based driver")

Also updated copyright info for Tegra PCM driver.

Bug 2845498

Change-Id: I6c748b94544bc22c21a43b731e43862592047c09
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2356716
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
fe40005d9b ASoC: tegra: cosmetic changes for Tegra210
Following changes are pushed as part of this commit:
 - Update copyright signature as per new format.
 - Remove references to "_ALT_" in header macros.
 - Fix copyright year for I2S, DMIC, DSPK, ADMAIF and XBAR drivers.
 - Fix file name in source header for Machine Utility driver.

Bug 2845498

Change-Id: I18b040a9d48a86a33f3ac6b6932d55e81d6414ac
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2354014
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
435468ef49 ASoC: tegra: add register dump feature for ADMAIF
This is based on the following original commit for 'tegra-alt' version.
Commit fd0548f8eb8f ("ASoC: tegra-alt: Dump APE register for debugging")

Following minor changes are done:
 - The device reference is available in component structure and the same
   is used to get 'tegra_admaif' structure in *_dump() function. Hence no
   need to separately save device reference.
 - The pm_runtime_get_*() call on child device will first resume parent
   device and hence it would be sufficient to have RPM calls on ADMAIF
   device alone.
 - Since device reference is available in *_dump() function now, pr_info()
   calls are replaced by dev_info().

Bug 2845498

Change-Id: Ib8d8ff7af543a79c34bfa476ddbace1826167a8e
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2354012
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Sameer Pujar
ee22e8b8ce ASoC: tegra: expose DAIs/routes for ADSP Audio
ADMAIF driver is currently rebased as per the patch sent for upstream
review and it does not include interfaces/routing required for ADSP
audio. Since ADSP audio is required in downstream, DAIs, DAPM widgets
and DAPM routes are added for ADSP audio to be part of APE sound card.

Bug 2845498
Bug 200593718

Change-Id: I900963cac25e7ac4fcc4be1e35d1c2f839e965cc
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2354011
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Sameer Pujar
8799f04efd ASoC: tegra: Audio is broken on v5.7-rc7
Commit 209e5c7b4144 ("drivers: fix k5.9 build errors") fixes few build
errors, associated with audio, which are required for initial kernel-5.9
setup. However there are functional issues on TOT, where APE sound card
registration fails. The root cause of this problem is because of below
listed changes in ASoC core:

 - 'snd_soc_ops' member is removed from 'component_driver' structure.
   The PCM callbacks now have to be directly populated in the component
   driver structure. ADMAIF and ADSP drivers are updated and Tegra PCM
   driver is cleaned up accordingly.

 - 'of_node' and 'dev_name' members are removed from 'snd_soc_codec_conf'
   structure now and instead wrapper for these is provided under 'dlc'.

 - Signature of 'snd_soc_get_pcm_runtime()' has changed now and it no
   more accepts DAI link name as argument. But since we require specific
   'rtd' based on DAI link names, the older version is duplicated in
   machine driver.

 - There are changes in trigger() order for start and stop now.

   *_trigger_start()
       |
       |--> rtd trigger()
       |--> component trigger()
       |--> dai trigger()

   *_trigger_stop()
       |
       |--> dai trigger()
       |--> component trigger()
       |--> rtd trigger()

   Above is resulting in following:
       |-> start ADMA
       |-> start ADMAIF
       |-> ...
       |-> stop ADMAIF
       |-> stop ADMA (unable to stop DMA channel print is seen here)

   Current order in downstream for previous kernel versions is:
       |-> start ADMA
       |-> start ADMAIF
       |-> ...
       |-> stop ADMA
       |-> stop ADMAIF

   This issue is addressed by invoking DMA trigger() call from ADMAIF dai
   trigger() itself to avoid the error during stop.

Bug 2845498

Change-Id: I1011555f51f5e0b0a448125a46b47df50e366d6f
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2353304
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Sameer Pujar
a99eabde9e ASoC: tegra: update ADSP audio driver for 5.4
This patch registers ADSP device as a component with ASoC core. Necessary
changes are made to work with 5.4 kernel and driver need not register a
separate platform and codec device.

Along with this following cleanup is done:
 - Move driver to 'tegra' directory.
 - Wherever possible, fix ACV issues in the driver. Not all of them can be
   fixed at the moment.

Bug 200593718

Change-Id: Ic60c7f59095bbe9f84d25077e4d4469544ca7783
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2342897
(cherry picked from commit d927c5daa951a58924e25d32b8002eb682e43aa0)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.9/+/2353303
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:35:11 +05:30
Bitan Biswas
539a7841f3 drivers: fix k5.9 build errors
Fix linux-5.7-rc5 build in below source files:
	- mmc.c __mmc_switch 7th argument removed for downstream patches.
	- pwm-fan.c - remove unmatched #if PM_SLEEP
	- i2c-tegra.c , arm-smmu-nvidia.c and tegra_machine_driver.c

Bug 200617764

Change-Id: I5a98693219e431f25a101a13f9fc2f6d29829e73
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
5cbf657e1a ASoC: tegra: move ISOBW_MGR source to tegra
For 5.4 kernel AHUB drivers are put under kernel specific folder and plan
is to discontinue 'tegra-alt' directory. This patch moves ISOBW_MGR code
to 'tegra' and updates ADMAIF driver for BW requests.

Bug 2845498

Change-Id: Ib36b00482319f8d266e85b0a80a44b489db3e291
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2328028
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:35:11 +05:30
Sowjanya Komatineni
63a2f16499 ASoC: tegra: Enable audio mclk during tegra_asoc_utils_init()
Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30
through Tegra210 and currently Tegra clock driver keeps the audio mclk
enabled.

With the move of PMC clocks from clock driver into pmc driver, audio
mclk enable from clock driver is removed and this should be taken care
of by the audio driver.

tegra_asoc_utils_init() calls tegra_asoc_utils_set_rate() and audio mclk
rate configuration is not needed during init and the rate is actually
set during the ->hw_params() callback.

So, this patch removes tegra_asoc_utils_set_rate() call and just leaves
the audio mclk enabled.

Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-09-29 15:35:11 +05:30
Sowjanya Komatineni
ae713bc1c7 ASoC: tegra: Add audio mclk parent configuration
Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30
through Tegra210 and currently Tegra clock driver does the initial
parent configuration for audio mclk and keeps it enabled by default.

With the move of PMC clocks from clock driver into PMC driver, audio
clocks parent configuration can be specified through the device tree
using assigned-clock-parents property and audio mclk control should be
taken care of by the audio driver.

This patch has implementation for parent configuration when default
parent configuration through assigned-clock-parents property is not
specified in the device tree.

Tested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-09-29 15:35:11 +05:30
Sowjanya Komatineni
5e8303330e ASoC: tegra: Use device managed resource APIs to get the clock
tegra_asoc_utils uses clk_get() to get the clock and clk_put() to free
them explicitly.

This patch updates it to use device managed resource API devm_clk_get()
so the clock will be automatically released and freed when the device is
unbound and removes tegra_asoc_utils_fini() as its no longer needed.

Tested-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-09-29 15:35:11 +05:30
Sameer Pujar
d7c5b86e51 ASoC: tegra: use sample size of 32 for S24_LE
I2S bit clock is derived from PLLA_OUT0 and sample size of 24 bits
results in fractional value. Clock is not accurate because of this
and noisy playback is observed. To avoid this sample size of 32 bits
can be used to derive I2S bit clock. This means there are additional
bit clocks (8 cycles) per channel which are ignored. Codec picks up
data for the other channel when LRCK toggles. The same is true for
capture as well.

For I2S Tegra-Slave mode this problem is not seen because the clock
signals are driven from the codec and above fix is not necessary for
it.

Bug 200594265
Bug 2845498

Change-Id: Ifa17e65a814fab060ab4762d19edfe34420524ce
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2303591
(cherry picked from commit 1bc9e1904454b359361da6682517952fd0108b46)
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2312716
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
0978d6b988 Revert "ASoC: tegra-alt: remove S24_LE format"
This reverts commit 9ac3457ed88631ef035fe9aa6baa4ce0cf2d5d5d

There are some conficts mainly because the revert is being done
on 5.4 kernel drivers and these are resolved manually.

Tegra can support S24_LE and the way it works is as follows.
 * S24_LE is a 32-bit container with 24-bit data in LSBs and the
   DMA is configured for 32-bit.
 * When ADMAIF client channel is configured for 24-bits, it picks
   up 24-bit(starting from LSB) from the ADMAIF FIFO. Higher 8-bits
   are sign extended.

Earlier the confusion was primarily because of the way data gets
picked up from FIFO and the way data conversion happens at CIF.

Bug 200590182
Bug 2845498

Change-Id: Icd0d9fb8fdd0a08d39cb45d23b3f441eaba5a98c
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2308468
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
aede424970 ASoC: tegra-alt: remove XBAR utils source file
As part of upstream alignment all drivers are moved to "tegra" path and
"utils/tegra210_xbar_utils_alt.c" is no more used now. Hence this patch
removes this source file. The helper functions are already moved to AHUB
driver. Currently there are other files related to ISO BW manager, ADSP
audio and FPGA in "tegra-alt" path. These will be cleaned up in subsequent
patches.

Bug 2845498

Change-Id: Iee52eb71bbc3c1996ea75777d3806ef76652848c
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.4/+/2307646
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
a7db2ff05e ASoC: tegra: disable jack detect (WAR)
There seems to be kernel panic happening when rt5659_set_jack_detect()
is called from the machine driver.

For now the jack detection is disabled to unblock 5.4 bringup and
can be separately tracked. A FIXME item is put. Once the issue is
resolved this patch can be reverted.

Bug 2845498

Change-Id: Ieb67e783a1dbcfb9ebbeb2bf301a818c94e38457
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
517398df1a ASoC: tegra: fix crash in machine driver.
DAI link structure has changed in 5.4 and memory needs to be allocated
for DAI link cpu/codec/platform components. The same is done with the
current patch to avoid the crash.

Bug 2845498

Change-Id: I2d69517120b6debbd0bb8d6a51ab9c5f6d47a401
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
267f390083 ASoC: tegra: enable Tegra machine driver
This patch enables Tegra machine driver used on Jetson platform.
Tegra210 and later Jetson platforms use the same machine driver.

Following is the summary from the patch:
 * Enable the driver build in defconfig
 * Remove "tegra-alt" ASoC utility file
 * Renmae "tegra-alt" parser source file "tegra_asoc_dt_parser.c"
   to "tegra_asoc_machine.c" and move it to "tegra" directory.
 * Similarly "tegra_asoc_machine_alt.h" is renamed to
   "tegra_asoc_machine.h" and moved to "tegra".
 * Updated "tegra" ASoC utility files for supporting Tegra210 and
   later.
 * Rename machine driver file.
 * The older parsing code is removed.

Bug 2845498

Change-Id: I42d9d2da59febb99ce00a29ce65d7a16f96b1327
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
ec0813dbd1 ASoC: tegra: move remaining AHUB devices to component
Following AHUB modules are considered as part of this series. This updates
all drivers to use component structure. Initially AHUB, I2S, DMIC, DSPK
and ADMAIF drivers were updated.

FPGA code is removed from the related drivers. This can be cherry-picked
if it is really required.

Bug 2845498

Change-Id: Ia3f60257c225d281d86ad83325fb517969259cb4
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
5fa4522d98 ASoC: tegra: expose DAIs of other AHUB modules
For upstream initially ADMAIF and I/O modules are considered. And the
these drivers are rebased in previous commit. This patch tracks the
addition of DAIs in AHUB driver which are needed for other AHUB modules.

Bug 2845498

Change-Id: I16e04a3bcf1118d66a57da2db07c3155ec9fe1a3
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
6b98f0a740 ASoC: tegra: update AHUB drivers as per upstream
AHUB and few components have been pushed for upstream review. Though the
changes are still under review, we can leverage the work done on upstream
5.x and use the same here on 5.4 kernel. This helps to align the downstream
code. Any changes that happen because of upstream review can be cherry
picked here. If we plan for any downstream changes, upstream patch needs to
be pushed to keep the code in sync.

As of today current snapshot is pulled from v3 of AHUB series,
http://patchwork.ozlabs.org/project/linux-tegra/list/?series=159664

Above series was worked on later versions of linux-next and hence following
are the changes required for porting back on 5.4
 * tegra_pcm_new() and tegra_pcm_free() are exposed from tegra_pcm.c and
   component driver callbacks use these.
 * Callback functions required for snd_pcm_ops in component driver are
   implemented by tegra_pcm.c
 * With this ADMAIF driver need not register platform device with ASoC
   core.

For components (AHUB, ADMAIF, I2S, DMIC and DSPK) the downsream code
differs in few aspects from the code that was pushed for v3. Some of them
are listed below.
 * I2S driver in downstream implements startup()/shutdown() calls for DAI,
   which does some setup related to pinconfig and regulators. The same is
   true for DMIC and DSPK drivers as well.
 * Downstream ADMAIF drivers makes bandwidth requests in startup/shutdown()
   calls and has helper function for dumping registers. It also has
   additional DAI interfaces which are used for ADSP audio.
 * Downstream AHUB driver has DAI interfaces for connecting to all other
   modules.
These differences will be cherry-picked as and when it is necessary.

Bug 2845498

Change-Id: Id374967ecae26f6b7334a959fb23308d383c15f2
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30