ASoC: adau17x1: Add support for specifying the MCLK using the CCF
Subsystems (4)
Lars-Peter Clausen
maintainerPATCH 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.
--- .../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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -24,11 +24,16 @@ enum adau17x1_pll_src {enum adau17x1_clk_src {ADAU17X1_CLK_SRC_MCLK ,ADAU17X1_CLK_SRC_PLL , +/* Automatically configure PLL based on the sample rate */ +ADAU17X1_CLK_SRC_PLL_AUTO , }; +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