All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Sound support for Exynos5433 TM2(E) boards
@ 2016-06-23 10:45 Sylwester Nawrocki
       [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-23 10:45 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Sylwester Nawrocki

This patch series adds sound supoort for the Exynos 5433 based TM2 and
TM2E board.  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.
The changes are listed in individual patches, there were only v1 3/6,
4/6 patches (max98504), for others I skipped from RFC to v2.

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: Add DT bindings documentation for max98504 amplifier
  ASoC: max98504: Add max98504 speaker amplifier driver
  ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem

 .../devicetree/bindings/sound/max98504.txt         |  26 +
 .../bindings/sound/samsung,exynos5433-lpass.txt    |   8 +
 .../bindings/sound/samsung,tm2-audio.txt           |  36 ++
 sound/soc/codecs/Kconfig                           |   4 +
 sound/soc/codecs/Makefile                          |   2 +
 sound/soc/codecs/max98504.c                        | 356 +++++++++++++
 sound/soc/codecs/max98504.h                        |  76 +++
 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                     | 579 +++++++++++++++++++++
 12 files changed, 1313 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-audio.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

--
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] 21+ messages in thread

* [PATCH v2 1/6] ASoC: samsung: Add DT bindings documentation for LPASS
       [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-23 10:45   ` Sylwester Nawrocki
  2016-06-23 10:45   ` [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-23 10:45 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, 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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Krzysztof Kozlowski <k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
 .../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

--
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 related	[flat|nested] 21+ messages in thread

* [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
       [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2016-06-23 10:45   ` [PATCH v2 1/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
@ 2016-06-23 10:45   ` Sylwester Nawrocki
       [not found]     ` <1466678715-19962-3-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2016-06-23 10:45   ` [PATCH v2 3/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-23 10:45 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Beomho Seo,
	Sylwester Nawrocki

From: Inha Song <ideal.song-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Beomho Seo <beomho.seo-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Acked-by: Krzysztof Kozlowski <k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
Changes since initial version:
 - none.
---
 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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
+ *
+ * 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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>");
+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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
+ *
+ * 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

--
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 related	[flat|nested] 21+ messages in thread

* [PATCH v2 3/6] ASoC: Add DT bindings documentation for max98504 amplifier
       [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2016-06-23 10:45   ` [PATCH v2 1/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
  2016-06-23 10:45   ` [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
@ 2016-06-23 10:45   ` Sylwester Nawrocki
       [not found]     ` <1466678715-19962-4-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2016-06-23 10:45   ` [PATCH v2 4/6] ASoC: max98504: Add max98504 speaker amplifier driver Sylwester Nawrocki
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-23 10:45 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Sylwester Nawrocki

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

Signed-off-by: Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
Changes since v1:
 - added 'interrupts' property.
---
 .../devicetree/bindings/sound/max98504.txt         | 26 ++++++++++++++++++++++
 1 file changed, 26 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..254c92e
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/max98504.txt
@@ -0,0 +1,26 @@
+Maxim MAX98504 class D mono speaker amplifier
+
+This device supports I2C control interface and an IRQ output signal. It features
+a PCM and PDM digital audio interface (DAI) and a differential analog input.
+
+Required properties:
+
+ - compatible : "maxim,max98504"
+ - reg : should contain the I2C slave device address
+ - DVDD-supply, DIOVDD-supply, PVDD-supply: power supplies for the device,
+   as covered in ../regulator/regulator.txt
+ - interrupts : should specify the interrupt the device is connected to,
+   as described in ../interrupt-controller/interrupts.txt
+
+Example:
+
+ max98504@31 {
+	compatible = "maxim,max98504";
+	reg = <0x31>;
+	interrupt-parent = <&gpio_bank_0>;
+	interrupts = <2 0>;
+
+	DVDD-supply = <&regulator>;
+	DIOVDD-supply = <&regulator>;
+	PVDD-supply = <&regulator>;
+};
-- 
1.9.1

--
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 related	[flat|nested] 21+ messages in thread

* [PATCH v2 4/6] ASoC: max98504: Add max98504 speaker amplifier driver
       [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-06-23 10:45   ` [PATCH v2 3/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
@ 2016-06-23 10:45   ` Sylwester Nawrocki
       [not found]     ` <1466678715-19962-5-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2016-06-23 10:45   ` [PATCH v2 5/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
  2016-06-23 10:45   ` [PATCH v2 6/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board Sylwester Nawrocki
  5 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-23 10:45 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Sylwester Nawrocki,
	Krzysztof Kozlowski

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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
[k.kozlowski: rebased on 4.1]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
[s.nawrocki: removed unused macro definitions, rewrote regulator supply
 related parts, rewrote regmap configuration code, added support for speaker
 enable and global chip enable through DAPM, rewritten as component driver,
 added PDM DAI definition and TDM callbacks for PDM channels configuration]
Signed-off-by: Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
Changes since initial version:
 - added regulator supply handling,
 - added DAPM widges for speaker source selection,
 - added PDM DAI definition and TDM callbacks for setting up active
   PDM Tx channels and I/V sense ADC data mapping,
 - removed all optional DT properties, added regulator supply properties
   in the DT binding.
Changes since v1:
 - coding style fixes.

---
 sound/soc/codecs/Kconfig    |   4 +
 sound/soc/codecs/Makefile   |   2 +
 sound/soc/codecs/max98504.c | 356 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/max98504.h |  76 ++++++++++
 4 files changed, 438 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 60f8f13..597d51d3 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..972fa4c
--- /dev/null
+++ b/sound/soc/codecs/max98504.c
@@ -0,0 +1,356 @@
+/*
+ * 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/delay.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+#include <sound/soc.h>
+
+#include "max98504.h"
+
+static const char * const max98504_supply_names[] = {
+	"DVDD",
+	"DIOVDD",
+	"PVDD",
+};
+#define MAX98504_NUM_SUPPLIES ARRAY_SIZE(max98504_supply_names)
+
+struct max98504_priv {
+	struct regmap *regmap;
+	struct regulator_bulk_data supplies[MAX98504_NUM_SUPPLIES];
+	unsigned int pcm_rx_channels;
+};
+
+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_pcm_rx_ev(struct snd_soc_dapm_widget *w,
+			      struct snd_kcontrol *kcontrol, int event)
+{
+	struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm);
+	struct max98504_priv *max98504 = snd_soc_component_get_drvdata(c);
+
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		regmap_write(max98504->regmap, MAX98504_REG_PCM_RX_ENABLE,
+			     max98504->pcm_rx_channels);
+		break;
+	case SND_SOC_DAPM_POST_PMD:
+		regmap_write(max98504->regmap, MAX98504_REG_PCM_RX_ENABLE, 0);
+		break;
+	}
+
+	return 0;
+}
+
+static int max98504_component_probe(struct snd_soc_component *c)
+{
+	struct max98504_priv *max98504 = snd_soc_component_get_drvdata(c);
+	struct regmap *map = max98504->regmap;
+	int ret;
+
+	ret = regulator_bulk_enable(MAX98504_NUM_SUPPLIES, max98504->supplies);
+	if (ret < 0)
+		return ret;
+
+	regmap_write(map, MAX98504_REG_SOFTWARE_RESET, 0x1);
+
+	msleep(20);
+
+	/* Select analog input by default */
+	regmap_write(map, MAX98504_REG_SPEAKER_SOURCE_SELECT, 0x1);
+	/* Brownout protection enable */
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_ENABLE, 0x1);
+	/* Threshold 2.9V, 3dB speaker attenuation*/
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(1), 0x33);
+	/* Attack hold time 10 ms */
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(2), 0x0a);
+	/* Brownout hold time 255 ms, brownout release time 255 ms */
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(3), 0xff);
+	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(4), 0xff);
+
+	return 0;
+}
+
+static void max98504_component_remove(struct snd_soc_component *c)
+{
+	struct max98504_priv *max98504 = snd_soc_component_get_drvdata(c);
+
+	regulator_bulk_disable(MAX98504_NUM_SUPPLIES, max98504->supplies);
+}
+
+static const char *spk_source_mux_text[] = {
+	"PCM Monomix", "Analog In", "PDM Left", "PDM Right"
+};
+
+static const struct soc_enum spk_source_mux_enum =
+	SOC_ENUM_SINGLE(MAX98504_REG_SPEAKER_SOURCE_SELECT,
+			0, ARRAY_SIZE(spk_source_mux_text),
+			spk_source_mux_text);
+
+static const struct snd_kcontrol_new spk_source_mux =
+	SOC_DAPM_ENUM("SPK Source", spk_source_mux_enum);
+
+static const struct snd_soc_dapm_route max98504_dapm_routes[] = {
+	{ "SPKOUT", NULL, "Global Enable" },
+	{ "SPK Source", "PCM Monomix", "DAC PCM" },
+	{ "SPK Source", "Analog In", "AIN" },
+	{ "SPK Source", "PDM Left", "DAC PDM" },
+	{ "SPK Source", "PDM Right", "DAC PDM" },
+};
+
+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_INPUT("AIN"),
+	SND_SOC_DAPM_AIF_OUT("AIF2OUTL", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("AIF2OUTR", "AIF2 Capture", 1, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_DAC_E("DAC PCM", NULL, SND_SOC_NOPM, 0, 0,
+		max98504_pcm_rx_ev,
+		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+	SND_SOC_DAPM_DAC("DAC PDM", NULL, MAX98504_REG_PDM_RX_ENABLE, 0, 0),
+	SND_SOC_DAPM_MUX("SPK Source", SND_SOC_NOPM, 0, 0, &spk_source_mux),
+	SND_SOC_DAPM_REG(snd_soc_dapm_spk, "SPKOUT",
+		MAX98504_REG_SPEAKER_ENABLE, 0, 1, 1, 0),
+};
+
+static int max98504_set_tdm_slot(struct snd_soc_dai *dai,
+		unsigned int tx_mask, unsigned int rx_mask,
+		int slots, int slot_width)
+{
+	struct max98504_priv *max98504 = snd_soc_dai_get_drvdata(dai);
+	struct regmap *map = max98504->regmap;
+
+
+	switch (dai->id) {
+	case MAX98504_DAI_ID_PCM:
+		regmap_write(map, MAX98504_REG_PCM_TX_ENABLE, tx_mask);
+		max98504->pcm_rx_channels = rx_mask;
+		break;
+
+	case MAX98504_DAI_ID_PDM:
+		regmap_write(map, MAX98504_REG_PDM_TX_ENABLE, tx_mask);
+		break;
+	default:
+		WARN_ON(1);
+	}
+
+	return 0;
+}
+static int max98504_set_channel_map(struct snd_soc_dai *dai,
+		unsigned int tx_num, unsigned int *tx_slot,
+		unsigned int rx_num, unsigned int *rx_slot)
+{
+	struct max98504_priv *max98504 = snd_soc_dai_get_drvdata(dai);
+	struct regmap *map = max98504->regmap;
+	unsigned int i, sources = 0;
+
+	for (i = 0; i < tx_num; i++)
+		if (tx_slot[i])
+			sources |= (1 << i);
+
+	switch (dai->id) {
+	case MAX98504_DAI_ID_PCM:
+		regmap_write(map, MAX98504_REG_PCM_TX_CHANNEL_SOURCES,
+			     sources);
+		break;
+
+	case MAX98504_DAI_ID_PDM:
+		regmap_write(map, MAX98504_REG_PDM_TX_CONTROL, sources);
+		break;
+	default:
+		WARN_ON(1);
+	}
+
+	regmap_write(map, MAX98504_REG_MEASUREMENT_ENABLE,
+		     sources ? 0x3 : 0x01);
+
+	return 0;
+}
+
+static const struct snd_soc_dai_ops max98504_dai_ops = {
+	.set_tdm_slot		= max98504_set_tdm_slot,
+	.set_channel_map	= max98504_set_channel_map,
+};
+
+#define MAX98504_FORMATS	(SNDRV_PCM_FMTBIT_S8|SNDRV_PCM_FMTBIT_S16_LE|\
+				SNDRV_PCM_FMTBIT_S24_LE|SNDRV_PCM_FMTBIT_S32_LE)
+#define MAX98504_PDM_RATES	(SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|\
+				SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_44100|\
+				SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_88200|\
+				SNDRV_PCM_RATE_96000)
+
+static struct snd_soc_dai_driver max98504_dai[] = {
+	/* TODO: Add the PCM interface definitions */
+	{
+		.name = "max98504-aif2",
+		.id = MAX98504_DAI_ID_PDM,
+		.playback = {
+			.stream_name	= "AIF2 Playback",
+			.channels_min	= 1,
+			.channels_max	= 2,
+			.rates		= MAX98504_PDM_RATES,
+			.formats	= MAX98504_FORMATS,
+		},
+		.capture = {
+			.stream_name	= "AIF2 Capture",
+			.channels_min	= 1,
+			.channels_max	= 2,
+			.rates		= MAX98504_PDM_RATES,
+			.formats	= MAX98504_FORMATS,
+		},
+		.ops = &max98504_dai_ops,
+	},
+};
+
+static const struct snd_soc_component_driver max98504_component_driver = {
+	.probe			= max98504_component_probe,
+	.remove			= max98504_component_remove,
+	.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 int max98504_i2c_probe(struct i2c_client *client,
+			      const struct i2c_device_id *id)
+{
+	struct device *dev = &client->dev;
+	struct max98504_priv *max98504;
+	int i, ret;
+
+	max98504 = devm_kzalloc(dev, sizeof(*max98504), GFP_KERNEL);
+	if (!max98504)
+		return -ENOMEM;
+
+	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;
+	}
+
+	for (i = 0; i < MAX98504_NUM_SUPPLIES; i++)
+		max98504->supplies[i].supply = max98504_supply_names[i];
+
+	ret = devm_regulator_bulk_get(dev, MAX98504_NUM_SUPPLIES,
+				      max98504->supplies);
+	if (ret < 0)
+		return ret;
+
+	i2c_set_clientdata(client, max98504);
+
+	return devm_snd_soc_register_component(dev, &max98504_component_driver,
+				max98504_dai, ARRAY_SIZE(max98504_dai));
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id max98504_of_match[] = {
+	{ .compatible = "maxim,max98504" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, max98504_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..d761f25
--- /dev/null
+++ b/sound/soc/codecs/max98504.h
@@ -0,0 +1,76 @@
+/*
+ * 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)
+
+#define MAX98504_DAI_ID_PCM			1
+#define MAX98504_DAI_ID_PDM			2
+
+#endif /* MAX98504_H_ */
--
1.9.1

--
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 related	[flat|nested] 21+ messages in thread

* [PATCH v2 5/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
       [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
                     ` (3 preceding siblings ...)
  2016-06-23 10:45   ` [PATCH v2 4/6] ASoC: max98504: Add max98504 speaker amplifier driver Sylwester Nawrocki
@ 2016-06-23 10:45   ` Sylwester Nawrocki
       [not found]     ` <1466678715-19962-6-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2016-06-23 10:45   ` [PATCH v2 6/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board Sylwester Nawrocki
  5 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-23 10:45 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Sylwester Nawrocki

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

Signed-off-by: Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
Changes since initial version:
 - dropped clocks, clock-names properties, instead properties from
   the CODEC node will be used,
 - property renames: 'samsung,model' -> 'model', 'samsung,i2s-controller'
   -> 'i2s-controller', 'samsung,speaker-amplifier' -> 'audio-amplifier',
 - added 'audio-codec' property.
---
 .../bindings/sound/samsung,tm2-audio.txt           | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt

diff --git a/Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt b/Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt
new file mode 100644
index 0000000..3ae56f3
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt
@@ -0,0 +1,36 @@
+Samsung Exynos5433 TM2(E) audio complex with WM5110 codec
+
+Required properties:
+
+ - compatible : "samsung,tm2-audio"
+ - model : the user-visible name of this sound complex
+ - audio-codec: the phandle of the wm5110 audio codec node,
+   as described in Documentation/devicetree/bindings/mfd/arizona.txt
+ - i2s-controller : the phandle of the I2S controller
+ - audio-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";
+	audio-codec = <&wm5110>;
+	i2s-controller = <&i2s0>;
+	audio-amplifier = <&max98504>;
+	mic-bias-gpios = <&gpr3 2 0>;
+	model = "wm5110";
+	samsung,audio-routing =
+		"HP", "HPOUT1L",
+		"HP", "HPOUT1R",
+		"SPK", "SPKOUT",
+		"SPKOUT", "HPOUT2L",
+		"SPKOUT", "HPOUT2R",
+		"Main Mic", "MICBIAS2",
+		"IN1R", "Main Mic";
+};
-- 
1.9.1

--
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 related	[flat|nested] 21+ messages in thread

* [PATCH v2 6/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board
       [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
                     ` (4 preceding siblings ...)
  2016-06-23 10:45   ` [PATCH v2 5/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
@ 2016-06-23 10:45   ` Sylwester Nawrocki
  5 siblings, 0 replies; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-23 10:45 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Krzysztof Kozlowski,
	Sylwester Nawrocki

From: Inha Song <ideal.song-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

This patch adds the sound machine driver for TM2 and TM2E board.
Speaker and headphone playback, Main Mic capture, Bluetooth,
Voice call and external accessory are supported.

Signed-off-by: Inha Song <ideal.song-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
[k.kozlowski: rebased on 4.1]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
[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 "audio-amplifiers" and "audio-codecs"
 properties, added TDM API calls, switched to gpiod API]
Signed-off-by: Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
Changes since initial version:
 - added PDM Tx channels setup through TDM API
 - adaptation to renamed 'samsung,model', 'samsung,i2s-controller',
   'samsung,speaker-amplifier' properties,
 - removed some dev_dbg() calls,
 - cleaned up mic-bias GPIO handling and switched to gpiod API,
 - added parsing of 'audio-codec' property,
 - initialized codec_of_node of dai_link instead of codec_name,
 - switched to using clock, clock-names properties from the wm5110
   codec node,
 - fixed error paths in probe() (of_node reference counting).
---
 sound/soc/samsung/Kconfig      |  13 +
 sound/soc/samsung/Makefile     |   2 +
 sound/soc/samsung/tm2_wm5110.c | 579 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 594 insertions(+)
 create mode 100644 sound/soc/samsung/tm2_wm5110.c

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 7b722b0..e002204 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_MAX98504
+	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..9728b3c
--- /dev/null
+++ b/sound/soc/samsung/tm2_wm5110.c
@@ -0,0 +1,579 @@
+/*
+ * Copyright (C) 2015 - 2016 Samsung Electronics Co., Ltd.
+ *
+ * Authors: Inha Song <ideal.song-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
+ *          Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
+ *
+ * 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/clk.h>
+#include <linux/gpio.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
+#include "i2s.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;
+
+	struct gpio_desc *gpio_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;
+
+	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;
+
+	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:
+		gpiod_set_value_cansleep(priv->gpio_mic_bias,  1);
+		break;
+	case SND_SOC_DAPM_POST_PMD:
+		gpiod_set_value_cansleep(priv->gpio_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;
+
+	return 0;
+}
+
+static struct snd_soc_aux_dev tm2_speaker_amp_dev;
+
+static int tm2_late_probe(struct snd_soc_card *card)
+{
+	struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card);
+	struct snd_soc_dai_link_component dlc = { 0 };
+	struct snd_soc_dai *amp_pdm_dai;
+	struct snd_soc_pcm_runtime *rtd;
+	unsigned int ch_map[] = { 0, 1 };
+	int ret;
+
+	rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+	priv->codec = rtd->codec;
+
+	/* 32 kHz must be enabled for jack detection */
+	if (!IS_ERR(priv->codec_mclk2))
+		clk_prepare_enable(priv->codec_mclk2);
+
+	dlc.of_node = tm2_speaker_amp_dev.codec_of_node;
+	amp_pdm_dai = snd_soc_find_dai(&dlc);
+	if (!amp_pdm_dai)
+		return -ENODEV;
+
+	/* Set the MAX98504 V/I sense PDM Tx DAI channel mapping */
+	ret = snd_soc_dai_set_channel_map(amp_pdm_dai, ARRAY_SIZE(ch_map),
+					  ch_map, 0, NULL);
+	if (ret < 0)
+		return ret;
+
+	ret = snd_soc_dai_set_tdm_slot(amp_pdm_dai, 0x3, 0x0, 2, 16);
+	if (ret < 0)
+		return ret;
+
+	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 tm2_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 tm2_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 tm2_dai_links[] = {
+	{
+		.name		= "WM5110 AIF1",
+		.stream_name	= "HiFi Primary",
+		.codec_dai_name = "wm5110-aif1",
+		.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",
+		.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",
+		.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBM_CFM,
+		.ignore_suspend = 1,
+	}
+};
+
+static struct snd_soc_card tm2_card = {
+	.owner			= THIS_MODULE,
+
+	.dai_link		= tm2_dai_links,
+	.num_links		= ARRAY_SIZE(tm2_dai_links),
+	.controls		= tm2_controls,
+	.num_controls		= ARRAY_SIZE(tm2_controls),
+	.dapm_widgets		= tm2_dapm_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(tm2_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_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct snd_soc_card *card = &tm2_card;
+	struct tm2_machine_priv *priv;
+	struct device_node *cpu_dai_node, *codec_dai_node;
+	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;
+
+	priv->gpio_mic_bias = devm_gpiod_get(dev, "mic-bias",
+						GPIOF_OUT_INIT_LOW);
+	if (IS_ERR(priv->gpio_mic_bias)) {
+		dev_err(dev, "Failed to get mic bias gpio\n");
+		return PTR_ERR(priv->gpio_mic_bias);
+	}
+
+	ret = snd_soc_of_parse_card_name(card, "model");
+	if (ret < 0) {
+		dev_err(dev, "Card name is not specified\n");
+		return ret;
+	}
+
+	ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
+	if (ret < 0) {
+		dev_err(dev, "Audio routing is not specified or invalid\n");
+		return ret;
+	}
+
+	card->aux_dev[0].codec_of_node = of_parse_phandle(dev->of_node,
+							"audio-amplifier", 0);
+	if (!card->aux_dev[0].codec_of_node) {
+		dev_err(dev, "audio-amplifier property invalid or missing\n");
+		return -EINVAL;
+	}
+
+	cpu_dai_node = of_parse_phandle(dev->of_node, "i2s-controller", 0);
+	if (!cpu_dai_node) {
+		dev_err(dev, "i2s-controllers property invalid or missing\n");
+		ret = -EINVAL;
+		goto err_put_amp;
+	}
+
+	codec_dai_node = of_parse_phandle(dev->of_node, "audio-codec", 0);
+	if (!codec_dai_node) {
+		dev_err(dev, "audio-codec property invalid or missing\n");
+		ret = -EINVAL;
+		goto err_put_cpu_dai;
+	}
+
+	for (i = 0; i < card->num_links; i++) {
+		card->dai_link[i].cpu_dai_name = NULL;
+		card->dai_link[i].cpu_name = NULL;
+		card->dai_link[i].platform_name = NULL;
+		card->dai_link[i].codec_of_node = codec_dai_node;
+		card->dai_link[i].cpu_of_node = cpu_dai_node;
+		card->dai_link[i].platform_of_node = cpu_dai_node;
+	}
+
+	priv->codec_mclk1 = of_clk_get_by_name(codec_dai_node, "mclk1");
+	if (IS_ERR(priv->codec_mclk1)) {
+		dev_err(dev, "Failed to get mclk1 clock\n");
+		ret = PTR_ERR(priv->codec_mclk1);
+		goto err_put_codec_dai;
+	}
+
+	/* mclk2 is optional */
+	priv->codec_mclk2 = of_clk_get_by_name(codec_dai_node, "mclk2");
+	if (IS_ERR(priv->codec_mclk2))
+		dev_info(dev, "Not using mclk2 clock\n");
+
+	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);
+		goto err_put_mclk;
+	}
+
+	ret = devm_snd_soc_register_card(dev, card);
+	if (ret < 0) {
+		dev_err(dev, "Failed to register card: %d\n", ret);
+		goto err_put_mclk;
+	}
+
+	return 0;
+
+err_put_mclk:
+	clk_put(priv->codec_mclk1);
+	if (!IS_ERR(priv->codec_mclk2))
+		clk_put(priv->codec_mclk2);
+err_put_codec_dai:
+	of_node_put(codec_dai_node);
+err_put_cpu_dai:
+	of_node_put(cpu_dai_node);
+err_put_amp:
+	of_node_put(card->aux_dev[0].codec_of_node);
+	return ret;
+}
+
+static int tm2_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = &tm2_card;
+	struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card);
+
+	clk_put(priv->codec_mclk1);
+	if (!IS_ERR(priv->codec_mclk2))
+		clk_put(priv->codec_mclk2);
+
+	of_node_put(card->dai_link[0].codec_of_node);
+	of_node_put(card->dai_link[0].cpu_of_node);
+	of_node_put(card->aux_dev[0].codec_of_node);
+
+	return 0;
+}
+
+static const struct of_device_id tm2_of_match[] = {
+	{ .compatible = "samsung,tm2-audio" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, tm2_of_match);
+
+static struct platform_driver tm2_driver = {
+	.driver = {
+		.name		= "tm2-audio",
+		.pm		= &snd_soc_pm_ops,
+		.of_match_table	= tm2_of_match,
+	},
+	.probe	= tm2_probe,
+	.remove	= tm2_remove,
+};
+
+module_platform_driver(tm2_driver);
+
+MODULE_AUTHOR("Inha Song <ideal.song-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>");
+MODULE_DESCRIPTION("ALSA SoC Exynos TM2 Audio Support");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

--
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 related	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 4/6] ASoC: max98504: Add max98504 speaker amplifier driver
       [not found]     ` <1466678715-19962-5-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-27 16:33       ` Mark Brown
  2016-06-28 17:59         ` Sylwester Nawrocki
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Brown @ 2016-06-27 16:33 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Krzysztof Kozlowski

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

On Thu, Jun 23, 2016 at 12:45:13PM +0200, Sylwester Nawrocki wrote:

> +	/* Select analog input by default */
> +	regmap_write(map, MAX98504_REG_SPEAKER_SOURCE_SELECT, 0x1);

This should be done by userspace configuration, just leave the chip at
power on defaults.  This is policy so that we don't have people trying
to patch their configurations into the kernel.

> +	/* Brownout protection enable */
> +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_ENABLE, 0x1);
> +	/* Threshold 2.9V, 3dB speaker attenuation*/
> +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(1), 0x33);
> +	/* Attack hold time 10 ms */
> +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(2), 0x0a);
> +	/* Brownout hold time 255 ms, brownout release time 255 ms */
> +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(3), 0xff);
> +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(4), 0xff);

Should these be DT properties?

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

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

* Re: [PATCH v2 4/6] ASoC: max98504: Add max98504 speaker amplifier driver
  2016-06-27 16:33       ` Mark Brown
@ 2016-06-28 17:59         ` Sylwester Nawrocki
       [not found]           ` <5772BB07.4000609-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-28 17:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: robh, alsa-devel, devicetree, b.zolnierkie, Krzysztof Kozlowski,
	inki.dae, ideal.song

On 06/27/2016 06:33 PM, Mark Brown wrote:
> On Thu, Jun 23, 2016 at 12:45:13PM +0200, Sylwester Nawrocki wrote:
> 
>> > +	/* Select analog input by default */
>> > +	regmap_write(map, MAX98504_REG_SPEAKER_SOURCE_SELECT, 0x1);
>
> This should be done by userspace configuration, just leave the chip at
> power on defaults.  This is policy so that we don't have people trying
> to patch their configurations into the kernel.

OK, I will remove this and update the UCM configuration files instead.

>> > +	/* Brownout protection enable */
>> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_ENABLE, 0x1);
>> > +	/* Threshold 2.9V, 3dB speaker attenuation*/
>> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(1), 0x33);
>> > +	/* Attack hold time 10 ms */
>> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(2), 0x0a);
>> > +	/* Brownout hold time 255 ms, brownout release time 255 ms */
>> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(3), 0xff);
>> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(4), 0xff);
>
> Should these be DT properties?

