Commit Graph

13 Commits

Author SHA1 Message Date
Asha Talambedu
719434d072 AsoC: tegra-alt: Update i2s rate setting logic
Earlier hardcoded pll base rates were leading to fractional divider
values for i2s multichannel config while deriving i2s bclk.
Hence updated clock rates and logic  for >2 channel configs for t186ref
and higher boards such that the dynamic range between max plla and min plla
is < 35 MHz. Also, if desired bclk is above limit, the case will be
declared as not supported. Note that new facility will be used only in l4t
machine driver.

Bug 200702569

Change-Id: I83aba425f6dde30a1f29f85b16a1bbbebba14198
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2491744
(cherry picked from commit e0fe51d5e7ced073eb618e19836f88a023f70bdc)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2613507
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@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
d940c0e813 ASoC: tegra: Generic compatible names for driver
The tegra_machine_driver.c now is a generic machine driver which is used
with multiple Jetson platforms and audio cards. Hence get rid of strings
like 'mobile' or 'rt565x' which are misleading in terms of usage domain.

Bug 200717065
Bug 200739452

Change-Id: Ifc2a5bf238cc222ca23681a9764809f6afb2de87
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2545307
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@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:50:28 +05:30
Sameer Pujar
d0c00ff0a7 ASoC: tegra: Explicit driver name for sound card
This is inspired from following upstream commit:
https://lore.kernel.org/r/20210330180657.1867971-1-thierry.reding@gmail.com

For consistent audio configuration files between downstream and upstream
this change is required in downstream sound card driver as well.

Bug 200717065
Bug 200739452

Change-Id: Ibe37c0c892ab169eb9cf6fcf85015f22c4c7b658
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-5.10/+/2545304
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@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:50:28 +05:30
Sameer Pujar
ae9fe52e1e ASoC: tegra: External codec setup in Tegra audio graph card
Tegra platforms support multiple external codecs which in some cases
require initial setup or runtime setup. Since common machine driver is
used, it uses DAI link names passed from DT to apply specific settings.
Use the same logic for Tegra audio graph card driver as well. In doing
so separate out codec setup part and move the same to tegra_codec.c
source file. This is reference in current downstream machine driver
and future Tegra audio graph card driver.

Going ahead alternate solution need to be identified to avoid dependency
on DAI link names. Upstream generic audio graph driver does not support
such method and passing DAI link names from DT won't be entertained in
upstream.

Bug 200692799

Change-Id: I40d134e89405fd8bb2d9aebfe2bce82816b545bd
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:50:28 +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
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
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
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
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
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
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
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
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