Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 1 | /* |
| 2 | * FSI-AK464x sound support for ms7724se |
| 3 | * |
| 4 | * Copyright (C) 2009 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <morimoto.kuninori@renesas.com> |
| 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License. See the file "COPYING" in the main directory of this archive |
| 9 | * for more details. |
| 10 | */ |
| 11 | |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 13 | #include <linux/module.h> |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 14 | #include <sound/sh_fsi.h> |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 15 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 16 | struct fsi_ak4642_data { |
| 17 | const char *name; |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 18 | const char *card; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 19 | const char *cpu_dai; |
| 20 | const char *codec; |
| 21 | const char *platform; |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame] | 22 | int id; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 23 | }; |
| 24 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 25 | static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 26 | { |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 27 | struct snd_soc_dai *codec = rtd->codec_dai; |
| 28 | struct snd_soc_dai *cpu = rtd->cpu_dai; |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 29 | int ret; |
| 30 | |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 31 | ret = snd_soc_dai_set_fmt(codec, SND_SOC_DAIFMT_LEFT_J | |
| 32 | SND_SOC_DAIFMT_CBM_CFM); |
Kuninori Morimoto | 0643ce8 | 2010-03-15 18:10:50 +0900 | [diff] [blame] | 33 | if (ret < 0) |
| 34 | return ret; |
| 35 | |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 36 | ret = snd_soc_dai_set_sysclk(codec, 0, 11289600, 0); |
| 37 | if (ret < 0) |
| 38 | return ret; |
| 39 | |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 40 | ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_LEFT_J | |
| 41 | SND_SOC_DAIFMT_CBS_CFS); |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 42 | |
| 43 | return ret; |
| 44 | } |
| 45 | |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 46 | static struct snd_soc_dai_link fsi_dai_link = { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 47 | .codec_dai_name = "ak4642-hifi", |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 48 | .init = fsi_ak4642_dai_init, |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | static struct snd_soc_card fsi_soc_card = { |
Axel Lin | 4a7042e | 2011-12-23 14:53:32 +0800 | [diff] [blame] | 52 | .owner = THIS_MODULE, |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 53 | .dai_link = &fsi_dai_link, |
| 54 | .num_links = 1, |
| 55 | }; |
| 56 | |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 57 | static struct platform_device *fsi_snd_device; |
| 58 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 59 | static int fsi_ak4642_probe(struct platform_device *pdev) |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 60 | { |
| 61 | int ret = -ENOMEM; |
Kuninori Morimoto | 45f3121 | 2011-11-23 16:55:34 -0800 | [diff] [blame] | 62 | struct fsi_ak4642_info *pinfo = pdev->dev.platform_data; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 63 | |
Kuninori Morimoto | 45f3121 | 2011-11-23 16:55:34 -0800 | [diff] [blame] | 64 | if (!pinfo) { |
| 65 | dev_err(&pdev->dev, "no info for fsi ak4642\n"); |
| 66 | goto out; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 67 | } |
| 68 | |
Kuninori Morimoto | 45f3121 | 2011-11-23 16:55:34 -0800 | [diff] [blame] | 69 | fsi_snd_device = platform_device_alloc("soc-audio", pinfo->id); |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 70 | if (!fsi_snd_device) |
| 71 | goto out; |
| 72 | |
Kuninori Morimoto | 45f3121 | 2011-11-23 16:55:34 -0800 | [diff] [blame] | 73 | fsi_dai_link.name = pinfo->name; |
| 74 | fsi_dai_link.stream_name = pinfo->name; |
| 75 | fsi_dai_link.cpu_dai_name = pinfo->cpu_dai; |
| 76 | fsi_dai_link.platform_name = pinfo->platform; |
| 77 | fsi_dai_link.codec_name = pinfo->codec; |
| 78 | fsi_soc_card.name = pinfo->card; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 79 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 80 | platform_set_drvdata(fsi_snd_device, &fsi_soc_card); |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 81 | ret = platform_device_add(fsi_snd_device); |
| 82 | |
| 83 | if (ret) |
| 84 | platform_device_put(fsi_snd_device); |
| 85 | |
| 86 | out: |
| 87 | return ret; |
| 88 | } |
| 89 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 90 | static int fsi_ak4642_remove(struct platform_device *pdev) |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 91 | { |
| 92 | platform_device_unregister(fsi_snd_device); |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 93 | return 0; |
| 94 | } |
| 95 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 96 | static struct platform_driver fsi_ak4642 = { |
| 97 | .driver = { |
| 98 | .name = "fsi-ak4642-audio", |
| 99 | }, |
| 100 | .probe = fsi_ak4642_probe, |
| 101 | .remove = fsi_ak4642_remove, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 102 | }; |
| 103 | |
Axel Lin | cb5e873 | 2011-11-25 10:15:07 +0800 | [diff] [blame] | 104 | module_platform_driver(fsi_ak4642); |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 105 | |
| 106 | MODULE_LICENSE("GPL"); |
| 107 | MODULE_DESCRIPTION("Generic SH4 FSI-AK4642 sound card"); |
| 108 | MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>"); |