Skip to contentSkip to conversation

ASoC: Chromebook Pixel 2015 support

PATCH Superseded John Keeping 3 participants 15 messages Aug 14, 2016 – Sep 25, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Chromebook Pixel 2015 support

These patches add basic support for audio on the Chromebook Pixel 2015. I took the machine driver from ChromeOS commit v3.14-10186-g7e7d95df2983 and other than removing support for wake on voice (which is not supported by the mainline rt5677 codec driver), the only differences are to cope with API changes since 3.14.

Only two authors have committed changes to the machine driver in the ChromeOS tree and all of the commits are signed off; both authors' SoB lines are preserved in the second commit here.

The codec driver is sufficiently different that I just added ACPI support from scratch using the ChromeOS source as a reference for the property names.

John Keeping (2):
ASoC: rt5677: Add ACPI support
ASoC: Intel: boards: Add bdw-rt5677 machine driver

 sound/soc/codecs/rt5677.c           | 109 +++++++++---
 sound/soc/intel/Kconfig             |  11 ++
 sound/soc/intel/boards/Makefile     |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 341 ++++++++++++++++++++++++++++++++++++
 sound/soc/intel/common/sst-acpi.c   |   1 +
 5 files changed, 443 insertions(+), 21 deletions(-)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c
Signature · 1 line
2.9.3.728.g30b24b4.dirty
#1 lore raw

PATCH 1/2 ASoC: rt5677: Add ACPI support

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, so add an ACPI match table and support for reading properties from ACPI.

---
 sound/soc/codecs/rt5677.c | 109 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 88 insertions(+), 21 deletions(-)
sound/soc/codecs/rt5677.c +88 -21
index da9483c1c6fb..72c4e15a0cc8 100644
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/fs.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -40,6 +41,15 @@
 
 #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
 
+/* GPIO indexes defined by ACPI */
+enum {
+	RT5677_GPIO_PLUG_DET,
+	RT5677_GPIO_MIC_PRESENT_L,
+	RT5677_GPIO_HOTWORD_DET_L,
+	RT5677_GPIO_DSP_INT,
+	RT5677_GPIO_HP_AMP_SHDN_L,
+};
+
 static const struct regmap_range_cfg rt5677_ranges[] = {
 	{
 		.name = "PR",
@@ -5022,29 +5032,57 @@ static const struct i2c_device_id rt5677_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
 
+static const struct acpi_gpio_params plug_det_gpio = { RT5677_GPIO_PLUG_DET, 0, false };
+static const struct acpi_gpio_params mic_present_gpio = { RT5677_GPIO_MIC_PRESENT_L, 0, false };
+static const struct acpi_gpio_params headphone_enable_gpio = { RT5677_GPIO_HP_AMP_SHDN_L, 0, false };
+
+static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = {
+	{ "plug-det-gpios", &plug_det_gpio, 1 },
+	{ "mic-present-gpios", &mic_present_gpio, 1 },
+	{ "headphone-enable-gpios", &headphone_enable_gpio, 1 },
+	{ NULL },
+};
+
 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");
-
-	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);
+	if (ACPI_HANDLE(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");
+		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");
+
+		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);
+	} else {
+		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");
+
+		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);
+	}
 }
 
 static struct regmap_irq rt5677_irqs[] = {
@@ -5123,7 +5161,27 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
 
 	i2c_set_clientdata(i2c, rt5677);
 
-	rt5677->type = id->driver_data;
+	if (ACPI_HANDLE(&i2c->dev)) {
+		const struct acpi_device_id *acpi_id;
+
+		acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table,
+					    &i2c->dev);
+		if (!acpi_id) {
+			dev_err(&i2c->dev, "No driver data\n");
+			return -EINVAL;
+		}
+		rt5677->type = acpi_id->driver_data;
+
+		ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(&i2c->dev),
+						bdw_rt5677_gpios);
+		if (ret) {
+			dev_err(&i2c->dev, "Failed to add driver gpios\n");
+			return ret;
+		}
+
+	} else if (id) {
+		rt5677->type = id->driver_data;
+	}
 
 	if (pdata)
 		rt5677->pdata = *pdata;
