From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42F4316DC03 for ; Thu, 1 Aug 2024 11:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722510508; cv=none; b=T9rkwh0t+z0GBNHBmL0VNYw8xyiAXVYvKQN60LlVfkYKB+i2+MsSx6Rg4vwnNtD+ubMcm5ccwBXlzGEb9SDwlMQKnyYdgCIedAKSTMwNs2Aff2v/TAqqyK7zscMfrwUHnGumNyG4m85QlbMcK27p3YB4TuUfUFfw/dHGarp4Ikc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722510508; c=relaxed/simple; bh=IzTwNrilBUAlwP925WvEJZboHMLUQHtVa3f+NyNlaK0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b7Ze/1cVDZRSqD1q/SsTfTvhXA/acqV36IqZFQhJ8qts48Uj9SDAX8UItBeER+GPovzSmJX+YWsolw/j8ugpM2DJspg3zDclKnGVUAmbYgcSAedn3gEQmtT7OKDxypuyRmB838am2aCVTayFYEynqyghq+79Z27o+PE5aQruVHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Yq8ZrD88; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Yq8ZrD88" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5a15692b6f6so10437368a12.0 for ; Thu, 01 Aug 2024 04:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722510502; x=1723115302; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=FExuf/EqIwu44cXtirgV7vgVSEt4vB1L1sgTb2On32Q=; b=Yq8ZrD887ONOyl4wEtu2lGibkCoVD+lyETrjB1OxHCJXnoMhjFIMb0HD2KrNgiEZS1 Z5ySNdjFKrCqbphmgawAjuHTcWE4AqQkqamRnCU15OHUEAOXo4ny5vYiw50A8bv09eiW GG/v6hC7210/9TOKlJ8apE3Z6RqyRxEtcDY3oVm+8/1VoQUxg+qeoROqIOruPfsqDqsU 6LM44aVieRPCx6f1U82GH7TL7dX1/5dTZbPl7UZcGuLI+JwL742UlH8McGIIayOrpXOy DTPm0twDcyx8PabSraq9SQI1j2AeKcTmEfJs9CB9bcQXrgFBA2U4KCAN/qZD9+HGn4vl djXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722510502; x=1723115302; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FExuf/EqIwu44cXtirgV7vgVSEt4vB1L1sgTb2On32Q=; b=Z6GA+KFrYepQ9z3/vPx032GtkAonO3l3ZKWLvZzBLjo7m1eK+bkly5mcONSry8VtMF LAGJgWIOifgL1hvoTGXcFKk1pU5X9gyk658huaac9oPohZxa3gz7FHehmKJHl47iAoW1 IRSIu2znWO8ddBl/ulf1pqCy/ESY6efOauo+JE7ruGto8fhImcgrnBwWwPUysBzc9cNX YTFhYFpP7POBQHaQpNwAgZEZ8nshNTiu2SL7PHxdr6lMuLppydKbg7ZTAp2ZGaJyIMZZ fU1q8uj44f1WCeMcRmcRKZilzVUEOoYVlJs0xtDiBO38DSPLGjAMMzy7CRO0Px0nUUjD AjBQ== X-Forwarded-Encrypted: i=1; AJvYcCWqYCCYO9Lq8X/Yyq8B5+Xzpat91KPAqGpC4c9TsptHRr3NP6hlfk4TPF9SVn85oUW/EU6Pgb57+i91GVKXA5ITkVyHb8oqPgSW5A== X-Gm-Message-State: AOJu0YxoYcpGdYqM0LQRx9Dju0pJyil6dhvETYxN8mpICoUukmdYGq46 bGn8E0grsZxY6nJjgMUHHwgitDwmB03CVPuI1JzrqYjIPtU6wGaYAENtqujucJg= X-Google-Smtp-Source: AGHT+IGqr7N4CpNmN1ermVEFWMT0947mfSXTC3VHJzla+OoRW5oknSUl8o0Y7+o27NpeeOS8sdiOuw== X-Received: by 2002:a17:907:25c3:b0:a77:e48d:bc8 with SMTP id a640c23a62f3a-a7daf4c8093mr173415166b.21.1722510502384; Thu, 01 Aug 2024 04:08:22 -0700 (PDT) Received: from linaro.org ([2a02:2454:ff1f:b280:31d2:aeb1:18cd:e482]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad90264sm894932366b.148.2024.08.01.04.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 04:08:22 -0700 (PDT) Date: Thu, 1 Aug 2024 13:08:20 +0200 From: Stephan Gerhold To: Adam Skladowski Cc: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Stephan Gerhold , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 7/8] ASoC: qcom: apq8016_sbc: Add support for msm8976 SoC Message-ID: References: <20240731-msm8953-msm8976-asoc-v3-0-163f23c3a28d@gmail.com> <20240731-msm8953-msm8976-asoc-v3-7-163f23c3a28d@gmail.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240731-msm8953-msm8976-asoc-v3-7-163f23c3a28d@gmail.com> On Wed, Jul 31, 2024 at 05:25:31PM +0200, Adam Skladowski wrote: > Introduce support for audio card on MSM8976 platform. > While MSM8976 falls into v1 category with MSM8916, digitial codec clock > is not available in GCC so we have to set it in machine driver. > For that reason for V1 clocks new boolean is added to check > if we need to enable codec clock. > > Signed-off-by: Adam Skladowski > --- > sound/soc/qcom/apq8016_sbc.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c > index 3ed35beb671a..8219d4d55625 100644 > --- a/sound/soc/qcom/apq8016_sbc.c > +++ b/sound/soc/qcom/apq8016_sbc.c > @@ -35,6 +35,7 @@ struct apq8016_sbc_data { > struct snd_soc_jack jack; > bool jack_setup; > enum afe_clk_api q6afe_clk_ver; > + bool dig_cdc_mclk_en; > int mi2s_clk_count[MI2S_COUNT]; > }; > > @@ -242,6 +243,16 @@ static int msm8916_qdsp6_startup(struct snd_pcm_substream *substream) > > if (++data->mi2s_clk_count[mi2s] > 1) > return 0; > + /* > + * On newer legacy SoC (MSM8976) lpass codec clocks are not available in gcc region > + * so we have to request clock from machine driver using V1 API) > + */ > + if (data->q6afe_clk_ver == Q6AFE_CLK_V1 && > + data->dig_cdc_mclk_en) { > + ret = snd_soc_dai_set_sysclk(cpu_dai, LPAIF_DIG_CLK, DEFAULT_MCLK_RATE, 0); > + if (ret) > + dev_err(card->dev, "Failed to enable LPAIF dig clk: %d\n", ret); > + } > > ret = snd_soc_dai_set_sysclk(cpu_dai, qdsp6_get_clk_id(data, mi2s), MI2S_BCLK_RATE, 0); > if (ret) > @@ -267,6 +278,13 @@ static void msm8916_qdsp6_shutdown(struct snd_pcm_substream *substream) > ret = snd_soc_dai_set_sysclk(cpu_dai, qdsp6_get_clk_id(data, mi2s), 0, 0); > if (ret) > dev_err(card->dev, "Failed to disable LPAIF bit clk: %d\n", ret); > + > + if (data->q6afe_clk_ver == Q6AFE_CLK_V1 && > + data->dig_cdc_mclk_en) { > + ret = snd_soc_dai_set_sysclk(cpu_dai, LPAIF_DIG_CLK, 0, 0); > + if (ret) > + dev_err(card->dev, "Failed to disable LPAIF dig clk: %d\n", ret); > + } > } I'm a bit confused why this works correctly. The digital codec clock (mclk) is needed whenever accessing registers of the digital codec ("qcom,msm8916-wcd-digital-codec"). This is why the clock is directly assigned to it in the DT, so the codec driver can request it when needed. The startup/shutdown callbacks in this patch are only called during audio playback, while the codec registers might be accessed any time e.g. when changing the volume mixers. Perhaps you are lucky not to hit that, but if the clock is off at that point the device will crash or hang. Instead of requesting the clock here, we should assign it to the digital codec in the DT. I think Otto's series also allowed that for the older v1 firmware [1]. Can we work towards finishing that up instead? That should be more reliable. Thanks, Stephan [1]: https://lore.kernel.org/linux-arm-msm/20231029165716.69878-1-otto.pflueger@abscue.de/