2019-05-19 06:08:20 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-07-29 04:42:31 -06:00
|
|
|
/*
|
|
|
|
* Texas Instruments TLV320AIC26 low power audio CODEC
|
|
|
|
* ALSA SoC CODEC driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Secret Lab Technologies Ltd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
#include <linux/spi/spi.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2008-07-29 04:42:31 -06:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/pcm_params.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
|
|
|
|
#include "tlv320aic26.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("ASoC TLV320AIC26 codec driver");
|
|
|
|
MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/* AIC26 driver private data */
|
|
|
|
struct aic26 {
|
|
|
|
struct spi_device *spi;
|
2013-09-25 06:29:44 -06:00
|
|
|
struct regmap *regmap;
|
2018-01-28 21:13:13 -07:00
|
|
|
struct snd_soc_component *component;
|
2008-07-29 04:42:31 -06:00
|
|
|
int master;
|
|
|
|
int datfm;
|
|
|
|
int mclk;
|
|
|
|
|
|
|
|
/* Keyclick parameters */
|
|
|
|
int keyclick_amplitude;
|
|
|
|
int keyclick_freq;
|
|
|
|
int keyclick_len;
|
|
|
|
};
|
|
|
|
|
2013-08-16 05:24:47 -06:00
|
|
|
static const struct snd_soc_dapm_widget tlv320aic26_dapm_widgets[] = {
|
|
|
|
SND_SOC_DAPM_INPUT("MICIN"),
|
|
|
|
SND_SOC_DAPM_INPUT("AUX"),
|
|
|
|
|
|
|
|
SND_SOC_DAPM_OUTPUT("HPL"),
|
|
|
|
SND_SOC_DAPM_OUTPUT("HPR"),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_route tlv320aic26_dapm_routes[] = {
|
|
|
|
{ "Capture", NULL, "MICIN" },
|
|
|
|
{ "Capture", NULL, "AUX" },
|
|
|
|
|
|
|
|
{ "HPL", NULL, "Playback" },
|
|
|
|
{ "HPR", NULL, "Playback" },
|
|
|
|
};
|
|
|
|
|
2008-07-29 04:42:31 -06:00
|
|
|
/* ---------------------------------------------------------------------
|
|
|
|
* Digital Audio Interface Operations
|
|
|
|
*/
|
|
|
|
static int aic26_hw_params(struct snd_pcm_substream *substream,
|
2008-11-18 15:11:38 -07:00
|
|
|
struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_soc_dai *dai)
|
2008-07-29 04:42:31 -06:00
|
|
|
{
|
2018-01-28 21:13:13 -07:00
|
|
|
struct snd_soc_component *component = dai->component;
|
|
|
|
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
|
2008-07-29 04:42:31 -06:00
|
|
|
int fsref, divisor, wlen, pval, jval, dval, qval;
|
|
|
|
u16 reg;
|
|
|
|
|
|
|
|
dev_dbg(&aic26->spi->dev, "aic26_hw_params(substream=%p, params=%p)\n",
|
|
|
|
substream, params);
|
2014-07-31 05:48:04 -06:00
|
|
|
dev_dbg(&aic26->spi->dev, "rate=%i width=%d\n", params_rate(params),
|
|
|
|
params_width(params));
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
switch (params_rate(params)) {
|
|
|
|
case 8000: fsref = 48000; divisor = AIC26_DIV_6; break;
|
|
|
|
case 11025: fsref = 44100; divisor = AIC26_DIV_4; break;
|
|
|
|
case 12000: fsref = 48000; divisor = AIC26_DIV_4; break;
|
|
|
|
case 16000: fsref = 48000; divisor = AIC26_DIV_3; break;
|
|
|
|
case 22050: fsref = 44100; divisor = AIC26_DIV_2; break;
|
|
|
|
case 24000: fsref = 48000; divisor = AIC26_DIV_2; break;
|
|
|
|
case 32000: fsref = 48000; divisor = AIC26_DIV_1_5; break;
|
|
|
|
case 44100: fsref = 44100; divisor = AIC26_DIV_1; break;
|
|
|
|
case 48000: fsref = 48000; divisor = AIC26_DIV_1; break;
|
|
|
|
default:
|
|
|
|
dev_dbg(&aic26->spi->dev, "bad rate\n"); return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* select data word length */
|
2014-07-31 05:48:04 -06:00
|
|
|
switch (params_width(params)) {
|
|
|
|
case 8: wlen = AIC26_WLEN_16; break;
|
|
|
|
case 16: wlen = AIC26_WLEN_16; break;
|
|
|
|
case 24: wlen = AIC26_WLEN_24; break;
|
|
|
|
case 32: wlen = AIC26_WLEN_32; break;
|
2008-07-29 04:42:31 -06:00
|
|
|
default:
|
|
|
|
dev_dbg(&aic26->spi->dev, "bad format\n"); return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-05-20 08:26:06 -06:00
|
|
|
/**
|
|
|
|
* Configure PLL
|
|
|
|
* fsref = (mclk * PLLM) / 2048
|
|
|
|
* where PLLM = J.DDDD (DDDD register ranges from 0 to 9999, decimal)
|
|
|
|
*/
|
2008-07-29 04:42:31 -06:00
|
|
|
pval = 1;
|
2011-05-20 08:26:06 -06:00
|
|
|
/* compute J portion of multiplier */
|
|
|
|
jval = fsref / (aic26->mclk / 2048);
|
|
|
|
/* compute fractional DDDD component of multiplier */
|
|
|
|
dval = fsref - (jval * (aic26->mclk / 2048));
|
|
|
|
dval = (10000 * dval) / (aic26->mclk / 2048);
|
|
|
|
dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval);
|
2008-07-29 04:42:31 -06:00
|
|
|
qval = 0;
|
|
|
|
reg = 0x8000 | qval << 11 | pval << 8 | jval << 2;
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_write(component, AIC26_REG_PLL_PROG1, reg);
|
2008-07-29 04:42:31 -06:00
|
|
|
reg = dval << 2;
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_write(component, AIC26_REG_PLL_PROG2, reg);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
/* Audio Control 3 (master mode, fsref rate) */
|
|
|
|
if (aic26->master)
|
2013-09-25 06:14:41 -06:00
|
|
|
reg = 0x0800;
|
2008-07-29 04:42:31 -06:00
|
|
|
if (fsref == 48000)
|
2013-09-25 06:14:41 -06:00
|
|
|
reg = 0x2000;
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL3, 0xf800, reg);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
/* Audio Control 1 (FSref divisor) */
|
2013-09-25 06:14:41 -06:00
|
|
|
reg = wlen | aic26->datfm | (divisor << 3) | divisor;
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL1, 0xfff, reg);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aic26_mute - Mute control to reduce noise when changing audio format
|
|
|
|
*/
|
|
|
|
static int aic26_mute(struct snd_soc_dai *dai, int mute)
|
|
|
|
{
|
2018-01-28 21:13:13 -07:00
|
|
|
struct snd_soc_component *component = dai->component;
|
|
|
|
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
|
2013-09-25 06:14:41 -06:00
|
|
|
u16 reg;
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n",
|
|
|
|
dai, mute);
|
|
|
|
|
|
|
|
if (mute)
|
2013-09-25 06:14:41 -06:00
|
|
|
reg = 0x8080;
|
2008-07-29 04:42:31 -06:00
|
|
|
else
|
2013-09-25 06:14:41 -06:00
|
|
|
reg = 0;
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_update_bits(component, AIC26_REG_DAC_GAIN, 0x8000, reg);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int aic26_set_sysclk(struct snd_soc_dai *codec_dai,
|
|
|
|
int clk_id, unsigned int freq, int dir)
|
|
|
|
{
|
2018-01-28 21:13:13 -07:00
|
|
|
struct snd_soc_component *component = codec_dai->component;
|
|
|
|
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
dev_dbg(&aic26->spi->dev, "aic26_set_sysclk(dai=%p, clk_id==%i,"
|
|
|
|
" freq=%i, dir=%i)\n",
|
|
|
|
codec_dai, clk_id, freq, dir);
|
|
|
|
|
|
|
|
/* MCLK needs to fall between 2MHz and 50 MHz */
|
|
|
|
if ((freq < 2000000) || (freq > 50000000))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
aic26->mclk = freq;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
|
|
|
{
|
2018-01-28 21:13:13 -07:00
|
|
|
struct snd_soc_component *component = codec_dai->component;
|
|
|
|
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
dev_dbg(&aic26->spi->dev, "aic26_set_fmt(dai=%p, fmt==%i)\n",
|
|
|
|
codec_dai, fmt);
|
|
|
|
|
|
|
|
/* set master/slave audio interface */
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
|
|
|
case SND_SOC_DAIFMT_CBM_CFM: aic26->master = 1; break;
|
|
|
|
case SND_SOC_DAIFMT_CBS_CFS: aic26->master = 0; break;
|
|
|
|
default:
|
|
|
|
dev_dbg(&aic26->spi->dev, "bad master\n"); return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* interface format */
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
|
|
|
|
case SND_SOC_DAIFMT_I2S: aic26->datfm = AIC26_DATFM_I2S; break;
|
|
|
|
case SND_SOC_DAIFMT_DSP_A: aic26->datfm = AIC26_DATFM_DSP; break;
|
|
|
|
case SND_SOC_DAIFMT_RIGHT_J: aic26->datfm = AIC26_DATFM_RIGHTJ; break;
|
|
|
|
case SND_SOC_DAIFMT_LEFT_J: aic26->datfm = AIC26_DATFM_LEFTJ; break;
|
|
|
|
default:
|
|
|
|
dev_dbg(&aic26->spi->dev, "bad format\n"); return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------
|
|
|
|
* Digital Audio Interface Definition
|
|
|
|
*/
|
|
|
|
#define AIC26_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
|
|
|
|
SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
|
|
|
|
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
|
|
|
|
SNDRV_PCM_RATE_48000)
|
|
|
|
#define AIC26_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |\
|
|
|
|
SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE)
|
|
|
|
|
2011-11-23 03:40:40 -07:00
|
|
|
static const struct snd_soc_dai_ops aic26_dai_ops = {
|
2009-03-02 18:41:00 -07:00
|
|
|
.hw_params = aic26_hw_params,
|
|
|
|
.digital_mute = aic26_mute,
|
|
|
|
.set_sysclk = aic26_set_sysclk,
|
|
|
|
.set_fmt = aic26_set_fmt,
|
|
|
|
};
|
|
|
|
|
2010-03-17 14:15:21 -06:00
|
|
|
static struct snd_soc_dai_driver aic26_dai = {
|
|
|
|
.name = "tlv320aic26-hifi",
|
2008-07-29 04:42:31 -06:00
|
|
|
.playback = {
|
|
|
|
.stream_name = "Playback",
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = AIC26_RATES,
|
|
|
|
.formats = AIC26_FORMATS,
|
|
|
|
},
|
|
|
|
.capture = {
|
|
|
|
.stream_name = "Capture",
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = AIC26_RATES,
|
|
|
|
.formats = AIC26_FORMATS,
|
|
|
|
},
|
2009-03-02 18:41:00 -07:00
|
|
|
.ops = &aic26_dai_ops,
|
2008-07-29 04:42:31 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------
|
|
|
|
* ALSA controls
|
|
|
|
*/
|
|
|
|
static const char *aic26_capture_src_text[] = {"Mic", "Aux"};
|
2014-02-18 02:27:40 -07:00
|
|
|
static SOC_ENUM_SINGLE_DECL(aic26_capture_src_enum,
|
|
|
|
AIC26_REG_AUDIO_CTRL1, 12,
|
|
|
|
aic26_capture_src_text);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new aic26_snd_controls[] = {
|
|
|
|
/* Output */
|
|
|
|
SOC_DOUBLE("PCM Playback Volume", AIC26_REG_DAC_GAIN, 8, 0, 0x7f, 1),
|
|
|
|
SOC_DOUBLE("PCM Playback Switch", AIC26_REG_DAC_GAIN, 15, 7, 1, 1),
|
|
|
|
SOC_SINGLE("PCM Capture Volume", AIC26_REG_ADC_GAIN, 8, 0x7f, 0),
|
|
|
|
SOC_SINGLE("PCM Capture Mute", AIC26_REG_ADC_GAIN, 15, 1, 1),
|
|
|
|
SOC_SINGLE("Keyclick activate", AIC26_REG_AUDIO_CTRL2, 15, 0x1, 0),
|
|
|
|
SOC_SINGLE("Keyclick amplitude", AIC26_REG_AUDIO_CTRL2, 12, 0x7, 0),
|
|
|
|
SOC_SINGLE("Keyclick frequency", AIC26_REG_AUDIO_CTRL2, 8, 0x7, 0),
|
|
|
|
SOC_SINGLE("Keyclick period", AIC26_REG_AUDIO_CTRL2, 4, 0xf, 0),
|
|
|
|
SOC_ENUM("Capture Source", aic26_capture_src_enum),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------
|
|
|
|
* SPI device portion of driver: sysfs files for debugging
|
|
|
|
*/
|
|
|
|
|
|
|
|
static ssize_t aic26_keyclick_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct aic26 *aic26 = dev_get_drvdata(dev);
|
|
|
|
int val, amp, freq, len;
|
|
|
|
|
2018-01-28 21:13:13 -07:00
|
|
|
val = snd_soc_component_read32(aic26->component, AIC26_REG_AUDIO_CTRL2);
|
2008-07-29 04:42:31 -06:00
|
|
|
amp = (val >> 12) & 0x7;
|
|
|
|
freq = (125 << ((val >> 8) & 0x7)) >> 1;
|
|
|
|
len = 2 * (1 + ((val >> 4) & 0xf));
|
|
|
|
|
|
|
|
return sprintf(buf, "amp=%x freq=%iHz len=%iclks\n", amp, freq, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Any write to the keyclick attribute will trigger the keyclick event */
|
|
|
|
static ssize_t aic26_keyclick_set(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct aic26 *aic26 = dev_get_drvdata(dev);
|
|
|
|
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_update_bits(aic26->component, AIC26_REG_AUDIO_CTRL2,
|
2013-09-25 06:14:41 -06:00
|
|
|
0x8000, 0x800);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2008-07-29 04:42:33 -06:00
|
|
|
static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------
|
2010-03-17 14:15:21 -06:00
|
|
|
* SoC CODEC portion of driver: probe and release routines
|
2008-07-29 04:42:31 -06:00
|
|
|
*/
|
2018-01-28 21:13:13 -07:00
|
|
|
static int aic26_probe(struct snd_soc_component *component)
|
2008-07-29 04:42:31 -06:00
|
|
|
{
|
2018-01-28 21:13:13 -07:00
|
|
|
struct aic26 *aic26 = dev_get_drvdata(component->dev);
|
2013-09-25 06:14:41 -06:00
|
|
|
int ret, reg;
|
2008-07-29 04:42:31 -06:00
|
|
|
|
2018-01-28 21:13:13 -07:00
|
|
|
aic26->component = component;
|
2013-08-06 05:39:29 -06:00
|
|
|
|
2008-07-29 04:42:31 -06:00
|
|
|
/* Reset the codec to power on defaults */
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_write(component, AIC26_REG_RESET, 0xBB00);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
/* Power up CODEC */
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_write(component, AIC26_REG_POWER_CTRL, 0);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
/* Audio Control 3 (master mode, fsref rate) */
|
2018-01-28 21:13:13 -07:00
|
|
|
reg = snd_soc_component_read32(component, AIC26_REG_AUDIO_CTRL3);
|
2008-07-29 04:42:31 -06:00
|
|
|
reg &= ~0xf800;
|
|
|
|
reg |= 0x0800; /* set master mode */
|
2018-01-28 21:13:13 -07:00
|
|
|
snd_soc_component_write(component, AIC26_REG_AUDIO_CTRL3, reg);
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
/* Register the sysfs files for debugging */
|
|
|
|
/* Create SysFS files */
|
2018-01-28 21:13:13 -07:00
|
|
|
ret = device_create_file(component->dev, &dev_attr_keyclick);
|
2008-12-08 12:17:58 -07:00
|
|
|
if (ret)
|
2018-01-28 21:13:13 -07:00
|
|
|
dev_info(component->dev, "error creating sysfs files\n");
|
2008-07-29 04:42:31 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-28 21:13:13 -07:00
|
|
|
static const struct snd_soc_component_driver aic26_soc_component_dev = {
|
|
|
|
.probe = aic26_probe,
|
|
|
|
.controls = aic26_snd_controls,
|
|
|
|
.num_controls = ARRAY_SIZE(aic26_snd_controls),
|
|
|
|
.dapm_widgets = tlv320aic26_dapm_widgets,
|
|
|
|
.num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets),
|
|
|
|
.dapm_routes = tlv320aic26_dapm_routes,
|
|
|
|
.num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes),
|
|
|
|
.idle_bias_on = 1,
|
|
|
|
.use_pmdown_time = 1,
|
|
|
|
.endianness = 1,
|
|
|
|
.non_legacy_dai_naming = 1,
|
2010-03-17 14:15:21 -06:00
|
|
|
};
|
|
|
|
|
2013-09-25 06:29:44 -06:00
|
|
|
static const struct regmap_config aic26_regmap = {
|
|
|
|
.reg_bits = 16,
|
|
|
|
.val_bits = 16,
|
|
|
|
};
|
|
|
|
|
2010-03-17 14:15:21 -06:00
|
|
|
/* ---------------------------------------------------------------------
|
|
|
|
* SPI device portion of driver: probe and release routines and SPI
|
|
|
|
* driver registration.
|
|
|
|
*/
|
|
|
|
static int aic26_spi_probe(struct spi_device *spi)
|
2008-07-29 04:42:31 -06:00
|
|
|
{
|
2010-03-17 14:15:21 -06:00
|
|
|
struct aic26 *aic26;
|
|
|
|
int ret;
|
2008-07-29 04:42:31 -06:00
|
|
|
|
2010-03-17 14:15:21 -06:00
|
|
|
dev_dbg(&spi->dev, "probing tlv320aic26 spi device\n");
|
|
|
|
|
|
|
|
/* Allocate driver data */
|
2011-12-28 21:08:36 -07:00
|
|
|
aic26 = devm_kzalloc(&spi->dev, sizeof *aic26, GFP_KERNEL);
|
2010-03-17 14:15:21 -06:00
|
|
|
if (!aic26)
|
|
|
|
return -ENOMEM;
|
2008-07-29 04:42:31 -06:00
|
|
|
|
2013-09-25 06:29:44 -06:00
|
|
|
aic26->regmap = devm_regmap_init_spi(spi, &aic26_regmap);
|
|
|
|
if (IS_ERR(aic26->regmap))
|
|
|
|
return PTR_ERR(aic26->regmap);
|
|
|
|
|
2010-03-17 14:15:21 -06:00
|
|
|
/* Initialize the driver data */
|
|
|
|
aic26->spi = spi;
|
|
|
|
dev_set_drvdata(&spi->dev, aic26);
|
|
|
|
aic26->master = 1;
|
|
|
|
|
2018-01-28 21:13:13 -07:00
|
|
|
ret = devm_snd_soc_register_component(&spi->dev,
|
|
|
|
&aic26_soc_component_dev, &aic26_dai, 1);
|
2010-03-17 14:15:21 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-07-29 04:42:31 -06:00
|
|
|
static struct spi_driver aic26_spi = {
|
|
|
|
.driver = {
|
2010-03-17 14:15:21 -06:00
|
|
|
.name = "tlv320aic26-codec",
|
2008-07-29 04:42:31 -06:00
|
|
|
},
|
|
|
|
.probe = aic26_spi_probe,
|
|
|
|
};
|
|
|
|
|
2012-08-27 05:30:26 -06:00
|
|
|
module_spi_driver(aic26_spi);
|