lantiq: Use the BAR0 base address in the ath PCI fixup code
[openwrt/staging/wigyori.git] / target / linux / brcm2708 / patches-3.18 / 0060-Added-support-for-HiFiBerry-DAC.patch
1 From fb7a1cc51aee2d66232d3a170e1343dfbb7b3485 Mon Sep 17 00:00:00 2001
2 From: Daniel Matuschek <info@crazy-audio.com>
3 Date: Mon, 4 Aug 2014 10:06:56 +0200
4 Subject: [PATCH 060/114] Added support for HiFiBerry DAC+
5
6 The driver is based on the HiFiBerry DAC driver. However HiFiBerry DAC+ uses
7 a different codec chip (PCM5122), therefore a new driver is necessary.
8 ---
9 arch/arm/configs/bcmrpi_defconfig | 1 +
10 arch/arm/mach-bcm2708/bcm2708.c | 19 ++++++
11 sound/soc/bcm/Kconfig | 7 +++
12 sound/soc/bcm/Makefile | 2 +
13 sound/soc/bcm/hifiberry_dacplus.c | 119 ++++++++++++++++++++++++++++++++++++++
14 5 files changed, 148 insertions(+)
15 create mode 100644 sound/soc/bcm/hifiberry_dacplus.c
16
17 --- a/arch/arm/configs/bcmrpi_defconfig
18 +++ b/arch/arm/configs/bcmrpi_defconfig
19 @@ -756,6 +756,7 @@ CONFIG_SND_USB_6FIRE=m
20 CONFIG_SND_SOC=m
21 CONFIG_SND_BCM2708_SOC_I2S=m
22 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
23 +CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
24 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
25 CONFIG_SND_BCM2708_SOC_RPI_DAC=m
26 CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
27 --- a/arch/arm/mach-bcm2708/bcm2708.c
28 +++ b/arch/arm/mach-bcm2708/bcm2708.c
29 @@ -645,6 +645,20 @@ static struct platform_device snd_pcm510
30 };
31 #endif
32
33 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS_MODULE)
34 +static struct platform_device snd_rpi_hifiberry_dacplus_device = {
35 + .name = "snd-rpi-hifiberry-dacplus",
36 + .id = 0,
37 + .num_resources = 0,
38 +};
39 +
40 +static struct i2c_board_info __initdata snd_pcm512x_hbdacplus_i2c_devices[] = {
41 + {
42 + I2C_BOARD_INFO("pcm5122", 0x4d)
43 + },
44 +};
45 +#endif
46 +
47 #if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI_MODULE)
48 static struct platform_device snd_hifiberry_digi_device = {
49 .name = "snd-hifiberry-digi",
50 @@ -845,6 +859,11 @@ void __init bcm2708_init(void)
51 bcm_register_device(&snd_pcm5102a_codec_device);
52 #endif
53
54 +#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS_MODULE)
55 + bcm_register_device(&snd_rpi_hifiberry_dacplus_device);
56 + i2c_register_board_info(1, snd_pcm512x_hbdacplus_i2c_devices, ARRAY_SIZE(snd_pcm512x_hbdacplus_i2c_devices));
57 +#endif
58 +
59 #if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI_MODULE)
60 bcm_register_device(&snd_hifiberry_digi_device);
61 i2c_register_board_info(1, snd_wm8804_i2c_devices, ARRAY_SIZE(snd_wm8804_i2c_devices));
62 --- a/sound/soc/bcm/Kconfig
63 +++ b/sound/soc/bcm/Kconfig
64 @@ -26,6 +26,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DAC
65 help
66 Say Y or M if you want to add support for HifiBerry DAC.
67
68 +config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
69 + tristate "Support for HifiBerry DAC+"
70 + depends on SND_BCM2708_SOC_I2S
71 + select SND_SOC_PCM512x
72 + help
73 + Say Y or M if you want to add support for HifiBerry DAC+.
74 +
75 config SND_BCM2708_SOC_HIFIBERRY_DIGI
76 tristate "Support for HifiBerry Digi"
77 depends on SND_BCM2708_SOC_I2S
78 --- a/sound/soc/bcm/Makefile
79 +++ b/sound/soc/bcm/Makefile
80 @@ -10,11 +10,13 @@ obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd
81
82 # BCM2708 Machine Support
83 snd-soc-hifiberry-dac-objs := hifiberry_dac.o
84 +snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
85 snd-soc-hifiberry-digi-objs := hifiberry_digi.o
86 snd-soc-rpi-dac-objs := rpi-dac.o
87 snd-soc-iqaudio-dac-objs := iqaudio-dac.o
88
89 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
90 +obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
91 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) += snd-soc-hifiberry-digi.o
92 obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
93 obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
94 --- /dev/null
95 +++ b/sound/soc/bcm/hifiberry_dacplus.c
96 @@ -0,0 +1,119 @@
97 +/*
98 + * ASoC Driver for HiFiBerry DAC+
99 + *
100 + * Author: Daniel Matuschek
101 + * Copyright 2014
102 + * based on code by Florian Meier <florian.meier@koalo.de>
103 + *
104 + * This program is free software; you can redistribute it and/or
105 + * modify it under the terms of the GNU General Public License
106 + * version 2 as published by the Free Software Foundation.
107 + *
108 + * This program is distributed in the hope that it will be useful, but
109 + * WITHOUT ANY WARRANTY; without even the implied warranty of
110 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
111 + * General Public License for more details.
112 + */
113 +
114 +#include <linux/module.h>
115 +#include <linux/platform_device.h>
116 +
117 +#include <sound/core.h>
118 +#include <sound/pcm.h>
119 +#include <sound/pcm_params.h>
120 +#include <sound/soc.h>
121 +#include <sound/jack.h>
122 +
123 +#include "../codecs/pcm512x.h"
124 +
125 +static int snd_rpi_hifiberry_dacplus_init(struct snd_soc_pcm_runtime *rtd)
126 +{
127 + struct snd_soc_codec *codec = rtd->codec;
128 + snd_soc_update_bits(codec, PCM512x_GPIO_EN, 0x08, 0x08);
129 + snd_soc_update_bits(codec, PCM512x_GPIO_OUTPUT_4, 0xf, 0x02);
130 + snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x08);
131 + return 0;
132 +}
133 +
134 +static int snd_rpi_hifiberry_dacplus_hw_params(struct snd_pcm_substream *substream,
135 + struct snd_pcm_hw_params *params)
136 +{
137 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
138 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
139 + return snd_soc_dai_set_bclk_ratio(cpu_dai, 64);
140 +}
141 +
142 +static int snd_rpi_hifiberry_dacplus_startup(struct snd_pcm_substream *substream) {
143 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
144 + struct snd_soc_codec *codec = rtd->codec;
145 + snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x08);
146 + return 0;
147 +}
148 +
149 +static void snd_rpi_hifiberry_dacplus_shutdown(struct snd_pcm_substream *substream) {
150 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
151 + struct snd_soc_codec *codec = rtd->codec;
152 + snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x00);
153 +}
154 +
155 +/* machine stream operations */
156 +static struct snd_soc_ops snd_rpi_hifiberry_dacplus_ops = {
157 + .hw_params = snd_rpi_hifiberry_dacplus_hw_params,
158 + .startup = snd_rpi_hifiberry_dacplus_startup,
159 + .shutdown = snd_rpi_hifiberry_dacplus_shutdown,
160 +};
161 +
162 +static struct snd_soc_dai_link snd_rpi_hifiberry_dacplus_dai[] = {
163 +{
164 + .name = "HiFiBerry DAC+",
165 + .stream_name = "HiFiBerry DAC+ HiFi",
166 + .cpu_dai_name = "bcm2708-i2s.0",
167 + .codec_dai_name = "pcm512x-hifi",
168 + .platform_name = "bcm2708-i2s.0",
169 + .codec_name = "pcm512x.1-004d",
170 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
171 + SND_SOC_DAIFMT_CBS_CFS,
172 + .ops = &snd_rpi_hifiberry_dacplus_ops,
173 + .init = snd_rpi_hifiberry_dacplus_init,
174 +},
175 +};
176 +
177 +/* audio machine driver */
178 +static struct snd_soc_card snd_rpi_hifiberry_dacplus = {
179 + .name = "snd_rpi_hifiberry_dacplus",
180 + .dai_link = snd_rpi_hifiberry_dacplus_dai,
181 + .num_links = ARRAY_SIZE(snd_rpi_hifiberry_dacplus_dai),
182 +};
183 +
184 +static int snd_rpi_hifiberry_dacplus_probe(struct platform_device *pdev)
185 +{
186 + int ret = 0;
187 +
188 + snd_rpi_hifiberry_dacplus.dev = &pdev->dev;
189 + ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus);
190 + if (ret)
191 + dev_err(&pdev->dev,
192 + "snd_soc_register_card() failed: %d\n", ret);
193 +
194 + return ret;
195 +}
196 +
197 +static int snd_rpi_hifiberry_dacplus_remove(struct platform_device *pdev)
198 +{
199 + return snd_soc_unregister_card(&snd_rpi_hifiberry_dacplus);
200 +}
201 +
202 +static struct platform_driver snd_rpi_hifiberry_dacplus_driver = {
203 + .driver = {
204 + .name = "snd-rpi-hifiberry-dacplus",
205 + .owner = THIS_MODULE,
206 + },
207 + .probe = snd_rpi_hifiberry_dacplus_probe,
208 + .remove = snd_rpi_hifiberry_dacplus_remove,
209 +};
210 +
211 +module_platform_driver(snd_rpi_hifiberry_dacplus_driver);
212 +
213 +MODULE_AUTHOR("Daniel Matuschek <daniel@hifiberry.com>");
214 +MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+");
215 +MODULE_LICENSE("GPL v2");