From patchwork Mon Apr 1 20:55:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fletcher Woodruff X-Patchwork-Id: 10885069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D65817E0 for ; Thu, 4 Apr 2019 07:07:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28A8128384 for ; Thu, 4 Apr 2019 07:07:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CCD22874E; Thu, 4 Apr 2019 07:07:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0CB7928384 for ; Thu, 4 Apr 2019 07:06:52 +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 77ACF1636; Thu, 4 Apr 2019 08:40:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 77ACF1636 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554360099; bh=Iv9HlapDPexKD8FKfcbhgzBpBY99Ma4wieOliMfnAWM=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=dfqTHw5myNj4ISaKgJVLTNFv4Qf0qml2EmI+Tzv3DbfnrEvW3rNCrsxtm6LZdxzCO iIwVseRRPZ04r68MPgcBjkz0fe39xwgZ2IvKx8a1SL8bVmJCbdstlL0Tnlu4achoHo PwK366HW1HW91jeXrotrgMnmO1w35FJCRWoqex7I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DA228F89725; Thu, 4 Apr 2019 08:37:49 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 844A7F8075C; Mon, 1 Apr 2019 22:55:35 +0200 (CEST) Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 52C1FF8075C for ; Mon, 1 Apr 2019 22:55:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 52C1FF8075C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bifpHM2U" Received: by mail-io1-xd44.google.com with SMTP id f6so9042506iop.3 for ; Mon, 01 Apr 2019 13:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JK47rU0DWd1+5spxdfOX495JieVPe3JN24lbHksimy8=; b=bifpHM2UsAdCBa5yaU/Iq2YV9npSkvduLCUGWl3PSd5krgjdWmBP1A2WEinmzsw3JM mL6hXJ/s93KYhfohVaXc1Ih6lxI1oYHzec5tfCkgSS3yUJfXl+Ipx3HPm5Y1OSnuyKEr ed4WxPMQbDxXUA3obofYLSWFRy9Upbl2ON7Z4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JK47rU0DWd1+5spxdfOX495JieVPe3JN24lbHksimy8=; b=eS3+OqIlBP7/V19zJcz/V/h2LvLEcmXTf6RSFW8u7hf0iVR9nH2IR+92BY5i1o2+zX 1wgKASc6FnF1V3t29M3WgtKhfZwtoY1nuWEUJ65mdA8D/BqHxB1jcUFIwnVFJ1m8TAfB 9ch7rC/RABSQYtyLrBLVq9YLGCrMCnHypIbscSvEEFsm/B/QMW4JHqqkgd2jG6UnjzN+ mg2PCVPvp8LK4nJbBp6fk/Xkrq2BQa+fC6PThelefK9VqMjl0ky5qlDJ6MGy8x7pzjpD +wbL205Hr7E35NZCd2hfeNYtIeqiozSmnTnIQCynGPjfI6au2gWXYlYBkQG7RAt6e+lf G/SQ== X-Gm-Message-State: APjAAAVKycM/PVSL4ilUSiaP9pbRW80HJOw2fVbeYq9/J2b0SCOupBjo yfIbTbnkjdXpKO2lj+xYEWyAfg== X-Google-Smtp-Source: APXvYqyArqrI53yJMfrxnyRlGCiMx06exaNb2/NL61QpZsoncJ3RIr2jbvFTaoCjczY+pFUBwxXlLg== X-Received: by 2002:a6b:7401:: with SMTP id s1mr41326821iog.55.1554152130141; Mon, 01 Apr 2019 13:55:30 -0700 (PDT) Received: from fletcherw.bld.corp.google.com ([2620:15c:183:200:70a8:812a:cdeb:6e0]) by smtp.gmail.com with ESMTPSA id v133sm6688570ita.19.2019.04.01.13.55.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 13:55:29 -0700 (PDT) From: Fletcher Woodruff To: linux-kernel@vger.kernel.org Date: Mon, 1 Apr 2019 14:55:18 -0600 Message-Id: <20190401205519.34023-1-fletcherw@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 04 Apr 2019 08:37:44 +0200 Cc: Oder Chiou , alsa-devel@alsa-project.org, Takashi Iwai , Liam Girdwood , Ben Zhang , Mark Brown , Ross Zwisler , Bard Liao , Curtis Malainey , Fletcher Woodruff Subject: [alsa-devel] [PATCH 1/2] ASoC: rt5677: allow multiple interrupt sources 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Zhang This patch allows headphone plug detect and mic present detect to be enabled at the same time. This patch implements an irq_chip with irq_domain directly instead of using regmap_irq, so that interrupt source line polarities can be flipped to support irq sharing. Signed-off-by: Ben Zhang Signed-off-by: Fletcher Woodruff --- sound/soc/codecs/rt5677.c | 261 ++++++++++++++++++++++++++++---------- sound/soc/codecs/rt5677.h | 14 +- 2 files changed, 208 insertions(+), 67 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 9b7a1833d3316c..33380f82b7008f 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -23,6 +23,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -4620,7 +4624,6 @@ static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset, static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset) { struct rt5677_priv *rt5677 = gpiochip_get_data(chip); - struct regmap_irq_chip_data *data = rt5677->irq_data; int irq; if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) || @@ -4646,7 +4649,7 @@ static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset) return -ENXIO; } - return regmap_irq_get_virq(data, irq); + return irq_create_mapping(rt5677->domain, irq); } static const struct gpio_chip rt5677_template_chip = { @@ -4716,37 +4719,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); @@ -5063,65 +5042,215 @@ static void rt5677_read_device_properties(struct rt5677_priv *rt5677, &rt5677->pdata.jd3_gpio); } -static struct regmap_irq rt5677_irqs[] = { +struct rt5677_irq_desc { + unsigned int enable_mask; + unsigned int status_mask; + unsigned int polarity_mask; +}; + +static const struct rt5677_irq_desc rt5677_irq_descs[] = { [RT5677_IRQ_JD1] = { - .reg_offset = 0, - .mask = RT5677_EN_IRQ_GPIO_JD1, + .enable_mask = RT5677_EN_IRQ_GPIO_JD1, + .status_mask = RT5677_STA_GPIO_JD1, + .polarity_mask = RT5677_INV_GPIO_JD1, }, [RT5677_IRQ_JD2] = { - .reg_offset = 0, - .mask = RT5677_EN_IRQ_GPIO_JD2, + .enable_mask = RT5677_EN_IRQ_GPIO_JD2, + .status_mask = RT5677_STA_GPIO_JD2, + .polarity_mask = RT5677_INV_GPIO_JD2, }, [RT5677_IRQ_JD3] = { - .reg_offset = 0, - .mask = RT5677_EN_IRQ_GPIO_JD3, + .enable_mask = RT5677_EN_IRQ_GPIO_JD3, + .status_mask = RT5677_STA_GPIO_JD3, + .polarity_mask = RT5677_INV_GPIO_JD3, }, }; +static irqreturn_t rt5677_irq(int unused, void *data) +{ + struct rt5677_priv *rt5677 = data; + int ret = 0, i, loop, reg_irq, virq; + bool irq_fired; + + mutex_lock(&rt5677->irq_lock); + /* + * Loop to handle interrupts until the last i2c read shows no pending + * irqs. The interrupt line is shared by multiple interrupt sources. + * After the regmap_read() below, a new interrupt source line may + * become high before the regmap_write() finishes, so there isn't a + * rising edge on the shared interrupt line for the new interrupt. Thus, + * the loop is needed to avoid missing irqs. + * + * A safeguard of 20 loops is used to avoid hanging in the irq handler + * if there is something wrong with the interrupt status update. The + * interrupt sources here are audio jack plug/unplug events which + * shouldn't happen at a high frequency for a long period of time. + * Empirically, more than 3 loops have never been seen. + */ + for (loop = 0; loop < 20; loop++) { + /* Read interrupt status */ + ret = regmap_read(rt5677->regmap, RT5677_IRQ_CTRL1, ®_irq); + if (ret) + break; + /* + * Clear the interrupt by flipping the polarity of the + * interrupt source lines that just fired + */ + irq_fired = false; + for (i = 0; i < RT5677_IRQ_NUM; i++) { + if (reg_irq & rt5677_irq_descs[i].status_mask) { + reg_irq ^= rt5677_irq_descs[i].polarity_mask; + irq_fired = true; + } + } + if (!irq_fired) + break; -static struct regmap_irq_chip rt5677_irq_chip = { - .name = "rt5677", - .irqs = rt5677_irqs, - .num_irqs = ARRAY_SIZE(rt5677_irqs), + ret = regmap_write(rt5677->regmap, RT5677_IRQ_CTRL1, reg_irq); + if (ret) + break; - .num_regs = 1, - .status_base = RT5677_IRQ_CTRL1, - .mask_base = RT5677_IRQ_CTRL1, - .mask_invert = 1, -}; + /* Process interrupts */ + for (i = 0; i < RT5677_IRQ_NUM; i++) { + if ((reg_irq & rt5677_irq_descs[i].enable_mask) && + (reg_irq & rt5677_irq_descs[i].status_mask)) { + virq = irq_find_mapping(rt5677->domain, i); + if (virq) + handle_nested_irq(virq); + } + } + } + mutex_unlock(&rt5677->irq_lock); + return IRQ_HANDLED; +} +static void rt5677_irq_work(struct work_struct *work) +{ + struct rt5677_priv *rt5677 = + container_of(work, struct rt5677_priv, irq_work.work); + + rt5677_irq(0, rt5677); +} -static int rt5677_init_irq(struct i2c_client *i2c) +static void rt5677_irq_bus_lock(struct irq_data *data) { - int ret; - struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); + struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); - if (!rt5677->pdata.jd1_gpio && - !rt5677->pdata.jd2_gpio && - !rt5677->pdata.jd3_gpio) - return 0; + mutex_lock(&rt5677->irq_lock); +} - if (!i2c->irq) { - dev_err(&i2c->dev, "No interrupt specified\n"); - return -EINVAL; - } +static void rt5677_irq_bus_sync_unlock(struct irq_data *data) +{ + struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); - ret = regmap_add_irq_chip(rt5677->regmap, i2c->irq, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0, - &rt5677_irq_chip, &rt5677->irq_data); + regmap_update_bits(rt5677->regmap, RT5677_IRQ_CTRL1, + RT5677_EN_IRQ_GPIO_JD1 | RT5677_EN_IRQ_GPIO_JD2 | + RT5677_EN_IRQ_GPIO_JD3, rt5677->irq_en); + mutex_unlock(&rt5677->irq_lock); +} - if (ret != 0) { - dev_err(&i2c->dev, "Failed to register IRQ chip: %d\n", ret); - return ret; - } +static void rt5677_irq_enable(struct irq_data *data) +{ + struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); + + rt5677->irq_en |= rt5677_irq_descs[data->hwirq].enable_mask; +} + +static void rt5677_irq_disable(struct irq_data *data) +{ + struct rt5677_priv *rt5677 = irq_data_get_irq_chip_data(data); + + rt5677->irq_en &= ~rt5677_irq_descs[data->hwirq].enable_mask; +} +static struct irq_chip rt5677_irq_chip = { + .name = "rt5677_irq_chip", + .irq_bus_lock = rt5677_irq_bus_lock, + .irq_bus_sync_unlock = rt5677_irq_bus_sync_unlock, + .irq_disable = rt5677_irq_disable, + .irq_enable = rt5677_irq_enable, +}; + +static int rt5677_irq_map(struct irq_domain *h, unsigned int virq, + irq_hw_number_t hw) +{ + struct rt5677_priv *rt5677 = h->host_data; + + irq_set_chip_data(virq, rt5677); + irq_set_chip(virq, &rt5677_irq_chip); + irq_set_nested_thread(virq, 1); + irq_set_noprobe(virq); return 0; } -static void rt5677_free_irq(struct i2c_client *i2c) + +static const struct irq_domain_ops rt5677_domain_ops = { + .map = rt5677_irq_map, + .xlate = irq_domain_xlate_twocell, +}; + +static void rt5677_init_irq(struct i2c_client *i2c) +{ + struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); + int ret; + unsigned int jd_mask = 0, jd_val = 0; + + /* No irq has been assigned to the codec */ + if (!i2c->irq) + return; + + mutex_init(&rt5677->irq_lock); + INIT_DELAYED_WORK(&rt5677->irq_work, rt5677_irq_work); + + /* + * 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); + + /* Ready to listen for interrupts */ + rt5677->domain = irq_domain_add_linear(i2c->dev.of_node, + RT5677_IRQ_NUM, &rt5677_domain_ops, rt5677); + if (!rt5677->domain) { + dev_err(&i2c->dev, "Failed to create IRQ domain\n"); + return; + } + ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, rt5677_irq, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "rt5677", rt5677); + if (ret) { + dev_err(&i2c->dev, "Failed to request IRQ: %d\n", ret); + return; + } +} + +static void rt5677_irq_exit(struct i2c_client *i2c) { struct rt5677_priv *rt5677 = i2c_get_clientdata(i2c); - if (rt5677->irq_data) - regmap_del_irq_chip(i2c->irq, rt5677->irq_data); + cancel_delayed_work_sync(&rt5677->irq_work); } static int rt5677_i2c_probe(struct i2c_client *i2c) @@ -5259,7 +5388,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c) static int rt5677_i2c_remove(struct i2c_client *i2c) { - rt5677_free_irq(i2c); + rt5677_irq_exit(i2c); rt5677_free_gpio(i2c); return 0; diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index 183d92b030459f..9c73bea8635508 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -1636,6 +1636,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 @@ -1713,6 +1719,7 @@ enum { RT5677_IRQ_JD1, RT5677_IRQ_JD2, RT5677_IRQ_JD3, + RT5677_IRQ_NUM, }; enum rt5677_type { @@ -1811,9 +1818,14 @@ struct rt5677_priv { struct gpio_chip gpio_chip; #endif bool dsp_vad_en; - struct regmap_irq_chip_data *irq_data; bool is_dsp_mode; bool is_vref_slow; + + /* Interrupt handling */ + struct irq_domain *domain; + struct mutex irq_lock; + unsigned int irq_en; + struct delayed_work irq_work; }; int rt5677_sel_asrc_clk_src(struct snd_soc_component *component, From patchwork Mon Apr 1 20:55:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fletcher Woodruff X-Patchwork-Id: 10885067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 821C8139A for ; Thu, 4 Apr 2019 07:06:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C59E28756 for ; Thu, 4 Apr 2019 07:06:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DF82287A2; Thu, 4 Apr 2019 07:06:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 18F5E28740 for ; Thu, 4 Apr 2019 07:06:52 +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 C3DD9163D; Thu, 4 Apr 2019 08:41:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C3DD9163D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554360130; bh=R7v10Aqjx/CCjwvYAswXE2F+y+ml1PalXPyK1TIMUmg=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=W0Cr04a93L0uTLmnh8+dWqiJXMH9y+C8fXG46nOd6ZcZDAC08AvMfGnMstO2aGALr ZvLxyTZWJiei56Kw0YyPBa1WHCFSEvuChi7nlaTAs24Xcwq8CmHwZmXieDxrOgQKNb rTDY2TNrSXijt+zJm2NzUZHzCkKDxN770tg0WLxw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 50619F89729; Thu, 4 Apr 2019 08:37:51 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7D1BDF89614; Mon, 1 Apr 2019 22:55:46 +0200 (CEST) Received: from mail-it1-x141.google.com (mail-it1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9E531F8075C for ; Mon, 1 Apr 2019 22:55:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9E531F8075C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="c125njDp" Received: by mail-it1-x141.google.com with SMTP id q14so1535528itk.0 for ; Mon, 01 Apr 2019 13:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xrpr7Hq7dqaYL2Eo6DwUdVyXfie7eGeQXHVNyEFIVsc=; b=c125njDpcb+GViLFb7oVcDNQe5ZLS36m3H9L16x9knOSqaFwlnxDs+rGkawwSxJbev wzsTkjX3Y24BpRuyMM2PCZy92/gdYSpJwe6icQto/kqdVd40+EGD10UN9tvr2k3M8eOQ CSTTzL1rJRZkv/p3B9Xk++JR9RnhbLzOnsg4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xrpr7Hq7dqaYL2Eo6DwUdVyXfie7eGeQXHVNyEFIVsc=; b=oJ2Pse888sBd7mBlQSzKXUh0mFwHXuawUfalJHW1ET9uCWjLdKGfPiCymZoFpn8ocr EhHSRxv4/2LAC5cWBtW2JZHnjBpq1WH8fHHAAGUBlhnB/X7q8VjGW+5QalLzfBvN7WrY /8Fcq2xjNywv31m6kb/JP/uxioX+e0pZRvtzYn7PjM/LTpFQ2IafM4HXiF518w0WgFeQ dsKgqWZ+2rwX0JSxskcELg58VNmgjw/dCLvVyBJox1KFulIMK7tSTetVnCvvQKjZEn09 x5pLUB1+u7BgUGWy4+MgXMIf6huiDo9vqHRfx5owLcJex6xNoTN85TqEZchrRWSpCtrp WtOQ== X-Gm-Message-State: APjAAAUK1NN2W8pR1CxE987uwD1J/Wd7+fDNIE4rf8O6WCtJDnqbH3qc UYUaMYLYwvCk2Ny38HY0OWmVpA== X-Google-Smtp-Source: APXvYqxavNwBue4MkZ+KYHPxCUQFuW4/4QT/57VY6ql1jxwXoUaGRP9EICN0VkNK2m9QSLigHVZSgQ== X-Received: by 2002:a24:7014:: with SMTP id f20mr1286036itc.44.1554152141676; Mon, 01 Apr 2019 13:55:41 -0700 (PDT) Received: from fletcherw.bld.corp.google.com ([2620:15c:183:200:70a8:812a:cdeb:6e0]) by smtp.gmail.com with ESMTPSA id v133sm6688570ita.19.2019.04.01.13.55.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 13:55:41 -0700 (PDT) From: Fletcher Woodruff To: linux-kernel@vger.kernel.org Date: Mon, 1 Apr 2019 14:55:19 -0600 Message-Id: <20190401205519.34023-2-fletcherw@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190401205519.34023-1-fletcherw@chromium.org> References: <20190401205519.34023-1-fletcherw@chromium.org> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 04 Apr 2019 08:37:44 +0200 Cc: Oder Chiou , alsa-devel@alsa-project.org, Takashi Iwai , Liam Girdwood , Mark Brown , Ross Zwisler , Bard Liao , Fletcher Woodruff , Curtis Malainey Subject: [alsa-devel] [PATCH 2/2] ASoC: rt5677: make ACPI property names match _DSD 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" X-Virus-Scanned: ClamAV using ClamSMTP The rt5677 driver is using the wrong property names to read from ACPI. Update the property names to match those from _DSD, so that the correct GPIO pin numbers are read and that plug-detection works. With this patch, plugging and unplugging the headphone jack switches between headphones and speakers automatically. Signed-off-by: Fletcher Woodruff --- sound/soc/codecs/rt5677.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 33380f82b7008f..1f725086cee39c 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4998,25 +4998,6 @@ static const struct acpi_device_id rt5677_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); -static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677, - struct device *dev) -{ - u32 val; - - if (!device_property_read_u32(dev, "DCLK", &val)) - rt5677->pdata.dmic2_clk_pin = val; - - rt5677->pdata.in1_diff = device_property_read_bool(dev, "IN1"); - rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2"); - rt5677->pdata.lout1_diff = device_property_read_bool(dev, "OUT1"); - rt5677->pdata.lout2_diff = device_property_read_bool(dev, "OUT2"); - rt5677->pdata.lout3_diff = device_property_read_bool(dev, "OUT3"); - - device_property_read_u32(dev, "JD1", &rt5677->pdata.jd1_gpio); - device_property_read_u32(dev, "JD2", &rt5677->pdata.jd2_gpio); - device_property_read_u32(dev, "JD3", &rt5677->pdata.jd3_gpio); -} - static void rt5677_read_device_properties(struct rt5677_priv *rt5677, struct device *dev) { @@ -5273,19 +5254,23 @@ static int rt5677_i2c_probe(struct i2c_client *i2c) if (match_id) rt5677->type = (enum rt5677_type)match_id->data; - rt5677_read_device_properties(rt5677, &i2c->dev); } else if (ACPI_HANDLE(&i2c->dev)) { const struct acpi_device_id *acpi_id; + u32 val; acpi_id = acpi_match_device(rt5677_acpi_match, &i2c->dev); if (acpi_id) rt5677->type = (enum rt5677_type)acpi_id->driver_data; - rt5677_read_acpi_properties(rt5677, &i2c->dev); + if (!device_property_read_u32(&i2c->dev, + "realtek,dmic2_clk_pin", &val)) + rt5677->pdata.dmic2_clk_pin = val; } else { return -EINVAL; } + rt5677_read_device_properties(rt5677, &i2c->dev); + /* pow-ldo2 and reset are optional. The codec pins may be statically * connected on the board without gpios. If the gpio device property * isn't specified, devm_gpiod_get_optional returns NULL.