Skip to contentSkip to conversation

ASoC: adau17x1: Add support for specifying the MCLK using the CCF

PATCH In review Lars-Peter Clausen 2 participants 2 messages Jun 15, 2016

Subsystems (4)
lore
Share & tools
lore

Lars-Peter Clausen

author maintainer
#0 lore raw

PATCH v2 1/1 ASoC: adau17x1: Add support for specifying the MCLK using the CCF

The devices from the ADAU17X1 family all have a MCLK clock input which supplies the master clock for the device. The master clock is used as the input clock for the PLL. Currently the MCLK rate as well as the desired PLL output frequency need to be supplied by calling snd_soc_dai_set_pll() form a machine driver.

Add support for specifying the MCLK using the common clock framework. In addition to that also automatically configure the PLL to a suitable rate if the master clock was provided using the CCW. This allows to use the CODEC driver without any special configuration requirements from the machine driver.

While the PLL output frequency can be configured over a (more or less) continuous range the narrowness of the range and the other constraints of the clocking tree usually only result in two output frequencies that will actually be chosen. One for 44.1kHz based rates and one for 48kHz based rates, these are the rates that the automatic PLL configuration will use. For the rare case where a non-standard setup is required a machine driver can disable the auto-configuration and configure a custom frequency using the existing mechanisms.

If the common clock framework is not enabled clk_get() will return NULL and the driver will function as before and the clock rate needs to be configured manually.

---
Changes since v1:
* Change numerical value of ADAU17X1_CLK_SRC_PLL_AUTO to 0, since that is what the simple-card driver will call snd_soc_dai_set_sysclk() with when the CODEC node has a clock property. So this is really the only way to make this work with the simple-card driver.

---
 .../devicetree/bindings/sound/adi,adau17x1.txt     |   8 +
 sound/soc/codecs/adau1761-i2c.c                    |   2 +-
 sound/soc/codecs/adau1761-spi.c                    |   2 +-
 sound/soc/codecs/adau1781-i2c.c                    |   2 +-
 sound/soc/codecs/adau1781-spi.c                    |   2 +-
 sound/soc/codecs/adau17x1.c                        | 219 +++++++++++++++------
 sound/soc/codecs/adau17x1.h                        |   6 +
 7 files changed, 179 insertions(+), 62 deletions(-)
Documentation/devicetree/bindings/sound/adi,adau17x1.txt +8 -0
index 8dbce0e..1447dec 100644
@@ -13,6 +13,11 @@ Required properties:
  - reg:			The i2c address. Value depends on the state of ADDR0
 			and ADDR1, as wired in hardware.
 
+Optional properties:
+ - clock-names:		If provided must be "mclk".
+ - clocks:		phandle + clock-specifiers for the clock that provides
+			the audio master clock for the device.
+
 Examples:
 #include <dt-bindings/sound/adau17x1.h>
 
@@ -20,5 +25,8 @@ Examples:
 		adau1361@38 {
 			compatible = "adi,adau1761";
 			reg = <0x38>;
+
+			clock-names = "mclk";
+			clocks = <&audio_clock>;
 		};
 	};
