Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2657212ybi; Mon, 17 Jun 2019 08:25:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPAaPJLSKqtcKb1LyYwpOHzIf9qMvaKBLOkAuskFtFODwxP9RBSVO8aiq9KF/kqBkaaBVw X-Received: by 2002:a17:902:934a:: with SMTP id g10mr98508131plp.18.1560785107034; Mon, 17 Jun 2019 08:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560785107; cv=none; d=google.com; s=arc-20160816; b=0iLhXnbpQdSTgEb20vIWfhTsRo0qnrpE5SGqq2sEJ6f+hQXCeVrhGgdRUy5xFh0Evc jVy+1xFoko/11kBC5SAYQ1QDPkbaHGFWzXKdB1bi8ftwF5+cPpivgDKD6l/TBvfAdOgx ZeoBir5GWKMUr8HrGqtZ6lzY8otJBBPDzpm0fqJxGO9sqj6KgqMC2rycxmLnI8BgVwIm e75nxQKGhpojEseNtQmeZI9/3U0oQ8mbDgU7hOebXmVEeJMB8XouOjC939txjS3ZoTOd mKUXlkMyTBBu8HvS6gaccWi3FIke49fGFgxynI9K4m3fRJvZAGhm3hFistN6/iVs69Qi HPvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=wOd9Qi3GjEKts3WISLUYsBotXm/VRmWrNM78cMe3Cjw=; b=jkjMHNjCT0mVOpNv8N9M+0FcoQ1T52nPKDzIj2R1YoKtARPdA2HjcX7CvxRxnp4OB3 FP4zOguzhzIJJB/uCQFh6JG0bE0Zxr42sk2Qo3d+gvYrseHm+NXF9Yr7n/TqQIHEeQsS 7GHc3rWyNQpqDwFRKTHUv6JD8pyrAPSDZTDdtV2GmzW8ia6h1OC6ASW+GhQnltqYe7FX DcItLyjou6fAu0y0Ds7hPpzT63JfEiy3MBuZIbezv5r8xvljqoaJ0pihw190PDHyx85e BnXi5lbjCMdJfB214n7BvIcnAta7/5OVwXn2xXCamr4oDEMxXHMmkmm9qJR+eVtUXu/A uk8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=N7RxbLBU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si10842990pfh.56.2019.06.17.08.24.51; Mon, 17 Jun 2019 08:25:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=N7RxbLBU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728582AbfFQPYb (ORCPT + 99 others); Mon, 17 Jun 2019 11:24:31 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:51328 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728540AbfFQPY0 (ORCPT ); Mon, 17 Jun 2019 11:24:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=wOd9Qi3GjEKts3WISLUYsBotXm/VRmWrNM78cMe3Cjw=; b=N7RxbLBUWdzg PeQTW1bRfWlwWuT6qrA66B6HGk8eyu8HgivLsK2yq3RXzouBzUwcdzFMDxtq+rBmObnFRm0oQkclL 0edfnJ5iGch3mRGWSg+sOGqJvh3gQ1/5mvJtwn/HFG6NVSy6d/PSHKXwLgFYzPK//1vc1eJbumoo9 fMyXE=; Received: from [2001:470:1f1d:6b5:7e7a:91ff:fede:4a45] (helo=finisterre.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hctUX-0001wr-0D; Mon, 17 Jun 2019 15:24:17 +0000 Received: by finisterre.sirena.org.uk (Postfix, from userid 1000) id 5C81C440046; Mon, 17 Jun 2019 16:24:16 +0100 (BST) From: Mark Brown To: Fletcher Woodruff Cc: alsa-devel@alsa-project.org, Ben Zhang , Curtis Malainey , Jaroslav Kysela , Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown , Oder Chiou , Ross Zwisler , Takashi Iwai Subject: Applied "ASoC: rt5677: move jack-detect init to i2c probe" to the asoc tree In-Reply-To: <20190614194854.208436-3-fletcherw@chromium.org> X-Patchwork-Hint: ignore Message-Id: <20190617152416.5C81C440046@finisterre.sirena.org.uk> Date: Mon, 17 Jun 2019 16:24:16 +0100 (BST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch ASoC: rt5677: move jack-detect init to i2c probe has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 241800642ea3482ab3f80a2a3662e9f2e6a82208 Mon Sep 17 00:00:00 2001 From: Fletcher Woodruff Date: Fri, 14 Jun 2019 13:48:52 -0600 Subject: [PATCH] ASoC: rt5677: move jack-detect init to i2c probe This patch moves the code to select the gpios for jack detection from rt5677_probe to rt5677_init_irq (called from rt5677_i2c_probe). It also sets some registers to fix bugs related to jack detection, and adds some constants and comments to make it easier to understand what certain register settings are controlling. Signed-off-by: Ben Zhang Signed-off-by: Fletcher Woodruff Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 60 ++++++++++++++++++++++----------------- sound/soc/codecs/rt5677.h | 6 ++++ 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index fe000f30b9ad..87a92ba0d040 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4716,37 +4716,13 @@ static int rt5677_probe(struct snd_soc_component *component) snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); - regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020); + regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, + ~RT5677_IRQ_DEBOUNCE_SEL_MASK, 0x0020); regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00); for (i = 0; i < RT5677_GPIO_NUM; i++) rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]); - if (rt5677->irq_data) { - regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, 0x8000, - 0x8000); - regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x0018, - 0x0008); - - if (rt5677->pdata.jd1_gpio) - regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, - RT5677_SEL_GPIO_JD1_MASK, - rt5677->pdata.jd1_gpio << - RT5677_SEL_GPIO_JD1_SFT); - - if (rt5677->pdata.jd2_gpio) - regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, - RT5677_SEL_GPIO_JD2_MASK, - rt5677->pdata.jd2_gpio << - RT5677_SEL_GPIO_JD2_SFT); - - if (rt5677->pdata.jd3_gpio) - regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, - RT5677_SEL_GPIO_JD3_MASK, - rt5677->pdata.jd3_gpio << - RT5677_SEL_GPIO_JD3_SFT); - } - mutex_init(&rt5677->dsp_cmd_lock); mutex_init(&rt5677->dsp_pri_lock); @@ -5096,6 +5072,7 @@ static int rt5677_init_irq(struct i2c_client *i2c) { int ret; struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); + unsigned int jd_mask = 0, jd_val = 0; if (!rt5677->pdata.jd1_gpio && !rt5677->pdata.jd2_gpio && @@ -5107,6 +5084,37 @@ static int rt5677_init_irq(struct i2c_client *i2c) return -EINVAL; } + /* + * Select RC as the debounce clock so that GPIO works even when + * MCLK is gated which happens when there is no audio stream + * (SND_SOC_BIAS_OFF). + */ + regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, + RT5677_IRQ_DEBOUNCE_SEL_MASK, + RT5677_IRQ_DEBOUNCE_SEL_RC); + + /* Enable auto power on RC when GPIO states are changed */ + regmap_update_bits(rt5677->regmap, RT5677_GEN_CTRL1, 0xff, 0xff); + + /* Select and enable jack detection sources per platform data */ + if (rt5677->pdata.jd1_gpio) { + jd_mask |= RT5677_SEL_GPIO_JD1_MASK; + jd_val |= rt5677->pdata.jd1_gpio << RT5677_SEL_GPIO_JD1_SFT; + } + if (rt5677->pdata.jd2_gpio) { + jd_mask |= RT5677_SEL_GPIO_JD2_MASK; + jd_val |= rt5677->pdata.jd2_gpio << RT5677_SEL_GPIO_JD2_SFT; + } + if (rt5677->pdata.jd3_gpio) { + jd_mask |= RT5677_SEL_GPIO_JD3_MASK; + jd_val |= rt5677->pdata.jd3_gpio << RT5677_SEL_GPIO_JD3_SFT; + } + regmap_update_bits(rt5677->regmap, RT5677_JD_CTRL1, jd_mask, jd_val); + + /* Set GPIO1 pin to be IRQ output */ + regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1, + RT5677_GPIO1_PIN_MASK, RT5677_GPIO1_PIN_IRQ); + ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0, &rt5677_irq_chip, &rt5677->irq_data); diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index 076e5161d8da..c26edd387e34 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -1664,6 +1664,12 @@ #define RT5677_GPIO6_P_NOR (0x0 << 0) #define RT5677_GPIO6_P_INV (0x1 << 0) +/* General Control (0xfa) */ +#define RT5677_IRQ_DEBOUNCE_SEL_MASK (0x3 << 3) +#define RT5677_IRQ_DEBOUNCE_SEL_MCLK (0x0 << 3) +#define RT5677_IRQ_DEBOUNCE_SEL_RC (0x1 << 3) +#define RT5677_IRQ_DEBOUNCE_SEL_SLIM (0x2 << 3) + /* Virtual DSP Mixer Control (0xf7 0xf8 0xf9) */ #define RT5677_DSP_IB_01_H (0x1 << 15) #define RT5677_DSP_IB_01_H_SFT 15 -- 2.20.1