All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Add support for es8388 on the rock2
@ 2017-01-13 16:14 Romain Perier
  2017-01-13 16:14 ` [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388 Romain Perier
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Romain Perier @ 2017-01-13 16:14 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel, Heiko Stuebner
  Cc: Mark Rutland, devicetree, Pawel Moll, Ian Campbell,
	linux-rockchip, Sjoerd Simons, Rob Herring, Kumar Gala,
	Romain Perier

This set of patches adds a machine driver for rockchip boards that use
ES8388 codecs. It also adds slave mode to the es8328 driver that
currently only supported the master mode. Then, it adds the required DT
definitions to link rockchip-i2s to the es8388 analog output.

This work is based on the initial work that was done by Sjoerd Simons
<sjoerd.simons@collabora.co.uk> with some improvements, changes and more
commits.

Romain Perier (4):
  ASoC: es8328-i2c: Add compatible for ES8388
  ASoC: es8328: Add support for slave mode
  ASoC: rockchip: Add machine driver for ES8388 codecs
  arm: dts: Add support for ES8388 to the Radxa Rock 2

 Documentation/devicetree/bindings/sound/es8328.txt |   2 +-
 .../devicetree/bindings/sound/rockchip-es8388.txt  |  28 +++
 arch/arm/boot/dts/rk3288-rock2-square.dts          |  37 +++
 sound/soc/codecs/es8328-i2c.c                      |   3 +-
 sound/soc/codecs/es8328.c                          |  28 ++-
 sound/soc/rockchip/Kconfig                         |   9 +
 sound/soc/rockchip/Makefile                        |   2 +
 sound/soc/rockchip/rockchip_es8388.c               | 270 +++++++++++++++++++++
 8 files changed, 371 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/rockchip-es8388.txt
 create mode 100644 sound/soc/rockchip/rockchip_es8388.c

-- 
2.9.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388
  2017-01-13 16:14 [PATCH 0/4] Add support for es8388 on the rock2 Romain Perier
@ 2017-01-13 16:14 ` Romain Perier
       [not found]   ` <20170113161452.14313-2-romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
  2017-01-13 16:14 ` [PATCH 2/4] ASoC: es8328: Add support for slave mode Romain Perier
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Romain Perier @ 2017-01-13 16:14 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel, Heiko Stuebner
  Cc: Mark Rutland, devicetree, Pawel Moll, Ian Campbell,
	linux-rockchip, Sjoerd Simons, Rob Herring, Kumar Gala,
	Romain Perier

This commit adds a compatible string for everest,es8388. This is
an audio codec that is compatible with es8328.

Signed-off-by: Romain Perier <romain.perier@collabora.com>
---
 Documentation/devicetree/bindings/sound/es8328.txt | 2 +-
 sound/soc/codecs/es8328-i2c.c                      | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/es8328.txt b/Documentation/devicetree/bindings/sound/es8328.txt
index 30ea8a3..33fbf05 100644
--- a/Documentation/devicetree/bindings/sound/es8328.txt
+++ b/Documentation/devicetree/bindings/sound/es8328.txt
@@ -4,7 +4,7 @@ This device supports both I2C and SPI.
 
 Required properties:
 
-  - compatible : "everest,es8328"
+  - compatible  : Should be "everest,es8328" or "everest,es8388"
   - DVDD-supply : Regulator providing digital core supply voltage 1.8 - 3.6V
   - AVDD-supply : Regulator providing analog supply voltage 3.3V
   - PVDD-supply : Regulator providing digital IO supply voltage 1.8 - 3.6V
