diff mbox series

[SRU,Unstable,1/3] UBUNTU: SAUCE: ASoC: rt5660: (no-up) Move platform code to board file

Message ID 20190109072017.2598-5-hui.wang@canonical.com
State New
Headers show
Series [SRU,Unstable,1/3] UBUNTU: SAUCE: ASoC: rt5660: (no-up) Move platform code to board file | expand

Commit Message

Hui Wang Jan. 9, 2019, 7:20 a.m. UTC
From: Shrirang Bagul <shrirang.bagul@canonical.com>

BugLink: https://bugs.launchpad.net/bugs/1807334

ACPI GPIO table is defined on platform basis. Remove their definitions
from the Codec driver and include them in the machine driver instead
(where it belongs).

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/soc/codecs/rt5660.c             | 25 -------------------------
 sound/soc/intel/boards/bytcr_rt5660.c | 22 +++++++++++++++++-----
 2 files changed, 17 insertions(+), 30 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt5660.c b/sound/soc/codecs/rt5660.c
index baf18cb42024..e74b2e8cd423 100644
--- a/sound/soc/codecs/rt5660.c
+++ b/sound/soc/codecs/rt5660.c
@@ -9,7 +9,6 @@ 
  * published by the Free Software Foundation.
  */
 
-#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -1252,26 +1251,6 @@  static const struct acpi_device_id rt5660_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, rt5660_acpi_match);
 
-static const struct acpi_gpio_params audio_wake_intr_gpio = { 0, 0, false };
-static const struct acpi_gpio_params lineout_mute_gpio = { 1, 0, true };
-
-static const struct acpi_gpio_mapping byt_rt5660_gpios[] = {
-	{ "audio-wake-intr-gpios", &audio_wake_intr_gpio, 1 },
-	{ "lineout-mute-gpios", &lineout_mute_gpio , 1 },
-	{ NULL },
-};
-
-static void rt5660_read_acpi_properties(struct rt5660_priv *rt5660,
-		struct device *dev)
-{
-	int ret;
-
-	ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
-			byt_rt5660_gpios);
-	if (ret)
-		dev_warn(dev, "Failed to add driver gpios\n");
-}
-
 static int rt5660_parse_dt(struct rt5660_priv *rt5660, struct device *dev)
 {
 	rt5660->pdata.in1_diff = device_property_read_bool(dev,
@@ -1311,10 +1290,6 @@  static int rt5660_i2c_probe(struct i2c_client *i2c,
 		rt5660->pdata = *pdata;
 	else if (i2c->dev.of_node)
 		rt5660_parse_dt(rt5660, &i2c->dev);
-	else if (ACPI_HANDLE(&i2c->dev))
-		rt5660_read_acpi_properties(rt5660, &i2c->dev);
-	else
-		return -EINVAL;
 
 	rt5660->regmap = devm_regmap_init_i2c(i2c, &rt5660_regmap);
 	if (IS_ERR(rt5660->regmap)) {
diff --git a/sound/soc/intel/boards/bytcr_rt5660.c b/sound/soc/intel/boards/bytcr_rt5660.c
index 3003ea2c6319..79618550f5d7 100644
--- a/sound/soc/intel/boards/bytcr_rt5660.c
+++ b/sound/soc/intel/boards/bytcr_rt5660.c
@@ -193,24 +193,36 @@  static int byt_rt5660_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static const struct acpi_gpio_params audio_wake_intr_gpio = { 0, 0, false };
+static const struct acpi_gpio_params lineout_mute_gpio = { 1, 0, true };
+
+static const struct acpi_gpio_mapping byt_rt5660_gpios[] = {
+	{ "audio-wake-intr-gpios", &audio_wake_intr_gpio, 1 },
+	{ "lineout-mute-gpios", &lineout_mute_gpio , 1 },
+	{ NULL },
+};
+
 static int byt_rt5660_init(struct snd_soc_pcm_runtime *runtime)
 {
 	struct snd_soc_card *card = runtime->card;
 	struct byt_rt5660_private *priv = snd_soc_card_get_drvdata(card);
+	struct snd_soc_dai *codec_dai = runtime->codec_dai;
+	struct snd_soc_component *component = codec_dai->component;
+
 	int ret;
 
+	ret = devm_acpi_dev_add_driver_gpios(component->dev, byt_rt5660_gpios);
+	if (ret)
+		dev_warn(component->dev, "Failed to add driver gpios\n");
+
 	/* Request rt5660 GPIO for lineout mute control */
 	priv->gpio_lo_mute = devm_gpiod_get_index(card->dev,
-			"lineout-mute", 0, 0);
+			"lineout-mute", 0, GPIOD_OUT_HIGH);
 	if (IS_ERR(priv->gpio_lo_mute)) {
 		dev_err(card->dev, "Can't find GPIO_MUTE# gpio\n");
 		return PTR_ERR(priv->gpio_lo_mute);
 	}
 
-	ret = gpiod_direction_output(priv->gpio_lo_mute, 1);
-	if (ret)
-		return ret;
-
 	if (byt_rt5660_quirk & BYT_RT5660_MCLK_EN) {
 		/*
 		 * The firmware might enable the clock at