devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mfd: Add SiRF audio MFD driver
@ 2014-03-11  2:36 RongJun Ying
       [not found] ` <1394505387-13665-1-git-send-email-rongjun.ying-kQvG35nSl+M@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: RongJun Ying @ 2014-03-11  2:36 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz
  Cc: Mark Brown, devicetree-u79uwXL29TY76Z2rM5mHXA,
	workgroup.linux-kQvG35nSl+M, Rongjun Ying

From: Rongjun Ying <rongjun.ying-kQvG35nSl+M@public.gmane.org>

This patchset adds SiRF audio MFD driver including:
1. The SiRF audio MFD driver
2. The document of device tree binding

Rongjun Ying (2):
  mfd: Support SiRF audio modules
  Documentation: Describe the SiRF audio Device Tree bindings

 .../devicetree/bindings/mfd/sirf-audio.txt         |   51 ++++++++
 drivers/mfd/Kconfig                                |   10 ++
 drivers/mfd/Makefile                               |    1 +
 drivers/mfd/sirf-audio.c                           |  128 ++++++++++++++++++++
 include/linux/mfd/sirf/audio.h                     |   22 ++++
 5 files changed, 212 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/sirf-audio.txt
 create mode 100644 drivers/mfd/sirf-audio.c
 create mode 100644 include/linux/mfd/sirf/audio.h

-- 
1.7.5.4

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

* [PATCH v2 1/2] mfd: Support SiRF audio modules
       [not found] ` <1394505387-13665-1-git-send-email-rongjun.ying-kQvG35nSl+M@public.gmane.org>
