Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1334990ybi; Fri, 14 Jun 2019 12:49:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqznaK7mNKdqylJ2LmgA0iO0pfmyLM0wgTQNVHOljOtUIu/cwa7LSy+i0LsJtMHIV3JN1qI7 X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr12174379plo.88.1560541770285; Fri, 14 Jun 2019 12:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560541770; cv=none; d=google.com; s=arc-20160816; b=oYI5Q//zXucaE2897K9zTP5T3cjUkUA2ez/sOmWro3z7fiDW0WzPzLuGFuD+4D6rWy hAewTZ5ms7M1vmJXvYWDbPvXdEwPW609Ip3/W+mD9eXK9qAzc+FNwHNHbWCqNBAe5YTN xUsGRdRXMn4Y8JjD5pt8+zxkEANfVLnZcwL8PZ7Lgu9w1YX/IA4Ded2Q2deMTP3X+yj0 /c0NpBFUTpqUycHCPwR3w2aWrWX4SF1XiZdRIib9Ny8zqEuRn3djQESpoLvfp/93QxhW fvWjh1fvZgjF+ZsfXhkIc4lpiKQW8Mc9isFJdI6CPEG+rEDaVAy0j2QkNOsuZSJGglXO Mq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IvLXyNHUCELtSn+1/hcL5+QJvqQb1PiQqzqr+M8TCmg=; b=AFVfTdZ/ujybLqecKSL7PYLYRWBzWlmhM3KsAxKFE6mTSakB1lDbcE4anqIVOEnEKs f/EYTb3+54RA9n+1nal1KhTqepzMOLzPBzpUDHzmXIpD1l+ufjUqWaunIpgoN6T7Y5ND f8e7niVemmrxquVigLxGOZJmjeb9/cdhRJ5M3UXXKf6dWy+HdmoG3UmM7mIkwXBHJzWt kiVLiwjRFdNjtDny9Q+zBt/2EAKpafSuZ+VnzNhRRN+On0AWdqlAVLWMRYExHA03yl0z jEN2PEpY5Frya4BVmAYeGyolSTfll6r3moucY0B/mycBL0JlUzSrN857WdOgkkMlyk95 0JpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dcerv2zu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f89si3099300pje.50.2019.06.14.12.49.15; Fri, 14 Jun 2019 12:49:30 -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=pass header.i=@chromium.org header.s=google header.b=dcerv2zu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbfFNTtD (ORCPT + 99 others); Fri, 14 Jun 2019 15:49:03 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42336 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbfFNTtC (ORCPT ); Fri, 14 Jun 2019 15:49:02 -0400 Received: by mail-io1-f67.google.com with SMTP id u19so8272971ior.9 for ; Fri, 14 Jun 2019 12:49:01 -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=IvLXyNHUCELtSn+1/hcL5+QJvqQb1PiQqzqr+M8TCmg=; b=dcerv2zuu2KTKRZfFNU8oD5JsRSpt4zJwo7r6ULhlDGDekV0cHSQitYZbq8g+5De4G jMLYXrxrWFKi+8nzNpTt8CiPfO1sgzT4Hv12YAbgV6dYCN88dug16ii5eW63x4EQ75T9 p7Jjsc2ug7evjcI1QSnXOWJt1S0YkaSHVn4eg= 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=IvLXyNHUCELtSn+1/hcL5+QJvqQb1PiQqzqr+M8TCmg=; b=KNRxaEaTesEQkkJozwWHRX3c+xbNcs2xWZzDmwZGgV0JRXYk6hJBRHlem5w7MufHze B6iH3KWcryyhL0RmhUKeQol3DF+DiCxgKfQqZ6HtgKNZqEq2hNBG95gqSEnRQVH6GLL9 xYtO+diqUaqr+OomyBU3Ro4ozgg4WJ5l4mtW5VAxhV97Ga5X+j/OmTEM8lcg4B/xQb/R YDs95QtwxKyXwr2hFm0wN0i4ZgPW2GM4ahkQmAjDqNHyWQdvCQ9cCSJV+NyRsp4EnKyr NthIhQq1t8IPleCOKLR8a6VhZ/bBTWqoDPM791ZEA8hr0v39JMFVJYCJZ3SWePPR+ElC oBaQ== X-Gm-Message-State: APjAAAWJ/rM87tQMFkzBnZ07Y+IWX7EM36kJlYQ+REpRQlJgHph4hPFf h5saG5iX+NM0XqUD7fF+I+4nWuSysv7qSw== X-Received: by 2002:a5e:9701:: with SMTP id w1mr6065716ioj.294.1560541740706; Fri, 14 Jun 2019 12:49:00 -0700 (PDT) Received: from localhost ([2620:15c:183:200:33ce:f5cf:f863:d3a6]) by smtp.gmail.com with ESMTPSA id q15sm3287461ioi.15.2019.06.14.12.48.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jun 2019 12:49:00 -0700 (PDT) From: Fletcher Woodruff To: linux-kernel@vger.kernel.org Cc: Fletcher Woodruff , Jaroslav Kysela , Liam Girdwood , Mark Brown , Oder Chiou , Takashi Iwai , Curtis Malainey , Ross Zwisler , alsa-devel@alsa-project.org Subject: [PATCH v7 1/4] ASoC: rt5677: fall back to DT prop names on error Date: Fri, 14 Jun 2019 13:48:51 -0600 Message-Id: <20190614194854.208436-2-fletcherw@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190614194854.208436-1-fletcherw@chromium.org> References: <20190614194854.208436-1-fletcherw@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rt5677 driver uses ACPI-style property names to read from the device API. However, these do not match the property names in _DSD used on the Chromebook Pixel 2015, which are closer to the Device Tree style. Unify the two functions for reading from the device API so that they try ACPI-style names first and fall back to the DT names on error. 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 | 74 +++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index c49b5c21866663..fe000f30b9ad5f 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -5020,48 +5020,50 @@ 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, +static void rt5677_read_device_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") || + device_property_read_bool(dev, "realtek,in1-differential"); - 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"); + rt5677->pdata.in2_diff = + device_property_read_bool(dev, "IN2") || + device_property_read_bool(dev, "realtek,in2-differential"); - 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); -} + rt5677->pdata.lout1_diff = + device_property_read_bool(dev, "OUT1") || + device_property_read_bool(dev, "realtek,lout1-differential"); -static void rt5677_read_device_properties(struct rt5677_priv *rt5677, - struct device *dev) -{ - rt5677->pdata.in1_diff = device_property_read_bool(dev, - "realtek,in1-differential"); - rt5677->pdata.in2_diff = device_property_read_bool(dev, - "realtek,in2-differential"); - rt5677->pdata.lout1_diff = device_property_read_bool(dev, - "realtek,lout1-differential"); - rt5677->pdata.lout2_diff = device_property_read_bool(dev, - "realtek,lout2-differential"); - rt5677->pdata.lout3_diff = device_property_read_bool(dev, - "realtek,lout3-differential"); + rt5677->pdata.lout2_diff = + device_property_read_bool(dev, "OUT2") || + device_property_read_bool(dev, "realtek,lout2-differential"); + + rt5677->pdata.lout3_diff = + device_property_read_bool(dev, "OUT3") || + device_property_read_bool(dev, "realtek,lout3-differential"); device_property_read_u8_array(dev, "realtek,gpio-config", - rt5677->pdata.gpio_config, RT5677_GPIO_NUM); - - device_property_read_u32(dev, "realtek,jd1-gpio", - &rt5677->pdata.jd1_gpio); - device_property_read_u32(dev, "realtek,jd2-gpio", - &rt5677->pdata.jd2_gpio); - device_property_read_u32(dev, "realtek,jd3-gpio", - &rt5677->pdata.jd3_gpio); + rt5677->pdata.gpio_config, + RT5677_GPIO_NUM); + + if (!device_property_read_u32(dev, "DCLK", &val) || + !device_property_read_u32(dev, "realtek,dmic2_clk_pin", &val)) + rt5677->pdata.dmic2_clk_pin = val; + + if (!device_property_read_u32(dev, "JD1", &val) || + !device_property_read_u32(dev, "realtek,jd1-gpio", &val)) + rt5677->pdata.jd1_gpio = val; + + if (!device_property_read_u32(dev, "JD2", &val) || + !device_property_read_u32(dev, "realtek,jd2-gpio", &val)) + rt5677->pdata.jd2_gpio = val; + + if (!device_property_read_u32(dev, "JD3", &val) || + !device_property_read_u32(dev, "realtek,jd3-gpio", &val)) + rt5677->pdata.jd3_gpio = val; } static struct regmap_irq rt5677_irqs[] = { @@ -5144,20 +5146,18 @@ static int rt5677_i2c_probe(struct i2c_client *i2c) match_id = of_match_device(rt5677_of_match, &i2c->dev); 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; 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); } 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. -- 2.22.0.410.gd8fdbe21b5-goog