Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 1 | /* |
| 2 | * File: sound/soc/blackfin/bf5xx-ad1836.c |
| 3 | * Author: Barry Song <Barry.Song@analog.com> |
| 4 | * |
| 5 | * Created: Aug 4 2009 |
| 6 | * Description: Board driver for ad1836 sound chip |
| 7 | * |
| 8 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/moduleparam.h> |
| 19 | #include <linux/device.h> |
| 20 | #include <sound/core.h> |
| 21 | #include <sound/pcm.h> |
| 22 | #include <sound/soc.h> |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 23 | #include <sound/pcm_params.h> |
| 24 | |
| 25 | #include <asm/blackfin.h> |
| 26 | #include <asm/cacheflush.h> |
| 27 | #include <asm/irq.h> |
| 28 | #include <asm/dma.h> |
| 29 | #include <asm/portmux.h> |
| 30 | |
| 31 | #include "../codecs/ad1836.h" |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 32 | |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 33 | static struct snd_soc_card bf5xx_ad1836; |
| 34 | |
Lars-Peter Clausen | 34f4095 | 2013-05-28 19:22:16 +0200 | [diff] [blame] | 35 | static int bf5xx_ad1836_init(struct snd_soc_pcm_runtime *rtd) |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 36 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 37 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Barry Song | 08db48f | 2009-09-15 11:24:52 +0800 | [diff] [blame] | 38 | unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7}; |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 39 | int ret = 0; |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 40 | |
Barry Song | 08db48f | 2009-09-15 11:24:52 +0800 | [diff] [blame] | 41 | /* set cpu DAI channel mapping */ |
| 42 | ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map), |
| 43 | channel_map, ARRAY_SIZE(channel_map), channel_map); |
| 44 | if (ret < 0) |
| 45 | return ret; |
| 46 | |
Lars-Peter Clausen | 34f4095 | 2013-05-28 19:22:16 +0200 | [diff] [blame] | 47 | ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xFF, 0xFF, 8, 32); |
| 48 | if (ret < 0) |
| 49 | return ret; |
| 50 | |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
Lars-Peter Clausen | 980b0bc | 2012-02-01 19:24:21 +0100 | [diff] [blame] | 54 | #define BF5XX_AD1836_DAIFMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_IF | \ |
| 55 | SND_SOC_DAIFMT_CBM_CFM) |
| 56 | |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 57 | static struct snd_soc_dai_link bf5xx_ad1836_dai = { |
| 58 | .name = "ad1836", |
| 59 | .stream_name = "AD1836", |
| 60 | .codec_dai_name = "ad1836-hifi", |
Lars-Peter Clausen | 34f4095 | 2013-05-28 19:22:16 +0200 | [diff] [blame] | 61 | .platform_name = "bfin-i2s-pcm-audio", |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 62 | .dai_fmt = BF5XX_AD1836_DAIFMT, |
Lars-Peter Clausen | 34f4095 | 2013-05-28 19:22:16 +0200 | [diff] [blame] | 63 | .init = bf5xx_ad1836_init, |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | static struct snd_soc_card bf5xx_ad1836 = { |
Mike Frysinger | bfe4ee0 | 2011-03-28 01:45:09 -0400 | [diff] [blame] | 67 | .name = "bfin-ad1836", |
Axel Lin | 30e4953 | 2011-12-22 21:17:22 +0800 | [diff] [blame] | 68 | .owner = THIS_MODULE, |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 69 | .dai_link = &bf5xx_ad1836_dai, |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 70 | .num_links = 1, |
| 71 | }; |
| 72 | |
Bill Pemberton | dca66da | 2012-12-07 09:26:13 -0500 | [diff] [blame] | 73 | static int bf5xx_ad1836_driver_probe(struct platform_device *pdev) |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 74 | { |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 75 | struct snd_soc_card *card = &bf5xx_ad1836; |
| 76 | const char **link_name; |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 77 | int ret; |
| 78 | |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 79 | link_name = pdev->dev.platform_data; |
| 80 | if (!link_name) { |
| 81 | dev_err(&pdev->dev, "No platform data supplied\n"); |
| 82 | return -EINVAL; |
| 83 | } |
| 84 | bf5xx_ad1836_dai.cpu_dai_name = link_name[0]; |
| 85 | bf5xx_ad1836_dai.codec_name = link_name[1]; |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 86 | |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 87 | card->dev = &pdev->dev; |
| 88 | platform_set_drvdata(pdev, card); |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 89 | |
Axel Lin | 76b0d1f | 2015-08-30 17:17:44 +0800 | [diff] [blame] | 90 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 91 | if (ret) |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 92 | dev_err(&pdev->dev, "Failed to register card\n"); |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 93 | return ret; |
| 94 | } |
| 95 | |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 96 | static struct platform_driver bf5xx_ad1836_driver = { |
| 97 | .driver = { |
| 98 | .name = "bfin-snd-ad1836", |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 99 | .pm = &snd_soc_pm_ops, |
| 100 | }, |
| 101 | .probe = bf5xx_ad1836_driver_probe, |
Scott Jiang | d14a13d | 2012-08-10 18:06:08 -0400 | [diff] [blame] | 102 | }; |
| 103 | module_platform_driver(bf5xx_ad1836_driver); |
Barry Song | dce944d | 2009-09-01 12:45:14 +0800 | [diff] [blame] | 104 | |
| 105 | /* Module information */ |
| 106 | MODULE_AUTHOR("Barry Song"); |
| 107 | MODULE_DESCRIPTION("ALSA SoC AD1836 board driver"); |
| 108 | MODULE_LICENSE("GPL"); |
| 109 | |