2023-01-13 13:29:32

by Padmanabhan Rajanbabu

[permalink] [raw]
Subject: [PATCH v3 0/5] ASoC: samsung: fsd: audio support for FSD SoC

This patch series enables audio support on FSD SoC.

Changes in v3:
1. Addressed all the review comments provided for v2 patch.
2. Fixed compilation warnings reported by kernel test robot.

Changes in v2:
1. New compatible added in Exynos I2S driver for FSD platform.
2. Added Fixup support for Exynos I2S CPU DAI.
3. Migration of manual PSR, OPCLK configuration to Exynos CPU DAI driver as
fixup.
4. Migrated from dedicated sound card to simple audio card.
5. Support added for tlv320aic3x-i2c codec on FSD platform.

Changes in v1:
1. Add TDM support on samsung I2S interface.
2. Allow sound card to directly configure I2S prescaler divider instead of
calculating it from frame clock.
3. The sound card support for FSD SoC which utilizes samsung I2S interface
as CPU DAI.

Padmanabhan Rajanbabu (5):
ASoC: dt-bindings: Add FSD I2S controller bindings
ASoC: samsung: i2s: add support for FSD I2S
arm64: dts: fsd: Add I2S DAI node for Tesla FSD
arm64: dts: fsd: Add codec node for Tesla FSD
arm64: dts: fsd: Add sound card node for Tesla FSD

.../bindings/sound/samsung-i2s.yaml | 8 +++
arch/arm64/boot/dts/tesla/fsd-evb.dts | 53 +++++++++++++++++++
arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi | 14 +++++
arch/arm64/boot/dts/tesla/fsd.dtsi | 34 ++++++++++++
sound/soc/samsung/i2s-regs.h | 1 +
sound/soc/samsung/i2s.c | 53 +++++++++++++++++++
6 files changed, 163 insertions(+)

--
2.17.1


2023-01-13 13:36:44

by Padmanabhan Rajanbabu

[permalink] [raw]
Subject: [PATCH v3 5/5] arm64: dts: fsd: Add sound card node for Tesla FSD

Add device tree node support for sound card on Tesla FSD platform

Signed-off-by: Padmanabhan Rajanbabu <[email protected]>
---
arch/arm64/boot/dts/tesla/fsd-evb.dts | 33 +++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

diff --git a/arch/arm64/boot/dts/tesla/fsd-evb.dts b/arch/arm64/boot/dts/tesla/fsd-evb.dts
index 2f211a1ad50d..83281e305f20 100644
--- a/arch/arm64/boot/dts/tesla/fsd-evb.dts
+++ b/arch/arm64/boot/dts/tesla/fsd-evb.dts
@@ -29,6 +29,39 @@
device_type = "memory";
reg = <0x0 0x80000000 0x2 0x00000000>;
};
+
+ sound {
+ compatible = "simple-audio-card";
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ simple-audio-card,name = "FSD Audio Card";
+ simple-audio-card,widgets = "Line", "Line Out",
+ "Line", "Line In";
+ simple-audio-card,routing = "Line Out", "LLOUT",
+ "Line Out", "RLOUT",
+ "MIC2L", "Line In",
+ "MIC2R", "Line In";
+
+ simple-audio-card,dai-link@0 {
+ reg = <0>;
+ format = "i2s";
+ bitclock-master = <&tlv320aic3x>;
+ frame-master = <&tlv320aic3x>;
+
+ cpu-0 {
+ sound-dai = <&i2s_0 0>;
+ };
+ cpu-1 {
+ sound-dai = <&i2s_0 1>;
+ };
+ codec {
+ sound-dai = <&tlv320aic3x>;
+ system-clock-frequency = <33000000>;
+ };
+ };
+ };
};