diff --git a/sound/soc/codecs/es8328-i2c.c b/sound/soc/codecs/es8328-i2c.c
index 2d05b5d..09ae67f 100644
--- a/sound/soc/codecs/es8328-i2c.c
+++ b/sound/soc/codecs/es8328-i2c.c
@@ -19,13 +19,14 @@
 #include "es8328.h"
 
 static const struct i2c_device_id es8328_id[] = {
-	{ "es8328", 0 },
+	{ "es8328", "es8388", 0 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, es8328_id);
 
 static const struct of_device_id es8328_of_match[] = {
 	{ .compatible = "everest,es8328", },
+	{ .compatible = "everest,es8388", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, es8328_of_match);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] ASoC: es8328: Add support for slave mode
  2017-01-13 16:14 [PATCH 0/4] Add support for es8388 on the rock2 Romain Perier
  2017-01-13 16:14 ` [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388 Romain Perier
@ 2017-01-13 16:14 ` Romain Perier
  2017-01-13 16:14 ` [PATCH 3/4] ASoC: rockchip: Add machine driver for ES8388 codecs Romain Perier
  2017-01-13 16:14 ` [PATCH 4/4] arm: dts: Add support for ES8388 to the Radxa Rock 2 Romain Perier
  3 siblings, 0 replies; 9+ messages in thread
From: Romain Perier @ 2017-01-13 16:14 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel, Heiko Stuebner
  Cc: Mark Rutland, devicetree, Pawel Moll, Ian Campbell,
	linux-rockchip, Sjoerd Simons, Rob Herring, Kumar Gala,
	Romain Perier

Currently, the function that changes the DAI format only supports master
mode. Trying to use a slave mode exits the function with -EINVAL and
leave the codec misconfigured. This commits adds support for enabling
the slave mode.

Signed-off-by: Romain Perier <romain.perier@collabora.com>
---
 sound/soc/codecs/es8328.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c
index 37722194..054e123 100644
--- a/sound/soc/codecs/es8328.c
+++ b/sound/soc/codecs/es8328.c
@@ -588,10 +588,18 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai,
 	struct snd_soc_codec *codec = codec_dai->codec;
 	u8 dac_mode = 0;
 	u8 adc_mode = 0;
+	bool master;
 
-	/* set master/slave audio interface */
-	if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBM_CFM)
-		return -EINVAL;
+	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+		case SND_SOC_DAIFMT_CBM_CFM:
+			master = true;
+			break;
+		case SND_SOC_DAIFMT_CBS_CFS:
+			master = false;
+			break;
+		default:
+			return -EINVAL;
+	}
 
 	/* interface format */
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -620,9 +628,17 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai,
 	snd_soc_update_bits(codec, ES8328_ADCCONTROL4,
 			ES8328_ADCCONTROL4_ADCFORMAT_MASK, adc_mode);
 
-	/* Master serial port mode, with BCLK generated automatically */
-	snd_soc_update_bits(codec, ES8328_MASTERMODE,
-			ES8328_MASTERMODE_MSC, ES8328_MASTERMODE_MSC);
+	if (master) {
+		/* Master serial port mode, with BCLK generated automatically */
+		snd_soc_update_bits(codec, ES8328_MASTERMODE,
+				    ES8328_MASTERMODE_MSC,
+				    ES8328_MASTERMODE_MSC);
+	} else {
+		/* Slave serial port mode */
+		snd_soc_update_bits(codec, ES8328_MASTERMODE,
+				    ES8328_MASTERMODE_MSC,
+				    0);
+	}
 
 	return 0;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] ASoC: rockchip: Add machine driver for ES8388 codecs
  2017-01-13 16:14 [PATCH 0/4] Add support for es8388 on the rock2 Romain Perier
  2017-01-13 16:14 ` [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388 Romain Perier
  2017-01-13 16:14 ` [PATCH 2/4] ASoC: es8328: Add support for slave mode Romain Perier
