From patchwork Thu Jun 2 16:45:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Martinz X-Patchwork-Id: 578500 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D93EDC43334 for ; Fri, 3 Jun 2022 10:38:26 +0000 (UTC) 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 39C04182B; Fri, 3 Jun 2022 12:37:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 39C04182B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654252705; bh=lBR0PHCKTdFhrwXW+SXi2bkwp02US299GMkeMSQkacM=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=HQ5aqoQY09X4IR9Un+MpiBn741hDNjACdu5VlOavjtBZ0eUDgRjmw/HAqgEf0wtJi tvmlnkcyH1V2bdDQGygn7S2aD7+DCB12DoeZw9e0Nyw8tWoIIREiAjq8K834xkWlPG LjpBMnvVHIodBagW+H3dmvJCHbeLjwwj2jvohd4Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 85048F804F1; Fri, 3 Jun 2022 12:37:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 53646F80236; Thu, 2 Jun 2022 18:45:40 +0200 (CEST) Received: from mail.shift-gmbh.com (mail.shift-gmbh.com [85.10.195.145]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 156A7F80124 for ; Thu, 2 Jun 2022 18:45:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 156A7F80124 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=shiftphones.com header.i=@shiftphones.com header.b="b4JM09k7" From: Alexander Martinz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shiftphones.com; s=2018; t=1654188331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EtLUtGgtzmMn/jbekYRhgMbH2I3kcpmuGEIvnJpeso0=; b=b4JM09k7nFCSVq0T51RJbyb2fTAuM5XtI3WD+QMJwNzcS5nVhCZ5NiWjxFyxT2x068LG85 jWwCTMycoDmu1v3tSHXq3UE4X5AOLKIGRxPxiZBHZygfD5HoN4xGdreaOSSC0ljoeYw6mA qyorhrGR+M6x4g5qoOHJzNCQLM/pyvQF9i5ABm7gl7Ig/KizYeTMKSs4O/sZRbXNLZd0AW KNAQgjIbPJdVKdCwe9GrI3AQy+8YOcrlbQdjQIaiNQlM5Ygc2ovzjdeInwfA4qqpUWThGl G628nuK0mmtsW2H5+nGQZLDxBjPqRmWPJWZ53sGXiu9CvVxahMo1KbewQ2zZww== To: ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH 1/2] ASoC: codecs: tfa989x: Add support for tfa9890 Date: Thu, 2 Jun 2022 18:45:03 +0200 Message-Id: <20220602164504.261361-1-amartinz@shiftphones.com> MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=amartinz@shiftphones.com smtp.mailfrom=amartinz@shiftphones.com X-Mailman-Approved-At: Fri, 03 Jun 2022 12:37:02 +0200 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Stephan Gerhold , Dylan Van Assche , Alexander Martinz , linux-kernel@vger.kernel.org, Mark Brown , Takashi Iwai , Liam Girdwood , Caleb Connolly , Rob Herring , Krzysztof Kozlowski , phone-devel@vger.kernel.org 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" The initialization sequence is taken from the version provided by the supplier [1]. This allows speakers using the TFA9890 amplifier to work, which are used by various mobile phones such as the SHIFT6mq. [1]: https://source.codeaurora.org/external/mas/tfa98xx/tree/src/tfa_init.c?id=d2cd12931fbc48df988b62931fb9960d4e9dc05d#n1827 Signed-off-by: Alexander Martinz Reviewed-by: Stephan Gerhold --- sound/soc/codecs/tfa989x.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c index dc86852752c5..8ab2656de750 100644 --- a/sound/soc/codecs/tfa989x.c +++ b/sound/soc/codecs/tfa989x.c @@ -40,12 +40,14 @@ #define TFA989X_I2S_SEL_REG 0x0a #define TFA989X_I2S_SEL_REG_SPKR_MSK GENMASK(10, 9) /* speaker impedance */ #define TFA989X_I2S_SEL_REG_DCFG_MSK GENMASK(14, 11) /* DCDC compensation */ +#define TFA989X_HIDE_UNHIDE_KEY 0x40 #define TFA989X_PWM_CONTROL 0x41 #define TFA989X_CURRENTSENSE1 0x46 #define TFA989X_CURRENTSENSE2 0x47 #define TFA989X_CURRENTSENSE3 0x48 #define TFA989X_CURRENTSENSE4 0x49 +#define TFA9890_REVISION 0x80 #define TFA9895_REVISION 0x12 #define TFA9897_REVISION 0x97 @@ -188,6 +190,33 @@ static struct snd_soc_dai_driver tfa989x_dai = { .ops = &tfa989x_dai_ops, }; +static int tfa9890_init(struct regmap *regmap) +{ + int ret; + + /* unhide keys to allow updating them */ + ret = regmap_write(regmap, TFA989X_HIDE_UNHIDE_KEY, 0x5a6b); + if (ret) + return ret; + + /* update PLL registers */ + ret = regmap_set_bits(regmap, 0x59, 0x3); + if (ret) + return ret; + + /* hide keys again */ + ret = regmap_write(regmap, TFA989X_HIDE_UNHIDE_KEY, 0x0000); + if (ret) + return ret; + + return regmap_write(regmap, TFA989X_CURRENTSENSE2, 0x7BE1); +} + +static const struct tfa989x_rev tfa9890_rev = { + .rev = TFA9890_REVISION, + .init = tfa9890_init, +}; + static const struct reg_sequence tfa9895_reg_init[] = { /* some other registers must be set for optimal amplifier behaviour */ { TFA989X_BAT_PROT, 0x13ab }, @@ -376,6 +405,7 @@ static int tfa989x_i2c_probe(struct i2c_client *i2c) } static const struct of_device_id tfa989x_of_match[] = { + { .compatible = "nxp,tfa9890", .data = &tfa9890_rev }, { .compatible = "nxp,tfa9895", .data = &tfa9895_rev }, { .compatible = "nxp,tfa9897", .data = &tfa9897_rev }, { } From patchwork Thu Jun 2 16:45:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Martinz X-Patchwork-Id: 578765 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EED03C433EF for ; Fri, 3 Jun 2022 10:38:46 +0000 (UTC) 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 00AC91817; Fri, 3 Jun 2022 12:37:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 00AC91817 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654252725; bh=94AZfQNzohTSikU20D9y+1gErKKAeCfmcpY9ea6/fGk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YMriyhPyBlppYLkr7WHW/9rYqPRVuYD0x/jgFtcHMo/4IT4EygguF0w6VW4sWLihi lMf6Z1m3Iazj47TDlZo/ngMa71zY31KTWImDFpatIOm95syRnlIuDy2IUahHf9hUS8 +lLejryFZf4Z1kTwRzOgY1G5dme5lVoj6/PI/M2I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 28E44F80526; Fri, 3 Jun 2022 12:37:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B3C1F80149; Thu, 2 Jun 2022 18:45:43 +0200 (CEST) Received: from mail.shift-gmbh.com (mail.shift-gmbh.com [85.10.195.145]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 36881F80149 for ; Thu, 2 Jun 2022 18:45:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 36881F80149 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=shiftphones.com header.i=@shiftphones.com header.b="SPkvOhTj" From: Alexander Martinz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shiftphones.com; s=2018; t=1654188336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=imGM7saNPOQ6vbKogvcqXOICfijWBW6J11L5perWAFg=; b=SPkvOhTj83B6oiJW3ZAr24eQ87yTw5YKMp8thSdc+8WpuYXGlWvxUk4x3VYgij5bb4pOhs dQbS4mOPX1RWY/Pu1wgAh41UG3hwC2EZcw7HcMoEg1c33blT+f7q5V4f9tTARR3kOdlYZP CaQTjPSJF7G4uIaPouDVMMwa6fYRIa1l9h+NRSaZF55+ua8vne/ugrWaUnXXmUk09tKKKm dnW8FXetCsw1XtkBuauUiw366+SuKbEOwAmKxtDq9Lostm16iyTS7ZfyVurzQf4wiS30LI ftKT364RV/wmI64x5etHJMHvwIOyC0MmW06r1LmlAzXMSc6SM1CKtYNnKPxrAg== To: ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH 2/2] ASoC: dt-bindings: nxp,tfa989x: Add tfa9890 support Date: Thu, 2 Jun 2022 18:45:04 +0200 Message-Id: <20220602164504.261361-2-amartinz@shiftphones.com> In-Reply-To: <20220602164504.261361-1-amartinz@shiftphones.com> References: <20220602164504.261361-1-amartinz@shiftphones.com> MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=amartinz@shiftphones.com smtp.mailfrom=amartinz@shiftphones.com X-Mailman-Approved-At: Fri, 03 Jun 2022 12:37:02 +0200 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Stephan Gerhold , Dylan Van Assche , Alexander Martinz , linux-kernel@vger.kernel.org, Mark Brown , Takashi Iwai , Liam Girdwood , Caleb Connolly , Rob Herring , Krzysztof Kozlowski , phone-devel@vger.kernel.org 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" Document TFA9890 binding for tfa989x. Signed-off-by: Alexander Martinz Reviewed-by: Stephan Gerhold Acked-by: Rob Herring --- Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml index b9b1dba40856..7f2e68ff6d34 100644 --- a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml +++ b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml @@ -15,6 +15,7 @@ allOf: properties: compatible: enum: + - nxp,tfa9890 - nxp,tfa9895 - nxp,tfa9897