&fin_pll {
--
2.17.1

2023-01-13 13:53:31

by Padmanabhan Rajanbabu

[permalink] [raw]
Subject: [PATCH v3 3/5] arm64: dts: fsd: Add I2S DAI node for Tesla FSD

Add device tree node for I2S0 and I2S1 CPU DAI instances for Tesla
FSD platform.

FSD SoC has 2 I2S instances driving stereo channel I2S audio playback
and capture with external DMA support.

Signed-off-by: Padmanabhan Rajanbabu <[email protected]>
---
arch/arm64/boot/dts/tesla/fsd-evb.dts | 8 +++++
arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi | 14 +++++++++
arch/arm64/boot/dts/tesla/fsd.dtsi | 34 ++++++++++++++++++++++
3 files changed, 56 insertions(+)

diff --git a/arch/arm64/boot/dts/tesla/fsd-evb.dts b/arch/arm64/boot/dts/tesla/fsd-evb.dts
index 1db6ddf03f01..cf5f2ce4d2a7 100644
--- a/arch/arm64/boot/dts/tesla/fsd-evb.dts
+++ b/arch/arm64/boot/dts/tesla/fsd-evb.dts
@@ -38,6 +38,14 @@
status = "okay";
};

+&i2s_0 {
+ status = "okay";
+};
+
+&i2s_1 {
+ status = "okay";
+};
+
&ufs {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi b/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi
index e3852c946352..6b51e31afcff 100644
--- a/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi
@@ -339,6 +339,20 @@
samsung,pin-pud = <FSD_PIN_PULL_UP>;
samsung,pin-drv = <FSD_PIN_DRV_LV4>;
};
+
+ i2s0_bus: i2s0-bus-pins {
+ samsung,pins = "gpd1-0", "gpd1-1", "gpd1-2", "gpd1-3", "gpd1-4";
+ samsung,pin-function = <FSD_PIN_FUNC_2>;
+ samsung,pin-pud = <FSD_PIN_PULL_DOWN>;
+ samsung,pin-drv = <FSD_PIN_DRV_LV4>;
+ };
+
+ i2s1_bus: i2s1-bus-pins {
+ samsung,pins = "gpd2-0", "gpd2-1", "gpd2-2", "gpd2-3", "gpd2-4";
+ samsung,pin-function = <FSD_PIN_FUNC_2>;
+ samsung,pin-pud = <FSD_PIN_PULL_DOWN>;
+ samsung,pin-drv = <FSD_PIN_DRV_LV4>;
+ };
};

&pinctrl_pmu {
diff --git a/arch/arm64/boot/dts/tesla/fsd.dtsi b/arch/arm64/boot/dts/tesla/fsd.dtsi
index f35bc5a288c2..3e7265a41e37 100644
--- a/arch/arm64/boot/dts/tesla/fsd.dtsi
+++ b/arch/arm64/boot/dts/tesla/fsd.dtsi
@@ -738,6 +738,40 @@
status = "disabled";
};

