Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 3b04e29f authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'asoc/topic/wm8523', 'asoc/topic/wm8524',...

Merge remote-tracking branches 'asoc/topic/wm8523', 'asoc/topic/wm8524', 'asoc/topic/wm8580', 'asoc/topic/wm8711' and 'asoc/topic/wm8727' into asoc-next
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -10,7 +10,7 @@ Required properties:


Example:
Example:


codec: wm8524@0 {
codec: wm8524 {
	compatible = "wlf,wm8524";
	compatible = "wlf,wm8524";
	wlf,mute-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
	wlf,mute-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
};
};
+46 −52
Original line number Original line Diff line number Diff line
@@ -125,14 +125,14 @@ static const struct {
static int wm8523_startup(struct snd_pcm_substream *substream,
static int wm8523_startup(struct snd_pcm_substream *substream,
			  struct snd_soc_dai *dai)
			  struct snd_soc_dai *dai)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
	struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);


	/* The set of sample rates that can be supported depends on the
	/* The set of sample rates that can be supported depends on the
	 * MCLK supplied to the CODEC - enforce this.
	 * MCLK supplied to the CODEC - enforce this.
	 */
	 */
	if (!wm8523->sysclk) {
	if (!wm8523->sysclk) {
		dev_err(codec->dev,
		dev_err(component->dev,
			"No MCLK configured, call set_sysclk() on init\n");
			"No MCLK configured, call set_sysclk() on init\n");
		return -EINVAL;
		return -EINVAL;
	}
	}
@@ -148,11 +148,11 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
			    struct snd_pcm_hw_params *params,
			    struct snd_pcm_hw_params *params,
			    struct snd_soc_dai *dai)
			    struct snd_soc_dai *dai)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
	struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
	int i;
	int i;
	u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1);
	u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1);
	u16 aifctrl2 = snd_soc_read(codec, WM8523_AIF_CTRL2);
	u16 aifctrl2 = snd_soc_component_read32(component, WM8523_AIF_CTRL2);


	/* Find a supported LRCLK ratio */
	/* Find a supported LRCLK ratio */
	for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
	for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
@@ -163,7 +163,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,


	/* Should never happen, should be handled by constraints */
	/* Should never happen, should be handled by constraints */
	if (i == ARRAY_SIZE(lrclk_ratios)) {
	if (i == ARRAY_SIZE(lrclk_ratios)) {
		dev_err(codec->dev, "MCLK/fs ratio %d unsupported\n",
		dev_err(component->dev, "MCLK/fs ratio %d unsupported\n",
			wm8523->sysclk / params_rate(params));
			wm8523->sysclk / params_rate(params));
		return -EINVAL;
		return -EINVAL;
	}
	}
@@ -178,7 +178,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
				break;
				break;


		if (i == ARRAY_SIZE(bclk_ratios)) {
		if (i == ARRAY_SIZE(bclk_ratios)) {
			dev_err(codec->dev,
			dev_err(component->dev,
				"No matching BCLK/fs ratio for word length %d\n",
				"No matching BCLK/fs ratio for word length %d\n",
				params_width(params));
				params_width(params));
			return -EINVAL;
			return -EINVAL;
@@ -203,8 +203,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
		break;
		break;
	}
	}


	snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1);
	snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1);
	snd_soc_write(codec, WM8523_AIF_CTRL2, aifctrl2);
	snd_soc_component_write(component, WM8523_AIF_CTRL2, aifctrl2);


	return 0;
	return 0;
}
}
@@ -212,8 +212,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
		int clk_id, unsigned int freq, int dir)
		int clk_id, unsigned int freq, int dir)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
	struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
	unsigned int val;
	unsigned int val;
	int i;
	int i;


@@ -239,13 +239,13 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
		case 96000:
		case 96000:
		case 176400:
		case 176400:
		case 192000:
		case 192000:
			dev_dbg(codec->dev, "Supported sample rate: %dHz\n",
			dev_dbg(component->dev, "Supported sample rate: %dHz\n",
				val);
				val);
			wm8523->rate_constraint_list[i] = val;
			wm8523->rate_constraint_list[i] = val;
			wm8523->rate_constraint.count++;
			wm8523->rate_constraint.count++;
			break;
			break;
		default:
		default:
			dev_dbg(codec->dev, "Skipping sample rate: %dHz\n",
			dev_dbg(component->dev, "Skipping sample rate: %dHz\n",
				val);
				val);
		}
		}
	}
	}
@@ -261,8 +261,8 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai,
		unsigned int fmt)
		unsigned int fmt)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1);
	u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1);


	aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK |
	aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK |
		      WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK);
		      WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK);
