Skip to content

Commit

Permalink
Merge remote-tracking branches 'asoc/topic/tfa9879', 'asoc/topic/ts3a…
Browse files Browse the repository at this point in the history
…277e', 'asoc/topic/wm8741', 'asoc/topic/wm97xx' and 'asoc/topic/zte' into asoc-next
  • Loading branch information
Mark Brown committed Nov 10, 2017
6 parents 668f21b + 3d345b5 + a10953f + 81b3cc5 + 6bd25aa + b614583 commit df6a3e2
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 72 deletions.
23 changes: 23 additions & 0 deletions Documentation/devicetree/bindings/sound/tfa9879.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
NXP TFA9879 class-D audio amplifier

Required properties:

- compatible : "nxp,tfa9879"

- reg : the I2C address of the device

Example:

&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";

codec: tfa9879@6c {
#sound-dai-cells = <0>;
compatible = "nxp,tfa9879";
reg = <0x6c>;
};
};

9 changes: 6 additions & 3 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ config SND_SOC_ALL_CODECS
select SND_SOC_WM8998 if MFD_WM8998
select SND_SOC_WM9081 if I2C
select SND_SOC_WM9090 if I2C
select SND_SOC_WM9705 if SND_SOC_AC97_BUS
select SND_SOC_WM9712 if SND_SOC_AC97_BUS
select SND_SOC_WM9713 if SND_SOC_AC97_BUS
select SND_SOC_WM9705 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
select SND_SOC_WM9712 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
help
Normally ASoC codec drivers are only built if a machine driver which
uses them is also built since they are only usable with a machine
Expand Down Expand Up @@ -1132,14 +1132,17 @@ config SND_SOC_WM9090
config SND_SOC_WM9705
tristate
select REGMAP_AC97
select AC97_BUS_COMPAT if AC97_BUS_NEW

config SND_SOC_WM9712
tristate
select REGMAP_AC97
select AC97_BUS_COMPAT if AC97_BUS_NEW

config SND_SOC_WM9713
tristate
select REGMAP_AC97
select AC97_BUS_COMPAT if AC97_BUS_NEW

config SND_SOC_ZX_AUD96P22
tristate "ZTE ZX AUD96P22 CODEC"
Expand Down
6 changes: 6 additions & 0 deletions sound/soc/codecs/tfa9879.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,15 @@ static const struct i2c_device_id tfa9879_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, tfa9879_i2c_id);

static const struct of_device_id tfa9879_of_match[] = {
{ .compatible = "nxp,tfa9879", },
{ }
};

static struct i2c_driver tfa9879_i2c_driver = {
.driver = {
.name = "tfa9879",
.of_match_table = tfa9879_of_match,
},
.probe = tfa9879_i2c_probe,
.remove = tfa9879_i2c_remove,
Expand Down
10 changes: 10 additions & 0 deletions sound/soc/codecs/ts3a227e.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/of_gpio.h>
#include <linux/regmap.h>
#include <linux/acpi.h>

#include <sound/core.h>
#include <sound/jack.h>
Expand Down Expand Up @@ -374,11 +375,20 @@ static const struct of_device_id ts3a227e_of_match[] = {
};
MODULE_DEVICE_TABLE(of, ts3a227e_of_match);

#ifdef CONFIG_ACPI
static struct acpi_device_id ts3a227e_acpi_match[] = {
{ "104C227E", 0 },
{},
};
MODULE_DEVICE_TABLE(acpi, ts3a227e_acpi_match);
#endif

static struct i2c_driver ts3a227e_driver = {
.driver = {
.name = "ts3a227e",
.pm = &ts3a227e_pm,
.of_match_table = of_match_ptr(ts3a227e_of_match),
.acpi_match_table = ACPI_PTR(ts3a227e_acpi_match),
},
.probe = ts3a227e_i2c_probe,
.id_table = ts3a227e_i2c_ids,
Expand Down
39 changes: 23 additions & 16 deletions sound/soc/codecs/wm8741.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
{
struct snd_soc_codec *codec = dai->codec;
struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
u16 iface = snd_soc_read(codec, WM8741_FORMAT_CONTROL) & 0x1FC;
unsigned int iface;
int i;

/* The set of sample rates that can be supported depends on the
Expand All @@ -223,15 +223,16 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
/* bit size */
switch (params_width(params)) {
case 16:
iface = 0x0;
break;
case 20:
iface |= 0x0001;
iface = 0x1;
break;
case 24:
iface |= 0x0002;
iface = 0x2;
break;
case 32:
iface |= 0x0003;
iface = 0x3;
break;
default:
dev_dbg(codec->dev, "wm8741_hw_params: Unsupported bit size param = %d",
Expand All @@ -242,7 +243,9 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
dev_dbg(codec->dev, "wm8741_hw_params: bit size param = %d, rate param = %d",
params_width(params), params_rate(params));

snd_soc_write(codec, WM8741_FORMAT_CONTROL, iface);
snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK,
iface);

return 0;
}

Expand Down Expand Up @@ -295,7 +298,7 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
u16 iface = snd_soc_read(codec, WM8741_FORMAT_CONTROL) & 0x1C3;
unsigned int iface;

/* check master/slave audio interface */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
Expand All @@ -308,18 +311,19 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
/* interface format */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
iface |= 0x0008;
iface = 0x08;
break;
case SND_SOC_DAIFMT_RIGHT_J:
iface = 0x00;
break;
case SND_SOC_DAIFMT_LEFT_J:
iface |= 0x0004;
iface = 0x04;
break;
case SND_SOC_DAIFMT_DSP_A:
iface |= 0x000C;
iface = 0x0C;
break;
case SND_SOC_DAIFMT_DSP_B:
iface |= 0x001C;
iface = 0x1C;
break;
default:
return -EINVAL;
Expand All @@ -329,14 +333,14 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF:
break;
case SND_SOC_DAIFMT_IB_IF:
iface |= 0x0010;
case SND_SOC_DAIFMT_NB_IF:
iface |= 0x10;
break;
case SND_SOC_DAIFMT_IB_NF:
iface |= 0x0020;
iface |= 0x20;
break;
case SND_SOC_DAIFMT_NB_IF:
iface |= 0x0030;
case SND_SOC_DAIFMT_IB_IF:
iface |= 0x30;
break;
default:
return -EINVAL;
Expand All @@ -347,7 +351,10 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
fmt & SND_SOC_DAIFMT_FORMAT_MASK,
((fmt & SND_SOC_DAIFMT_INV_MASK)));

snd_soc_write(codec, WM8741_FORMAT_CONTROL, iface);
snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL,
WM8741_BCP_MASK | WM8741_LRP_MASK | WM8741_FMT_MASK,
iface);

return 0;
}

