From patchwork Thu Jun 17 08:52:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudius Heine X-Patchwork-Id: 463124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D04D7C2B9F4 for ; Thu, 17 Jun 2021 08:54:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F7BF60FF0 for ; Thu, 17 Jun 2021 08:54:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F7BF60FF0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3C8A716D9; Thu, 17 Jun 2021 10:53:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3C8A716D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623920067; bh=wpiUlIhIPjRAkxrI3DlHDqRPyMqLB8TuXwrTBuTuZ0o=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Pid+JwkWK39dP1Vc1kCZbovcACzLC1hPUKjdf4yFPbdNky6uObeFxqLwLtxAs3kFP 4eVgNNZytL9QjDz33ReRcq0OF9vnPY8Im350d+ZNoWGcFalSGVIeq7n/XZkXMvyWt1 6KvumpLnVptyFDCtceEeBNwvXPphPe6I5NAj7Fo0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ADE81F802A9; Thu, 17 Jun 2021 10:52:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1BD98F804BC; Thu, 17 Jun 2021 10:52:52 +0200 (CEST) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DF544F8025E for ; Thu, 17 Jun 2021 10:52:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DF544F8025E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="JuXzL/8V" Received: from localhost (dslb-084-062-104-230.084.062.pools.vodafone-ip.de [84.62.104.230]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ch@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 2FD3980488; Thu, 17 Jun 2021 10:52:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1623919964; bh=vC+2dzjgp/JxAjdCV0NbI2OvRkd+qLzEHvMIz/YJSvg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JuXzL/8Vx0sFPPmI50+yYILg74j+d8QYUN6Ncd/K6ISsGVbgSCingNM+HLY5NUtFn YZuiUfQgbhGkXbe+dKLp+46Ig4TggRBXQEB3katuNgg88553zS2swFe+6TxrcFLsUJ Bp6XYBlQBhsooL4HyHtOEFLMdgaZT5GaGwqrsTmouHQ6jQJRcZKpi2/EJen0Ltu8lS ySbjZgnsdVhJ9qmN4mpiqhT+0RpdaGh7i+PECUer03CNeU+5/ykYl4B6ysBIvcfrre YU+BHNxVs5vbTueRQHs8Var8BOEEe2ell0M7naE+qrM3lKO1ZrdDqzoqXO1tiMEXcY pLqTRU0Q4Qpxw== From: Claudius Heine To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, Marek Vasut , Claudius Heine , Kuninori Morimoto , Sia Jee Heng , Pierre-Louis Bossart , Michael Sit Wei Hong , Miquel Raynal , Matthias Schiffer , Annaliese McDermond , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/3] ASoC: tlv320aic32x4: add type to device private data struct Date: Thu, 17 Jun 2021 10:52:28 +0200 Message-Id: <20210617085230.1851503-2-ch@denx.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210617085230.1851503-1-ch@denx.de> References: <20210617085230.1851503-1-ch@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" While this driver can already handle different device variants, the variant information cannot be used in the driver code and therefor cannot have different code paths depending on the device variant. This change adds a `type` value into the `aic32x4_priv` structure, that contains a device variant identifier, which was set when the driver was bound to the device. Signed-off-by: Claudius Heine --- sound/soc/codecs/tlv320aic32x4-i2c.c | 20 ++++++++++++++++---- sound/soc/codecs/tlv320aic32x4-spi.c | 23 +++++++++++++++++++---- sound/soc/codecs/tlv320aic32x4.c | 3 +++ sound/soc/codecs/tlv320aic32x4.h | 5 +++++ 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/tlv320aic32x4-i2c.c b/sound/soc/codecs/tlv320aic32x4-i2c.c index 6d54cbf70a0b..247fb1e13674 100644 --- a/sound/soc/codecs/tlv320aic32x4-i2c.c +++ b/sound/soc/codecs/tlv320aic32x4-i2c.c @@ -16,6 +16,8 @@ #include "tlv320aic32x4.h" +static const struct of_device_id aic32x4_of_id[]; + static int aic32x4_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -27,6 +29,16 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c, config.val_bits = 8; regmap = devm_regmap_init_i2c(i2c, &config); + + if (i2c->dev.of_node) { + const struct of_device_id *oid; + + oid = of_match_node(aic32x4_of_id, i2c->dev.of_node); + dev_set_drvdata(&i2c->dev, (void *)oid->data); + } else if (id) { + dev_set_drvdata(&i2c->dev, (void *)id->driver_data); + } + return aic32x4_probe(&i2c->dev, regmap); } @@ -36,15 +48,15 @@ static int aic32x4_i2c_remove(struct i2c_client *i2c) } static const struct i2c_device_id aic32x4_i2c_id[] = { - { "tlv320aic32x4", 0 }, - { "tlv320aic32x6", 1 }, + { "tlv320aic32x4", (kernel_ulong_t)AIC32X4_TYPE_AIC32X4 }, + { "tlv320aic32x6", (kernel_ulong_t)AIC32X4_TYPE_AIC32X6 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id); static const struct of_device_id aic32x4_of_id[] = { - { .compatible = "ti,tlv320aic32x4", }, - { .compatible = "ti,tlv320aic32x6", }, + { .compatible = "ti,tlv320aic32x4", .data = (void *)AIC32X4_TYPE_AIC32X4 }, + { .compatible = "ti,tlv320aic32x6", .data = (void *)AIC32X4_TYPE_AIC32X6 }, { /* senitel */ } }; MODULE_DEVICE_TABLE(of, aic32x4_of_id); diff --git a/sound/soc/codecs/tlv320aic32x4-spi.c b/sound/soc/codecs/tlv320aic32x4-spi.c index a22e7700bfc8..e81c72958a82 100644 --- a/sound/soc/codecs/tlv320aic32x4-spi.c +++ b/sound/soc/codecs/tlv320aic32x4-spi.c @@ -16,6 +16,8 @@ #include "tlv320aic32x4.h" +static const struct of_device_id aic32x4_of_id[]; + static int aic32x4_spi_probe(struct spi_device *spi) { struct regmap *regmap; @@ -28,6 +30,19 @@ static int aic32x4_spi_probe(struct spi_device *spi) config.read_flag_mask = 0x01; regmap = devm_regmap_init_spi(spi, &config); + + if (spi->dev.of_node) { + const struct of_device_id *oid; + + oid = of_match_node(aic32x4_of_id, spi->dev.of_node); + dev_set_drvdata(&spi->dev, (void *)oid->data); + } else { + const struct spi_device_id *id_entry; + + id_entry = spi_get_device_id(spi); + dev_set_drvdata(&spi->dev, (void *)id_entry->driver_data); + } + return aic32x4_probe(&spi->dev, regmap); } @@ -37,15 +52,15 @@ static int aic32x4_spi_remove(struct spi_device *spi) } static const struct spi_device_id aic32x4_spi_id[] = { - { "tlv320aic32x4", 0 }, - { "tlv320aic32x6", 1 }, + { "tlv320aic32x4", (kernel_ulong_t)AIC32X4_TYPE_AIC32X4 }, + { "tlv320aic32x6", (kernel_ulong_t)AIC32X4_TYPE_AIC32X6 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(spi, aic32x4_spi_id); static const struct of_device_id aic32x4_of_id[] = { - { .compatible = "ti,tlv320aic32x4", }, - { .compatible = "ti,tlv320aic32x6", }, + { .compatible = "ti,tlv320aic32x4", .data = (void *)AIC32X4_TYPE_AIC32X4 }, + { .compatible = "ti,tlv320aic32x6", .data = (void *)AIC32X4_TYPE_AIC32X6 }, { /* senitel */ } }; MODULE_DEVICE_TABLE(of, aic32x4_of_id); diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index b689f26fc4be..70a1574fb72a 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -48,6 +48,7 @@ struct aic32x4_priv { struct aic32x4_setup_data *setup; struct device *dev; + enum aic32x4_type type; }; static int aic32x4_reset_adc(struct snd_soc_dapm_widget *w, @@ -1198,6 +1199,8 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap) return -ENOMEM; aic32x4->dev = dev; + aic32x4->type = (enum aic32x4_type)dev_get_drvdata(dev); + dev_set_drvdata(dev, aic32x4); if (pdata) { diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h index 7550122e9f8a..8a18dbec76a6 100644 --- a/sound/soc/codecs/tlv320aic32x4.h +++ b/sound/soc/codecs/tlv320aic32x4.h @@ -10,6 +10,11 @@ struct device; struct regmap_config; +enum aic32x4_type { + AIC32X4_TYPE_AIC32X4 = 0, + AIC32X4_TYPE_AIC32X6, +}; + extern const struct regmap_config aic32x4_regmap_config; int aic32x4_probe(struct device *dev, struct regmap *regmap); int aic32x4_remove(struct device *dev); From patchwork Thu Jun 17 08:52:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudius Heine X-Patchwork-Id: 462230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A035BC2B9F4 for ; Thu, 17 Jun 2021 08:54:34 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC55261245 for ; Thu, 17 Jun 2021 08:54:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC55261245 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4DE8A16E9; Thu, 17 Jun 2021 10:53:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4DE8A16E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623920072; bh=TJ94BIc5Y/rI2h8Plvg8qnFJbpAIpk49tsKvsh5vr7k=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V8Zh4hQLHJeHKhs+iO3wsbSYtWYEQ8wbxxclvRuel02I8W1BbhUkfWNxZWTuF/+u2 jUwozGIA1ogRYRq2eKBzJWzAqnorUIyWF4cN42jGOoVUMJjCQ1yXdLg8cT/ekFtBFw e8XcGJBFY8KHjHaJzkQz/B3DXTIIeQgW5x51qSsg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DBFABF804D8; Thu, 17 Jun 2021 10:52:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5D3C8F804D2; Thu, 17 Jun 2021 10:52:54 +0200 (CEST) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CE2DDF8028B for ; Thu, 17 Jun 2021 10:52:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CE2DDF8028B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="xb1oiVBU" Received: from localhost (dslb-084-062-104-230.084.062.pools.vodafone-ip.de [84.62.104.230]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ch@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 66EDB81E1C; Thu, 17 Jun 2021 10:52:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1623919967; bh=GkYhVu6GmZrM4digSTjDrFnhz57dLng0Yt11YKVUd7Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xb1oiVBUirW44xdRE9GYg6l64bFXK0ng/3xMS7zmJPHEW7RdR6xIypK+FhB9W5UUH e8YhH7R+Yj1+NGiMLKB7Kh1+P/5UUSNKEocUx2XJbyYrVNtX0qGHMkcMQjLe40h5Nv Q5kcsqfg6L/1dc/z6kvPbKzj3+RjOb/oQPoOfrTfAhngEHqdHWiZT/0ceiSpYM8Ne1 0HZv6lXympUSVaNFdu5uP00pAvAk6rWjv8BhZA5d9xo/Lb5/RGxIO5putpczMPIbwn PQ71vVPO+qrJ/A+Lm6ZT30RLiMQjlkcq88VTWVE2MszI23vKSmR+L3/RDE/EWEYYVT TJU6NljJyktcQ== From: Claudius Heine To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, Marek Vasut , Claudius Heine , Michael Sit Wei Hong , Pierre-Louis Bossart , Kuninori Morimoto , Sia Jee Heng , Annaliese McDermond , Matthias Schiffer , Miquel Raynal , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 2/3] ASoC: tlv320aic32x4: add support for TAS2505 Date: Thu, 17 Jun 2021 10:52:29 +0200 Message-Id: <20210617085230.1851503-3-ch@denx.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210617085230.1851503-1-ch@denx.de> References: <20210617085230.1851503-1-ch@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This adds support for TAS2505 and TAS2521 to the tlv320aic32x4 driver. The TAS2505 seems to be a stripped down version of the TLV320AIC32X4 so it makes sense to handle them in the same driver. Signed-off-by: Claudius Heine --- sound/soc/codecs/tlv320aic32x4-i2c.c | 2 + sound/soc/codecs/tlv320aic32x4.c | 136 ++++++++++++++++++++++++++- sound/soc/codecs/tlv320aic32x4.h | 5 + 3 files changed, 142 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/tlv320aic32x4-i2c.c b/sound/soc/codecs/tlv320aic32x4-i2c.c index 247fb1e13674..04ad38311360 100644 --- a/sound/soc/codecs/tlv320aic32x4-i2c.c +++ b/sound/soc/codecs/tlv320aic32x4-i2c.c @@ -50,6 +50,7 @@ static int aic32x4_i2c_remove(struct i2c_client *i2c) static const struct i2c_device_id aic32x4_i2c_id[] = { { "tlv320aic32x4", (kernel_ulong_t)AIC32X4_TYPE_AIC32X4 }, { "tlv320aic32x6", (kernel_ulong_t)AIC32X4_TYPE_AIC32X6 }, + { "tas2505", (kernel_ulong_t)AIC32X4_TYPE_TAS2505 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id); @@ -57,6 +58,7 @@ MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id); static const struct of_device_id aic32x4_of_id[] = { { .compatible = "ti,tlv320aic32x4", .data = (void *)AIC32X4_TYPE_AIC32X4 }, { .compatible = "ti,tlv320aic32x6", .data = (void *)AIC32X4_TYPE_AIC32X6 }, + { .compatible = "ti,tas2505", .data = (void *)AIC32X4_TYPE_TAS2505 }, { /* senitel */ } }; MODULE_DEVICE_TABLE(of, aic32x4_of_id); diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 70a1574fb72a..c63b717040ed 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -251,6 +251,9 @@ static DECLARE_TLV_DB_SCALE(tlv_driver_gain, -600, 100, 0); /* -12dB min, 0.5dB steps */ static DECLARE_TLV_DB_SCALE(tlv_adc_vol, -1200, 50, 0); +static DECLARE_TLV_DB_LINEAR(tlv_spk_vol, TLV_DB_GAIN_MUTE, 0); +static DECLARE_TLV_DB_SCALE(tlv_amp_vol, 0, 600, 1); + static const char * const lo_cm_text[] = { "Full Chip", "1.65V", }; @@ -1059,6 +1062,129 @@ static const struct snd_soc_component_driver soc_component_dev_aic32x4 = { .non_legacy_dai_naming = 1, }; +static const struct snd_kcontrol_new aic32x4_tas2505_snd_controls[] = { + SOC_DOUBLE_R_S_TLV("PCM Playback Volume", AIC32X4_LDACVOL, + AIC32X4_LDACVOL, 0, -0x7f, 0x30, 7, 0, tlv_pcm), + SOC_ENUM("DAC Playback PowerTune Switch", l_ptm_enum), + SOC_DOUBLE_R_S_TLV("HP Driver Playback Volume", AIC32X4_HPLGAIN, + AIC32X4_HPLGAIN, 0, -0x6, 0x1d, 5, 0, + tlv_driver_gain), + SOC_DOUBLE_R("HP DAC Playback Switch", AIC32X4_HPLGAIN, + AIC32X4_HPLGAIN, 6, 0x01, 1), + + SOC_SINGLE("Auto-mute Switch", AIC32X4_DACMUTE, 4, 7, 0), + + SOC_SINGLE_RANGE_TLV("Speaker Driver Playback Volume", TAS2505_SPKVOL1, + 0, 0, 117, 1, tlv_spk_vol), + SOC_SINGLE_TLV("Speaker Amplifier Playback Volume", TAS2505_SPKVOL2, + 4, 5, 0, tlv_amp_vol), +}; + +static const struct snd_kcontrol_new hp_output_mixer_controls[] = { + SOC_DAPM_SINGLE("DAC Switch", AIC32X4_HPLROUTE, 3, 1, 0), +}; + +static const struct snd_soc_dapm_widget aic32x4_tas2505_dapm_widgets[] = { + SND_SOC_DAPM_DAC("DAC", "Playback", AIC32X4_DACSETUP, 7, 0), + SND_SOC_DAPM_MIXER("HP Output Mixer", SND_SOC_NOPM, 0, 0, + &hp_output_mixer_controls[0], + ARRAY_SIZE(hp_output_mixer_controls)), + SND_SOC_DAPM_PGA("HP Power", AIC32X4_OUTPWRCTL, 5, 0, NULL, 0), + + SND_SOC_DAPM_PGA("Speaker Driver", TAS2505_SPK, 1, 0, NULL, 0), + + SND_SOC_DAPM_OUTPUT("HP"), + SND_SOC_DAPM_OUTPUT("Speaker"), +}; + +static const struct snd_soc_dapm_route aic32x4_tas2505_dapm_routes[] = { + /* Left Output */ + {"HP Output Mixer", "DAC Switch", "DAC"}, + + {"HP Power", NULL, "HP Output Mixer"}, + {"HP", NULL, "HP Power"}, + + {"Speaker Driver", NULL, "DAC"}, + {"Speaker", NULL, "Speaker Driver"}, +}; + +static struct snd_soc_dai_driver aic32x4_tas2505_dai = { + .name = "tas2505-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 1, + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = AIC32X4_FORMATS,}, + .ops = &aic32x4_ops, + .symmetric_rate = 1, +}; + +static int aic32x4_tas2505_component_probe(struct snd_soc_component *component) +{ + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component); + u32 tmp_reg; + int ret; + + struct clk_bulk_data clocks[] = { + { .id = "codec_clkin" }, + { .id = "pll" }, + { .id = "bdiv" }, + { .id = "mdac" }, + }; + + ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks); + if (ret) + return ret; + + if (aic32x4->setup) + aic32x4_setup_gpios(component); + + clk_set_parent(clocks[0].clk, clocks[1].clk); + clk_set_parent(clocks[2].clk, clocks[3].clk); + + /* Power platform configuration */ + if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE) + snd_soc_component_write(component, AIC32X4_PWRCFG, AIC32X4_AVDDWEAKDISABLE); + + tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ? + AIC32X4_LDOCTLEN : 0; + snd_soc_component_write(component, AIC32X4_LDOCTL, tmp_reg); + + tmp_reg = snd_soc_component_read(component, AIC32X4_CMMODE); + if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36) + tmp_reg |= AIC32X4_LDOIN_18_36; + if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED) + tmp_reg |= AIC32X4_LDOIN2HP; + snd_soc_component_write(component, AIC32X4_CMMODE, tmp_reg); + + /* + * Enable the fast charging feature and ensure the needed 40ms ellapsed + * before using the analog circuits. + */ + snd_soc_component_write(component, TAS2505_REFPOWERUP, + AIC32X4_REFPOWERUP_40MS); + msleep(40); + + return 0; +} + +static const struct snd_soc_component_driver soc_component_dev_aic32x4_tas2505 = { + .probe = aic32x4_tas2505_component_probe, + .set_bias_level = aic32x4_set_bias_level, + .controls = aic32x4_tas2505_snd_controls, + .num_controls = ARRAY_SIZE(aic32x4_tas2505_snd_controls), + .dapm_widgets = aic32x4_tas2505_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(aic32x4_tas2505_dapm_widgets), + .dapm_routes = aic32x4_tas2505_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(aic32x4_tas2505_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + static int aic32x4_parse_dt(struct aic32x4_priv *aic32x4, struct device_node *np) { @@ -1250,8 +1376,16 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap) if (ret) goto err_disable_regulators; - ret = devm_snd_soc_register_component(dev, + switch (aic32x4->type) { + case AIC32X4_TYPE_TAS2505: + ret = devm_snd_soc_register_component(dev, + &soc_component_dev_aic32x4_tas2505, &aic32x4_tas2505_dai, 1); + break; + default: + ret = devm_snd_soc_register_component(dev, &soc_component_dev_aic32x4, &aic32x4_dai, 1); + } + if (ret) { dev_err(dev, "Failed to register component\n"); goto err_disable_regulators; diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h index 8a18dbec76a6..e9fd2e55d6c3 100644 --- a/sound/soc/codecs/tlv320aic32x4.h +++ b/sound/soc/codecs/tlv320aic32x4.h @@ -13,6 +13,7 @@ struct regmap_config; enum aic32x4_type { AIC32X4_TYPE_AIC32X4 = 0, AIC32X4_TYPE_AIC32X6, + AIC32X4_TYPE_TAS2505, }; extern const struct regmap_config aic32x4_regmap_config; @@ -93,6 +94,9 @@ int aic32x4_register_clocks(struct device *dev, const char *mclk_name); #define AIC32X4_LOLGAIN AIC32X4_REG(1, 18) #define AIC32X4_LORGAIN AIC32X4_REG(1, 19) #define AIC32X4_HEADSTART AIC32X4_REG(1, 20) +#define TAS2505_SPK AIC32X4_REG(1, 45) +#define TAS2505_SPKVOL1 AIC32X4_REG(1, 46) +#define TAS2505_SPKVOL2 AIC32X4_REG(1, 48) #define AIC32X4_MICBIAS AIC32X4_REG(1, 51) #define AIC32X4_LMICPGAPIN AIC32X4_REG(1, 52) #define AIC32X4_LMICPGANIN AIC32X4_REG(1, 54) @@ -101,6 +105,7 @@ int aic32x4_register_clocks(struct device *dev, const char *mclk_name); #define AIC32X4_FLOATINGINPUT AIC32X4_REG(1, 58) #define AIC32X4_LMICPGAVOL AIC32X4_REG(1, 59) #define AIC32X4_RMICPGAVOL AIC32X4_REG(1, 60) +#define TAS2505_REFPOWERUP AIC32X4_REG(1, 122) #define AIC32X4_REFPOWERUP AIC32X4_REG(1, 123) /* Bits, masks, and shifts */ From patchwork Thu Jun 17 08:52:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudius Heine X-Patchwork-Id: 463123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DEA6C49EA2 for ; Thu, 17 Jun 2021 08:55:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD65960FF0 for ; Thu, 17 Jun 2021 08:55:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD65960FF0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 42AB516EF; Thu, 17 Jun 2021 10:54:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 42AB516EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623920112; bh=0JfZD3u5IFaUiozDYAt43Axmf4bDptnheqIAdh2Zo+s=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=flUo7skDTFGUyDayD5PORH2SU4X/37qdDOa1XqqmoONtUNvFi3J3A1krMiB8wkXyO RnIIdWhwAlexMRaZRWENqBuffgkI335BukqAaX82EIvQjLsLVWEvN1i6tnldATM+kg Z0Z/RBetIUhJATktPzRWi3hU28YcLZYtznOjuMoo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 29CB2F804E2; Thu, 17 Jun 2021 10:52:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 07646F804E3; Thu, 17 Jun 2021 10:52:57 +0200 (CEST) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 77366F8016D for ; Thu, 17 Jun 2021 10:52:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 77366F8016D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="iQgnirbV" Received: from localhost (dslb-084-062-104-230.084.062.pools.vodafone-ip.de [84.62.104.230]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ch@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 47B3982024; Thu, 17 Jun 2021 10:52:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1623919968; bh=xeDue/WnOOtGXp+2ku3MmnMQPyFPmeXZP5vSiFO0p24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQgnirbV2ldVLDDkgvLyQa3BRo6DqY1N3zdtuKIzLpuPGeF6gTGnQd/RGGB3TwXYI yRKBn11SbXvuA1QL6ybmL+L8m+0Rfcyq5SisjVg/60nnBv44Ynrs5t13Gq8oB4yJti OmVHcHsDrEHeS4cBe/u7tF+EzrTBmOJGRRxzQBfuIrgbMbEc8N0x8m8QlFUL6nqNnj Xx4xjONQJ+ysdZI3eh4pGJ/evCh4p81iDo44iXL6u3albdbI0p766tgkNCXAlrgfGB gYuOMXRN+shDYXSd6mo2rzS+XV0DxXyKmMmwBRgwQmCrACPHGQ+YZBwOwTuxnJRcVy fhTvA38OR7GMQ== From: Claudius Heine To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, Marek Vasut , Rob Herring , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 3/3] ASoC: tlv320aic32x4: dt-bindings: add TAS2505 to compatible Date: Thu, 17 Jun 2021 10:52:30 +0200 Message-Id: <20210617085230.1851503-4-ch@denx.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210617085230.1851503-1-ch@denx.de> References: <20210617085230.1851503-1-ch@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Cc: Claudius Heine X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This adds 'ti,tas2505' for TAS2505 to the list of allowed compatible strings. Signed-off-by: Claudius Heine --- Documentation/devicetree/bindings/sound/tlv320aic32x4.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/sound/tlv320aic32x4.txt b/Documentation/devicetree/bindings/sound/tlv320aic32x4.txt index ca75890f0d07..f59125bc79d1 100644 --- a/Documentation/devicetree/bindings/sound/tlv320aic32x4.txt +++ b/Documentation/devicetree/bindings/sound/tlv320aic32x4.txt @@ -6,6 +6,7 @@ Required properties: - compatible - "string" - One of: "ti,tlv320aic32x4" TLV320AIC3204 "ti,tlv320aic32x6" TLV320AIC3206, TLV320AIC3256 + "ti,tas2505" TAS2505, TAS2521 - reg: I2C slave address - supply-*: Required supply regulators are: "iov" - digital IO power supply