From patchwork Tue Apr 2 07:12:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786724 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 C771DCD11C2 for ; Sun, 7 Apr 2024 07:17:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DD12322A7; Sun, 7 Apr 2024 09:17:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DD12322A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474265; bh=Mh2LHM8oJ/CJGsfoIFwaaxA758nlCt7jqRreMW4pp4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rU2WJbObDghRrHche2XkIFSB/NSLf0MUWr2uBiXdoVrWrMYu5L1LLnGYVmP8BXaOG WfRh2eSXriG2kKvmF60B8npzvaxOiD9p8WQIqg7CFKFnmxGs0ABSNpQAX9xYLq9lGn nUO4Y/+0r+vufbFJqJRPH3U4c0NyJ09V6ThzSNrc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 691BCF8057F; Sun, 7 Apr 2024 09:17:15 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A191FF805A9; Sun, 7 Apr 2024 09:17:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 98FAAF80588; Tue, 2 Apr 2024 09:12:37 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 47FA9F80568 for ; Tue, 2 Apr 2024 09:12:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 47FA9F80568 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=itUJfzVY Received: by mail.gandi.net (Postfix) with ESMTPA id 57E66FF803; Tue, 2 Apr 2024 07:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bVsKOWPb4Rd565bWpf2m06Y2VAlQVW0XhgGG23AgwRw=; b=itUJfzVYv3klqtnyEMVDg2E7rjmPA6DSQihARuQk91eujLgf+NwVEhY5Bba8ooIpVjc5Hw pd1mYqT02lr9JJ2OETE6UJnI6y0bXTWmG0gR3BUU/Oz4xy/ZRaoJuoY/flkrf3mXHHMv6E pERRfbxVkjAWAiuKyOdftboq9DruynMe6Pdx2Qh6MwpoUZeRoQ6LkZ3nFpQjbIhkpslhjV GOuDD+faS8tKSfQavrPBL6Owt56Bu/ooMgFcjO9YdRo6cgf5D8rDsm4TQhInzChGRy44oK d7RES5xaxraH0X/9Dcb8bmrg8rFli9S75f+IAMWPw1LLuv25Vfglq7rzATSS1g== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 01/13] ASoC: dt-bindings: davinci-mcbsp: convert McBSP bindings to yaml schema Date: Tue, 2 Apr 2024 09:12:01 +0200 Message-ID: <20240402071213.11671-2-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: NAH2UF7MJI4G4PV3BQZ626NZ6U6TEUQA X-Message-ID-Hash: NAH2UF7MJI4G4PV3BQZ626NZ6U6TEUQA X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:00 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Convert the binding for McBSP controllers for TI SoCs from txt to YAML schema. Add properties 'clocks', 'clock-names', 'power-domains' and '#sound-dai-cells' which were missing from the txt file. Add '#sound-dai-cells' and 'clocks' in the example which were missing from the txt file. Signed-off-by: Bastien Curutchet Reviewed-by: Rob Herring --- .../bindings/sound/davinci-mcbsp.txt | 50 ---------- .../bindings/sound/davinci-mcbsp.yaml | 95 +++++++++++++++++++ 2 files changed, 95 insertions(+), 50 deletions(-) delete mode 100644 Documentation/devicetree/bindings/sound/davinci-mcbsp.txt create mode 100644 Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml diff --git a/Documentation/devicetree/bindings/sound/davinci-mcbsp.txt b/Documentation/devicetree/bindings/sound/davinci-mcbsp.txt deleted file mode 100644 index 3ffc2562fb31..000000000000 --- a/Documentation/devicetree/bindings/sound/davinci-mcbsp.txt +++ /dev/null @@ -1,50 +0,0 @@ -Texas Instruments DaVinci McBSP module -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This binding describes the "Multi-channel Buffered Serial Port" (McBSP) -audio interface found in some TI DaVinci processors like the OMAP-L138 or AM180x. - - -Required properties: -~~~~~~~~~~~~~~~~~~~~ -- compatible : - "ti,da850-mcbsp" : for DA850, AM180x and OPAM-L138 platforms - -- reg : physical base address and length of the controller memory mapped - region(s). -- reg-names : Should contain: - * "mpu" for the main registers (required). - * "dat" for the data FIFO (optional). - -- dmas: three element list of DMA controller phandles, DMA request line and - TC channel ordered triplets. -- dma-names: identifier string for each DMA request line in the dmas property. - These strings correspond 1:1 with the ordered pairs in dmas. The dma - identifiers must be "rx" and "tx". - -Optional properties: -~~~~~~~~~~~~~~~~~~~~ -- interrupts : Interrupt numbers for McBSP -- interrupt-names : Known interrupt names are "rx" and "tx" - -- pinctrl-0: Should specify pin control group used for this controller. -- pinctrl-names: Should contain only one value - "default", for more details - please refer to pinctrl-bindings.txt - -Example (AM1808): -~~~~~~~~~~~~~~~~~ - -mcbsp0: mcbsp@1d10000 { - compatible = "ti,da850-mcbsp"; - pinctrl-names = "default"; - pinctrl-0 = <&mcbsp0_pins>; - - reg = <0x00110000 0x1000>, - <0x00310000 0x1000>; - reg-names = "mpu", "dat"; - interrupts = <97 98>; - interrupt-names = "rx", "tx"; - dmas = <&edma0 3 1 - &edma0 2 1>; - dma-names = "tx", "rx"; -}; diff --git a/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml b/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml new file mode 100644 index 000000000000..139b594dd192 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml @@ -0,0 +1,95 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/davinci-mcbsp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: McBSP Controller for TI SoCs + +maintainers: + - Bastien Curutchet + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + enum: + - ti,da850-mcbsp + + reg: + minItems: 1 + items: + - description: CFG registers + - description: data registers + + reg-names: + minItems: 1 + items: + - const: mpu + - const: dat + + dmas: + items: + - description: transmission DMA channel + - description: reception DMA channel + + dma-names: + items: + - const: tx + - const: rx + + interrupts: + items: + - description: RX interrupt + - description: TX interrupt + + interrupt-names: + items: + - const: rx + - const: tx + + clocks: + items: + - description: functional clock + + clock-names: + items: + - const: fck + + power-domains: + maxItems: 1 + + "#sound-dai-cells": + const: 0 + +required: + - "#sound-dai-cells" + - compatible + - reg + - reg-names + - dmas + - dma-names + - clocks + +unevaluatedProperties: false + +examples: + - | + mcbsp0@1d10000 { + #sound-dai-cells = <0>; + compatible = "ti,da850-mcbsp"; + pinctrl-names = "default"; + pinctrl-0 = <&mcbsp0_pins>; + + reg = <0x111000 0x1000>, + <0x311000 0x1000>; + reg-names = "mpu", "dat"; + interrupts = <97>, <98>; + interrupt-names = "rx", "tx"; + dmas = <&edma0 3 1>, + <&edma0 2 1>; + dma-names = "tx", "rx"; + + clocks = <&psc1 14>; + }; From patchwork Tue Apr 2 07:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786723 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 EA8D6CD11C2 for ; Sun, 7 Apr 2024 07:18:22 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 509062971; Sun, 7 Apr 2024 09:18:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 509062971 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474301; bh=MDsLsFHtLslxvPtCs/nUPioPhXfjVy6AZnDa713pFfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kB9/6K9BDH6lN/+l9pxTsYs+AzCtfaTrmlK+Jjz4eV1rQwq5Ikw4blWXOCO2SwLYy aJ0REI4YccHEQ2/Wht2fExlcmb6KgnLprLC4QKbb3QxYOpvfrnjbHCm00rmUloDUBW yzRIkofwVG/ksUdmfzeKijDW+1dcuFnmlsmTCKaQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B7535F8060C; Sun, 7 Apr 2024 09:17:19 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B4AF6F805F1; Sun, 7 Apr 2024 09:17:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 68613F80589; Tue, 2 Apr 2024 09:12:42 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A5427F8056F for ; Tue, 2 Apr 2024 09:12:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A5427F8056F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=f3bX7Jpc Received: by mail.gandi.net (Postfix) with ESMTPA id 10E9BFF80A; Tue, 2 Apr 2024 07:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kjMah6RzWU9Pw9jrFvPJ1cd8OwCxOXg5IsWRlfB0YHk=; b=f3bX7Jpc6sXcyKJnYTY182aCDhlFJ78Bq9bDoCqL3Q4wpQw6nArUE4pWQr6S5iLlThLMtC 40CGAijuVr7Dsjcfisy4N4kQFIvibJXT041zmdssqolQ0p06rxlHB6NRjnX0UvOY5B2SNf 33D+47Val3gVaOcSmDuXBQ6tneJrOqRJyyIZT5tNeTbFL6EmiFfpJpB7IPvvWfMqz4P6Fl fan3UFGtnsh5CbWHpJWdfjz/Jc7njZoqV7Uy6IlY8bbfeML2r1eH3csi227NZqC5QXTYLp X9JT26fUsKT75D2Y7TT9D/82uqY4tAXwW5gbbufgxbxZjC7GuhN8m3fG323JdA== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 02/13] ASoC: dt-bindings: davinci-mcbsp: Add optional clock Date: Tue, 2 Apr 2024 09:12:02 +0200 Message-ID: <20240402071213.11671-3-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: 7MXKNXKMUOQ6HLMTDNGKJTOQPGRPIA2I X-Message-ID-Hash: 7MXKNXKMUOQ6HLMTDNGKJTOQPGRPIA2I X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:05 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The McBSP uses an internal sample rate generator to provide bit clock or frame clock. This sample rate generator can be programmed to be driven by McBSP's internal clock source or by an external clock source (located on CLKS pin). The external clock source is not described in the bindings. Add an optional clock item that allows to select an external clock as sample rate generator's input. Signed-off-by: Bastien Curutchet Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml b/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml index 139b594dd192..0c2b1936c6a1 100644 --- a/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml +++ b/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml @@ -50,12 +50,16 @@ properties: - const: tx clocks: + minItems: 1 items: - description: functional clock + - description: external input clock for sample rate generator. clock-names: + minItems: 1 items: - const: fck + - const: clks power-domains: maxItems: 1 From patchwork Tue Apr 2 07:12:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786983 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 AFA79CD11C2 for ; Sun, 7 Apr 2024 07:19:10 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C324D2B00; Sun, 7 Apr 2024 09:18:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C324D2B00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474348; bh=IwfrzWFQMK5aKYIP+JpJjBWSv5PRYRdxAqXqTNhqjec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HNX16lVVPQhGkWxmOmqaYQyw/7ZV8qgbdM5KNHumCCH5oCvNYOHcmCz+lEeMgr3CD WvIfzbvkuzqXEFQ8whMA9wWAIChl6UUuAOSAVNVYTPYaxPlymWHYsf8qvTCM9zb7an 8p7uSsZjiPBjPYQa+hFoFtKuZO1u0UV9YX/3J9gA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B2934F8067C; Sun, 7 Apr 2024 09:17:26 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3F4F3F80675; Sun, 7 Apr 2024 09:17:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 076A2F8057D; Tue, 2 Apr 2024 09:12:59 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B6F3DF80578 for ; Tue, 2 Apr 2024 09:12:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B6F3DF80578 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=CPrylJLU Received: by mail.gandi.net (Postfix) with ESMTPA id 7AAF9FF804; Tue, 2 Apr 2024 07:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vZrZE1ws3fDn3UjdBfQcUrpkUXJj9Z/9NRZDie5wy+o=; b=CPrylJLUBe2LjtOjTJqNfF63pOpEETI40X7AVNJgQVyg5/snrSg/QajeSN9AWOYL+YfiXY lS72zKUZR85ox7BIXLEEcyRr46tfLkXlJOHhdUaQrM6BzNN478KlNNsGIF1nVj1igT9xgo UYRWpP1fxuMRznvqMXV2qUijf7LmJ4/9Aw6EadDrecBlsALOEGXbiCFNvDIQd06UYpdhBG AeH++YErAudKjhK6Q/nyLwK0ZLNX/xc6neo3KUA9Xr9X/bhYBVjOH/sbTr7j7JBIGrtndZ KfCWJledjZlxR4rkBrDyp5BmUlQAVJk02P6LKwN8L3pipWyQ5UtxWoWLLHjeTw== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 03/13] ASoC: ti: davinci-i2s: Remove the unused clk_input_pin attribute Date: Tue, 2 Apr 2024 09:12:03 +0200 Message-ID: <20240402071213.11671-4-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: B6LPXFIOWCWFPJICZJIX5U5GT2YZFJ7W X-Message-ID-Hash: B6LPXFIOWCWFPJICZJIX5U5GT2YZFJ7W X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:06 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The clk_input_pin attribute of davinci_mcbsp_dev struct is not set since commit 257ade78b601 ("ASoC: davinci-i2s: Convert to use edma-pcm"). Remove the attribute. Keep the behaviour of the MCBSP_CLKR case as MCBSP_CLKR == 0. I can't test the BC_FP format so I added back the initial comment that was removed by commit ec6375533748 ("ASoC: DaVinci: Added selection of clk input pin for McBSP"). This was the last dependency to linux/platform_data/davinci_asp.h so it is not included anymore. Remove the enum mcbsp_clk_input_pin from davinci_asp.h as it is not used anywhere else. Signed-off-by: Bastien Curutchet --- include/linux/platform_data/davinci_asp.h | 15 -------------- sound/soc/ti/davinci-i2s.c | 24 ++++------------------- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/include/linux/platform_data/davinci_asp.h b/include/linux/platform_data/davinci_asp.h index c8645b2ed3c0..b9c8520b4bd3 100644 --- a/include/linux/platform_data/davinci_asp.h +++ b/include/linux/platform_data/davinci_asp.h @@ -25,16 +25,6 @@ struct davinci_mcasp_pdata { unsigned sram_size_capture; struct gen_pool *sram_pool; - /* - * If McBSP peripheral gets the clock from an external pin, - * there are three chooses, that are MCBSP_CLKX, MCBSP_CLKR - * and MCBSP_CLKS. - * Depending on different hardware connections it is possible - * to use this setting to change the behaviour of McBSP - * driver. - */ - int clk_input_pin; - /* * This flag works when both clock and FS are outputs for the cpu * and makes clock more accurate (FS is not symmetrical and the @@ -91,11 +81,6 @@ enum { MCASP_VERSION_OMAP, /* OMAP4/5 */ }; -enum mcbsp_clk_input_pin { - MCBSP_CLKR = 0, /* as in DM365 */ - MCBSP_CLKS, -}; - #define INACTIVE_MODE 0 #define TX_MODE 1 #define RX_MODE 2 diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index 07c8b2259208..5c906641640e 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -159,7 +158,6 @@ struct davinci_mcbsp_dev { unsigned int fmt; int clk_div; - int clk_input_pin; bool i2s_accurate_sck; }; @@ -239,26 +237,12 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, DAVINCI_MCBSP_PCR_CLKRM; break; case SND_SOC_DAIFMT_BC_FP: - pcr = DAVINCI_MCBSP_PCR_FSRM | DAVINCI_MCBSP_PCR_FSXM; /* - * Selection of the clock input pin that is the - * input for the Sample Rate Generator. - * McBSP FSR and FSX are driven by the Sample Rate - * Generator. + * McBSP CLKR pin is the input for the Sample Rate Generator. + * McBSP FSR and FSX are driven by the Sample Rate Generator. */ - switch (dev->clk_input_pin) { - case MCBSP_CLKS: - pcr |= DAVINCI_MCBSP_PCR_CLKXM | - DAVINCI_MCBSP_PCR_CLKRM; - break; - case MCBSP_CLKR: - pcr |= DAVINCI_MCBSP_PCR_SCLKME; - break; - default: - dev_err(dev->dev, "bad clk_input_pin\n"); - return -EINVAL; - } - + pcr = DAVINCI_MCBSP_PCR_FSRM | DAVINCI_MCBSP_PCR_FSXM; + pcr |= DAVINCI_MCBSP_PCR_SCLKME; break; case SND_SOC_DAIFMT_BC_FC: /* codec is master */ From patchwork Tue Apr 2 07:12:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786985 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 9C554CD128A for ; Sun, 7 Apr 2024 07:18:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EE49527A6; Sun, 7 Apr 2024 09:17:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EE49527A6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474283; bh=flqmIvc29aq03tyjckaFwyCD7FjGJloE0Stz4DI3BWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=q93P8oawZgIhrbDgGONjorJDWnYm8ygDGaUbX7Iv5f8Uc+4hwsu/Ruvg6olooesIb iiI5fdGJQXRH7faAsRWnXc1UNjUNOYjVLG3/0T74ggWqfNGjeU2GApCkSdm/E+pa3Z iOx57n82a23Oqbu9HH8NZngbAWECq47uiCpakg9E= Received: by alsa1.perex.cz (Postfix, from userid 50401) id EA426F805D5; Sun, 7 Apr 2024 09:17:16 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 649D4F805C3; Sun, 7 Apr 2024 09:17:16 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DCC59F8058C; Tue, 2 Apr 2024 09:12:40 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B4518F80570 for ; Tue, 2 Apr 2024 09:12:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B4518F80570 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=SlgINAU+ Received: by mail.gandi.net (Postfix) with ESMTPA id 01FCCFF80B; Tue, 2 Apr 2024 07:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7mFoXC/7lZncljkGK1+GfQv48vrdua/OVliFLiKRc2A=; b=SlgINAU+zuI8Bem8akyfc0t7xKmu4rUVZEM3IVa0IwYsK+DDPs1sDhofdMdra9u+xNJ1fF uMW8Popwmvhk1niBAJKFtVQi2IoqADVic4CZ9AsCQ8S6O1QBqgxnbd5r2ILYdrbHKaYVl7 jBykm4J62EMwPAu8UwwJGOQOMY0S/496JI8257CFrXBxZB+vnCzjrvDVmfqfi85kOkS714 RvcsnSri9LLhxE2zi/zUGXFfD+D1gPqCte7C2dGW14Gv0v0gCumDg9pfSzNxD/CZCWHNrn VIW3PKOnGDk6DZ6lhQTqvGZA4c8EuAS0HGXJimcl1BktvTdIyvT3KQbuwdBd2A== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 04/13] ASoC: ti: davinci-i2s: Replace dev_err with dev_err_probe Date: Tue, 2 Apr 2024 09:12:04 +0200 Message-ID: <20240402071213.11671-5-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: SVQZ7RHWQX7ACIUGE37FNXDF4DYEQFBZ X-Message-ID-Hash: SVQZ7RHWQX7ACIUGE37FNXDF4DYEQFBZ X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:05 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: <> List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In probe(), the dev_err() is used for every returned error. Replace dev_err() with dev_err_probe() where -EPROBE_DEFER can be returned. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index 5c906641640e..cd64f1384e18 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -708,7 +708,7 @@ static int davinci_i2s_probe(struct platform_device *pdev) ret = edma_pcm_platform_register(&pdev->dev); if (ret) { - dev_err(&pdev->dev, "register PCM failed: %d\n", ret); + dev_err_probe(&pdev->dev, ret, "register PCM failed\n"); goto err_unregister_component; } From patchwork Tue Apr 2 07:12:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786984 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 04898CD11C2 for ; Sun, 7 Apr 2024 07:18:38 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7333D1ED; Sun, 7 Apr 2024 09:18:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7333D1ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474316; bh=UsLK0heJUS0ZdOtjODmExf7eqS2NsI4dk3TuxOHSLlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KdV+OzulA0gs6ax/xjtpCKnMeBO+0jZ/JM4XcziX8TCuUrO0XczAbhYJXdRyZ75Me LZE1GN7W3yLwjJ3qja+ly1WK0LAVTKdJJ/lIOpuGmL4mvP1CRLGav75Dj9vrC8vUn3 8Axt3jxPIYS3ON0GwrN6t2Mdv7chYTeoXl4CGH2Q= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 95066F805E9; Sun, 7 Apr 2024 09:17:21 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 7A19DF80616; Sun, 7 Apr 2024 09:17:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4E904F80568; Tue, 2 Apr 2024 09:12:51 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 64024F8057D for ; Tue, 2 Apr 2024 09:12:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 64024F8057D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=PN61uJa9 Received: by mail.gandi.net (Postfix) with ESMTPA id 5E971FF80C; Tue, 2 Apr 2024 07:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9FxQAwvoRhx4YNmaJ3JdZe1YTK1lfejPZbAcyRGLNHk=; b=PN61uJa9OJF7vyS/QUuAHlU/hjt68rFy2GCnPQ+VJh0NBlBQgsqcYIYMzGzCLxzSKIfpgN ZOSJMZxnG6/HpbLRRpX3f9pAIrseevZbGVL2S6nwS5D38h+UsBdS3OzTq8tu0FXHshgSVw mTouQhTIk9dyAU1mbpkkdHkEnnozTxULKVo4/xAgtfJM7tYJHrYOPj3kahE/RKwDs2d9D0 M94xPxdsjuWHPH7qlJFTkqvYot0DZtQBlYIu9S2hnEVz3rFMNknWhAG4BpjRhtRWZcgghI GWccWmcV6NJjUbNsL6RiptQyL4EBCBWqR8xODHC0Md9rp/HN+kf53je0Z9Xc1g== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 05/13] ASoC: ti: davinci-i2s: Use external clock to drive sample rate generator Date: Tue, 2 Apr 2024 09:12:05 +0200 Message-ID: <20240402071213.11671-6-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: UKJAEVQOE4DCMM3EEKSLBBM3SXBO24MD X-Message-ID-Hash: UKJAEVQOE4DCMM3EEKSLBBM3SXBO24MD X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:05 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: McBSP's internal sample rate generator can be programed to be driven by its internal clock or by an external clock source located on CLKS pin. The external clock source case is not handled by the driver. Handle an optional clock related to this external clock source. If present, the driver uses the clock located on CLKS pin as input for the sample rate generator. Thus, the external clock rate is used to compute divisors. If this optional clock is not present, the sample rate generator is driven by the McBSP's functional clock. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 65 ++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index cd64f1384e18..578b4ae28b71 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -134,6 +134,7 @@ struct davinci_mcbsp_dev { int mode; u32 pcr; struct clk *clk; + struct clk *ext_clk; /* * Combining both channels into 1 element will at least double the * amount of time between servicing the dma channel, increase @@ -364,7 +365,8 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai); struct snd_interval *i = NULL; int mcbsp_word_length, master; - unsigned int rcr, xcr, srgr, clk_div, freq, framesize; + unsigned int rcr, xcr, clk_div, freq, framesize; + unsigned int srgr = 0; u32 spcr; snd_pcm_format_t fmt; unsigned element_cnt = 1; @@ -385,9 +387,13 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, switch (master) { case SND_SOC_DAIFMT_BP_FP: - freq = clk_get_rate(dev->clk); - srgr = DAVINCI_MCBSP_SRGR_FSGM | - DAVINCI_MCBSP_SRGR_CLKSM; + if (dev->ext_clk) { + freq = clk_get_rate(dev->ext_clk); + } else { + freq = clk_get_rate(dev->clk); + srgr = DAVINCI_MCBSP_SRGR_CLKSM; + } + srgr |= DAVINCI_MCBSP_SRGR_FSGM; srgr |= DAVINCI_MCBSP_SRGR_FWID(mcbsp_word_length * 8 - 1); if (dev->i2s_accurate_sck) { @@ -691,12 +697,36 @@ static int davinci_i2s_probe(struct platform_device *pdev) return -ENODEV; } - dev->clk = clk_get(&pdev->dev, NULL); + /* + * The optional is there for backward compatibility. + * If 'fck' is not present, the clk_get(dev, NULL) that follows may find something + */ + dev->clk = devm_clk_get_optional(&pdev->dev, "fck"); if (IS_ERR(dev->clk)) - return -ENODEV; - ret = clk_enable(dev->clk); + return dev_err_probe(&pdev->dev, PTR_ERR(dev->clk), "Invalid functional clock\n"); + if (!dev->clk) { + dev->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(dev->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(dev->clk), + "Missing functional clock\n"); + } + + dev->ext_clk = devm_clk_get_optional(&pdev->dev, "clks"); + if (IS_ERR(dev->ext_clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(dev->ext_clk), "Invalid external clock\n"); + + ret = clk_prepare_enable(dev->clk); if (ret) - goto err_put_clk; + return ret; + + if (dev->ext_clk) { + dev_dbg(&pdev->dev, "External clock used for sample rate generator\n"); + ret = clk_prepare_enable(dev->ext_clk); + if (ret) { + dev_err_probe(&pdev->dev, ret, "Failed to enable external clock\n"); + goto err_disable_clk; + } + } dev->dev = &pdev->dev; dev_set_drvdata(&pdev->dev, dev); @@ -704,7 +734,7 @@ static int davinci_i2s_probe(struct platform_device *pdev) ret = snd_soc_register_component(&pdev->dev, &davinci_i2s_component, &davinci_i2s_dai, 1); if (ret != 0) - goto err_release_clk; + goto err_disable_ext_clk; ret = edma_pcm_platform_register(&pdev->dev); if (ret) { @@ -716,10 +746,12 @@ static int davinci_i2s_probe(struct platform_device *pdev) err_unregister_component: snd_soc_unregister_component(&pdev->dev); -err_release_clk: - clk_disable(dev->clk); -err_put_clk: - clk_put(dev->clk); +err_disable_ext_clk: + if (dev->ext_clk) + clk_disable_unprepare(dev->ext_clk); +err_disable_clk: + clk_disable_unprepare(dev->clk); + return ret; } @@ -729,9 +761,10 @@ static void davinci_i2s_remove(struct platform_device *pdev) snd_soc_unregister_component(&pdev->dev); - clk_disable(dev->clk); - clk_put(dev->clk); - dev->clk = NULL; + clk_disable_unprepare(dev->clk); + + if (dev->ext_clk) + clk_disable_unprepare(dev->ext_clk); } static const struct of_device_id davinci_i2s_match[] __maybe_unused = { From patchwork Tue Apr 2 07:12:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786722 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 13158CD128A for ; Sun, 7 Apr 2024 07:18:41 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0DFCFE8E; Sun, 7 Apr 2024 09:18:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0DFCFE8E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474320; bh=xT943C5Lc6QbwMrA6Li4GMts7767Jo8Mq5mXiDRi4PQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=O5q1rN+Th4FhXUnG33Pgz9x1gttQYUiITv/0Xir4SdzPo7OtSq92MQdkE/OWxJxnR TkOzg2hJ5ZSnxsd+gnT/VEpIi77c74sLj5VISckdCvdqy5Ytwt8IjQlpSOPQ907Ayf VprggNQEpdPS3kIdJ4NCu63FfhPlhw8JyhDLJ7gg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 989E8F8060F; Sun, 7 Apr 2024 09:17:22 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 068C1F80634; Sun, 7 Apr 2024 09:17:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7063EF8059F; Tue, 2 Apr 2024 09:12:57 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 63C63F8057A for ; Tue, 2 Apr 2024 09:12:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 63C63F8057A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=Vn749ZgT Received: by mail.gandi.net (Postfix) with ESMTPA id C7F4AFF810; Tue, 2 Apr 2024 07:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041946; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qNpzql9+lH/lBhekmkx7lLo9hsDbNRyvScO8cpF1Sio=; b=Vn749ZgTdPjlWbJ72PnBY0ctPhrcvGn3UHn/wE+Z4138OYr6T5OKAwqCwWuEAqBE3drNZX 0rZLPrkHcR648FVI4TS5hfDdEji/wqfXTN1c3kSTOZF7EYLBbLLblnCzHiIWP8mDKQyaON ABeuY8e6oH+Q8oBiEI003YTfiTPzLoF1a7oGXunJTWVFYJG99T5yxavG5x/N+R8YCHr5ZQ uZCfOOpxytoN+pBQ/7q55JFVoA2JMMx0aUqw6PK0GnqG1lzM6wJvHzRwvOXIcOVco8eAOD uVITNA1Mcp98Tsh7/X4bRuSAILMQ8hG47z7wAKWQ4sOhs2X8vJ9QMOB15rBf0w== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 06/13] ASoC: ti: davinci-i2s: Delete unnecessary assignment Date: Tue, 2 Apr 2024 09:12:06 +0200 Message-ID: <20240402071213.11671-7-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: DKSFMQOV66IIONOJM6RMHQBTRTER5ZRF X-Message-ID-Hash: DKSFMQOV66IIONOJM6RMHQBTRTER5ZRF X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:05 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In davinci_i2s_hw_params(), mcbsp_word_length is set twice to asp_word_length[fmt]. Remove second unnecessary assignment. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index 578b4ae28b71..a2c7c812ea50 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -479,7 +479,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } } - mcbsp_word_length = asp_word_length[fmt]; switch (master) { case SND_SOC_DAIFMT_BP_FP: From patchwork Tue Apr 2 07:12:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786721 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 01FCECD128A for ; Sun, 7 Apr 2024 07:19:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 186A6279D; Sun, 7 Apr 2024 09:19:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 186A6279D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474366; bh=+FFguuWjmpl99xzEjdNjMqKEsp079adJwqAqXV6U1yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PDMj+4SN6EGaC7Zx4MXONjehGTp3KUfY1njxiuxLKTIVZW5TlIDIT14K6j4+u1YB/ dXTJzoSeeqiAbNd8gCuYINlSXkhoHFJBnf8Oqo5eqtN1GZfDvJRw5UUfjdpf+4/pnu A/oayec9H7phQyO7aAnnSv+YMuG4VPSGW3BtpJJI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CC424F8069A; Sun, 7 Apr 2024 09:17:29 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id ED847F8069E; Sun, 7 Apr 2024 09:17:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9BA8EF8057A; Tue, 2 Apr 2024 09:12:59 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7F324F8057E for ; Tue, 2 Apr 2024 09:12:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7F324F8057E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=ozIq5YGe Received: by mail.gandi.net (Postfix) with ESMTPA id 24E0BFF809; Tue, 2 Apr 2024 07:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZOE+gMok9O7xOxfyDenN7oiNfzS579Yi+szYYcmC2sQ=; b=ozIq5YGeWp2nIAyMNlSLn5hjNh/fD8pPFu2OxUqr8I827c8oDovhNzoxmqZ2e/g1q5dqwa flsAjv9P+ThwbgFVQEtwdbKj3bwsT40toiweRCc5gn9dHR0F3vL59SDiMXBRzFmeTYWA7S kL0ud3k09Xc+neLQd4Yta0+Im6MyuQRX+vMnfpEtepT+Tkptc8Oi3f3cbj6tC/zCGjulQ1 6kswrgHBbFeqFqyJ1k9AoOGGARKHP6x7U8dYtSnrcHZSz2BjcLIeihLVH5wwu5lexDVZgP 2m9k8Tj03vdLOdQaO2OU1FvufwQoSgdc7gUaxmWn5jbRWWOhRQI8o5n67EWeXA== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 07/13] ASoC: ti: davinci-i2s: Add TDM support Date: Tue, 2 Apr 2024 09:12:07 +0200 Message-ID: <20240402071213.11671-8-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: AJNZECBLKDNA43YGPQYH76HKGABY3CEE X-Message-ID-Hash: AJNZECBLKDNA43YGPQYH76HKGABY3CEE X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:06 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: TDM is not supported by the McBSP driver. The McBSP datasheet does not name explicitly TDM as a supported format but it is possible to configure the McBSP to do TDM if all slots are used by McBSP. Add TDM support. It uses single-phase frame. Slot width is used to compute the McBSP's word length. Implement the set_tdm_slot() hook of snd_soc_dai_ops struct. It only supports TDM if all slots are used by McBSP. The snd_soc_dai_driver's channels_max is updated from 2 to 128. This was tested with BP_FC format on a platform designed off of DAVINCI/OMAP_L138. A check is done in davinci_i2s_set_dai_fmt() to prevent TDM to be used with BC_FC and BC_FP formats. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 92 +++++++++++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 5 deletions(-) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index a2c7c812ea50..f9a67c2bc2f5 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -160,6 +160,9 @@ struct davinci_mcbsp_dev { unsigned int fmt; int clk_div; bool i2s_accurate_sck; + + int tdm_slots; + int slot_width; }; static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev, @@ -213,6 +216,63 @@ static void davinci_mcbsp_stop(struct davinci_mcbsp_dev *dev, int playback) toggle_clock(dev, playback); } +static int davinci_i2s_tdm_word_length(int tdm_slot_width) +{ + switch (tdm_slot_width) { + case 8: + return DAVINCI_MCBSP_WORD_8; + case 12: + return DAVINCI_MCBSP_WORD_12; + case 16: + return DAVINCI_MCBSP_WORD_16; + case 20: + return DAVINCI_MCBSP_WORD_20; + case 24: + return DAVINCI_MCBSP_WORD_24; + case 32: + return DAVINCI_MCBSP_WORD_32; + default: + return -EINVAL; + } +} + +static int davinci_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, + unsigned int tx_mask, + unsigned int rx_mask, + int slots, int slot_width) +{ + struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); + + dev_dbg(dev->dev, "slots %d, slot_width %d\n", slots, slot_width); + + if (slots > 128 || !slots) { + dev_err(dev->dev, "Invalid number of slots\n"); + return -EINVAL; + } + + if (rx_mask != (1 << slots) - 1) { + dev_err(dev->dev, "Invalid RX mask (0x%08x) : all slots must be used by McBSP\n", + rx_mask); + return -EINVAL; + } + + if (tx_mask != (1 << slots) - 1) { + dev_err(dev->dev, "Invalid TX mask (0x%08x) : all slots must be used by McBSP\n", + tx_mask); + return -EINVAL; + } + + if (davinci_i2s_tdm_word_length(slot_width) < 0) { + dev_err(dev->dev, "%s: Unsupported slot_width %d\n", __func__, slot_width); + return -EINVAL; + } + + dev->tdm_slots = slots; + dev->slot_width = slot_width; + + return 0; +} + #define DEFAULT_BITPERSAMPLE 16 static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, @@ -238,6 +298,11 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, DAVINCI_MCBSP_PCR_CLKRM; break; case SND_SOC_DAIFMT_BC_FP: + if (dev->tdm_slots || dev->slot_width) { + dev_err(dev->dev, "TDM is not supported for BC_FP format\n"); + return -EINVAL; + } + /* * McBSP CLKR pin is the input for the Sample Rate Generator. * McBSP FSR and FSX are driven by the Sample Rate Generator. @@ -246,6 +311,11 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, pcr |= DAVINCI_MCBSP_PCR_SCLKME; break; case SND_SOC_DAIFMT_BC_FC: + if (dev->tdm_slots || dev->slot_width) { + dev_err(dev->dev, "TDM is not supported for BC_FC format\n"); + return -EINVAL; + } + /* codec is master */ pcr = 0; break; @@ -383,7 +453,13 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, master = dev->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK; fmt = params_format(params); - mcbsp_word_length = asp_word_length[fmt]; + if (dev->slot_width) + mcbsp_word_length = davinci_i2s_tdm_word_length(dev->slot_width); + else + mcbsp_word_length = asp_word_length[fmt]; + + if (mcbsp_word_length < 0) + return mcbsp_word_length; switch (master) { case SND_SOC_DAIFMT_BP_FP: @@ -483,8 +559,13 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, switch (master) { case SND_SOC_DAIFMT_BP_FP: case SND_SOC_DAIFMT_BP_FC: - rcr |= DAVINCI_MCBSP_RCR_RFRLEN1(0); - xcr |= DAVINCI_MCBSP_XCR_XFRLEN1(0); + if (dev->tdm_slots > 0) { + rcr |= DAVINCI_MCBSP_RCR_RFRLEN1(dev->tdm_slots - 1); + xcr |= DAVINCI_MCBSP_XCR_XFRLEN1(dev->tdm_slots - 1); + } else { + rcr |= DAVINCI_MCBSP_RCR_RFRLEN1(0); + xcr |= DAVINCI_MCBSP_XCR_XFRLEN1(0); + } break; case SND_SOC_DAIFMT_BC_FC: case SND_SOC_DAIFMT_BC_FP: @@ -609,19 +690,20 @@ static const struct snd_soc_dai_ops davinci_i2s_dai_ops = { .hw_params = davinci_i2s_hw_params, .set_fmt = davinci_i2s_set_dai_fmt, .set_clkdiv = davinci_i2s_dai_set_clkdiv, + .set_tdm_slot = davinci_i2s_set_tdm_slot, }; static struct snd_soc_dai_driver davinci_i2s_dai = { .playback = { .channels_min = 2, - .channels_max = 2, + .channels_max = 128, .rates = DAVINCI_I2S_RATES, .formats = DAVINCI_I2S_FORMATS, }, .capture = { .channels_min = 2, - .channels_max = 2, + .channels_max = 128, .rates = DAVINCI_I2S_RATES, .formats = DAVINCI_I2S_FORMATS, }, From patchwork Tue Apr 2 07:12:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786720 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 74968CD128A for ; Sun, 7 Apr 2024 07:19:58 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ADD86207; Sun, 7 Apr 2024 09:19:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ADD86207 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474396; bh=GJaodrsvsUKepJh5HOvgM3By9lC7drwoFVmPzzyuZSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=aNZLr96+GTQTZf4srfdGgYedv9vSYOHuu6unbPqDTMDEQVhRJjik9dRtVLP/2cziB ph6bkc6Ie1DiLb849kP1UnsSFHa8tsUjgavHH6cTnzQIJC6c70xuHVUMsV8o8suzq6 JXtic3qPZdOjEHWASjRrUYrRk6i6ZpSIG3HOyWHg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D0B6DF806B1; Sun, 7 Apr 2024 09:17:32 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 56CBFF806DD; Sun, 7 Apr 2024 09:17:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 071F0F8057A; Tue, 2 Apr 2024 09:13:02 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1D810F8057F for ; Tue, 2 Apr 2024 09:12:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1D810F8057F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=eollKoDn Received: by mail.gandi.net (Postfix) with ESMTPA id 6FD7BFF80B; Tue, 2 Apr 2024 07:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041949; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B8mmblUe82t+hx13yGYU8qdAec50yUQsVghOvUGSIMk=; b=eollKoDn3KuG4KvaXPrltRHFBIsN36vPdK3DJkycbYXA+vraNbsfDEX9Yj6Z8BE6AvfK/a PhSP4VEgcmO09RYy7UQPwQPmg01KsFtKCzzp2JykNFDdd2XYeOVbVkMGU7j2eLXqbmzP82 n4U9dFbj/BT4O289prGUTXXguyYsQ0B56MsM2sicYKtf+WyErz+lSIKTmZxxpXreqX7fSp jvECNCfqj6pzCBueS//S9/kKK8JcNOoxqq4i6dUnh9IxL+VR45OsNcBHt3QuClB+G8fLoS t9dTLg4iWF6odauJGkBQPsUU6wuWcJgqUwEgMLy5YX7SV+nGQ4nTdNANDcPtkg== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 08/13] ASoC: ti: davinci-i2s: Add handling of BP_FC format Date: Tue, 2 Apr 2024 09:12:08 +0200 Message-ID: <20240402071213.11671-9-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: FONJZQJBKYBO3FFXANPTRRIMCYA6Q7AB X-Message-ID-Hash: FONJZQJBKYBO3FFXANPTRRIMCYA6Q7AB X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:07 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: McBSP is able to drive bit clock and consume frame clock but BP_FC format is not handled by McBSP driver. Add BP_FC format support. When BP_FC is selected: - CLKX and CLKR are configured as outputs - The sample rate generator is configured to be able to provide bit clock. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index f9a67c2bc2f5..e51f05cda941 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -310,6 +310,12 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, pcr = DAVINCI_MCBSP_PCR_FSRM | DAVINCI_MCBSP_PCR_FSXM; pcr |= DAVINCI_MCBSP_PCR_SCLKME; break; + case SND_SOC_DAIFMT_BP_FC: + /* cpu is bitclock provider */ + pcr = DAVINCI_MCBSP_PCR_CLKXM | + DAVINCI_MCBSP_PCR_CLKRM; + break; + case SND_SOC_DAIFMT_BC_FC: if (dev->tdm_slots || dev->slot_width) { dev_err(dev->dev, "TDM is not supported for BC_FC format\n"); @@ -500,6 +506,23 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, clk_div &= 0xFF; srgr |= clk_div; break; + case SND_SOC_DAIFMT_BP_FC: + if (dev->ext_clk) { + freq = clk_get_rate(dev->ext_clk); + } else { + freq = clk_get_rate(dev->clk); + srgr = DAVINCI_MCBSP_SRGR_CLKSM; + } + if (dev->tdm_slots && dev->slot_width) { + clk_div = freq / (params->rate_num * params->rate_den) + / (dev->tdm_slots * dev->slot_width) - 1; + } else { + clk_div = freq / (mcbsp_word_length * 16) / + params->rate_num * params->rate_den; + } + clk_div &= 0xFF; + srgr |= clk_div; + break; case SND_SOC_DAIFMT_BC_FC: /* Clock and frame sync given from external sources */ i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); From patchwork Tue Apr 2 07:12:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786981 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 A2E74CD11C2 for ; Sun, 7 Apr 2024 07:20:14 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F104B2BA3; Sun, 7 Apr 2024 09:20:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F104B2BA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474413; bh=Q7kTk1pOg/NlcWm8yefb0S3wgoRZDW+UapJioBKAJ5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=AG8ShWJvLRe+8RBzVdEDR1pKurnS2zkhz2VtMuWfjhh7dMMszdS9S3IrKL8B2bF7s cLUy5iwW5aWp2M8DakQCRA7tDP2EZTmN1a5ssbDkDCoQxS1Tw3kT13XQ5geSE+ix7X Mg4Y1lwTRACVG8rZpjc1ceXT/nLahGRHP33Oj1KQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 03800F80715; Sun, 7 Apr 2024 09:17:37 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 93CCFF8057D; Sun, 7 Apr 2024 09:17:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 37D8AF8057A; Tue, 2 Apr 2024 09:13:02 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6CF1AF8057C for ; Tue, 2 Apr 2024 09:12:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6CF1AF8057C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=gtBR9Cj3 Received: by mail.gandi.net (Postfix) with ESMTPA id D98B9FF808; Tue, 2 Apr 2024 07:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HvbHeeS3hR6xxZxnOS4/gZMDTkNCkYqtTO8AzSbFnAU=; b=gtBR9Cj3w6T5MCM3MKOtnT3CCueCifNr1cENC9icgWs52nSs4LVhR0OHZbiOqBiTAWqE0X 8hMe13a/H9NdlMaJx/iin+LxcIb1N5ZzrVahD5tOrMUrv9TbuADHy12cwoeehL8FtA0pXN jmYsvmHrdza7l3M0Dirs2ePt2JtvCNWtFJByV1lfhc8hZh7yeSWnxTr8OnIBCPDG6MGRv9 3dCiUaeqLIMhBzFo8WY3AzHHVJlR6k6SuG105KTrGoERp7Sx+5eRnnnLbekudOSUuxvAvv C6QFsyeJ1YPgRBRUHCLMqD3oIhDwJTfkoU6iNFoS4OzvBU80jMlFJmTJKdxF5g== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 09/13] ASoC: ti: davinci-i2s: Enable unexpected frame pulses detection Date: Tue, 2 Apr 2024 09:12:09 +0200 Message-ID: <20240402071213.11671-10-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: 23EMYXHACKBAOSUDPN3B7VWDTGRMOX2Z X-Message-ID-Hash: 23EMYXHACKBAOSUDPN3B7VWDTGRMOX2Z X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:48 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: McBSP can generate a SYNCERR when unexpected frame pulses are detected. The driver always disables this feature and ignore the unexpected frame pulses. Enable the generation of SYNCERR by the McBSP. Unexpected frame pulses are not ignored anymore. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index e51f05cda941..82a0dfa07cec 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -441,8 +441,10 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai); struct snd_interval *i = NULL; int mcbsp_word_length, master; - unsigned int rcr, xcr, clk_div, freq, framesize; + unsigned int clk_div, freq, framesize; unsigned int srgr = 0; + unsigned int rcr = 0; + unsigned int xcr = 0; u32 spcr; snd_pcm_format_t fmt; unsigned element_cnt = 1; @@ -539,8 +541,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, } davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SRGR_REG, srgr); - rcr = DAVINCI_MCBSP_RCR_RFIG; - xcr = DAVINCI_MCBSP_XCR_XFIG; if (dev->mode == MOD_DSP_B) { rcr |= DAVINCI_MCBSP_RCR_RDATDLY(0); xcr |= DAVINCI_MCBSP_XCR_XDATDLY(0); From patchwork Tue Apr 2 07:12:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786980 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 5CD33CD11C2 for ; Sun, 7 Apr 2024 07:20:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8F3E52BA7; Sun, 7 Apr 2024 09:20:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8F3E52BA7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474447; bh=raqZRXpSAUQKXil8z5AtZK8I91UM9WjPAbTjuIxfsT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=S8GV3BfZvpkeirRgvws5qU97MTr4WCIFn0ftAmkOly+HP5oTmvICqJyw0W6BpnJwG IIqtNboCBv7xZNjO9supRlctrXFSdTARWTl0kruugj5t4Ci5/uI7fr7eAIZzMC1vlh hcp/4qMhvq1g8uPkz+wmJmCykCEDya+yPvoHhDNg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 71D36F8076A; Sun, 7 Apr 2024 09:17:40 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6BEEEF80760; Sun, 7 Apr 2024 09:17:40 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E11B8F8057A; Tue, 2 Apr 2024 09:13:04 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5EEA0F80587 for ; Tue, 2 Apr 2024 09:12:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5EEA0F80587 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=TyJGS7gJ Received: by mail.gandi.net (Postfix) with ESMTPA id 61BB1FF804; Tue, 2 Apr 2024 07:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041952; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ryoqfTLjKn66TnerPCn7gg2/Qxg9JuXh/P0bs+WVTIc=; b=TyJGS7gJDTLORWyHUtik2qmgLQWu+1QobOj/bZ5fKukP7/xQkT/y7Li1gBUe9ykjzhBrof KvQqwPNmN8Y9cp60ztHZ9N1u5JiWbBgN5oQja5XKgv00D9eaytCihDmi4C3W0Fcvsl23Fz lPzMRoPKJuTsnAsGn87OX+Eb3ifq252qOl6QdrykwSYhbH6rfEDCbqj1aSGNMdAMdPcUKx MamDCqbugQImrX1SZIIkvqGijCUmYONdL7vrhpTQiCd+DyEYMKQgdnTyACA0QCKjShRgmE Oz7VXxpiGajXIq9uNf4iYAYO92EsuWb9DYst/t0FdJiM8ttu/4vHYGLkNgSKbg== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 10/13] ASoC: ti: davinci-i2s: Link free-run mode to SND_SOC_DAIFMT_[GATED/CONT] Date: Tue, 2 Apr 2024 09:12:10 +0200 Message-ID: <20240402071213.11671-11-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: XLSW3NKSESN6LMO7DAM2CMTQZYHKO66Q X-Message-ID-Hash: XLSW3NKSESN6LMO7DAM2CMTQZYHKO66Q X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:48 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: McBSP has free-running mode where serial clocks continue to run during emulation halts. This mode is always enabled by the driver. Set free-running mode when SND_SOC_DAIFMT_CONT is selected by DAI format, unset it when SND_SOC_DAIFMT_GATED is selected. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index 82a0dfa07cec..7fb41987175b 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -280,6 +280,7 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, { struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); unsigned int pcr; + unsigned int spcr; unsigned int srgr; bool inv_fs = false; /* Attention srgr is updated by hw_params! */ @@ -288,6 +289,23 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, DAVINCI_MCBSP_SRGR_FWID(DEFAULT_BITPERSAMPLE - 1); dev->fmt = fmt; + + spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); + switch (fmt & SND_SOC_DAIFMT_CLOCK_MASK) { + case SND_SOC_DAIFMT_CONT: + spcr |= DAVINCI_MCBSP_SPCR_FREE; + dev_dbg(dev->dev, "Free-running mode ON\n"); + break; + case SND_SOC_DAIFMT_GATED: + spcr &= ~DAVINCI_MCBSP_SPCR_FREE; + dev_dbg(dev->dev, "Free-running mode OFF\n"); + break; + default: + dev_err(dev->dev, "Invalid clock gating\n"); + return -EINVAL; + } + davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); + /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { case SND_SOC_DAIFMT_BP_FP: @@ -452,10 +470,10 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, /* general line settings */ spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - spcr |= DAVINCI_MCBSP_SPCR_RINTM(3) | DAVINCI_MCBSP_SPCR_FREE; + spcr |= DAVINCI_MCBSP_SPCR_RINTM(3); davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); } else { - spcr |= DAVINCI_MCBSP_SPCR_XINTM(3) | DAVINCI_MCBSP_SPCR_FREE; + spcr |= DAVINCI_MCBSP_SPCR_XINTM(3); davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); } From patchwork Tue Apr 2 07:12:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786982 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 7E64ECD128A for ; Sun, 7 Apr 2024 07:19:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6044E21E2; Sun, 7 Apr 2024 09:19:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6044E21E2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474384; bh=aEvLZ42Sz56/Mq00rxNsquYsuc4I6XXsq0WZKRms/uk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kQ9yLmFz0WiWpmgOMZPGkY3VIgKYtV9tUyaqENKFGdWYjkKI2TTGoP6QJjZ6OwGa6 v693cm9/QgxysX5T7Z5KNQvZ2lUIXehueoiX16Avu3r6VWquSQvZIvneg02NghAAry wy/dgSVXgyTPIvAVUJhqHdngdMdZstOMKmTxP6ms= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A2BBDF806CC; Sun, 7 Apr 2024 09:17:31 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 22697F806C1; Sun, 7 Apr 2024 09:17:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3C3F7F805AB; Tue, 2 Apr 2024 09:13:01 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E915AF80007 for ; Tue, 2 Apr 2024 09:12:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E915AF80007 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=dvS9r/61 Received: by mail.gandi.net (Postfix) with ESMTPA id C648CFF805; Tue, 2 Apr 2024 07:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kGgoavkWPYXIisQyOjz1zAZv2po0MrsfHiyY+MEsubo=; b=dvS9r/61DMhpSthZq/wkIW2aWqRag/BQv+j4bSdjOV/esteKS+egqrnc7QtqUWc8nibjmR j+AmfM0ylUJpWTKVJyDKowEaSb5gJaHegHh8+z8hzk7liatrp9emg4ARQDCM64Oaa+q6D6 vrbagM0FUuDMfk1f67aHZzOgNkuKplfoWnPVdYpL7SRe+7hqT61c4A1oebNIHZgMAkj4L9 Vp2N3oDvdfo7AUle6eKLeTEwmjPJGWJ1LTfPd5FfZrZi5vxdtUFvqPtY2qP7QskiGB9pSN ZPIDajAWHBsW3YsJr44/nHqUIUrbHo0y9jVrmDmFoBp2BayzJMdtbr3Oxkbh8A== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 11/13] ASoC: ti: davinci-i2s: Add S24_LE to supported formats Date: Tue, 2 Apr 2024 09:12:11 +0200 Message-ID: <20240402071213.11671-12-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: DRK3UKXIVD4RM2YDDOYQZGORA4PITMYL X-Message-ID-Hash: DRK3UKXIVD4RM2YDDOYQZGORA4PITMYL X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:06 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: S24_LE is supported by McBSP but not by the driver. Add S24_LE to driver's supported formats. Using it enables the sign extension in DRR (Data Receive Register). The other formats are kept with the zero extension in DRR. Remove data_type table as it is no longer used. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index 7fb41987175b..fb1e09c78bdf 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -61,6 +61,9 @@ #define DAVINCI_MCBSP_SPCR_RRST (1 << 0) #define DAVINCI_MCBSP_SPCR_RINTM(v) ((v) << 4) +#define DAVINCI_MCBSP_SPCR_RJUST(v) ((v) << 13) +#define DAVINCI_MCBSP_SPCR_RJUST_Z_LE DAVINCI_MCBSP_SPCR_RJUST(0) +#define DAVINCI_MCBSP_SPCR_RJUST_S_LE DAVINCI_MCBSP_SPCR_RJUST(1) #define DAVINCI_MCBSP_SPCR_XRST (1 << 16) #define DAVINCI_MCBSP_SPCR_XINTM(v) ((v) << 20) #define DAVINCI_MCBSP_SPCR_GRST (1 << 22) @@ -107,15 +110,10 @@ enum { DAVINCI_MCBSP_WORD_32, }; -static const unsigned char data_type[SNDRV_PCM_FORMAT_S32_LE + 1] = { - [SNDRV_PCM_FORMAT_S8] = 1, - [SNDRV_PCM_FORMAT_S16_LE] = 2, - [SNDRV_PCM_FORMAT_S32_LE] = 4, -}; - static const unsigned char asp_word_length[SNDRV_PCM_FORMAT_S32_LE + 1] = { [SNDRV_PCM_FORMAT_S8] = DAVINCI_MCBSP_WORD_8, [SNDRV_PCM_FORMAT_S16_LE] = DAVINCI_MCBSP_WORD_16, + [SNDRV_PCM_FORMAT_S24_LE] = DAVINCI_MCBSP_WORD_24, [SNDRV_PCM_FORMAT_S32_LE] = DAVINCI_MCBSP_WORD_32, }; @@ -467,8 +465,23 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, snd_pcm_format_t fmt; unsigned element_cnt = 1; - /* general line settings */ spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); + + /* Determine xfer data type */ + fmt = params_format(params); + switch (fmt) { + case SNDRV_PCM_FORMAT_S16_LE: + case SNDRV_PCM_FORMAT_S32_LE: + break; + case SNDRV_PCM_FORMAT_S24_LE: + spcr |= DAVINCI_MCBSP_SPCR_RJUST_S_LE; + break; + default: + dev_warn(dev->dev, "davinci-i2s: unsupported PCM format\n"); + return -EINVAL; + } + + /* general line settings */ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { spcr |= DAVINCI_MCBSP_SPCR_RINTM(3); davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr); @@ -566,12 +579,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, rcr |= DAVINCI_MCBSP_RCR_RDATDLY(1); xcr |= DAVINCI_MCBSP_XCR_XDATDLY(1); } - /* Determine xfer data type */ - fmt = params_format(params); - if ((fmt > SNDRV_PCM_FORMAT_S32_LE) || !data_type[fmt]) { - printk(KERN_WARNING "davinci-i2s: unsupported PCM format\n"); - return -EINVAL; - } if (params_channels(params) == 2) { element_cnt = 2; @@ -710,6 +717,7 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, #define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 #define DAVINCI_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) static int davinci_i2s_dai_probe(struct snd_soc_dai *dai) From patchwork Tue Apr 2 07:12:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786719 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 652A6CD11C2 for ; Sun, 7 Apr 2024 07:20:32 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9D80D21A2; Sun, 7 Apr 2024 09:20:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9D80D21A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474430; bh=YgIbRUy6+1L5DOGVht8whZV1f4NbwbHZHWVmd2UytFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=USxPrg1gm8CeAl1T0jYYjAcOUSpX6nIIbz4MbP+VfVilNZgIEXIeuhI80TZBHq53a k9ueHbS5iMQiohtrg/u9JhTzrn6yPhGzbHdlVHIkQd32T2vPLpeCLGjz3eq9zKg5JP APOxE1CkqBz5aW9PV3Ccvv90vygTggGu1EcEqAJw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 08CBFF80759; Sun, 7 Apr 2024 09:17:39 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D4EB9F8074A; Sun, 7 Apr 2024 09:17:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2DA2AF8057A; Tue, 2 Apr 2024 09:13:03 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 57D52F8055C for ; Tue, 2 Apr 2024 09:12:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 57D52F8055C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=i6CP8+jV Received: by mail.gandi.net (Postfix) with ESMTPA id EADE9FF809; Tue, 2 Apr 2024 07:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6hUXRPUn9Ew3xx8mNXSwygNKoR19Gfh8s6NOLyAtqSQ=; b=i6CP8+jVSldQ/HJGgUsQdDB4c3KK4OwrJlMLeSshrbCKBa+aV1SQ9ewq1GXO0GxOXbGWXg sMPMwvYVigLnAZNXrldko5xJzftmVB1uf7K3OLAIKQt+5IL1ufw+HhjPF7KkNb/ZAKDzxr Q3H5eshHRygaEpu1WkXSwKE3wKs93A3P9up6eJm/fsUI7BKE6BrgUfs+xvnP0sUtT5BYOK Fb0oncJe+BWsKWv70FbBIAeRtSpRS25w/uSDfD8bSpJXOs+2tIFC1KvFswXvpxZkE3SYcL rc8fYgqPQsTfTyiJsACP0Zs6XxC34G4rjRpG1CXISj9WA+Hl4DSDUaNLgzs/yQ== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 12/13] ASoC: dt-bindings: davinci-mcbsp: Add the 'ti,T1-framing-{rx/tx}' flags Date: Tue, 2 Apr 2024 09:12:12 +0200 Message-ID: <20240402071213.11671-13-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: FIAVRVGVJ6LEKXFMM4S3FGDSSPTP24O5 X-Message-ID-Hash: FIAVRVGVJ6LEKXFMM4S3FGDSSPTP24O5 X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:48 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: McBSP's data delay can be configured from 0 to 2 bit clock periods. 0 is used for DSP_B format, 1 for DSP_A format. A data delay of 2 bit clock periods can be used to interface to 'T1 framing' devices where data stream is preceded by a 'framing bit'. This 2 bit clock data delay is not described in the bindings. Add two flags 'ti,T1-framing-[rx/tx]' to enable a data delay of 2 bit clock periods in reception or transmission. Signed-off-by: Bastien Curutchet --- .../devicetree/bindings/sound/davinci-mcbsp.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml b/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml index 0c2b1936c6a1..4fa677023827 100644 --- a/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml +++ b/Documentation/devicetree/bindings/sound/davinci-mcbsp.yaml @@ -67,6 +67,20 @@ properties: "#sound-dai-cells": const: 0 + ti,T1-framing-tx: + $ref: /schemas/types.yaml#/definitions/flag + description: + If the property is present, tx data delay is set to 2 bit clock periods. + McBSP will insert a blank period (high-impedance period) before the first + data bit. This can be used to interface to T1-framing devices. + + ti,T1-framing-rx: + $ref: /schemas/types.yaml#/definitions/flag + description: + If the property is present, rx data delay is set to 2 bit clock periods. + McBSP will discard the bit preceding the data stream (called framing bit). + This can be used to interface to T1-framing devices. + required: - "#sound-dai-cells" - compatible From patchwork Tue Apr 2 07:12:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 786718 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 7F61ECD11C2 for ; Sun, 7 Apr 2024 07:21:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E183014DE; Sun, 7 Apr 2024 09:20:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E183014DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712474459; bh=n8C2sMFznZ+aSgwy6VZZBdp6GtGS+ViwXxZAO/kOhSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rUd/fxT3a37oycc7OpqstptMd4aIOuGrGKvgOxsyYeXmaMdYJi5CNdERjrrkmGD0m BVzE8cB68LHekufrbSW3G0hXtUQig5kwDRaCoGIRXFUkIUHE0OLqQh4oMNZ4jPsVE/ pHBvIfsNtK2V4OyEWttTE3aBg7sesT7ZmMe6b5wI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8723DF80808; Sun, 7 Apr 2024 09:17:44 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id AC07BF807CA; Sun, 7 Apr 2024 09:17:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7D10DF805B1; Tue, 2 Apr 2024 09:13:07 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D6FA2F80114 for ; Tue, 2 Apr 2024 09:12:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D6FA2F80114 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=H78MRbh1 Received: by mail.gandi.net (Postfix) with ESMTPA id 2DD34FF80B; Tue, 2 Apr 2024 07:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712041955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PE3YvX4Y16ibvrY87Lo5u2VWlVZ0kvZSV/V9W8+29Ew=; b=H78MRbh18HozjmvX6U8/RisNl1hxS6rRFIyRStLQwOFgG0EzwIze+ki3HBx0wMmJXZgzua KFN6OxHpXsXDDjjNAleJizhmSTi4pttKWeWArkxtULPfH2viNPhXZpg5deGc6AHPZeqInm D4B9jOJdIDDE2pXS+mZsFmjd059rX9kVoZXXx5TikWiDDlz/h3gOHa0lU5Caqhdncyz3Q/ x29TNap5WlkPZH2B4MSQ0F9N6iCbvr60ogpdZ+ysBS5VNZFZ8UsOUWmeDVZH9larPRGx7A f9jIzh1n4x78gRTTfTCAgm7bMrZCaCl+n7h9lMlNJVWjRyiWCB7AG3CXScxCSg== From: Bastien Curutchet To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Ujfalusi , Jaroslav Kysela , Takashi Iwai , Bastien Curutchet Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Thomas Petazzoni , herve.codina@bootlin.com, christophercordahi@nanometrics.ca Subject: [PATCH v2 13/13] ASoC: ti: davinci-i2s: Add T1 framing support Date: Tue, 2 Apr 2024 09:12:13 +0200 Message-ID: <20240402071213.11671-14-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402071213.11671-1-bastien.curutchet@bootlin.com> References: <20240402071213.11671-1-bastien.curutchet@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com X-MailFrom: bastien.curutchet@bootlin.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: MK3EAHR7KI4IBSH4XSVJOY5XKB7QB64E X-Message-ID-Hash: MK3EAHR7KI4IBSH4XSVJOY5XKB7QB64E X-Mailman-Approved-At: Sun, 07 Apr 2024 07:14:48 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: McBSP's data delay can be configured from 0 to 2 bit clock periods. 0 is used for DSP_B format, 1 is used for DSP_A format, 2 is unused. A data delay of 2 bit clock periods can be used to interface to 'T1 framing' devices where data stream is preceded by a 'framing bit'. On transmission, McBSP inserts a blank period (high-impedance period) before the first data bit to leave an opportunity for other devices to set this 'framing bit'. On reception, McBSP discards the 'framing bit' that precedes the data stream. Add support for the 'framing bit' according to the 'ti,T1-framing-[tx/rx]' device-tree properties. If a flag is present, the data delay is set to 2 bit clock periods regardless of the selected DAI format. Signed-off-by: Bastien Curutchet --- sound/soc/ti/davinci-i2s.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c index fb1e09c78bdf..0f15a743c798 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -161,6 +161,9 @@ struct davinci_mcbsp_dev { int tdm_slots; int slot_width; + + bool tx_framing_bit; + bool rx_framing_bit; }; static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev, @@ -580,6 +583,15 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, xcr |= DAVINCI_MCBSP_XCR_XDATDLY(1); } + if (dev->tx_framing_bit) { + xcr &= ~DAVINCI_MCBSP_XCR_XDATDLY(1); + xcr |= DAVINCI_MCBSP_XCR_XDATDLY(2); + } + if (dev->rx_framing_bit) { + rcr &= ~DAVINCI_MCBSP_RCR_RDATDLY(1); + rcr |= DAVINCI_MCBSP_RCR_RDATDLY(2); + } + if (params_channels(params) == 2) { element_cnt = 2; if (double_fmt[fmt] && dev->enable_channel_combine) { @@ -796,6 +808,9 @@ static int davinci_i2s_probe(struct platform_device *pdev) dev->base = io_base; + dev->tx_framing_bit = of_property_read_bool(pdev->dev.of_node, "ti,T1-framing-tx"); + dev->rx_framing_bit = of_property_read_bool(pdev->dev.of_node, "ti,T1-framing-rx"); + /* setup DMA, first TX, then RX */ dma_data = &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK]; dma_data->addr = (dma_addr_t)(mem->start + DAVINCI_MCBSP_DXR_REG);