Skip to content

Commit

Permalink
Merge remote-tracking branches 'asoc/topic/rt5665', 'asoc/topic/rt567…
Browse files Browse the repository at this point in the history
…0', 'asoc/topic/rt5677', 'asoc/topic/samsung' and 'asoc/topic/simple' into asoc-next
  • Loading branch information
broonie committed Dec 12, 2016
6 parents b35ddfd + f2826c1 + d252800 + a40db07 + 1bfbc26 + 29a43aa commit f617134
Show file tree
Hide file tree
Showing 22 changed files with 751 additions and 1,210 deletions.
38 changes: 38 additions & 0 deletions Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Samsung Exynos5433 TM2(E) audio complex with WM5110 codec

Required properties:

- compatible : "samsung,tm2-audio"
- model : the user-visible name of this sound complex
- audio-codec : the phandle of the wm5110 audio codec node,
as described in ../mfd/arizona.txt
- i2s-controller : the phandle of the I2S controller
- audio-amplifier : the phandle of the MAX98504 amplifier
- samsung,audio-routing : a list of the connections between audio components;
each entry is a pair of strings, the first being the
connection's sink, the second being the connection's
source; valid names for sources and sinks are the
WM5110's and MAX98504's pins and the jacks on the
board: HP, SPK, Main Mic, Sub Mic, Third Mic,
Headset Mic
- mic-bias-gpios : GPIO pin that enables the Main Mic bias regulator


Example:

sound {
compatible = "samsung,tm2-audio";
audio-codec = <&wm5110>;
i2s-controller = <&i2s0>;
audio-amplifier = <&max98504>;
mic-bias-gpios = <&gpr3 2 0>;
model = "wm5110";
samsung,audio-routing =
"HP", "HPOUT1L",
"HP", "HPOUT1R",
"SPK", "SPKOUT",
"SPKOUT", "HPOUT2L",
"SPKOUT", "HPOUT2R",
"Main Mic", "MICBIAS2",
"IN1R", "Main Mic";
};
8 changes: 4 additions & 4 deletions include/sound/simple_card_utils.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* simple_card_core.h
* simple_card_utils.h
*
* Copyright (c) 2016 Kuninori Morimoto <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __SIMPLE_CARD_CORE_H
#define __SIMPLE_CARD_CORE_H
#ifndef __SIMPLE_CARD_UTILS_H
#define __SIMPLE_CARD_UTILS_H

#include <sound/soc.h>

Expand Down Expand Up @@ -68,4 +68,4 @@ void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link,

int asoc_simple_card_clean_reference(struct snd_soc_card *card);

#endif /* __SIMPLE_CARD_CORE_H */
#endif /* __SIMPLE_CARD_UTILS_H */
11 changes: 5 additions & 6 deletions sound/soc/codecs/rt5665.c
Original file line number Diff line number Diff line change
Expand Up @@ -4587,7 +4587,7 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
pr_err("HP Calibration Failure\n");
regmap_write(rt5665->regmap, RT5665_RESET, 0);
regcache_cache_bypass(rt5665->regmap, false);
return;
goto out_unlock;
}

count++;
Expand All @@ -4606,7 +4606,7 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
pr_err("MONO Calibration Failure\n");
regmap_write(rt5665->regmap, RT5665_RESET, 0);
regcache_cache_bypass(rt5665->regmap, false);
return;
goto out_unlock;
}

count++;
Expand All @@ -4621,6 +4621,7 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
regmap_write(rt5665->regmap, RT5665_BIAS_CUR_CTRL_8, 0xa602);
regmap_write(rt5665->regmap, RT5665_ASRC_8, 0x0120);

out_unlock:
mutex_unlock(&rt5665->calibrate_mutex);
}

Expand Down Expand Up @@ -4676,11 +4677,9 @@ static int rt5665_i2c_probe(struct i2c_client *i2c,
}

if (gpio_is_valid(rt5665->pdata.ldo1_en)) {
if (devm_gpio_request(&i2c->dev, rt5665->pdata.ldo1_en,
"rt5665"))
if (devm_gpio_request_one(&i2c->dev, rt5665->pdata.ldo1_en,
GPIOF_OUT_INIT_HIGH, "rt5665"))
dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n");
else if (gpio_direction_output(rt5665->pdata.ldo1_en, 1))
dev_err(&i2c->dev, "Fail gpio_direction gpio_ldo\n");
}