+ i2s_0: i2s@140e0000 {
+ compatible = "tesla,fsd-i2s";
+ reg = <0x0 0x140e0000 0x0 0x100>;
+ interrupts = <GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH>;
+ dmas = <&pdma1 14>, <&pdma1 13>, <&pdma1 12>;
+ dma-names = "tx", "rx", "tx-sec";
+ #clock-cells = <1>;
+ clocks = <&clock_peric PERIC_PCLK_TDM0>,
+ <&clock_peric PERIC_HCLK_TDM0>,
+ <&clock_peric PERIC_HCLK_TDM0>;
+ clock-names = "iis", "i2s_opclk0", "i2s_opclk1";
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2s0_bus>;
+ #sound-dai-cells = <1>;
+ status = "disabled";
+ };
+
+ i2s_1: i2s@140f0000 {
+ compatible = "tesla,fsd-i2s";
+ reg = <0x0 0x140f0000 0x0 0x100>;
+ interrupts = <GIC_SPI 207 IRQ_TYPE_LEVEL_HIGH>;
+ dmas = <&pdma1 17>, <&pdma1 16>, <&pdma1 15>;
+ dma-names = "tx", "rx", "tx-sec";
+ #clock-cells = <1>;
+ clocks = <&clock_peric PERIC_PCLK_TDM1>,
+ <&clock_peric PERIC_HCLK_TDM1>,
+ <&clock_peric PERIC_HCLK_TDM1>;
+ clock-names = "iis", "i2s_opclk0", "i2s_opclk1";
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2s1_bus>;
+ #sound-dai-cells = <1>;
+ status = "disabled";
+ };
+
pinctrl_pmu: pinctrl@114f0000 {
compatible = "tesla,fsd-pinctrl";
reg = <0x0 0x114f0000 0x0 0x1000>;
--
2.17.1

2023-01-13 13:55:01

by Padmanabhan Rajanbabu

[permalink] [raw]
Subject: [PATCH v3 2/5] ASoC: samsung: i2s: add support for FSD I2S

Add support for enabling I2S controller on FSD platform.

FSD I2S controller is based on Exynos7 I2S controller, supporting
2CH playback/capture in I2S mode and 7.1CH playback/capture in TDM
mode.

Reported-by: kernel test robot <[email protected]>
Signed-off-by: Padmanabhan Rajanbabu <[email protected]>
---
sound/soc/samsung/i2s-regs.h | 1 +
sound/soc/samsung/i2s.c | 53 ++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)

diff --git a/sound/soc/samsung/i2s-regs.h b/sound/soc/samsung/i2s-regs.h
index b4b5d6053503..138e95581979 100644
--- a/sound/soc/samsung/i2s-regs.h
+++ b/sound/soc/samsung/i2s-regs.h
@@ -132,6 +132,7 @@
#define EXYNOS7_MOD_RCLK_192FS 7

#define PSR_PSREN (1 << 15)
+#define PSR_PSVAL(x) ((((x) - 1) << 8) & 0x3f00)

#define FIC_TX2COUNT(x) (((x) >> 24) & 0xf)
#define FIC_TX1COUNT(x) (((x) >> 16) & 0xf)
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 9505200f3d11..6f96032090de 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -50,6 +50,10 @@ struct samsung_i2s_dai_data {
u32 quirks;
unsigned int pcm_rates;
const struct samsung_i2s_variant_regs *i2s_variant_regs;
+ void (*fixup_early)(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai);
+ void (*fixup_late)(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai);
};