@ 2017-01-13 16:14 ` Romain Perier
       [not found]   ` <20170113161452.14313-4-romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
  2017-01-13 16:14 ` [PATCH 4/4] arm: dts: Add support for ES8388 to the Radxa Rock 2 Romain Perier
  3 siblings, 1 reply; 9+ messages in thread
From: Romain Perier @ 2017-01-13 16:14 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel, Heiko Stuebner
  Cc: Mark Rutland, devicetree, Pawel Moll, Ian Campbell,
	linux-rockchip, Sjoerd Simons, Rob Herring, Kumar Gala,
	Romain Perier

The driver is used for Rockchip boards using an audio codec compatible
with ES8388.

This commit is based on the initial work that was done by Sjoerd Simons
<sjoerd.simons@collabora.co.uk> with some improvements.

Signed-off-by: Romain Perier <romain.perier@collabora.com>
---
 .../devicetree/bindings/sound/rockchip-es8388.txt  |  28 +++
 sound/soc/rockchip/Kconfig                         |   9 +
 sound/soc/rockchip/Makefile                        |   2 +
 sound/soc/rockchip/rockchip_es8388.c               | 270 +++++++++++++++++++++
 4 files changed, 309 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/rockchip-es8388.txt
 create mode 100644 sound/soc/rockchip/rockchip_es8388.c

diff --git a/Documentation/devicetree/bindings/sound/rockchip-es8388.txt b/Documentation/devicetree/bindings/sound/rockchip-es8388.txt
new file mode 100644
index 0000000..03a0507
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/rockchip-es8388.txt
@@ -0,0 +1,28 @@
+ROCKCHIP with ES8388 CODECS
+
+Required properties:
+- compatible: "rockchip,rockchip-audio-es8388"
+- rockchip,model: The user-visible name of this sound complex
+- rockchip,i2s-controller: The phandle of the Rockchip I2S controller that's
+  connected to the CODEC
+- rockchip,audio-codec: The phandle of the es8388 audio codec
+
+Optionnal properties:
+- rockchip,hp-en-gpios = The phandle of the GPIO that power up/down the
+  headphone.
+- rockchip,hp-det-gpios = The phandle of the GPIO that detects the headphone
+- pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt
+
+Example:
+	
+sound {
+	compatible = "rockchip,rockchip-audio-es8388";
+	rockchip,model = "Analog audio output";
+	rockchip,i2s-controller = <&i2s>;
+	rockchip,audio-codec = <&es8388>;
+	rockchip,hp-en-gpios = <&gpio8 0 GPIO_ACTIVE_HIGH>;
+	rockchip,hp-det-gpios = <&gpio7 7 GPIO_ACTIVE_HIGH>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&headphone>;
+};
+
diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig
index c783f9a..ec982c5 100644
--- a/sound/soc/rockchip/Kconfig
+++ b/sound/soc/rockchip/Kconfig
@@ -42,6 +42,15 @@ config SND_SOC_ROCKCHIP_RT5645
 	  Say Y or M here if you want to add support for SoC audio on Rockchip
 	  boards using the RT5645/RT5650 codec, such as Veyron.
 
+config SND_SOC_ROCKCHIP_ES8388
+	tristate "ASoC support for Rockchip boards using a ES8388 codec"
+	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB
+	select SND_SOC_ROCKCHIP_I2S
+	select SND_SOC_ES8328_I2C if I2C
+	help
+	  Say Y or M here if you want to add support for SoC audio on Rockchip
+	  boards using the ES8388 Codec such as Radxa Rock 2
+
 config SND_SOC_RK3399_GRU_SOUND
 	tristate "ASoC support multiple codecs for Rockchip RK3399 GRU boards"
 	depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP && SPI
diff --git a/sound/soc/rockchip/Makefile b/sound/soc/rockchip/Makefile
index 84e5c7c..759db5e 100644
--- a/sound/soc/rockchip/Makefile
+++ b/sound/soc/rockchip/Makefile
@@ -7,8 +7,10 @@ obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIF) += snd-soc-rockchip-spdif.o
 
 snd-soc-rockchip-max98090-objs := rockchip_max98090.o
 snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o
+snd-soc-rockchip-es8388-objs := rockchip_es8388.o
 snd-soc-rk3399-gru-sound-objs := rk3399_gru_sound.o
 
 obj-$(CONFIG_SND_SOC_ROCKCHIP_MAX98090) += snd-soc-rockchip-max98090.o
 obj-$(CONFIG_SND_SOC_ROCKCHIP_RT5645) += snd-soc-rockchip-rt5645.o
+obj-$(CONFIG_SND_SOC_ROCKCHIP_ES8388) += snd-soc-rockchip-es8388.o
 obj-$(CONFIG_SND_SOC_RK3399_GRU_SOUND) += snd-soc-rk3399-gru-sound.o
diff --git a/sound/soc/rockchip/rockchip_es8388.c b/sound/soc/rockchip/rockchip_es8388.c
new file mode 100644
index 0000000..b23ce8e
--- /dev/null
+++ b/sound/soc/rockchip/rockchip_es8388.c
@@ -0,0 +1,270 @@
+/*
+ * Rockchip machine ASoC driver for boards using a ES8388 CODEC.
+ *
+ * Copyright (c) 2016, Collabora Ltd.
+ *
+ * Authors: Sjoerd Simons <sjoerd.simons@collabora.com>,
+ *	    Romain Perier <romain.perier@collabora.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+#include <sound/core.h>
+#include <sound/jack.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include "rockchip_i2s.h"
+
+#define DRV_NAME "rockchip-snd-es8388"
+
+struct rk_es8388_drvdata {
+	int gpio_hp_en;
+	int gpio_hp_det;
+};
+
+static int rk_es8388_hp_power(struct snd_soc_dapm_widget *w,
+			      struct snd_kcontrol *k, int event)
+{
+	struct rk_es8388_drvdata *machine = snd_soc_card_get_drvdata(w->dapm->card);
+
+	if (!gpio_is_valid(machine->gpio_hp_en))
+		return 0;
+
+	gpio_set_value_cansleep(machine->gpio_hp_en,
+				SND_SOC_DAPM_EVENT_ON(event));
+
+	return 0;
+}
+
+static struct snd_soc_jack headphone_jack;
+static struct snd_soc_jack_pin headphone_jack_pins[] = {
+	{
+		.pin = "Headphone",
+		.mask = SND_JACK_HEADPHONE
+	},
+};
+
+static const struct snd_soc_dapm_widget rk_dapm_widgets[] = {
+	SND_SOC_DAPM_HP("Headphone", rk_es8388_hp_power),
+};
+
+static const struct snd_soc_dapm_route rk_audio_map[] = {
+	{"Headphone", NULL, "LOUT2"},
+	{"Headphone", NULL, "ROUT2"},
+};
+
+static const struct snd_kcontrol_new rk_mc_controls[] = {
+	SOC_DAPM_PIN_SWITCH("Headphone"),
+};
+
+static int rk_hw_params(struct snd_pcm_substream *substream,
+			struct snd_pcm_hw_params *params)
+{
+	int ret = 0;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	int mclk;
+
+	switch (params_rate(params)) {
+	case 8000:
+	case 16000:
+	case 24000:
+	case 32000:
+	case 48000:
+	case 64000:
+	case 96000:
+		mclk = 12288000;
+		break;
+	case 11025:
+	case 22050:
+	case 44100:
+	case 88200:
+		mclk = 11289600;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
+				     SND_SOC_CLOCK_OUT);
+
+	if (ret && ret != -ENOTSUPP) {
+		dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
+				     SND_SOC_CLOCK_IN);
+	if (ret && ret != -ENOTSUPP) {
+		dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct snd_soc_jack_gpio rk_hp_jack_gpio = {
+	.name = "Headphone detection",
+	.report = SND_JACK_HEADPHONE,
+	.debounce_time = 150
+};
+
+static int rk_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct rk_es8388_drvdata *machine = snd_soc_card_get_drvdata(runtime->card);
+
+	/* Enable Headset Jack detection */
+	if (gpio_is_valid(machine->gpio_hp_det)) {
+		snd_soc_card_jack_new(runtime->card, "Headphone Jack",
+				      SND_JACK_HEADPHONE, &headphone_jack,
+				      headphone_jack_pins,
+				      ARRAY_SIZE(headphone_jack_pins));
+		rk_hp_jack_gpio.gpio = machine->gpio_hp_det;
+		snd_soc_jack_add_gpios(&headphone_jack, 1, &rk_hp_jack_gpio);
+	}
+
+	return 0;
+}
+
+static struct snd_soc_ops rk_ops = {
+	.hw_params = rk_hw_params,
+};
+
+static struct snd_soc_dai_link rk_dailink = {
+	.name = "ES8388",
+	.stream_name = "Audio",
+	.codec_dai_name = "es8328-hifi-analog",
+	.init = rk_init,
+	.ops = &rk_ops,
+	/* Set es8388 as slave */
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+		SND_SOC_DAIFMT_CBS_CFS,
+};
+
+static struct snd_soc_card snd_soc_card_rk = {
+	.name = "I2S-ES8388",
+	.dai_link = &rk_dailink,
+	.num_links = 1,
+	.num_aux_devs = 0,
+	.dapm_widgets = rk_dapm_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(rk_dapm_widgets),
+	.dapm_routes = rk_audio_map,
+	.num_dapm_routes = ARRAY_SIZE(rk_audio_map),
+	.controls = rk_mc_controls,
+	.num_controls = ARRAY_SIZE(rk_mc_controls),
+};
+
+static int snd_rk_mc_probe(struct platform_device *pdev)
+{
+	int ret = 0;
+	struct snd_soc_card *card = &snd_soc_card_rk;
+	struct device_node *np = pdev->dev.of_node;
+	struct rk_es8388_drvdata *machine;
+
+	machine = devm_kzalloc(&pdev->dev, sizeof(struct rk_es8388_drvdata),
+			       GFP_KERNEL);
+
+	if (!machine)
+		return -ENOMEM;
+
+	card->dev = &pdev->dev;
+
+	machine->gpio_hp_det = of_get_named_gpio(np,
+		"rockchip,hp-det-gpios", 0);
+	if (machine->gpio_hp_det == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
+	machine->gpio_hp_en = of_get_named_gpio(np,
+		"rockchip,hp-en-gpios", 0);
+	if (machine->gpio_hp_en == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
+	if (gpio_is_valid(machine->gpio_hp_en)) {
+		ret = devm_gpio_request_one(&pdev->dev, machine->gpio_hp_en,
+					    GPIOF_OUT_INIT_LOW, "hp_en");
+		if (ret) {
+			dev_err(card->dev, "cannot get hp_en gpio\n");
+			return ret;
+		}
+	}
+
+	ret = snd_soc_of_parse_card_name(card, "rockchip,model");
+	if (ret) {
+		dev_err(card->dev, "SoC parse card name failed %d\n", ret);
+		return ret;
+	}
+
+	rk_dailink.codec_of_node = of_parse_phandle(np, "rockchip,audio-codec",
+						    0);
+	if (!rk_dailink.codec_of_node) {
+		dev_err(&pdev->dev,
+			"Property 'rockchip,audio-codec' missing or invalid\n");
+		return -EINVAL;
+	}
+
+	rk_dailink.cpu_of_node = of_parse_phandle(np, "rockchip,i2s-controller",
+						  0);
+	if (!rk_dailink.cpu_of_node) {
+		dev_err(&pdev->dev,
+			"Property 'rockchip,i2s-controller' missing or invalid\n");
+		return -EINVAL;
+	}
+
+	rk_dailink.platform_of_node = rk_dailink.cpu_of_node;
+	snd_soc_card_set_drvdata(card, machine);
+
+	ret = devm_snd_soc_register_card(&pdev->dev, card);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"Soc register card failed %d\n", ret);
+		return ret;
+	}
+
+	platform_set_drvdata(pdev, card);
+
+	return ret;
+}
+
+static const struct of_device_id rockchip_es8388_of_match[] = {
+	{ .compatible = "rockchip,rockchip-audio-es8388", },
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, rockchip_es8388_of_match);
+
+static struct platform_driver snd_rk_es8388_driver = {
+	.probe = snd_rk_mc_probe,
+	.driver = {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+		.pm = &snd_soc_pm_ops,
+		.of_match_table = rockchip_es8388_of_match,
+	},
+};
+
+module_platform_driver(snd_rk_es8388_driver);
+
+MODULE_AUTHOR("Sjoerd Simons");
+MODULE_DESCRIPTION("Rockchip es8388 machine ASoC driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:" DRV_NAME);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] arm: dts: Add support for ES8388 to the Radxa Rock 2
  2017-01-13 16:14 [PATCH 0/4] Add support for es8388 on the rock2 Romain Perier
                   ` (2 preceding siblings ...)
  2017-01-13 16:14 ` [PATCH 3/4] ASoC: rockchip: Add machine driver for ES8388 codecs Romain Perier
@ 2017-01-13 16:14 ` Romain Perier
  3 siblings, 0 replies; 9+ messages in thread