/* Sleep for 300 ms miniumum */
Expand Down
16 changes: 13 additions & 3 deletions sound/soc/codecs/rt5670.c
Original file line number Diff line number Diff line change
Expand Up @@ -2618,15 +2618,15 @@ static int rt5670_set_bias_level(struct snd_soc_codec *codec,
RT5670_OSW_L_DIS | RT5670_OSW_R_DIS);
snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x1);
snd_soc_update_bits(codec, RT5670_PWR_ANLG1,
RT5670_LDO_SEL_MASK, 0x3);
RT5670_LDO_SEL_MASK, 0x5);
}
break;
case SND_SOC_BIAS_STANDBY:
snd_soc_update_bits(codec, RT5670_PWR_ANLG1,
RT5670_PWR_VREF1 | RT5670_PWR_VREF2 |
RT5670_PWR_FV1 | RT5670_PWR_FV2, 0);
snd_soc_update_bits(codec, RT5670_PWR_ANLG1,
RT5670_LDO_SEL_MASK, 0x1);
RT5670_LDO_SEL_MASK, 0x3);
break;
case SND_SOC_BIAS_OFF:
if (rt5670->pdata.jd_mode)
Expand Down Expand Up @@ -2813,6 +2813,7 @@ MODULE_DEVICE_TABLE(i2c, rt5670_i2c_id);
#ifdef CONFIG_ACPI
static const struct acpi_device_id rt5670_acpi_match[] = {
{ "10EC5670", 0},
{ "10EC5672", 0},
{ },
};
MODULE_DEVICE_TABLE(acpi, rt5670_acpi_match);
Expand All @@ -2826,6 +2827,13 @@ static const struct dmi_system_id dmi_platform_intel_braswell[] = {
DMI_MATCH(DMI_BOARD_NAME, "Braswell CRB"),
},
},
{
.ident = "Dell Wyse 3040",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Wyse 3040"),
},
},
{}
};

Expand Down Expand Up @@ -2889,6 +2897,9 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
if (ret != 0)
dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);

regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC,
RT5670_MCLK_DET, RT5670_MCLK_DET);

if (rt5670->pdata.in2_diff)
regmap_update_bits(rt5670->regmap, RT5670_IN2,
RT5670_IN_DF2, RT5670_IN_DF2);
Expand All @@ -2903,7 +2914,6 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_IRQ);
regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2,
RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT);
regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC, 0x8, 0x8);
}