sound/soc/codecs/adau1761-i2c.c +1 -1
index 8de010f..9e7f257 100644
@@ -31,7 +31,7 @@ static int adau1761_i2c_probe(struct i2c_client *client,
 
 static int adau1761_i2c_remove(struct i2c_client *client)
 {
-	snd_soc_unregister_codec(&client->dev);
+	adau17x1_remove(&client->dev);
 	return 0;
 }
 
sound/soc/codecs/adau1761-spi.c +1 -1
index d917124..a0b214b 100644
@@ -48,7 +48,7 @@ static int adau1761_spi_probe(struct spi_device *spi)
 
 static int adau1761_spi_remove(struct spi_device *spi)
 {
-	snd_soc_unregister_codec(&spi->dev);
+	adau17x1_remove(&spi->dev);
 	return 0;
 }
 
sound/soc/codecs/adau1781-i2c.c +1 -1
index 06cbca8..7b9d180 100644
@@ -31,7 +31,7 @@ static int adau1781_i2c_probe(struct i2c_client *client,
 
 static int adau1781_i2c_remove(struct i2c_client *client)
 {
-	snd_soc_unregister_codec(&client->dev);
+	adau17x1_remove(&client->dev);
 	return 0;
 }
 
sound/soc/codecs/adau1781-spi.c +1 -1
index 3d965a0..9b23354 100644
@@ -48,7 +48,7 @@ static int adau1781_spi_probe(struct spi_device *spi)
 
 static int adau1781_spi_remove(struct spi_device *spi)
 {
-	snd_soc_unregister_codec(&spi->dev);
+	adau17x1_remove(&spi->dev);
 	return 0;
 }
 
sound/soc/codecs/adau17x1.c +161 -58

269 lines not on this page · raw message

sound/soc/codecs/adau17x1.h +6 -0
index 5ae87a0..bf04b7e 100644
@@ -22,13 +22,18 @@ enum adau17x1_pll_src {
 };
 
 enum adau17x1_clk_src {
+	/* Automatically configure PLL based on the sample rate */
+	ADAU17X1_CLK_SRC_PLL_AUTO,
 	ADAU17X1_CLK_SRC_MCLK,
 	ADAU17X1_CLK_SRC_PLL,
 };
 
+struct clk;
+
 struct adau {
 	unsigned int sysclk;
 	unsigned int pll_freq;
+	struct clk *mclk;
 
 	enum adau17x1_clk_src clk_src;
 	enum adau17x1_type type;
@@ -52,6 +57,7 @@ int adau17x1_add_routes(struct snd_soc_codec *codec);
 int adau17x1_probe(struct device *dev, struct regmap *regmap,
 	enum adau17x1_type type, void (*switch_mode)(struct device *dev),
 	const char *firmware_name);
+void adau17x1_remove(struct device *dev);
 int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec,
 	enum adau17x1_micbias_voltage micbias);
 bool adau17x1_readable_register(struct device *dev, unsigned int reg);
Signature · 1 line
2.1.4
maintainer
#1 lore raw

Applied "ASoC: adau17x1: Add support for specifying the MCLK using the CCF" to the asoc tree

The patch

ASoC: adau17x1: Add support for specifying the MCLK using the CCF

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 5d76de61dd8cb89b7189ef7456fba921c547c398 Mon Sep 17 00:00:00 2001

From: Lars-Peter Clausen <[email protected]>
Date: Wed, 15 Jun 2016 15:07:27 +0200
Subject: [PATCH] ASoC: adau17x1: Add support for specifying the MCLK using the
CCF

The devices from the ADAU17X1 family all have a MCLK clock input which supplies the master clock for the device. The master clock is used as the input clock for the PLL. Currently the MCLK rate as well as the desired PLL output frequency need to be supplied by calling snd_soc_dai_set_pll() form a machine driver.

Add support for specifying the MCLK using the common clock framework. In addition to that also automatically configure the PLL to a suitable rate if the master clock was provided using the CCW. This allows to use the CODEC driver without any special configuration requirements from the machine driver.

While the PLL output frequency can be configured over a (more or less) continuous range the narrowness of the range and the other constraints of the clocking tree usually only result in two output frequencies that will actually be chosen. One for 44.1kHz based rates and one for 48kHz based rates, these are the rates that the automatic PLL configuration will use. For the rare case where a non-standard setup is required a machine driver can disable the auto-configuration and configure a custom frequency using the existing mechanisms.

If the common clock framework is not enabled clk_get() will return NULL and the driver will function as before and the clock rate needs to be configured manually.

---
 .../devicetree/bindings/sound/adi,adau17x1.txt     |   8 +
 sound/soc/codecs/adau1761-i2c.c                    |   2 +-
 sound/soc/codecs/adau1761-spi.c                    |   2 +-
 sound/soc/codecs/adau1781-i2c.c                    |   2 +-
 sound/soc/codecs/adau1781-spi.c                    |   2 +-
 sound/soc/codecs/adau17x1.c                        | 219 +++++++++++++++------
 sound/soc/codecs/adau17x1.h                        |   6 +
 7 files changed, 179 insertions(+), 62 deletions(-)
Documentation/devicetree/bindings/sound/adi,adau17x1.txt +8 -0
index 8dbce0e18dda..1447dec28125 100644
@@ -13,6 +13,11 @@ Required properties:
  - reg:			The i2c address. Value depends on the state of ADDR0
 			and ADDR1, as wired in hardware.
 
+Optional properties:
+ - clock-names:		If provided must be "mclk".
+ - clocks:		phandle + clock-specifiers for the clock that provides
+			the audio master clock for the device.
+
 Examples:
 #include <dt-bindings/sound/adau17x1.h>
 
@@ -20,5 +25,8 @@ Examples:
 		adau1361@38 {
 			compatible = "adi,adau1761";
 			reg = <0x38>;
+
+			clock-names = "mclk";
+			clocks = <&audio_clock>;
 		};
 	};
sound/soc/codecs/adau1761-i2c.c +1 -1
index 8de010f758cd..9e7f257f17f8 100644
@@ -31,7 +31,7 @@ static int adau1761_i2c_probe(struct i2c_client *client,
 
 static int adau1761_i2c_remove(struct i2c_client *client)
 {
-	snd_soc_unregister_codec(&client->dev);
+	adau17x1_remove(&client->dev);
 	return 0;
 }
 
sound/soc/codecs/adau1761-spi.c +1 -1
index d9171245bd9f..a0b214be759a 100644
@@ -48,7 +48,7 @@ static int adau1761_spi_probe(struct spi_device *spi)
 
 static int adau1761_spi_remove(struct spi_device *spi)
 {
-	snd_soc_unregister_codec(&spi->dev);
+	adau17x1_remove(&spi->dev);
 	return 0;
 }
 
sound/soc/codecs/adau1781-i2c.c +1 -1
index 06cbca84cf02..7b9d1802d159 100644
@@ -31,7 +31,7 @@ static int adau1781_i2c_probe(struct i2c_client *client,
 
 static int adau1781_i2c_remove(struct i2c_client *client)
 {
-	snd_soc_unregister_codec(&client->dev);
+	adau17x1_remove(&client->dev);
 	return 0;
 }
 
sound/soc/codecs/adau1781-spi.c +1 -1
index 3d965a01b99c..9b233544d2e8 100644
@@ -48,7 +48,7 @@ static int adau1781_spi_probe(struct spi_device *spi)
 
 static int adau1781_spi_remove(struct spi_device *spi)
 {
-	snd_soc_unregister_codec(&spi->dev);
+	adau17x1_remove(&spi->dev);
 	return 0;
 }
 
sound/soc/codecs/adau17x1.c +161 -58

269 lines not on this page · raw message

sound/soc/codecs/adau17x1.h +6 -0
index 5ae87a084d97..bf04b7efee40 100644
@@ -22,13 +22,18 @@ enum adau17x1_pll_src {
 };
 
 enum adau17x1_clk_src {
+	/* Automatically configure PLL based on the sample rate */
+	ADAU17X1_CLK_SRC_PLL_AUTO,
 	ADAU17X1_CLK_SRC_MCLK,
 	ADAU17X1_CLK_SRC_PLL,
 };
 
+struct clk;
+
 struct adau {
 	unsigned int sysclk;
 	unsigned int pll_freq;
+	struct clk *mclk;
 
 	enum adau17x1_clk_src clk_src;
 	enum adau17x1_type type;
@@ -52,6 +57,7 @@ int adau17x1_add_routes(struct snd_soc_codec *codec);
 int adau17x1_probe(struct device *dev, struct regmap *regmap,
 	enum adau17x1_type type, void (*switch_mode)(struct device *dev),
 	const char *firmware_name);
+void adau17x1_remove(struct device *dev);
 int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec,
 	enum adau17x1_micbias_voltage micbias);
 bool adau17x1_readable_register(struct device *dev, unsigned int reg);
Signature · 1 line
2.8.1