linux/sound/soc/fsl/phycore-ac97.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2//
   3// phycore-ac97.c  --  SoC audio for imx_phycore in AC97 mode
   4//
   5// Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
   6
   7#include <linux/module.h>
   8#include <linux/moduleparam.h>
   9#include <linux/device.h>
  10#include <linux/i2c.h>
  11#include <sound/core.h>
  12#include <sound/pcm.h>
  13#include <sound/soc.h>
  14#include <asm/mach-types.h>
  15
  16#include "imx-audmux.h"
  17
  18static struct snd_soc_card imx_phycore;
  19
  20static const struct snd_soc_ops imx_phycore_hifi_ops = {
  21};
  22
  23static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
  24        {
  25                .name           = "HiFi",
  26                .stream_name    = "HiFi",
  27                .codec_dai_name         = "wm9712-hifi",
  28                .codec_name     = "wm9712-codec",
  29                .cpu_dai_name   = "imx-ssi.0",
  30                .platform_name  = "imx-ssi.0",
  31                .ops            = &imx_phycore_hifi_ops,
  32        },
  33};
  34
  35static struct snd_soc_card imx_phycore = {
  36        .name           = "PhyCORE-ac97-audio",
  37        .owner          = THIS_MODULE,
  38        .dai_link       = imx_phycore_dai_ac97,
  39        .num_links      = ARRAY_SIZE(imx_phycore_dai_ac97),
  40};
  41
  42static struct platform_device *imx_phycore_snd_ac97_device;
  43static struct platform_device *imx_phycore_snd_device;
  44
  45static int __init imx_phycore_init(void)
  46{
  47        int ret;
  48
  49        if (machine_is_pca100()) {
  50                imx_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
  51                        IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
  52                        IMX_AUDMUX_V1_PCR_TFCSEL(3) |
  53                        IMX_AUDMUX_V1_PCR_TCLKDIR | /* clock is output */
  54                        IMX_AUDMUX_V1_PCR_RXDSEL(3));
  55                imx_audmux_v1_configure_port(3,
  56                        IMX_AUDMUX_V1_PCR_SYN | /* 4wire mode */
  57                        IMX_AUDMUX_V1_PCR_TFCSEL(0) |
  58                        IMX_AUDMUX_V1_PCR_TFSDIR |
  59                        IMX_AUDMUX_V1_PCR_RXDSEL(0));
  60        } else if (machine_is_pcm043()) {
  61                imx_audmux_v2_configure_port(3,
  62                        IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
  63                        IMX_AUDMUX_V2_PTCR_TFSEL(0) |
  64                        IMX_AUDMUX_V2_PTCR_TFSDIR,
  65                        IMX_AUDMUX_V2_PDCR_RXDSEL(0));
  66                imx_audmux_v2_configure_port(0,
  67                        IMX_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
  68                        IMX_AUDMUX_V2_PTCR_TCSEL(3) |
  69                        IMX_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
  70                        IMX_AUDMUX_V2_PDCR_RXDSEL(3));
  71        } else {
  72                /* return happy. We might run on a totally different machine */
  73                return 0;
  74        }
  75
  76        imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
  77        if (!imx_phycore_snd_ac97_device)
  78                return -ENOMEM;
  79
  80        platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
  81        ret = platform_device_add(imx_phycore_snd_ac97_device);
  82        if (ret)
  83                goto fail1;
  84
  85        imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
  86        if (!imx_phycore_snd_device) {
  87                ret = -ENOMEM;
  88                goto fail2;
  89        }
  90        ret = platform_device_add(imx_phycore_snd_device);
  91
  92        if (ret) {
  93                printk(KERN_ERR "ASoC: Platform device allocation failed\n");
  94                goto fail3;
  95        }
  96
  97        return 0;
  98
  99fail3:
 100        platform_device_put(imx_phycore_snd_device);
 101fail2:
 102        platform_device_del(imx_phycore_snd_ac97_device);
 103fail1:
 104        platform_device_put(imx_phycore_snd_ac97_device);
 105        return ret;
 106}
 107
 108static void __exit imx_phycore_exit(void)
 109{
 110        platform_device_unregister(imx_phycore_snd_device);
 111        platform_device_unregister(imx_phycore_snd_ac97_device);
 112}
 113
 114late_initcall(imx_phycore_init);
 115module_exit(imx_phycore_exit);
 116
 117MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
 118MODULE_DESCRIPTION("PhyCORE ALSA SoC driver");
 119MODULE_LICENSE("GPL");
 120