From patchwork Sat Apr 25 00:50:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yang.a.fang@intel.com X-Patchwork-Id: 6273941 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7BDBE9F389 for ; Sat, 25 Apr 2015 00:52:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A164E2038A for ; Sat, 25 Apr 2015 00:52:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6AE5920379 for ; Sat, 25 Apr 2015 00:51:59 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 95C5F261484; Sat, 25 Apr 2015 02:51:58 +0200 (CEST) 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, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E8CFD261293; Sat, 25 Apr 2015 02:51:48 +0200 (CEST) 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 E8461261295; Sat, 25 Apr 2015 02:51:47 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by alsa0.perex.cz (Postfix) with ESMTP id 79C5B2610A6 for ; Sat, 25 Apr 2015 02:51:33 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 24 Apr 2015 17:51:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,644,1422950400"; d="scan'208";a="718953333" Received: from mocha.sc.intel.com ([143.183.245.87]) by orsmga002.jf.intel.com with ESMTP; 24 Apr 2015 17:51:32 -0700 From: yang.a.fang@intel.com To: broonie@kernel.org, lgirdwood@gmail.com Date: Fri, 24 Apr 2015 17:50:54 -0700 Message-Id: <1429923054-108946-1-git-send-email-yang.a.fang@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1429832118-20741-2-git-send-email-yang.a.fang@intel.com> References: <1429832118-20741-2-git-send-email-yang.a.fang@intel.com> Cc: alsa-devel@alsa-project.org, vinod.koul@intel.com, praveen.k.jain@intel.com, denny.iriawan@intel.com, "Fang, Yang A" , sathyanarayana.nujella@intel.com, kevin.strasser@linux.intel.com, bardliao@realtek.com Subject: [alsa-devel] [PATCH v2] ASoC: rt5645: set platform data base on DMI 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 From: "Fang, Yang A" set platform specific data for intel strago platform Signed-off-by: Fang, Yang A --- sound/soc/codecs/rt5645.c | 47 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 61ca49f..07ef1b9 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2666,6 +2667,34 @@ static struct acpi_device_id rt5645_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, rt5645_acpi_match); #endif +static struct rt5645_platform_data *rt5645_pdata; + +static struct rt5645_platform_data strago_platform_data = { + .dmic_en = true, + .dmic1_data_pin = -1, + .dmic2_data_pin = RT5645_DMIC_DATA_IN2P, + .en_jd_func = true, + .jd_mode = 3, +}; + +static int strago_quirk_cb(const struct dmi_system_id *id) +{ + rt5645_pdata = &strago_platform_data; + + return 1; +} + +static struct dmi_system_id dmi_platform_intel_braswell[] __initdata = { + { + .ident = "Intel Strago", + .callback = strago_quirk_cb, + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "Strago"), + }, + }, + { } +}; + static int rt5645_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -2673,6 +2702,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, struct rt5645_priv *rt5645; int ret; unsigned int val; + struct gpio_desc *gpiod; rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv), GFP_KERNEL); @@ -2682,8 +2712,23 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, rt5645->i2c = i2c; i2c_set_clientdata(i2c, rt5645); - if (pdata) + if (pdata) { rt5645->pdata = *pdata; + } else { + if (dmi_check_system(dmi_platform_intel_braswell)) { + rt5645->pdata = *rt5645_pdata; + gpiod = devm_gpiod_get_index(&i2c->dev, "rt5645", 0); + + if (IS_ERR(gpiod) || gpiod_direction_input(gpiod)) { + rt5645->pdata.hp_det_gpio = -1; + dev_err(&i2c->dev, "failed to initialize gpiod\n"); + } else { + rt5645->pdata.hp_det_gpio = desc_to_gpio(gpiod); + rt5645->pdata.gpio_hp_det_active_high + = !gpiod_is_active_low(gpiod); + } + } + } rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap); if (IS_ERR(rt5645->regmap)) {