From patchwork Wed Sep 7 13:57:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Astrid Rost X-Patchwork-Id: 12969754 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 0555EECAAD5 for ; Thu, 8 Sep 2022 08:19:19 +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 F37F916B3; Thu, 8 Sep 2022 10:18:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F37F916B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1662625158; bh=dgxKMdUcEEqzB3+/56Ev+52SaodgllPzde81zk+gxm0=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=KzoJEqMMTzM+nH3QrzDrun85doXW4Kzit0QApZNabIWCGS3gsIUFaR9DazsTvDf4r o1JuL2eG1a3vtSTOdGlkV66LYOGuDXdpTo/abE/xHR2NVMFt2CIxYZ2e9AKBh7MD63 ONkcfqIlZJCeADIcAtcJZyPtGP0a2581ko42MFwU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9E5DAF801F7; Thu, 8 Sep 2022 10:18:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 15C6FF8023B; Wed, 7 Sep 2022 15:57:28 +0200 (CEST) Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) (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 6B1E9F8023B for ; Wed, 7 Sep 2022 15:57:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6B1E9F8023B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=axis.com header.i=@axis.com header.b="D2Rd3aiJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1662559042; x=1694095042; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QRrtf0z8byXtDSLxOTZdZ1/pRN/4ljMiBiyuNUzrFI8=; b=D2Rd3aiJu0aLROEYyGQ2YvZZCV7aJrc+YgFhkQkqaSOStB1zjPrQQt9G g1K5n25aAVJLmee41Szyswkii7xkFwUMOhV5cehA5TZQQ0/Nu2quK91yn OVjkWU8vUrPoVRMtz1SR+qYPWdmht7xy68yeLtMzMi+SvnHNu4jif6KbD fXiXZ+f0VtXx3s/SXncL2lKGuY9jSWobHXlzXHcYMiPpaxETQjH1bJHqU m3b9XTkLIGeqE6xRVSo20RABvUoogZnHPieMx4xAseqMLyqJNRT+Y2+c5 Mtv1GLvICnJ/iI7AhvpXa2Z6krbGPRaKwUcyFy0jo9hb5ITwKYlF2h6OQ Q==; From: Astrid Rost To: Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai Subject: [PATCH] ASoC: ts3a227e: add parameters to control debounce times Date: Wed, 7 Sep 2022 15:57:07 +0200 Message-ID: <20220907135707.15836-1-astrid.rost@axis.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 08 Sep 2022 10:18:26 +0200 Cc: alsa-devel-mejlinglistan , kernel@axis.com, Astrid Rost , linux-kernel@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" Add devicetree parameters to control the insertion, release and press debounce times. Signed-off-by: Astrid Rost --- sound/soc/codecs/ts3a227e.c | 48 +++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index d8ab0810fceb..fea274a0a91b 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -78,12 +78,20 @@ static const int ts3a227e_buttons[] = { #define ADC_COMPLETE_INT_DISABLE 0x04 #define INTB_DISABLE 0x08 +/* TS3A227E_REG_SETTING_1 0x4 */ +#define DEBOUNCE_INSERTION_SETTING_SFT (0) +#define DEBOUNCE_INSERTION_SETTING_MASK (0x7 << DEBOUNCE_PRESS_SETTING_SFT) + /* TS3A227E_REG_SETTING_2 0x05 */ #define KP_ENABLE 0x04 /* TS3A227E_REG_SETTING_3 0x06 */ -#define MICBIAS_SETTING_SFT (3) +#define MICBIAS_SETTING_SFT 3 #define MICBIAS_SETTING_MASK (0x7 << MICBIAS_SETTING_SFT) +#define DEBOUNCE_RELEASE_SETTING_SFT 2 +#define DEBOUNCE_RELEASE_SETTING_MASK (0x1 << DEBOUNCE_RELEASE_SETTING_SFT) +#define DEBOUNCE_PRESS_SETTING_SFT 0 +#define DEBOUNCE_PRESS_SETTING_MASK (0x3 << DEBOUNCE_PRESS_SETTING_SFT) /* TS3A227E_REG_ACCESSORY_STATUS 0x0b */ #define TYPE_3_POLE 0x01 @@ -136,7 +144,7 @@ static bool ts3a227e_volatile_reg(struct device *dev, unsigned int reg) { switch (reg) { case TS3A227E_REG_INTERRUPT ... TS3A227E_REG_INTERRUPT_DISABLE: - case TS3A227E_REG_SETTING_2: + case TS3A227E_REG_SETTING_1 ... TS3A227E_REG_SETTING_2: case TS3A227E_REG_SWITCH_STATUS_1 ... TS3A227E_REG_ADC_OUTPUT: return true; default: @@ -269,16 +277,42 @@ static const struct regmap_config ts3a227e_regmap_config = { static int ts3a227e_parse_device_property(struct ts3a227e *ts3a227e, struct device *dev) { - u32 micbias; + u32 value; + u32 setting3_value = 0; + u32 setting3_mask = 0; int err; - err = device_property_read_u32(dev, "ti,micbias", &micbias); + err = device_property_read_u32(dev, "ti,micbias", &value); if (!err) { - regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3, - MICBIAS_SETTING_MASK, - (micbias & 0x07) << MICBIAS_SETTING_SFT); + setting3_mask = MICBIAS_SETTING_MASK; + setting3_value = + (value << MICBIAS_SETTING_SFT) & MICBIAS_SETTING_MASK; + } + + err = device_property_read_u32(dev, "ti,debounce-release", &value); + if (!err) { + setting3_mask |= DEBOUNCE_RELEASE_SETTING_MASK; + setting3_value |= (value << DEBOUNCE_RELEASE_SETTING_SFT) & + DEBOUNCE_RELEASE_SETTING_MASK; } + err = device_property_read_u32(dev, "ti,debounce-press", &value); + if (!err) { + setting3_mask |= DEBOUNCE_PRESS_SETTING_MASK; + setting3_value |= (value << DEBOUNCE_PRESS_SETTING_SFT) & + DEBOUNCE_PRESS_SETTING_MASK; + } + + if (setting3_mask) + regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3, + setting3_mask, setting3_value); + + err = device_property_read_u32(dev, "ti,debounce-insertion", &value); + if (!err) + regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_1, + DEBOUNCE_INSERTION_SETTING_MASK, (value << DEBOUNCE_INSERTION_SETTING_SFT) + & DEBOUNCE_INSERTION_SETTING_MASK); + return 0; }