@ 2014-03-11  2:36   ` RongJun Ying
       [not found]     ` <1394505387-13665-2-git-send-email-rongjun.ying-kQvG35nSl+M@public.gmane.org>
  2014-03-11  2:36   ` [PATCH v2 2/2] Documentation: Describe the SiRF audio Device Tree bindings RongJun Ying
  1 sibling, 1 reply; 4+ messages in thread
From: RongJun Ying @ 2014-03-11  2:36 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz
  Cc: Mark Brown, devicetree-u79uwXL29TY76Z2rM5mHXA,
	workgroup.linux-kQvG35nSl+M, Rongjun Ying

From: Rongjun Ying <rongjun.ying-kQvG35nSl+M@public.gmane.org>

The audio modules consist of an internal audio codec, internal
audio port and i2s controller.

These modules sharing same register address space.
sirf-audio.c provides common regmap mmio handling for all audio modules.
The sound drivers will get regmap from sirf audio mfd driver.

Signed-off-by: Rongjun Ying <rongjun.ying-kQvG35nSl+M@public.gmane.org>
---
-v2:
1. Fixed a lot of english syntax error
2. Add "OF" depend
3. Get codec compatible from child node of dts
4. Use a standard header

 drivers/mfd/Kconfig            |   10 +++
 drivers/mfd/Makefile           |    1 +
 drivers/mfd/sirf-audio.c       |  128 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/sirf/audio.h |   22 +++++++
 4 files changed, 161 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/sirf-audio.c
 create mode 100644 include/linux/mfd/sirf/audio.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..d3e79f7 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -546,6 +546,16 @@ config MFD_SI476X_CORE
 	  To compile this driver as a module, choose M here: the
 	  module will be called si476x-core.
 
+config MFD_SIRF_AUDIO
+	tristate "SiRF Audio modules"
+	depends on ARCH_SIRF && OF
+	select MFD_CORE
+	select REGMAP_MMIO
+	help
+	  This is the driver for the SiRF audio modules, which consists of I2S,
+	  internal audio codec, internal audio port and AC97. These modules share
+	  the same address space. So this MFD driver is used to manage the regmap.
+
 config MFD_SM501
 	tristate "Silicon Motion SM501"
 	 ---help---
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..9182170 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -164,3 +164,4 @@ obj-$(CONFIG_MFD_RETU)		+= retu-mfd.o
 obj-$(CONFIG_MFD_AS3711)	+= as3711.o
 obj-$(CONFIG_MFD_AS3722)	+= as3722.o
 obj-$(CONFIG_MFD_STW481X)	+= stw481x.o
+obj-$(CONFIG_MFD_SIRF_AUDIO)	+= sirf-audio.o
diff --git a/drivers/mfd/sirf-audio.c b/drivers/mfd/sirf-audio.c
new file mode 100644
index 0000000..3bcb198
--- /dev/null
+++ b/drivers/mfd/sirf-audio.c
@@ -0,0 +1,128 @@
+/*
+ * airf-audio.c -- Register map share for all SiRF audio modules
+ *
+ * Copyright (c) 2014 Cambridge Silicon Radio Limited, a CSR plc group company.
+ *
+ * Author: RongJun Ying <rongjun.ying-kQvG35nSl+M@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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/sirf/audio.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+static struct mfd_cell sirf_audio_devs[] = {
+	{
+		.name = "sirf-audio-codec",
+	}, {
+		.of_compatible = "sirf,prima2-i2s",
+		.name = "sirf-i2s",
+	}, {
+		.of_compatible = "sirf,audio-port",
+		.name = "sirf-audio-port",
+	}
+};
+
+static const struct regmap_config sirf_audio_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+	.cache_type = REGCACHE_NONE,
+};
+
+static int sirf_audio_probe(struct platform_device *pdev)
+{
+	struct resource *mem_res;
+	struct sirf_audio_dev *sirf_audio;
+	void __iomem *base;
+	struct regmap *regmap;
+	struct device_node *codec_np;
+	const char *compatible;
+	int cplen;
+	int ret;
+
+	sirf_audio = devm_kzalloc(&pdev->dev, sizeof(*sirf_audio),
+				GFP_KERNEL);
+	if (!sirf_audio)
+		return -ENOMEM;
+
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (!base)
+		return -ENOMEM;
+
+	regmap = devm_regmap_init_mmio(&pdev->dev, base,
+					    &sirf_audio_regmap_config);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	sirf_audio->regmap = regmap;
+
+	platform_set_drvdata(pdev, sirf_audio);
+
+	codec_np = of_get_child_by_name(pdev->dev.of_node, "audiocodec");
+	if (!codec_np)
+		return -EINVAL;
+
+	compatible = of_get_property(codec_np, "compatible", &cplen);
+	if (!compatible)
+		return -EINVAL;
+
+	/* Overwrite internal codec compatible string */
+	sirf_audio_devs[0].of_compatible = kstrdup(compatible, GFP_KERNEL);
+
+	ret =  mfd_add_devices(&pdev->dev, -1, sirf_audio_devs,
+			ARRAY_SIZE(sirf_audio_devs),
+			NULL, 0, NULL);
+	if (ret) {
+		dev_err(&pdev->dev, "add mfd devices failed: %d\n", ret);
+		goto err_add_devs;
+	}
+
+	return 0;
+
+err_add_devs:
+	kfree(sirf_audio_devs[0].of_compatible);
+	return ret;
+}
+
+static int sirf_audio_remove(struct platform_device *pdev)
+{
+	kfree(sirf_audio_devs[0].of_compatible);
+	mfd_remove_devices(&pdev->dev);
+	return 0;
+}
+
+static const struct of_device_id sirf_audio_of_match[] = {
+	{ .compatible = "sirf,audio", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, sirf_audio_of_match);
+
+static struct platform_driver sirf_audio_driver = {
+	.driver = {
+		.name = "sirf-audio",
+		.owner = THIS_MODULE,
+		.of_match_table = sirf_audio_of_match,
+	},
+	.probe = sirf_audio_probe,
+	.remove = sirf_audio_remove,
+};
+
+module_platform_driver(sirf_audio_driver);
+
+MODULE_DESCRIPTION("SiRF Audio MFD driver");
+MODULE_AUTHOR("RongJun Ying <Rongjun.Ying-kQvG35nSl+M@public.gmane.org>");
+MODULE_LICENSE("GPL v2");
+
diff --git a/include/linux/mfd/sirf/audio.h b/include/linux/mfd/sirf/audio.h
new file mode 100644
index 0000000..f010466
--- /dev/null
+++ b/include/linux/mfd/sirf/audio.h
@@ -0,0 +1,22 @@
+/*
+ * audio.h -- Provide a struct to share the regmap to all child drivers
+ *
+ * Copyright (c) 2014 Cambridge Silicon Radio Limited, a CSR plc group company.
+ *
+ * Author: RongJun Ying <rongjun.ying-kQvG35nSl+M@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.
+ *
+ */
+
+#ifndef __MFD_SIRF_AUDIO_H
+#define __MFD_SIRF_AUDIO_H
+
+struct sirf_audio_dev {
+	struct regmap *regmap;
+};
+
+#endif /* __MFD_SIRF_AUDIO_H */
-- 
1.7.5.4

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

* [PATCH v2 2/2] Documentation: Describe the SiRF audio Device Tree bindings
       [not found] ` <1394505387-13665-1-git-send-email-rongjun.ying-kQvG35nSl+M@public.gmane.org>
  2014-03-11  2:36   ` [PATCH v2 1/2] mfd: Support SiRF audio modules RongJun Ying
@ 2014-03-11  2:36   ` RongJun Ying
  1 sibling, 0 replies; 4+ messages in thread