@@ -312,15 +312,15 @@ static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai,
		return -EINVAL;
		return -EINVAL;
	}
	}


	snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1);
	snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1);


	return 0;
	return 0;
}
}


static int wm8523_set_bias_level(struct snd_soc_codec *codec,
static int wm8523_set_bias_level(struct snd_soc_component *component,
				 enum snd_soc_bias_level level)
				 enum snd_soc_bias_level level)
{
{
	struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
	struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
	int ret;
	int ret;


	switch (level) {
	switch (level) {
@@ -329,16 +329,16 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,


	case SND_SOC_BIAS_PREPARE:
	case SND_SOC_BIAS_PREPARE:
		/* Full power on */
		/* Full power on */
		snd_soc_update_bits(codec, WM8523_PSCTRL1,
		snd_soc_component_update_bits(component, WM8523_PSCTRL1,
				    WM8523_SYS_ENA_MASK, 3);
				    WM8523_SYS_ENA_MASK, 3);
		break;
		break;


	case SND_SOC_BIAS_STANDBY:
	case SND_SOC_BIAS_STANDBY:
		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
			ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
			ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
						    wm8523->supplies);
						    wm8523->supplies);
			if (ret != 0) {
			if (ret != 0) {
				dev_err(codec->dev,
				dev_err(component->dev,
					"Failed to enable supplies: %d\n",
					"Failed to enable supplies: %d\n",
					ret);
					ret);
				return ret;
				return ret;
@@ -348,21 +348,21 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
			regcache_sync(wm8523->regmap);
			regcache_sync(wm8523->regmap);


			/* Initial power up */
			/* Initial power up */
			snd_soc_update_bits(codec, WM8523_PSCTRL1,
			snd_soc_component_update_bits(component, WM8523_PSCTRL1,
					    WM8523_SYS_ENA_MASK, 1);
					    WM8523_SYS_ENA_MASK, 1);


			msleep(100);
			msleep(100);
		}
		}


		/* Power up to mute */
		/* Power up to mute */
		snd_soc_update_bits(codec, WM8523_PSCTRL1,
		snd_soc_component_update_bits(component, WM8523_PSCTRL1,
				    WM8523_SYS_ENA_MASK, 2);
				    WM8523_SYS_ENA_MASK, 2);


		break;
		break;


	case SND_SOC_BIAS_OFF:
	case SND_SOC_BIAS_OFF:
		/* The chip runs through the power down sequence for us. */
		/* The chip runs through the power down sequence for us. */
		snd_soc_update_bits(codec, WM8523_PSCTRL1,
		snd_soc_component_update_bits(component, WM8523_PSCTRL1,
				    WM8523_SYS_ENA_MASK, 0);
				    WM8523_SYS_ENA_MASK, 0);
		msleep(100);
		msleep(100);


@@ -397,35 +397,36 @@ static struct snd_soc_dai_driver wm8523_dai = {
	.ops = &wm8523_dai_ops,
	.ops = &wm8523_dai_ops,
};
};


static int wm8523_probe(struct snd_soc_codec *codec)
static int wm8523_probe(struct snd_soc_component *component)
{
{
	struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
	struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);


	wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0];
	wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0];
	wm8523->rate_constraint.count =
	wm8523->rate_constraint.count =
		ARRAY_SIZE(wm8523->rate_constraint_list);
		ARRAY_SIZE(wm8523->rate_constraint_list);


	/* Change some default settings - latch VU and enable ZC */
	/* Change some default settings - latch VU and enable ZC */
	snd_soc_update_bits(codec, WM8523_DAC_GAINR,
	snd_soc_component_update_bits(component, WM8523_DAC_GAINR,
			    WM8523_DACR_VU, WM8523_DACR_VU);
			    WM8523_DACR_VU, WM8523_DACR_VU);
	snd_soc_update_bits(codec, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC);
	snd_soc_component_update_bits(component, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC);


	return 0;
	return 0;
}
}


