aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFang, Yang A <yang.a.fang@intel.com>2015-04-24 20:50:54 -0400
committerMark Brown <broonie@kernel.org>2015-04-27 17:00:34 -0400
commit78c34fd42e3b0ea6336ba3ef77bb329e0b256756 (patch)
treefcfc7050c303362c435a9917eff133d46abacd88
parent10bb15a9a5ddf148bfc52f0c683b99487f4e2c10 (diff)
ASoC: rt5645: set platform data base on DMI
set platform specific data for intel strago platform Signed-off-by: Fang, Yang A <yang.a.fang@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/rt5645.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index be4d741c45ba..fb561b4332a0 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -19,6 +19,7 @@
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/acpi.h> 21#include <linux/acpi.h>
22#include <linux/dmi.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
@@ -2666,6 +2667,34 @@ static struct acpi_device_id rt5645_acpi_match[] = {
2666MODULE_DEVICE_TABLE(acpi, rt5645_acpi_match); 2667MODULE_DEVICE_TABLE(acpi, rt5645_acpi_match);
2667#endif 2668#endif
2668 2669
2670static struct rt5645_platform_data *rt5645_pdata;
2671
2672static struct rt5645_platform_data strago_platform_data = {
2673 .dmic_en = true,
2674 .dmic1_data_pin = -1,
2675 .dmic2_data_pin = RT5645_DMIC_DATA_IN2P,
2676 .en_jd_func = true,
2677 .jd_mode = 3,
2678};
2679
2680static int strago_quirk_cb(const struct dmi_system_id *id)
2681{
2682 rt5645_pdata = &strago_platform_data;
2683
2684 return 1;
2685}
2686
2687static struct dmi_system_id dmi_platform_intel_braswell[] __initdata = {
2688 {
2689 .ident = "Intel Strago",
2690 .callback = strago_quirk_cb,
2691 .matches = {
2692 DMI_MATCH(DMI_PRODUCT_NAME, "Strago"),
2693 },
2694 },
2695 { }
2696};
2697
2669static int rt5645_i2c_probe(struct i2c_client *i2c, 2698static int rt5645_i2c_probe(struct i2c_client *i2c,
2670 const struct i2c_device_id *id) 2699 const struct i2c_device_id *id)
2671{ 2700{
@@ -2673,6 +2702,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
2673 struct rt5645_priv *rt5645; 2702 struct rt5645_priv *rt5645;
2674 int ret; 2703 int ret;
2675 unsigned int val; 2704 unsigned int val;
2705 struct gpio_desc *gpiod;
2676 2706
2677 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv), 2707 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv),
2678 GFP_KERNEL); 2708 GFP_KERNEL);
@@ -2682,8 +2712,23 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
2682 rt5645->i2c = i2c; 2712 rt5645->i2c = i2c;
2683 i2c_set_clientdata(i2c, rt5645); 2713 i2c_set_clientdata(i2c, rt5645);
2684 2714
2685 if (pdata) 2715 if (pdata) {
2686 rt5645->pdata = *pdata; 2716 rt5645->pdata = *pdata;
2717 } else {
2718 if (dmi_check_system(dmi_platform_intel_braswell)) {
2719 rt5645->pdata = *rt5645_pdata;
2720 gpiod = devm_gpiod_get_index(&i2c->dev, "rt5645", 0);
2721
2722 if (IS_ERR(gpiod) || gpiod_direction_input(gpiod)) {
2723 rt5645->pdata.hp_det_gpio = -1;
2724 dev_err(&i2c->dev, "failed to initialize gpiod\n");
2725 } else {
2726 rt5645->pdata.hp_det_gpio = desc_to_gpio(gpiod);
2727 rt5645->pdata.gpio_hp_det_active_high
2728 = !gpiod_is_active_low(gpiod);
2729 }
2730 }
2731 }
2687 2732
2688 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap); 2733 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap);
2689 if (IS_ERR(rt5645->regmap)) { 2734 if (IS_ERR(rt5645->regmap)) {