diff options
| author | Evan Wilson <evan@oliodevices.com> | 2015-07-06 14:01:23 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@ip-172-31-25-77.us-west-1.compute.internal> | 2015-04-16 10:08:13 +0000 |
| commit | 9bf9e3a205f36d4349bc6aa63da76cdaf3e855c3 (patch) | |
| tree | 6aab7dacf43291af0ab2fc4df0a402ac09ea8e97 | |
| parent | 35f13297fb4355719f4715223e5442d3be692320 (diff) | |
| parent | 5976db28505ede7c77f7bb180b1386a149f768c7 (diff) | |
| download | olio-linux-3.10-9bf9e3a205f36d4349bc6aa63da76cdaf3e855c3.tar.xz olio-linux-3.10-9bf9e3a205f36d4349bc6aa63da76cdaf3e855c3.zip | |
Merge "Changes to mic driver to support device tree" into android-3.10-bringup
| -rw-r--r-- | sound/soc/omap/omap3h1.c | 77 |
1 files changed, 51 insertions, 26 deletions
diff --git a/sound/soc/omap/omap3h1.c b/sound/soc/omap/omap3h1.c index 108d104502d..2cd624744ea 100644 --- a/sound/soc/omap/omap3h1.c +++ b/sound/soc/omap/omap3h1.c @@ -26,6 +26,7 @@ #include <linux/clk.h> #include <linux/platform_device.h> #include <linux/module.h> +#include <linux/of.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> @@ -46,7 +47,7 @@ static int omap3h1_hw_params(struct snd_pcm_substream *substream, //freq = 256 * params_rate(params); // We are triggering from the 96 MHz FSCK - pr_info("ASoc OMAP3H1: setting according to system clock\n"); + pr_info("ASoc OMAP3H1: setting system clock to: %d", freq); ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_FCLK, 96000000, SND_SOC_CLOCK_OUT); if (ret < 0) { @@ -103,45 +104,69 @@ static struct snd_soc_card snd_soc_omap3h1 = { // .num_dapm_routes = ARRAY_SIZE(dmic_audio_map), }; -static struct platform_device *omap3h1_snd_device; - -static int __init omap3h1_soc_init(void) +static int omap3h1_card_probe(struct platform_device *pdev) { - int ret; + struct device_node *node = pdev->dev.of_node; + struct snd_soc_card *card = &snd_soc_omap3h1; + int ret = 0; - if (!(machine_is_omap3_h1())) - return -ENODEV; - pr_info("OMAP3 H1 SoC init\n"); +#ifdef CONFIG_OF + if (node) { + struct device_node *dai_node; + + dai_node = of_parse_phandle(node, "olio,mcbsp", 0); + if (!dai_node) { + dev_err(&pdev->dev, "mcbsp node is not provided\n"); + return -EINVAL; + } + omap3h1_dai.cpu_dai_name = NULL; + omap3h1_dai.cpu_of_node = dai_node; - omap3h1_snd_device = platform_device_alloc("soc-audio", -1); - if (!omap3h1_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; + } else { + dev_err(&pdev->dev, "Missing node\n"); + return -ENODEV; } +#endif - platform_set_drvdata(omap3h1_snd_device, &snd_soc_omap3h1); + card->dev = &pdev->dev; + snd_soc_card_set_drvdata(card, NULL); - ret = platform_device_add(omap3h1_snd_device); - if (ret) - goto err1; + ret = snd_soc_register_card(card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); + return ret; + } return 0; - -err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(omap3h1_snd_device); - - return ret; } -static void __exit omap3h1_soc_exit(void) +static int omap3h1_card_remove(struct platform_device *pdev) { - platform_device_unregister(omap3h1_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + snd_soc_unregister_card(card); + + return 0; } -module_init(omap3h1_soc_init); -module_exit(omap3h1_soc_exit); +static const struct of_device_id omap_soc_h1_of_match[] = { + {.compatible = "olio,omap-soc-omap3h1", }, + { }, +}; +MODULE_DEVICE_TABLE(of, omap_soc_h1_of_match); + +static struct platform_driver omap3h1_driver = { + .driver = { + .name = "omap-soc-omap3h1", + .of_match_table = of_match_ptr(omap_soc_h1_of_match), + }, + .probe = omap3h1_card_probe, + .remove = omap3h1_card_remove, +}; + +module_platform_driver(omap3h1_driver); MODULE_AUTHOR("Evan Wilson <evan@oliodevices.com"); MODULE_DESCRIPTION("ALSA SoC OMAP3 H1"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:omap-soc-omap3h1"); |