Expand Down
68 changes: 46 additions & 22 deletions sound/soc/codecs/wm9705.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@

#include <linux/init.h>
#include <linux/slab.h>
#include <linux/mfd/wm97xx.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/ac97_codec.h>
#include <sound/ac97/codec.h>
#include <sound/ac97/compat.h>
#include <sound/initval.h>
#include <sound/soc.h>

#define WM9705_VENDOR_ID 0x574d4c05
#define WM9705_VENDOR_ID_MASK 0xffffffff

struct wm9705_priv {
struct snd_ac97 *ac97;
struct wm97xx_platform_data *mfd_pdata;
};

static const struct reg_default wm9705_reg_defaults[] = {
{ 0x02, 0x8000 },
{ 0x04, 0x8000 },
Expand Down Expand Up @@ -292,10 +300,10 @@ static int wm9705_soc_suspend(struct snd_soc_codec *codec)

static int wm9705_soc_resume(struct snd_soc_codec *codec)
{
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
int ret;

ret = snd_ac97_reset(ac97, true, WM9705_VENDOR_ID,
ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID,
WM9705_VENDOR_ID_MASK);
if (ret < 0)
return ret;
Expand All @@ -311,38 +319,45 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)

static int wm9705_soc_probe(struct snd_soc_codec *codec)
{
struct snd_ac97 *ac97;
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
struct regmap *regmap;
int ret;

ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
WM9705_VENDOR_ID_MASK);
if (IS_ERR(ac97)) {
dev_err(codec->dev, "Failed to register AC97 codec\n");
return PTR_ERR(ac97);
}

regmap = regmap_init_ac97(ac97, &wm9705_regmap_config);
if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
goto err_free_ac97_codec;
if (wm9705->mfd_pdata) {
wm9705->ac97 = wm9705->mfd_pdata->ac97;
regmap = wm9705->mfd_pdata->regmap;
} else {
#ifdef CONFIG_SND_SOC_AC97_BUS
wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
WM9705_VENDOR_ID_MASK);
if (IS_ERR(wm9705->ac97)) {
dev_err(codec->dev, "Failed to register AC97 codec\n");
return PTR_ERR(wm9705->ac97);
}

regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
if (IS_ERR(regmap)) {
snd_soc_free_ac97_codec(wm9705->ac97);
return PTR_ERR(regmap);
}
#endif
}

snd_soc_codec_set_drvdata(codec, ac97);
snd_soc_codec_set_drvdata(codec, wm9705->ac97);
snd_soc_codec_init_regmap(codec, regmap);

return 0;
err_free_ac97_codec:
snd_soc_free_ac97_codec(ac97);
return ret;
}

static int wm9705_soc_remove(struct snd_soc_codec *codec)
{
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
#ifdef CONFIG_SND_SOC_AC97_BUS
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);

snd_soc_codec_exit_regmap(codec);
snd_soc_free_ac97_codec(ac97);
if (!wm9705->mfd_pdata) {
snd_soc_codec_exit_regmap(codec);
snd_soc_free_ac97_codec(wm9705->ac97);
}
#endif
return 0;
}

Expand All @@ -364,6 +379,15 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm9705 = {

static int wm9705_probe(struct platform_device *pdev)
{
struct wm9705_priv *wm9705;

wm9705 = devm_kzalloc(&pdev->dev, sizeof(*wm9705), GFP_KERNEL);
if (wm9705 == NULL)
return -ENOMEM;

wm9705->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9705);

return snd_soc_register_codec(&pdev->dev,
&soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai));
}
Expand Down
Loading

0 comments on commit df6a3e2

Please sign in to comment.