From patchwork Tue Mar 30 06:32:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 411681 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4212648jai; Mon, 29 Mar 2021 23:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygVkxm2esA0J0y94QO/7i3+OaDaOmM59qKkuwQSB9JTe0z/LxjRAheDENKuzHi6oE4QVQ2 X-Received: by 2002:a17:906:d9c9:: with SMTP id qk9mr31257926ejb.504.1617086866623; Mon, 29 Mar 2021 23:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617086866; cv=none; d=google.com; s=arc-20160816; b=NvdLoOHGlJVoAM/GaLLATCL7BlSRQ0IH+QJWS7MyymY7w310T9R6q9grzSrr9l8UDt 8A8v0lfkABX9d3+SacnpxJ1fM7iVGN5TsZZ9GsOi+NsZnNfj2oOA3+gNtEuGvw4Mki1O in1lBblH6KNFQi4wJnLRnSGdSiU2xEWb6H9ghN15XMbiY5zc177oQkI2tQ29W2dlGPUd VC55s7mZKV/UgMaZ0q7daRGjVu32CZhByPrCxpuA09zixNwn7Q2wG9I5nkozy3O6qTrd brqgt6GNFfdmH0VNVLEPkrbfkpMvsCz3t9pYbGj8DPDCi6/EztTkt7PoXPjnXfDcUbTR Wx5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from; bh=97Y7GdPiAc5KBkzvA+lEZRIyJBqMYB/vs3NwWBWlfic=; b=X8dV5mE6spNin9u+7vTi2hkxYul/4XtwzlEtiZ+J+/pwxo+FRy1JCAMbmz79fX4MGX z5C7+z+8C6E3+dYRLW1UCk5pfnkXGTs7g//i6h5MItt4jsjuyPE6NYeyth85QkBLCjbq 1MrEeIMh80Q3Twil9JkfZYXekjcUY92SOTASv7zeUaaAfbzv60vi8+dBCqab42B44om6 mc/ACKmrqE1V4reNUOINFMbEY5zhAYbwNTMByNRO7X3CwM3Ppj8pON2BkDLbJmTAS9kR Dy15LlMHUoXKMfXnBF3jHE1MnP4i2UEm8V/HqfskDGgOYY2qRYeT0ngX6kw5+ppMwVIt 8Qhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si14341027edi.135.2021.03.29.23.47.46; Mon, 29 Mar 2021 23:47:46 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230323AbhC3GrN (ORCPT + 6 others); Tue, 30 Mar 2021 02:47:13 -0400 Received: from inva021.nxp.com ([92.121.34.21]:35286 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbhC3Gq6 (ORCPT ); Tue, 30 Mar 2021 02:46:58 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 85BB420594F; Tue, 30 Mar 2021 08:46:54 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 104332058F2; Tue, 30 Mar 2021 08:46:51 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 9DE5E402B0; Tue, 30 Mar 2021 08:46:46 +0200 (CEST) From: Shengjiu Wang To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/2] ASoC: ak5558: Add support for ak5552 Date: Tue, 30 Mar 2021 14:32:51 +0800 Message-Id: <1617085972-6094-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Viorel Suman AK5552 is a 32-bit 2ch ADC and has the same register map as AK5558. Signed-off-by: Viorel Suman Signed-off-by: Shengjiu Wang --- sound/soc/codecs/ak5558.c | 93 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 5 deletions(-) -- 2.27.0 diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c index 85bdd0534180..af12afa83b4f 100644 --- a/sound/soc/codecs/ak5558.c +++ b/sound/soc/codecs/ak5558.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,11 @@ #include "ak5558.h" +enum ak555x_type { + AK5558, + AK5552, +}; + #define AK5558_NUM_SUPPLIES 2 static const char *ak5558_supply_names[AK5558_NUM_SUPPLIES] = { "DVDD", @@ -59,6 +65,15 @@ static const struct soc_enum ak5558_mono_enum[] = { ARRAY_SIZE(mono_texts), mono_texts), }; +static const char * const mono_5552_texts[] = { + "2 Slot", "1 Slot (Fixed)", "2 Slot", "1 Slot (Optimal)", +}; + +static const struct soc_enum ak5552_mono_enum[] = { + SOC_ENUM_SINGLE(AK5558_01_POWER_MANAGEMENT2, 1, + ARRAY_SIZE(mono_5552_texts), mono_5552_texts), +}; + static const char * const digfil_texts[] = { "Sharp Roll-Off", "Show Roll-Off", "Short Delay Sharp Roll-Off", "Short Delay Show Roll-Off", @@ -74,6 +89,11 @@ static const struct snd_kcontrol_new ak5558_snd_controls[] = { SOC_ENUM("AK5558 Digital Filter", ak5558_adcset_enum[0]), }; +static const struct snd_kcontrol_new ak5552_snd_controls[] = { + SOC_ENUM("AK5552 Monaural Mode", ak5552_mono_enum[0]), + SOC_ENUM("AK5552 Digital Filter", ak5558_adcset_enum[0]), +}; + static const struct snd_soc_dapm_widget ak5558_dapm_widgets[] = { /* Analog Input */ SND_SOC_DAPM_INPUT("AIN1"), @@ -97,6 +117,17 @@ static const struct snd_soc_dapm_widget ak5558_dapm_widgets[] = { SND_SOC_DAPM_AIF_OUT("SDTO", "Capture", 0, SND_SOC_NOPM, 0, 0), }; +static const struct snd_soc_dapm_widget ak5552_dapm_widgets[] = { + /* Analog Input */ + SND_SOC_DAPM_INPUT("AIN1"), + SND_SOC_DAPM_INPUT("AIN2"), + + SND_SOC_DAPM_ADC("ADC Ch1", NULL, AK5558_00_POWER_MANAGEMENT1, 0, 0), + SND_SOC_DAPM_ADC("ADC Ch2", NULL, AK5558_00_POWER_MANAGEMENT1, 1, 0), + + SND_SOC_DAPM_AIF_OUT("SDTO", "Capture", 0, SND_SOC_NOPM, 0, 0), +}; + static const struct snd_soc_dapm_route ak5558_intercon[] = { {"ADC Ch1", NULL, "AIN1"}, {"SDTO", NULL, "ADC Ch1"}, @@ -123,6 +154,14 @@ static const struct snd_soc_dapm_route ak5558_intercon[] = { {"SDTO", NULL, "ADC Ch8"}, }; +static const struct snd_soc_dapm_route ak5552_intercon[] = { + {"ADC Ch1", NULL, "AIN1"}, + {"SDTO", NULL, "ADC Ch1"}, + + {"ADC Ch2", NULL, "AIN2"}, + {"SDTO", NULL, "ADC Ch2"}, +}; + static int ak5558_set_mcki(struct snd_soc_component *component) { return snd_soc_component_update_bits(component, AK5558_02_CONTROL1, AK5558_CKS, @@ -267,6 +306,18 @@ static struct snd_soc_dai_driver ak5558_dai = { .ops = &ak5558_dai_ops, }; +static struct snd_soc_dai_driver ak5552_dai = { + .name = "ak5558-aif", + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = AK5558_FORMATS, + }, + .ops = &ak5558_dai_ops, +}; + static void ak5558_power_off(struct ak5558_priv *ak5558) { if (!ak5558->reset_gpiod) @@ -354,6 +405,21 @@ static const struct snd_soc_component_driver soc_codec_dev_ak5558 = { .non_legacy_dai_naming = 1, }; +static const struct snd_soc_component_driver soc_codec_dev_ak5552 = { + .probe = ak5558_probe, + .remove = ak5558_remove, + .controls = ak5552_snd_controls, + .num_controls = ARRAY_SIZE(ak5552_snd_controls), + .dapm_widgets = ak5552_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak5552_dapm_widgets), + .dapm_routes = ak5552_intercon, + .num_dapm_routes = ARRAY_SIZE(ak5552_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + static const struct regmap_config ak5558_regmap = { .reg_bits = 8, .val_bits = 8, @@ -368,6 +434,7 @@ static int ak5558_i2c_probe(struct i2c_client *i2c) { struct ak5558_priv *ak5558; int ret = 0; + int dev_id; int i; ak5558 = devm_kzalloc(&i2c->dev, sizeof(*ak5558), GFP_KERNEL); @@ -396,11 +463,26 @@ static int ak5558_i2c_probe(struct i2c_client *i2c) return ret; } - ret = devm_snd_soc_register_component(&i2c->dev, - &soc_codec_dev_ak5558, - &ak5558_dai, 1); - if (ret) + dev_id = (uintptr_t)of_device_get_match_data(&i2c->dev); + switch (dev_id) { + case AK5552: + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_codec_dev_ak5552, + &ak5552_dai, 1); + break; + case AK5558: + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_codec_dev_ak5558, + &ak5558_dai, 1); + break; + default: + dev_err(&i2c->dev, "unexpected device type\n"); + return -EINVAL; + } + if (ret < 0) { + dev_err(&i2c->dev, "failed to register component: %d\n", ret); return ret; + } pm_runtime_enable(&i2c->dev); regcache_cache_only(ak5558->regmap, true); @@ -416,7 +498,8 @@ static int ak5558_i2c_remove(struct i2c_client *i2c) } static const struct of_device_id ak5558_i2c_dt_ids[] __maybe_unused = { - { .compatible = "asahi-kasei,ak5558"}, + { .compatible = "asahi-kasei,ak5558", .data = (void *) AK5558 }, + { .compatible = "asahi-kasei,ak5552", .data = (void *) AK5552 }, { } }; MODULE_DEVICE_TABLE(of, ak5558_i2c_dt_ids); From patchwork Tue Mar 30 06:32:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 411680 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4212639jai; Mon, 29 Mar 2021 23:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxgYZgOHcWgr48AT2ek99LeU+7b8FRqMs1QKJYoUdNZ0Xs+OIp3+O6WbNUO5WOWTvFocF4 X-Received: by 2002:a17:906:7c57:: with SMTP id g23mr31093934ejp.195.1617086866179; Mon, 29 Mar 2021 23:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617086866; cv=none; d=google.com; s=arc-20160816; b=s8RvqC80X6T0fYVCiuQcyG+lVBOeEdlsgnVNsbvHWUkpk86QCSANO9rKO4kfqpZXfN K3aWbEn1kN1gTByu9MFxY83DTQ5svyiL3XufyhytI2LGR3trSL8CAngzL63gmq5Nha1b EuMHyjLP1oMcMow8dVm+T3iYR/WuSOJvs625QPhgUA76FM+6J9dYNJuk1kVEIgsrDvgu AppEmfW/3KiaMEC+k/5dEE+y2ulYV+6sxC1HuMDFk1/EGTMI9KBYO1MOdAsuwIkQLI6n nJIxzi6yx68ymeH8rpLnWM33bux/2VJF0+QaZswQDbVbtfhNDHC72PBMLP2pRDvqbX4L 2jLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :to:from; bh=c3YxNJ+LMqH2T4cvl75Icr5BNUrx7tnMexgY94mNcCo=; b=AzuSRtx6rzLDiMOSeZo8RZAmCl7lxltU/fAV3Mf8Dt604g93Pd7i/TYNDVN4VvqPWR TcVmp8pieB2kVIqjtrWW9PxEpyyG+8VvOidzB/i/7F8qp+Ffi2m7oO4U5ZR+4askj3fK +nQSh3hhiuELz2ToX63uFdr+35mG1ZzJNjoQqBV0g6JpwYpwqk6CzDvxOonZimCgZfv/ mNthmxYIfVeorCpnrfFHEmAEdsOaE/zdW2O7p6DqO58j8ezfL9zdCzfRk+QUzzcedKX7 rG+my9Whj/jYkkXzuuJ8hm+lGaNeup0rjHeJWuaJm2Jesve78/DTatWNdBon+djLPthO M3Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si14341027edi.135.2021.03.29.23.47.45; Mon, 29 Mar 2021 23:47:46 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbhC3GrN (ORCPT + 6 others); Tue, 30 Mar 2021 02:47:13 -0400 Received: from inva021.nxp.com ([92.121.34.21]:35376 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbhC3Gq6 (ORCPT ); Tue, 30 Mar 2021 02:46:58 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 33F8B205963; Tue, 30 Mar 2021 08:46:55 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id DD3D7205912; Tue, 30 Mar 2021 08:46:51 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 6F8AF402F0; Tue, 30 Mar 2021 08:46:47 +0200 (CEST) From: Shengjiu Wang To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/2] ASoC: dt-bindings: ak5558: Add compatible string for ak5552 Date: Tue, 30 Mar 2021 14:32:52 +0800 Message-Id: <1617085972-6094-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617085972-6094-1-git-send-email-shengjiu.wang@nxp.com> References: <1617085972-6094-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add compatible string "asahi-kasei,ak5552" for ak5552 Signed-off-by: Shengjiu Wang --- Documentation/devicetree/bindings/sound/ak5558.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.27.0 Acked-by: Rob Herring diff --git a/Documentation/devicetree/bindings/sound/ak5558.txt b/Documentation/devicetree/bindings/sound/ak5558.txt index 36934098170c..e28708db6686 100644 --- a/Documentation/devicetree/bindings/sound/ak5558.txt +++ b/Documentation/devicetree/bindings/sound/ak5558.txt @@ -4,7 +4,7 @@ This device supports I2C mode only. Required properties: -- compatible : "asahi-kasei,ak5558" +- compatible : "asahi-kasei,ak5558" or "asahi-kasei,ak5552". - reg : The I2C address of the device. Optional properties: