From patchwork Tue Feb 6 12:55:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13547224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77FD5C48297 for ; Tue, 6 Feb 2024 12:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=JWd2pekKp/utoScTbj3xgIzOOgccVLAJdeCa80dp7zQ=; b=K9PjViU1texs/b E1X0W0n+twyzbgEG2GaRYHVZL2gNhrBpdHIBbX5WYn1IAzzWf4uGcow8A0mdsMZx+WI+TtPc4Jf7I gNOFfUuy5IKmfUW/RR2gZ87TyERDN4I8VwgfFWi66WnbqeHALxM6ZX6/7A2zMN8/o6zURhFjN/cDV MTLdQbweGH97YOLQEU6Hym+YnuJJ9eUIm5HM5nD3KOA9TaCVPwgT18jzsK3IsJwf+dU/5ZLKhWl4n R72df9t50XZ0V9VXNNsy2OGV2fFWCy0PQfrGLkbV/8FNEuWDQ224LKuY6Y24ruMohOKGsU0xJ8tPU 5pmxprxcV31AKisDFmSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXKzU-00000007d68-45pO; Tue, 06 Feb 2024 12:55:56 +0000 Received: from phobos.denx.de ([2a01:238:438b:c500:173d:9f52:ddab:ee01]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXKzS-00000007d59-2J1X for linux-arm-kernel@lists.infradead.org; Tue, 06 Feb 2024 12:55:56 +0000 Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id CC46587C1F; Tue, 6 Feb 2024 13:55:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1707224150; bh=GataKuj1P7hIgOKqSLO+5+6HLYpAAd7gxFJBAHs20pQ=; h=From:To:Cc:Subject:Date:From; b=yYXXgJ+N8houLKHWvRmcx2aMruGUKIwuGf6KYS1O574k2tM4/p1oFHz7K7gHOjgPE W1nwyS2+YcJvsc50d1RZZDP6PQZmeBP2gILoWK7RZfnysGrVjKCBpS2djmq6kYFi12 hR0JfFxdaadcHzq98jPprHFIL1qHEXDDvsAsw24ZHeOrEBOQsJiCr9NS2M88lINI7B hH4y7S6VgzYFP629Ddm9eCIuakOpFv+cbwxkGqgeNWVgCoXup5uGQDgoaWFrPFxg4q c6oe4fxZpthDjNXceP3WXkuxC67CWG6hpgy+mbux0o9/HWOsoJERBjGin39Fp74N8k DbqIHAmPyrqRw== From: Marek Vasut To: linux-arm-kernel@lists.infradead.org Cc: Marek Vasut , Conor Dooley , Fabio Estevam , Krzysztof Kozlowski , NXP Linux Team , Pengutronix Kernel Team , Rob Herring , Sascha Hauer , Shawn Guo , devicetree@vger.kernel.org Subject: [PATCH v2] arm64: dts: imx8mp: Enable SAI audio on Data Modul i.MX8M Plus eDM SBC Date: Tue, 6 Feb 2024 13:55:17 +0100 Message-ID: <20240206125541.37959-1-marex@denx.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240206_045554_915193_191EAA92 X-CRM114-Status: GOOD ( 15.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add SAI I2S and audio bindings to Data Modul i.MX8M Plus eDM SBC. The SGTL5000 is attached to SAI3, however the SGTL5000 codec MCLK must be supplied even if the SAI3 is not in use and is controlled separately by the codec. The MCLK is also used to drive the codec I2C block, so without MCLK, I2C access to the codec would not be possible. To provide such flexible MCLK control, use PWM4 with period 1 and duty cycle 50% as 12 MHz clock source, as there is no direct way to route MX8MP CCM clock to the MCLK pin. Use codec as bitclock and frame clock master, so that the SGTL5000 PLL can be used to generate derived clock. Signed-off-by: Marek Vasut --- Cc: Conor Dooley Cc: Fabio Estevam Cc: Krzysztof Kozlowski Cc: NXP Linux Team Cc: Pengutronix Kernel Team Cc: Rob Herring Cc: Sascha Hauer Cc: Shawn Guo Cc: devicetree@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org --- V2: Reorder DT properties --- .../freescale/imx8mp-data-modul-edm-sbc.dts | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-data-modul-edm-sbc.dts b/arch/arm64/boot/dts/freescale/imx8mp-data-modul-edm-sbc.dts index 5828c9d7821de..ef36b7ec65ee1 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-data-modul-edm-sbc.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-data-modul-edm-sbc.dts @@ -45,6 +45,19 @@ clk_xtal25: clock-xtal25 { clock-frequency = <25000000>; }; + clk_pwm4: clock-pwm4 { + compatible = "pwm-clock"; + #clock-cells = <0>; + clock-frequency = <12000000>; + clock-output-names = "codec-pwm4"; + /* + * 1 / 83 ns ~= 12 MHz , but since the PWM input clock is 24 MHz + * and the calculated PWM period is 1 and duty cycle is 50%, the + * result is exactly 12 MHz, which is fine for SGTL5000 MCLK. + */ + pwms = <&pwm4 0 83 0>; + }; + panel: panel { /* Compatible string is filled in by panel board DT Overlay. */ backlight = <&backlight>; @@ -82,6 +95,24 @@ reg_usdhc2_vmmc: regulator-usdhc2-vmmc { vin-supply = <&buck4>; }; + sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "SGTL5000-Card"; + simple-audio-card,format = "i2s"; + simple-audio-card,bitclock-master = <&codec_dai>; + simple-audio-card,frame-master = <&codec_dai>; + simple-audio-card,widgets = "Headphone", "Headphone Jack"; + simple-audio-card,routing = "Headphone Jack", "HP_OUT"; + + cpu_dai: simple-audio-card,cpu { + sound-dai = <&sai3>; + }; + + codec_dai: simple-audio-card,codec { + sound-dai = <&sgtl5000>; + }; + }; + watchdog { /* TPS3813 */ compatible = "linux,wdt-gpio"; pinctrl-names = "default"; @@ -288,6 +319,15 @@ &i2c1 { sda-gpios = <&gpio5 15 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; status = "okay"; + sgtl5000: audio-codec@a { + compatible = "fsl,sgtl5000"; + reg = <0x0a>; + #sound-dai-cells = <0>; + clocks = <&clk_pwm4>; + VDDA-supply = <&buck4>; + VDDIO-supply = <&buck4>; + }; + usb-hub@2c { compatible = "microchip,usb2514bi"; reg = <0x2c>; @@ -436,6 +476,23 @@ &pwm1 { status = "disabled"; }; +&pwm4 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm4>; + status = "okay"; +}; + +&sai3 { + #clock-cells = <0>; + #sound-dai-cells = <0>; + assigned-clocks = <&clk IMX8MP_CLK_SAI3>; + assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>; + assigned-clock-rates = <12288000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_sai3>; + status = "okay"; +}; + /* SD slot */ &usdhc2 { pinctrl-names = "default", "state_100mhz", "state_200mhz"; @@ -785,6 +842,12 @@ MX8MP_IOMUXC_GPIO1_IO03__GPIO1_IO03 0x40000090 >; }; + pinctrl_pwm4: pwm4-grp { + fsl,pins = < + MX8MP_IOMUXC_SAI3_MCLK__PWM4_OUT 0xd6 + >; + }; + pinctrl_rtc: rtc-grp { fsl,pins = < /* RTC_IRQ# */ @@ -816,7 +879,6 @@ pinctrl_sai3: sai3-grp { MX8MP_IOMUXC_SAI3_TXFS__AUDIOMIX_SAI3_TX_SYNC 0xd6 MX8MP_IOMUXC_SAI3_TXD__AUDIOMIX_SAI3_TX_DATA00 0xd6 MX8MP_IOMUXC_SAI3_TXC__AUDIOMIX_SAI3_TX_BCLK 0xd6 - MX8MP_IOMUXC_SAI3_MCLK__AUDIOMIX_SAI3_MCLK 0xd6 MX8MP_IOMUXC_SAI3_RXD__AUDIOMIX_SAI3_RX_DATA00 0xd6 >; };