devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards
@ 2016-06-13 10:52 Sylwester Nawrocki
  2016-06-13 10:52 ` [PATCH RFC 1/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
                   ` (5 more replies)
  0 siblings, 6 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-13 10:52 UTC (permalink / raw)
  To: broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae,
	k.kozlowski, b.zolnierkie, Sylwester Nawrocki

This patch series adds sound supoort for the Exynos 5433 based TM2(E)
boards.  It includes minimal drivers for the Low Power Audio Subsystem
(LPASS) and the MAX98504 class D speaker amplifier as well as the actual
asoc machine driver.

Inha Song (2):
  ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
  ASoC: samsung: Add machine driver for Exynos5433 based TM2 board

Sylwester Nawrocki (4):
  ASoC: samsung: Add DT bindings documentation for LPASS
  ASoC: max98504: Add max98504 speaker amplifier driver
  ASoC: Add DT bindings documentation for max98504 amplifier
  ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem

 .../devicetree/bindings/sound/max98504.txt         |  44 ++
 .../bindings/sound/samsung,exynos5433-lpass.txt    |   8 +
 .../bindings/sound/samsung,tm2-wm5110.txt          |  39 ++
 sound/soc/codecs/Kconfig                           |   4 +
 sound/soc/codecs/Makefile                          |   2 +
 sound/soc/codecs/max98504.c                        | 241 +++++++++
 sound/soc/codecs/max98504.h                        |  94 ++++
 sound/soc/samsung/Kconfig                          |  13 +
 sound/soc/samsung/Makefile                         |   4 +
 sound/soc/samsung/lpass.c                          | 162 ++++++
 sound/soc/samsung/lpass.h                          |  47 ++
 sound/soc/samsung/tm2_wm5110.c                     | 553 +++++++++++++++++++++
 12 files changed, 1211 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/max98504.txt
 create mode 100644 Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt
 create mode 100644 Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt
 create mode 100644 sound/soc/codecs/max98504.c
 create mode 100644 sound/soc/codecs/max98504.h
 create mode 100644 sound/soc/samsung/lpass.c
 create mode 100644 sound/soc/samsung/lpass.h
 create mode 100644 sound/soc/samsung/tm2_wm5110.c

--
1.9.1

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

