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 = substream->private_data;
  26        struct snd_soc_dai *codec_dai = rtd->codec_dai;
  27        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  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
  63static struct snd_soc_dai_link snappercl15_dai = {
  64        .name           = "tlv320aic23",
  65        .stream_name    = "AIC23",
  66        .cpu_dai_name   = "ep93xx-i2s",
  67        .codec_dai_name = "tlv320aic23-hifi",
  68        .codec_name     = "tlv320aic23-codec.0-001a",
  69        .platform_name  = "ep93xx-i2s",
  70        .dai_fmt        = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  71                          SND_SOC_DAIFMT_CBS_CFS,
  72        .ops            = &snappercl15_ops,
  73};
  74
  75static struct snd_soc_card snd_soc_snappercl15 = {
  76        .name           = "Snapper CL15",
  77        .owner          = THIS_MODULE,
  78        .dai_link       = &snappercl15_dai,
  79        .num_links      = 1,
  80
  81        .dapm_widgets           = tlv320aic23_dapm_widgets,
  82        .num_dapm_widgets       = ARRAY_SIZE(tlv320aic23_dapm_widgets),
  83        .dapm_routes            = audio_map,
  84        .num_dapm_routes        = ARRAY_SIZE(audio_map),
  85};
  86
  87static int snappercl15_probe(struct platform_device *pdev)
  88{
  89        struct snd_soc_card *card = &snd_soc_snappercl15;
  90        int ret;
  91
  92        ret = ep93xx_i2s_acquire();
  93        if (ret)
  94                return ret;
  95
  96        card->dev = &pdev->dev;
  97
  98        ret = snd_soc_register_card(card);
  99        if (ret) {
 100                dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
 101                        ret);
 102                ep93xx_i2s_release();
 103        }
 104
 105        return ret;
 106}
 107
 108static int snappercl15_remove(struct platform_device *pdev)
 109{
 110        struct snd_soc_card *card = platform_get_drvdata(pdev);
 111
 112        snd_soc_unregister_card(card);
 113        ep93xx_i2s_release();
 114
 115        return 0;
 116}
 117
 118static struct platform_driver snappercl15_driver = {
 119        .driver         = {
 120                .name   = "snappercl15-audio",
 121        },
 122        .probe          = snappercl15_probe,
 123        .remove         = snappercl15_remove,
 124};
 125
 126module_platform_driver(snappercl15_driver);
 127
 128MODULE_AUTHOR("Ryan Mallon");
 129MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
 130MODULE_LICENSE("GPL");
 131MODULE_ALIAS("platform:snappercl15-audio");
 132