2019-05-27 08:55:01 +02:00
// SPDX-License-Identifier: GPL-2.0-or-later
2010-06-08 22:01:12 +12:00
/*
* snappercl15 . c - - SoC audio for Bluewater Systems Snapper CL15 module
*
* Copyright ( C ) 2008 Bluewater Systems Ltd
2011-06-15 14:45:36 +10:00
* Author : Ryan Mallon
2010-06-08 22:01:12 +12:00
*/
# include <linux/platform_device.h>
2011-07-15 12:38:28 -04:00
# include <linux/module.h>
2019-04-15 22:17:11 +02:00
# include <linux/soc/cirrus/ep93xx.h>
2010-06-08 22:01:12 +12:00
# include <sound/core.h>
# include <sound/pcm.h>
# include <sound/soc.h>
# include <asm/mach-types.h>
# include "../codecs/tlv320aic23.h"
# define CODEC_CLOCK 5644800
static int snappercl15_hw_params ( struct snd_pcm_substream * substream ,
struct snd_pcm_hw_params * params )
{
2020-07-20 10:18:24 +09:00
struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd ( substream ) ;
2020-03-23 14:18:11 +09:00
struct snd_soc_dai * codec_dai = asoc_rtd_to_codec ( rtd , 0 ) ;
struct snd_soc_dai * cpu_dai = asoc_rtd_to_cpu ( rtd , 0 ) ;
2010-06-08 22:01:12 +12:00
int err ;
err = snd_soc_dai_set_sysclk ( codec_dai , 0 , CODEC_CLOCK ,
SND_SOC_CLOCK_IN ) ;
if ( err )
return err ;
err = snd_soc_dai_set_sysclk ( cpu_dai , 0 , CODEC_CLOCK ,
SND_SOC_CLOCK_OUT ) ;
if ( err )
return err ;
return 0 ;
}
2017-08-16 22:29:25 +05:30
static const struct snd_soc_ops snappercl15_ops = {
2010-06-08 22:01:12 +12:00
. hw_params = snappercl15_hw_params ,
} ;
static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets [ ] = {
SND_SOC_DAPM_HP ( " Headphone Jack " , NULL ) ,
SND_SOC_DAPM_LINE ( " Line In " , NULL ) ,
SND_SOC_DAPM_MIC ( " Mic Jack " , NULL ) ,
} ;
static const struct snd_soc_dapm_route audio_map [ ] = {
{ " Headphone Jack " , NULL , " LHPOUT " } ,
{ " Headphone Jack " , NULL , " RHPOUT " } ,
{ " LLINEIN " , NULL , " Line In " } ,
{ " RLINEIN " , NULL , " Line In " } ,
{ " MICIN " , NULL , " Mic Jack " } ,
} ;
2019-06-06 13:14:28 +09:00
SND_SOC_DAILINK_DEFS ( aic23 ,
DAILINK_COMP_ARRAY ( COMP_CPU ( " ep93xx-i2s " ) ) ,
DAILINK_COMP_ARRAY ( COMP_CODEC ( " tlv320aic23-codec.0-001a " ,
" tlv320aic23-hifi " ) ) ,
DAILINK_COMP_ARRAY ( COMP_PLATFORM ( " ep93xx-i2s " ) ) ) ;
2010-06-08 22:01:12 +12:00
static struct snd_soc_dai_link snappercl15_dai = {
. name = " tlv320aic23 " ,
. stream_name = " AIC23 " ,
2018-04-28 22:51:38 +02:00
. dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
2021-09-16 15:38:28 +01:00
SND_SOC_DAIFMT_CBC_CFC ,
2010-06-08 22:01:12 +12:00
. ops = & snappercl15_ops ,
2019-06-06 13:14:28 +09:00
SND_SOC_DAILINK_REG ( aic23 ) ,
2010-06-08 22:01:12 +12:00
} ;
static struct snd_soc_card snd_soc_snappercl15 = {
. name = " Snapper CL15 " ,
2011-12-22 21:21:37 +08:00
. owner = THIS_MODULE ,
2010-06-08 22:01:12 +12:00
. dai_link = & snappercl15_dai ,
. num_links = 1 ,
2014-03-12 15:27:36 +01:00
. dapm_widgets = tlv320aic23_dapm_widgets ,
. num_dapm_widgets = ARRAY_SIZE ( tlv320aic23_dapm_widgets ) ,
. dapm_routes = audio_map ,
. num_dapm_routes = ARRAY_SIZE ( audio_map ) ,
2010-06-08 22:01:12 +12:00
} ;
2012-12-07 09:26:23 -05:00
static int snappercl15_probe ( struct platform_device * pdev )
2010-06-08 22:01:12 +12:00
{
2011-09-11 12:28:52 +03:00
struct snd_soc_card * card = & snd_soc_snappercl15 ;
2010-06-08 22:01:12 +12:00
int ret ;
2012-01-11 14:14:31 +11:00
ret = ep93xx_i2s_acquire ( ) ;
2010-06-08 22:01:12 +12:00
if ( ret )
return ret ;
2011-09-11 12:28:52 +03:00
card - > dev = & pdev - > dev ;
ret = snd_soc_register_card ( card ) ;
if ( ret ) {
dev_err ( & pdev - > dev , " snd_soc_register_card() failed: %d \n " ,
ret ) ;
ep93xx_i2s_release ( ) ;
}
2010-06-08 22:01:12 +12:00
return ret ;
}
2012-12-07 09:26:23 -05:00
static int snappercl15_remove ( struct platform_device * pdev )
2010-06-08 22:01:12 +12:00
{
2011-09-11 12:28:52 +03:00
struct snd_soc_card * card = platform_get_drvdata ( pdev ) ;
snd_soc_unregister_card ( card ) ;
2010-06-08 22:01:12 +12:00
ep93xx_i2s_release ( ) ;
2011-09-11 12:28:52 +03:00
return 0 ;
}
static struct platform_driver snappercl15_driver = {
. driver = {
. name = " snappercl15-audio " ,
} ,
. probe = snappercl15_probe ,
2012-12-07 09:26:23 -05:00
. remove = snappercl15_remove ,
2011-09-11 12:28:52 +03:00
} ;
2011-11-24 12:07:55 +08:00
module_platform_driver ( snappercl15_driver ) ;
2010-06-08 22:01:12 +12:00
2011-06-15 14:45:36 +10:00
MODULE_AUTHOR ( " Ryan Mallon " ) ;
2010-06-08 22:01:12 +12:00
MODULE_DESCRIPTION ( " ALSA SoC Snapper CL15 " ) ;
MODULE_LICENSE ( " GPL " ) ;
2011-09-11 12:28:52 +03:00
MODULE_ALIAS ( " platform:snappercl15-audio " ) ;