ASoC: mx27vis-aic32x4: Convert it to platform driver
[deliverable/linux.git] / sound / soc / imx / mx27vis-aic32x4.c
index 155899c08c0c4c15ddcdf5fe3e6874463c6cb578..f6d04ad4bb39f99e83752e06c9e253d3c8bff8cd 100644 (file)
 #include <sound/soc-dapm.h>
 #include <sound/tlv.h>
 #include <asm/mach-types.h>
-#include <mach/audmux.h>
 #include <mach/iomux-mx27.h>
 
 #include "../codecs/tlv320aic32x4.h"
 #include "imx-ssi.h"
+#include "imx-audmux.h"
 
 #define MX27VIS_AMP_GAIN       0
 #define MX27VIS_AMP_MUTE       1
@@ -188,55 +188,58 @@ static struct snd_soc_card mx27vis_aic32x4 = {
        .num_dapm_routes = ARRAY_SIZE(aic32x4_dapm_routes),
 };
 
-static struct platform_device *mx27vis_aic32x4_snd_device;
-
-static int __init mx27vis_aic32x4_init(void)
+static int __devinit mx27vis_aic32x4_probe(struct platform_device *pdev)
 {
        int ret;
 
-       mx27vis_aic32x4_snd_device = platform_device_alloc("soc-audio", -1);
-       if (!mx27vis_aic32x4_snd_device)
-               return -ENOMEM;
-
-       platform_set_drvdata(mx27vis_aic32x4_snd_device, &mx27vis_aic32x4);
-       ret = platform_device_add(mx27vis_aic32x4_snd_device);
-
+       mx27vis_aic32x4.dev = &pdev->dev;
+       ret = snd_soc_register_card(&mx27vis_aic32x4);
        if (ret) {
-               printk(KERN_ERR "ASoC: Platform device allocation failed\n");
-               platform_device_put(mx27vis_aic32x4_snd_device);
+               dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
+                       ret);
+               return ret;
        }
 
        /* Connect SSI0 as clock slave to SSI1 external pins */
-       mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
-                       MXC_AUDMUX_V1_PCR_SYN |
-                       MXC_AUDMUX_V1_PCR_TFSDIR |
-                       MXC_AUDMUX_V1_PCR_TCLKDIR |
-                       MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) |
-                       MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1)
+       imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
+                       IMX_AUDMUX_V1_PCR_SYN |
+                       IMX_AUDMUX_V1_PCR_TFSDIR |
+                       IMX_AUDMUX_V1_PCR_TCLKDIR |
+                       IMX_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1) |
+                       IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_PPCR1_SSI_PINS_1)
        );
-       mxc_audmux_v1_configure_port(MX27_AUDMUX_PPCR1_SSI_PINS_1,
-                       MXC_AUDMUX_V1_PCR_SYN |
-                       MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
+       imx_audmux_v1_configure_port(MX27_AUDMUX_PPCR1_SSI_PINS_1,
+                       IMX_AUDMUX_V1_PCR_SYN |
+                       IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
        );
 
        ret = mxc_gpio_setup_multiple_pins(mx27vis_amp_pins,
                        ARRAY_SIZE(mx27vis_amp_pins), "MX27VIS_AMP");
-       if (ret) {
+       if (ret)
                printk(KERN_ERR "ASoC: unable to setup gpios\n");
-               platform_device_put(mx27vis_aic32x4_snd_device);
-       }
 
        return ret;
 }
 
-static void __exit mx27vis_aic32x4_exit(void)
+static int __devexit mx27vis_aic32x4_remove(struct platform_device *pdev)
 {
-       platform_device_unregister(mx27vis_aic32x4_snd_device);
+       snd_soc_unregister_card(&mx27vis_aic32x4);
+
+       return 0;
 }
 
-module_init(mx27vis_aic32x4_init);
-module_exit(mx27vis_aic32x4_exit);
+static struct platform_driver mx27vis_aic32x4_audio_driver = {
+       .driver = {
+               .name = "mx27vis",
+               .owner = THIS_MODULE,
+       },
+       .probe = mx27vis_aic32x4_probe,
+       .remove = __devexit_p(mx27vis_aic32x4_remove),
+};
+
+module_platform_driver(mx27vis_aic32x4_audio_driver);
 
 MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");
 MODULE_DESCRIPTION("ALSA SoC AIC32X4 mx27 visstrim");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:mx27vis");
This page took 0.046647 seconds and 5 git commands to generate.