Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp707620lqb; Fri, 15 Mar 2024 04:29:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX6y4EnfJiPhf/cnlObKO47FvAcw+D+qxEpVJ4grvPrXAYium0CBo/kqI8PEbsC/UbD6MIWlN806esTG2T/oSLuXNaWJRBuchnzNtyHmQ== X-Google-Smtp-Source: AGHT+IGmhezKW2TwjbK/FnRRrE968gY0u2LHiWQmzym2YlrgLI2xBY7+ALa9WuwJSHwtEIUtLB0+ X-Received: by 2002:a05:6e02:1544:b0:365:147e:f813 with SMTP id j4-20020a056e02154400b00365147ef813mr4027215ilu.23.1710502187578; Fri, 15 Mar 2024 04:29:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710502187; cv=pass; d=google.com; s=arc-20160816; b=UK5ydh+T5GERY8PMSoC9U8ve4kYVIe3tAX5rz2Nug9CYdZLsFFEEt2KyGRmg6QyTVd IKUZ2ED0dFzQ7/9QKF8H78ep1UeivO8GYdiHSWEueWtxK6thHG35YQUldRsxEKUYa3kL p3R7iIIX8FBtNdDyPtaC6X3197PJpApcWStZjEe19oN7SP1XBVSZ1SmCwNtHWe8uR8kq yoewXnvDbxLEQ5mfIUrfMcJ/QUluPI0DnvSnaUofXtyAJDNoz76w6tU92j0QqpQzqeu/ DO30fSTFk63P9LcWOk0WVs2/VYN4mb+Kb1VwSalf9daM0qx5I/+oqgiLBEq59MBx7pHy rlgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=COu6rizlcU/iAlgPx7V2opJGGo26BYauVb3ba1eZNgM=; fh=n4SwjJiNP2/Niz3kNAE60jWVwmW8nZqV++r9tHasXi4=; b=IPoxzEqKVUNiWF7buFm+3vGUHNwDwn0W8OXY1x7bBLSDkWV+y5REWS65XqoV/Z/wSq OReYFFkI7GEjOhQMPxYKq2iLk1MknS/wwdbZOoqzy831WTMNxcjEzQIi5zrws84D8X4i uayQLypbdFjWecEkATnbtvLE3vthHLX4wfbhxprp3YhtkfiEH63x0Z4+gGn+EYZ7hiHO zW59E1P7Ju4QeA2dN55/9FS01TVtUXcwVYp70Ui0xS98XeYazHunQy1Ojcks0qdZGg8P 2UiEyMl5EMN7zHBJfPTBG8t3Dh4tPnJA3EibytL4GQQKBg8qbNkOtiswvHDWv8O7quc/ JNsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZHaKolmq; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-104340-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z2-20020a63e542000000b005d9b49b7ad6si2473781pgj.775.2024.03.15.04.29.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 04:29:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104340-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ZHaKolmq; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-104340-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 48310B2150A for ; Fri, 15 Mar 2024 11:29:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E60DA286B3; Fri, 15 Mar 2024 11:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZHaKolmq" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F25381CD1B; Fri, 15 Mar 2024 11:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710502089; cv=none; b=SU+L3oVdvNqWEv0OPt0iK/JYLa64yL05S3I6NP2kB4KNAbQ9yexef1Wd0NQnWqZmL6o9k4B66Og0Q+x0KNE718p+3hZwl8Z6sb985z9cFM6z6KulMInZeqn6XIUDxvlEnZcUfzEHMbFOhdcESQgwKR2ZJzOiDB6cXbwaSuSNd2g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710502089; c=relaxed/simple; bh=q/HkeRlpaieA7+S1Zq4RKJ57Symb70E/kyVvENJqJ7w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GRmCKKBKOI1SWI+R/WhCiQIlllqtRkN16kgpdNx6DfyWxp+IAswMXZYPNTIh9x8ONDLpVgexIGfYhEAeggYqqy771yWAPME/Mg2HomySK8ngtAgvft6hcRd1OT0QyCxoq4J5SRPJk1Rt4PblxyAdDdqFIU9faAfcVm8hy8a0trU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ZHaKolmq; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id F24ECE0010; Fri, 15 Mar 2024 11:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710502085; 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=COu6rizlcU/iAlgPx7V2opJGGo26BYauVb3ba1eZNgM=; b=ZHaKolmqERDtyC6GBThHLDu9kWPdkP3m/vJAdQgUzgqrX/8nxn+NRPnnYnib71RMRVqW+I 0MGJXKjKMYCJqI1uI0Kbl58bDLyuDkjfEqDQ8M7bXCG5ug4d94RbIQXGBWVqMDLGGQIYB2 Jy7RGIiBMDRNFyF5xT/XUg7yEh0O2ztpBaNHcSVsZliV9AHazDamAU40cqPOlyQtNmz/iH AWoRWqR6AGH2pHwRnrcQqLkPSxMMCnovypu9yffAweyAcXDYJmu52ydff/JtCD2aabL9Vs riU1JJKtaWs5P1/KpB3Lrhdn2dB3f2BddsZHnndhmkQSmDgJAXw1rKII0RvGNQ== 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 08/13] ASoC: ti: davinci-i2s: Add handling of BP_FC format Date: Fri, 15 Mar 2024 12:27:40 +0100 Message-ID: <20240315112745.63230-9-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240315112745.63230-1-bastien.curutchet@bootlin.com> References: <20240315112745.63230-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: bastien.curutchet@bootlin.com 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 4adaed010700..7cdd86f47ead 100644 --- a/sound/soc/ti/davinci-i2s.c +++ b/sound/soc/ti/davinci-i2s.c @@ -306,6 +306,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: /* codec is master */ pcr = 0; @@ -491,6 +497,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); -- 2.43.2