devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Shiyan <shc_work@mail.ru>
To: alsa-devel@alsa-project.org
Cc: devicetree@vger.kernel.org, Samuel Ortiz <sameo@linux.intel.com>,
	Alexander Shiyan <shc_work@mail.ru>, Takashi Iwai <tiwai@suse.de>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Lee Jones <lee.jones@linaro.org>
Subject: [PATCH] ASoC: mc13783: Add devicetree support
Date: Sat, 26 Apr 2014 10:57:03 +0400	[thread overview]
Message-ID: <1398495423-2223-1-git-send-email-shc_work@mail.ru> (raw)

This patch adds devicetree support for mc13783-codec.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 Documentation/devicetree/bindings/mfd/mc13xxx.txt |  3 +++
 drivers/mfd/mc13xxx-core.c                        | 10 +++++++---
 sound/soc/codecs/mc13783.c                        | 14 +++++++++++++-
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/mc13xxx.txt b/Documentation/devicetree/bindings/mfd/mc13xxx.txt
index 1413f39..8aba488 100644
--- a/Documentation/devicetree/bindings/mfd/mc13xxx.txt
+++ b/Documentation/devicetree/bindings/mfd/mc13xxx.txt
@@ -10,6 +10,9 @@ Optional properties:
 - fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used
 
 Sub-nodes:
+- codec: Contain the Audio Codec node.
+  - adc-port: Contain PMIC SSI port number used for ADC.
+  - dac-port: Contain PMIC SSI port number used for DAC.
 - leds : Contain the led nodes and initial register values in property
   "led-control". Number of register depends of used IC, for MC13783 is 6,
   for MC13892 is 4, for MC34708 is 1. See datasheet for bits definitions of
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 06e64b6..0c6c21c 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -673,9 +673,13 @@ int mc13xxx_common_init(struct device *dev)
 	if (mc13xxx->flags & MC13XXX_USE_ADC)
 		mc13xxx_add_subdevice(mc13xxx, "%s-adc");
 
-	if (mc13xxx->flags & MC13XXX_USE_CODEC)
-		mc13xxx_add_subdevice_pdata(mc13xxx, "%s-codec",
-					pdata->codec, sizeof(*pdata->codec));
+	if (mc13xxx->flags & MC13XXX_USE_CODEC) {
+		if (pdata)
+			mc13xxx_add_subdevice_pdata(mc13xxx, "%s-codec",
+				pdata->codec, sizeof(*pdata->codec));
+		else
+			mc13xxx_add_subdevice(mc13xxx, "%s-codec");
+	}
 
 	if (mc13xxx->flags & MC13XXX_USE_RTC)
 		mc13xxx_add_subdevice(mc13xxx, "%s-rtc");
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
index 0b0a4ca..9965277 100644
--- a/sound/soc/codecs/mc13783.c
+++ b/sound/soc/codecs/mc13783.c
@@ -22,6 +22,7 @@
  */
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/of.h>
 #include <linux/mfd/mc13xxx.h>
 #include <linux/slab.h>
 #include <sound/core.h>
@@ -748,6 +749,7 @@ static int __init mc13783_codec_probe(struct platform_device *pdev)
 {
 	struct mc13783_priv *priv;
 	struct mc13xxx_codec_platform_data *pdata = pdev->dev.platform_data;
+	struct device_node *np;
 	int ret;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -758,7 +760,17 @@ static int __init mc13783_codec_probe(struct platform_device *pdev)
 		priv->adc_ssi_port = pdata->adc_ssi_port;
 		priv->dac_ssi_port = pdata->dac_ssi_port;
 	} else {
-		return -ENOSYS;
+		np = of_get_child_by_name(pdev->dev.parent->of_node, "codec");
+		if (!np)
+			return -ENOSYS;
+
+		ret = of_property_read_u32(np, "adc-port", &priv->adc_ssi_port);
+		if (ret)
+			return ret;
+
+		ret = of_property_read_u32(np, "dac-port", &priv->dac_ssi_port);
+		if (ret)
+			return ret;
 	}
 
 	dev_set_drvdata(&pdev->dev, priv);
-- 
1.8.3.2

             reply	other threads:[~2014-04-26  6:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-26  6:57 Alexander Shiyan [this message]
     [not found] ` <1398495423-2223-1-git-send-email-shc_work-JGs/UdohzUI@public.gmane.org>
2014-04-28 11:17   ` [PATCH] ASoC: mc13783: Add devicetree support Lee Jones
2014-04-29 22:25   ` Mark Brown
     [not found]     ` <20140429222522.GS15125-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-04-30 14:08       ` Lee Jones
2014-04-30 14:11         ` Alexander Shiyan
     [not found]           ` <1398867073.695596467-rKA3owyty39sdVUOrk1QfQ@public.gmane.org>
2014-04-30 14:17             ` Lee Jones
2014-04-30 14:20               ` Alexander Shiyan
     [not found]                 ` <1398867618.574635813-rKA3owyty39sdVUOrk1QfQ@public.gmane.org>
2014-04-30 14:24                   ` Lee Jones
2014-04-30 14:28                     ` Alexander Shiyan
     [not found]                       ` <1398868130.411182088-rKA3owyty39sdVUOrk1QfQ@public.gmane.org>
2014-04-30 14:33                         ` Lee Jones
2014-04-30 14:40                           ` Alexander Shiyan
     [not found]                             ` <1398868829.456957971-NHsxxyuixOdsdVUOrk1QfQ@public.gmane.org>
2014-04-30 14:46                               ` Lee Jones
2014-04-30 14:58                                 ` Alexander Shiyan
2014-04-30 18:06               ` Mark Brown
     [not found]                 ` <20140430180653.GB3245-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-04-30 18:12                   ` Alexander Shiyan
     [not found]                     ` <1398881556.141711961-JZ33oUlt0U9sdVUOrk1QfQ@public.gmane.org>
2014-04-30 18:23                       ` Mark Brown
2014-05-01  7:42                   ` Lee Jones
2014-05-01 15:06                     ` Mark Brown
     [not found]                       ` <20140501150653.GZ3245-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-05-02  8:09                         ` Lee Jones
2014-05-03  1:49                           ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398495423-2223-1-git-send-email-shc_work@mail.ru \
    --to=shc_work@mail.ru \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=sameo@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).