Merge remote-tracking branches 'asoc/topic/multi-codec', 'asoc/topic/mxs-saif', ...
authorMark Brown <broonie@kernel.org>
Mon, 8 Dec 2014 13:12:05 +0000 (13:12 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 8 Dec 2014 13:12:05 +0000 (13:12 +0000)
arch/arm/mach-pxa/spitz.c
include/sound/soc.h
sound/soc/mxs/mxs-saif.c
sound/soc/mxs/mxs-sgtl5000.c
sound/soc/omap/Kconfig
sound/soc/omap/mcbsp.c
sound/soc/pxa/mioa701_wm9713.c
sound/soc/pxa/pxa-ssp.c
sound/soc/pxa/spitz.c
sound/soc/soc-core.c

index 840c3a48e7200106c0050e8ff7c2f5cd35840c3d..962a7f31f5969a49cbd88be8501d74eaf272608d 100644 (file)
@@ -923,6 +923,14 @@ static void __init spitz_i2c_init(void)
 static inline void spitz_i2c_init(void) {}
 #endif
 
+/******************************************************************************
+ * Audio devices
+ ******************************************************************************/
+static inline void spitz_audio_init(void)
+{
+       platform_device_register_simple("spitz-audio", -1, NULL, 0);
+}
+
 /******************************************************************************
  * Machine init
  ******************************************************************************/
@@ -970,6 +978,7 @@ static void __init spitz_init(void)
        spitz_nor_init();
        spitz_nand_init();
        spitz_i2c_init();
+       spitz_audio_init();
 }
 
 static void __init spitz_fixup(struct tag *tags, char **cmdline)
index 29a52909ddef8536672e68fe1d7c859319f133ad..b4fca9aed2a2b00296ce040428b830b93095d562 100644 (file)
@@ -1496,6 +1496,9 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
                                     struct device_node **framemaster);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
                            const char **dai_name);
+int snd_soc_of_get_dai_link_codecs(struct device *dev,
+                                  struct device_node *of_node,
+                                  struct snd_soc_dai_link *dai_link);
 
 #include <sound/soc-dai.h>
 
index 231d7e7b07110d9e219788810acf70d62f1e00c6..83b2fea0921967ffa8820887127c2b573b5dd1f5 100644 (file)
@@ -773,7 +773,7 @@ static int mxs_saif_probe(struct platform_device *pdev)
 
        saif->dev = &pdev->dev;
        ret = devm_request_irq(&pdev->dev, saif->irq, mxs_saif_irq, 0,
-                              "mxs-saif", saif);
+                              dev_name(&pdev->dev), saif);
        if (ret) {
                dev_err(&pdev->dev, "failed to request irq\n");
                return ret;
index 61822cc53bd3e9b53b63042dd6ea986b681a7d1b..3bba6cfe4f2959b15206b976e6e605ebdc04c78c 100644 (file)
@@ -49,13 +49,6 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream,
                break;
        }
 
