From patchwork Thu Jun 13 08:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrejs Cainikovs X-Patchwork-Id: 13696374 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 488A013D8A6; Thu, 13 Jun 2024 08:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268423; cv=none; b=W5K7eyepCLhw9X4NRBP7ZYR4nzSxUFXHvOHjRVYeV02vq5Aj7ILEeYQqvbt82wKSL5IoVzXJc5nm7M18T6WCsAkthRZzr5Y95k+7KZ1dEBVe6Qz6/zwKFMlQD+0BDlFWVgkF/w0EIl6bFONSFKb4atrEY2mfla5OO2ZEjeTD3nc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268423; c=relaxed/simple; bh=9PtQ8zM9C8kWoJ/j3aD7oi8Q4SAOvIat/GQcZAYBzWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LEgDpWP8p9kSwk/o/LiejdLk8kKRBI5WF2SaLzQpSFVANFvg+q22zlEosxc9cCzuEGU/7zm97NUpcdfHO3/nTSRctHhz77qvb+0o/UfVzadmL0Jw8Up2upUmeAM8kTFOTITFucB0yCUdM7+EUvvNlS6E9NNP2rNRdGidPr09/Ho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I5NKCP+l; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I5NKCP+l" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-57c61165af6so672007a12.2; Thu, 13 Jun 2024 01:47:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718268420; x=1718873220; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qrljha2mkLWZllZM4qPDb9u5Vppz4LLT+JoE5p6lano=; b=I5NKCP+l5hW9yj7mOb0Ya0WSeQ0GPA8hHpEw2stanBt84ldmmOT38joeFn6WEA7JTW 7xiODu7YccOZghKo7oeJtYwgYy6pu7GSMyKpArFybcMlqT6Rn+mAe61q3qJ3P3DAL6yJ 68atTbnL3k7mCmyf+1wJyr6wdEe/oajsrbsSQ/ZYBpWgR0f51GsuiW1SinPV1xDuzaKf nKEPmZ8hYQpWCuFjzKLgayA+I+vBixQ+Vy5tCAB0EbhjZGq0KPf/ulfhLs/yTtQqCNci ssHYZKrMltBuC6/7GDU+KfY3Dzp0yOIYevex5uX+HV7x9QEWlkfrAl4jdUr8dP82weG7 NnSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718268420; x=1718873220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qrljha2mkLWZllZM4qPDb9u5Vppz4LLT+JoE5p6lano=; b=eJgIcz2L2sE3Lz//g4tObMXMGos3tcXQRDik/1Yv4qphrMeQc3XbV17xs+AyLVqJSd eB2+FX+FqeSBkonaLdmY+JK7drApVLe2drLSNV8BXPjbQhm7W6YScdr5qjZsQMQkRqIw g7ZO7mhYU0rSZXzUeY9Akr0Jw/73WRb46EVLJC8J+u6aosCGImcxjkXrn6xNAoJL+5q2 Xlbb49UwLlafIaNnzLgk1BDkSQvYXxE+jTd+atWiARDP/dE8bIyYC7hyWheQiOwxIdvh h4azDHNYexAAeTyu7uQjMQpL9uikQW3S6/cdc5hjNZlaVepJMCHIFhFR4vq+ggtfiSrs +eOw== X-Forwarded-Encrypted: i=1; AJvYcCUNlx08u/iYPdDGd5LdKCVZ7m966ZoWG3lXCEV+DgGzxRMi2YhNG95nnUJHflatAZcTlaryj+f1ORFCbinhLjm+Eb7RrAYcWIFAMg3/ X-Gm-Message-State: AOJu0YwZm2iNxxryslbDjH9f4wRESH2pMjXfavwgw3SMhcCjSb8CqM/6 cukS+/KEkh/HpPc983c9ZA/Qjdyt6NXI2Bnjnx7U4GEBt0a3Jpz9 X-Google-Smtp-Source: AGHT+IFFzf8Xo+GvNocVfwURbaXw6j9mQa3VZgFp1TirAhgpggh4VF036LnafPgKJAK3xNbKpeF1Yg== X-Received: by 2002:a17:906:d7a6:b0:a6f:5b5f:89a9 with SMTP id a640c23a62f3a-a6f5b5f8ba3mr36412766b.55.1718268420204; Thu, 13 Jun 2024 01:47:00 -0700 (PDT) Received: from andrejs-nb.. (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56dd2daasm48364266b.97.2024.06.13.01.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 01:46:58 -0700 (PDT) From: Andrejs Cainikovs To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Andrejs Cainikovs Subject: [PATCH v2 1/3] ASoC: nau8822: move nau8822_set_dai_sysclk() Date: Thu, 13 Jun 2024 10:46:50 +0200 Message-Id: <20240613084652.13113-2-andrejs.cainikovs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240613084652.13113-1-andrejs.cainikovs@gmail.com> References: <20240613084652.13113-1-andrejs.cainikovs@gmail.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrejs Cainikovs Next commit in series makes a change which calls nau8822_set_pll() from nau8822_set_dai_sysclk(). Moving latter after the former would avoid a forward declaration, and this is exactly what this change does. Signed-off-by: Andrejs Cainikovs --- sound/soc/codecs/nau8822.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c index e6909e64dfa3..a6741bda6a9e 100644 --- a/sound/soc/codecs/nau8822.c +++ b/sound/soc/codecs/nau8822.c @@ -612,20 +612,6 @@ static const struct snd_soc_dapm_route nau8822_dapm_routes[] = { {"Right DAC", NULL, "Digital Loopback"}, }; -static int nau8822_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, - unsigned int freq, int dir) -{ - struct snd_soc_component *component = dai->component; - struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); - - nau8822->div_id = clk_id; - nau8822->sysclk = freq; - dev_dbg(component->dev, "master sysclk %dHz, source %s\n", freq, - clk_id == NAU8822_CLK_PLL ? "PLL" : "MCLK"); - - return 0; -} - static int nau8822_calc_pll(unsigned int pll_in, unsigned int fs, struct nau8822_pll *pll_param) { @@ -782,6 +768,20 @@ static int nau8822_set_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; } +static int nau8822_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, + unsigned int freq, int dir) +{ + struct snd_soc_component *component = dai->component; + struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); + + nau8822->div_id = clk_id; + nau8822->sysclk = freq; + dev_dbg(component->dev, "master sysclk %dHz, source %s\n", freq, + clk_id == NAU8822_CLK_PLL ? "PLL" : "MCLK"); + + return 0; +} + static int nau8822_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct snd_soc_component *component = dai->component; From patchwork Thu Jun 13 08:46:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrejs Cainikovs X-Patchwork-Id: 13696375 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 8C7CD13D638; Thu, 13 Jun 2024 08:47:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268425; cv=none; b=Yyfw7E4ppyHTvUtGzGB45xmRTsY+bZLNbO6sCpG+yywt6lJGh5/x9OsshTqDUmuJxBhpkLBqiCBJim0nFrYIewHInzAZV8FEOcFslRPFSgFobnuUEW9tNEtu1sY++vHpNerOGhD982FyJQ4QUp+VzGx/teVnySKv4NU8vJ3ju/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268425; c=relaxed/simple; bh=EqkSdTqJHaYEQuNi/uLAeCi9pEAL2ae1wXXb2wxmqNM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lAc/wGl/pfN8OI+a+QfnlH/NEkcfaTrXJ0J4sPya7aEhRLltne7GcfAFiR95WT99RjBr8WJZlu8TicBLj/WXoDS2FI6rqMEaHLcKJND5F5SISzryTCcBUS+vAeYPjDF5wM2JGt7UPt81+8Hu4ZTvAAzdmK6E5DL7Tvo+5ap9bXc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hkGYIGsv; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hkGYIGsv" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a6efe62f583so71163866b.3; Thu, 13 Jun 2024 01:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718268422; x=1718873222; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=thQRC36oe2yKpAcPC3plDlm/TWRwjC8u5J3scWrGsuY=; b=hkGYIGsvEn94ajE67tKf8/1TKNpUX3yTt0MWou14r55jCIf7DuFVOHhZmIoB4oylhd eaQgicuC4axvzOt8eS4tI9mxSF1M/X2LVl0l1YDEFx813lI/DbzVhozUG5PjMVvxou7M LVoXoIlTwo7TU9aMi4N+JJADr8i3psS1jlmRmVdAnQc4ORwfJHDZbr4DGtjw92uUgd23 4V0qeX64gQDyqeOQ2aqSccBUjNSe23r6brUP46y4yXa+x0AVqYEERHJAgye/wM8kUUzE rKIKaChiz3cF9SkSjILze9gT1Wj5PGU+I8n3DUE2UXRA9VdD8nbN+6HkDFgTH21a4NxO QIzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718268422; x=1718873222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=thQRC36oe2yKpAcPC3plDlm/TWRwjC8u5J3scWrGsuY=; b=C5+oLgE1DySQ9PYwTKtb7+FQ4HuBq/WF0dEGzGUgjQxFp1DtizPRjkEDCTiIjaFFsq za9e06+gWDaCTrQXia4RV0VhADy3IpV4CyGvI3GFiewdk6yu4MkHczUEOfwc3tpsTxIY 7uYJFN0KKq2pn8E0x74XUMoDmF7ZoJ1OKsPXw278wECmhA3NsNB9VVBK88Gted/FM3kA oqm1nVCAETQaQpEUjofXMqYYMDpPlRWzCtGFd0cCfqW478kGDet8Dlg0W7Of/h4R2uG2 TXNOCFD4KS6Et78GN2jVOkcQeBksp3rajtpbF3as2vCIEeCXMIuxmGUqhMhiDgSmkawF o3mA== X-Forwarded-Encrypted: i=1; AJvYcCUXoyTBEbFS6R/QnUuwihrJiVwtgpojQCsWXp1FzQBtLgWG3DXM9nboEBSV7RPE0nWPO7/LgukK7Ux37E8DKg1QxfhGjpGqDEUNrk4U X-Gm-Message-State: AOJu0Yx7HX0SwEZQy/fm81i/uRiodtM93jjS5l32oqOGSTRt68ufT4wy 5BSFsXRnqVmctRTr+bnWnb37ovjMZYgeqh0qpfCAnvI25m/3ovJU X-Google-Smtp-Source: AGHT+IH+mYeCaw5E5vk77ROWpy5NO+f5UmGrTBrK24oz5K/O4bX/DcDKQcBs+PHYKe41rBz7J4b8XQ== X-Received: by 2002:a17:906:c105:b0:a6f:48b2:aace with SMTP id a640c23a62f3a-a6f48b2aebdmr282579766b.51.1718268421698; Thu, 13 Jun 2024 01:47:01 -0700 (PDT) Received: from andrejs-nb.. (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56dd2daasm48364266b.97.2024.06.13.01.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 01:47:00 -0700 (PDT) From: Andrejs Cainikovs To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Andrejs Cainikovs , Emanuele Ghidoli Subject: [PATCH v2 2/3] ASoC: nau8822: set NAU8822_REFIMP_80K only once Date: Thu, 13 Jun 2024 10:46:51 +0200 Message-Id: <20240613084652.13113-3-andrejs.cainikovs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240613084652.13113-1-andrejs.cainikovs@gmail.com> References: <20240613084652.13113-1-andrejs.cainikovs@gmail.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrejs Cainikovs Following bias state machine logic this bit is set twice before playback. This change makes sure this bit set is set only once. Signed-off-by: Andrejs Cainikovs Suggested-by: Emanuele Ghidoli --- sound/soc/codecs/nau8822.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c index a6741bda6a9e..5f9f0953aa2f 100644 --- a/sound/soc/codecs/nau8822.c +++ b/sound/soc/codecs/nau8822.c @@ -942,6 +942,8 @@ static int nau8822_set_bias_level(struct snd_soc_component *component, { switch (level) { case SND_SOC_BIAS_ON: + break; + case SND_SOC_BIAS_PREPARE: snd_soc_component_update_bits(component, NAU8822_REG_POWER_MANAGEMENT_1, From patchwork Thu Jun 13 08:46:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrejs Cainikovs X-Patchwork-Id: 13696376 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 33E6113E03B; Thu, 13 Jun 2024 08:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268426; cv=none; b=Qt+uhucukiFTj7l8RAkPWS+ooRYFNQb2LeAi5BiMz7K1vN9KYhQtu/vys9pfuGLSvXKp05OF64wx+A3BWb90vKFTXYG9hMWWcEE3hC3qQcoV/FRSmQyyeKoUndiIF7cjV+f4qsJE6ipy4IwdCNdWZo3PAWUPP645klO+2NddlBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718268426; c=relaxed/simple; bh=7cTfU0NzG4EQ73KLfyQ5mMxgJ/9Ax3Um1XAQjism0x0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W2epbFbzHghXCcqt23CoEWp2OWB/ngFjCh662hXf72rzbvJP/8Os5ajidRfPrbhdsGNM6aiBQbxRlVr0selyjU2LQYgGFc6GNYOIQUZY/ifNCL76BlNemiacz4pUNvBarJikwF09IP1UVLmmbEaYDFgWGGkzSzlfwdC3MDOIbII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZV4SBzjn; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZV4SBzjn" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a6f253a06caso94566366b.1; Thu, 13 Jun 2024 01:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718268423; x=1718873223; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4CEwTUZlBDBOuLF/YpPCjybp6G8vWfidbX5dtN7b7RA=; b=ZV4SBzjnV9+AwGTakM2YDQ1Vvp9GbqH1JuPDLFEfYZg2eviAVP7YVaAUaYGW0ZRPCX WJFM1MCOZxZNVMGa0gkTlcn5hCzYUMqkFSn6/VfOc5lgSR8UnxePa6cibRy8RNkShu2T HptpuY8f+EGz4q5tVR///YWiACFaT7KtR9PjRqEyX3qORNTGCONXm7D+qEqOBwzlaAoL MjzhQy04NBBVklxJPtAxU0Ow7GSZCNJkT8jROyetAQgjoRGtWk/m8ciRmzbHjHSnp2AR vYTEkNmvzsYhkdL5rpsKRlMRlCL+gXZWYLVNoeeP3AR4WgC7G48KiocHLMxnB+Ac47kn 6sQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718268423; x=1718873223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4CEwTUZlBDBOuLF/YpPCjybp6G8vWfidbX5dtN7b7RA=; b=GTlMKdP8oWqcZBzzEW0KonDzMkJoiTFeVE+mntad2qtZc3j6zeF/F5sFtKIMS8F3Zf ZkFlsX6Hy+EASren9xdBVhkqjlvTZnf+rzM879IJwgbLQEFbI0+YpRDmo3SZi2Ozh1So np4/onEKIW2QfMJoPnO5WyLRWv02sts4Nf4a/j5mKIXFHWWhoGzjZ+uU77i6e5tw8dkD FJui0LZC/6VUE8TbN7WelSHkucvl6m4gYuYaRSRihmFNz04FJAY731R5Xzf+pq3UTWFL NvsolZ1OioHdFSIVH74dhnyDHfzonKq2WOlLWcG2YsWLIcWCgvvsTr7RC1Oi5HCAyRpI w2Wg== X-Forwarded-Encrypted: i=1; AJvYcCUcJ0jddBWC7kgWV9aBuqm6wU3eRJoL4met+DOIj66mZ+5Qfot3pklEJrHnpcCT/SrMejdV0bHLJZezMMqeuRDaDl7UwYZCB+W3jJ3u X-Gm-Message-State: AOJu0YwfD9SkRseHpjgZZjD5qwbeD6vo+wVVlOT87jUNOw5L6lzjShB1 dbyBK08fo7YdD1O4bEymlKSnhsxNwaTgiiVsuFDeeVmetKwhgYcr X-Google-Smtp-Source: AGHT+IHD68zIcX1XZw4+ce22ZWsZXStN7p7QMpvIuUboTuQbkKFMtrJiGWaZHH78gds6l45c3bAJkA== X-Received: by 2002:a17:907:72cb:b0:a6f:5259:72e0 with SMTP id a640c23a62f3a-a6f525973camr208690766b.25.1718268423010; Thu, 13 Jun 2024 01:47:03 -0700 (PDT) Received: from andrejs-nb.. (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56dd2daasm48364266b.97.2024.06.13.01.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 01:47:02 -0700 (PDT) From: Andrejs Cainikovs To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Andrejs Cainikovs Subject: [PATCH v2 3/3] ASoC: nau8822: add MCLK support Date: Thu, 13 Jun 2024 10:46:52 +0200 Message-Id: <20240613084652.13113-4-andrejs.cainikovs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240613084652.13113-1-andrejs.cainikovs@gmail.com> References: <20240613084652.13113-1-andrejs.cainikovs@gmail.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrejs Cainikovs This change adds MCLK clock handling directly within driver. When used in combination with simple-audio-card, and mclk-fs is set, simple-audio-card will change MCLK frequency before configuring PLL. In some cases, however, MCLK reference clock should be static (see [1]), which means it needs to be moved away from simple-audio-card. [1]: https://lore.kernel.org/all/ZfBdxrzX3EnPuGOn@ediswmail9.ad.cirrus.com/ Signed-off-by: Andrejs Cainikovs --- sound/soc/codecs/nau8822.c | 48 ++++++++++++++++++++++++++++++++++---- sound/soc/codecs/nau8822.h | 1 + 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c index 5f9f0953aa2f..e1cbaf8a944d 100644 --- a/sound/soc/codecs/nau8822.c +++ b/sound/soc/codecs/nau8822.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -773,11 +774,26 @@ static int nau8822_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, { struct snd_soc_component *component = dai->component; struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); + unsigned long mclk_freq; nau8822->div_id = clk_id; nau8822->sysclk = freq; + + if (nau8822->mclk) { + mclk_freq = clk_get_rate(nau8822->mclk); + if (mclk_freq != freq) { + int ret = nau8822_set_pll(dai, NAU8822_CLK_MCLK, + NAU8822_CLK_MCLK, mclk_freq, freq); + if (ret) { + dev_err(component->dev, "Failed to set PLL\n"); + return ret; + } + nau8822->div_id = NAU8822_CLK_PLL; + } + } + dev_dbg(component->dev, "master sysclk %dHz, source %s\n", freq, - clk_id == NAU8822_CLK_PLL ? "PLL" : "MCLK"); + nau8822->div_id == NAU8822_CLK_PLL ? "PLL" : "MCLK"); return 0; } @@ -848,7 +864,7 @@ static int nau8822_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); - int val_len = 0, val_rate = 0; + int div = 0, val_len = 0, val_rate = 0; unsigned int ctrl_val, bclk_fs, bclk_div; /* make BCLK and LRC divide configuration if the codec as master. */ @@ -915,8 +931,10 @@ static int nau8822_hw_params(struct snd_pcm_substream *substream, /* If the master clock is from MCLK, provide the runtime FS for driver * to get the master clock prescaler configuration. */ - if (nau8822->div_id == NAU8822_CLK_MCLK) - nau8822_config_clkdiv(dai, 0, params_rate(params)); + if (nau8822->div_id != NAU8822_CLK_MCLK) + div = nau8822->pll.mclk_scaler; + + nau8822_config_clkdiv(dai, div, params_rate(params)); return 0; } @@ -940,17 +958,34 @@ static int nau8822_mute(struct snd_soc_dai *dai, int mute, int direction) static int nau8822_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); + switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: + if (nau8822->mclk && + snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) { + int ret = clk_prepare_enable(nau8822->mclk); + + if (ret) { + dev_err(component->dev, + "Failed to enable MCLK: %d\n", ret); + return ret; + } + } + snd_soc_component_update_bits(component, NAU8822_REG_POWER_MANAGEMENT_1, NAU8822_REFIMP_MASK, NAU8822_REFIMP_80K); break; case SND_SOC_BIAS_STANDBY: + if (nau8822->mclk && + snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_OFF) + clk_disable_unprepare(nau8822->mclk); + snd_soc_component_update_bits(component, NAU8822_REG_POWER_MANAGEMENT_1, NAU8822_IOBUF_EN | NAU8822_ABIAS_EN, @@ -1127,6 +1162,11 @@ static int nau8822_i2c_probe(struct i2c_client *i2c) } i2c_set_clientdata(i2c, nau8822); + nau8822->mclk = devm_clk_get_optional(&i2c->dev, "mclk"); + if (IS_ERR(nau8822->mclk)) + return dev_err_probe(&i2c->dev, PTR_ERR(nau8822->mclk), + "Error getting mclk\n"); + nau8822->regmap = devm_regmap_init_i2c(i2c, &nau8822_regmap_config); if (IS_ERR(nau8822->regmap)) { ret = PTR_ERR(nau8822->regmap); diff --git a/sound/soc/codecs/nau8822.h b/sound/soc/codecs/nau8822.h index 6ecd46e45923..13fe0a091e9e 100644 --- a/sound/soc/codecs/nau8822.h +++ b/sound/soc/codecs/nau8822.h @@ -215,6 +215,7 @@ struct nau8822_pll { struct nau8822 { struct device *dev; struct regmap *regmap; + struct clk *mclk; struct nau8822_pll pll; int sysclk; int div_id;