static const struct snd_soc_codec_driver soc_codec_dev_wm8523 = {
static const struct snd_soc_component_driver soc_component_dev_wm8523 = {
	.probe			= wm8523_probe,
	.probe			= wm8523_probe,
	.set_bias_level		= wm8523_set_bias_level,
	.set_bias_level		= wm8523_set_bias_level,
	.suspend_bias_off = true,

	.component_driver = {
	.controls		= wm8523_controls,
	.controls		= wm8523_controls,
	.num_controls		= ARRAY_SIZE(wm8523_controls),
	.num_controls		= ARRAY_SIZE(wm8523_controls),
	.dapm_widgets		= wm8523_dapm_widgets,
	.dapm_widgets		= wm8523_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(wm8523_dapm_widgets),
	.num_dapm_widgets	= ARRAY_SIZE(wm8523_dapm_widgets),
	.dapm_routes		= wm8523_dapm_routes,
	.dapm_routes		= wm8523_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(wm8523_dapm_routes),
	.num_dapm_routes	= ARRAY_SIZE(wm8523_dapm_routes),
	},
	.suspend_bias_off	= 1,
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};
};


static const struct of_device_id wm8523_of_match[] = {
static const struct of_device_id wm8523_of_match[] = {
@@ -511,8 +512,8 @@ static int wm8523_i2c_probe(struct i2c_client *i2c,


	i2c_set_clientdata(i2c, wm8523);
	i2c_set_clientdata(i2c, wm8523);


	ret =  snd_soc_register_codec(&i2c->dev,
	ret = devm_snd_soc_register_component(&i2c->dev,
			&soc_codec_dev_wm8523, &wm8523_dai, 1);
			&soc_component_dev_wm8523, &wm8523_dai, 1);


	return ret;
	return ret;


@@ -521,12 +522,6 @@ static int wm8523_i2c_probe(struct i2c_client *i2c,
	return ret;
	return ret;
}
}


static int wm8523_i2c_remove(struct i2c_client *client)
{
	snd_soc_unregister_codec(&client->dev);
	return 0;
}

static const struct i2c_device_id wm8523_i2c_id[] = {
static const struct i2c_device_id wm8523_i2c_id[] = {
	{ "wm8523", 0 },
	{ "wm8523", 0 },
	{ }
	{ }
@@ -539,7 +534,6 @@ static struct i2c_driver wm8523_i2c_driver = {
		.of_match_table = wm8523_of_match,
		.of_match_table = wm8523_of_match,
	},
	},
	.probe =    wm8523_i2c_probe,
	.probe =    wm8523_i2c_probe,
	.remove =   wm8523_i2c_remove,
	.id_table = wm8523_i2c_id,
	.id_table = wm8523_i2c_id,
};
};


+25 −31
Original line number Original line Diff line number Diff line
@@ -62,14 +62,14 @@ static const struct {
static int wm8524_startup(struct snd_pcm_substream *substream,
static int wm8524_startup(struct snd_pcm_substream *substream,
			  struct snd_soc_dai *dai)
			  struct snd_soc_dai *dai)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec);
	struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);


	/* The set of sample rates that can be supported depends on the
	/* The set of sample rates that can be supported depends on the
	 * MCLK supplied to the CODEC - enforce this.
	 * MCLK supplied to the CODEC - enforce this.
	 */
	 */
	if (!wm8524->sysclk) {
	if (!wm8524->sysclk) {
		dev_err(codec->dev,
		dev_err(component->dev,
			"No MCLK configured, call set_sysclk() on init\n");
			"No MCLK configured, call set_sysclk() on init\n");
		return -EINVAL;
		return -EINVAL;
	}
	}
@@ -86,8 +86,8 @@ static int wm8524_startup(struct snd_pcm_substream *substream,
static void wm8524_shutdown(struct snd_pcm_substream *substream,
static void wm8524_shutdown(struct snd_pcm_substream *substream,
			  struct snd_soc_dai *dai)
			  struct snd_soc_dai *dai)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec);
	struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);


	gpiod_set_value_cansleep(wm8524->mute, 0);
	gpiod_set_value_cansleep(wm8524->mute, 0);
}
}
@@ -95,8 +95,8 @@ static void wm8524_shutdown(struct snd_pcm_substream *substream,
static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai,
		int clk_id, unsigned int freq, int dir)
		int clk_id, unsigned int freq, int dir)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec);
	struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);
	unsigned int val;
	unsigned int val;
	int i, j = 0;
	int i, j = 0;


@@ -118,13 +118,13 @@ static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai,
		case 96000:
		case 96000:
		case 176400:
		case 176400:
		case 192000:
		case 192000:
			dev_dbg(codec->dev, "Supported sample rate: %dHz\n",
			dev_dbg(component->dev, "Supported sample rate: %dHz\n",
				val);
				val);
			wm8524->rate_constraint_list[j++] = val;
			wm8524->rate_constraint_list[j++] = val;
			wm8524->rate_constraint.count++;
			wm8524->rate_constraint.count++;
			break;
			break;
		default:
		default:
			dev_dbg(codec->dev, "Skipping sample rate: %dHz\n",
			dev_dbg(component->dev, "Skipping sample rate: %dHz\n",
				val);
				val);
		}
		}
	}
	}