if (rt5670->pdata.jd_mode) {
Expand Down
1 change: 1 addition & 0 deletions sound/soc/codecs/rt5670.h
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,7 @@ enum {
#define RT5670_IF1_ADC1_IN2_SFT 11
#define RT5670_IF1_ADC2_IN1_SEL (0x1 << 10)
#define RT5670_IF1_ADC2_IN1_SFT 10
#define RT5670_MCLK_DET (0x1 << 3)

/* General Control2 (0xfb) */
#define RT5670_RXDC_SRC_MASK (0x1 << 7)
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/rt5677-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/regulator/consumer.h>
Expand Down
5 changes: 1 addition & 4 deletions sound/soc/generic/simple-card-utils.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* simple-card-core.c
* simple-card-utils.c
*
* Copyright (c) 2016 Kuninori Morimoto <[email protected]>
*
Expand Down Expand Up @@ -195,9 +195,6 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai);

int asoc_simple_card_canonicalize_dailink(struct snd_soc_dai_link *dai_link)
{
if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name)
return -EINVAL;

/* Assumes platform == cpu */
if (!dai_link->platform_of_node)
dai_link->platform_of_node = dai_link->cpu_of_node;
Expand Down
113 changes: 50 additions & 63 deletions sound/soc/generic/simple-scu-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <sound/soc-dai.h>
#include <sound/simple_card_utils.h>

struct asoc_simple_card_priv {
struct simple_card_data {
struct snd_soc_card snd_card;
struct snd_soc_codec_conf codec_conf;
struct asoc_simple_dai *dai_props;
Expand All @@ -42,7 +42,7 @@ struct asoc_simple_card_priv {
static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
struct asoc_simple_dai *dai_props =
simple_priv_to_props(priv, rtd->num);

Expand All @@ -52,7 +52,7 @@ static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
struct asoc_simple_dai *dai_props =
simple_priv_to_props(priv, rtd->num);

Expand All @@ -66,7 +66,7 @@ static const struct snd_soc_ops asoc_simple_card_ops = {

static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
{
struct asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *dai;
struct snd_soc_dai_link *dai_link;
struct asoc_simple_dai *dai_props;
Expand All @@ -84,7 +84,7 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
static int asoc_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
struct asoc_simple_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
struct snd_interval *rate = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_RATE);
struct snd_interval *channels = hw_param_interval(params,
Expand All @@ -101,8 +101,8 @@ static int asoc_simple_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
return 0;
}

static int asoc_simple_card_parse_links(struct device_node *np,
struct asoc_simple_card_priv *priv,
static int asoc_simple_card_dai_link_of(struct device_node *np,
struct simple_card_data *priv,
unsigned int daifmt,
int idx, bool is_fe)
{
Expand Down Expand Up @@ -195,22 +195,35 @@ static int asoc_simple_card_parse_links(struct device_node *np,
return 0;
}

static int asoc_simple_card_dai_link_of(struct device_node *node,
struct asoc_simple_card_priv *priv)
static int asoc_simple_card_parse_of(struct device_node *node,
struct simple_card_data *priv)

{
struct device *dev = simple_priv_to_dev(priv);
struct device_node *np;
unsigned int daifmt = 0;
int ret, i;
bool is_fe;
int ret, i;

if (!node)
return -EINVAL;

ret = snd_soc_of_parse_audio_routing(&priv->snd_card, PREFIX "routing");
if (ret < 0)
return ret;

/* sampling rate convert */
of_property_read_u32(node, PREFIX "convert-rate", &priv->convert_rate);

/* channels transfer */
of_property_read_u32(node, PREFIX "convert-channels", &priv->convert_channels);

/* find 1st codec */
np = of_get_child_by_name(node, PREFIX "codec");
if (!np)
return -ENODEV;

ret = asoc_simple_card_parse_daifmt(dev, node, np,
PREFIX, &daifmt);
ret = asoc_simple_card_parse_daifmt(dev, node, np, PREFIX, &daifmt);
if (ret < 0)
return ret;

Expand All @@ -220,58 +233,12 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
if (strcmp(np->name, PREFIX "cpu") == 0)
is_fe = true;

ret = asoc_simple_card_parse_links(np, priv, daifmt, i, is_fe);
ret = asoc_simple_card_dai_link_of(np, priv, daifmt, i, is_fe);
if (ret < 0)
return ret;
i++;
}

return 0;
}

static int asoc_simple_card_parse_of(struct device_node *node,
struct asoc_simple_card_priv *priv,
struct device *dev)
{
struct asoc_simple_dai *props;
struct snd_soc_dai_link *links;
int ret;
int num;

if (!node)
return -EINVAL;

num = of_get_child_count(node);
props = devm_kzalloc(dev, sizeof(*props) * num, GFP_KERNEL);
links = devm_kzalloc(dev, sizeof(*links) * num, GFP_KERNEL);
if (!props || !links)
return -ENOMEM;

priv->dai_props = props;
priv->dai_link = links;

/* Init snd_soc_card */
priv->snd_card.owner = THIS_MODULE;
priv->snd_card.dev = dev;
priv->snd_card.dai_link = priv->dai_link;
priv->snd_card.num_links = num;
priv->snd_card.codec_conf = &priv->codec_conf;
priv->snd_card.num_configs = 1;

ret = snd_soc_of_parse_audio_routing(&priv->snd_card, PREFIX "routing");
if (ret < 0)
return ret;

/* sampling rate convert */
of_property_read_u32(node, PREFIX "convert-rate", &priv->convert_rate);

/* channels transfer */
of_property_read_u32(node, PREFIX "convert-channels", &priv->convert_channels);

ret = asoc_simple_card_dai_link_of(node, priv);
if (ret < 0)
return ret;

ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
if (ret < 0)
return ret;
Expand All @@ -286,17 +253,37 @@ static int asoc_simple_card_parse_of(struct device_node *node,

static int asoc_simple_card_probe(struct platform_device *pdev)
{
struct asoc_simple_card_priv *priv;
struct device_node *np = pdev->dev.of_node;
struct simple_card_data *priv;
struct snd_soc_dai_link *dai_link;
struct asoc_simple_dai *dai_props;
struct device *dev = &pdev->dev;
int ret;
struct device_node *np = pdev->dev.of_node;
int num, ret;

/* Allocate the private data */
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;

ret = asoc_simple_card_parse_of(np, priv, dev);
num = of_get_child_count(np);

dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
if (!dai_props || !dai_link)
return -ENOMEM;

priv->dai_props = dai_props;
priv->dai_link = dai_link;

/* Init snd_soc_card */
priv->snd_card.owner = THIS_MODULE;
priv->snd_card.dev = dev;
priv->snd_card.dai_link = priv->dai_link;
priv->snd_card.num_links = num;
priv->snd_card.codec_conf = &priv->codec_conf;
priv->snd_card.num_configs = 1;

ret = asoc_simple_card_parse_of(np, priv);
if (ret < 0) {
if (ret != -EPROBE_DEFER)
dev_err(dev, "parse error %d\n", ret);
Expand Down
Loading

0 comments on commit f617134

Please sign in to comment.