From: Daniel Mack <zonque@gmail.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Liam Girdwood <lrg@ti.com>, Simon <horms@verge.net.au>,
Kuninori Morimoto <kuninori.morimoto.gx@gmail.com>
Subject: Re: [RFC][PATCH 2/2] ASoC: simple-card: add DT support
Date: Fri, 30 Nov 2012 11:38:42 +0100 [thread overview]
Message-ID: <50B88CB2.9040605@gmail.com> (raw)
In-Reply-To: <87r4ndhvwj.wl%kuninori.morimoto.gx@renesas.com>
Hi Kuninori,
On 29.11.2012 05:32, Kuninori Morimoto wrote:
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> sound/soc/generic/simple-card.c | 90 +++++++++++++++++++++++++++++++++++++--
> 1 file changed, 87 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
> index b4b4cab..a59e88c 100644
> --- a/sound/soc/generic/simple-card.c
> +++ b/sound/soc/generic/simple-card.c
> @@ -9,6 +9,7 @@
> * published by the Free Software Foundation.
> */
>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/module.h>
> #include <sound/simple_card.h>
> @@ -47,12 +48,89 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
> return 0;
> }
>
> +static void asoc_simple_card_parse_of(struct device_node *np,
> + struct asoc_simple_card_info *cinfo,
> + struct device *dev)
> +{
> + struct asoc_simple_dai_init_info *iinfo;
> + unsigned int cpu_daifmt = 0;
> + unsigned int codec_daifmt = 0;
> + unsigned int sysclk = 0;
> +
> + /*
> + * it will find
> + *
> + * iinfo,cpu,snd,soc,daifmt,xxx
> + * iinfo,codec,snd,soc,daifmt,xxx
> + * iinfo,sysclk
> + */
> + snd_soc_of_parse_daifmt(np, "iinfo,cpu,", &cpu_daifmt);
> + snd_soc_of_parse_daifmt(np, "iinfo,codec,", &codec_daifmt);
> + of_property_read_u32(np, "iinfo,sysclk", &sysclk);
> +
> + if (cpu_daifmt || codec_daifmt || sysclk) {
> + iinfo = devm_kzalloc(dev, sizeof(*iinfo), GFP_KERNEL);
> + if (!iinfo)
> + return;
> +
> + cinfo->init = iinfo;
> + iinfo->cpu_daifmt = cpu_daifmt;
> + iinfo->codec_daifmt = codec_daifmt;
> + iinfo->sysclk = sysclk;
> + }
> +
> + /*
> + * it will find
> + *
> + * cinfo,xxx
> + */
> + of_property_read_string(np, "cinfo,name", &cinfo->name);
> + of_property_read_string(np, "cinfo,card", &cinfo->card);
> + of_property_read_string(np, "cinfo,cpu_dai", &cinfo->cpu_dai);
> + of_property_read_string(np, "cinfo,codec", &cinfo->codec);
> + of_property_read_string(np, "cinfo,platform", &cinfo->platform);
> + of_property_read_string(np, "cinfo,codec_dai", &cinfo->codec_dai);
CPUs, codecs and platforms should be referenced by phandles rather than
by string. The ASoC core is well prepared for this, by using the
dai_link's *_of_node members.
> + /*
> + * debug info
> + */
> + if (cinfo->name)
> + dev_dbg(dev, "name = %s\n", cinfo->name);
> + if (cinfo->card)
> + dev_dbg(dev, "card = %s\n", cinfo->card);
> + if (cinfo->cpu_dai)
> + dev_dbg(dev, "cpu_dai = %s\n", cinfo->cpu_dai);
> + if (cinfo->codec)
> + dev_dbg(dev, "codec = %s\n", cinfo->codec);
> + if (cinfo->platform)
> + dev_dbg(dev, "platform = %s\n", cinfo->platform);
> + if (cinfo->codec_dai)
> + dev_dbg(dev, "codec_dai = %s\n", cinfo->codec_dai);
> + if (iinfo && iinfo->cpu_daifmt)
> + dev_dbg(dev, "cpu_daifmt = %08x\n", iinfo->cpu_daifmt);
> + if (iinfo && iinfo->codec_daifmt)
> + dev_dbg(dev, "codec_daifmt = %08x\n", iinfo->codec_daifmt);
> + if (iinfo && iinfo->sysclk)
> + dev_dbg(dev, "iinfo,sysclk = %d\n", iinfo->sysclk);
> +}
> +
> static int asoc_simple_card_probe(struct platform_device *pdev)
> {
> - struct asoc_simple_card_info *cinfo = pdev->dev.platform_data;
> + struct asoc_simple_card_info *cinfo;
> + struct device_node *np = pdev->dev.of_node;
> + struct device *dev = &pdev->dev;
> +
> + cinfo = NULL;
> + if (np && of_device_is_available(np)) {
> + cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
> + if (cinfo)
> + asoc_simple_card_parse_of(np, cinfo, dev);
> + } else {
> + cinfo = pdev->dev.platform_data;
> + }
>
> if (!cinfo) {
> - dev_err(&pdev->dev, "no info for asoc-simple-card\n");
> + dev_err(dev, "no info for asoc-simple-card\n");
> return -EINVAL;
> }
>
> @@ -62,7 +140,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
> !cinfo->codec ||
> !cinfo->platform ||
> !cinfo->codec_dai) {
> - dev_err(&pdev->dev, "insufficient asoc_simple_card_info settings\n");
> + dev_err(dev, "insufficient asoc_simple_card_info settings\n");
That's an unrelated change that should probably go into a separate commit.
Daniel
next prev parent reply other threads:[~2012-11-30 10:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 4:31 [RFC][PATCH 0/2] ASoC: add DT support on simple-card Kuninori Morimoto
2012-11-29 4:31 ` [RFC][PATCH 1/2] ASoC: add snd_soc_of_parse_daifmt() Kuninori Morimoto
2012-11-29 5:21 ` Stephen Warren
2012-11-29 15:12 ` Mark Brown
2012-11-30 0:35 ` Kuninori Morimoto
2012-12-04 20:18 ` Stephen Warren
2012-12-05 7:55 ` Kuninori Morimoto
2012-12-05 20:42 ` Stephen Warren
2012-12-06 9:02 ` Kuninori Morimoto
2012-11-29 4:32 ` [RFC][PATCH 2/2] ASoC: simple-card: add DT support Kuninori Morimoto
2012-11-29 5:20 ` Stephen Warren
2012-11-29 6:05 ` Kuninori Morimoto
2012-11-30 10:38 ` Daniel Mack [this message]
2012-12-03 0:18 ` Kuninori Morimoto
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=50B88CB2.9040605@gmail.com \
--to=zonque@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=horms@verge.net.au \
--cc=kuninori.morimoto.gx@gmail.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lrg@ti.com \
/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 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.