@@ -152,7 +152,7 @@ static int wm8524_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)


static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
{
{
	struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(dai->codec);
	struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(dai->component);


	if (wm8524->mute)
	if (wm8524->mute)
		gpiod_set_value_cansleep(wm8524->mute, mute);
		gpiod_set_value_cansleep(wm8524->mute, mute);
@@ -184,9 +184,9 @@ static struct snd_soc_dai_driver wm8524_dai = {
	.ops = &wm8524_dai_ops,
	.ops = &wm8524_dai_ops,
};
};


static int wm8524_probe(struct snd_soc_codec *codec)
static int wm8524_probe(struct snd_soc_component *component)
{
{
	struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec);
	struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);


	wm8524->rate_constraint.list = &wm8524->rate_constraint_list[0];
	wm8524->rate_constraint.list = &wm8524->rate_constraint_list[0];
	wm8524->rate_constraint.count =
	wm8524->rate_constraint.count =
@@ -195,15 +195,16 @@ static int wm8524_probe(struct snd_soc_codec *codec)
	return 0;
	return 0;
}
}


static const struct snd_soc_codec_driver soc_codec_dev_wm8524 = {
static const struct snd_soc_component_driver soc_component_dev_wm8524 = {
	.probe			= wm8524_probe,
	.probe			= wm8524_probe,

	.component_driver = {
	.dapm_widgets		= wm8524_dapm_widgets,
	.dapm_widgets		= wm8524_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(wm8524_dapm_widgets),
	.num_dapm_widgets	= ARRAY_SIZE(wm8524_dapm_widgets),
	.dapm_routes		= wm8524_dapm_routes,
	.dapm_routes		= wm8524_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(wm8524_dapm_routes),
	.num_dapm_routes	= ARRAY_SIZE(wm8524_dapm_routes),
	},
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};
};


static const struct of_device_id wm8524_of_match[] = {
static const struct of_device_id wm8524_of_match[] = {
@@ -231,23 +232,16 @@ static int wm8524_codec_probe(struct platform_device *pdev)
		return ret;
		return ret;
	}
	}


	ret =  snd_soc_register_codec(&pdev->dev,
	ret = devm_snd_soc_register_component(&pdev->dev,
			&soc_codec_dev_wm8524, &wm8524_dai, 1);
			&soc_component_dev_wm8524, &wm8524_dai, 1);
	if (ret < 0)
	if (ret < 0)
		dev_err(&pdev->dev, "Failed to register codec: %d\n", ret);
		dev_err(&pdev->dev, "Failed to register component: %d\n", ret);


	return ret;
	return ret;
}
}


static int wm8524_codec_remove(struct platform_device *pdev)
{
	snd_soc_unregister_codec(&pdev->dev);
	return 0;
}