I'm not sure, these properties define the speaker gain decrease pattern
during VBAT brownout, it seems a system integration detail and will most
likely differ from board to board.  I'd assume it's acceptable to put
these in DT, looking at other bindings.  I've prepared something like
this:

------8<--------
Optional properties:

- maxim,brownout-threshold - the VBAT brownout threshold, the value must be
  from 0, 1...21 range, corresponding to 2.6V, 2.65V...3.65V voltage range
- maxim,brownout-attenuation - the brownout attenuation to the speaker gain
  applied during the "attack hold" and "timed hold" phase, the value must be
  from 0...6 (dB) range
- maxim,brownout-attack-hold-ms - the brownout attack hold phase time in ms,
  0...255 (VBATBROWN_ATTK_HOLD, register 0x0018)
- maxim,brownout-timed-hold-ms - the brownout timed hold phase time in ms,
  0...255 (VBATBROWN_TIME_HOLD, register 0x0019)
- maxim,brownout-release-rate-ms - the brownout release phase step time in ms,
  0...255 (VBATBROWN_RELEASE, register 0x001A)

The default value when the above properties are not specified is 0,
the maxim,brownout-level property must be specified to actually enable
the VBAT brownout protection.
------8<--------

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

* Re: [alsa-devel] [PATCH v2 4/6] ASoC: max98504: Add max98504 speaker amplifier driver
       [not found]           ` <5772BB07.4000609-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-28 19:31             ` Mark Brown
  0 siblings, 0 replies; 21+ messages in thread
