Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7725648ioo; Fri, 3 Jun 2022 12:07:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbYmpOvUAQGkpWY0B9usf1C8VPML1WKaoYCsJixPwBoSvakLIb7SJnqwac4N26taHNSNqr X-Received: by 2002:a17:907:6295:b0:703:92b8:e113 with SMTP id nd21-20020a170907629500b0070392b8e113mr10275556ejc.594.1654283271078; Fri, 03 Jun 2022 12:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654283271; cv=none; d=google.com; s=arc-20160816; b=0zK2Za//s1y7wNIp1ImF0clxxisPiglD9fz6MTcl8l9wyHJX9QMPvY0SyxnbWlgooh yvoAv35fx5+tyTCDEcwdGscq269O4FC8JeznPZ1zBAT+c9FxBD9FrPCM463qF+Es7G7r 5CT0jnOe6+iYupkUx88gqlP7amiGR0O2WyieugxkG+FmOuWEmH+dxad089TbK9gQ4imj KNFjuBTSkFIxgImJqvsd9aALsFyFocWGpMGVIcoJ9xfBrP2OwQNHTXXyiISv28L+K8N1 Ly6EzoiEW0aVz/W6DcZ8Hkv+REjJkihEe8r4EE+B7hdVms3WUXokhkqMToJ2L7P3xIfN PhZQ== 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 :message-id:date:subject:cc:to:dkim-signature:from; bh=EtLUtGgtzmMn/jbekYRhgMbH2I3kcpmuGEIvnJpeso0=; b=JVKR0mM8NXMjUoq8Tv3GiokeLcCxASyEFub6Ws6z3glIw73F+WjnMGLm+W8nQ5MU/Q Qq3Gtxk92QvY3RuUkKhqU53DgLZzSmbXE0yXgV6hvrTNmW4BtS14kRaVvDaSlkrQs7MW gcBsVCw0JOOhqE2hSYYrMZc74s2XoflAqdRAKFU8p9srxT9K9XVlytC89oLbW0tbyRtd KzbH2EWGgkDunBZpnwFXrS5h+ZauLPQQbI9BQKzv70Mvnl/N0o4r+T7t0lric4JAfkuz 0kW9qdVypNcl2FqZJm/yb+Sbmv5yg5rKmAospdCahuSAqikw+zWmJgKtcg5HFVf7uRz4 JUfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shiftphones.com header.s=2018 header.b=b4JM09k7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020a50aacd000000b0042b34c92366si8038235edc.299.2022.06.03.12.07.25; Fri, 03 Jun 2022 12:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shiftphones.com header.s=2018 header.b=b4JM09k7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shiftphones.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237311AbiFBQxK (ORCPT + 99 others); Thu, 2 Jun 2022 12:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235643AbiFBQxD (ORCPT ); Thu, 2 Jun 2022 12:53:03 -0400 X-Greylist: delayed 445 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 02 Jun 2022 09:52:59 PDT Received: from mail.shift-gmbh.com (mail.shift-gmbh.com [85.10.195.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DCB027B9B0; Thu, 2 Jun 2022 09:52:59 -0700 (PDT) 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 Cc: phone-devel@vger.kernel.org, Stephan Gerhold , Liam Girdwood , Mark Brown , Rob Herring , 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 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 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Signed-off-by: Alexander Martinz --- 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 }, { } -- 2.36.1