From patchwork Sat Nov 15 06:56:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Zhang X-Patchwork-Id: 5311001 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 50B21C11AC for ; Sat, 15 Nov 2014 06:57:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 747F1201E4 for ; Sat, 15 Nov 2014 06:57:38 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 30E14201C7 for ; Sat, 15 Nov 2014 06:57:37 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7330B2605B4; Sat, 15 Nov 2014 07:57:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 46A6126058F; Sat, 15 Nov 2014 07:57:20 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 34032260590; Sat, 15 Nov 2014 07:57:18 +0100 (CET) Received: from mail-oi0-f73.google.com (mail-oi0-f73.google.com [209.85.218.73]) by alsa0.perex.cz (Postfix) with ESMTP id E0FDC260589 for ; Sat, 15 Nov 2014 07:57:09 +0100 (CET) Received: by mail-oi0-f73.google.com with SMTP id a141so392626oig.2 for ; Fri, 14 Nov 2014 22:57:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uTWtEmIsPZAoHg9JW6IPIs2+OtmZeqg28+C1VsozrII=; b=WvbkVnPaO6vqHWYX1V2OGw1g0x5SgOMSso7wYijNz0aG0XL5nrrM1gzlxryZg6CZoW P/wv4Q6mA4Y22iOr9OKlxYLK9TOQZvviin5UZITm06H5XsQN2VO4Pvt6PvmoHDrDCbYq crMjfNJYxlpGd53l2KrXhSRpdNathaaQ+tiTv5hKvZ8cP7X3oDg6PrNkijdZ55UyeN2e 2oabzd/AL9u96snNrDzLvUn3KlJsLuYmLKuRa+za02PrZiMUihSdMwyy5Hh0rgHAnaIi uS2ASieXbqueN4PWjSkpJejPW/gIC9Em0vMx1vFlJMZWTG4QqmS2U4aS9yNOFmY7IZMn vQRQ== X-Gm-Message-State: ALoCoQmN14GgpYprVSDyZUFxyKWz+4FNTp0cMDjm6eT/gG6xvx9HicF2gEjgU2AJIy3yH60ruJCsOPzeV+k7we0lFJ+Wj3LBSgiVorkELJY1MecwilpdPPxvJst4iE7gb2RIX4bz8L2zskjEwX7LEjbR6whwE4GixcG6YyxgkfYXxcoh/z3goVI= X-Received: by 10.42.6.71 with SMTP id 7mr4669073icz.19.1416034628385; Fri, 14 Nov 2014 22:57:08 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id k66si1281856yho.7.2014.11.14.22.57.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Nov 2014 22:57:08 -0800 (PST) Received: from benzh.mtv.corp.google.com ([172.22.65.67]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id 6kqUTVv6.1; Fri, 14 Nov 2014 22:57:08 -0800 Received: by benzh.mtv.corp.google.com (Postfix, from userid 215530) id E4D80E09EB; Fri, 14 Nov 2014 22:57:06 -0800 (PST) From: Ben Zhang To: alsa-devel@alsa-project.org Date: Fri, 14 Nov 2014 22:56:47 -0800 Message-Id: <1416034608-24238-1-git-send-email-benzh@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 Cc: Oder Chiou , Liam Girdwood , linux-kernel@vger.kernel.org, Ben Zhang , Mark Brown , Anatol Pomozov , Bard Liao , Dylan Reid , flove@realtek.com Subject: [alsa-devel] [PATCH 1/2] ASoC: rt5677: Add ACPI device probing X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The rt5677 codec driver looks for ACPI device ID "RT5677CE", which is specified in coreboot. This patch allows platform data to be obtained via ACPI Signed-off-by: Ben Zhang --- sound/soc/codecs/rt5677.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 5d317c68..384281d 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -4525,6 +4526,43 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) return 0; } +#ifdef CONFIG_ACPI + +static unsigned long long rt5677_parse_acpi_entry(struct device *dev, + acpi_string name) +{ + acpi_handle handle = ACPI_HANDLE(dev); + unsigned long long val; + acpi_status status; + + status = acpi_evaluate_integer(handle, name, NULL, &val); + if (ACPI_FAILURE(status)) { + dev_err(dev, "Failed to parse ACPI entry %s, default to 0: %d\n", + name, status); + return 0; + } + return val; +} + +static void rt5677_parse_acpi(struct rt5677_priv *rt5677, struct device *dev) +{ + rt5677->pdata.dmic2_clk_pin = (enum rt5677_dmic2_clk) + rt5677_parse_acpi_entry(dev, "DCLK"); + rt5677->pdata.in1_diff = (bool)rt5677_parse_acpi_entry(dev, "IN1"); + rt5677->pdata.in2_diff = (bool)rt5677_parse_acpi_entry(dev, "IN2"); + rt5677->pdata.lout1_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT1"); + rt5677->pdata.lout2_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT2"); + rt5677->pdata.lout3_diff = (bool)rt5677_parse_acpi_entry(dev, "OUT3"); + rt5677->pdata.jd1_gpio = rt5677_parse_acpi_entry(dev, "JD1"); + rt5677->pdata.jd2_gpio = rt5677_parse_acpi_entry(dev, "JD2"); + rt5677->pdata.jd3_gpio = rt5677_parse_acpi_entry(dev, "JD3"); +} +#else +static void rt5677_parse_acpi(struct rt5677_priv *rt5677, struct device *dev) +{ +} +#endif + static struct regmap_irq rt5677_irqs[] = { [RT5677_IRQ_JD1] = { .reg_offset = 0, @@ -4604,6 +4642,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, if (pdata) rt5677->pdata = *pdata; + rt5677->pow_ldo2 = -EINVAL; if (i2c->dev.of_node) { ret = rt5677_parse_dt(rt5677, i2c->dev.of_node); if (ret) { @@ -4611,8 +4650,8 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, ret); return ret; } - } else { - rt5677->pow_ldo2 = -EINVAL; + } else if (ACPI_HANDLE(&i2c->dev)) { + rt5677_parse_acpi(rt5677, &i2c->dev); } if (gpio_is_valid(rt5677->pow_ldo2)) { @@ -4708,10 +4747,19 @@ static int rt5677_i2c_remove(struct i2c_client *i2c) return 0; } +#ifdef CONFIG_ACPI +static const struct acpi_device_id rt5677_acpi_id[] = { + { "RT5677CE", 0 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, rt5677_acpi_id); +#endif + static struct i2c_driver rt5677_i2c_driver = { .driver = { .name = "rt5677", .owner = THIS_MODULE, + .acpi_match_table = ACPI_PTR(rt5677_acpi_id), }, .probe = rt5677_i2c_probe, .remove = rt5677_i2c_remove,