-       /* Sgtl5000 sysclk should be >= 8MHz and <= 27M */
-       if (mclk < 8000000 || mclk > 27000000) {
-               dev_err(codec_dai->dev, "Invalid mclk frequency: %u.%03uMHz\n",
-                       mclk / 1000000, mclk / 1000 % 1000);
-               return -EINVAL;
-       }
-
        /* Set SGTL5000's SYSCLK (provided by SAIF MCLK) */
        ret = snd_soc_dai_set_sysclk(codec_dai, SGTL5000_SYSCLK, mclk, 0);
        if (ret) {
index d44463a7b0faed8faef4565657962111604daa2c..2738b198441048c658c70e912321984e428e093c 100644 (file)
@@ -25,15 +25,15 @@ config SND_OMAP_SOC_N810
          Say Y if you want to add support for SoC audio on Nokia N810.
 
 config SND_OMAP_SOC_RX51
-       tristate "SoC Audio support for Nokia RX-51"
-       depends on SND_OMAP_SOC && ARM && (MACH_NOKIA_RX51 || COMPILE_TEST) && I2C
+       tristate "SoC Audio support for Nokia N900 (RX-51)"
+       depends on SND_OMAP_SOC && ARM && I2C
        select SND_OMAP_SOC_MCBSP
        select SND_SOC_TLV320AIC3X
        select SND_SOC_TPA6130A2
        depends on GPIOLIB
        help
-         Say Y if you want to add support for SoC audio on Nokia RX-51
-         hardware. This is also known as Nokia N900 product.
+         Say Y if you want to add support for SoC audio on Nokia N900
+         cellphone.
 
 config SND_OMAP_SOC_AMS_DELTA
        tristate "SoC Audio support for Amstrad E3 (Delta) videophone"
index 86c75384c3c87dd0e4c9109f737122b1888ad295..68a1252053750a29489382ce6434ed54bd698c96 100644 (file)
@@ -621,8 +621,7 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
        mcbsp->reg_cache = NULL;
        spin_unlock(&mcbsp->lock);
 
-       if (reg_cache)
-               kfree(reg_cache);
+       kfree(reg_cache);
 }
 
 /*
index 595eee341e90b6910d60348fdae5e970e0854fa6..a6b2be20cc0ba93ff658b5c1e33556cb8e206107 100644 (file)
@@ -127,15 +127,12 @@ static const struct snd_soc_dapm_route audio_map[] = {
 static int mioa701_wm9713_init(struct snd_soc_pcm_runtime *rtd)
 {
        struct snd_soc_codec *codec = rtd->codec;
-       unsigned short reg;
 
        /* Prepare GPIO8 for rear speaker amplifier */
-       reg = codec->driver->read(codec, AC97_GPIO_CFG);
-       codec->driver->write(codec, AC97_GPIO_CFG, reg | 0x0100);
+       snd_soc_update_bits(codec, AC97_GPIO_CFG, 0x100, 0x100);
 
        /* Prepare MIC input */
-       reg = codec->driver->read(codec, AC97_3D_CONTROL);
-       codec->driver->write(codec, AC97_3D_CONTROL, reg | 0xc000);
+       snd_soc_update_bits(codec, AC97_3D_CONTROL, 0xc000, 0xc000);
 
        return 0;
 }
index a8e0974330749f86c894ce520ff43d7c4d0960cc..cbba063a7210cb440f1b0ac03735a410f499841c 100644 (file)
@@ -97,7 +97,7 @@ static int pxa_ssp_startup(struct snd_pcm_substream *substream,
        int ret = 0;
 
        if (!cpu_dai->active) {
-               clk_enable(ssp->clk);
+               clk_prepare_enable(ssp->clk);
                pxa_ssp_disable(ssp);
        }
 
@@ -121,7 +121,7 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream,
 
        if (!cpu_dai->active) {
                pxa_ssp_disable(ssp);
-               clk_disable(ssp->clk);
+               clk_disable_unprepare(ssp->clk);
        }
 
        kfree(snd_soc_dai_get_dma_data(cpu_dai, substream));
@@ -136,7 +136,7 @@ static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
        struct ssp_device *ssp = priv->ssp;
 
        if (!cpu_dai->active)
-               clk_enable(ssp->clk);
+               clk_prepare_enable(ssp->clk);
 
        priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0);
        priv->cr1 = __raw_readl(ssp->mmio_base + SSCR1);
@@ -144,7 +144,7 @@ static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai)
        priv->psp = __raw_readl(ssp->mmio_base + SSPSP);
 
        pxa_ssp_disable(ssp);
-       clk_disable(ssp->clk);
+       clk_disable_unprepare(ssp->clk);
        return 0;
 }
 
@@ -154,7 +154,7 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
        struct ssp_device *ssp = priv->ssp;
        uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE;
 
-       clk_enable(ssp->clk);
+       clk_prepare_enable(ssp->clk);
 
        __raw_writel(sssr, ssp->mmio_base + SSSR);
        __raw_writel(priv->cr0 & ~SSCR0_SSE, ssp->mmio_base + SSCR0);
@@ -165,7 +165,7 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai)
        if (cpu_dai->active)
                pxa_ssp_enable(ssp);
        else
