linux/sound/soc/cirrus/snappercl15.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-or-later
   2/*
   3 * snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
   4 *
   5 * Copyright (C) 2008 Bluewater Systems Ltd
   6 * Author: Ryan Mallon
   7 */
   8
   9#include <linux/platform_device.h>
  10#include <linux/module.h>
  11#include <linux/soc/cirrus/ep93xx.h>
  12#include <sound/core.h>
  13#include <sound/pcm.h>
  14#include <sound/soc.h>
  15
  16#include <asm/mach-types.h>
  17
  18#include "../codecs/tlv320aic23.h"
  19
  20#define CODEC_CLOCK 5644800
  21
  22static int snappercl15_hw_params(struct snd_pcm_substream *substream,
  23                                 struct snd_pcm_hw_params *params)
  24{
  25        struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
  26        struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
  27        struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
  28        int err;
  29
  30        err = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK, 
  31                                     SND_SOC_CLOCK_IN);
  32        if (err)
  33                return err;
  34
  35        err = snd_soc_dai_set_sysclk(cpu_dai, 0, CODEC_CLOCK, 
  36                                     SND_SOC_CLOCK_OUT);
  37        if (err)
  38                return err;
  39
  40        return 0;
  41}
  42
  43static const struct snd_soc_ops snappercl15_ops = {
  44        .hw_params      = snappercl15_hw_params,
  45};
  46
  47static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = {
  48        SND_SOC_DAPM_HP("Headphone Jack", NULL),
  49        SND_SOC_DAPM_LINE("Line In", NULL),
  50        SND_SOC_DAPM_MIC("Mic Jack", NULL),
  51};
  52
  53static const struct snd_soc_dapm_route audio_map[] = {
  54        {"Headphone Jack", NULL, "LHPOUT"},
  55        {"Headphone Jack", NULL, "RHPOUT"},
  56
  57        {"LLINEIN", NULL, "Line In"},
  58        {"RLINEIN", NULL, "Line In"},
  59
  60        {"MICIN", NULL, "Mic Jack"},
  61};
  62
  63SND_SOC_DAILINK_DEFS(aic23,
  64        DAILINK_COMP_ARRAY(COMP_CPU("ep93xx-i2s")),
  65        DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic23-codec.0-001a",
  66                                      "tlv320aic23-hifi")),
  67        DAILINK_COMP_ARRAY(COMP_PLATFORM("ep93xx-i2s")));
  68
  69static struct snd_soc_dai_link snappercl15_dai = {
  70        .name           = "tlv320aic23",
  71        .stream_name    = "AIC23",
  72        .dai_fmt        = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  73                          SND_SOC_DAIFMT_CBS_CFS,
  74        .ops            = &snappercl15_ops,
  75        SND_SOC_DAILINK_REG(aic23),
  76};
  77
  78static struct snd_soc_card snd_soc_snappercl15 = {
  79        .name           = "Snapper CL15",
  80        .owner          = THIS_MODULE,
  81        .dai_link       = &snappercl15_dai,
  82        .num_links      = 1,
  83
  84        .dapm_widgets           = tlv320aic23_dapm_widgets,
  85        .num_dapm_widgets       = ARRAY_SIZE(tlv320aic23_dapm_widgets),
  86        .dapm_routes            = audio_map,
  87        .num_dapm_routes        = ARRAY_SIZE(audio_map),
  88};
  89
  90static int snappercl15_probe(struct platform_device *pdev)
  91{
  92        struct snd_soc_card *card = &snd_soc_snappercl15;
  93        int ret;
  94
  95        ret = ep93xx_i2s_acquire();
  96        if (ret)
  97                return ret;
  98
  99        card->dev = &pdev->dev;
 100
 101        ret = snd_soc_register_card(card);
 102        if (ret) {
 103                dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 104                        ret);
 105                ep93xx_i2s_release();
 106        }
 107
 108        return ret;
 109}
 110
 111static int snappercl15_remove(struct platform_device *pdev)
 112{
 113        struct snd_soc_card *card = platform_get_drvdata(pdev);
 114
 115        snd_soc_unregister_card(card);
 116        ep93xx_i2s_release();
 117
 118        return 0;
 119}
 120
 121static struct platform_driver snappercl15_driver = {
 122        .driver         = {
 123                .name   = "snappercl15-audio",
 124        },
 125        .probe          = snappercl15_probe,
 126        .remove         = snappercl15_remove,
 127};
 128
 129module_platform_driver(snappercl15_driver);
 130
 131MODULE_AUTHOR("Ryan Mallon");
 132MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
 133MODULE_LICENSE("GPL");
 134MODULE_ALIAS("platform:snappercl15-audio");
 135