From: Mark Brown @ 2016-06-28 19:31 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Krzysztof Kozlowski,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ

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

On Tue, Jun 28, 2016 at 07:59:35PM +0200, Sylwester Nawrocki wrote:
> On 06/27/2016 06:33 PM, Mark Brown wrote:
> > On Thu, Jun 23, 2016 at 12:45:13PM +0200, Sylwester Nawrocki wrote:

> >> > +	/* Brownout protection enable */
> >> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_ENABLE, 0x1);
> >> > +	/* Threshold 2.9V, 3dB speaker attenuation*/
> >> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(1), 0x33);
> >> > +	/* Attack hold time 10 ms */
> >> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(2), 0x0a);
> >> > +	/* Brownout hold time 255 ms, brownout release time 255 ms */
> >> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(3), 0xff);
> >> > +	regmap_write(map, MAX98504_REG_PVDD_BROWNOUT_CONFIG(4), 0xff);

> > Should these be DT properties?

> I'm not sure, these properties define the speaker gain decrease pattern
> during VBAT brownout, it seems a system integration detail and will most
> likely differ from board to board.  I'd assume it's acceptable to put
> these in DT, looking at other bindings.  I've prepared something like
> this:

Exactly, yes - it depends on the characteristics of the speaker which is
hardware.  Your proposals look OK.

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

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