From: RongJun Ying @ 2014-03-11  2:36 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz
  Cc: Mark Brown, devicetree-u79uwXL29TY76Z2rM5mHXA,
	workgroup.linux-kQvG35nSl+M, Rongjun Ying

From: Rongjun Ying <rongjun.ying-kQvG35nSl+M@public.gmane.org>

Signed-off-by: Rongjun Ying <rongjun.ying-kQvG35nSl+M@public.gmane.org>
---
 .../devicetree/bindings/mfd/sirf-audio.txt         |   51 ++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/sirf-audio.txt

diff --git a/Documentation/devicetree/bindings/mfd/sirf-audio.txt b/Documentation/devicetree/bindings/mfd/sirf-audio.txt
new file mode 100644
index 0000000..ff05cb2
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/sirf-audio.txt
@@ -0,0 +1,51 @@
+SiRF SoC audio modules
+
+The audio modules inside the consist of an internal audio codec, internal
+audio port and i2s controller
+
+Required properties:
+- compatible: Must be "sirf,audio"
+- reg : The register address of the device
+- #address-cells: Must be 1
+- #size-cells: Must be 1
+
+Nodes:
+Internal audio codec:
+  - compatible : "sirf,atlas6-audio-codec" or "sirf,prima2-audio-codec"
+  - clocks: A phandle reference to the SiRF internal audio codec clock
+
+Internal audio port:
+- compatible: "sirf,audio-port"
+
+I2S controller:
+- compatible: "sirf,prima2-i2s"
+- clocks: A phandle reference to the SiRF I2S controller clock
+
+Example:
+sirfaudio: sirfaudio@b0040000 {
+	compatible = "sirf,atlas6-audio";
+	reg = <0xb0040000 0x10000>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	audiocodec: audiocodec {
+		compatible = "sirf,atlas6-audio-codec";
+		interrupts = <35>;
+		clocks = <&clks 27>;
+	};
+
+	audioport: audioport {
+		compatible = "sirf,audio-port";
+		dmas = <&dmac1 3>, <&dmac1 8>;
+		dma-names = "rx", "tx";
+	};
+
+	i2s: i2s {
+		compatible = "sirf,prima2-i2s";
+		dmas = <&dmac1 6>, <&dmac1 12>;
+		dma-names = "rx", "tx";
+		clocks = <&clks 27>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&i2s_pins_a>;
+	};
+};
-- 
1.7.5.4

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