From: Romain Perier @ 2017-01-13 16:14 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel, Heiko Stuebner
  Cc: Mark Rutland, devicetree, Pawel Moll, Ian Campbell,
	linux-rockchip, Sjoerd Simons, Rob Herring, Kumar Gala,
	Romain Perier

This commit adds the DT definition of the es8388 i2c device
found at address 0x10. It also adds the definition for connecting
the Rockchip I2S to the es8388 analog output.

This commit is based on the initial work that was done by Sjoerd Simons
<sjoerd.simons@collabora.com> with some improvements.

Signed-off-by: Romain Perier <romain.perier@collabora.com>
---
 arch/arm/boot/dts/rk3288-rock2-square.dts | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288-rock2-square.dts b/arch/arm/boot/dts/rk3288-rock2-square.dts
index 96a2e74..4f9b7d2 100644
--- a/arch/arm/boot/dts/rk3288-rock2-square.dts
+++ b/arch/arm/boot/dts/rk3288-rock2-square.dts
@@ -86,6 +86,17 @@
 		#sound-dai-cells = <0>;
 	};
 
+	sound_es8388 {
+		compatible = "rockchip,rockchip-audio-es8388";
+		rockchip,model = "Analog audio output";
+		rockchip,i2s-controller = <&i2s>;
+		rockchip,audio-codec = <&es8388>;
+		rockchip,hp-en-gpios = <&gpio8 0 GPIO_ACTIVE_HIGH>;
+		rockchip,hp-det-gpios = <&gpio7 7 GPIO_ACTIVE_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&headphone>;
+	};
+
 	sdio_pwrseq: sdio-pwrseq {
 		compatible = "mmc-pwrseq-simple";
 		clocks = <&hym8563>;
@@ -173,10 +184,29 @@
 	};
 };
 
