From patchwork Fri Jun 2 04:09:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lin X-Patchwork-Id: 13264709 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 E0E5DC7EE24 for ; Fri, 2 Jun 2023 04:12:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9FED4828; Fri, 2 Jun 2023 06:11:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9FED4828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685679145; bh=Te9HOvLZpKtpHY+x8qQbBi4dpcZFdmf32iMXC7de5OM=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LxuqdHjxqvfBgGNqqZiioE3FprnGWvV9gVyiVk3JiJhVnWlT695d4My4iMFultarN wIZZ9yYCTGp6GtnRNUiGcXgHLrzrtd/FXnifL3squKtipAC4K6WYyvMEKZPQXfXXwA aL7GQnx+47gRXcPIpRdqVKm20xBVgVmtlLMrvgeY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BED89F8056F; Fri, 2 Jun 2023 06:10:38 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3291BF80552; Fri, 2 Jun 2023 06:10:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 623E4F8016B; Fri, 2 Jun 2023 06:10:15 +0200 (CEST) Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:704b::600]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 92F25F80149 for ; Fri, 2 Jun 2023 06:09:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 92F25F80149 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=nuvoton.com header.i=@nuvoton.com header.a=rsa-sha256 header.s=selector1 header.b=DGcrqQ4I ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nPv/tNMzAKBaW+msdWtJlINRkAwrFwswFBYz7EPZtcPh73OduY5PIZEVvpBu2KiVufe3de0f3oRb2kI5FqO4S9lf6WZ+vh4q05AGkez2CpE8d4eEs3O9Felip2R69r06H0hh/UBmrY/TjTnwNWUFgNMmItTEG7vKZo+GpHxCBFt4f+gxVCvKkagUes/zg17fvQUED9TBqfjY0h0OJGqoU+On/5Gp3JGi0h3NBW2LQje/lQ1ki0FIkVgvYKqdPPRhAzY0jEPd25XpQRgtnPFyPBYMKb/RQs+hk4r8SaM3bGkdh1ehgfkaQXz1BKHD9b2Es7Qh0xNIxOZxdccBk29p5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V0v0l7CcUK6IzqQladg5sFbCkEe8ah0B+Dgdc0TbeEw=; b=LHfKlB8svZqjblvMCyPlksXESqx/vwje7SbBYZOUCZm1YYVWgmZEgK8XHZfa74mNzvHcabdIsEPGKAnXPbLZopLc7QBu9Bsvq3vFN859XWHwPBbRVWR5wGadWwHguCM07LMBb8mOseozTHid1s9WwqcKYPPiEu7qtP7/CRl7u9+YLNSx4euGRpjeA5Jb7ziP+vmaWwsiepuEHs9Ty5apo6WMr23JRZ4N7TBIvDOWBFhMaq7aywKXZt8G+daijpNAn3VyCzlH3tFFwYF+S7aYOq17S4KRD3W7Ml+SJE/ty7LH1ebMv/MhKIU4RcxT0W6RixwMFdYaSagW1MPtBlPghg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 175.98.123.7) smtp.rcpttodomain=kernel.org smtp.mailfrom=nuvoton.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nuvoton.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuvoton.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V0v0l7CcUK6IzqQladg5sFbCkEe8ah0B+Dgdc0TbeEw=; b=DGcrqQ4IspsfE0wlcC0bY/H+XOu1U+89oTAJ35i2F6p2mJOcHz0CbQduRFtDXYASi1GZ5e0OVmC7FitRD5yOk96vrsvgDRsubn6EsJl+QGsZbWN4n2Ovai637lo04fggD1u8GUvVH1LyFFhgTn+v6Y1pG6Mz7YWSiwC6zlP9gL0= Received: from SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) by SEYPR03MB7046.apcprd03.prod.outlook.com (2603:1096:101:d0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.24; Fri, 2 Jun 2023 04:09:43 +0000 Received: from SG2APC01FT0060.eop-APC01.prod.protection.outlook.com (2603:1096:4:1:cafe::e2) by SG2PR06CA0189.outlook.office365.com (2603:1096:4:1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.24 via Frontend Transport; Fri, 2 Jun 2023 04:09:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 175.98.123.7) smtp.mailfrom=nuvoton.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nuvoton.com; Received-SPF: Pass (protection.outlook.com: domain of nuvoton.com designates 175.98.123.7 as permitted sender) receiver=protection.outlook.com; client-ip=175.98.123.7; helo=NTHCCAS04.nuvoton.com; pr=C Received: from NTHCCAS04.nuvoton.com (175.98.123.7) by SG2APC01FT0060.mail.protection.outlook.com (10.13.36.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.6455.13 via Frontend Transport; Fri, 2 Jun 2023 04:09:42 +0000 Received: from NTHCCAS02.nuvoton.com (10.1.9.121) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 2 Jun 2023 12:09:34 +0800 Received: from NTHCCAS04.nuvoton.com (10.1.8.29) by NTHCCAS02.nuvoton.com (10.1.9.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Fri, 2 Jun 2023 12:09:34 +0800 Received: from localhost.localdomain (10.11.36.27) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Fri, 2 Jun 2023 12:09:34 +0800 From: David Lin To: CC: , , , , , , , David Lin Subject: [PATCH 1/3] ASoC: nau8825: Add registers patch for NAU8825C Date: Fri, 2 Jun 2023 12:09:22 +0800 Message-ID: <20230602040924.188913-2-CTLIN0@nuvoton.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602040924.188913-1-CTLIN0@nuvoton.com> References: <20230602040924.188913-1-CTLIN0@nuvoton.com> MIME-Version: 1.0 X-NotSetDelaration: True X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2APC01FT0060:EE_|SEYPR03MB7046:EE_ X-MS-Office365-Filtering-Correlation-Id: c9bce271-97d0-44bb-63b4-08db631f315e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 569pVsYIBOmeaopJ79BFG4DYC/++Qcm0lVr9RjYJ8M54yTj++wOw5hIpOCcW+TxnG3TOUa/9UhqmuBIJG+R0b+bezqUrnJ5aBqSvSfJqmWHScmLQNODmJIGbPIFhQMyNWD0icdU5DICWJuTQRZbwvs3NIddB3pj5kaqLjiNdNTForYmg4hgrCL9oYZ7q1zOKmVL2tqhYE/5Ejs5cauwodLZjtQwtpkReZCOzEu52yLhOwbnrWblo3WkwQwzUs8oACRZdmVZKtq2a7QM5jjf2ZKE2qY+il0ZGtgo8hED+el9KkaODNpXCqGBOCL5xAwW3Klqfkxh25U+HAmCe7SMhIN+887zOY0Uv8BffA1AelQKAJQsb0HVMs5S6s83L0JUAWV+mT1UsgwGgdGmAmXcye/EECxjnpCqEQe5l7VqX5782L/epx9dat2gSSwGcuj+4+4a9IeDN23HQpSmvEcWE8BAf6I/ffmeg3//xbaFuj6PXB9sMV/tMbFrK6566VHM3XyYurYJD6CQ4EIgo/zphQ34koOTcv44gWx717DMzdbRFl13t1K2pZgV8IG34ecnSlIW2eSecbKEK4lMLxsAhh5U5hOZRbrIQU4sTUbjMnwwySbjYa4N3Ak7WTY7iaKlWLd2y9o3O7vO8fyCKFtyuXUkOltYSmgaUqP4A7rhlwNgKQM/qL8Z9SblbmkThFTQ4y1eyvzldRO+nNG3nENy/9pzV9v5kAh7weehOhbpfysdkyAyaHgL9UqYeh+Cah35UuKj4CzqZPobbZ7F4VNrBeEu574yVliqpXEbaEr2ytEY= X-Forefront-Antispam-Report: CIP:175.98.123.7;CTRY:TW;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:NTHCCAS04.nuvoton.com;PTR:175-98-123-7.static.tfn.net.tw;CAT:NONE;SFS:(13230028)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(4326008)(1076003)(107886003)(26005)(186003)(6666004)(36860700001)(47076005)(2616005)(426003)(336012)(83380400001)(41300700001)(5660300002)(316002)(8936002)(2906002)(8676002)(478600001)(54906003)(6916009)(70206006)(70586007)(86362001)(40480700001)(33656002)(36756003)(82740400003)(356005)(81166007)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: nuvoton.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 04:09:42.5368 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9bce271-97d0-44bb-63b4-08db631f315e X-MS-Exchange-CrossTenant-Id: a3f24931-d403-4b4a-94f1-7d83ac638e07 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a3f24931-d403-4b4a-94f1-7d83ac638e07;Ip=[175.98.123.7];Helo=[NTHCCAS04.nuvoton.com] X-MS-Exchange-CrossTenant-AuthSource: SG2APC01FT0060.eop-APC01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR03MB7046 Message-ID-Hash: 5JHDC4NWV5R6WA5446243OYJVFF44CRD X-Message-ID-Hash: 5JHDC4NWV5R6WA5446243OYJVFF44CRD X-MailFrom: CTLIN0@nuvoton.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The patch is to update default regmap and register a set of registers for NAU8825C. Signed-off-by: David Lin --- sound/soc/codecs/nau8825.c | 37 ++++++++++++++++++++++++++++++++++--- sound/soc/codecs/nau8825.h | 4 ++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index f6dd84b32e0b..91eb05899a88 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -178,6 +178,8 @@ static const struct reg_default nau8825_reg_defaults[] = { { NAU8825_REG_CLASSG_CTRL, 0x0 }, { NAU8825_REG_OPT_EFUSE_CTRL, 0x0 }, { NAU8825_REG_MISC_CTRL, 0x0 }, + { NAU8825_REG_FLL2_LOWER, 0x0 }, + { NAU8825_REG_FLL2_UPPER, 0x0 }, { NAU8825_REG_BIAS_ADJ, 0x0 }, { NAU8825_REG_TRIM_SETTINGS, 0x0 }, { NAU8825_REG_ANALOG_CONTROL_1, 0x0 }, @@ -200,6 +202,23 @@ static struct reg_default nau8825_xtalk_baktab[] = { { NAU8825_REG_DACR_CTRL, 0x02cf }, }; +/* The regmap patch for Rev C */ +static const struct reg_sequence nau8825_regmap_patch[] = { + { NAU8825_REG_FLL2, 0x0000 }, + { NAU8825_REG_FLL4, 0x8010 }, + { NAU8825_REG_FLL_VCO_RSV, 0x0bc0 }, + { NAU8825_REG_INTERRUPT_MASK, 0x0800 }, + { NAU8825_REG_DACL_CTRL, 0x00cf }, + { NAU8825_REG_DACR_CTRL, 0x02cf }, + { NAU8825_REG_OPT_EFUSE_CTRL, 0x0400 }, + { NAU8825_REG_FLL2_LOWER, 0x26e9 }, + { NAU8825_REG_FLL2_UPPER, 0x0031 }, + { NAU8825_REG_ANALOG_CONTROL_2, 0x0020 }, + { NAU8825_REG_ANALOG_ADC_2, 0x0220 }, + { NAU8825_REG_MIC_BIAS, 0x0046 }, +}; + + static const unsigned short logtable[256] = { 0x0000, 0x0171, 0x02e0, 0x044e, 0x05ba, 0x0725, 0x088e, 0x09f7, 0x0b5d, 0x0cc3, 0x0e27, 0x0f8a, 0x10eb, 0x124b, 0x13aa, 0x1508, @@ -855,7 +874,7 @@ static bool nau8825_readable_reg(struct device *dev, unsigned int reg) case NAU8825_REG_IMM_MODE_CTRL ... NAU8825_REG_IMM_RMS_R: case NAU8825_REG_CLASSG_CTRL ... NAU8825_REG_OPT_EFUSE_CTRL: case NAU8825_REG_MISC_CTRL: - case NAU8825_REG_I2C_DEVICE_ID ... NAU8825_REG_SARDOUT_RAM_STATUS: + case NAU8825_REG_I2C_DEVICE_ID ... NAU8825_REG_FLL2_UPPER: case NAU8825_REG_BIAS_ADJ: case NAU8825_REG_TRIM_SETTINGS ... NAU8825_REG_ANALOG_CONTROL_2: case NAU8825_REG_ANALOG_ADC_1 ... NAU8825_REG_MIC_BIAS: @@ -881,6 +900,7 @@ static bool nau8825_writeable_reg(struct device *dev, unsigned int reg) case NAU8825_REG_IMM_MODE_CTRL: case NAU8825_REG_CLASSG_CTRL ... NAU8825_REG_OPT_EFUSE_CTRL: case NAU8825_REG_MISC_CTRL: + case NAU8825_REG_FLL2_LOWER ... NAU8825_REG_FLL2_UPPER: case NAU8825_REG_BIAS_ADJ: case NAU8825_REG_TRIM_SETTINGS ... NAU8825_REG_ANALOG_CONTROL_2: case NAU8825_REG_ANALOG_ADC_1 ... NAU8825_REG_MIC_BIAS: @@ -2930,8 +2950,19 @@ static int nau8825_i2c_probe(struct i2c_client *i2c) ret); return ret; } - if ((value & NAU8825_SOFTWARE_ID_MASK) != - NAU8825_SOFTWARE_ID_NAU8825) { + nau8825->sw_id = value & NAU8825_SOFTWARE_ID_MASK; + switch (nau8825->sw_id) { + case NAU8825_SOFTWARE_ID_NAU8825: + break; + case NAU8825_SOFTWARE_ID_NAU8825C: + ret = regmap_register_patch(nau8825->regmap, nau8825_regmap_patch, + ARRAY_SIZE(nau8825_regmap_patch)); + if (ret) { + dev_err(dev, "Failed to register Rev C patch: %d\n", ret); + return ret; + } + break; + default: dev_err(dev, "Not a NAU8825 chip\n"); return -ENODEV; } diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h index 38ce052aed50..2abfbb5184da 100644 --- a/sound/soc/codecs/nau8825.h +++ b/sound/soc/codecs/nau8825.h @@ -75,6 +75,8 @@ #define NAU8825_REG_MISC_CTRL 0x55 #define NAU8825_REG_I2C_DEVICE_ID 0x58 #define NAU8825_REG_SARDOUT_RAM_STATUS 0x59 +#define NAU8825_REG_FLL2_LOWER 0x5a +#define NAU8825_REG_FLL2_UPPER 0x5b #define NAU8825_REG_BIAS_ADJ 0x66 #define NAU8825_REG_TRIM_SETTINGS 0x68 #define NAU8825_REG_ANALOG_CONTROL_1 0x69 @@ -386,6 +388,7 @@ #define NAU8825_GPIO2JD1 (1 << 7) #define NAU8825_SOFTWARE_ID_MASK 0x3 #define NAU8825_SOFTWARE_ID_NAU8825 0x0 +#define NAU8825_SOFTWARE_ID_NAU8825C 0x1 /* BIAS_ADJ (0x66) */ #define NAU8825_BIAS_HPR_IMP (1 << 15) @@ -497,6 +500,7 @@ struct nau8825 { struct clk *mclk; struct work_struct xtalk_work; struct semaphore xtalk_sem; + int sw_id; int irq; int mclk_freq; /* 0 - mclk is disabled */ int button_pressed; From patchwork Fri Jun 2 04:09:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lin X-Patchwork-Id: 13264708 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 E0B11C77B7A for ; Fri, 2 Jun 2023 04:12:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0541E825; Fri, 2 Jun 2023 06:11:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0541E825 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685679139; bh=U4Uovn0Yu4Un4bgVe+SSj5DK95lAwhixeE76YeMd1mM=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rQ1ULRT1+N/dI5pxlWKKxFIQfNw2H16kisx5aT6GPqwdeDsQXoZYtZgdRS479qbMS 90PjvTpGEC8N2ZiwDeIHXAgwMazFPcfrgIkiZ9kno2HzahlENFM0oasH1pfjonOipv FwmBUZCadDWcGdzbr/WWqL0c4UEIY8MlPUsEplqM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51567F8055B; Fri, 2 Jun 2023 06:10:38 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 556E3F80552; Fri, 2 Jun 2023 06:10:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A0C49F80199; Fri, 2 Jun 2023 06:10:07 +0200 (CEST) Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on20617.outbound.protection.outlook.com [IPv6:2a01:111:f400:feab::617]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2C419F80132 for ; Fri, 2 Jun 2023 06:09:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2C419F80132 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=nuvoton.com header.i=@nuvoton.com header.a=rsa-sha256 header.s=selector1 header.b=CTIG5mZR ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgmI1AsC7aQjX1oL+8AKLJyLQIdOU20WF3oEblr6neIckp8qdefkv17lk6cv7riikxAoahsr34AHPgTaNuG+iMVFkXHilhSXZu+bBvgTWpwaA8AxdA5Rc8HKnAb2+Ugs+974H7bgKu/9NV8TbDUtSkaQZj2WKvX/9SRYvTIZQMyZ5GMZYfMj1uGBPFv81CgUVdHr87beFrenVzUciKfEQswCjr9me8s7DeQqXhrTmLMqHWdQrGNI67r9r8FGuvxLFAVK8q5vu4xTh5H5WTfRmDyF+joG0mYXGs/cjnzn7iaStje6UEypw3bexEDdTXyPlzRATKBiq7de0p26JwdABQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rhht8zuMi5kGXVTf4/e7iN3inIGOZMgvVnME9QEXcmY=; b=GL8RsUm2YDDP53sGQrTAEZ5gFmr9/UDpK9dtuI8puZyBXO0LZ1aL7OIC4O0x/wNJOI00Bom3IRfpaLDQW5wzkNehJdwJ0K63tioNRnWGdwaI3JOYCyXK7TTUTizL5Vy/4oTdRVAjB9e2FHKoZbw95Z4z+Vy35BKWokaW8JeE51P+ZKW9SsoM4CEt2XbPutgDBKimrN3TTu+NJC0SAMirrA059r95DsIW+Q5yLXg4cq/33YsNjNN/RUfzdQrPmW98TTbraHCIUdJsqkwE4D9vbcAHK8gKWZtiM6zzdpVwQ++1rULXubGd/zX4oDGSPpC5R1s+EFs0v/nJ4byC+GonVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 175.98.123.7) smtp.rcpttodomain=kernel.org smtp.mailfrom=nuvoton.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nuvoton.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuvoton.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rhht8zuMi5kGXVTf4/e7iN3inIGOZMgvVnME9QEXcmY=; b=CTIG5mZRK8mEYbIkO39ROKm3GszoXMvOWezUbBnjxqRUvUdnIaG/ASPmS/AFl7XwVx/ezVIo/SiAbmKlE8JmMj0ZhmWWU+YnqgNBXivWm4RVuBsaf/cXV/f5PRyJdzCZkfKxRIlx1aMD5XTuke1VNH7M1A+JeHMbvRwCnj9teEM= Received: from SG2PR06CA0183.apcprd06.prod.outlook.com (2603:1096:4:1::15) by SEZPR03MB7680.apcprd03.prod.outlook.com (2603:1096:101:127::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23; Fri, 2 Jun 2023 04:09:41 +0000 Received: from SG2APC01FT0060.eop-APC01.prod.protection.outlook.com (2603:1096:4:1:cafe::38) by SG2PR06CA0183.outlook.office365.com (2603:1096:4:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.24 via Frontend Transport; Fri, 2 Jun 2023 04:09:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 175.98.123.7) smtp.mailfrom=nuvoton.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nuvoton.com; Received-SPF: Pass (protection.outlook.com: domain of nuvoton.com designates 175.98.123.7 as permitted sender) receiver=protection.outlook.com; client-ip=175.98.123.7; helo=NTHCCAS04.nuvoton.com; pr=C Received: from NTHCCAS04.nuvoton.com (175.98.123.7) by SG2APC01FT0060.mail.protection.outlook.com (10.13.36.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.6455.13 via Frontend Transport; Fri, 2 Jun 2023 04:09:41 +0000 Received: from NTHCCAS04.nuvoton.com (10.1.8.29) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 2 Jun 2023 12:09:34 +0800 Received: from localhost.localdomain (10.11.36.27) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Fri, 2 Jun 2023 12:09:34 +0800 From: David Lin To: CC: , , , , , , , David Lin Subject: [PATCH 2/3] ASoC: nau8825: Update the calculation of FLL for NAU8825C Date: Fri, 2 Jun 2023 12:09:23 +0800 Message-ID: <20230602040924.188913-3-CTLIN0@nuvoton.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602040924.188913-1-CTLIN0@nuvoton.com> References: <20230602040924.188913-1-CTLIN0@nuvoton.com> MIME-Version: 1.0 X-NotSetDelaration: True X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2APC01FT0060:EE_|SEZPR03MB7680:EE_ X-MS-Office365-Filtering-Correlation-Id: d3b469f0-9cd9-4ab0-1e26-08db631f30d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gHJqjWQ4Y2rPvm+hmtQrhgKwcxJdVFbzotP+HKmzV/IizKm2h7V/dpK9jzFRZFVkPfhrS5YaXNZJfD8rKZBph3yN3afkzqBfRjZRHzzJrk6bbVQDxdl9ckxqguYyQ8QGcTjDpKq42y1u9Od/1vmLavHjV4mbGqqY4Yv1hJ4Pq8kpEuoWdMwzUmQBfmkl+H0q+23ki2KEtczgANHu0hycQAIuUTUIASq7ngexaH+la6zdh4lD+efXWkwaFCEPApMze3ZrFBogmRkSN0v0VQIVa/xDe5BjjmNvFMz/bPabtwGD7dH46akbnZwi7CTcIHQ+JbuSaQOZhZQpISvRcBkpKJHJ0P7toPBOpBlb+McXbctjyKAqvpOsLx6ogPhaO6wUkuLpYu4U/7b204271VA1TJJE+W/UQjVRhCwh4ga1qlVYkj3HdsfiBzx/LxoMhrUJwRa10YupH3kV2Wpf6B6ORN9qNz38nixxFfGAxequOwV9ibkgreFS4PVs4HSenta54NLTUq3Gf+g3sAlj8i+GyofaPJmsyjQvKExqyzGxvfE1CzwiCDLQBmRt8WqiqsxbC3JLiofF3IpaEpy5qiawEmKu6iJXaShLEEZYbvwVC5DKxxC0OZtGa4EGl75WoRvbR/sBv0b/Vkb4IvY8WY494JdEJn9kfV+ni2IYBMn0lNf7QZzLsnLP2oXgZ+I/oH4vO05831n0w7C4iCAkGbfdM8cNbsgq/1mO5mL5E4KrlUkUgKQaPeLU+FhvSKzB1Wwm X-Forefront-Antispam-Report: CIP:175.98.123.7;CTRY:TW;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:NTHCCAS04.nuvoton.com;PTR:175-98-123-7.static.tfn.net.tw;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(39860400002)(396003)(136003)(451199021)(36840700001)(46966006)(40470700004)(83380400001)(316002)(81166007)(4326008)(6916009)(36860700001)(47076005)(54906003)(2616005)(336012)(426003)(40460700003)(82740400003)(70586007)(70206006)(40480700001)(356005)(2906002)(5660300002)(6666004)(15650500001)(478600001)(1076003)(26005)(186003)(107886003)(82310400005)(41300700001)(8676002)(86362001)(36756003)(33656002)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: nuvoton.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 04:09:41.6307 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3b469f0-9cd9-4ab0-1e26-08db631f30d4 X-MS-Exchange-CrossTenant-Id: a3f24931-d403-4b4a-94f1-7d83ac638e07 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a3f24931-d403-4b4a-94f1-7d83ac638e07;Ip=[175.98.123.7];Helo=[NTHCCAS04.nuvoton.com] X-MS-Exchange-CrossTenant-AuthSource: SG2APC01FT0060.eop-APC01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR03MB7680 Message-ID-Hash: QMXGCQZQ276OEWVRWGLYYN5ZR4MVRZMJ X-Message-ID-Hash: QMXGCQZQ276OEWVRWGLYYN5ZR4MVRZMJ X-MailFrom: CTLIN0@nuvoton.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The FLL is updated to 24 bit with lower power consumption. Signed-off-by: David Lin --- sound/soc/codecs/nau8825.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 91eb05899a88..e62f3d615b40 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -53,6 +53,7 @@ struct nau8825_fll { int mclk_src; int ratio; int fll_frac; + int fll_frac_num; int fll_int; int clk_ref_div; }; @@ -2360,9 +2361,12 @@ static int nau8825_calc_fll_param(unsigned int fll_in, unsigned int fs, /* Calculate the FLL 10-bit integer input and the FLL 16-bit fractional * input based on FDCO, FREF and FLL ratio. */ - fvco = div_u64(fvco_max << 16, fref * fll_param->ratio); - fll_param->fll_int = (fvco >> 16) & 0x3FF; - fll_param->fll_frac = fvco & 0xFFFF; + fvco = div_u64(fvco_max << fll_param->fll_frac_num, fref * fll_param->ratio); + fll_param->fll_int = (fvco >> fll_param->fll_frac_num) & 0x3FF; + if (fll_param->fll_frac_num == 16) + fll_param->fll_frac = fvco & 0xFFFF; + else + fll_param->fll_frac = fvco & 0xFFFFFF; return 0; } @@ -2376,8 +2380,16 @@ static void nau8825_fll_apply(struct nau8825 *nau8825, regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL1, NAU8825_FLL_RATIO_MASK | NAU8825_ICTRL_LATCH_MASK, fll_param->ratio | (0x6 << NAU8825_ICTRL_LATCH_SFT)); - /* FLL 16-bit fractional input */ - regmap_write(nau8825->regmap, NAU8825_REG_FLL2, fll_param->fll_frac); + /* FLL 16/24 bit fractional input */ + if (fll_param->fll_frac_num == 16) + regmap_write(nau8825->regmap, NAU8825_REG_FLL2, + fll_param->fll_frac); + else { + regmap_write(nau8825->regmap, NAU8825_REG_FLL2_LOWER, + fll_param->fll_frac & 0xffff); + regmap_write(nau8825->regmap, NAU8825_REG_FLL2_UPPER, + (fll_param->fll_frac >> 16) & 0xff); + } /* FLL 10-bit integer input */ regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL3, NAU8825_FLL_INTEGER_MASK, fll_param->fll_int); @@ -2419,6 +2431,11 @@ static int nau8825_set_pll(struct snd_soc_component *component, int pll_id, int struct nau8825_fll fll_param; int ret, fs; + if (nau8825->sw_id == NAU8825_SOFTWARE_ID_NAU8825) + fll_param.fll_frac_num = 16; + else + fll_param.fll_frac_num = 24; + fs = freq_out / 256; ret = nau8825_calc_fll_param(freq_in, fs, &fll_param); if (ret < 0) { From patchwork Fri Jun 2 04:09:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lin X-Patchwork-Id: 13264707 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 C04BEC7EE24 for ; Fri, 2 Jun 2023 04:11:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 52C0B206; Fri, 2 Jun 2023 06:10:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 52C0B206 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685679088; bh=fqNpOH+W/QSt26g7REj/C9i5JbLivTRaiu2cCcJT7nA=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=jPpOr8HK0yIQrcfmAGWEjy60tHsqzgZs9Q1cShXiA1WzePN6ge2AgrFpap/5BPng9 TGfbtIwwn87WkfFXVfuV8smlqF3E5fT/YG70W3kQIhDOvuPAU51JWO7Z68QvtMjAHP WDiskGAO7bjBNDvEDiImlcYvxignf1ZUaG2GjVQY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F3B9CF80149; Fri, 2 Jun 2023 06:10:36 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 732B3F80132; Fri, 2 Jun 2023 06:10:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 32861F8047D; Fri, 2 Jun 2023 06:10:04 +0200 (CEST) Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f403:704b::62d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2DCAEF800BD for ; Fri, 2 Jun 2023 06:09:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2DCAEF800BD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=nuvoton.com header.i=@nuvoton.com header.a=rsa-sha256 header.s=selector1 header.b=Mtg8aX9R ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UaEdkVtlETaszf7+pPpOFXAg5Me2AhALL1XNMyaVwoDPxklRAUe2SQ9p8R+ihyF59uhdUVinJoV/xvSRQSsP22+amaaAM9Tnnvj/YUZRa8xtpPRdmv8k3OwL7dtWM1LcpqwLLJJPO6TLbvggA4gdeT3YARYpITvBs9L5HKe5zchTV7JiJ0KY7VJpAzHHAB8LioLH0A5VHmB0xrO7g/EgvUfB6+WbLKAfY9Y2+sUFntQsDttgRWTnGWh8NxvMl/aKbQ1DHO2CEV/ovkEG5g39Snb+eQkwVbe5ePt/qUr6XKhrYYKnGpVeWmXrxCa7kXal2Uf033PTniE2Tg/J6oWwYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yyDmtDVVtgJsFv3He3qtMfNgzy2T9Dq9owX33MhSSpY=; b=Xq/Q1Lfc2g5grAr1RT4rtuf6fSIIdbEp7ZNpcurs15AUW/QW39g61aiTunLjKmHS+V+j5U9i18RHo9VY4TLwsQGUmzTM36CrQs8kQkGbusYaiI5419VPjRf+I+cY1fsSBcE+35bhnvnSO1u7vxolOYDJxjF9cE3ZjDDunRWky6AyHpB2mqmkovmo7pgIahB8q8pCVb7E0BfxLuNdMZw2UmzNvdyvgNsKwh0FgcIApDSE2MJqzcfq2kYomhnk77ndIhtStpQ+7CQegSsktXnFqBeAI0GKG/MrDWMqjtYGjV9SyVuzQ1bIp5G24YuBuzTw4vCkVVaKxkyUSEnusvlBkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 211.75.126.7) smtp.rcpttodomain=kernel.org smtp.mailfrom=nuvoton.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nuvoton.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuvoton.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yyDmtDVVtgJsFv3He3qtMfNgzy2T9Dq9owX33MhSSpY=; b=Mtg8aX9RAnWQA8lagZvSc9lDEyQEbo+qSKbOAgU6WyOt03+SY8F8Q2ssCUvFqN2g7EJNEyTjOzlMu2V0WjQ697Pca4Ckq2imkLsX9JeSPyKudXWzuMgTVXsCGpJQ+ZxMDchA6Iwbb4lA0ey8xeQzTbsLF1KkKc9FHg3/RR8Qldg= Received: from PS2PR01CA0033.apcprd01.prod.exchangelabs.com (2603:1096:300:58::21) by PUZPR03MB6856.apcprd03.prod.outlook.com (2603:1096:301:e4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23; Fri, 2 Jun 2023 04:09:37 +0000 Received: from PSAAPC01FT049.eop-APC01.prod.protection.outlook.com (2603:1096:300:58:cafe::68) by PS2PR01CA0033.outlook.office365.com (2603:1096:300:58::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.24 via Frontend Transport; Fri, 2 Jun 2023 04:09:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 211.75.126.7) smtp.mailfrom=nuvoton.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nuvoton.com; Received-SPF: Pass (protection.outlook.com: domain of nuvoton.com designates 211.75.126.7 as permitted sender) receiver=protection.outlook.com; client-ip=211.75.126.7; helo=NTHCCAS01.nuvoton.com; pr=C Received: from NTHCCAS01.nuvoton.com (211.75.126.7) by PSAAPC01FT049.mail.protection.outlook.com (10.13.39.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6455.24 via Frontend Transport; Fri, 2 Jun 2023 04:09:37 +0000 Received: from NTHCML01A.nuvoton.com (10.1.8.177) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 2 Jun 2023 12:09:35 +0800 Received: from NTHCCAS04.nuvoton.com (10.1.8.29) by NTHCML01A.nuvoton.com (10.1.8.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Fri, 2 Jun 2023 12:09:34 +0800 Received: from localhost.localdomain (10.11.36.27) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Fri, 2 Jun 2023 12:09:34 +0800 From: David Lin To: CC: , , , , , , , David Lin Subject: [PATCH 3/3] ASoC: nau8825: Update output control for NAU8825C Date: Fri, 2 Jun 2023 12:09:24 +0800 Message-ID: <20230602040924.188913-4-CTLIN0@nuvoton.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602040924.188913-1-CTLIN0@nuvoton.com> References: <20230602040924.188913-1-CTLIN0@nuvoton.com> MIME-Version: 1.0 X-NotSetDelaration: True X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PSAAPC01FT049:EE_|PUZPR03MB6856:EE_ X-MS-Office365-Filtering-Correlation-Id: 0403897d-2363-4ba5-68e8-08db631f2e7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pioqjfsd1Woi7RRp3qR9sFCEORwP6jDsqTcZC022a9VppePyCF/8XQ480dYxbxPasSViQNq8VbgZNqQb+/H1amrjiPDwtsH9IahwrRWeWvhkRP0XzI/15Quw1jB0pFOqL1vCadT0S3onP5vH7sjUg9Q5imsuD7XnSC5GReKwYIAMEhSEcAi/nRU8pqf5awavtpNEW0niZTV2se9IFtCmILecp6qMdet2Z7fXq8bQFsLZ+uBrS7SfPtGsCCvqI24BdVlxzb3HPN1itcKGsYMJD4bFoYHHSK2p+PAs3JnnA7emk+6HVy6+pc8Rml1mcZLYcP7xQ5WVkCN0vp5fQtSxB+FtRo1W/LyXfWMj1Y+x7GpkmUc21PBXKr48d+gUK0Q8deGwa6Em2tP94AQO31xFxEjpTjkY5zHe+7VioQgYvsxCV06IiJt5MAC284JWe1kVR0Yl0Pea4RwajuAduOAAEOYj/IHY2zMZKPkRWksZy5F2zqavkntm5HPNVoA+y6HD8hIjfOKaJKqgwNqOSgRE67nzT/ThQho6NQFExshdg1y/5mI5aXtGWjSGtIYUFPz9yZmuPnBqrpVrmKWAnYBhSQesJyqnNsarEnB/j9CdnFMfq71R6V9YZwj8/383vmv4X9t5pGJfvrGivAFj9Ua87HY9oxBZyDuj1yBJ1k8V0qrLA5ia2JTgG6Vf7UPN+raxV05bf5pscQO5O1EvdaUtoNtwfW2szSHuWDkbf83xOi0= X-Forefront-Antispam-Report: CIP:211.75.126.7;CTRY:TW;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:NTHCCAS01.nuvoton.com;PTR:211-75-126-7.hinet-ip.hinet.net;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199021)(36840700001)(46966006)(40470700004)(6916009)(54906003)(15650500001)(8936002)(8676002)(2906002)(70586007)(70206006)(41300700001)(5660300002)(316002)(4326008)(478600001)(6666004)(36860700001)(40460700003)(107886003)(356005)(81166007)(33656002)(186003)(26005)(40480700001)(1076003)(82740400003)(83380400001)(426003)(336012)(47076005)(36756003)(86362001)(82310400005)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: nuvoton.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 04:09:37.7004 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0403897d-2363-4ba5-68e8-08db631f2e7c X-MS-Exchange-CrossTenant-Id: a3f24931-d403-4b4a-94f1-7d83ac638e07 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a3f24931-d403-4b4a-94f1-7d83ac638e07;Ip=[211.75.126.7];Helo=[NTHCCAS01.nuvoton.com] X-MS-Exchange-CrossTenant-AuthSource: PSAAPC01FT049.eop-APC01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR03MB6856 Message-ID-Hash: UOLCCODITSCDT7JJ3JWMB777KCOJFCB4 X-Message-ID-Hash: UOLCCODITSCDT7JJ3JWMB777KCOJFCB4 X-MailFrom: CTLIN0@nuvoton.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Update the output control for NAU8825C. Signed-off-by: David Lin --- sound/soc/codecs/nau8825.c | 47 ++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index e62f3d615b40..9e0e4ddf128e 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -628,8 +628,13 @@ static void nau8825_xtalk_prepare(struct nau8825 *nau8825) regmap_update_bits(nau8825->regmap, NAU8825_REG_INTERRUPT_MASK, NAU8825_IRQ_RMS_EN, 0); /* Power up left and right DAC */ - regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, - NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, 0); + if (nau8825->sw_id == NAU8825_SOFTWARE_ID_NAU8825) + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, 0); + else + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL); } static void nau8825_xtalk_clean_dac(struct nau8825 *nau8825) @@ -642,9 +647,14 @@ static void nau8825_xtalk_clean_dac(struct nau8825 *nau8825) NAU8825_SPKR_DWN1R | NAU8825_SPKR_DWN1L, NAU8825_SPKR_DWN1R | NAU8825_SPKR_DWN1L); /* Power down left and right DAC */ - regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, - NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, - NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL); + if (nau8825->sw_id == NAU8825_SOFTWARE_ID_NAU8825) + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL); + else + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, 0); + /* Enable the TESTDAC and disable L/R HP impedance */ regmap_update_bits(nau8825->regmap, NAU8825_REG_BIAS_ADJ, NAU8825_BIAS_HPR_IMP | NAU8825_BIAS_HPL_IMP | @@ -1017,10 +1027,25 @@ static int nau8825_output_dac_event(struct snd_soc_dapm_widget *w, /* Disables the TESTDAC to let DAC signal pass through. */ regmap_update_bits(nau8825->regmap, NAU8825_REG_BIAS_ADJ, NAU8825_BIAS_TESTDAC_EN, 0); + if (nau8825->sw_id == NAU8825_SOFTWARE_ID_NAU8825) + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, 0); + else + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL); break; case SND_SOC_DAPM_POST_PMD: regmap_update_bits(nau8825->regmap, NAU8825_REG_BIAS_ADJ, NAU8825_BIAS_TESTDAC_EN, NAU8825_BIAS_TESTDAC_EN); + if (nau8825->sw_id == NAU8825_SOFTWARE_ID_NAU8825) + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL); + else + regmap_update_bits(nau8825->regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, 0); + break; default: return -EINVAL; @@ -1228,12 +1253,13 @@ static const struct snd_soc_dapm_widget nau8825_dapm_widgets[] = { NAU8825_REG_POWER_UP_CONTROL, 0, 0, NULL, 0), SND_SOC_DAPM_PGA_S("Output DACL", 7, - NAU8825_REG_CHARGE_PUMP, 8, 1, nau8825_output_dac_event, + SND_SOC_NOPM, 0, 0, nau8825_output_dac_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_PGA_S("Output DACR", 7, - NAU8825_REG_CHARGE_PUMP, 9, 1, nau8825_output_dac_event, + SND_SOC_NOPM, 0, 0, nau8825_output_dac_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + /* HPOL/R are ungrounded by disabling 16 Ohm pull-downs on playback */ SND_SOC_DAPM_PGA_S("HPOL Pulldown", 8, NAU8825_REG_HSD_CTRL, 0, 1, NULL, 0), @@ -2227,9 +2253,10 @@ static void nau8825_init_regs(struct nau8825 *nau8825) regmap_update_bits(regmap, NAU8825_REG_DAC_CTRL1, NAU8825_DAC_OVERSAMPLE_MASK, NAU8825_DAC_OVERSAMPLE_64); /* Disable DACR/L power */ - regmap_update_bits(regmap, NAU8825_REG_CHARGE_PUMP, - NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, - NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL); + if (nau8825->sw_id == NAU8825_SOFTWARE_ID_NAU8825) + regmap_update_bits(regmap, NAU8825_REG_CHARGE_PUMP, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL, + NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL); /* Enable TESTDAC. This sets the analog DAC inputs to a '0' input * signal to avoid any glitches due to power up transients in both * the analog and digital DAC circuit.