static struct platform_driver wm8524_codec_driver = {
static struct platform_driver wm8524_codec_driver = {
	.probe		= wm8524_codec_probe,
	.probe		= wm8524_codec_probe,
	.remove		= wm8524_codec_remove,
	.driver		= {
	.driver		= {
		.name	= "wm8524-codec",
		.name	= "wm8524-codec",
		.of_match_table = wm8524_of_match,
		.of_match_table = wm8524_of_match,
+71 −79
Original line number Original line Diff line number Diff line
@@ -262,8 +262,8 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol,
{
{
	struct soc_mixer_control *mc =
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;
		(struct soc_mixer_control *)kcontrol->private_value;
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
	struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);
	unsigned int reg = mc->reg;
	unsigned int reg = mc->reg;
	unsigned int reg2 = mc->rreg;
	unsigned int reg2 = mc->rreg;
	int ret;
	int ret;
@@ -279,8 +279,8 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol,
		return ret;
		return ret;


	/* Now write again with the volume update bit set */
	/* Now write again with the volume update bit set */
	snd_soc_update_bits(codec, reg, 0x100, 0x100);
	snd_soc_component_update_bits(component, reg, 0x100, 0x100);
	snd_soc_update_bits(codec, reg2, 0x100, 0x100);
	snd_soc_component_update_bits(component, reg2, 0x100, 0x100);


	return 0;
	return 0;
}
}
@@ -465,8 +465,8 @@ static int wm8580_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
		int source, unsigned int freq_in, unsigned int freq_out)
		int source, unsigned int freq_in, unsigned int freq_out)
{
{
	int offset;
	int offset;
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
	struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);
	struct pll_state *state;
	struct pll_state *state;
	struct _pll_div pll_div;
	struct _pll_div pll_div;
	unsigned int reg;
	unsigned int reg;
@@ -505,25 +505,25 @@ static int wm8580_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
	/* Always disable the PLL - it is not safe to leave it running
	/* Always disable the PLL - it is not safe to leave it running
	 * while reprogramming it.
	 * while reprogramming it.
	 */
	 */
	snd_soc_update_bits(codec, WM8580_PWRDN2, pwr_mask, pwr_mask);
	snd_soc_component_update_bits(component, WM8580_PWRDN2, pwr_mask, pwr_mask);


	if (!freq_in || !freq_out)
	if (!freq_in || !freq_out)
		return 0;
		return 0;


	snd_soc_write(codec, WM8580_PLLA1 + offset, pll_div.k & 0x1ff);
	snd_soc_component_write(component, WM8580_PLLA1 + offset, pll_div.k & 0x1ff);
	snd_soc_write(codec, WM8580_PLLA2 + offset, (pll_div.k >> 9) & 0x1ff);
	snd_soc_component_write(component, WM8580_PLLA2 + offset, (pll_div.k >> 9) & 0x1ff);
	snd_soc_write(codec, WM8580_PLLA3 + offset,
	snd_soc_component_write(component, WM8580_PLLA3 + offset,
		     (pll_div.k >> 18 & 0xf) | (pll_div.n << 4));
		     (pll_div.k >> 18 & 0xf) | (pll_div.n << 4));


	reg = snd_soc_read(codec, WM8580_PLLA4 + offset);
	reg = snd_soc_component_read32(component, WM8580_PLLA4 + offset);
	reg &= ~0x1b;
	reg &= ~0x1b;
	reg |= pll_div.prescale | pll_div.postscale << 1 |
	reg |= pll_div.prescale | pll_div.postscale << 1 |
		pll_div.freqmode << 3;
		pll_div.freqmode << 3;


	snd_soc_write(codec, WM8580_PLLA4 + offset, reg);
	snd_soc_component_write(component, WM8580_PLLA4 + offset, reg);


	/* All done, turn it on */
	/* All done, turn it on */
	snd_soc_update_bits(codec, WM8580_PWRDN2, pwr_mask, 0);
	snd_soc_component_update_bits(component, WM8580_PWRDN2, pwr_mask, 0);


	return 0;
	return 0;
}
}
@@ -539,8 +539,8 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream,
				 struct snd_pcm_hw_params *params,
				 struct snd_pcm_hw_params *params,
				 struct snd_soc_dai *dai)
				 struct snd_soc_dai *dai)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
	struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);
	u16 paifa = 0;
	u16 paifa = 0;
	u16 paifb = 0;
	u16 paifb = 0;
	int i, ratio, osr;
	int i, ratio, osr;
