Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1280433ybi; Fri, 14 Jun 2019 11:44:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5/7Qc19BzYQlChr0qNo2Fh8MW+P/Ne4+9IpggC/ALXTvQHaPjzuNG2v5QLUgguWF2gc8G X-Received: by 2002:a17:90a:d3c3:: with SMTP id d3mr12771559pjw.17.1560537847236; Fri, 14 Jun 2019 11:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560537847; cv=none; d=google.com; s=arc-20160816; b=C6YZtova8+xZu1zI7xz6n41CWyuWgPm7wKEkeScUWZfF4Z0hQ4TFMhzzjJpBTPq8jo yTzTqc3lnRVolenGnaEGLlkIRTxwjmwwLPt3oimd8l0K2haxwW9xjjp2NW0BSFQv+fdM 61+r6a1sq9M4nmdrfUUri5kLbCFxKn52lhxvrCnOP5lXY5pfwiIVzqYTleeNyWEXQa8p rNwE2uTh26InLj9RDpD4PaZ8ExWtwXo15d1TVpTazB3zAQTMa3UlAzvK/rjaLTjR8o92 iavjjYZBxjXj0bwxluf49r3H/GuF4S3nWC7gW7XoYNcUU9koLuTaSLeRC5ilPrq5gEhH W8dQ== 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=TKOU5/QG7HDd7I0ABDKPRdJPLDsTX1/0xBbtCwEaRXI=; b=QMxSegIxhdEAasuiJDBvdZBO2B1pBGbEOLv+ibSZdmPjUTFq/0d5gOq1GFsCi4NXAX w5a37aUyirHJOIqX2ddTdEkydFWfbH8ZySN2snQ775OI4MwjDdMqtbMD5y5BvdMpY2Yg RNgE+aqQ5Zq+/bThzO454zHSORlCNAmHiSxNpmsMq/QBd0nEXPGVpMUDPWedscFQo6lD 7KedTvrHwv0JZMS4/TfHouEWVfCVc0wJNiwOXkPjlKsUQifgyHcZ9GrjgzJGJ4/uf0Ma EyUO4jhcFKdK7AKUePQW6iBi2P4vcEheXF2MOic7S4oI9RXOo07H9zlgOCjwbHmOvKfi JMeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Boy/fMbo"; 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 f24si3247843pgi.289.2019.06.14.11.43.52; Fri, 14 Jun 2019 11:44: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=pass header.i=@chromium.org header.s=google header.b="Boy/fMbo"; 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 S1726377AbfFNSnj (ORCPT + 99 others); Fri, 14 Jun 2019 14:43:39 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42056 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbfFNSnj (ORCPT ); Fri, 14 Jun 2019 14:43:39 -0400 Received: by mail-io1-f67.google.com with SMTP id u19so7879086ior.9 for ; Fri, 14 Jun 2019 11:43:38 -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=TKOU5/QG7HDd7I0ABDKPRdJPLDsTX1/0xBbtCwEaRXI=; b=Boy/fMbohwlITd6mc8nqg+LUATuM4f8SJh5L9lP6FCDLZ2D4dOL9FPP/Di00Z6acIV Meio9yNykkvR+UmOCf2n5AYYcNnPFcBijUkKJD+NPGfCycT8WtUc0D8C647y/c77VNNb 0khjOKaNGgIvsOSGTe53/lMwaCWZX4EXIKiU4= 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=TKOU5/QG7HDd7I0ABDKPRdJPLDsTX1/0xBbtCwEaRXI=; b=kALFdC7OaHfbSNYFJQWz6PXRX10hYDVkcR5acyoM65VT/oGZ3CH0MbeczLhNE7dKaT VlFkVCPz8YWwOA6MBmtLROuGz3JOb9MbBjH3sZ3Y+sDgTb1ZrG3LBfzezZGenMwMM8ig NlwRW9RMSmaswBaSXkhOGrrQ3jSZKrhilaj5Aw8IxXyzkU+V27FLynafaex1P5c5FnAN S44EGKDyp650lMmx1nErYPDvRLh6ofPanYAzZ3fT42zVhAcWyNIAqVSWRcDT+mxxfODP nEebC0N1wM9XEH3xdIn2WapTWouA40CP/sVJnZkO/JiLUKiwwJsfXgABRDzXDbnmlCBh OkWA== X-Gm-Message-State: APjAAAXva63nl8Y1x4X0cDq3CqGJvxlHOwBYaWM3UlYi1Cv9JOwn4dxE gVyKYUTFvgso4Dmm4aAphgWTA+nwjGqTsA== X-Received: by 2002:a5e:c241:: with SMTP id w1mr1685672iop.58.1560537817451; Fri, 14 Jun 2019 11:43:37 -0700 (PDT) Received: from localhost ([2620:15c:183:200:33ce:f5cf:f863:d3a6]) by smtp.gmail.com with ESMTPSA id f20sm3913678ioh.17.2019.06.14.11.43.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jun 2019 11:43:36 -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 v6 1/4] ASoC: rt5677: fall back to DT prop names on error Date: Fri, 14 Jun 2019 12:43:12 -0600 Message-Id: <20190614184315.252945-2-fletcherw@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190614184315.252945-1-fletcherw@chromium.org> References: <20190614184315.252945-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 6fc70e441458de..63e28eaf1f40ba 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -5019,48 +5019,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[] = { @@ -5143,20 +5145,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