Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2063715iof; Tue, 7 Jun 2022 18:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxb0ReRBZa9Gu6a3TwRDlsj0zEboPRoVS9Axe9IsyLmwLg3bJnrEop2qx0zUufhqe9h6Ky X-Received: by 2002:a17:902:d54a:b0:167:879c:abdf with SMTP id z10-20020a170902d54a00b00167879cabdfmr10001663plf.73.1654651922193; Tue, 07 Jun 2022 18:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654651922; cv=none; d=google.com; s=arc-20160816; b=V79KDUkwjgN6xO62+P4hCXCWjLFVcGCyoRyZ+S/GHL4Wph0kNmeCzjRWaXzru4lDSM ihvorhTJj/p04Slyljdtwyp21L3ogYSb3/JCHxDEMQCRHo+1mi3NchogNWw/8V6eNbHn j8J8+ypPwFuTKmpUgw5VHvtHzOsdOWqVyB175C11MQonQ4IQZoh0ZuM+31M6dwDZRNde Sv0YljUqGJopI/O7JH7fhR1pLovYArZFIr9UqauLoVz6RWbl46vOaK5veebWwufk3Zk+ ZbZUAO5jJh7fsq+BAo+nvIVaSrnKqvf/EAJK5lrvw65+J3Soj9rd6ILCiAO02tY6HIOs Q7Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :from; bh=Asv1fLCYiPiifmvDhcl0BxRwcR2Y3nmkKTyFuAD1iew=; b=Po+O9ZJYH30lMr/L84v027WcJPBo85QpzNLFR4758bjeFVRv94pWhQdZEDLUl+QGFQ L97xNJnw7N6B60IkoqHmAj7XMH6EXFMyeuvjtP8yUvi7cuF3IPfLIsVDlZEDfpIQZTlZ rIK6I57YUPmzXM2vo/Km5OtfzwyA4MuH71EBGC46iGs3CKr55EES11P8q7x+ymjwiCV1 xxXDDOT0bhT30zLVpwmwHAXdQ8Ynnrs8fS85xGqqZXzb7uPtcVEmcGSS2ExjRbdX1qVL 3TX50P7iJ6a8UGw4+w6RE05qkhohrRt7mOIlRDJXSAo52503FF2H8lQTyN5Z9LZa7Ggu rj5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shiftphones.com header.s=2018 header.b=YHMAwMYT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shiftphones.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e7-20020a654787000000b003fdd5d89ba0si8113220pgs.228.2022.06.07.18.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 18:32:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@shiftphones.com header.s=2018 header.b=YHMAwMYT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shiftphones.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 90A7229A63D; Tue, 7 Jun 2022 18:23:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237838AbiFGHoo (ORCPT + 99 others); Tue, 7 Jun 2022 03:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235160AbiFGHon (ORCPT ); Tue, 7 Jun 2022 03:44:43 -0400 Received: from mail.shift-gmbh.com (mail.shift-gmbh.com [IPv6:2a01:4f8:a0:5496::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D816A2ED49; Tue, 7 Jun 2022 00:44:39 -0700 (PDT) From: Alexander Martinz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shiftphones.com; s=2018; t=1654587877; 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=Asv1fLCYiPiifmvDhcl0BxRwcR2Y3nmkKTyFuAD1iew=; b=YHMAwMYTWczcAj2vcskeAzuUVY+UHKweEBxCPj+RcGMEkxbufH/8VKVpi/dknM/AJEC1iL ogmsA73Oya9Fbyp8XaZ4gZJSWHKAlt+gbp7fcW0sMo8yYdKJJ4mBtK5emUjkbk7epOPz2W HHVRLErLaCVOjHZhaEJYCiIBqJVR3I0nLrXlyDhyAEEuGw9dcBh82zBun/wLPN2wqzyoEl vFcFZTom22STW2i+LoBy5aRQWburriZDzq+JF/KlxtGlPQjhFg28GtvRp3i5BasoLwj7L/ 52kN157aFcMiqQpb0G78DqKaRomxQ4gFjZXwSk6QKzjbZJwk59iXr5foaKs6ng== To: ~postmarketos/upstreaming@lists.sr.ht Cc: phone-devel@vger.kernel.org, Stephan Gerhold , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Connolly , Dylan Van Assche , Alexander Martinz Subject: [PATCH v2 2/2] ASoC: codecs: tfa989x: Add support for tfa9890 Date: Tue, 7 Jun 2022 09:43:31 +0200 Message-Id: <20220607074329.13129-2-amartinz@shiftphones.com> In-Reply-To: <20220607074329.13129-1-amartinz@shiftphones.com> References: <20220607074329.13129-1-amartinz@shiftphones.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: ORIGINATING; auth=pass smtp.auth=amartinz@shiftphones.com smtp.mailfrom=amartinz@shiftphones.com X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2: Fix comments regarding register access based on review feedback. 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..e6cb62165524 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; + + /* temporarily allow access to hidden registers */ + 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 registers 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 }, { } -- 2.36.1