@@ -572,12 +572,12 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream,
		if (ratio == wm8580_sysclk_ratios[i])
		if (ratio == wm8580_sysclk_ratios[i])
			break;
			break;
	if (i == ARRAY_SIZE(wm8580_sysclk_ratios)) {
	if (i == ARRAY_SIZE(wm8580_sysclk_ratios)) {
		dev_err(codec->dev, "Invalid clock ratio %d/%d\n",
		dev_err(component->dev, "Invalid clock ratio %d/%d\n",
			wm8580->sysclk[dai->driver->id], params_rate(params));
			wm8580->sysclk[dai->driver->id], params_rate(params));
		return -EINVAL;
		return -EINVAL;
	}
	}
	paifa |= i;
	paifa |= i;
	dev_dbg(codec->dev, "Running at %dfs with %dHz clock\n",
	dev_dbg(component->dev, "Running at %dfs with %dHz clock\n",
		wm8580_sysclk_ratios[i], wm8580->sysclk[dai->driver->id]);
		wm8580_sysclk_ratios[i], wm8580->sysclk[dai->driver->id]);


	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -585,21 +585,21 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream,
		case 128:
		case 128:
		case 192:
		case 192:
			osr = WM8580_DACOSR;
			osr = WM8580_DACOSR;
			dev_dbg(codec->dev, "Selecting 64x OSR\n");
			dev_dbg(component->dev, "Selecting 64x OSR\n");
			break;
			break;
		default:
		default:
			osr = 0;
			osr = 0;
			dev_dbg(codec->dev, "Selecting 128x OSR\n");
			dev_dbg(component->dev, "Selecting 128x OSR\n");
			break;
			break;
		}
		}


		snd_soc_update_bits(codec, WM8580_PAIF3, WM8580_DACOSR, osr);
		snd_soc_component_update_bits(component, WM8580_PAIF3, WM8580_DACOSR, osr);
	}
	}


	snd_soc_update_bits(codec, WM8580_PAIF1 + dai->driver->id,
	snd_soc_component_update_bits(component, WM8580_PAIF1 + dai->driver->id,
			    WM8580_AIF_RATE_MASK | WM8580_AIF_BCLKSEL_MASK,
			    WM8580_AIF_RATE_MASK | WM8580_AIF_BCLKSEL_MASK,
			    paifa);
			    paifa);
	snd_soc_update_bits(codec, WM8580_PAIF3 + dai->driver->id,
	snd_soc_component_update_bits(component, WM8580_PAIF3 + dai->driver->id,
			    WM8580_AIF_LENGTH_MASK, paifb);
			    WM8580_AIF_LENGTH_MASK, paifb);
	return 0;
	return 0;
}
}
@@ -607,13 +607,13 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream,
static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai,
static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai,
				      unsigned int fmt)
				      unsigned int fmt)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	unsigned int aifa;
	unsigned int aifa;
	unsigned int aifb;
	unsigned int aifb;
	int can_invert_lrclk;
	int can_invert_lrclk;


	aifa = snd_soc_read(codec, WM8580_PAIF1 + codec_dai->driver->id);
	aifa = snd_soc_component_read32(component, WM8580_PAIF1 + codec_dai->driver->id);
	aifb = snd_soc_read(codec, WM8580_PAIF3 + codec_dai->driver->id);
	aifb = snd_soc_component_read32(component, WM8580_PAIF3 + codec_dai->driver->id);


	aifb &= ~(WM8580_AIF_FMT_MASK | WM8580_AIF_LRP | WM8580_AIF_BCP);
	aifb &= ~(WM8580_AIF_FMT_MASK | WM8580_AIF_LRP | WM8580_AIF_BCP);


@@ -679,8 +679,8 @@ static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai,
		return -EINVAL;
		return -EINVAL;
	}
	}


	snd_soc_write(codec, WM8580_PAIF1 + codec_dai->driver->id, aifa);
	snd_soc_component_write(component, WM8580_PAIF1 + codec_dai->driver->id, aifa);
	snd_soc_write(codec, WM8580_PAIF3 + codec_dai->driver->id, aifb);
	snd_soc_component_write(component, WM8580_PAIF3 + codec_dai->driver->id, aifb);


	return 0;
	return 0;
}
}
@@ -688,12 +688,12 @@ static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai,
static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
				 int div_id, int div)
				 int div_id, int div)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	unsigned int reg;
	unsigned int reg;


	switch (div_id) {
	switch (div_id) {
	case WM8580_MCLK:
	case WM8580_MCLK:
		reg = snd_soc_read(codec, WM8580_PLLB4);
		reg = snd_soc_component_read32(component, WM8580_PLLB4);
		reg &= ~WM8580_PLLB4_MCLKOUTSRC_MASK;
		reg &= ~WM8580_PLLB4_MCLKOUTSRC_MASK;


		switch (div) {
		switch (div) {
@@ -715,11 +715,11 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
		default:
		default:
			return -EINVAL;
			return -EINVAL;
		}
		}
		snd_soc_write(codec, WM8580_PLLB4, reg);
		snd_soc_component_write(component, WM8580_PLLB4, reg);
		break;
		break;


	case WM8580_CLKOUTSRC:
	case WM8580_CLKOUTSRC:
		reg = snd_soc_read(codec, WM8580_PLLB4);
		reg = snd_soc_component_read32(component, WM8580_PLLB4);
		reg &= ~WM8580_PLLB4_CLKOUTSRC_MASK;
		reg &= ~WM8580_PLLB4_CLKOUTSRC_MASK;


		switch (div) {
		switch (div) {
@@ -741,7 +741,7 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
		default:
		default:
			return -EINVAL;
			return -EINVAL;
		}
		}
		snd_soc_write(codec, WM8580_PLLB4, reg);
		snd_soc_component_write(component, WM8580_PLLB4, reg);
		break;
		break;


	default:
	default:
@@ -754,8 +754,8 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id,
			     unsigned int freq, int dir)
			     unsigned int freq, int dir)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
	struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);
	int ret, sel, sel_mask, sel_shift;
	int ret, sel, sel_mask, sel_shift;


	switch (dai->driver->id) {
	switch (dai->driver->id) {
@@ -790,14 +790,14 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id,
		sel = 3 << sel_shift;
		sel = 3 << sel_shift;
		break;
		break;
	default:
	default:
		dev_err(codec->dev, "Unknown clock %d\n", clk_id);
		dev_err(component->dev, "Unknown clock %d\n", clk_id);
		return -EINVAL;
		return -EINVAL;
	}
	}


	/* We really should validate PLL settings but not yet */
	/* We really should validate PLL settings but not yet */
	wm8580->sysclk[dai->driver->id] = freq;
	wm8580->sysclk[dai->driver->id] = freq;


	ret = snd_soc_update_bits(codec, WM8580_CLKSEL, sel_mask, sel);
	ret = snd_soc_component_update_bits(component, WM8580_CLKSEL, sel_mask, sel);
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;


