Kuninori Morimoto | a2911cd | 2013-07-03 21:15:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ak4554.c |
| 3 | * |
| 4 | * Copyright (C) 2013 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
| 13 | #include <sound/soc.h> |
| 14 | |
| 15 | /* |
| 16 | * ak4554 is very simple DA/AD converter which has no setting register. |
| 17 | * |
| 18 | * CAUTION |
| 19 | * |
| 20 | * ak4554 playback format is SND_SOC_DAIFMT_RIGHT_J, |
| 21 | * and, capture format is SND_SOC_DAIFMT_LEFT_J |
| 22 | * on same bit clock, LR clock. |
| 23 | * But, this driver doesn't have snd_soc_dai_ops :: set_fmt |
| 24 | * |
| 25 | * CPU/Codec DAI image |
| 26 | * |
| 27 | * CPU-DAI1 (plaback only fmt = RIGHT_J) --+-- ak4554 |
| 28 | * | |
| 29 | * CPU-DAI2 (capture only fmt = LEFT_J) ---+ |
| 30 | */ |
| 31 | |
Mark Brown | 4601736 | 2013-08-11 12:28:42 +0100 | [diff] [blame] | 32 | static const struct snd_soc_dapm_widget ak4554_dapm_widgets[] = { |
| 33 | SND_SOC_DAPM_INPUT("AINL"), |
| 34 | SND_SOC_DAPM_INPUT("AINR"), |
| 35 | |
| 36 | SND_SOC_DAPM_OUTPUT("AOUTL"), |
| 37 | SND_SOC_DAPM_OUTPUT("AOUTR"), |
| 38 | }; |
| 39 | |
| 40 | static const struct snd_soc_dapm_route ak4554_dapm_routes[] = { |
| 41 | { "Capture", NULL, "AINL" }, |
| 42 | { "Capture", NULL, "AINR" }, |
| 43 | |
| 44 | { "AOUTL", NULL, "Playback" }, |
| 45 | { "AOUTR", NULL, "Playback" }, |
| 46 | }; |
| 47 | |
Kuninori Morimoto | a2911cd | 2013-07-03 21:15:13 -0700 | [diff] [blame] | 48 | static struct snd_soc_dai_driver ak4554_dai = { |
| 49 | .name = "ak4554-hifi", |
| 50 | .playback = { |
| 51 | .stream_name = "Playback", |
| 52 | .channels_min = 2, |
| 53 | .channels_max = 2, |
| 54 | .rates = SNDRV_PCM_RATE_8000_48000, |
| 55 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 56 | }, |
| 57 | .capture = { |
| 58 | .stream_name = "Capture", |
| 59 | .channels_min = 2, |
| 60 | .channels_max = 2, |
| 61 | .rates = SNDRV_PCM_RATE_8000_48000, |
| 62 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 63 | }, |
| 64 | .symmetric_rates = 1, |
| 65 | }; |
| 66 | |
| 67 | static struct snd_soc_codec_driver soc_codec_dev_ak4554 = { |
Mark Brown | 4601736 | 2013-08-11 12:28:42 +0100 | [diff] [blame] | 68 | .dapm_widgets = ak4554_dapm_widgets, |
| 69 | .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets), |
| 70 | .dapm_routes = ak4554_dapm_routes, |
| 71 | .num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes), |
Kuninori Morimoto | a2911cd | 2013-07-03 21:15:13 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | static int ak4554_soc_probe(struct platform_device *pdev) |
| 75 | { |
| 76 | return snd_soc_register_codec(&pdev->dev, |
| 77 | &soc_codec_dev_ak4554, |
| 78 | &ak4554_dai, 1); |
| 79 | } |
| 80 | |
| 81 | static int ak4554_soc_remove(struct platform_device *pdev) |
| 82 | { |
| 83 | snd_soc_unregister_codec(&pdev->dev); |
| 84 | return 0; |
| 85 | } |
| 86 | |
Fabian Frederick | f7d4bfe | 2015-03-18 17:49:00 +0100 | [diff] [blame] | 87 | static const struct of_device_id ak4554_of_match[] = { |
Kuninori Morimoto | b25f778 | 2013-07-04 19:42:49 -0700 | [diff] [blame] | 88 | { .compatible = "asahi-kasei,ak4554" }, |
| 89 | {}, |
| 90 | }; |
| 91 | MODULE_DEVICE_TABLE(of, ak4554_of_match); |
| 92 | |
Kuninori Morimoto | a2911cd | 2013-07-03 21:15:13 -0700 | [diff] [blame] | 93 | static struct platform_driver ak4554_driver = { |
| 94 | .driver = { |
| 95 | .name = "ak4554-adc-dac", |
Kuninori Morimoto | b25f778 | 2013-07-04 19:42:49 -0700 | [diff] [blame] | 96 | .of_match_table = ak4554_of_match, |
Kuninori Morimoto | a2911cd | 2013-07-03 21:15:13 -0700 | [diff] [blame] | 97 | }, |
| 98 | .probe = ak4554_soc_probe, |
| 99 | .remove = ak4554_soc_remove, |
| 100 | }; |
| 101 | module_platform_driver(ak4554_driver); |
| 102 | |
| 103 | MODULE_LICENSE("GPL"); |
| 104 | MODULE_DESCRIPTION("SoC AK4554 driver"); |
| 105 | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); |