* Re: [PATCH v2 1/2] mfd: Support SiRF audio modules
       [not found]     ` <1394505387-13665-2-git-send-email-rongjun.ying-kQvG35nSl+M@public.gmane.org>
@ 2014-03-11  6:44       ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2014-03-11  6:44 UTC (permalink / raw)
  To: RongJun Ying
  Cc: Samuel Ortiz, Mark Brown, devicetree-u79uwXL29TY76Z2rM5mHXA,
	workgroup.linux-kQvG35nSl+M, Rongjun Ying

> From: Rongjun Ying <rongjun.ying-kQvG35nSl+M@public.gmane.org>
> 
> The audio modules consist of an internal audio codec, internal
> audio port and i2s controller.
> 
> These modules sharing same register address space.
> sirf-audio.c provides common regmap mmio handling for all audio modules.
> The sound drivers will get regmap from sirf audio mfd driver.
> 
> Signed-off-by: Rongjun Ying <rongjun.ying-kQvG35nSl+M@public.gmane.org>
> ---
> -v2:
> 1. Fixed a lot of english syntax error
> 2. Add "OF" depend
> 3. Get codec compatible from child node of dts
> 4. Use a standard header
> 
>  drivers/mfd/Kconfig            |   10 +++
>  drivers/mfd/Makefile           |    1 +
>  drivers/mfd/sirf-audio.c       |  128 ++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/sirf/audio.h |   22 +++++++
>  4 files changed, 161 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/mfd/sirf-audio.c
>  create mode 100644 include/linux/mfd/sirf/audio.h

<snip>

> +static struct mfd_cell sirf_audio_devs[] = {
> +	{
> +		.name = "sirf-audio-codec",
> +	}, {
> +		.of_compatible = "sirf,prima2-i2s",
> +		.name = "sirf-i2s",
> +	}, {
> +		.of_compatible = "sirf,audio-port",
> +		.name = "sirf-audio-port",
> +	}
> +};

The compatible string for the CODEC is mentioned in the Documentation,
but missing here.

Nit: Also please put .name first and .of_compatible second.

<snip>

> +	regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +					    &sirf_audio_regmap_config);

Odd tabbing here. It's neither tabs, nor '(' aligned.

> +	compatible = of_get_property(codec_np, "compatible", &cplen);
> +	if (!compatible)
> +		return -EINVAL;
> +
> +	/* Overwrite internal codec compatible string */
> +	sirf_audio_devs[0].of_compatible = kstrdup(compatible, GFP_KERNEL);

Oh wow, but no.

Use of_platform_populate() instead of fiddling with the DT like this.

> +	ret =  mfd_add_devices(&pdev->dev, -1, sirf_audio_devs,
> +			ARRAY_SIZE(sirf_audio_devs),
> +			NULL, 0, NULL);
> +	if (ret) {
> +		dev_err(&pdev->dev, "add mfd devices failed: %d\n", ret);
> +		goto err_add_devs;
> +	}
> +
> +	return 0;
> +
> +err_add_devs:
> +	kfree(sirf_audio_devs[0].of_compatible);

<snip>

> +static int sirf_audio_remove(struct platform_device *pdev)
> +{
> +	kfree(sirf_audio_devs[0].of_compatible);

Gross.

> +	mfd_remove_devices(&pdev->dev);
> +	return 0;
> +}

<snip>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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] 4+ messages in thread

end of thread, other threads:[~2014-03-11  6:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11  2:36 [PATCH v2 0/2] mfd: Add SiRF audio MFD driver RongJun Ying
     [not found] ` <1394505387-13665-1-git-send-email-rongjun.ying-kQvG35nSl+M@public.gmane.org>
2014-03-11  2:36   ` [PATCH v2 1/2] mfd: Support SiRF audio modules RongJun Ying
     [not found]     ` <1394505387-13665-2-git-send-email-rongjun.ying-kQvG35nSl+M@public.gmane.org>
2014-03-11  6:44       ` Lee Jones
2014-03-11  2:36   ` [PATCH v2 2/2] Documentation: Describe the SiRF audio Device Tree bindings RongJun Ying

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).