* Re: [PATCH v2 3/6] ASoC: Add DT bindings documentation for max98504 amplifier
       [not found]     ` <1466678715-19962-4-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-28 20:55       ` Rob Herring
  0 siblings, 0 replies; 21+ messages in thread
From: Rob Herring @ 2016-06-28 20:55 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ

On Thu, Jun 23, 2016 at 12:45:12PM +0200, Sylwester Nawrocki wrote:
> This patch adds DT bindings documentation for Maxim MAX98504
> speaker amplifier.
> 
> Signed-off-by: Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---
> Changes since v1:
>  - added 'interrupts' property.
> ---
>  .../devicetree/bindings/sound/max98504.txt         | 26 ++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/max98504.txt

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
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] 21+ messages in thread

* Re: [PATCH v2 5/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem
       [not found]     ` <1466678715-19962-6-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-28 20:55       ` Rob Herring
  0 siblings, 0 replies; 21+ messages in thread
From: Rob Herring @ 2016-06-28 20:55 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ

On Thu, Jun 23, 2016 at 12:45:14PM +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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---
> Changes since initial version:
>  - dropped clocks, clock-names properties, instead properties from
>    the CODEC node will be used,
>  - property renames: 'samsung,model' -> 'model', 'samsung,i2s-controller'
>    -> 'i2s-controller', 'samsung,speaker-amplifier' -> 'audio-amplifier',
>  - added 'audio-codec' property.
> ---
>  .../bindings/sound/samsung,tm2-audio.txt           | 36 ++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
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] 21+ messages in thread