@@ -5238,9 +5296,18 @@ static int rt5677_i2c_remove(struct i2c_client *i2c)
 	return 0;
 }
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id rt5677_acpi_id[] = {
+	{ "RT5677CE", RT5677 },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, rt5677_acpi_id);
+#endif
+
 static struct i2c_driver rt5677_i2c_driver = {
 	.driver = {
 		.name = "rt5677",
+		.acpi_match_table = ACPI_PTR(rt5677_acpi_id),
 	},
 	.probe = rt5677_i2c_probe,
 	.remove   = rt5677_i2c_remove,
Signature · 1 line
2.9.3.728.g30b24b4.dirty
maintainer
#2 lore raw

Re: [PATCH 1/2] ASoC: rt5677: Add ACPI support

Quoted 2 lines · John Keeping

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, so add an ACPI match table and support for reading properties from ACPI.

This would be a lot easier to review with a concrete description of what "support for reading properties from ACPI" means and probably also split out a bit so that different things were being added separately.

sound/soc/codecs/rt5677.c line 51

Quoted 8 lines
sound/soc/codecs/rt5677.c +8 -0
+/* GPIO indexes defined by ACPI */
+enum {
+	RT5677_GPIO_PLUG_DET,
+	RT5677_GPIO_MIC_PRESENT_L,
+	RT5677_GPIO_HOTWORD_DET_L,
+	RT5677_GPIO_DSP_INT,
+	RT5677_GPIO_HP_AMP_SHDN_L,
+};

If these are an ABI you should explicitly assign the values so that they can't get remapped by future edits. If they're not an ABI I don't understand the comment.

sound/soc/codecs/rt5677.c static const struct i2c_device_id rt5677_i2c_id[] = { · line 5056

Quoted 8 lines
sound/soc/codecs/rt5677.c +8 -0
+	if (ACPI_HANDLE(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");
+		rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2");

What happens if someone makes a machine which uses the DT<->ACPI mappings (especially given that this is currently undocumented)? That would not work which defeats the whole purpose of using the device property APIs. Shouldn't we be accepting either property?

#3 lore raw

Re: [PATCH 1/2] ASoC: rt5677: Add ACPI support

Quoted 8 lines · Mark Brown
Quoted 2 lines · John Keeping

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, so add an ACPI match table and support for reading properties from ACPI.

This would be a lot easier to review with a concrete description of what "support for reading properties from ACPI" means and probably also split out a bit so that different things were being added separately.

OK, I'll have a think about this, although I'm not sure how much it can be split up. We can add the ACPI device property names in a separate patch and maybe add the match table as a final step, but the GPIO mapping and probe changes depend on each other.

Quoted 4 lines
Quoted 4 lines
sound/soc/codecs/rt5677.c +4 -0
+/* GPIO indexes defined by ACPI */
+enum {
+	RT5677_GPIO_PLUG_DET,
+	RT5677_GPIO_MIC_PRESENT_L,
Quoted 8 lines

sound/soc/codecs/rt5677.c line 51

Quoted 4 lines
sound/soc/codecs/rt5677.c +4 -0
+	RT5677_GPIO_HOTWORD_DET_L,
+	RT5677_GPIO_DSP_INT,
+	RT5677_GPIO_HP_AMP_SHDN_L,
+};  

If these are an ABI you should explicitly assign the values so that they can't get remapped by future edits. If they're not an ABI I don't understand the comment.

Yes, these are ABI. I'll add explicit values.

Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/rt5677.c +5 -0
+	if (ACPI_HANDLE(dev)) {
+		u32 val;
+
+		if (!device_property_read_u32(dev, "DCLK", &val))
+			rt5677->pdata.dmic2_clk_pin = val;
Quoted 8 lines

sound/soc/codecs/rt5677.c static const struct i2c_device_id rt5677_i2c_id[] = { · line 5056

Quoted 3 lines
sound/soc/codecs/rt5677.c +3 -0
+
+		rt5677->pdata.in1_diff = device_property_read_bool(dev, "IN1");
+		rt5677->pdata.in2_diff = device_property_read_bool(dev, "IN2");  

What happens if someone makes a machine which uses the DT<->ACPI mappings (especially given that this is currently undocumented)? That would not work which defeats the whole purpose of using the device property APIs. Shouldn't we be accepting either property?

I'm not sure we want to accept undocumented properties in the DT case. I went looking for other drivers that have different property names for ACPI and DT and the only example I could find is:

drivers/net/ethernet/amd/xgbe/xgbe-main.c

In that case there are separate functions for parsing DT and ACPI properties. Having separate functions would have made this patch a lot clearer, so if we keep the separation between DT and ACPI I'll make that change for the next round.

The ideal might be to have something similar to the ACPI GPIO mapping support so that the ACPI device property code could handle the different names, but that feels like overkill if there are only two drivers that use different property names in DT and ACPI.

#4 lore raw

PATCH 2/2 ASoC: Intel: boards: Add bdw-rt5677 machine driver

In reply to John Keeping

This is used by the Chromebook Pixel 2015.

[jk:
- forward-port driver from ChromeOS 3.14 tree to master
- remove wake on voice function that isn't supported by upstream rt5677 driver]

---
 sound/soc/intel/Kconfig             |  11 ++
 sound/soc/intel/boards/Makefile     |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 341 ++++++++++++++++++++++++++++++++++++
 sound/soc/intel/common/sst-acpi.c   |   1 +
 4 files changed, 355 insertions(+)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c
sound/soc/intel/Kconfig +11 -0
index a20c3dfbcb5d..b141b226510d 100644
@@ -120,6 +120,17 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH
 	  This adds audio driver for Intel Baytrail platform based boards
 	  with the MAX98090 audio codec.
 
+config SND_SOC_INTEL_BDW_RT5677_MACH
+	tristate "ASoC Audio driver for Intel Broadwell with RT5677 codec"
+	depends on X86_INTEL_LPSS && I2C && DW_DMAC
+	depends on DW_DMAC_CORE=y
+	select SND_SOC_INTEL_SST
+	select SND_SOC_INTEL_HASWELL
+	select SND_SOC_RT5677
+	help
+	  This adds support for Intel Broadwell platform based boards with
+	  the RT5677 audio codec.
+
 config SND_SOC_INTEL_BROADWELL_MACH
 	tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
 	depends on X86_INTEL_LPSS && I2C && DW_DMAC && \
sound/soc/intel/boards/Makefile +2 -0
index dac03a06bfd8..5639f10774e6 100644
@@ -1,6 +1,7 @@
 snd-soc-sst-haswell-objs := haswell.o
 snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o
 snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o
+snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o
 snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o
 snd-soc-sst-bxt-rt298-objs := bxt_rt298.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += snd-soc-sst-bxt-da7219_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
+obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
sound/soc/intel/boards/bdw-rt5677.c new file +341 -0

341 lines not on this page · raw message

sound/soc/intel/common/sst-acpi.c +1 -0
index 2c5eda14d510..1285cc597b6b 100644
@@ -199,6 +199,7 @@ static struct sst_acpi_desc sst_acpi_haswell_desc = {
 
 static struct sst_acpi_mach broadwell_machines[] = {
 	{ "INT343A", "broadwell-audio", "intel/IntcSST2.bin", NULL, NULL, NULL },
+	{ "RT5677CE", "bdw-rt5677", "intel/IntcSST2.bin", NULL, NULL, NULL },
 	{}
 };
 
Signature · 1 line
2.9.3.728.g30b24b4.dirty
#5 lore raw

Re: [PATCH 2/2] ASoC: Intel: boards: Add bdw-rt5677 machine driver

Hi Ben,

sound/soc/intel/boards/bdw-rt5677.c line 3

Quoted 5 lines
sound/soc/intel/boards/bdw-rt5677.c +3 -0
@@ -0,0 +1,341 @@
+/*
+ * ASoC machine driver for Intel Broadwell platforms with RT5677 codec
+ */

It has been pointed out to me that this file lacks a proper license header; I pulled it from the chromeos-3.14 branch and I can't see a version with a license header.

The module properties indicate GPLv2, but who should be the subject of the copyright statement?

Thanks,
John

#6 lore raw

v2 cover ASoC: Chromebook Pixel 2015 audio support

In reply to John Keeping

This is the second version of the series originally posted here [1].

The second patch is largely unchanged and is still derived from the Chromium OS 3.14 source, but the patch to the codec driver now takes a different approach that I hope is easier to review as well resulting in less code.

[1] https://lkml.org/lkml/2016/8/14/207

John Keeping (2):
ASoC: rt5677: Add ACPI support
ASoC: Intel: boards: Add bdw-rt5677 machine driver

 sound/soc/codecs/rt5677.c           |  53 +++++-
 sound/soc/intel/Kconfig             |  11 ++
 sound/soc/intel/boards/Makefile     |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 347 ++++++++++++++++++++++++++++++++++++
 sound/soc/intel/common/sst-acpi.c   |   1 +
 5 files changed, 413 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c
Signature · 1 line
2.9.3.728.g30b24b4.dirty
#7 lore raw

PATCH v2 1/2 ASoC: rt5677: Add ACPI support

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, but does not use the standard DT property names so add a new function to parse the codec properties from these ACPI properties.

Also, the GPIOs are only available by index, so we need to register a mapping to allow machine drivers to access the GPIOs by name.

---
Changes in v2:
- Add explicit values to ACPI GPIO enum
- Add new function for reading ACPI properties, leave the existing rt5677_read_device_properties() as it was
- Add entry to i2c_device_id table instead of adding acpi_driver_id

 sound/soc/codecs/rt5677.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5677.c +52 -1
index da9483c1c6fb..0e7aba1af881 100644
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/fs.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -40,6 +41,15 @@
 
 #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
 
+/* GPIO indexes defined by ACPI */
+enum {
+	RT5677_GPIO_PLUG_DET		= 0,
+	RT5677_GPIO_MIC_PRESENT_L	= 1,
+	RT5677_GPIO_HOTWORD_DET_L	= 2,
+	RT5677_GPIO_DSP_INT		= 3,
+	RT5677_GPIO_HP_AMP_SHDN_L	= 4,
+};
+
 static const struct regmap_range_cfg rt5677_ranges[] = {
 	{
 		.name = "PR",
@@ -5018,10 +5028,47 @@ static const struct regmap_config rt5677_regmap = {
 static const struct i2c_device_id rt5677_i2c_id[] = {
 	{ "rt5677", RT5677 },
 	{ "rt5676", RT5676 },
+	{ "RT5677CE:00", RT5677 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
 
+static const struct acpi_gpio_params plug_det_gpio = { RT5677_GPIO_PLUG_DET, 0, false };
+static const struct acpi_gpio_params mic_present_gpio = { RT5677_GPIO_MIC_PRESENT_L, 0, false };
+static const struct acpi_gpio_params headphone_enable_gpio = { RT5677_GPIO_HP_AMP_SHDN_L, 0, false };
+
+static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = {
+	{ "plug-det-gpios", &plug_det_gpio, 1 },
+	{ "mic-present-gpios", &mic_present_gpio, 1 },
+	{ "headphone-enable-gpios", &headphone_enable_gpio, 1 },
+	{ NULL },
+};
+
+static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677,
+		struct device *dev)
+{
+	int ret;
+	u32 val;
+
+	ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
+			bdw_rt5677_gpios);
+	if (ret)
+		dev_warn(dev, "Failed to add driver gpios\n");
+
+	if (!device_property_read_u32(dev, "DCLK", &val))
+		rt5677->pdata.dmic2_clk_pin = val;
+
+	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");
+
+	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);
+}
+
 static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
 		struct device *dev)
 {
@@ -5127,8 +5174,12 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
 
 	if (pdata)
 		rt5677->pdata = *pdata;
-	else
+	else if (i2c->dev.of_node)
 		rt5677_read_device_properties(rt5677, &i2c->dev);
+	else if (ACPI_HANDLE(&i2c->dev))
+		rt5677_read_acpi_properties(rt5677, &i2c->dev);
+	else
+		return -EINVAL;
 
 	/* pow-ldo2 and reset are optional. The codec pins may be statically
 	 * connected on the board without gpios. If the gpio device property
Signature · 1 line
2.9.3.728.g30b24b4.dirty
Tested-by on v2 1/2
#8 lore raw

Re: [PATCH v2 1/2] ASoC: rt5677: Add ACPI support

Quoted 8 lines · John Keeping

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, but does not use the standard DT property names so add a new function to parse the codec properties from these ACPI properties.

Also, the GPIOs are only available by index, so we need to register a mapping to allow machine drivers to access the GPIOs by name.

Signature · 1 line
Tom
maintainer
#9 lore raw

Applied "ASoC: rt5677: Add ACPI support" to the asoc tree

In reply to John Keeping

The patch

ASoC: rt5677: Add ACPI support

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 89128534f925711eea1653c264683b7d14a46530 Mon Sep 17 00:00:00 2001

From: John Keeping <[email protected]>
Date: Wed, 24 Aug 2016 22:06:35 +0100
Subject: [PATCH] ASoC: rt5677: Add ACPI support

The Chromebook Pixel 2015 uses this codec with the ACPI ID RT5677CE, but does not use the standard DT property names so add a new function to parse the codec properties from these ACPI properties.

Also, the GPIOs are only available by index, so we need to register a mapping to allow machine drivers to access the GPIOs by name.

---
 sound/soc/codecs/rt5677.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5677.c +52 -1
index da9483c1c6fb..0e7aba1af881 100644
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/fs.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -40,6 +41,15 @@
 
 #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING))
 
+/* GPIO indexes defined by ACPI */
+enum {
+	RT5677_GPIO_PLUG_DET		= 0,
+	RT5677_GPIO_MIC_PRESENT_L	= 1,
+	RT5677_GPIO_HOTWORD_DET_L	= 2,
+	RT5677_GPIO_DSP_INT		= 3,
+	RT5677_GPIO_HP_AMP_SHDN_L	= 4,
+};
+
 static const struct regmap_range_cfg rt5677_ranges[] = {
 	{
 		.name = "PR",
@@ -5018,10 +5028,47 @@ static const struct regmap_config rt5677_regmap = {
 static const struct i2c_device_id rt5677_i2c_id[] = {
 	{ "rt5677", RT5677 },
 	{ "rt5676", RT5676 },
+	{ "RT5677CE:00", RT5677 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
 
+static const struct acpi_gpio_params plug_det_gpio = { RT5677_GPIO_PLUG_DET, 0, false };
+static const struct acpi_gpio_params mic_present_gpio = { RT5677_GPIO_MIC_PRESENT_L, 0, false };
+static const struct acpi_gpio_params headphone_enable_gpio = { RT5677_GPIO_HP_AMP_SHDN_L, 0, false };
+
+static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = {
+	{ "plug-det-gpios", &plug_det_gpio, 1 },
+	{ "mic-present-gpios", &mic_present_gpio, 1 },
+	{ "headphone-enable-gpios", &headphone_enable_gpio, 1 },
+	{ NULL },
+};
+
+static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677,
+		struct device *dev)
+{
+	int ret;
+	u32 val;
+
+	ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
+			bdw_rt5677_gpios);
+	if (ret)
+		dev_warn(dev, "Failed to add driver gpios\n");
+
+	if (!device_property_read_u32(dev, "DCLK", &val))
+		rt5677->pdata.dmic2_clk_pin = val;
+
+	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");
+
+	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);
+}
+
 static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
 		struct device *dev)
 {
@@ -5127,8 +5174,12 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
 
 	if (pdata)
 		rt5677->pdata = *pdata;
-	else
+	else if (i2c->dev.of_node)
 		rt5677_read_device_properties(rt5677, &i2c->dev);
+	else if (ACPI_HANDLE(&i2c->dev))
+		rt5677_read_acpi_properties(rt5677, &i2c->dev);
+	else
+		return -EINVAL;
 
 	/* pow-ldo2 and reset are optional. The codec pins may be statically
 	 * connected on the board without gpios. If the gpio device property
Signature · 1 line
2.9.3
#10 lore raw

PATCH v2 2/2 ASoC: Intel: boards: Add bdw-rt5677 machine driver

In reply to John Keeping

This is used by the Chromebook Pixel 2015.

[[email protected]:
- forward-port driver from Chromium OS 3.14 tree to master
- remove wake on voice function that isn't supported by upstream rt5677 driver
- remote owner assignment in platform_driver (Evan McClain)
- convert to devm_snd_soc_register_card (Evan McClain)
- add a full copyright header based on module license and Chromium OS Git history
]

---
Changes in v2:
- Remove owner assignment from platform_driver
- Convert to devm_snd_soc_register_card
- Add GPIOLIB dependency
- Add copyright header

 sound/soc/intel/Kconfig             |  11 ++
 sound/soc/intel/boards/Makefile     |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 347 ++++++++++++++++++++++++++++++++++++
 sound/soc/intel/common/sst-acpi.c   |   1 +
 4 files changed, 361 insertions(+)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c
sound/soc/intel/Kconfig +11 -0
index a20c3dfbcb5d..a77db4b0961c 100644
@@ -120,6 +120,17 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH
 	  This adds audio driver for Intel Baytrail platform based boards
 	  with the MAX98090 audio codec.
 
+config SND_SOC_INTEL_BDW_RT5677_MACH
+	tristate "ASoC Audio driver for Intel Broadwell with RT5677 codec"
+	depends on X86_INTEL_LPSS && GPIOLIB && I2C && DW_DMAC
+	depends on DW_DMAC_CORE=y
+	select SND_SOC_INTEL_SST
+	select SND_SOC_INTEL_HASWELL
+	select SND_SOC_RT5677
+	help
+	  This adds support for Intel Broadwell platform based boards with
+	  the RT5677 audio codec.
+
 config SND_SOC_INTEL_BROADWELL_MACH
 	tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
 	depends on X86_INTEL_LPSS && I2C && DW_DMAC && \
sound/soc/intel/boards/Makefile +2 -0
index dac03a06bfd8..5639f10774e6 100644
@@ -1,6 +1,7 @@
 snd-soc-sst-haswell-objs := haswell.o
 snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o
 snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o
+snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o
 snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o
 snd-soc-sst-bxt-rt298-objs := bxt_rt298.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += snd-soc-sst-bxt-da7219_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
+obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
sound/soc/intel/boards/bdw-rt5677.c new file +347 -0

347 lines not on this page · raw message

sound/soc/intel/common/sst-acpi.c +1 -0
index 2c5eda14d510..1285cc597b6b 100644
@@ -199,6 +199,7 @@ static struct sst_acpi_desc sst_acpi_haswell_desc = {
 
 static struct sst_acpi_mach broadwell_machines[] = {
 	{ "INT343A", "broadwell-audio", "intel/IntcSST2.bin", NULL, NULL, NULL },
+	{ "RT5677CE", "bdw-rt5677", "intel/IntcSST2.bin", NULL, NULL, NULL },
 	{}
 };
 
Signature · 1 line
2.9.3.728.g30b24b4.dirty
Tested-by on v2 2/2
#11 lore raw

Re: [PATCH v2 2/2] ASoC: Intel: boards: Add bdw-rt5677 machine driver

Quoted 13 lines · John Keeping

This is used by the Chromebook Pixel 2015.

[[email protected]:
- forward-port driver from Chromium OS 3.14 tree to master
- remove wake on voice function that isn't supported by upstream rt5677 driver
- remote owner assignment in platform_driver (Evan McClain)
- convert to devm_snd_soc_register_card (Evan McClain)
- add a full copyright header based on module license and Chromium OS Git history
]

Quoted 2 lines
Signature · 1 line
Tom
maintainer
#12 lore raw

Applied "ASoC: Intel: boards: Add bdw-rt5677 machine driver" to the asoc tree

In reply to John Keeping

The patch

ASoC: Intel: boards: Add bdw-rt5677 machine driver

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 2d995e5dc283adbfbf9c1eb81bf35ca7af2d22a6 Mon Sep 17 00:00:00 2001

From: John Keeping <[email protected]>
Date: Wed, 24 Aug 2016 22:06:36 +0100
Subject: [PATCH] ASoC: Intel: boards: Add bdw-rt5677 machine driver

This is used by the Chromebook Pixel 2015.

[[email protected]:
- forward-port driver from Chromium OS 3.14 tree to master
- remove wake on voice function that isn't supported by upstream rt5677 driver
- remote owner assignment in platform_driver (Evan McClain)
- convert to devm_snd_soc_register_card (Evan McClain)
- add a full copyright header based on module license and Chromium OS Git history
]

---
 sound/soc/intel/Kconfig             |  11 ++
 sound/soc/intel/boards/Makefile     |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 347 ++++++++++++++++++++++++++++++++++++
 sound/soc/intel/common/sst-acpi.c   |   1 +
 4 files changed, 361 insertions(+)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c
sound/soc/intel/Kconfig +11 -0
index fc6e78050a79..26eb5a0a5575 100644
@@ -121,6 +121,17 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH
 	  This adds audio driver for Intel Baytrail platform based boards
 	  with the MAX98090 audio codec.
 
+config SND_SOC_INTEL_BDW_RT5677_MACH
+	tristate "ASoC Audio driver for Intel Broadwell with RT5677 codec"
+	depends on X86_INTEL_LPSS && GPIOLIB && I2C && DW_DMAC
+	depends on DW_DMAC_CORE=y
+	select SND_SOC_INTEL_SST
+	select SND_SOC_INTEL_HASWELL
+	select SND_SOC_RT5677
+	help
+	  This adds support for Intel Broadwell platform based boards with
+	  the RT5677 audio codec.
+
 config SND_SOC_INTEL_BROADWELL_MACH
 	tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
 	depends on X86_INTEL_LPSS && I2C && DW_DMAC && \
sound/soc/intel/boards/Makefile +2 -0
index dac03a06bfd8..5639f10774e6 100644
@@ -1,6 +1,7 @@
 snd-soc-sst-haswell-objs := haswell.o
 snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o
 snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o
+snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o
 snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o
 snd-soc-sst-bxt-rt298-objs := bxt_rt298.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += snd-soc-sst-bxt-da7219_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
+obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
sound/soc/intel/boards/bdw-rt5677.c new file +347 -0

347 lines not on this page · raw message

sound/soc/intel/common/sst-acpi.c +1 -0
index 2c5eda14d510..1285cc597b6b 100644
@@ -199,6 +199,7 @@ static struct sst_acpi_desc sst_acpi_haswell_desc = {
 
 static struct sst_acpi_mach broadwell_machines[] = {
 	{ "INT343A", "broadwell-audio", "intel/IntcSST2.bin", NULL, NULL, NULL },
+	{ "RT5677CE", "bdw-rt5677", "intel/IntcSST2.bin", NULL, NULL, NULL },
 	{}
 };
 
Signature · 1 line
2.9.3
#13 lore raw

Re: [PATCH v2 0/2] ASoC: Chromebook Pixel 2015 audio support

In reply to John Keeping
Quoted 8 lines · John Keeping

This is the second version of the series originally posted here [1].

The second patch is largely unchanged and is still derived from the Chromium OS 3.14 source, but the patch to the codec driver now takes a different approach that I hope is easier to review as well resulting in less code.

[1] https://lkml.org/lkml/2016/8/14/207

Ping? Is there anything I can do to help move this forward?

Quoted 12 lines

John Keeping (2):
ASoC: rt5677: Add ACPI support
ASoC: Intel: boards: Add bdw-rt5677 machine driver

 sound/soc/codecs/rt5677.c           |  53 +++++-
 sound/soc/intel/Kconfig             |  11 ++
 sound/soc/intel/boards/Makefile     |   2 +
 sound/soc/intel/boards/bdw-rt5677.c | 347 ++++++++++++++++++++++++++++++++++++
 sound/soc/intel/common/sst-acpi.c   |   1 +
 5 files changed, 413 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/boards/bdw-rt5677.c
maintainer
#14 lore raw

Re: [PATCH v2 0/2] ASoC: Chromebook Pixel 2015 audio support

Quoted 3 lines · John Keeping

On Wed, 24 Aug 2016 22:06:34 +0100, John Keeping wrote:

Ping? Is there anything I can do to help move this forward?

Please don't send content free pings and please allow a reasonable time for review. People get busy, go on holiday, attend conferences and so on so unless there is some reason for urgency (like critical bug fixes) please allow at least a couple of weeks for review. If there have been review comments then people may be waiting for those to be addressed.

Sending content free pings adds to the mail volume (if they are seen at all) which is often the problem and since they can't be reviewed directly if something has gone wrong you'll have to resend the patches anyway, though there are some other maintainers who like them - if in doubt look at how patches for the subsystem are normally handled.