@@ -806,22 +806,22 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id,


static int wm8580_digital_mute(struct snd_soc_dai *codec_dai, int mute)
static int wm8580_digital_mute(struct snd_soc_dai *codec_dai, int mute)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	unsigned int reg;
	unsigned int reg;


	reg = snd_soc_read(codec, WM8580_DAC_CONTROL5);
	reg = snd_soc_component_read32(component, WM8580_DAC_CONTROL5);


	if (mute)
	if (mute)
		reg |= WM8580_DAC_CONTROL5_MUTEALL;
		reg |= WM8580_DAC_CONTROL5_MUTEALL;
	else
	else
		reg &= ~WM8580_DAC_CONTROL5_MUTEALL;
		reg &= ~WM8580_DAC_CONTROL5_MUTEALL;


	snd_soc_write(codec, WM8580_DAC_CONTROL5, reg);
	snd_soc_component_write(component, WM8580_DAC_CONTROL5, reg);


	return 0;
	return 0;
}
}


static int wm8580_set_bias_level(struct snd_soc_codec *codec,
static int wm8580_set_bias_level(struct snd_soc_component *component,
	enum snd_soc_bias_level level)
	enum snd_soc_bias_level level)
{
{
	switch (level) {
	switch (level) {
@@ -830,20 +830,20 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec,
		break;
		break;


	case SND_SOC_BIAS_STANDBY:
	case SND_SOC_BIAS_STANDBY:
		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
			/* Power up and get individual control of the DACs */
			/* Power up and get individual control of the DACs */
			snd_soc_update_bits(codec, WM8580_PWRDN1,
			snd_soc_component_update_bits(component, WM8580_PWRDN1,
					    WM8580_PWRDN1_PWDN |
					    WM8580_PWRDN1_PWDN |
					    WM8580_PWRDN1_ALLDACPD, 0);
					    WM8580_PWRDN1_ALLDACPD, 0);


			/* Make VMID high impedance */
			/* Make VMID high impedance */
			snd_soc_update_bits(codec, WM8580_ADC_CONTROL1,
			snd_soc_component_update_bits(component, WM8580_ADC_CONTROL1,
					    0x100, 0);
					    0x100, 0);
		}
		}
		break;
		break;


	case SND_SOC_BIAS_OFF:
	case SND_SOC_BIAS_OFF:
		snd_soc_update_bits(codec, WM8580_PWRDN1,
		snd_soc_component_update_bits(component, WM8580_PWRDN1,
				    WM8580_PWRDN1_PWDN, WM8580_PWRDN1_PWDN);
				    WM8580_PWRDN1_PWDN, WM8580_PWRDN1_PWDN);
		break;
		break;
	}
	}
@@ -853,8 +853,8 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec,
static int wm8580_playback_startup(struct snd_pcm_substream *substream,
static int wm8580_playback_startup(struct snd_pcm_substream *substream,
			   struct snd_soc_dai *dai)
			   struct snd_soc_dai *dai)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
	struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);


	return snd_pcm_hw_constraint_minmax(substream->runtime,
	return snd_pcm_hw_constraint_minmax(substream->runtime,
		SNDRV_PCM_HW_PARAM_CHANNELS, 1, wm8580->drvdata->num_dacs * 2);
		SNDRV_PCM_HW_PARAM_CHANNELS, 1, wm8580->drvdata->num_dacs * 2);
@@ -907,15 +907,15 @@ static struct snd_soc_dai_driver wm8580_dai[] = {
	},
	},
};
};


