From patchwork Fri Apr 14 14:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Anikiel?= X-Patchwork-Id: 674124 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 997D0C77B72 for ; Fri, 14 Apr 2023 14:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbjDNODo (ORCPT ); Fri, 14 Apr 2023 10:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230177AbjDNODg (ORCPT ); Fri, 14 Apr 2023 10:03:36 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 882D9A5CC for ; Fri, 14 Apr 2023 07:03:02 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id h8so3066529ljf.3 for ; Fri, 14 Apr 2023 07:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480970; x=1684072970; 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=b/pTs4z9rhsBzBw4ml9qs5JBHN4WLKpluPzA9XU/6Jk=; b=OXpk08I1AC9etobtye7i60c27lC4lj7/SZW9B5ttLpNUFKqf0S6rQ6xjLnu0O6h2DD rSG1RCCO6BeNy6NOLso/6J68yWcbnJ4MCO0bFEEK07LPLj66vlhIql0CIAKOAdAb9GMf /mNuvuM+bh5rghs6+bfmEU/hQmU6MFLUkIopX7dNWDZ6k3DniD+TkQlzdYDFlPRKdMRM VVi4SQyrVEx3XqVLJdWk9o2XfkRdnTfEoxMRjBRchUg5BfUo55RQiZHWx9feBm8xe4C1 rbpklvVxxNTe6IeiPG1crcrDS90TCgdjp2ZjVW3NeU8bR+s7SwN0MdYEJuGEgYZNRO7B LujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480970; x=1684072970; 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=b/pTs4z9rhsBzBw4ml9qs5JBHN4WLKpluPzA9XU/6Jk=; b=GbZGXWw24BStcNGfvzvLe4XDkDVB1G4VTh/LK6HMB6o3d9Ufjgh3xqwImAl3wkJJjU 1fHYYMi5RCGUw4gF6NYdd2oyxn81awXc7Xwsu/KWvjq6ayHnYaBgvaLixqx/MV5+M/+z v/bmfVRBaoXMufzEvqX2yT+tY6Kdo9N/QHc0xDR33/vMb9pJ1sdytx8OTx2MUOpcCbp6 3284FnaK1+W2KJBlBIYnKSyfRA/02LTSqyjjAi0rInUShbgOYNCdvo2S6K2E92+9Pz2r fQ4SF4NQA6LTnThgY+cNC5bRiC+IjqRoJHbh5gHp60tPyC/lm7cYCVFHo9ldgd7xX8l3 vYzw== X-Gm-Message-State: AAQBX9cY90x2NBNFsNb9YPygwUGZUOL28A+qY76nhHKPiKKT22qk0zBD eJNQSZtiBaSihMMOJBYrLrQ3sg== X-Google-Smtp-Source: AKy350a2jetYlrjNvabc9jILg3C4DgASyuZ+RZVm6baefXeSjrRJTfnzHFRX467sNw55w+dKiuBNqg== X-Received: by 2002:a2e:978a:0:b0:2a8:ad32:3d59 with SMTP id y10-20020a2e978a000000b002a8ad323d59mr770788lji.9.1681480970216; Fri, 14 Apr 2023 07:02:50 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:49 -0700 (PDT) From: =?utf-8?q?Pawe=C5=82_Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?utf-8?q?Pawe=C5=82_Anikiel?= Subject: [PATCH 6/9] ASoC: ssm2602: Add support for CLKDIV2 Date: Fri, 14 Apr 2023 16:02:00 +0200 Message-ID: <20230414140203.707729-7-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The SSM260x chips have an internal MCLK /2 divider (bit D7 in register R8). Add logic that allows for more MCLK values using this divider. Signed-off-by: Paweł Anikiel --- sound/soc/codecs/ssm2602.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 021e0c860fa1..35c4743e756e 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -280,9 +280,12 @@ static inline int ssm2602_get_coeff(int mclk, int rate) int i; for (i = 0; i < ARRAY_SIZE(ssm2602_coeff_table); i++) { - if (ssm2602_coeff_table[i].rate == rate && - ssm2602_coeff_table[i].mclk == mclk) - return ssm2602_coeff_table[i].srate; + if (ssm2602_coeff_table[i].rate == rate) { + if (ssm2602_coeff_table[i].mclk == mclk) + return ssm2602_coeff_table[i].srate; + if (ssm2602_coeff_table[i].mclk == mclk / 2) + return ssm2602_coeff_table[i].srate | SRATE_CORECLK_DIV2; + } } return -EINVAL; } @@ -365,18 +368,24 @@ static int ssm2602_set_dai_sysclk(struct snd_soc_dai *codec_dai, switch (freq) { case 12288000: case 18432000: + case 24576000: + case 36864000: ssm2602->sysclk_constraints = &ssm2602_constraints_12288000; break; case 11289600: case 16934400: + case 22579200: + case 33868800: ssm2602->sysclk_constraints = &ssm2602_constraints_11289600; break; case 12000000: + case 24000000: ssm2602->sysclk_constraints = NULL; break; default: return -EINVAL; } + ssm2602->sysclk = freq; } else { unsigned int mask;