* Re: [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
       [not found]     ` <1466678715-19962-3-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-29 21:57       ` Mark Brown
  2016-06-30 17:16         ` Sylwester Nawrocki
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Brown @ 2016-06-29 21:57 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ, Beomho Seo

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

On Thu, Jun 23, 2016 at 12:45:11PM +0200, Sylwester Nawrocki wrote:
> From: Inha Song <ideal.song-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> 
> 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.

This is so trivial that I'm wondering why you even need it, it does
essentially nothing except for manage power on and off, and that isn't
synced up with the rest of the audio subsystem in any discernable way.
Previous Samsung SoCs have quite happily ignored their LPASS subsystems
in mainline.  As things stand I'm concerned that systems may get broken
if more functionality is added without the joining up with the rest of
the audio hardware via a card, there's not even the hooks which would
allow that.

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

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

* Re: [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
  2016-06-29 21:57       ` Mark Brown
@ 2016-06-30 17:16         ` Sylwester Nawrocki
       [not found]           ` <577553FE.6080803-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2016-07-01 15:07           ` Mark Brown
  0 siblings, 2 replies; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-06-30 17:16 UTC (permalink / raw)
  To: Mark Brown
  Cc: robh, alsa-devel, devicetree, b.zolnierkie, inki.dae, Beomho Seo,
	ideal.song

On 06/29/2016 11:57 PM, Mark Brown wrote:
> On Thu, Jun 23, 2016 at 12:45:11PM +0200, Sylwester Nawrocki wrote:
...
>> > 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.
>
> This is so trivial that I'm wondering why you even need it, it does
> essentially nothing except for manage power on and off, and that isn't
> synced up with the rest of the audio subsystem in any discernable way.
> Previous Samsung SoCs have quite happily ignored their LPASS subsystems
> in mainline.  As things stand I'm concerned that systems may get broken
> if more functionality is added without the joining up with the rest of
> the audio hardware via a card, there's not even the hooks which would
> allow that.

Sorry, I didn't notice this e-mail earlier.  With previous Exynos versions
the LPASS (or AudioSS) was mainly about the embedded audio DSP processor
(at least WRT to SFRs), which was not required for boards supported in 
the mainline kernel. Since e.g. Exynos5433 the LPASS SFR region contains 
also entries related to other IP blocks, like I2S or DMAC.  Even though 
functionality covered by these registers is still rather trivial, like 
SW resets and unmasking interrupts, it's essential for the whole audio 
subsystem operation. The intention was to have in future the LPASS driver 
covering any functionality provided by the embedded audio dedicated MCU.
I'm afraid we have to handle those power sequences in central place to
ensure proper SoC operation. I would also rather avoid adding any exynos 
quirks to the PL330 DMAC driver. 

I agree this driver is currently detached from the rest, while it would
be good at the card to ensure the required resources are prepared.
How about making LPASS registering a component and then adding it at
the card as aux_dev? I would move some parts to the component's probe()
callback and with component's probe_order specified a proper 
initialization sequence could be ensured.

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

* Re: [alsa-devel] [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
       [not found]           ` <577553FE.6080803-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-07-01 10:35             ` Sylwester Nawrocki
  0 siblings, 0 replies; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-07-01 10:35 UTC (permalink / raw)
  To: Mark Brown
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ, Beomho Seo,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ

On 06/30/2016 07:16 PM, Sylwester Nawrocki wrote:
> How about making LPASS registering a component and then adding it at
> the card as aux_dev? I would move some parts to the component's probe()
> callback and with component's probe_order specified a proper 
> initialization sequence could be ensured.

I see now it's not a good idea since aux_devs is meant for something
different.
--
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] 21+ messages in thread

* Re: [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
  2016-06-30 17:16         ` Sylwester Nawrocki
       [not found]           ` <577553FE.6080803-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-07-01 15:07           ` Mark Brown
  2016-07-01 16:31             ` Sylwester Nawrocki
  1 sibling, 1 reply; 21+ messages in thread
From: Mark Brown @ 2016-07-01 15:07 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: robh, alsa-devel, devicetree, b.zolnierkie, inki.dae, Beomho Seo,
	ideal.song


[-- Attachment #1.1: Type: text/plain, Size: 1150 bytes --]

On Thu, Jun 30, 2016 at 07:16:46PM +0200, Sylwester Nawrocki wrote:

> Sorry, I didn't notice this e-mail earlier.  With previous Exynos versions
> the LPASS (or AudioSS) was mainly about the embedded audio DSP processor
> (at least WRT to SFRs), which was not required for boards supported in 
> the mainline kernel. Since e.g. Exynos5433 the LPASS SFR region contains 
> also entries related to other IP blocks, like I2S or DMAC.  Even though 
> functionality covered by these registers is still rather trivial, like 
> SW resets and unmasking interrupts, it's essential for the whole audio 
> subsystem operation. The intention was to have in future the LPASS driver 
> covering any functionality provided by the embedded audio dedicated MCU.
> I'm afraid we have to handle those power sequences in central place to
> ensure proper SoC operation. I would also rather avoid adding any exynos 
> quirks to the PL330 DMAC driver. 

Hrm.  This is sounding a bit like a combination of a power domain and
an interrupt controller, would something like that fit in perhaps?
Depends on how many of these trivial bits there are I think...

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

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
  2016-07-01 15:07           ` Mark Brown
@ 2016-07-01 16:31             ` Sylwester Nawrocki
       [not found]               ` <57769AE5.4050407-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-07-01 16:31 UTC (permalink / raw)
  To: Mark Brown
  Cc: robh, alsa-devel, devicetree, b.zolnierkie, inki.dae, Beomho Seo,
	ideal.song

On 07/01/2016 05:07 PM, Mark Brown wrote:
> On Thu, Jun 30, 2016 at 07:16:46PM +0200, Sylwester Nawrocki wrote:
> 
>> > Sorry, I didn't notice this e-mail earlier.  With previous Exynos versions
>> > the LPASS (or AudioSS) was mainly about the embedded audio DSP processor
>> > (at least WRT to SFRs), which was not required for boards supported in 
>> > the mainline kernel. Since e.g. Exynos5433 the LPASS SFR region contains 
>> > also entries related to other IP blocks, like I2S or DMAC.  Even though 
>> > functionality covered by these registers is still rather trivial, like 
>> > SW resets and unmasking interrupts, it's essential for the whole audio 
>> > subsystem operation. The intention was to have in future the LPASS driver 
>> > covering any functionality provided by the embedded audio dedicated MCU.
>> > I'm afraid we have to handle those power sequences in central place to
>> > ensure proper SoC operation. I would also rather avoid adding any exynos 
>> > quirks to the PL330 DMAC driver.
>
> Hrm.  This is sounding a bit like a combination of a power domain and
> an interrupt controller, would something like that fit in perhaps?
> Depends on how many of these trivial bits there are I think...

To me LPASS is somehow similar to the camera subsystem, it's a container/
manager for all the audio related sub-IP blocks.  The LPASS (top) SFR 
region contains bits for resetting sub-blocks like: DMAC, SRAM, TIMER, WDT,
I2S, UART.  It also contains mask and status bits of interrupts from those
IP blocks to the CPU or the embedded MCU (CA5). An (incomplete) list of 
registers can be seen at [1]. There are also entries for software triggered
interrupts to the CPU/MCU, for the MCU reset vector control and general 
purpose register for CPU/MCU communication.

In the SoC there is a dedicated power domain for the whole audio subsystem 
and LPASS also contains a VIC itself. We could try to decompose the LPASS 
top block into various subsystems but I seriously doubt it's a good way
forward. I think LPASS should rather be some top level SoC platform entity.

[1] https://goo.gl/JiYbaZ

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

* Re: [alsa-devel] [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
       [not found]               ` <57769AE5.4050407-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-07-02  8:25                 ` Mark Brown
       [not found]                   ` <20160702082548.GF6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Brown @ 2016-07-02  8:25 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Beomho Seo,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ

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

On Fri, Jul 01, 2016 at 06:31:33PM +0200, Sylwester Nawrocki wrote:

> In the SoC there is a dedicated power domain for the whole audio subsystem 
> and LPASS also contains a VIC itself. We could try to decompose the LPASS 
> top block into various subsystems but I seriously doubt it's a good way
> forward. I think LPASS should rather be some top level SoC platform entity.

So a MFD then?

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

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

* Re: [alsa-devel] [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
       [not found]                   ` <20160702082548.GF6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2016-07-04 16:16                     ` Sylwester Nawrocki
       [not found]                       ` <577A8BF7.8090900-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-07-04 16:16 UTC (permalink / raw)
  To: Mark Brown
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Beomho Seo,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ

On 07/02/2016 10:25 AM, Mark Brown wrote:
> On Fri, Jul 01, 2016 at 06:31:33PM +0200, Sylwester Nawrocki wrote:
> 
>> > In the SoC there is a dedicated power domain for the whole audio subsystem 
>> > and LPASS also contains a VIC itself. We could try to decompose the LPASS 
>> > top block into various subsystems but I seriously doubt it's a good way
>> > forward. I think LPASS should rather be some top level SoC platform entity.
>
> So a MFD then?

It might a best match, however I yet need to figure out what to do with
the PL330 DMAC which is a child of the amba bus.
--
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] 21+ messages in thread

* Re: [alsa-devel] [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
       [not found]                       ` <577A8BF7.8090900-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2016-07-05 14:25                         ` Mark Brown
       [not found]                           ` <20160705142524.GW6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Brown @ 2016-07-05 14:25 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Beomho Seo,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ

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

On Mon, Jul 04, 2016 at 06:16:55PM +0200, Sylwester Nawrocki wrote:
> On 07/02/2016 10:25 AM, Mark Brown wrote:

> > So a MFD then?

> It might a best match, however I yet need to figure out what to do with
> the PL330 DMAC which is a child of the amba bus.

There should be nothing in principle that stops you registering AMBA
devices like MFDs currently register platform devices, or you could
perhaps add platform device registration in the PL330 to let it be
registered with either platform or AMBA?

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

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

* Re: [alsa-devel] [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver
       [not found]                           ` <20160705142524.GW6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2016-07-05 14:58                             ` Sylwester Nawrocki
  0 siblings, 0 replies; 21+ messages in thread
From: Sylwester Nawrocki @ 2016-07-05 14:58 UTC (permalink / raw)
  To: Mark Brown
  Cc: robh-DgEjT+Ai2ygdnm+yROfE0A, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ,
	inki.dae-Sze3O3UU22JBDgjK7y7TUQ, Beomho Seo,
	ideal.song-Sze3O3UU22JBDgjK7y7TUQ

On 07/05/2016 04:25 PM, Mark Brown wrote:
> There should be nothing in principle that stops you registering AMBA
> devices like MFDs currently register platform devices, or you could
> perhaps add platform device registration in the PL330 to let it be
> registered with either platform or AMBA?

As it turned out of_platform_populate() handles properly AMBA devices
by looking at the compatible string. If compatible contains
"arm,primecell" then an amba device instead of a platform device
is created for a DT node.

I used of_platform_populate() instead of mfd_add_devices() in the MFD
driver's probe(). Additionally I had to rearrange exynos5433.dtsi
and to make the LPASS devices specified as sub-nodes of the LPASS node.

It all seems to work fine, I will post v4 so we can continue commenting
on the actual patches.

--
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] 21+ messages in thread

end of thread, other threads:[~2016-07-05 14:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-23 10:45 [PATCH v2 0/6] Sound support for Exynos5433 TM2(E) boards Sylwester Nawrocki
     [not found] ` <1466678715-19962-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-23 10:45   ` [PATCH v2 1/6] ASoC: samsung: Add DT bindings documentation for LPASS Sylwester Nawrocki
2016-06-23 10:45   ` [PATCH v2 2/6] ASoC: samsung: Add Samsung Low Power Audio Subsystem driver Sylwester Nawrocki
     [not found]     ` <1466678715-19962-3-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-29 21:57       ` Mark Brown
2016-06-30 17:16         ` Sylwester Nawrocki
     [not found]           ` <577553FE.6080803-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-07-01 10:35             ` [alsa-devel] " Sylwester Nawrocki
2016-07-01 15:07           ` Mark Brown
2016-07-01 16:31             ` Sylwester Nawrocki
     [not found]               ` <57769AE5.4050407-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-07-02  8:25                 ` [alsa-devel] " Mark Brown
     [not found]                   ` <20160702082548.GF6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-07-04 16:16                     ` Sylwester Nawrocki
     [not found]                       ` <577A8BF7.8090900-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-07-05 14:25                         ` Mark Brown
     [not found]                           ` <20160705142524.GW6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-07-05 14:58                             ` Sylwester Nawrocki
2016-06-23 10:45   ` [PATCH v2 3/6] ASoC: Add DT bindings documentation for max98504 amplifier Sylwester Nawrocki
     [not found]     ` <1466678715-19962-4-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-28 20:55       ` Rob Herring
2016-06-23 10:45   ` [PATCH v2 4/6] ASoC: max98504: Add max98504 speaker amplifier driver Sylwester Nawrocki
     [not found]     ` <1466678715-19962-5-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-27 16:33       ` Mark Brown
2016-06-28 17:59         ` Sylwester Nawrocki
     [not found]           ` <5772BB07.4000609-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-28 19:31             ` [alsa-devel] " Mark Brown
2016-06-23 10:45   ` [PATCH v2 5/6] ASoC: samsung: Add DT bindings documentation for TM2 sound subsystem Sylwester Nawrocki
     [not found]     ` <1466678715-19962-6-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-06-28 20:55       ` Rob Herring
2016-06-23 10:45   ` [PATCH v2 6/6] ASoC: samsung: Add machine driver for Exynos5433 based TM2 board Sylwester Nawrocki

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.