Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 // ak4554.c
0003 //
0004 // Copyright (C) 2013 Renesas Solutions Corp.
0005 // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
0006 
0007 #include <linux/module.h>
0008 #include <sound/soc.h>
0009 
0010 /*
0011  * ak4554 is very simple DA/AD converter which has no setting register.
0012  *
0013  * CAUTION
0014  *
0015  * ak4554 playback format is SND_SOC_DAIFMT_RIGHT_J,
0016  * and,   capture  format is SND_SOC_DAIFMT_LEFT_J
0017  * on same bit clock, LR clock.
0018  * But, this driver doesn't have snd_soc_dai_ops :: set_fmt
0019  *
0020  * CPU/Codec DAI image
0021  *
0022  * CPU-DAI1 (plaback only fmt = RIGHT_J) --+-- ak4554
0023  *                     |
0024  * CPU-DAI2 (capture only fmt = LEFT_J) ---+
0025  */
0026 
0027 static const struct snd_soc_dapm_widget ak4554_dapm_widgets[] = {
0028 SND_SOC_DAPM_INPUT("AINL"),
0029 SND_SOC_DAPM_INPUT("AINR"),
0030 
0031 SND_SOC_DAPM_OUTPUT("AOUTL"),
0032 SND_SOC_DAPM_OUTPUT("AOUTR"),
0033 };
0034 
0035 static const struct snd_soc_dapm_route ak4554_dapm_routes[] = {
0036     { "Capture", NULL, "AINL" },
0037     { "Capture", NULL, "AINR" },
0038 
0039     { "AOUTL", NULL, "Playback" },
0040     { "AOUTR", NULL, "Playback" },
0041 };
0042 
0043 static struct snd_soc_dai_driver ak4554_dai = {
0044     .name = "ak4554-hifi",
0045     .playback = {
0046         .stream_name = "Playback",
0047         .channels_min = 2,
0048         .channels_max = 2,
0049         .rates = SNDRV_PCM_RATE_8000_48000,
0050         .formats = SNDRV_PCM_FMTBIT_S16_LE,
0051     },
0052     .capture = {
0053         .stream_name = "Capture",
0054         .channels_min = 2,
0055         .channels_max = 2,
0056         .rates = SNDRV_PCM_RATE_8000_48000,
0057         .formats = SNDRV_PCM_FMTBIT_S16_LE,
0058     },
0059     .symmetric_rate = 1,
0060 };
0061 
0062 static const struct snd_soc_component_driver soc_component_dev_ak4554 = {
0063     .dapm_widgets       = ak4554_dapm_widgets,
0064     .num_dapm_widgets   = ARRAY_SIZE(ak4554_dapm_widgets),
0065     .dapm_routes        = ak4554_dapm_routes,
0066     .num_dapm_routes    = ARRAY_SIZE(ak4554_dapm_routes),
0067     .idle_bias_on       = 1,
0068     .use_pmdown_time    = 1,
0069     .endianness     = 1,
0070 };
0071 
0072 static int ak4554_soc_probe(struct platform_device *pdev)
0073 {
0074     return devm_snd_soc_register_component(&pdev->dev,
0075                       &soc_component_dev_ak4554,
0076                       &ak4554_dai, 1);
0077 }
0078 
0079 static const struct of_device_id ak4554_of_match[] = {
0080     { .compatible = "asahi-kasei,ak4554" },
0081     {},
0082 };
0083 MODULE_DEVICE_TABLE(of, ak4554_of_match);
0084 
0085 static struct platform_driver ak4554_driver = {
0086     .driver = {
0087         .name = "ak4554-adc-dac",
0088         .of_match_table = ak4554_of_match,
0089     },
0090     .probe  = ak4554_soc_probe,
0091 };
0092 module_platform_driver(ak4554_driver);
0093 
0094 MODULE_LICENSE("GPL v2");
0095 MODULE_DESCRIPTION("SoC AK4554 driver");
0096 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");