struct i2s_dai {
@@ -111,6 +115,10 @@ struct samsung_i2s_priv {
u32 suspend_i2spsr;

const struct samsung_i2s_variant_regs *variant_regs;
+ void (*fixup_early)(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai);
+ void (*fixup_late)(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai);
u32 quirks;

/* The clock provider's data */
@@ -940,6 +948,10 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
pm_runtime_get_sync(dai->dev);
+
+ if (priv->fixup_early)
+ priv->fixup_early(substream, dai);
+
spin_lock_irqsave(&priv->lock, flags);

if (config_setup(i2s)) {
@@ -947,6 +959,9 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
return -EINVAL;
}

+ if (priv->fixup_late)
+ priv->fixup_late(substream, dai);
+
if (capture)
i2s_rxctrl(i2s, 1);
else
@@ -1410,6 +1425,8 @@ static int samsung_i2s_probe(struct platform_device *pdev)

if (np) {
priv->quirks = i2s_dai_data->quirks;
+ priv->fixup_early = i2s_dai_data->fixup_early;
+ priv->fixup_late = i2s_dai_data->fixup_late;
} else {
if (!i2s_pdata) {
dev_err(&pdev->dev, "Missing platform data\n");
@@ -1563,6 +1580,31 @@ static int samsung_i2s_remove(struct platform_device *pdev)
return 0;
}

+static void fsd_i2s_fixup_early(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct i2s_dai *i2s = to_info(asoc_rtd_to_cpu(rtd, 0));
+ struct i2s_dai *other = get_other_dai(i2s);
+
+ if (!is_opened(other)) {
+ i2s_set_sysclk(dai, SAMSUNG_I2S_CDCLK, 0, SND_SOC_CLOCK_OUT);
+ i2s_set_sysclk(dai, SAMSUNG_I2S_OPCLK, 0, MOD_OPCLK_PCLK);
+ }
+}
+
+static void fsd_i2s_fixup_late(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
+ struct i2s_dai *i2s = to_info(asoc_rtd_to_cpu(rtd, 0));
+ struct i2s_dai *other = get_other_dai(i2s);
+
+ if (!is_opened(other))
+ writel(PSR_PSVAL(2) | PSR_PSREN, priv->addr + I2SPSR);
+}
+
static const struct samsung_i2s_variant_regs i2sv3_regs = {
.bfs_off = 1,
.rfs_off = 3,
@@ -1652,6 +1694,14 @@ static const struct samsung_i2s_dai_data i2sv5_dai_type_i2s1 __maybe_unused = {
.i2s_variant_regs = &i2sv5_i2s1_regs,
};

+static const struct samsung_i2s_dai_data fsd_dai_type __maybe_unused = {
+ .quirks = QUIRK_SEC_DAI | QUIRK_NEED_RSTCLR | QUIRK_SUPPORTS_TDM,
+ .pcm_rates = SNDRV_PCM_RATE_8000_192000,
+ .i2s_variant_regs = &i2sv7_regs,
+ .fixup_early = fsd_i2s_fixup_early,
+ .fixup_late = fsd_i2s_fixup_late,
+};
+
static const struct platform_device_id samsung_i2s_driver_ids[] = {
{
.name = "samsung-i2s",
@@ -1678,6 +1728,9 @@ static const struct of_device_id exynos_i2s_match[] = {
}, {
.compatible = "samsung,exynos7-i2s1",
.data = &i2sv5_dai_type_i2s1,
+ }, {
+ .compatible = "tesla,fsd-i2s",
+ .data = &fsd_dai_type,
},
{},
};
--
2.17.1

2023-01-15 15:33:24

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 2/5] ASoC: samsung: i2s: add support for FSD I2S

On 13/01/2023 13:17, Padmanabhan Rajanbabu wrote:
> Add support for enabling I2S controller on FSD platform.
>
> FSD I2S controller is based on Exynos7 I2S controller, supporting
> 2CH playback/capture in I2S mode and 7.1CH playback/capture in TDM
> mode.
>
> Reported-by: kernel test robot <[email protected]>

Drop. It's for the bugs. Just be sure that the code compiles without W=1
warnings.


> Signed-off-by: Padmanabhan Rajanbabu <[email protected]>
> ---
> sound/soc/samsung/i2s-regs.h | 1 +
> sound/soc/samsung/i2s.c | 53 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
Best regards,
Krzysztof

2023-01-15 15:35:14

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 3/5] arm64: dts: fsd: Add I2S DAI node for Tesla FSD

On 13/01/2023 13:17, Padmanabhan Rajanbabu wrote:
> Add device tree node for I2S0 and I2S1 CPU DAI instances for Tesla
> FSD platform.
>
> FSD SoC has 2 I2S instances driving stereo channel I2S audio playback
> and capture with external DMA support.
>
> Signed-off-by: Padmanabhan Rajanbabu <[email protected]>
> ---
> arch/arm64/boot/dts/tesla/fsd-evb.dts | 8 +++++
> arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi | 14 +++++++++
> arch/arm64/boot/dts/tesla/fsd.dtsi | 34 ++++++++++++++++++++++
> 3 files changed, 56 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/tesla/fsd-evb.dts b/arch/arm64/boot/dts/tesla/fsd-evb.dts
> index 1db6ddf03f01..cf5f2ce4d2a7 100644
> --- a/arch/arm64/boot/dts/tesla/fsd-evb.dts
> +++ b/arch/arm64/boot/dts/tesla/fsd-evb.dts
> @@ -38,6 +38,14 @@
> status = "okay";
> };
>
> +&i2s_0 {
> + status = "okay";
> +};
> +
> +&i2s_1 {
> + status = "okay";
> +};
> +

You need to rebase.

> &ufs {
> status = "okay";
> };

Best regards,
Krzysztof

2023-01-16 05:19:28

by Padmanabhan Rajanbabu

[permalink] [raw]
Subject: RE: [PATCH v3 3/5] arm64: dts: fsd: Add I2S DAI node for Tesla FSD



> -----Original Message-----
> From: Krzysztof Kozlowski [mailto:[email protected]]
> Sent: 15 January 2023 08:35 PM
> To: Padmanabhan Rajanbabu <[email protected]>;
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]
> Cc: [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Subject: Re: [PATCH v3 3/5] arm64: dts: fsd: Add I2S DAI node for Tesla FSD
>
> On 13/01/2023 13:17, Padmanabhan Rajanbabu wrote:
> > Add device tree node for I2S0 and I2S1 CPU DAI instances for Tesla FSD
> > platform.
> >
> > FSD SoC has 2 I2S instances driving stereo channel I2S audio playback
> > and capture with external DMA support.
> >
> > Signed-off-by: Padmanabhan Rajanbabu <[email protected]>
> > ---
> > arch/arm64/boot/dts/tesla/fsd-evb.dts | 8 +++++
> > arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi | 14 +++++++++
> > arch/arm64/boot/dts/tesla/fsd.dtsi | 34 ++++++++++++++++++++++
> > 3 files changed, 56 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/tesla/fsd-evb.dts
> > b/arch/arm64/boot/dts/tesla/fsd-evb.dts
> > index 1db6ddf03f01..cf5f2ce4d2a7 100644
> > --- a/arch/arm64/boot/dts/tesla/fsd-evb.dts
> > +++ b/arch/arm64/boot/dts/tesla/fsd-evb.dts
> > @@ -38,6 +38,14 @@
> > status = "okay";
> > };
> >
> > +&i2s_0 {
> > + status = "okay";
> > +};
> > +
> > +&i2s_1 {
> > + status = "okay";
> > +};
> > +
>
> You need to rebase.

This patch series has been rebased on top of for-next branch of
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

I'll rebase the DT patches on top of next/dt64 of
https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-dt.git and
driver changes on top of for-next of broonie/sound.git

>
> > &ufs {
> > status = "okay";
> > };
>
> Best regards,
> Krzysztof


2023-01-16 05:57:18

by Padmanabhan Rajanbabu

[permalink] [raw]
Subject: RE: [PATCH v3 2/5] ASoC: samsung: i2s: add support for FSD I2S



> -----Original Message-----
> From: Krzysztof Kozlowski [mailto:[email protected]]
> Sent: 15 January 2023 08:33 PM
> To: Padmanabhan Rajanbabu <[email protected]>;
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]
> Cc: [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Subject: Re: [PATCH v3 2/5] ASoC: samsung: i2s: add support for FSD I2S
>
> On 13/01/2023 13:17, Padmanabhan Rajanbabu wrote:
> > Add support for enabling I2S controller on FSD platform.
> >
> > FSD I2S controller is based on Exynos7 I2S controller, supporting 2CH
> > playback/capture in I2S mode and 7.1CH playback/capture in TDM mode.
> >
> > Reported-by: kernel test robot <[email protected]>
>
> Drop. It's for the bugs. Just be sure that the code compiles without W=1
> warnings.

Okay, got it. I'll drop it in the upcoming patchset.

>
>
> > Signed-off-by: Padmanabhan Rajanbabu <[email protected]>
> > ---
> > sound/soc/samsung/i2s-regs.h | 1 +
> > sound/soc/samsung/i2s.c | 53
> ++++++++++++++++++++++++++++++++++++
> > 2 files changed, 54 insertions(+)
> Best regards,
> Krzysztof