+&i2c2 {
+	status = "okay";
+
+	es8388: es8388@10 {
+		compatible = "everest,es8388", "everest,es8328";
+		reg = <0x10>;
+		AVDD-supply = <&vcca_codec>;
+		DVDD-supply = <&vcca_codec>;
+		HPVDD-supply = <&vcca_codec>;
+		PVDD-supply = <&vcca_codec>;
+		clocks = <&cru SCLK_I2S0_OUT>;
+		clock-names = "i2s_clk_out";
+	};
+};
+
 &i2c5 {
 	status = "okay";
 };
 
+&i2s {
+	status = "okay";
+};
+
 &pinctrl {
 	ir {
 		ir_int: ir-int {
@@ -190,6 +220,13 @@
 		};
 	};
 
+	sound {
+		headphone: headphone {
+			rockchip,pins = <8 0 RK_FUNC_GPIO &pcfg_pull_up>,
+					<7 7 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
+
 	usb {
 		host_vbus_drv: host-vbus-drv {
 			rockchip,pins = <0 14 RK_FUNC_GPIO &pcfg_pull_none>;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388
       [not found]   ` <20170113161452.14313-2-romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
@ 2017-01-13 16:43     ` Heiko Stuebner
  2017-01-16  8:19       ` Romain Perier
  2017-01-15  2:56     ` [alsa-devel] " kbuild test robot
  1 sibling, 1 reply; 9+ messages in thread
From: Heiko Stuebner @ 2017-01-13 16:43 UTC (permalink / raw)
  To: Romain Perier
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Ian Campbell,
	Pawel Moll, Mark Rutland, Kumar Gala,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Sjoerd Simons

Hi Romain,

Am Freitag, 13. Januar 2017, 17:14:49 CET schrieb Romain Perier:
> This commit adds a compatible string for everest,es8388. This is
> an audio codec that is compatible with es8328.
> 
> Signed-off-by: Romain Perier <romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/sound/es8328.txt | 2 +-
>  sound/soc/codecs/es8328-i2c.c                      | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/sound/es8328.txt
> b/Documentation/devicetree/bindings/sound/es8328.txt index 30ea8a3..33fbf05
> 100644
> --- a/Documentation/devicetree/bindings/sound/es8328.txt
> +++ b/Documentation/devicetree/bindings/sound/es8328.txt
> @@ -4,7 +4,7 @@ This device supports both I2C and SPI.
> 
>  Required properties:
> 
> -  - compatible : "everest,es8328"
> +  - compatible  : Should be "everest,es8328" or "everest,es8388"
>    - DVDD-supply : Regulator providing digital core supply voltage 1.8 -
> 3.6V - AVDD-supply : Regulator providing analog supply voltage 3.3V
>    - PVDD-supply : Regulator providing digital IO supply voltage 1.8 - 3.6V
> diff --git a/sound/soc/codecs/es8328-i2c.c b/sound/soc/codecs/es8328-i2c.c
> index 2d05b5d..09ae67f 100644
> --- a/sound/soc/codecs/es8328-i2c.c
> +++ b/sound/soc/codecs/es8328-i2c.c
> @@ -19,13 +19,14 @@
>  #include "es8328.h"
> 
>  static const struct i2c_device_id es8328_id[] = {
> -	{ "es8328", 0 },
> +	{ "es8328", "es8388", 0 },

that looks strange or I'm just blind.

struct i2c_device_id {
        char name[I2C_NAME_SIZE];
        kernel_ulong_t driver_data;     /* Data private to the driver */
};

so shouldn't this be

 static const struct i2c_device_id es8328_id[] = {
 	{ "es8328", 0 },
+	{ "es8388", 0 },

instead?

>  	{ }
>  };
>  MODULE_DEVICE_TABLE(i2c, es8328_id);
> 
>  static const struct of_device_id es8328_of_match[] = {
>  	{ .compatible = "everest,es8328", },
> +	{ .compatible = "everest,es8388", },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, es8328_of_match);


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [alsa-devel] [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388
       [not found]   ` <20170113161452.14313-2-romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
  2017-01-13 16:43     ` Heiko Stuebner
@ 2017-01-15  2:56     ` kbuild test robot
  1 sibling, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2017-01-15  2:56 UTC (permalink / raw)
  Cc: kbuild-all-JC7UmRfGjtg, Jaroslav Kysela, Takashi Iwai,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, Heiko Stuebner, Mark Rutland,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Pawel Moll, Ian Campbell,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Sjoerd Simons,
	Rob Herring, Kumar Gala, Romain Perier

[-- Attachment #1: Type: text/plain, Size: 2358 bytes --]

Hi Romain,

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on v4.10-rc3 next-20170113]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Romain-Perier/Add-support-for-es8388-on-the-rock2/20170115-095611
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=alpha 

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/es8328-i2c.c:22:14: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
     { "es8328", "es8388", 0 },
                 ^~~~~~~~
   sound/soc/codecs/es8328-i2c.c:22:14: note: (near initialization for 'es8328_id[0].driver_data')
>> sound/soc/codecs/es8328-i2c.c:22:24: warning: excess elements in struct initializer
     { "es8328", "es8388", 0 },
                           ^
   sound/soc/codecs/es8328-i2c.c:22:24: note: (near initialization for 'es8328_id[0]')

vim +22 sound/soc/codecs/es8328-i2c.c

     6	 * Author: Sean Cross <xobs-nXMMniAx+RbQT0dZR+AlfA@public.gmane.org>
     7	 *
     8	 * This program is free software; you can redistribute it and/or modify
     9	 * it under the terms of the GNU General Public License version 2 as
    10	 * published by the Free Software Foundation.
    11	 */
    12	
    13	#include <linux/module.h>
    14	#include <linux/i2c.h>
    15	#include <linux/regmap.h>
    16	
    17	#include <sound/soc.h>
    18	
    19	#include "es8328.h"
    20	
    21	static const struct i2c_device_id es8328_id[] = {
  > 22		{ "es8328", "es8388", 0 },
    23		{ }
    24	};
    25	MODULE_DEVICE_TABLE(i2c, es8328_id);
    26	
    27	static const struct of_device_id es8328_of_match[] = {
    28		{ .compatible = "everest,es8328", },
    29		{ .compatible = "everest,es8388", },
    30		{ }

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 48654 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [alsa-devel] [PATCH 3/4] ASoC: rockchip: Add machine driver for ES8388 codecs
       [not found]   ` <20170113161452.14313-4-romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
@ 2017-01-15  5:21     ` kbuild test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2017-01-15  5:21 UTC (permalink / raw)
  Cc: kbuild-all-JC7UmRfGjtg, Jaroslav Kysela, Takashi Iwai,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, Heiko Stuebner, Mark Rutland,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Pawel Moll, Ian Campbell,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Sjoerd Simons,
	Rob Herring, Kumar Gala, Romain Perier

[-- Attachment #1: Type: text/plain, Size: 1167 bytes --]

Hi Romain,

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on v4.10-rc3 next-20170113]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Romain-Perier/Add-support-for-es8388-on-the-rock2/20170115-095611
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All warnings (new ones prefixed by >>):

warning: (SND_SOC_ROCKCHIP_ES8388) selects SND_SOC_ROCKCHIP_I2S which has unmet direct dependencies (SOUND && !M68K && !UML && SND && SND_SOC && CLKDEV_LOOKUP && SND_SOC_ROCKCHIP)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 48885 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388
  2017-01-13 16:43     ` Heiko Stuebner
@ 2017-01-16  8:19       ` Romain Perier
  0 siblings, 0 replies; 9+ messages in thread
From: Romain Perier @ 2017-01-16  8:19 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Ian Campbell,
	Pawel Moll, Mark Rutland, Kumar Gala,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Sjoerd Simons

Hi Heiko,

Le 13/01/2017 à 17:43, Heiko Stuebner a écrit :
> Hi Romain,
>
> Am Freitag, 13. Januar 2017, 17:14:49 CET schrieb Romain Perier:
>> This commit adds a compatible string for everest,es8388. This is
>> an audio codec that is compatible with es8328.
>>
>> Signed-off-by: Romain Perier <romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
>> ---
>>   Documentation/devicetree/bindings/sound/es8328.txt | 2 +-
>>   sound/soc/codecs/es8328-i2c.c                      | 3 ++-
>>   2 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/sound/es8328.txt
>> b/Documentation/devicetree/bindings/sound/es8328.txt index 30ea8a3..33fbf05
>> 100644
>> --- a/Documentation/devicetree/bindings/sound/es8328.txt
>> +++ b/Documentation/devicetree/bindings/sound/es8328.txt
>> @@ -4,7 +4,7 @@ This device supports both I2C and SPI.
>>
>>   Required properties:
>>
>> -  - compatible : "everest,es8328"
>> +  - compatible  : Should be "everest,es8328" or "everest,es8388"
>>     - DVDD-supply : Regulator providing digital core supply voltage 1.8 -
>> 3.6V - AVDD-supply : Regulator providing analog supply voltage 3.3V
>>     - PVDD-supply : Regulator providing digital IO supply voltage 1.8 - 3.6V
>> diff --git a/sound/soc/codecs/es8328-i2c.c b/sound/soc/codecs/es8328-i2c.c
>> index 2d05b5d..09ae67f 100644
>> --- a/sound/soc/codecs/es8328-i2c.c
>> +++ b/sound/soc/codecs/es8328-i2c.c
>> @@ -19,13 +19,14 @@
>>   #include "es8328.h"
>>
>>   static const struct i2c_device_id es8328_id[] = {
>> -	{ "es8328", 0 },
>> +	{ "es8328", "es8388", 0 },
> that looks strange or I'm just blind.
>
> struct i2c_device_id {
>          char name[I2C_NAME_SIZE];
>          kernel_ulong_t driver_data;     /* Data private to the driver */
> };
>
> so shouldn't this be
>
>   static const struct i2c_device_id es8328_id[] = {
>   	{ "es8328", 0 },
> +	{ "es8388", 0 },
>
> instead?

Good catch!

thanks,
Romain
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-01-16  8:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-13 16:14 [PATCH 0/4] Add support for es8388 on the rock2 Romain Perier
2017-01-13 16:14 ` [PATCH 1/4] ASoC: es8328-i2c: Add compatible for ES8388 Romain Perier
     [not found]   ` <20170113161452.14313-2-romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2017-01-13 16:43     ` Heiko Stuebner
2017-01-16  8:19       ` Romain Perier
2017-01-15  2:56     ` [alsa-devel] " kbuild test robot
2017-01-13 16:14 ` [PATCH 2/4] ASoC: es8328: Add support for slave mode Romain Perier
2017-01-13 16:14 ` [PATCH 3/4] ASoC: rockchip: Add machine driver for ES8388 codecs Romain Perier
     [not found]   ` <20170113161452.14313-4-romain.perier-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2017-01-15  5:21     ` [alsa-devel] " kbuild test robot
2017-01-13 16:14 ` [PATCH 4/4] arm: dts: Add support for ES8388 to the Radxa Rock 2 Romain Perier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.