-               clk_disable(ssp->clk);
+               clk_disable_unprepare(ssp->clk);
 
        return 0;
 }
@@ -256,11 +256,11 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
        /* The SSP clock must be disabled when changing SSP clock mode
         * on PXA2xx.  On PXA3xx it must be enabled when doing so. */
        if (ssp->type != PXA3xx_SSP)
-               clk_disable(ssp->clk);
+               clk_disable_unprepare(ssp->clk);
        val = pxa_ssp_read_reg(ssp, SSCR0) | sscr0;
        pxa_ssp_write_reg(ssp, SSCR0, val);
        if (ssp->type != PXA3xx_SSP)
-               clk_enable(ssp->clk);
+               clk_prepare_enable(ssp->clk);
 
        return 0;
 }
index 1373b017a9514f379bf8f111afad10ddac640d6f..d7d5fb20ea6f461f70fcfca85f928db617fba1bb 100644 (file)
@@ -305,19 +305,15 @@ static struct snd_soc_card snd_soc_spitz = {
        .num_dapm_routes = ARRAY_SIZE(spitz_audio_map),
 };
 
-static struct platform_device *spitz_snd_device;
-
-static int __init spitz_init(void)
+static int spitz_probe(struct platform_device *pdev)
 {
+       struct snd_soc_card *card = &snd_soc_spitz;
        int ret;
 
-       if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita()))
-               return -ENODEV;
-
-       if (machine_is_borzoi() || machine_is_spitz())
-               spitz_mic_gpio = SPITZ_GPIO_MIC_BIAS;
-       else
+       if (machine_is_akita())
                spitz_mic_gpio = AKITA_GPIO_MIC_BIAS;
+       else
+               spitz_mic_gpio = SPITZ_GPIO_MIC_BIAS;
 
        ret = gpio_request(spitz_mic_gpio, "MIC GPIO");
        if (ret)
@@ -327,37 +323,45 @@ static int __init spitz_init(void)
        if (ret)
                goto err2;
 
-       spitz_snd_device = platform_device_alloc("soc-audio", -1);
-       if (!spitz_snd_device) {
-               ret = -ENOMEM;
+       card->dev = &pdev->dev;
+
+       ret = snd_soc_register_card(card);
+       if (ret) {
+               dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
+                       ret);
                goto err2;
        }
 
-       platform_set_drvdata(spitz_snd_device, &snd_soc_spitz);
-
-       ret = platform_device_add(spitz_snd_device);
-       if (ret)
-               goto err3;
-
        return 0;
 
-err3:
-       platform_device_put(spitz_snd_device);
 err2:
        gpio_free(spitz_mic_gpio);
 err1:
        return ret;
 }
 
-static void __exit spitz_exit(void)
+static int spitz_remove(struct platform_device *pdev)
 {
-       platform_device_unregister(spitz_snd_device);
+       struct snd_soc_card *card = platform_get_drvdata(pdev);
+
+       snd_soc_unregister_card(card);
        gpio_free(spitz_mic_gpio);
+       return 0;
 }
 
-module_init(spitz_init);
-module_exit(spitz_exit);
+static struct platform_driver spitz_driver = {
+       .driver         = {
+               .name   = "spitz-audio",
+               .owner  = THIS_MODULE,
+               .pm     = &snd_soc_pm_ops,
+       },
+       .probe          = spitz_probe,
+       .remove         = spitz_remove,
+};
+
+module_platform_driver(spitz_driver);
 
 MODULE_AUTHOR("Richard Purdie");
 MODULE_DESCRIPTION("ALSA SoC Spitz");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:spitz-audio");