static int wm8580_probe(struct snd_soc_codec *codec)
static int wm8580_probe(struct snd_soc_component *component)
{
{
	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
	struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);
	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
	int ret = 0;
	int ret = 0;


	switch (wm8580->drvdata->num_dacs) {
	switch (wm8580->drvdata->num_dacs) {
	case 4:
	case 4:
		snd_soc_add_codec_controls(codec, wm8581_snd_controls,
		snd_soc_add_component_controls(component, wm8581_snd_controls,
					ARRAY_SIZE(wm8581_snd_controls));
					ARRAY_SIZE(wm8581_snd_controls));
		snd_soc_dapm_new_controls(dapm, wm8581_dapm_widgets,
		snd_soc_dapm_new_controls(dapm, wm8581_dapm_widgets,
					ARRAY_SIZE(wm8581_dapm_widgets));
					ARRAY_SIZE(wm8581_dapm_widgets));
@@ -929,14 +929,14 @@ static int wm8580_probe(struct snd_soc_codec *codec)
	ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies),
	ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies),
				    wm8580->supplies);
				    wm8580->supplies);
	if (ret != 0) {
	if (ret != 0) {
		dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
		dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
		goto err_regulator_get;
		goto err_regulator_get;
	}
	}


	/* Get the codec into a known state */
	/* Get the codec into a known state */
	ret = snd_soc_write(codec, WM8580_RESET, 0);
	ret = snd_soc_component_write(component, WM8580_RESET, 0);
	if (ret != 0) {
	if (ret != 0) {
		dev_err(codec->dev, "Failed to reset codec: %d\n", ret);
		dev_err(component->dev, "Failed to reset component: %d\n", ret);
		goto err_regulator_enable;
		goto err_regulator_enable;
	}
	}


@@ -949,28 +949,27 @@ static int wm8580_probe(struct snd_soc_codec *codec)
}
}


/* power down chip */
/* power down chip */
static int wm8580_remove(struct snd_soc_codec *codec)
static void wm8580_remove(struct snd_soc_component *component)
{
{
	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
	struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);


	regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
	regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);

	return 0;
}
}


static const struct snd_soc_codec_driver soc_codec_dev_wm8580 = {
static const struct snd_soc_component_driver soc_component_dev_wm8580 = {
	.probe			= wm8580_probe,
	.probe			= wm8580_probe,
	.remove			= wm8580_remove,
	.remove			= wm8580_remove,
	.set_bias_level		= wm8580_set_bias_level,
	.set_bias_level		= wm8580_set_bias_level,

	.component_driver = {
	.controls		= wm8580_snd_controls,
	.controls		= wm8580_snd_controls,
	.num_controls		= ARRAY_SIZE(wm8580_snd_controls),
	.num_controls		= ARRAY_SIZE(wm8580_snd_controls),
	.dapm_widgets		= wm8580_dapm_widgets,
	.dapm_widgets		= wm8580_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(wm8580_dapm_widgets),
	.num_dapm_widgets	= ARRAY_SIZE(wm8580_dapm_widgets),
	.dapm_routes		= wm8580_dapm_routes,
	.dapm_routes		= wm8580_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(wm8580_dapm_routes),
	.num_dapm_routes	= ARRAY_SIZE(wm8580_dapm_routes),
	},
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};
};


static const struct regmap_config wm8580_regmap = {
static const struct regmap_config wm8580_regmap = {
@@ -1037,18 +1036,12 @@ static int wm8580_i2c_probe(struct i2c_client *i2c,
		return -EINVAL;
		return -EINVAL;
	}
	}


	ret =  snd_soc_register_codec(&i2c->dev,
	ret = devm_snd_soc_register_component(&i2c->dev,
			&soc_codec_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai));
			&soc_component_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai));


	return ret;
	return ret;
}
}


static int wm8580_i2c_remove(struct i2c_client *client)
{
	snd_soc_unregister_codec(&client->dev);
	return 0;
}

static const struct i2c_device_id wm8580_i2c_id[] = {
static const struct i2c_device_id wm8580_i2c_id[] = {
	{ "wm8580", (kernel_ulong_t)&wm8580_data },
	{ "wm8580", (kernel_ulong_t)&wm8580_data },
	{ "wm8581", (kernel_ulong_t)&wm8581_data },
	{ "wm8581", (kernel_ulong_t)&wm8581_data },
@@ -1062,7 +1055,6 @@ static struct i2c_driver wm8580_i2c_driver = {
		.of_match_table = wm8580_of_match,
		.of_match_table = wm8580_of_match,
	},
	},
	.probe =    wm8580_i2c_probe,
	.probe =    wm8580_i2c_probe,
	.remove =   wm8580_i2c_remove,
	.id_table = wm8580_i2c_id,
	.id_table = wm8580_i2c_id,
};
};


+51 −65

File changed.

Preview size limit exceeded, changes collapsed.

Loading