* [PATCH RFC 1/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
  2016-06-13 10:52 [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
@ 2016-06-13 10:52 ` Sylwester Nawrocki
  2016-06-16 11:28   ` Krzysztof Kozlowski
  2016-06-13 10:52 ` [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-13 10:52 UTC (permalink / raw)
  To: broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae,
	k.kozlowski, b.zolnierkie, Sylwester Nawrocki

From: Inha Song <ideal.song@samsung.com>

This patch adds LPASS driver. The LPASS (Low Power Audio Subsystem)
is a special subsystem that supports audio playback with low power
consumption. This is a minimal driver which prepares resources for
IP blocks like I2S, audio DMA and UART.
Also system power ops are added to ensure the Audio Subsystem is
operational after system suspend/resume cycle.

Signed-off-by: Inha Song <ideal.song@samsung.com>
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 sound/soc/samsung/Makefile |   2 +
 sound/soc/samsung/lpass.c  | 162 +++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/samsung/lpass.h  |  47 +++++++++++++
 3 files changed, 211 insertions(+)
 create mode 100644 sound/soc/samsung/lpass.c
 create mode 100644 sound/soc/samsung/lpass.h

diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile
index 5d03f5c..2b919d5 100644
--- a/sound/soc/samsung/Makefile
+++ b/sound/soc/samsung/Makefile
@@ -8,6 +8,7 @@ snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o
 snd-soc-samsung-spdif-objs := spdif.o
 snd-soc-pcm-objs := pcm.o
 snd-soc-i2s-objs := i2s.o
+snd-soc-lpass-objs := lpass.o
 
 obj-$(CONFIG_SND_SOC_SAMSUNG) += snd-soc-s3c-dma.o
 obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o
@@ -18,6 +19,7 @@ obj-$(CONFIG_SND_SAMSUNG_SPDIF) += snd-soc-samsung-spdif.o
 obj-$(CONFIG_SND_SAMSUNG_PCM) += snd-soc-pcm.o
 obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-i2s.o
 obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-idma.o
+obj-$(CONFIG_SND_SAMSUNG_AUDSS) += snd-soc-lpass.o
 
 # S3C24XX Machine Support
 snd-soc-jive-wm8750-objs := jive_wm8750.o
diff --git a/sound/soc/samsung/lpass.c b/sound/soc/samsung/lpass.c
new file mode 100644
index 0000000..57198cf
--- /dev/null
+++ b/sound/soc/samsung/lpass.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2015 - 2016 Samsung Electronics Co., Ltd.
+ * 	Inha Song <ideal.song@samsung.com>
+ *
+ * Low Power Audio Subsystem driver for Samsung Exynos
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <sound/soc.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
+
+#include "lpass.h"
+
+#define EXYNOS5433_PAD_RETENTION_AUD_OPTION_OFFSET	0x3028
+#define EXYNOS5433_INITIATE_WAKEUP_FROM_LOWPWR_MASK	BIT(28)
+
+struct lpass_info {
+	struct platform_device	*pdev;
+	void __iomem		*reg_sfr;
+	struct regmap		*reg_pmu;
+};
+
+static void lpass_core_sw_reset(struct lpass_info *lpass, int bit)
+{
+	unsigned int val;
+
+	val = readl(lpass->reg_sfr + SFR_LPASS_CORE_SW_RESET);
+
+	val &= ~(1 << bit);
+	writel(val, lpass->reg_sfr + SFR_LPASS_CORE_SW_RESET);
+
+	udelay(100);
+
+	val |= 1 << bit;
+	writel(val, lpass->reg_sfr + SFR_LPASS_CORE_SW_RESET);
+}
+
+static void lpass_enable(struct lpass_info *lpass)
+{
+	if (!lpass->reg_pmu)
+		return;
+
+	/* Unmasks SFR, DMA, I2S Interrupt */
+	writel(LPASS_INTR_SFR | LPASS_INTR_DMA | LPASS_INTR_I2S,
+	       lpass->reg_sfr + SFR_LPASS_INTR_CA5_MASK);
+
+	writel(LPASS_INTR_DMA | LPASS_INTR_I2S | LPASS_INTR_SFR
+			| LPASS_INTR_UART,
+	       lpass->reg_sfr + SFR_LPASS_INTR_CPU_MASK);
+
+	/* Activate related PADs from retention state */
+	regmap_write(lpass->reg_pmu,
+		     EXYNOS5433_PAD_RETENTION_AUD_OPTION_OFFSET,
+		     EXYNOS5433_INITIATE_WAKEUP_FROM_LOWPWR_MASK);
+
+	lpass_core_sw_reset(lpass, SW_RESET_I2S);
+	lpass_core_sw_reset(lpass, SW_RESET_DMA);
+	lpass_core_sw_reset(lpass, SW_RESET_MEM);
+}
+
+static void lpass_disable(struct lpass_info *lpass)
+{
+	if (!lpass->reg_pmu)
+		return;
+
+	/* Masks SFR, DMA, I2S Interrupt */
+	writel(0, lpass->reg_sfr + SFR_LPASS_INTR_CA5_MASK);
+
+	writel(0, lpass->reg_sfr + SFR_LPASS_INTR_CPU_MASK);
+
+	/* Deactivate related PADs from retention state */
+	regmap_write(lpass->reg_pmu,
+		     EXYNOS5433_PAD_RETENTION_AUD_OPTION_OFFSET, 0);
+}
+
+static int lpass_probe(struct platform_device *pdev)
+{
+	struct lpass_info *lpass;
+	struct device *dev = &pdev->dev;
+	struct resource *res;
+
+	if (!dev->of_node) {
+		dev_err(dev, "Failed to get DT node\n");
+		return -ENODEV;
+	}
+
+	lpass = devm_kzalloc(dev, sizeof(*lpass), GFP_KERNEL);
+	if (!lpass)
+		return -ENOMEM;
+
+	lpass->pdev = pdev;
+	platform_set_drvdata(pdev, lpass);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	lpass->reg_sfr = devm_ioremap_resource(dev, res);
+	if (IS_ERR(lpass->reg_sfr))
+		return PTR_ERR(lpass->reg_sfr);
+
+	lpass->reg_pmu = syscon_regmap_lookup_by_phandle(dev->of_node,
+						"samsung,pmu-syscon");
+	if (IS_ERR(lpass->reg_pmu)) {
+		dev_err(dev, "Failed to lookup PMU regmap\n");
+		return PTR_ERR(lpass->reg_pmu);
+	}
+
+	lpass_enable(lpass);
+
+	return 0;
+}
+
+static int lpass_suspend(struct device *dev)
+{
+	struct lpass_info *lpass = dev_get_drvdata(dev);
+
+	lpass_disable(lpass);
+
+	return 0;
+}
+
+static int lpass_resume(struct device *dev)
+{
+	struct lpass_info *lpass = dev_get_drvdata(dev);
+
+	lpass_enable(lpass);
+
+	return 0;
+}
+
+static const struct of_device_id lpass_of_match[] = {
+	{ .compatible	= "samsung,exynos5433-lpass", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, lpass_of_match);
+
+static const struct dev_pm_ops lpass_pm_ops = {
+	.suspend	= lpass_suspend,
+	.resume		= lpass_resume,
+};
+
+static struct platform_driver lpass_driver = {
+	.driver = {
+		.name		= "samsung-lpass",
+		.pm		= &lpass_pm_ops,
+		.of_match_table	= lpass_of_match,
+	},
+	.probe	= lpass_probe,
+};
+
+module_platform_driver(lpass_driver);
+
+MODULE_AUTHOR("Inha Song <ideal.song@samsung.com>");
+MODULE_DESCRIPTION("Samsung Low Power Audio Subsystem (LPASS) driver");
+MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/samsung/lpass.h b/sound/soc/samsung/lpass.h
new file mode 100644
index 0000000..59179d6
--- /dev/null
+++ b/sound/soc/samsung/lpass.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 - 2016 Samsung Electronics Co., Ltd.
+ *	Inha Song <ideal.song@samsung.com>
+ *
+ * Low Power Audio Subsystem driver for Samsung Exynos
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+#ifndef SND_SOC_SAMSUNG_LPASS_H_
+#define SND_SOC_SAMSUNG_LPASS_H_
+
+/* SFR */
+#define SFR_LPASS_CORE_SW_RESET	(0x08)
+#define SFR_LPASS_INTR_CA5_MASK	(0x48)
+#define SFR_LPASS_INTR_CPU_MASK	(0x58)
+
+/* SW_RESET */
+#define LPASS_SW_RESET_CA5	(1 << 0)
+#define LPASS_SW_RESET_SB	(1 << 11)
+
+/* Interrupt mask */
+#define LPASS_INTR_APM		(1 << 9)
+#define LPASS_INTR_MIF		(1 << 8)
+#define LPASS_INTR_TIMER	(1 << 7)
+#define LPASS_INTR_DMA		(1 << 6)
+#define LPASS_INTR_GPIO		(1 << 5)
+#define LPASS_INTR_I2S		(1 << 4)
+#define LPASS_INTR_PCM		(1 << 3)
+#define LPASS_INTR_SB		(1 << 2)
+#define LPASS_INTR_UART		(1 << 1)
+#define LPASS_INTR_SFR		(1 << 0)
+
+/* SW Reset bit */
+enum {
+	SW_RESET_DMA = 0,
+	SW_RESET_MEM,
+	SW_RESET_TIMER,
+	SW_RESET_I2S = 8,
+	SW_RESET_PCM,
+	SW_RESET_UART,
+	SW_RESET_SLIMBUS,
+};
+
+#endif /* SND_SOC_SAMSUNG_LPASS_H_ */
-- 
1.9.1

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

* [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS
  2016-06-13 10:52 [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
  2016-06-13 10:52 ` [PATCH RFC 1/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
@ 2016-06-13 10:52 ` Sylwester Nawrocki
  2016-06-14 23:28   ` Rob Herring
  2016-06-16 11:28   ` Krzysztof Kozlowski
  2016-06-13 10:52 ` [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver Sylwester Nawrocki
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-13 10:52 UTC (permalink / raw)
  To: broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae,
	k.kozlowski, b.zolnierkie, Sylwester Nawrocki

This patch add documentation of the DT bindings for the Samsung
Exynos SoC Low Power Audio Subsystem.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 .../devicetree/bindings/sound/samsung,exynos5433-lpass.txt        | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt

diff --git a/Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt b/Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt
new file mode 100644
index 0000000..4beef25
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt
@@ -0,0 +1,8 @@
+
+Samsung Exynos SoC Low Power Audio Subsystem (LPASS)
+
+Required properties:
+
+ - compatible : "samsung,exynos5433-lpass"
+ - reg : should contain the LPASS SFR region location and size
+ - samsung,pmu-syscon : the phandle to the Power Management Unit node
-- 
1.9.1

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

* [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver
  2016-06-13 10:52 [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
  2016-06-13 10:52 ` [PATCH RFC 1/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
  2016-06-13 10:52 ` [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
@ 2016-06-13 10:52 ` Sylwester Nawrocki
  2016-06-13 15:14   ` Mark Brown
  2016-06-13 10:52 ` [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-13 10:52 UTC (permalink / raw)
  To: broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae,
	k.kozlowski, b.zolnierkie, Sylwester Nawrocki

This patch adds driver for the MAX98504 speaker amplifier.  The MAX98504
is a high efficiency mono class D amplifier that features an integrated
boost converter with voltage and current sensing ADCs for Dynamic Speaker
Management.
This driver does not include support for the I2S DAI, as we wouldn't be
able  to test such code in a hardware configuration where the amplifier
has only wired the analogue input.

Signed-off-by: Inha Song <ideal.song@samsung.com>
[k.kozlowski: rebased on 4.1]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[s.nawrocki: removed unused macro definitions and regulator handling
 code, rewrote regmap config code, added support for speaker enable
 and global chip enable through DAPM, rewritten as component driver,
 redesigned DT bindings]
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 sound/soc/codecs/Kconfig    |   4 +
 sound/soc/codecs/Makefile   |   2 +
 sound/soc/codecs/max98504.c | 241 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/max98504.h |  94 +++++++++++++++++
 4 files changed, 341 insertions(+)
 create mode 100644 sound/soc/codecs/max98504.c
 create mode 100644 sound/soc/codecs/max98504.h

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index c923c96..46853b2 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -552,6 +552,10 @@ config SND_SOC_MAX98357A
 config SND_SOC_MAX98371
        tristate
 
+config SND_SOC_MAX98504
+	tristate "Maxim MAX98504 speaker amplifier"
+	depends on I2C
+
 config SND_SOC_MAX9867
 	tristate
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 1264fa4..09d581c 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -213,6 +213,7 @@ snd-soc-wm-hubs-objs := wm_hubs.o
 
 # Amp
 snd-soc-max9877-objs := max9877.o
+snd-soc-max98504-objs := max98504.o
 snd-soc-tpa6130a2-objs := tpa6130a2.o
 snd-soc-tas2552-objs := tas2552.o
 
@@ -429,4 +430,5 @@ obj-$(CONFIG_SND_SOC_WM_HUBS)	+= snd-soc-wm-hubs.o
 
 # Amp
 obj-$(CONFIG_SND_SOC_MAX9877)	+= snd-soc-max9877.o
+obj-$(CONFIG_SND_SOC_MAX98504)	+= snd-soc-max98504.o
 obj-$(CONFIG_SND_SOC_TPA6130A2)	+= snd-soc-tpa6130a2.o
diff --git a/sound/soc/codecs/max98504.c b/sound/soc/codecs/max98504.c
new file mode 100644
index 0000000..15035e1
--- /dev/null
+++ b/sound/soc/codecs/max98504.c
@@ -0,0 +1,241 @@
+/*
+ * MAX98504 ALSA SoC Audio driver
+ *
+ * Copyright 2013 - 2014 Maxim Integrated Products
+ * Copyright 2016 Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <sound/soc.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+
+#include "max98504.h"
+
+static struct reg_default max98504_reg_defaults[] = {
+	{ 0x01,	0},
+	{ 0x02,	0},
+	{ 0x03,	0},
+	{ 0x04,	0},
+	{ 0x10, 0},
+	{ 0x11, 0},
+	{ 0x12, 0},
+	{ 0x13, 0},
+	{ 0x14, 0},
+	{ 0x15, 0},
+	{ 0x16, 0},
+	{ 0x17, 0},
+	{ 0x18, 0},
+	{ 0x19, 0},
+	{ 0x1A, 0},
+	{ 0x20, 0},
+	{ 0x21, 0},
+	{ 0x22, 0},
+	{ 0x23, 0},
+	{ 0x24, 0},
+	{ 0x25, 0},
+	{ 0x26, 0},
+	{ 0x27, 0},
+	{ 0x28, 0},
+	{ 0x30, 0},
+	{ 0x31, 0},
+	{ 0x32, 0},
+	{ 0x33, 0},
+	{ 0x34, 0},
+	{ 0x35, 0},
+	{ 0x36, 0},
+	{ 0x37, 0},
+	{ 0x38, 0},
+	{ 0x39, 0},
+	{ 0x40, 0},
+	{ 0x41, 0},
+};
+
+static bool max98504_volatile_register(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case MAX98504_REG_INTERRUPT_STATUS:
+	case MAX98504_REG_INTERRUPT_FLAGS:
+	case MAX98504_REG_INTERRUPT_FLAG_CLEARS:
+	case MAX98504_REG_WATCHDOG_CLEAR:
+	case MAX98504_REG_GLOBAL_ENABLE:
+	case MAX98504_REG_SOFTWARE_RESET:
+		return true;
+	default:
+		return false;
+	}
+}
+
+static bool max98504_readable_register(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case MAX98504_REG_SOFTWARE_RESET:
+	case MAX98504_REG_WATCHDOG_CLEAR:
+	case MAX98504_REG_INTERRUPT_FLAG_CLEARS:
+		return false;
+	default:
+		return true;
+	}
+}
+
+static int max98504_probe(struct max98504_priv *max98504)
+{
+	struct regmap *map = max98504->regmap;
+
+	/* Software reset */
+	regmap_write(map, MAX98504_REG_SOFTWARE_RESET, 0x01);
+	msleep(20);
+
+	/* DAI PCM/PDM Rx configuration */
+	switch (max98504->rx_path) {
+	case MODE_RX_PCM:
+		regmap_write(map, MAX98504_REG_PCM_RX_ENABLE,
+			     max98504->rx_ch_enable);
+		break;
+	case MODE_RX_PDM0...MODE_RX_PDM1:
+		regmap_write(map, MAX98504_REG_PDM_RX_ENABLE,
+			     M98504_PDM_RX_EN_MASK);
+		break;
+	default:
+		/* Analog input, disable PCM, PDM Rx */
+		regmap_write(map, MAX98504_REG_PCM_RX_ENABLE, 0);
+		regmap_write(map, MAX98504_REG_PDM_RX_ENABLE, 0);
+	}
+
+	regmap_write(map, MAX98504_REG_SPEAKER_SOURCE_SELECT,
+		     max98504->rx_path & M98504_SPK_SRC_SEL_MASK);
+
+	/* DAI PCM/PDM Tx configuration */
+	switch (max98504->tx_path) {
+	case MODE_TX_PCM:
+		regmap_write(map, MAX98504_REG_PCM_TX_ENABLE,
+			     max98504->tx_ch_enable);
+		regmap_write(map, MAX98504_REG_PCM_TX_CHANNEL_SOURCES,
+			     max98504->tx_ch_source);
+		break;
+	default:
+		/* PDM Tx */
+		regmap_write(map, MAX98504_REG_PDM_TX_ENABLE,
+			     max98504->tx_ch_enable);
+		regmap_write(map, MAX98504_REG_PDM_TX_CONTROL,
+			     max98504->tx_ch_source);
+	}
+
+	regmap_write(map, MAX98504_REG_MEASUREMENT_ENABLE, 0x3);
+
+	/* Brownout protection */
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_ENABLE, 0x1);
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(1), 0x33);
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(2), 0x0a);
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(3), 0xff);
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(4), 0xff);
+
+	return 0;
+}
+
+static const struct snd_soc_dapm_route max98504_dapm_routes[] = {
+	{ "SPKOUT", NULL, "Global Enable" },
+};
+
+static const struct snd_soc_dapm_widget max98504_dapm_widgets[] = {
+	SND_SOC_DAPM_SUPPLY("Global Enable", MAX98504_REG_GLOBAL_ENABLE,
+		0, 0, NULL, 0),
+	SND_SOC_DAPM_REG(snd_soc_dapm_spk, "SPKOUT",
+		MAX98504_REG_SPEAKER_ENABLE, 0, 1, 1, 0),
+};
+
+static const struct snd_soc_component_driver max98504_component_driver = {
+	.dapm_widgets		= max98504_dapm_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(max98504_dapm_widgets),
+	.dapm_routes		= max98504_dapm_routes,
+	.num_dapm_routes	= ARRAY_SIZE(max98504_dapm_routes),
+};
+
+static const struct regmap_config max98504_regmap = {
+	.reg_bits		= 16,
+	.val_bits		= 8,
+	.max_register		= MAX98504_MAX_REGISTER,
+	.reg_defaults		= max98504_reg_defaults,
+	.num_reg_defaults	= ARRAY_SIZE(max98504_reg_defaults),
+	.volatile_reg		= max98504_volatile_register,
+	.readable_reg		= max98504_readable_register,
+	.cache_type		= REGCACHE_RBTREE,
+};
+
+static void max98504_parse_dt(struct max98504_priv *max98504,
+			      struct device_node *of_node)
+{
+	of_property_read_u32(of_node, "maxim,rx-path",
+			     &max98504->rx_path);
+
+	of_property_read_u32(of_node, "maxim,tx-path",
+			     &max98504->tx_path);
+
+	of_property_read_u32(of_node, "maxim,rx-channel-mask",
+			     &max98504->rx_ch_enable);
+
+	of_property_read_u32(of_node, "maxim,tx-channel-mask",
+			     &max98504->tx_ch_enable);
+
+	of_property_read_u32(of_node, "maxim,tx-channel-source",
+			     &max98504->tx_ch_source);
+}
+
+static int max98504_i2c_probe(struct i2c_client *client,
+			      const struct i2c_device_id *id)
+{
+	struct max98504_priv *max98504;
+	int ret;
+
+	max98504 = devm_kzalloc(&client->dev, sizeof(*max98504), GFP_KERNEL);
+	if (!max98504)
+		return -ENOMEM;
+
+	if (client->dev.of_node)
+		max98504_parse_dt(max98504, client->dev.of_node);
+
+	max98504->regmap = devm_regmap_init_i2c(client, &max98504_regmap);
+	if (IS_ERR(max98504->regmap)) {
+		ret = PTR_ERR(max98504->regmap);
+		dev_err(&client->dev, "regmap initialization failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = max98504_probe(max98504);
+	if (ret < 0)
+		return ret;
+
+	return devm_snd_soc_register_component(&client->dev,
+				&max98504_component_driver, NULL, 0);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id max98504_of_match[] = {
+	{ .compatible = "maxim,max98504", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rt5651_of_match);
+#endif
+
+static const struct i2c_device_id max98504_i2c_id[] = {
+	{ "max98504" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, max98504_i2c_id);
+
+static struct i2c_driver max98504_i2c_driver = {
+	.driver = {
+		.name = "max98504",
+		.of_match_table = of_match_ptr(max98504_of_match),
+	},
+	.probe = max98504_i2c_probe,
+	.id_table = max98504_i2c_id,
+};
+module_i2c_driver(max98504_i2c_driver);
+
+MODULE_DESCRIPTION("ASoC MAX98504 driver");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/max98504.h b/sound/soc/codecs/max98504.h
new file mode 100644
index 0000000..fa176ffd
--- /dev/null
+++ b/sound/soc/codecs/max98504.h
@@ -0,0 +1,94 @@
+/*
+ * MAX98504 ALSA SoC Audio driver
+ *
+ * Copyright 2011 - 2012 Maxim Integrated Products
+ * Copyright 2016 Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef MAX98504_H_
+#define MAX98504_H_
+
+/*
+ * MAX98504 Register Definitions
+ */
+#define MAX98504_REG_INTERRUPT_STATUS		0x01
+#define MAX98504_REG_INTERRUPT_FLAGS		0x02
+#define MAX98504_REG_INTERRUPT_ENABLE		0x03
+#define MAX98504_REG_INTERRUPT_FLAG_CLEARS	0x04
+#define MAX98504_REG_GPIO_ENABLE		0x10
+#define MAX98504_REG_GPIO_CONFIG		0x11
+#define MAX98504_REG_WATCHDOG_ENABLE		0x12
+#define MAX98504_REG_WATCHDOG_CONFIG		0x13
+#define MAX98504_REG_WATCHDOG_CLEAR		0x14
+#define MAX98504_REG_CLOCK_MONITOR_ENABLE	0x15
+#define MAX98504_REG_PVDD_BROWNOUT_ENABLE	0x16
+/* n = 1...4 */
+#define MAX98504_REG_PVDD_BROWNOUT_CONFIG(n)	(0x17 + (n) - 1)
+#define MAX98504_REG_PCM_RX_ENABLE		0x20
+#define MAX98504_REG_PCM_TX_ENABLE		0x21
+#define MAX98504_REG_PCM_TX_HIZ_CONTROL		0x22
+#define MAX98504_REG_PCM_TX_CHANNEL_SOURCES	0x23
+#define MAX98504_REG_PCM_MODE_CONFIG		0x24
+#define MAX98504_REG_PCM_DSP_CONFIG		0x25
+#define MAX98504_REG_PCM_CLOCK_SETUP		0x26
+#define MAX98504_REG_PCM_SAMPLE_RATE_SETUP	0x27
+#define MAX98504_REG_PCM_TO_SPEAKER_MONOMIX	0x28
+#define MAX98504_REG_PDM_TX_ENABLE		0x30
+#define MAX98504_REG_PDM_TX_HIZ_CONTROL		0x31
+#define MAX98504_REG_PDM_TX_CONTROL		0x32
+#define MAX98504_REG_PDM_RX_ENABLE		0x33
+#define MAX98504_REG_SPEAKER_ENABLE		0x34
+#define MAX98504_REG_SPEAKER_SOURCE_SELECT	0x35
+#define MAX98504_REG_MEASUREMENT_ENABLE		0x36
+#define MAX98504_REG_ANALOGUE_INPUT_GAIN	0x37
+#define MAX98504_REG_TEMPERATURE_LIMIT_CONFIG	0x38
+#define MAX98504_REG_ANALOGUE_SPARE		0x39
+#define MAX98504_REG_GLOBAL_ENABLE		0x40
+#define MAX98504_REG_SOFTWARE_RESET		0x41
+#define MAX98504_REG_REV_ID			0x7fff
+
+#define MAX98504_MAX_REGISTER			0x7fff
+
+/* Register Bit Fields */
+
+/* MAX98504_REG_PCM_DSP_CONFIG */
+#define M98504_PCM_DSP_CFG_TX_DITH_EN_MASK	(1 << 7)
+#define M98504_PCM_DSP_CFG_MEAS_DCBLK_EN_MASK	(1 << 6)
+#define M98504_PCM_DSP_CFG_RX_DITH_EN_MASK	(1 << 5)
+#define M98504_PCM_DSP_CFG_RX_FLT_MODE_MASK	(1 << 4)
+
+/* MAX98504_REG_PDM_RX_ENABLE */
+#define M98504_PDM_RX_EN_MASK			(1 << 0)
+
+/* MAX98504_REG_SPEAKER_SOURCE_SELECT */
+#define M98504_SPK_SRC_SEL_MASK			(0x3 << 0)
+#define M98504_SPK_SRC_SEL_PDM_CH1		(0x3 << 0)
+#define M98504_SPK_SRC_SEL_PDM_CH0		(0x2 << 0)
+#define M98504_SPK_SRC_SEL_ANALOG		(0x1 << 0)
+#define M98504_SPK_SRC_SEL_PCM_MONOMIX		(0x0 << 0)
+
+enum max98504_rx_path {
+	MODE_RX_PCM,
+	MODE_RX_AIN,
+	MODE_RX_PDM0,
+	MODE_RX_PDM1,
+};
+
+enum max98504_tx_path {
+	MODE_TX_PCM,
+	MODE_TX_PDM,
+};
+
+struct max98504_priv {
+	struct regmap *regmap;
+	u32 rx_path;
+	u32 tx_path;
+	u32 rx_ch_enable;
+	u32 tx_ch_enable;
+	u32 tx_ch_source;
+};
+
+#endif /* MAX98504_H_ */
-- 
1.9.1

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

* [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier
  2016-06-13 10:52 [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
                   ` (2 preceding siblings ...)
  2016-06-13 10:52 ` [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver Sylwester Nawrocki
@ 2016-06-13 10:52 ` Sylwester Nawrocki
  2016-06-13 15:32   ` Mark Brown
  2016-06-16 11:31   ` Krzysztof Kozlowski
  2016-06-13 10:52 ` [PATCH RFC 5/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board Sylwester Nawrocki
  2016-06-13 10:52 ` [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
  5 siblings, 2 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-13 10:52 UTC (permalink / raw)
  To: broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae,
	k.kozlowski, b.zolnierkie, Sylwester Nawrocki

This patch adds DT bindings documentation for Maxim MAX98504
speaker amplifier.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 .../devicetree/bindings/sound/max98504.txt         | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/max98504.txt

diff --git a/Documentation/devicetree/bindings/sound/max98504.txt b/Documentation/devicetree/bindings/sound/max98504.txt
new file mode 100644
index 0000000..0cb75af
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/max98504.txt
@@ -0,0 +1,44 @@
+
+Maxim MAX98504 class D mono speaker amplifier
+
+Required properties:
+
+ - compatible : "maxim,max98504"
+ - reg : should contain the I2C slave device address
+
+Optional properties:
+
+ - maxim,rx-path : indicates speaker source interface:
+    0 - PCM monomix output,
+    1 - Analog input,
+    2 - left PDM channel (CH0),
+    3 - right PDM channel (CH1)
+
+ - maxim,rx-channel-mask : a bitmask indicating active PCM Rx channels,
+   bits b7...b0 correspond to channels CH7...CH0
+
+ - maxim,tx-path : indicates the V/I sense (feedback) Tx data interface used:
+    0 - PCM, 1 - TDM
+
+ - maxim,tx-channel-mask : a bitmask indicating active PCM or PDM Tx channels,
+   bits b7...b0 correspond to channels CH7...CH0, for PCM are meaningful
+   channels CH7...CH0, for PDM only channels CH1, CH0
+
+ - maxim,tx-channel-source : a bitmask indicating V/I sense source type for
+   each PCM or PDM Tx channel; bits b7...b0 correspond to channels CH7...CH0,
+   for PCM are meaningful channels CH7...CH0, for PDM only channels CH1, CH0:
+    0 - selects voltage measurement data (V),
+    1 - selects current measurement data (I)
+
+If any of the above optional properties is missing its value defaults to 0.
+
+Example:
+
+ max98504: max98504@31 {
+	compatible = "maxim,max98504";
+	reg = <0x31>;
+	maxim,rx-path = <1>;		// Analog input
+	maxim,tx-path = <1>;		// V/I sense PDM Tx
+	maxim,tx-channel-mask = <3>;	// channels CH1, CH0
+	maxim,tx-channel-source = <2>;	// CH1 current, CH0 voltage
+};
-- 
1.9.1

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

* [PATCH RFC 5/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board
  2016-06-13 10:52 [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
                   ` (3 preceding siblings ...)
  2016-06-13 10:52 ` [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
@ 2016-06-13 10:52 ` Sylwester Nawrocki
  2016-06-13 10:52 ` [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
  5 siblings, 0 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-13 10:52 UTC (permalink / raw)
  To: broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae,
	k.kozlowski, b.zolnierkie, Sylwester Nawrocki

From: Inha Song <ideal.song@samsung.com>

This patch adds the sound machine driver for TM2 board. The codec
operates in master mode. So, reference to the codec master clock
must be set. This machine driver supports SPK playback and Main Mic
capture, BT and Voice call and external accessory.

Signed-off-by: Inha Song <ideal.song@samsung.com>
[k.kozlowski: rebased on 4.1]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[s.nawrocki: rebased to 4.7, adjustment to the ASoC core changes,
 removed unused ops and direct calls to the max98504 function,
 added parsing of "samsung,speaker-amplifier" property]
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 sound/soc/samsung/Kconfig      |  13 +
 sound/soc/samsung/Makefile     |   2 +
 sound/soc/samsung/tm2_wm5110.c | 553 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 568 insertions(+)
 create mode 100644 sound/soc/samsung/tm2_wm5110.c

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 7b722b0..475b25c 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -31,6 +31,9 @@ config SND_SAMSUNG_SPDIF
 config SND_SAMSUNG_I2S
 	tristate
 
+config SND_SAMSUNG_AUDSS
+	tristate
+
 config SND_SOC_SAMSUNG_NEO1973_WM8753
 	tristate "Audio support for Openmoko Neo1973 Smartphones (GTA02)"
 	depends on SND_SOC_SAMSUNG && MACH_NEO1973_GTA02
@@ -229,3 +232,13 @@ config SND_SOC_ARNDALE_RT5631_ALC5631
         depends on SND_SOC_SAMSUNG && I2C
         select SND_SAMSUNG_I2S
         select SND_SOC_RT5631
+
+config SND_SOC_SAMSUNG_TM2_WM5110
+	tristate "SoC I2S Audio support for WM5110 on TM2 board"
+	depends on SND_SOC_SAMSUNG
+	select SND_SOC_MAX98504A
+	select SND_SOC_WM5110
+	select SND_SAMSUNG_I2S
+	select SND_SAMSUNG_AUDSS
+	help
+	  Say Y if you want to add support for SoC audio on the TM2 board.
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile
index 2b919d5..9332991 100644
--- a/sound/soc/samsung/Makefile
+++ b/sound/soc/samsung/Makefile
@@ -46,6 +46,7 @@ snd-soc-lowland-objs := lowland.o
 snd-soc-littlemill-objs := littlemill.o
 snd-soc-bells-objs := bells.o
 snd-soc-arndale-rt5631-objs := arndale_rt5631.o
+snd-soc-tm2-wm5110-objs := tm2_wm5110.o
 
 obj-$(CONFIG_SND_SOC_SAMSUNG_JIVE_WM8750) += snd-soc-jive-wm8750.o
 obj-$(CONFIG_SND_SOC_SAMSUNG_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
@@ -71,3 +72,4 @@ obj-$(CONFIG_SND_SOC_LOWLAND) += snd-soc-lowland.o
 obj-$(CONFIG_SND_SOC_LITTLEMILL) += snd-soc-littlemill.o
 obj-$(CONFIG_SND_SOC_BELLS) += snd-soc-bells.o
 obj-$(CONFIG_SND_SOC_ARNDALE_RT5631_ALC5631) += snd-soc-arndale-rt5631.o
+obj-$(CONFIG_SND_SOC_SAMSUNG_TM2_WM5110) += snd-soc-tm2-wm5110.o
diff --git a/sound/soc/samsung/tm2_wm5110.c b/sound/soc/samsung/tm2_wm5110.c
new file mode 100644
index 0000000..7150958
--- /dev/null
+++ b/sound/soc/samsung/tm2_wm5110.c
@@ -0,0 +1,553 @@
+/*
+ * Copyright (C) 2015 - 2016 Samsung Electronics Co., Ltd.
+ *
+ * Author: Inha Song <ideal.song@samsung.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio.h>
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <sound/soc.h>
+#include <sound/pcm_params.h>
+
+#include "i2s.h"
+#include "lpass.h"
+#include "../codecs/wm5110.h"
+
+struct tm2_machine_priv {
+	struct snd_soc_codec *codec;
+	struct clk *codec_mclk1;
+	struct clk *codec_mclk2;
+
+	unsigned int sysclk_rate;
+
+	int mic_bias;
+};
+
+static int tm2_start_sysclk(struct snd_soc_card *card)
+{
+	struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card);
+	struct snd_soc_codec *codec = priv->codec;
+	unsigned long mclk_rate = clk_get_rate(priv->codec_mclk1);
+	int ret;
+
+	ret = clk_prepare_enable(priv->codec_mclk1);
+	if (ret < 0) {
+		dev_err(card->dev, "Failed to enable mclk: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_codec_set_pll(codec, WM5110_FLL1,
+				    ARIZONA_FLL_SRC_MCLK1,
+				    mclk_rate,
+				    priv->sysclk_rate);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to start FLL: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_codec_set_pll(codec, WM5110_FLL1_REFCLK,
+				    ARIZONA_FLL_SRC_MCLK1,
+				    mclk_rate,
+				    priv->sysclk_rate);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to set FLL1 Source: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK,
+				       ARIZONA_CLK_SRC_FLL1,
+				       priv->sysclk_rate,
+				       SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to set SYSCLK Source: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int tm2_stop_sysclk(struct snd_soc_card *card)
+{
+	struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card);
+	struct snd_soc_codec *codec = priv->codec;
+	int ret;
+
+	ret = snd_soc_codec_set_pll(codec, WM5110_FLL1, 0, 0, 0);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to stop FLL: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK,
+				       ARIZONA_CLK_SRC_FLL1, 0, 0);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to stop SYSCLK: %d\n", ret);
+		return ret;
+	}
+
+	clk_disable_unprepare(priv->codec_mclk1);
+
+	return 0;
+}
+
+static int tm2_aif1_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_codec *codec = rtd->codec;
+	struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+	int ret;
+
+	dev_dbg(codec->dev, "params_rate: %d\n", params_rate(params));
+
+	/*
+	 * SYSCLK Frequency is dependent on the Sample Rate. According to
+	 * the sample rate, valid SYSCLK frequency is defined in manual.
+	 * The manual recommand to select the highest possible SYSCLK
+	 * frequency.
+	 */
+	switch (params_rate(params)) {
+	case 4000:
+	case 8000:
+	case 12000:
+	case 16000:
+	case 24000:
+	case 32000:
+	case 48000:
+	case 96000:
+	case 192000:
+		/* highest possible SYSCLK frequency: 147.456MHz */
+		priv->sysclk_rate = 147456000U;
+		break;
+	case 11025:
+	case 22050:
+	case 44100:
+	case 88200:
+	case 176400:
+		/* highest possible SYSCLK frequency: 135.4752 MHz */
+		priv->sysclk_rate = 135475200U;
+		break;
+	default:
+		dev_err(codec->dev, "Not supported sample rate: %d\n",
+			params_rate(params));
+		return -EINVAL;
+	}
+
+	ret = snd_soc_dai_set_sysclk(codec_dai, ARIZONA_CLK_SYSCLK, 0, 0);
+	if (ret < 0) {
+		dev_err(codec_dai->dev, "Failed to set SYSCLK: %d\n", ret);
+		return ret;
+	}
+
+	return tm2_start_sysclk(rtd->card);
+}
+
+static struct snd_soc_ops tm2_aif1_ops = {
+	.hw_params = tm2_aif1_hw_params,
+};
+
+static int tm2_aif2_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_codec *codec = rtd->codec;
+	struct tm2_machine_priv *priv =	snd_soc_card_get_drvdata(rtd->card);
+	unsigned long mclk_rate = clk_get_rate(priv->codec_mclk1);
+	unsigned int asyncclk_rate;
+	int ret;
+
+	dev_dbg(codec->dev, "params_rate: %d\n", params_rate(params));
+
+	/*
+	 * ASYNC Frequency is dependent on the Sample Rate. According to
+	 * the sample rate, valid ASYNC frequency is defined in manual.
+	 * The manual recommand to select the highest possible ASYNC
+	 * frequency.
+	 */
+	switch (params_rate(params)) {
+	case 8000:
+	case 12000:
+	case 16000:
+		/* highest possible ASYNCCLK frequency: 49.152MHz */
+		asyncclk_rate = 49152000U;
+		break;
+	case 11025:
+		/* highest possible ASYNCCLK frequency: 45.1584 MHz */
+		asyncclk_rate = 45158400U;
+		break;
+	default:
+		dev_err(codec->dev, "Not supported sample rate: %d\n",
+			params_rate(params));
+		return -EINVAL;
+	}
+
+	ret = snd_soc_codec_set_pll(codec, WM5110_FLL2,
+				    ARIZONA_FLL_SRC_MCLK1,
+				    mclk_rate,
+				    asyncclk_rate);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to start FLL: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_codec_set_pll(codec, WM5110_FLL2_REFCLK,
+				    ARIZONA_FLL_SRC_MCLK1,
+				    mclk_rate,
+				    asyncclk_rate);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to set FLL1 Source: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dai_set_sysclk(codec_dai, ARIZONA_CLK_ASYNCCLK, 0, 0);
+
+	if (ret < 0) {
+		dev_err(codec_dai->dev, "Failed to set ASYNCCLK: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_ASYNCCLK,
+				       ARIZONA_CLK_SRC_FLL2,
+				       asyncclk_rate,
+				       SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to set ASYNCCLK Source: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct snd_soc_ops tm2_aif2_ops = {
+	.hw_params = tm2_aif2_hw_params,
+};
+
+static int tm2_mic_bias(struct snd_soc_dapm_widget *w,
+				struct snd_kcontrol *kcontrol, int event)
+{
+	struct snd_soc_card *card = w->dapm->card;
+	struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card);
+
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		gpio_set_value(priv->mic_bias,  1);
+		break;
+	case SND_SOC_DAPM_POST_PMD:
+		gpio_set_value(priv->mic_bias,  0);
+		break;
+	}
+
+	return 0;
+}
+
+static int tm2_set_bias_level(struct snd_soc_card *card,
+				struct snd_soc_dapm_context *dapm,
+				enum snd_soc_bias_level level)
+{
+	struct snd_soc_pcm_runtime *rtd;
+
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+
+	if (dapm->dev != rtd->codec_dai->dev)
+		return 0;
+
+	switch (level) {
+	case SND_SOC_BIAS_STANDBY:
+		if (card->dapm.bias_level == SND_SOC_BIAS_OFF)
+			tm2_start_sysclk(card);
+		break;
+	case SND_SOC_BIAS_OFF:
+		tm2_stop_sysclk(card);
+		break;
+	case SND_SOC_BIAS_PREPARE:
+		break;
+	default:
+		break;
+	}
+
+	card->dapm.bias_level = level;
+
+	dev_dbg(card->dev, "%s: %d\n", __func__, level);
+
+	return 0;
+}
+
+static int tm2_late_probe(struct snd_soc_card *card)
+{
+	struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card);
+	struct snd_soc_pcm_runtime *rtd;
+	int ret;
+
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	priv->codec = rtd->codec;
+
+	ret = devm_gpio_request_one(card->dev, priv->mic_bias,
+				    GPIOF_OUT_INIT_LOW, "MICBIAS_EN_AP");
+	if (ret < 0) {
+		dev_err(card->dev,
+			"Failed to request mic_bias_gpio: %d\n", ret);
+		return ret;
+	}
+
+	/* 32 kHz must be enabled for jack detection */
+	if (!IS_ERR(priv->codec_mclk2))
+		clk_prepare_enable(priv->codec_mclk2);
+
+	gpio_direction_output(priv->mic_bias, 0);
+
+	return 0;
+}
+
+static int tm2_suspend_post(struct snd_soc_card *card)
+{
+	return tm2_stop_sysclk(card);
+}
+
+static int tm2_resume_pre(struct snd_soc_card *card)
+{
+	return tm2_start_sysclk(card);
+}
+
+static const struct snd_kcontrol_new card_controls[] = {
+	SOC_DAPM_PIN_SWITCH("HP"),
+	SOC_DAPM_PIN_SWITCH("SPK"),
+	SOC_DAPM_PIN_SWITCH("RCV"),
+	SOC_DAPM_PIN_SWITCH("VPS"),
+	SOC_DAPM_PIN_SWITCH("HDMI"),
+
+	SOC_DAPM_PIN_SWITCH("Main Mic"),
+	SOC_DAPM_PIN_SWITCH("Sub Mic"),
+	SOC_DAPM_PIN_SWITCH("Third Mic"),
+
+	SOC_DAPM_PIN_SWITCH("Headset Mic"),
+};
+
+const struct snd_soc_dapm_widget machine_dapm_widgets[] = {
+	SND_SOC_DAPM_HP("HP", NULL),
+	SND_SOC_DAPM_SPK("SPK", NULL),
+	SND_SOC_DAPM_SPK("RCV", NULL),
+	SND_SOC_DAPM_LINE("VPS", NULL),
+	SND_SOC_DAPM_LINE("HDMI", NULL),
+
+	SND_SOC_DAPM_MIC("Main Mic", tm2_mic_bias),
+	SND_SOC_DAPM_MIC("Sub Mic", NULL),
+	SND_SOC_DAPM_MIC("Third Mic", NULL),
+
+	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+};
+
+static const struct snd_soc_component_driver tm2_component = {
+	.name	= "tm2-audio",
+};
+
+static struct snd_soc_dai_driver tm2_ext_dai[] = {
+	{
+		.name = "Voice call",
+		.playback = {
+			.channels_min = 1,
+			.channels_max = 4,
+			.rate_min = 8000,
+			.rate_max = 48000,
+			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+					SNDRV_PCM_RATE_48000),
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		},
+		.capture = {
+			.channels_min = 1,
+			.channels_max = 4,
+			.rate_min = 8000,
+			.rate_max = 48000,
+			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
+					SNDRV_PCM_RATE_48000),
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		},
+	},
+	{
+		.name = "Bluetooth",
+		.playback = {
+			.channels_min = 1,
+			.channels_max = 4,
+			.rate_min = 8000,
+			.rate_max = 16000,
+			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		},
+		.capture = {
+			.channels_min = 1,
+			.channels_max = 2,
+			.rate_min = 8000,
+			.rate_max = 16000,
+			.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
+			.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		},
+	},
+};
+
+static struct snd_soc_dai_link machine_dai[] = {
+	{
+		.name		= "WM5110 AIF1",
+		.stream_name	= "HiFi Primary",
+		.codec_dai_name = "wm5110-aif1",
+		.codec_name	= "wm5110-codec",
+		.ops		= &tm2_aif1_ops,
+		.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBM_CFM,
+	}, {
+		.name		= "WM5110 Voice",
+		.stream_name	= "Voice call",
+		.codec_dai_name = "wm5110-aif2",
+		.codec_name	= "wm5110-codec",
+		.ops		= &tm2_aif2_ops,
+		.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBM_CFM,
+		.ignore_suspend = 1,
+	}, {
+		.name		= "WM5110 BT",
+		.stream_name	= "Bluetooth",
+		.codec_dai_name = "wm5110-aif3",
+		.codec_name	= "wm5110-codec",
+		.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBM_CFM,
+		.ignore_suspend = 1,
+	}
+};
+
+static struct snd_soc_aux_dev tm2_speaker_amp_dev;
+
+static struct snd_soc_card tm2_card = {
+	.owner			= THIS_MODULE,
+
+	.dai_link		= machine_dai,
+	.num_links		= ARRAY_SIZE(machine_dai),
+	.controls		= card_controls,
+	.num_controls		= ARRAY_SIZE(card_controls),
+	.dapm_widgets		= machine_dapm_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(machine_dapm_widgets),
+
+	.aux_dev		= &tm2_speaker_amp_dev,
+	.num_aux_devs		= 1,
+
+	.late_probe		= tm2_late_probe,
+
+	.set_bias_level		= tm2_set_bias_level,
+
+	.suspend_post		= tm2_suspend_post,
+	.resume_pre		= tm2_resume_pre,
+};
+
+static int tm2_wm5110_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct snd_soc_card *card = &tm2_card;
+	struct snd_soc_dai_link *dai_link = card->dai_link;
+	struct tm2_machine_priv *priv;
+	int ret, i;
+
+	if (!dev->of_node) {
+		dev_err(dev, "DT node is missing\n");
+		return -ENODEV;
+	}
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	snd_soc_card_set_drvdata(card, priv);
+	card->dev = dev;
+
+	ret = snd_soc_of_parse_card_name(card, "samsung,model");
+	if (ret < 0) {
+		dev_err(dev, "Card name is not provided\n");
+		return ret;
+	}
+
+	ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
+	if (ret < 0) {
+		dev_err(dev, "Audio routing is not provided\n");
+		return ret;
+	}
+
+	tm2_speaker_amp_dev.codec_of_node = of_parse_phandle(dev->of_node,
+						"samsung,speaker-amplifier", 0);
+	if (!tm2_speaker_amp_dev.codec_of_node) {
+		dev_err(dev, "speaker-amplifier property parse error\n");
+		return -EINVAL;
+	}
+
+	for (i = 0; i < card->num_links; i++) {
+		dai_link[i].cpu_dai_name = NULL;
+		dai_link[i].cpu_name = NULL;
+		dai_link[i].cpu_of_node = of_parse_phandle(dev->of_node,
+						"samsung,i2s-controller", 0);
+		if (!dai_link[i].cpu_of_node) {
+			dev_err(dev, "i2s-controller property parse error\n");
+			return -EINVAL;
+		}
+
+		dai_link[i].platform_name = NULL;
+		dai_link[i].platform_of_node = dai_link[i].cpu_of_node;
+	}
+
+	priv->codec_mclk1 = devm_clk_get(dev, "mclk1");
+	if (IS_ERR(priv->codec_mclk1)) {
+		dev_err(dev, "Failed to get out clock\n");
+		return PTR_ERR(priv->codec_mclk1);
+	}
+
+	/* mclk2 is optional */
+	priv->codec_mclk2 = devm_clk_get(dev, "mclk2");
+	if (IS_ERR(priv->codec_mclk2))
+		dev_err(dev, "Failed to get mclk2 clock\n");
+
+	priv->mic_bias = of_get_named_gpio(dev->of_node, "mic_bias_gpio", 0);
+	if (!gpio_is_valid(priv->mic_bias)) {
+		dev_err(dev, "Failed to get mic_bias_gpio\n");
+		return -EINVAL;
+	}
+
+	ret = devm_snd_soc_register_component(dev, &tm2_component,
+				tm2_ext_dai, ARRAY_SIZE(tm2_ext_dai));
+	if (ret < 0) {
+		dev_err(dev, "Failed to register component: %d\n", ret);
+		return ret;
+	}
+
+	ret = devm_snd_soc_register_card(dev, card);
+	if (ret < 0) {
+		dev_err(dev, "Failed to register card: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct of_device_id tm2_wm5110_of_match[] = {
+	{ .compatible = "samsung,tm2-audio" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, tm2_wm5110_of_match);
+
+static struct platform_driver tm2_wm5110_driver = {
+	.driver = {
+		.name = "tm2-audio",
+		.pm = &snd_soc_pm_ops,
+		.of_match_table = tm2_wm5110_of_match,
+	},
+	.probe = tm2_wm5110_probe,
+};
+
+module_platform_driver(tm2_wm5110_driver);
+
+MODULE_AUTHOR("Inha Song <ideal.song@samsung.com>");
+MODULE_DESCRIPTION("ALSA SoC TM2 Audio Support");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

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

* [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-13 10:52 [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
                   ` (4 preceding siblings ...)
  2016-06-13 10:52 ` [PATCH RFC 5/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board Sylwester Nawrocki
@ 2016-06-13 10:52 ` Sylwester Nawrocki
  2016-06-14 23:32   ` Rob Herring
                     ` (2 more replies)
  5 siblings, 3 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-13 10:52 UTC (permalink / raw)
  To: broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae,
	k.kozlowski, b.zolnierkie, Sylwester Nawrocki

This patch adds DT binding documentation for Exnos5433 based TM2
and TM2E boards sound subsystem.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 .../bindings/sound/samsung,tm2-wm5110.txt          | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt

diff --git a/Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt b/Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt
new file mode 100644
index 0000000..32f69fcc
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt
@@ -0,0 +1,39 @@
+Samsung Exynos5433 TM2(E) audio complex with WM5110 codec
+
+Required properties:
+
+ - compatible : "samsung,tm2-audio"
+ - samsung,model : the user-visible name of this sound complex
+ - clocks : must contain an entry for each entry in clock-names,
+   see ../clocks/clock-bindings.txt for details
+ - clock-names : must include the following entries:
+   "mclk1", "mclk2"
+ - samsung,i2s-controller : the phandle of the I2S controller
+ - samsung,speaker-amplifier : the phandle of the MAX98504 amplifier
+ - samsung,audio-routing : a list of the connections between audio
+   components;  each entry is a pair of strings, the first being the
+   connection's sink, the second being the connection's source;
+   valid names for sources and sinks are the WM5110's and MAX98504's
+   pins and the jacks on the board:
+   HP, SPK, Main Mic, Sub Mic, Third Mic, Headset Mic.
+ - mic-bias-gpios : GPIO pin that enables the Main Mic bias regulator
+
+Example:
+
+sound {
+	compatible = "samsung,tm2-audio";
+	clocks = <&pmu_system_controller 0>, <&s2mps13_osc 2>;
+	clock-names = "mclk1", "mclk2";
+	samsung,i2s-controller = <&i2s0>;
+	samsung,speaker-amplifier = <&max98504>;
+	samsung,model = "wm5110";
+	mic-bias-gpios = <&gpr3 2 0>;
+	samsung,audio-routing =
+		"HP", "HPOUT1L",
+		"HP", "HPOUT1R",
+		"SPK", "SPKOUT",
+		"SPKOUT", "HPOUT2L",
+		"SPKOUT", "HPOUT2R",
+		"Main Mic", "MICBIAS2",
+		"IN1R", "Main Mic";
+};
-- 
1.9.1

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

* Re: [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver
  2016-06-13 10:52 ` [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver Sylwester Nawrocki
@ 2016-06-13 15:14   ` Mark Brown
  2016-06-14 14:52     ` Sylwester Nawrocki
  0 siblings, 1 reply; 28+ messages in thread
From: Mark Brown @ 2016-06-13 15:14 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: alsa-devel, devicetree, robh, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

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

On Mon, Jun 13, 2016 at 12:52:37PM +0200, Sylwester Nawrocki wrote:

> [s.nawrocki: removed unused macro definitions and regulator handling
>  code, rewrote regmap config code, added support for speaker enable
>  and global chip enable through DAPM, rewritten as component driver,
>  redesigned DT bindings]

Removed the regulator handling code?  Why?

> +	default:
> +		/* Analog input, disable PCM, PDM Rx */
> +		regmap_write(map, MAX98504_REG_PCM_RX_ENABLE, 0);
> +		regmap_write(map, MAX98504_REG_PDM_RX_ENABLE, 0);
> +	}

Add a break here please, at least for consistency.

> +		ret = PTR_ERR(max98504->regmap);
> +		dev_err(&client->dev, "regmap initialization failed: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = max98504_probe(max98504);
> +	if (ret < 0)
> +		return ret;

Why not just inline this code?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier
  2016-06-13 10:52 ` [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
@ 2016-06-13 15:32   ` Mark Brown
  2016-06-14 15:14     ` Sylwester Nawrocki
  2016-06-16 11:31   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 28+ messages in thread
From: Mark Brown @ 2016-06-13 15:32 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: alsa-devel, devicetree, robh, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

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

On Mon, Jun 13, 2016 at 12:52:38PM +0200, Sylwester Nawrocki wrote:

> + - maxim,rx-path : indicates speaker source interface:
> +    0 - PCM monomix output,
> +    1 - Analog input,
> +    2 - left PDM channel (CH0),
> +    3 - right PDM channel (CH1)

This should be a DAPM control.

> + - maxim,rx-channel-mask : a bitmask indicating active PCM Rx channels,
> +   bits b7...b0 correspond to channels CH7...CH0

This should be done using the TDM API.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver
  2016-06-13 15:14   ` Mark Brown
@ 2016-06-14 14:52     ` Sylwester Nawrocki
  2016-06-15  9:25       ` Mark Brown
  0 siblings, 1 reply; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-14 14:52 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, devicetree, robh, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

On 06/13/2016 05:14 PM, Mark Brown wrote:
> On Mon, Jun 13, 2016 at 12:52:37PM +0200, Sylwester Nawrocki wrote:
> 
>> [s.nawrocki: removed unused macro definitions and regulator handling
>>  code, rewrote regmap config code, added support for speaker enable
>>  and global chip enable through DAPM, rewritten as component driver,
>>  redesigned DT bindings]
> 
> Removed the regulator handling code?  Why?

Because it was effectively a dead code (disabled by a DT flag property)
and didn't make any sense on our test board. It was setting regulator's
load and voltage on a shared fixed voltage regulator. Even if calls like
regulator_set_optimum_mode() were added that wouldn't make any difference,
since the corresponding PMIC driver ops were not implemented.
I started more or less with something like this [1].

>> +	default:
>> +		/* Analog input, disable PCM, PDM Rx */
>> +		regmap_write(map, MAX98504_REG_PCM_RX_ENABLE, 0);
>> +		regmap_write(map, MAX98504_REG_PDM_RX_ENABLE, 0);
>> +	}
> 
> Add a break here please, at least for consistency.
> 
>> +		ret = PTR_ERR(max98504->regmap);
>> +		dev_err(&client->dev, "regmap initialization failed: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	ret = max98504_probe(max98504);
>> +	if (ret < 0)
>> +		return ret;
> 
> Why not just inline this code?

Will do in next iteration. Thanks for your review.

[1]
https://github.com/halaszk/Perseus-halaszk-universal5433/blob/perseus5433-mm/sound/soc/codecs/max98504a.c

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

* Re: [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier
  2016-06-13 15:32   ` Mark Brown
@ 2016-06-14 15:14     ` Sylwester Nawrocki
  2016-06-15  9:25       ` Mark Brown
  0 siblings, 1 reply; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-14 15:14 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, devicetree, robh, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

On 06/13/2016 05:32 PM, Mark Brown wrote:
> On Mon, Jun 13, 2016 at 12:52:38PM +0200, Sylwester Nawrocki wrote:
> 
>> > + - maxim,rx-path : indicates speaker source interface:
>> > +    0 - PCM monomix output,
>> > +    1 - Analog input,
>> > +    2 - left PDM channel (CH0),
>> > +    3 - right PDM channel (CH1)
>
> This should be a DAPM control.
> 
>> > + - maxim,rx-channel-mask : a bitmask indicating active PCM Rx channels,
>> > +   bits b7...b0 correspond to channels CH7...CH0
>
> This should be done using the TDM API.

I suspected these don't belong here. I'll add a DAPM control for speaker
source and will learn about the TDM API. I'm inclined to simply omit
the PCM Rx channels configuration feature for now, as the MAX98504's PCM
interface is left unconnected on our board.

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

* Re: [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS
  2016-06-13 10:52 ` [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
@ 2016-06-14 23:28   ` Rob Herring
  2016-06-16 16:13     ` Sylwester Nawrocki
  2016-06-16 11:28   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 28+ messages in thread
From: Rob Herring @ 2016-06-14 23:28 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: broonie, alsa-devel, devicetree, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

On Mon, Jun 13, 2016 at 12:52:36PM +0200, Sylwester Nawrocki wrote:
> This patch add documentation of the DT bindings for the Samsung
> Exynos SoC Low Power Audio Subsystem.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
>  .../devicetree/bindings/sound/samsung,exynos5433-lpass.txt        | 8 ++++++++
>  1 file changed, 8 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt

Seems kind of incomplete, but for what's here:

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-13 10:52 ` [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
@ 2016-06-14 23:32   ` Rob Herring
  2016-06-15  9:47     ` Mark Brown
  2016-06-15  9:40   ` Lars-Peter Clausen
  2016-06-16 11:33   ` Krzysztof Kozlowski
  2 siblings, 1 reply; 28+ messages in thread
From: Rob Herring @ 2016-06-14 23:32 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: broonie, alsa-devel, devicetree, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

On Mon, Jun 13, 2016 at 12:52:40PM +0200, Sylwester Nawrocki wrote:
> This patch adds DT binding documentation for Exnos5433 based TM2
> and TM2E boards sound subsystem.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
>  .../bindings/sound/samsung,tm2-wm5110.txt          | 39 ++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt
> 
> diff --git a/Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt b/Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt
> new file mode 100644
> index 0000000..32f69fcc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt
> @@ -0,0 +1,39 @@
> +Samsung Exynos5433 TM2(E) audio complex with WM5110 codec
> +
> +Required properties:
> +
> + - compatible : "samsung,tm2-audio"

SoC specific compatible string please.

> + - samsung,model : the user-visible name of this sound complex

I think we have a standard property for this.

> + - clocks : must contain an entry for each entry in clock-names,
> +   see ../clocks/clock-bindings.txt for details
> + - clock-names : must include the following entries:
> +   "mclk1", "mclk2"

> + - samsung,i2s-controller : the phandle of the I2S controller
> + - samsung,speaker-amplifier : the phandle of the MAX98504 amplifier

We should have standard properties for these. 2nd ones I've seen today.

> + - samsung,audio-routing : a list of the connections between audio
> +   components;  each entry is a pair of strings, the first being the
> +   connection's sink, the second being the connection's source;
> +   valid names for sources and sinks are the WM5110's and MAX98504's
> +   pins and the jacks on the board:
> +   HP, SPK, Main Mic, Sub Mic, Third Mic, Headset Mic.
> + - mic-bias-gpios : GPIO pin that enables the Main Mic bias regulator
> +
> +Example:
> +
> +sound {
> +	compatible = "samsung,tm2-audio";
> +	clocks = <&pmu_system_controller 0>, <&s2mps13_osc 2>;
> +	clock-names = "mclk1", "mclk2";
> +	samsung,i2s-controller = <&i2s0>;
> +	samsung,speaker-amplifier = <&max98504>;
> +	samsung,model = "wm5110";
> +	mic-bias-gpios = <&gpr3 2 0>;
> +	samsung,audio-routing =
> +		"HP", "HPOUT1L",
> +		"HP", "HPOUT1R",
> +		"SPK", "SPKOUT",
> +		"SPKOUT", "HPOUT2L",
> +		"SPKOUT", "HPOUT2R",
> +		"Main Mic", "MICBIAS2",
> +		"IN1R", "Main Mic";
> +};
> -- 
> 1.9.1
> 

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

* Re: [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver
  2016-06-14 14:52     ` Sylwester Nawrocki
@ 2016-06-15  9:25       ` Mark Brown
  2016-06-16 16:17         ` Sylwester Nawrocki
  0 siblings, 1 reply; 28+ messages in thread
From: Mark Brown @ 2016-06-15  9:25 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: alsa-devel, devicetree, robh, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

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

On Tue, Jun 14, 2016 at 04:52:15PM +0200, Sylwester Nawrocki wrote:
> On 06/13/2016 05:14 PM, Mark Brown wrote:

> > Removed the regulator handling code?  Why?

> Because it was effectively a dead code (disabled by a DT flag property)
> and didn't make any sense on our test board. It was setting regulator's
> load and voltage on a shared fixed voltage regulator. Even if calls like
> regulator_set_optimum_mode() were added that wouldn't make any difference,
> since the corresponding PMIC driver ops were not implemented.
> I started more or less with something like this [1].

The mode and voltage setting code there are just obviously broken but
having the get and enable is useful, even if it doesn't do anything on
your board it's nice to have them there already to avoid any transition
issues adding them later and help get more complete and accurate DTs in
from the get go.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier
  2016-06-14 15:14     ` Sylwester Nawrocki
@ 2016-06-15  9:25       ` Mark Brown
  0 siblings, 0 replies; 28+ messages in thread
From: Mark Brown @ 2016-06-15  9:25 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: alsa-devel, devicetree, robh, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

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

On Tue, Jun 14, 2016 at 05:14:58PM +0200, Sylwester Nawrocki wrote:

> I suspected these don't belong here. I'll add a DAPM control for speaker
> source and will learn about the TDM API. I'm inclined to simply omit
> the PCM Rx channels configuration feature for now, as the MAX98504's PCM
> interface is left unconnected on our board.

That works too.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-13 10:52 ` [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
  2016-06-14 23:32   ` Rob Herring
@ 2016-06-15  9:40   ` Lars-Peter Clausen
  2016-06-16 16:39     ` [alsa-devel] " Sylwester Nawrocki
  2016-06-16 11:33   ` Krzysztof Kozlowski
  2 siblings, 1 reply; 28+ messages in thread
From: Lars-Peter Clausen @ 2016-06-15  9:40 UTC (permalink / raw)
  To: Sylwester Nawrocki, broonie, alsa-devel, devicetree
  Cc: robh, k.kozlowski, linux-samsung-soc, b.zolnierkie, inki.dae,
	beomho.seo, ideal.song

On 06/13/2016 12:52 PM, Sylwester Nawrocki wrote:
[...]
> + - compatible : "samsung,tm2-audio"
> + - samsung,model : the user-visible name of this sound complex
> + - clocks : must contain an entry for each entry in clock-names,
> +   see ../clocks/clock-bindings.txt for details
> + - clock-names : must include the following entries:
> +   "mclk1", "mclk2"

If these are the MCLKs that go to the CODEC they should be properties of the
CODEC node.

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

* Re: [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-14 23:32   ` Rob Herring
@ 2016-06-15  9:47     ` Mark Brown
  2016-06-20 17:49       ` Rob Herring
  0 siblings, 1 reply; 28+ messages in thread
From: Mark Brown @ 2016-06-15  9:47 UTC (permalink / raw)
  To: Rob Herring
  Cc: Sylwester Nawrocki, alsa-devel, devicetree, linux-samsung-soc,
	ideal.song, beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

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

On Tue, Jun 14, 2016 at 06:32:24PM -0500, Rob Herring wrote:
> On Mon, Jun 13, 2016 at 12:52:40PM +0200, Sylwester Nawrocki wrote:

> > +Samsung Exynos5433 TM2(E) audio complex with WM5110 codec

> > +Required properties:

> > + - compatible : "samsung,tm2-audio"

> SoC specific compatible string please.

No, this isn't a SoC IP - this is a binding for a board called TM2(E)
which has a bunch of chips on it including this.

> > + - samsung,i2s-controller : the phandle of the I2S controller
> > + - samsung,speaker-amplifier : the phandle of the MAX98504 amplifier

> We should have standard properties for these. 2nd ones I've seen today.

No, these aren't fixed roles in a system, you couldn't have standard
handling for them.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH RFC 1/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
  2016-06-13 10:52 ` [PATCH RFC 1/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
@ 2016-06-16 11:28   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 28+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-16 11:28 UTC (permalink / raw)
  To: Sylwester Nawrocki, broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae, b.zolnierkie

On 06/13/2016 12:52 PM, Sylwester Nawrocki wrote:
> From: Inha Song <ideal.song@samsung.com>
> 
> This patch adds LPASS driver. The LPASS (Low Power Audio Subsystem)
> is a special subsystem that supports audio playback with low power
> consumption. This is a minimal driver which prepares resources for
> IP blocks like I2S, audio DMA and UART.
> Also system power ops are added to ensure the Audio Subsystem is
> operational after system suspend/resume cycle.
> 
> Signed-off-by: Inha Song <ideal.song@samsung.com>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
>  sound/soc/samsung/Makefile |   2 +
>  sound/soc/samsung/lpass.c  | 162 +++++++++++++++++++++++++++++++++++++++++++++
>  sound/soc/samsung/lpass.h  |  47 +++++++++++++
>  3 files changed, 211 insertions(+)
>  create mode 100644 sound/soc/samsung/lpass.c
>  create mode 100644 sound/soc/samsung/lpass.h

Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

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

* Re: [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS
  2016-06-13 10:52 ` [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
  2016-06-14 23:28   ` Rob Herring
@ 2016-06-16 11:28   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 28+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-16 11:28 UTC (permalink / raw)
  To: Sylwester Nawrocki, broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae, b.zolnierkie

On 06/13/2016 12:52 PM, Sylwester Nawrocki wrote:
> This patch add documentation of the DT bindings for the Samsung
> Exynos SoC Low Power Audio Subsystem.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
>  .../devicetree/bindings/sound/samsung,exynos5433-lpass.txt        | 8 ++++++++
>  1 file changed, 8 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt

Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

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

* Re: [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier
  2016-06-13 10:52 ` [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
  2016-06-13 15:32   ` Mark Brown
@ 2016-06-16 11:31   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 28+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-16 11:31 UTC (permalink / raw)
  To: Sylwester Nawrocki, broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae, b.zolnierkie

On 06/13/2016 12:52 PM, Sylwester Nawrocki wrote:
> This patch adds DT bindings documentation for Maxim MAX98504
> speaker amplifier.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
>  .../devicetree/bindings/sound/max98504.txt         | 44 ++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/max98504.txt
> 

Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

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

* Re: [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-13 10:52 ` [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
  2016-06-14 23:32   ` Rob Herring
  2016-06-15  9:40   ` Lars-Peter Clausen
@ 2016-06-16 11:33   ` Krzysztof Kozlowski
  2 siblings, 0 replies; 28+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-16 11:33 UTC (permalink / raw)
  To: Sylwester Nawrocki, broonie, alsa-devel, devicetree
  Cc: robh, linux-samsung-soc, ideal.song, beomho.seo, inki.dae, b.zolnierkie

On 06/13/2016 12:52 PM, Sylwester Nawrocki wrote:
> This patch adds DT binding documentation for Exnos5433 based TM2

s/Exnos5433/Exynos5433/

> and TM2E boards sound subsystem.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
>  .../bindings/sound/samsung,tm2-wm5110.txt          | 39 ++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/samsung,tm2-wm5110.txt
> 

Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

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

* Re: [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS
  2016-06-14 23:28   ` Rob Herring
@ 2016-06-16 16:13     ` Sylwester Nawrocki
  0 siblings, 0 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-16 16:13 UTC (permalink / raw)
  To: Rob Herring
  Cc: broonie, alsa-devel, devicetree, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

On 06/15/2016 01:28 AM, Rob Herring wrote:
> On Mon, Jun 13, 2016 at 12:52:36PM +0200, Sylwester Nawrocki wrote:
>> > This patch add documentation of the DT bindings for the Samsung
>> > Exynos SoC Low Power Audio Subsystem.
>> > 
>> > Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
>> > ---
>> >  .../devicetree/bindings/sound/samsung,exynos5433-lpass.txt        | 8 ++++++++
>> >  1 file changed, 8 insertions(+)
>> >  create mode 100644 Documentation/devicetree/bindings/sound/samsung,exynos5433-lpass.txt
> Seems kind of incomplete, but for what's here:
> 
> Acked-by: Rob Herring <robh@kernel.org>

Thanks, it's indeed a bit incomplete. Most of the functionality is
already covered by existing bindings of sub-IPs like I2S, DMAC, UART.
I'd expect more detailed binding be specified for newer SoCs and that
would be a different compatible string.

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

* Re: [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver
  2016-06-15  9:25       ` Mark Brown
@ 2016-06-16 16:17         ` Sylwester Nawrocki
  0 siblings, 0 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-16 16:17 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, devicetree, robh, linux-samsung-soc, ideal.song,
	beomho.seo, inki.dae, k.kozlowski, b.zolnierkie

On 06/15/2016 11:25 AM, Mark Brown wrote:
> On Tue, Jun 14, 2016 at 04:52:15PM +0200, Sylwester Nawrocki wrote:
>> > On 06/13/2016 05:14 PM, Mark Brown wrote:
>>> > > Removed the regulator handling code?  Why?
>> > Because it was effectively a dead code (disabled by a DT flag property)
>> > and didn't make any sense on our test board. It was setting regulator's
>> > load and voltage on a shared fixed voltage regulator. Even if calls like
>> > regulator_set_optimum_mode() were added that wouldn't make any difference,
>> > since the corresponding PMIC driver ops were not implemented.
>> > I started more or less with something like this [1].
>
> The mode and voltage setting code there are just obviously broken but
> having the get and enable is useful, even if it doesn't do anything on
> your board it's nice to have them there already to avoid any transition
> issues adding them later and help get more complete and accurate DTs in
> from the get go.

OK, I've added regulator supply related code and properties to the DT binding.

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

* Re: [alsa-devel] [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-15  9:40   ` Lars-Peter Clausen
@ 2016-06-16 16:39     ` Sylwester Nawrocki
  2016-06-16 16:45       ` Lars-Peter Clausen
  0 siblings, 1 reply; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-16 16:39 UTC (permalink / raw)
  To: Lars-Peter Clausen, broonie, alsa-devel, devicetree
  Cc: robh, k.kozlowski, linux-samsung-soc, b.zolnierkie, inki.dae,
	beomho.seo, ideal.song

On 06/15/2016 11:40 AM, Lars-Peter Clausen wrote:
> On 06/13/2016 12:52 PM, Sylwester Nawrocki wrote:
> [...]
>> > + - compatible : "samsung,tm2-audio"
>> > + - samsung,model : the user-visible name of this sound complex
>> > + - clocks : must contain an entry for each entry in clock-names,
>> > +   see ../clocks/clock-bindings.txt for details
>> > + - clock-names : must include the following entries:
>> > +   "mclk1", "mclk2"
>
> If these are the MCLKs that go to the CODEC they should be properties of the
> CODEC node.

Yes, these are both CODEC clocks. I couldn't find any related clk code in
the wm5110 arizona codec driver and indeed the clocks stay disabled when
I specify them in the wm5110 DT node. AFAICS from other thread in this
mailing list it is going to take some time until the CODEC drivers are
updated. How about minimizing the requirement of those clocks, making them
optional and then when the CODEC driver gets updated specifying the clocks
in the codec node instead of the sound card one?
The MCLK1 rate could be just hard coded instead of using clk_get_rate(),
but without clk enable calls nothing works.

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

* Re: [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-16 16:39     ` [alsa-devel] " Sylwester Nawrocki
@ 2016-06-16 16:45       ` Lars-Peter Clausen
  2016-06-17 11:08         ` [alsa-devel] " Sylwester Nawrocki
  0 siblings, 1 reply; 28+ messages in thread
From: Lars-Peter Clausen @ 2016-06-16 16:45 UTC (permalink / raw)
  To: Sylwester Nawrocki, broonie, alsa-devel, devicetree
  Cc: robh, k.kozlowski, linux-samsung-soc, b.zolnierkie, inki.dae,
	beomho.seo, ideal.song

On 06/16/2016 06:39 PM, Sylwester Nawrocki wrote:
> On 06/15/2016 11:40 AM, Lars-Peter Clausen wrote:
>> On 06/13/2016 12:52 PM, Sylwester Nawrocki wrote:
>> [...]
>>>> + - compatible : "samsung,tm2-audio"
>>>> + - samsung,model : the user-visible name of this sound complex
>>>> + - clocks : must contain an entry for each entry in clock-names,
>>>> +   see ../clocks/clock-bindings.txt for details
>>>> + - clock-names : must include the following entries:
>>>> +   "mclk1", "mclk2"
>>
>> If these are the MCLKs that go to the CODEC they should be properties of the
>> CODEC node.
> 
> Yes, these are both CODEC clocks. I couldn't find any related clk code in
> the wm5110 arizona codec driver and indeed the clocks stay disabled when
> I specify them in the wm5110 DT node. AFAICS from other thread in this
> mailing list it is going to take some time until the CODEC drivers are
> updated. How about minimizing the requirement of those clocks, making them
> optional and then when the CODEC driver gets updated specifying the clocks
> in the codec node instead of the sound card one?
> The MCLK1 rate could be just hard coded instead of using clk_get_rate(),
> but without clk enable calls nothing works.

You can still handle the clocks in the machine driver, but they should be
specified in the node of the CODEC to accurately represent the hardware.

The simple-card driver e.g. does this, requests the clock of the CODEC and
uses it to configure the CODEC input frequency based on it with
snd_soc_dai_set_sysclk().

- Lars

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

* Re: [alsa-devel] [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-16 16:45       ` Lars-Peter Clausen
@ 2016-06-17 11:08         ` Sylwester Nawrocki
  0 siblings, 0 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-17 11:08 UTC (permalink / raw)
  To: Lars-Peter Clausen, alsa-devel, devicetree
  Cc: broonie, robh, k.kozlowski, linux-samsung-soc, b.zolnierkie,
	inki.dae, beomho.seo, ideal.song

On 06/16/2016 06:45 PM, Lars-Peter Clausen wrote:
> You can still handle the clocks in the machine driver, but they should be
> specified in the node of the CODEC to accurately represent the hardware.
> 
> The simple-card driver e.g. does this, requests the clock of the CODEC and
> uses it to configure the CODEC input frequency based on it with
> snd_soc_dai_set_sysclk().

I was assuming parsing the CODEC node was not preferred. Thanks for the
clarification, I have reworked the machine driver to use the CODEC node.

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

* Re: [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-15  9:47     ` Mark Brown
@ 2016-06-20 17:49       ` Rob Herring
  2016-06-21  9:48         ` Sylwester Nawrocki
  0 siblings, 1 reply; 28+ messages in thread
From: Rob Herring @ 2016-06-20 17:49 UTC (permalink / raw)
  To: Mark Brown
  Cc: devicetree, Linux-ALSA, linux-samsung-soc,
	Bartlomiej Zolnierkiewicz, Krzysztof Kozłowski, InKi Dae,
	Sylwester Nawrocki, Beomho Seo, Inha Song

On Wed, Jun 15, 2016 at 4:47 AM, Mark Brown <broonie@kernel.org> wrote:
> On Tue, Jun 14, 2016 at 06:32:24PM -0500, Rob Herring wrote:
>> On Mon, Jun 13, 2016 at 12:52:40PM +0200, Sylwester Nawrocki wrote:
>
>> > +Samsung Exynos5433 TM2(E) audio complex with WM5110 codec
>
>> > +Required properties:
>
>> > + - compatible : "samsung,tm2-audio"
>
>> SoC specific compatible string please.
>
> No, this isn't a SoC IP - this is a binding for a board called TM2(E)
> which has a bunch of chips on it including this.

Okay, good.

>
>> > + - samsung,i2s-controller : the phandle of the I2S controller
>> > + - samsung,speaker-amplifier : the phandle of the MAX98504 amplifier
>
>> We should have standard properties for these. 2nd ones I've seen today.
>
> No, these aren't fixed roles in a system, you couldn't have standard
> handling for them.

What do you mean? It is silly for us to put vendor prefixes on all of
these. There are dozens of examples in the binding docs of
<vendor>,i2s-controller and <vendor>,audio-codec. Yes, dropping just
the vendor prefix doesn't buy much (maybe some string space), but it
certainly adds nothing.

Rob

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

* Re: [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
  2016-06-20 17:49       ` Rob Herring
@ 2016-06-21  9:48         ` Sylwester Nawrocki
  0 siblings, 0 replies; 28+ messages in thread
From: Sylwester Nawrocki @ 2016-06-21  9:48 UTC (permalink / raw)
  To: Rob Herring, Mark Brown
  Cc: Linux-ALSA, devicetree, linux-samsung-soc, Inha Song, Beomho Seo,
	InKi Dae, Krzysztof Kozłowski, Bartlomiej Zolnierkiewicz

On 06/20/2016 07:49 PM, Rob Herring wrote:
>>>> + - samsung,i2s-controller : the phandle of the I2S controller
>>>> + - samsung,speaker-amplifier : the phandle of the MAX98504 amplifier

I'm considering changing this to a more generic (samsung,?)audio-amplifier
in next iteration. Or maybe just listing MAX98504 as second entry of the
(samsung,)audio-codec(s) property value, since capabilities and functionality 
of the device in the system is not limited to just simple audio power 
amplification. It accepts analogue audio signal on its input and is 
transmitting digital audio data stream in the feedback path to the WM5110 
codec's DSP.

>>> >> We should have standard properties for these. 2nd ones I've seen today.
>> >
>> > No, these aren't fixed roles in a system, you couldn't have standard
>> > handling for them.
>
> What do you mean? It is silly for us to put vendor prefixes on all of
> these. There are dozens of examples in the binding docs of
> <vendor>,i2s-controller and <vendor>,audio-codec. Yes, dropping just
> the vendor prefix doesn't buy much (maybe some string space), but it
> certainly adds nothing.

It also looked unnecessary to me to at first sight to be adding
vendor prefixes to those properties. We could look at the compatible
string in the pointed node for handling any differences.

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

end of thread, other threads:[~2016-06-21  9:48 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-13 10:52 [PATCH RFC 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
2016-06-13 10:52 ` [PATCH RFC 1/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
2016-06-16 11:28   ` Krzysztof Kozlowski
2016-06-13 10:52 ` [PATCH RFC 2/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
2016-06-14 23:28   ` Rob Herring
2016-06-16 16:13     ` Sylwester Nawrocki
2016-06-16 11:28   ` Krzysztof Kozlowski
2016-06-13 10:52 ` [PATCH RFC 3/6] ASoC: max98504: Add max98504 speaker amplifier driver Sylwester Nawrocki
2016-06-13 15:14   ` Mark Brown
2016-06-14 14:52     ` Sylwester Nawrocki
2016-06-15  9:25       ` Mark Brown
2016-06-16 16:17         ` Sylwester Nawrocki
2016-06-13 10:52 ` [PATCH RFC 4/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
2016-06-13 15:32   ` Mark Brown
2016-06-14 15:14     ` Sylwester Nawrocki
2016-06-15  9:25       ` Mark Brown
2016-06-16 11:31   ` Krzysztof Kozlowski
2016-06-13 10:52 ` [PATCH RFC 5/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board Sylwester Nawrocki
2016-06-13 10:52 ` [PATCH RFC 6/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
2016-06-14 23:32   ` Rob Herring
2016-06-15  9:47     ` Mark Brown
2016-06-20 17:49       ` Rob Herring
2016-06-21  9:48         ` Sylwester Nawrocki
2016-06-15  9:40   ` Lars-Peter Clausen
2016-06-16 16:39     ` [alsa-devel] " Sylwester Nawrocki
2016-06-16 16:45       ` Lars-Peter Clausen
2016-06-17 11:08         ` [alsa-devel] " Sylwester Nawrocki
2016-06-16 11:33   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).