index 11d01e5a2f708a94b0faa7f9d1bd19523f42fc31..935721062c212719c60f7a5e3aa3ecbab50d4114 100644 (file)
@@ -3400,36 +3400,30 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
-int snd_soc_of_get_dai_name(struct device_node *of_node,
-                           const char **dai_name)
+static int snd_soc_get_dai_name(struct of_phandle_args *args,
+                               const char **dai_name)
 {
        struct snd_soc_component *pos;
-       struct of_phandle_args args;
-       int ret;
-
-       ret = of_parse_phandle_with_args(of_node, "sound-dai",
-                                        "#sound-dai-cells", 0, &args);
-       if (ret)
-               return ret;
-
-       ret = -EPROBE_DEFER;
+       int ret = -EPROBE_DEFER;
 
        mutex_lock(&client_mutex);
        list_for_each_entry(pos, &component_list, list) {
-               if (pos->dev->of_node != args.np)
+               if (pos->dev->of_node != args->np)
                        continue;
 
                if (pos->driver->of_xlate_dai_name) {
-                       ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
+                       ret = pos->driver->of_xlate_dai_name(pos,
+                                                            args,
+                                                            dai_name);
                } else {
                        int id = -1;
 
-                       switch (args.args_count) {
+                       switch (args->args_count) {
                        case 0:
                                id = 0; /* same as dai_drv[0] */
                                break;
                        case 1:
-                               id = args.args[0];
+                               id = args->args[0];
                                break;
                        default:
                                /* not supported */
@@ -3451,6 +3445,21 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
                break;
        }
        mutex_unlock(&client_mutex);
+       return ret;
+}
+
+int snd_soc_of_get_dai_name(struct device_node *of_node,
+                           const char **dai_name)
+{
+       struct of_phandle_args args;
+       int ret;
+
+       ret = of_parse_phandle_with_args(of_node, "sound-dai",
+                                        "#sound-dai-cells", 0, &args);
+       if (ret)
+               return ret;
+
+       ret = snd_soc_get_dai_name(&args, dai_name);
 
        of_node_put(args.np);
 
@@ -3458,6 +3467,77 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name);
 
+/*
+ * snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree
+ * @dev: Card device
+ * @of_node: Device node
+ * @dai_link: DAI link
+ *
+ * Builds an array of CODEC DAI components from the DAI link property
+ * 'sound-dai'.
+ * The array is set in the DAI link and the number of DAIs is set accordingly.
+ * The device nodes in the array (of_node) must be dereferenced by the caller.
+ *
+ * Returns 0 for success
+ */
+int snd_soc_of_get_dai_link_codecs(struct device *dev,
+                                  struct device_node *of_node,
+                                  struct snd_soc_dai_link *dai_link)
+{
+       struct of_phandle_args args;
+       struct snd_soc_dai_link_component *component;
+       char *name;
+       int index, num_codecs, ret;
+
+       /* Count the number of CODECs */
+       name = "sound-dai";
+       num_codecs = of_count_phandle_with_args(of_node, name,
+                                               "#sound-dai-cells");
+       if (num_codecs <= 0) {
+               if (num_codecs == -ENOENT)
+                       dev_err(dev, "No 'sound-dai' property\n");
+               else
+                       dev_err(dev, "Bad phandle in 'sound-dai'\n");
+               return num_codecs;
+       }
+       component = devm_kzalloc(dev,
+                                sizeof *component * num_codecs,
+                                GFP_KERNEL);
+       if (!component)
+               return -ENOMEM;
+       dai_link->codecs = component;
+       dai_link->num_codecs = num_codecs;
+
+       /* Parse the list */
+       for (index = 0, component = dai_link->codecs;
+            index < dai_link->num_codecs;
+            index++, component++) {
+               ret = of_parse_phandle_with_args(of_node, name,
+                                                "#sound-dai-cells",
+                                                 index, &args);
+               if (ret)
+                       goto err;
+               component->of_node = args.np;
+               ret = snd_soc_get_dai_name(&args, &component->dai_name);
+               if (ret < 0)
+                       goto err;
+       }
+       return 0;
+err:
+       for (index = 0, component = dai_link->codecs;
+            index < dai_link->num_codecs;
+            index++, component++) {
+               if (!component->of_node)
+                       break;
+               of_node_put(component->of_node);
+               component->of_node = NULL;
+       }
+       dai_link->codecs = NULL;
+       dai_link->num_codecs = 0;
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_link_codecs);
+
 static int __init snd_soc_init(void)
 {
 #ifdef CONFIG_DEBUG_FS