mirror of https://gitee.com/openkylin/linux.git
Merge series "Adds SPI support" from Jiri Prchal <jiri.prchal@aksignal.cz>:
Moved I2C stuff to separated file, shered thingk to header file. Added SPI in separeted file. Jiri Prchal (4): ASoC: codecs: tlv320aic3x: move model definitions ASoC: codecs: tlv320aic3x: rename probe function ASoC: codecs: tlv320aic3x: move I2C to separated file ASoC: codecs: tlv320aic3x: add SPI support sound/soc/codecs/Kconfig | 16 ++++- sound/soc/codecs/Makefile | 4 ++ sound/soc/codecs/tlv320aic3x-i2c.c | 70 +++++++++++++++++++ sound/soc/codecs/tlv320aic3x-spi.c | 76 ++++++++++++++++++++ sound/soc/codecs/tlv320aic3x.c | 108 ++++++++--------------------- sound/soc/codecs/tlv320aic3x.h | 12 ++++ 6 files changed, 204 insertions(+), 82 deletions(-) create mode 100644 sound/soc/codecs/tlv320aic3x-i2c.c create mode 100644 sound/soc/codecs/tlv320aic3x-spi.c -- 2.25.1
This commit is contained in:
commit
8361c6da77
|
@ -218,7 +218,8 @@ config SND_SOC_ALL_CODECS
|
||||||
imply SND_SOC_TLV320AIC31XX
|
imply SND_SOC_TLV320AIC31XX
|
||||||
imply SND_SOC_TLV320AIC32X4_I2C
|
imply SND_SOC_TLV320AIC32X4_I2C
|
||||||
imply SND_SOC_TLV320AIC32X4_SPI
|
imply SND_SOC_TLV320AIC32X4_SPI
|
||||||
imply SND_SOC_TLV320AIC3X
|
imply SND_SOC_TLV320AIC3X_I2C
|
||||||
|
imply SND_SOC_TLV320AIC3X_SPI
|
||||||
imply SND_SOC_TPA6130A2
|
imply SND_SOC_TPA6130A2
|
||||||
imply SND_SOC_TLV320DAC33
|
imply SND_SOC_TLV320DAC33
|
||||||
imply SND_SOC_TSCS42XX
|
imply SND_SOC_TSCS42XX
|
||||||
|
@ -1446,8 +1447,19 @@ config SND_SOC_TLV320AIC32X4_SPI
|
||||||
select SND_SOC_TLV320AIC32X4
|
select SND_SOC_TLV320AIC32X4
|
||||||
|
|
||||||
config SND_SOC_TLV320AIC3X
|
config SND_SOC_TLV320AIC3X
|
||||||
tristate "Texas Instruments TLV320AIC3x CODECs"
|
tristate
|
||||||
|
|
||||||
|
config SND_SOC_TLV320AIC3X_I2C
|
||||||
|
tristate "Texas Instruments TLV320AIC3x audio CODECs - I2C"
|
||||||
depends on I2C
|
depends on I2C
|
||||||
|
select SND_SOC_TLV320AIC3X
|
||||||
|
select REGMAP_I2C
|
||||||
|
|
||||||
|
config SND_SOC_TLV320AIC3X_SPI
|
||||||
|
tristate "Texas Instruments TLV320AIC3x audio CODECs - SPI"
|
||||||
|
depends on SPI_MASTER
|
||||||
|
select SND_SOC_TLV320AIC3X
|
||||||
|
select REGMAP_SPI
|
||||||
|
|
||||||
config SND_SOC_TLV320DAC33
|
config SND_SOC_TLV320DAC33
|
||||||
tristate
|
tristate
|
||||||
|
|
|
@ -238,6 +238,8 @@ snd-soc-tlv320aic32x4-objs := tlv320aic32x4.o tlv320aic32x4-clk.o
|
||||||
snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
|
snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
|
||||||
snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
|
snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
|
||||||
snd-soc-tlv320aic3x-objs := tlv320aic3x.o
|
snd-soc-tlv320aic3x-objs := tlv320aic3x.o
|
||||||
|
snd-soc-tlv320aic3x-i2c-objs := tlv320aic3x-i2c.o
|
||||||
|
snd-soc-tlv320aic3x-spi-objs := tlv320aic3x-spi.o
|
||||||
snd-soc-tlv320dac33-objs := tlv320dac33.o
|
snd-soc-tlv320dac33-objs := tlv320dac33.o
|
||||||
snd-soc-tlv320adcx140-objs := tlv320adcx140.o
|
snd-soc-tlv320adcx140-objs := tlv320adcx140.o
|
||||||
snd-soc-tscs42xx-objs := tscs42xx.o
|
snd-soc-tscs42xx-objs := tscs42xx.o
|
||||||
|
@ -558,6 +560,8 @@ obj-$(CONFIG_SND_SOC_TLV320AIC32X4) += snd-soc-tlv320aic32x4.o
|
||||||
obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C) += snd-soc-tlv320aic32x4-i2c.o
|
obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C) += snd-soc-tlv320aic32x4-i2c.o
|
||||||
obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI) += snd-soc-tlv320aic32x4-spi.o
|
obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI) += snd-soc-tlv320aic32x4-spi.o
|
||||||
obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o
|
obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o
|
||||||
|
obj-$(CONFIG_SND_SOC_TLV320AIC3X_I2C) += snd-soc-tlv320aic3x-i2c.o
|
||||||
|
obj-$(CONFIG_SND_SOC_TLV320AIC3X_SPI) += snd-soc-tlv320aic3x-spi.o
|
||||||
obj-$(CONFIG_SND_SOC_TLV320DAC33) += snd-soc-tlv320dac33.o
|
obj-$(CONFIG_SND_SOC_TLV320DAC33) += snd-soc-tlv320dac33.o
|
||||||
obj-$(CONFIG_SND_SOC_TLV320ADCX140) += snd-soc-tlv320adcx140.o
|
obj-$(CONFIG_SND_SOC_TLV320ADCX140) += snd-soc-tlv320adcx140.o
|
||||||
obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
|
obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
*
|
||||||
|
* ALSA SoC TLV320AIC3x codec driver I2C interface
|
||||||
|
*
|
||||||
|
* Author: Arun KS, <arunks@mistralsolutions.com>
|
||||||
|
* Copyright: (C) 2008 Mistral Solutions Pvt Ltd.,
|
||||||
|
*
|
||||||
|
* Based on sound/soc/codecs/wm8731.c by Richard Purdie
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/i2c.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/regmap.h>
|
||||||
|
#include <sound/soc.h>
|
||||||
|
|
||||||
|
#include "tlv320aic3x.h"
|
||||||
|
|
||||||
|
static int aic3x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
|
||||||
|
{
|
||||||
|
struct regmap *regmap;
|
||||||
|
struct regmap_config config;
|
||||||
|
|
||||||
|
config = aic3x_regmap;
|
||||||
|
config.reg_bits = 8;
|
||||||
|
config.val_bits = 8;
|
||||||
|
|
||||||
|
regmap = devm_regmap_init_i2c(i2c, &config);
|
||||||
|
return aic3x_probe(&i2c->dev, regmap, id->driver_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int aic3x_i2c_remove(struct i2c_client *i2c)
|
||||||
|
{
|
||||||
|
return aic3x_remove(&i2c->dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct i2c_device_id aic3x_i2c_id[] = {
|
||||||
|
{ "tlv320aic3x", AIC3X_MODEL_3X },
|
||||||
|
{ "tlv320aic33", AIC3X_MODEL_33 },
|
||||||
|
{ "tlv320aic3007", AIC3X_MODEL_3007 },
|
||||||
|
{ "tlv320aic3104", AIC3X_MODEL_3104 },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
|
||||||
|
|
||||||
|
static const struct of_device_id aic3x_of_id[] = {
|
||||||
|
{ .compatible = "ti,tlv320aic3x", },
|
||||||
|
{ .compatible = "ti,tlv320aic33" },
|
||||||
|
{ .compatible = "ti,tlv320aic3007" },
|
||||||
|
{ .compatible = "ti,tlv320aic3104" },
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, aic3x_of_id);
|
||||||
|
|
||||||
|
static struct i2c_driver aic3x_i2c_driver = {
|
||||||
|
.driver = {
|
||||||
|
.name = "tlv320aic3x",
|
||||||
|
.of_match_table = aic3x_of_id,
|
||||||
|
},
|
||||||
|
.probe = aic3x_i2c_probe,
|
||||||
|
.remove = aic3x_i2c_remove,
|
||||||
|
.id_table = aic3x_i2c_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
module_i2c_driver(aic3x_i2c_driver);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("ASoC TLV320AIC3x codec driver I2C");
|
||||||
|
MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
|
||||||
|
MODULE_LICENSE("GPL");
|
|
@ -0,0 +1,76 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0
|
||||||
|
*
|
||||||
|
* ALSA SoC TLV320AIC3x codec driver SPI interface
|
||||||
|
*
|
||||||
|
* Author: Arun KS, <arunks@mistralsolutions.com>
|
||||||
|
* Copyright: (C) 2008 Mistral Solutions Pvt Ltd.,
|
||||||
|
*
|
||||||
|
* Based on sound/soc/codecs/wm8731.c by Richard Purdie
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/spi/spi.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/regmap.h>
|
||||||
|
#include <sound/soc.h>
|
||||||
|
|
||||||
|
#include "tlv320aic3x.h"
|
||||||
|
|
||||||
|
static int aic3x_spi_probe(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
struct regmap *regmap;
|
||||||
|
struct regmap_config config;
|
||||||
|
const struct spi_device_id *id = spi_get_device_id(spi);
|
||||||
|
|
||||||
|
config = aic3x_regmap;
|
||||||
|
config.reg_bits = 7;
|
||||||
|
config.pad_bits = 1;
|
||||||
|
config.val_bits = 8;
|
||||||
|
config.read_flag_mask = 0x01;
|
||||||
|
|
||||||
|
dev_dbg(&spi->dev, "probing tlv320aic3x spi device\n");
|
||||||
|
|
||||||
|
regmap = devm_regmap_init_spi(spi, &config);
|
||||||
|
return aic3x_probe(&spi->dev, regmap, id->driver_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int aic3x_spi_remove(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
return aic3x_remove(&spi->dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct spi_device_id aic3x_spi_id[] = {
|
||||||
|
{ "tlv320aic3x", AIC3X_MODEL_3X },
|
||||||
|
{ "tlv320aic33", AIC3X_MODEL_33 },
|
||||||
|
{ "tlv320aic3007", AIC3X_MODEL_3007 },
|
||||||
|
{ "tlv320aic3104", AIC3X_MODEL_3104 },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(spi, aic3x_spi_id);
|
||||||
|
|
||||||
|
static const struct of_device_id aic3x_of_id[] = {
|
||||||
|
{ .compatible = "ti,tlv320aic3x", },
|
||||||
|
{ .compatible = "ti,tlv320aic33" },
|
||||||
|
{ .compatible = "ti,tlv320aic3007" },
|
||||||
|
{ .compatible = "ti,tlv320aic3104" },
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, aic3x_of_id);
|
||||||
|
|
||||||
|
static struct spi_driver aic3x_spi_driver = {
|
||||||
|
.driver = {
|
||||||
|
.name = "tlv320aic3x",
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.of_match_table = aic3x_of_id,
|
||||||
|
},
|
||||||
|
.probe = aic3x_spi_probe,
|
||||||
|
.remove = aic3x_spi_remove,
|
||||||
|
.id_table = aic3x_spi_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
module_spi_driver(aic3x_spi_driver);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("ASoC TLV320AIC3x codec driver SPI");
|
||||||
|
MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>");
|
||||||
|
MODULE_LICENSE("GPL");
|
|
@ -1,6 +1,5 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/* ALSA SoC TLV320AIC3X codec driver
|
||||||
* ALSA SoC TLV320AIC3X codec driver
|
|
||||||
*
|
*
|
||||||
* Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
|
* Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
|
||||||
* Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
|
* Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
|
||||||
|
@ -82,10 +81,6 @@ struct aic3x_priv {
|
||||||
int master;
|
int master;
|
||||||
int gpio_reset;
|
int gpio_reset;
|
||||||
int power;
|
int power;
|
||||||
#define AIC3X_MODEL_3X 0
|
|
||||||
#define AIC3X_MODEL_33 1
|
|
||||||
#define AIC3X_MODEL_3007 2
|
|
||||||
#define AIC3X_MODEL_3104 3
|
|
||||||
u16 model;
|
u16 model;
|
||||||
|
|
||||||
/* Selects the micbias voltage */
|
/* Selects the micbias voltage */
|
||||||
|
@ -135,10 +130,7 @@ static bool aic3x_volatile_reg(struct device *dev, unsigned int reg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct regmap_config aic3x_regmap = {
|
const struct regmap_config aic3x_regmap = {
|
||||||
.reg_bits = 8,
|
|
||||||
.val_bits = 8,
|
|
||||||
|
|
||||||
.max_register = DAC_ICC_ADJ,
|
.max_register = DAC_ICC_ADJ,
|
||||||
.reg_defaults = aic3x_reg,
|
.reg_defaults = aic3x_reg,
|
||||||
.num_reg_defaults = ARRAY_SIZE(aic3x_reg),
|
.num_reg_defaults = ARRAY_SIZE(aic3x_reg),
|
||||||
|
@ -147,6 +139,7 @@ static const struct regmap_config aic3x_regmap = {
|
||||||
|
|
||||||
.cache_type = REGCACHE_RBTREE,
|
.cache_type = REGCACHE_RBTREE,
|
||||||
};
|
};
|
||||||
|
EXPORT_SYMBOL_GPL(aic3x_regmap);
|
||||||
|
|
||||||
#define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \
|
#define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \
|
||||||
SOC_SINGLE_EXT(xname, reg, shift, mask, invert, \
|
SOC_SINGLE_EXT(xname, reg, shift, mask, invert, \
|
||||||
|
@ -1614,7 +1607,7 @@ static bool aic3x_is_shared_reset(struct aic3x_priv *aic3x)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int aic3x_probe(struct snd_soc_component *component)
|
static int aic3x_component_probe(struct snd_soc_component *component)
|
||||||
{
|
{
|
||||||
struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
|
struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
@ -1693,7 +1686,7 @@ static int aic3x_probe(struct snd_soc_component *component)
|
||||||
|
|
||||||
static const struct snd_soc_component_driver soc_component_dev_aic3x = {
|
static const struct snd_soc_component_driver soc_component_dev_aic3x = {
|
||||||
.set_bias_level = aic3x_set_bias_level,
|
.set_bias_level = aic3x_set_bias_level,
|
||||||
.probe = aic3x_probe,
|
.probe = aic3x_component_probe,
|
||||||
.controls = aic3x_snd_controls,
|
.controls = aic3x_snd_controls,
|
||||||
.num_controls = ARRAY_SIZE(aic3x_snd_controls),
|
.num_controls = ARRAY_SIZE(aic3x_snd_controls),
|
||||||
.dapm_widgets = aic3x_dapm_widgets,
|
.dapm_widgets = aic3x_dapm_widgets,
|
||||||
|
@ -1705,10 +1698,9 @@ static const struct snd_soc_component_driver soc_component_dev_aic3x = {
|
||||||
.non_legacy_dai_naming = 1,
|
.non_legacy_dai_naming = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void aic3x_configure_ocmv(struct i2c_client *client)
|
static void aic3x_configure_ocmv(struct device *dev, struct aic3x_priv *aic3x)
|
||||||
{
|
{
|
||||||
struct device_node *np = client->dev.of_node;
|
struct device_node *np = dev->of_node;
|
||||||
struct aic3x_priv *aic3x = i2c_get_clientdata(client);
|
|
||||||
u32 value;
|
u32 value;
|
||||||
int dvdd, avdd;
|
int dvdd, avdd;
|
||||||
|
|
||||||
|
@ -1724,7 +1716,7 @@ static void aic3x_configure_ocmv(struct i2c_client *client)
|
||||||
avdd = regulator_get_voltage(aic3x->supplies[2].consumer);
|
avdd = regulator_get_voltage(aic3x->supplies[2].consumer);
|
||||||
|
|
||||||
if (avdd > 3600000 || dvdd > 1950000) {
|
if (avdd > 3600000 || dvdd > 1950000) {
|
||||||
dev_warn(&client->dev,
|
dev_warn(dev,
|
||||||
"Too high supply voltage(s) AVDD: %d, DVDD: %d\n",
|
"Too high supply voltage(s) AVDD: %d, DVDD: %d\n",
|
||||||
avdd, dvdd);
|
avdd, dvdd);
|
||||||
} else if (avdd == 3600000 && dvdd == 1950000) {
|
} else if (avdd == 3600000 && dvdd == 1950000) {
|
||||||
|
@ -1736,26 +1728,12 @@ static void aic3x_configure_ocmv(struct i2c_client *client)
|
||||||
} else if (avdd >= 2700000 && dvdd >= 1525000) {
|
} else if (avdd >= 2700000 && dvdd >= 1525000) {
|
||||||
aic3x->ocmv = HPOUT_SC_OCMV_1_35V;
|
aic3x->ocmv = HPOUT_SC_OCMV_1_35V;
|
||||||
} else {
|
} else {
|
||||||
dev_warn(&client->dev,
|
dev_warn(dev,
|
||||||
"Invalid supply voltage(s) AVDD: %d, DVDD: %d\n",
|
"Invalid supply voltage(s) AVDD: %d, DVDD: %d\n",
|
||||||
avdd, dvdd);
|
avdd, dvdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* AIC3X 2 wire address can be up to 4 devices with device addresses
|
|
||||||
* 0x18, 0x19, 0x1A, 0x1B
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const struct i2c_device_id aic3x_i2c_id[] = {
|
|
||||||
{ "tlv320aic3x", AIC3X_MODEL_3X },
|
|
||||||
{ "tlv320aic33", AIC3X_MODEL_33 },
|
|
||||||
{ "tlv320aic3007", AIC3X_MODEL_3007 },
|
|
||||||
{ "tlv320aic3106", AIC3X_MODEL_3X },
|
|
||||||
{ "tlv320aic3104", AIC3X_MODEL_3104 },
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
|
|
||||||
|
|
||||||
static const struct reg_sequence aic3007_class_d[] = {
|
static const struct reg_sequence aic3007_class_d[] = {
|
||||||
/* Class-D speaker driver init; datasheet p. 46 */
|
/* Class-D speaker driver init; datasheet p. 46 */
|
||||||
|
@ -1767,25 +1745,20 @@ static const struct reg_sequence aic3007_class_d[] = {
|
||||||
{ AIC3X_PAGE_SELECT, 0x00 },
|
{ AIC3X_PAGE_SELECT, 0x00 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
int aic3x_probe(struct device *dev, struct regmap *regmap, kernel_ulong_t driver_data)
|
||||||
* If the i2c layer weren't so broken, we could pass this kind of data
|
|
||||||
* around
|
|
||||||
*/
|
|
||||||
static int aic3x_i2c_probe(struct i2c_client *i2c,
|
|
||||||
const struct i2c_device_id *id)
|
|
||||||
{
|
{
|
||||||
struct aic3x_pdata *pdata = i2c->dev.platform_data;
|
struct aic3x_pdata *pdata = dev->platform_data;
|
||||||
struct aic3x_priv *aic3x;
|
struct aic3x_priv *aic3x;
|
||||||
struct aic3x_setup_data *ai3x_setup;
|
struct aic3x_setup_data *ai3x_setup;
|
||||||
struct device_node *np = i2c->dev.of_node;
|
struct device_node *np = dev->of_node;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
u32 value;
|
u32 value;
|
||||||
|
|
||||||
aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL);
|
aic3x = devm_kzalloc(dev, sizeof(struct aic3x_priv), GFP_KERNEL);
|
||||||
if (!aic3x)
|
if (!aic3x)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
aic3x->regmap = devm_regmap_init_i2c(i2c, &aic3x_regmap);
|
aic3x->regmap = regmap;
|
||||||
if (IS_ERR(aic3x->regmap)) {
|
if (IS_ERR(aic3x->regmap)) {
|
||||||
ret = PTR_ERR(aic3x->regmap);
|
ret = PTR_ERR(aic3x->regmap);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1793,14 +1766,13 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
|
||||||
|
|
||||||
regcache_cache_only(aic3x->regmap, true);
|
regcache_cache_only(aic3x->regmap, true);
|
||||||
|
|
||||||
i2c_set_clientdata(i2c, aic3x);
|
dev_set_drvdata(dev, aic3x);
|
||||||
if (pdata) {
|
if (pdata) {
|
||||||
aic3x->gpio_reset = pdata->gpio_reset;
|
aic3x->gpio_reset = pdata->gpio_reset;
|
||||||
aic3x->setup = pdata->setup;
|
aic3x->setup = pdata->setup;
|
||||||
aic3x->micbias_vg = pdata->micbias_vg;
|
aic3x->micbias_vg = pdata->micbias_vg;
|
||||||
} else if (np) {
|
} else if (np) {
|
||||||
ai3x_setup = devm_kzalloc(&i2c->dev, sizeof(*ai3x_setup),
|
ai3x_setup = devm_kzalloc(dev, sizeof(*ai3x_setup), GFP_KERNEL);
|
||||||
GFP_KERNEL);
|
|
||||||
if (!ai3x_setup)
|
if (!ai3x_setup)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -1810,7 +1782,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
|
||||||
} else {
|
} else {
|
||||||
ret = of_get_named_gpio(np, "gpio-reset", 0);
|
ret = of_get_named_gpio(np, "gpio-reset", 0);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
dev_warn(&i2c->dev, "Using deprecated property \"gpio-reset\", please update your DT");
|
dev_warn(dev, "Using deprecated property \"gpio-reset\", please update your DT");
|
||||||
aic3x->gpio_reset = ret;
|
aic3x->gpio_reset = ret;
|
||||||
} else {
|
} else {
|
||||||
aic3x->gpio_reset = -1;
|
aic3x->gpio_reset = -1;
|
||||||
|
@ -1835,7 +1807,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
aic3x->micbias_vg = AIC3X_MICBIAS_OFF;
|
aic3x->micbias_vg = AIC3X_MICBIAS_OFF;
|
||||||
dev_err(&i2c->dev, "Unsuitable MicBias voltage "
|
dev_err(dev, "Unsuitable MicBias voltage "
|
||||||
"found in DT\n");
|
"found in DT\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1846,7 +1818,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
|
||||||
aic3x->gpio_reset = -1;
|
aic3x->gpio_reset = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
aic3x->model = id->driver_data;
|
aic3x->model = driver_data;
|
||||||
|
|
||||||
if (gpio_is_valid(aic3x->gpio_reset) &&
|
if (gpio_is_valid(aic3x->gpio_reset) &&
|
||||||
!aic3x_is_shared_reset(aic3x)) {
|
!aic3x_is_shared_reset(aic3x)) {
|
||||||
|
@ -1859,25 +1831,24 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
|
||||||
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
|
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
|
||||||
aic3x->supplies[i].supply = aic3x_supply_names[i];
|
aic3x->supplies[i].supply = aic3x_supply_names[i];
|
||||||
|
|
||||||
ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(aic3x->supplies),
|
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(aic3x->supplies),
|
||||||
aic3x->supplies);
|
aic3x->supplies);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
|
dev_err(dev, "Failed to request supplies: %d\n", ret);
|
||||||
goto err_gpio;
|
goto err_gpio;
|
||||||
}
|
}
|
||||||
|
|
||||||
aic3x_configure_ocmv(i2c);
|
aic3x_configure_ocmv(dev, aic3x);
|
||||||
|
|
||||||
if (aic3x->model == AIC3X_MODEL_3007) {
|
if (aic3x->model == AIC3X_MODEL_3007) {
|
||||||
ret = regmap_register_patch(aic3x->regmap, aic3007_class_d,
|
ret = regmap_register_patch(aic3x->regmap, aic3007_class_d,
|
||||||
ARRAY_SIZE(aic3007_class_d));
|
ARRAY_SIZE(aic3007_class_d));
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
dev_err(&i2c->dev, "Failed to init class D: %d\n",
|
dev_err(dev, "Failed to init class D: %d\n",
|
||||||
ret);
|
ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = devm_snd_soc_register_component(&i2c->dev,
|
ret = devm_snd_soc_register_component(dev, &soc_component_dev_aic3x, &aic3x_dai, 1);
|
||||||
&soc_component_dev_aic3x, &aic3x_dai, 1);
|
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto err_gpio;
|
goto err_gpio;
|
||||||
|
@ -1894,10 +1865,11 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
|
||||||
err:
|
err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(aic3x_probe);
|
||||||
|
|
||||||
static int aic3x_i2c_remove(struct i2c_client *client)
|
int aic3x_remove(struct device *dev)
|
||||||
{
|
{
|
||||||
struct aic3x_priv *aic3x = i2c_get_clientdata(client);
|
struct aic3x_priv *aic3x = dev_get_drvdata(dev);
|
||||||
|
|
||||||
list_del(&aic3x->list);
|
list_del(&aic3x->list);
|
||||||
|
|
||||||
|
@ -1908,31 +1880,7 @@ static int aic3x_i2c_remove(struct i2c_client *client)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(aic3x_remove);
|
||||||
#if defined(CONFIG_OF)
|
|
||||||
static const struct of_device_id tlv320aic3x_of_match[] = {
|
|
||||||
{ .compatible = "ti,tlv320aic3x", },
|
|
||||||
{ .compatible = "ti,tlv320aic33" },
|
|
||||||
{ .compatible = "ti,tlv320aic3007" },
|
|
||||||
{ .compatible = "ti,tlv320aic3106" },
|
|
||||||
{ .compatible = "ti,tlv320aic3104" },
|
|
||||||
{},
|
|
||||||
};
|
|
||||||
MODULE_DEVICE_TABLE(of, tlv320aic3x_of_match);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* machine i2c codec control layer */
|
|
||||||
static struct i2c_driver aic3x_i2c_driver = {
|
|
||||||
.driver = {
|
|
||||||
.name = "tlv320aic3x-codec",
|
|
||||||
.of_match_table = of_match_ptr(tlv320aic3x_of_match),
|
|
||||||
},
|
|
||||||
.probe = aic3x_i2c_probe,
|
|
||||||
.remove = aic3x_i2c_remove,
|
|
||||||
.id_table = aic3x_i2c_id,
|
|
||||||
};
|
|
||||||
|
|
||||||
module_i2c_driver(aic3x_i2c_driver);
|
|
||||||
|
|
||||||
MODULE_DESCRIPTION("ASoC TLV320AIC3X codec driver");
|
MODULE_DESCRIPTION("ASoC TLV320AIC3X codec driver");
|
||||||
MODULE_AUTHOR("Vladimir Barinov");
|
MODULE_AUTHOR("Vladimir Barinov");
|
||||||
|
|
|
@ -9,6 +9,18 @@
|
||||||
#ifndef _AIC3X_H
|
#ifndef _AIC3X_H
|
||||||
#define _AIC3X_H
|
#define _AIC3X_H
|
||||||
|
|
||||||
|
struct device;
|
||||||
|
struct regmap_config;
|
||||||
|
|
||||||
|
extern const struct regmap_config aic3x_regmap;
|
||||||
|
int aic3x_probe(struct device *dev, struct regmap *regmap, kernel_ulong_t driver_data);
|
||||||
|
int aic3x_remove(struct device *dev);
|
||||||
|
|
||||||
|
#define AIC3X_MODEL_3X 0
|
||||||
|
#define AIC3X_MODEL_33 1
|
||||||
|
#define AIC3X_MODEL_3007 2
|
||||||
|
#define AIC3X_MODEL_3104 3
|
||||||
|
|
||||||
/* AIC3X register space */
|
/* AIC3X register space */
|
||||||
#define AIC3X_CACHEREGNUM 110
|
#define AIC3X_CACHEREGNUM 110
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue