devicetree: Add devicetree bindings documentation for the ADAU1977
Subsystems (4)
PATCH 1/2 devicetree: Add devicetree bindings documentation for the ADAU1977
The ADAU1977 is a four channel audio ADC. It can either be connected to an I2C or a SPI bus. Both bindings are described in this document. Other than the standard I2C and SPI bus properties a regulator for the AVDD supply needs to be specified in the bindings. Optionally, if present in the hardware design, a regulator for the DVDD supply and a GPIO connected to the chips reset pin can be specified. The bindings also allow to specify the microphone bias voltage that should be used with the hardware design.
--- .../devicetree/bindings/sound/adi,adau1977.txt | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/adi,adau1977.txt
Documentation/devicetree/bindings/sound/adi,adau1977.txt new file +58 -0
@@ -0,0 +1,58 @@ +Analog Devices ADAU1977, ADAU1978, ADAU1979 devicetree bindings + +The ADAU1977 is a four channel audio ADC. It can either be connected to an I2C +or a SPI bus. Both bindings are described in this document. Depending on the bus +type different properties must/can be specified. + +Shared required properties: + - compatible: Must be "adi,adau1977", "adi,adau1978" or adi,adau1979" + - AVDD-supply: A handle to the power supply connected to the AVDD pin + +Shared optional properties: + - DVDD-supply: A handle to the power supply connected to the DVDD pin. If + specified the internal LDO will be disabled. + - reset-gpios: GPIO chip handle and specifier that define which GPIO is + connected to the chips PD/RST pin. If not specified the reset pin is assumed + to be hardwired to VCC. + - adi,micbias: Configures the voltage setting for the MICBIAS pin. If not + specified the default value will be 8.5 Volts. This property is only valid + for the ADAU1977. + Valid values for this property are: + 0: 5.0V + 1: 5.5V + 2: 6.0V + 3: 6.5V + 4: 7.0V + 5: 7.5V + 6: 8.0V + 7: 8.5V + 8: 9.0V + +I2C required properties: + - reg: The I2C address of the chip + +SPI required properties: + - reg: The SPI chipselect signal of the SPI master associated with this chip + - spi-max-frequency: Maximum spi frequency to use. + +Examples: + +&i2c_bus { + adau1977: codec@11 { + compatible = "adi,adau1977"; + reg = <0x11>; + reset-gpios = <&gpio 5 0>; + AVDD-supply = <&codec_avdd_supply>; + DVDD-supply = <&codec_dvdd_supply>; + }; +}; + +&spi_bus { + adau1977: codec@1 { + compatible = "adi,adau1977"; + reg = <0x1>; + spi-max-frequency = <10000000>; + AVDD-supply = <&codec_avdd_supply>; + adi,micbias = <5>; + }; +};
Signature · 6 lines
1.8.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Lars-Peter Clausen
maintainerPATCH 2/2 ASoC: Add ADAU1977 driver
This patch adds support for the ADAU1977, ADAU1978 and ADAU1979 audio CODEC devices. They are a family of 4-channel differntial input audio ADC devices. They can be connected to either a SPI or I2C bus.
--- include/linux/platform_data/adau1977.h | 45 ++ sound/soc/codecs/Kconfig | 13 + sound/soc/codecs/Makefile | 6 + sound/soc/codecs/adau1977-i2c.c | 58 ++ sound/soc/codecs/adau1977-spi.c | 73 +++ sound/soc/codecs/adau1977.c | 994 +++++++++++++++++++++++++++++++++ sound/soc/codecs/adau1977.h | 37 ++ 7 files changed, 1226 insertions(+) create mode 100644 include/linux/platform_data/adau1977.h create mode 100644 sound/soc/codecs/adau1977-i2c.c create mode 100644 sound/soc/codecs/adau1977-spi.c create mode 100644 sound/soc/codecs/adau1977.c create mode 100644 sound/soc/codecs/adau1977.h
include/linux/platform_data/adau1977.h new file +45 -0
@@ -0,0 +1,45 @@ +/* +* ADAU1977/ADAU1978/ADAU1979 driver +* +* Copyright 2014 Analog Devices Inc. +* Author: Lars-Peter Clausen <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#ifndef __LINUX_PLATFORM_DATA_ADAU1977_H__ +#define __LINUX_PLATFORM_DATA_ADAU1977_H__ + +/** +* enum adau1977_micbias - ADAU1977 MICBIAS pin voltage setting +* @ADAU1977_MICBIAS_5V0: MICBIAS is set to 5.0 V +* @ADAU1977_MICBIAS_5V5: MICBIAS is set to 5.5 V +* @ADAU1977_MICBIAS_6V0: MICBIAS is set to 6.0 V +* @ADAU1977_MICBIAS_6V5: MICBIAS is set to 6.5 V +* @ADAU1977_MICBIAS_7V0: MICBIAS is set to 7.0 V +* @ADAU1977_MICBIAS_7V5: MICBIAS is set to 7.5 V +* @ADAU1977_MICBIAS_8V0: MICBIAS is set to 8.0 V +* @ADAU1977_MICBIAS_8V5: MICBIAS is set to 8.5 V +* @ADAU1977_MICBIAS_9V0: MICBIAS is set to 9.0 V +*/ +enum adau1977_micbias { +ADAU1977_MICBIAS_5V0 =0x0 , +ADAU1977_MICBIAS_5V5 =0x1 , +ADAU1977_MICBIAS_6V0 =0x2 , +ADAU1977_MICBIAS_6V5 =0x3 , +ADAU1977_MICBIAS_7V0 =0x4 , +ADAU1977_MICBIAS_7V5 =0x5 , +ADAU1977_MICBIAS_8V0 =0x6 , +ADAU1977_MICBIAS_8V5 =0x7 , +ADAU1977_MICBIAS_9V0 =0x8 , +}; + +/** +* struct adau1977_platform_data - Platform configuration data for the ADAU1977 +* @micbias: Specifies the voltage for the MICBIAS pin +*/ +struct adau1977_platform_data { +enum adau1977_micbias micbias; +}; + +#endif
sound/soc/codecs/Kconfig +13 -0
@@ -20,6 +20,8 @@ config SND_SOC_ALL_CODECS select SND_SOC_AD1980 if SND_SOC_AC97_BUS select SND_SOC_AD73311 select SND_SOC_ADAU1373 if I2C + select SND_SOC_ADAU1977_SPI if SPI_MASTER + select SND_SOC_ADAU1977_I2C if I2C select SND_SOC_ADAV80X if SND_SOC_I2C_AND_SPI select SND_SOC_ADAU1701 if I2C select SND_SOC_ADS117X
@@ -195,6 +197,17 @@ config SND_SOC_ADAU1701 config SND_SOC_ADAU1373 tristate +config SND_SOC_ADAU1977 + tristate + +config SND_SOC_ADAU1977_I2C + tristate + select SND_SOC_ADAU1977 + +config SND_SOC_ADAU1977_SPI + tristate + select SND_SOC_ADAU1977 + config SND_SOC_ADAV80X tristate
sound/soc/codecs/Makefile +6 -0
@@ -7,6 +7,9 @@ snd-soc-ad1980-objs := ad1980.o snd-soc-ad73311-objs := ad73311.o snd-soc-adau1701-objs := adau1701.o snd-soc-adau1373-objs := adau1373.o +snd-soc-adau1977-objs := adau1977.o +snd-soc-adau1977-spi-objs := adau1977-spi.o +snd-soc-adau1977-i2c-objs := adau1977-i2c.o snd-soc-adav80x-objs := adav80x.o snd-soc-ads117x-objs := ads117x.o snd-soc-ak4104-objs := ak4104.o
@@ -137,6 +140,9 @@ obj-$(CONFIG_SND_SOC_AD193X) += snd-soc-ad193x.o obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o obj-$(CONFIG_SND_SOC_ADAU1373) += snd-soc-adau1373.o +obj-$(CONFIG_SND_SOC_ADAU1977) += snd-soc-adau1977.o +obj-$(CONFIG_SND_SOC_ADAU1977_SPI) += snd-soc-adau1977-spi.o +obj-$(CONFIG_SND_SOC_ADAU1977_I2C) += snd-soc-adau1977-i2c.o obj-$(CONFIG_SND_SOC_ADAU1701) += snd-soc-adau1701.o obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o
sound/soc/codecs/adau1977-i2c.c new file +58 -0
58 lines not on this page · raw message
sound/soc/codecs/adau1977-spi.c new file +73 -0
73 lines not on this page · raw message
sound/soc/codecs/adau1977.c new file +994 -0
994 lines not on this page · raw message
sound/soc/codecs/adau1977.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* ADAU1977/ADAU1978/ADAU1979 driver +* +* Copyright 2014 Analog Devices Inc. +* Author: Lars-Peter Clausen <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#ifndef __SOUND_SOC_CODECS_ADAU1977_H__ +#define __SOUND_SOC_CODECS_ADAU1977_H__ + +#include <linux/regmap.h> + +struct device ; + +enum adau1977_type { +ADAU1977 , +ADAU1978 , +ADAU1979 , +}; + +int adau1977_probe (struct device *dev,struct regmap *regmap, +enum adau1977_type type,void (*switch_mode)(struct device *dev)); + +extern const struct regmap_config adau1977_regmap_config; + +enum adau1977_clk_id { +ADAU1977_SYSCLK , +}; + +enum adau1977_sysclk_src { +ADAU1977_SYSCLK_SRC_MCLK , +ADAU1977_SYSCLK_SRC_LRCLK , +}; + +#endif
Signature · 1 line
1.8.0
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: Add ADAU1977 driver
Quoted 3 lines · Lars-Peter Clausen
This patch adds support for the ADAU1977, ADAU1978 and ADAU1979 audio CODEC devices. They are a family of 4-channel differntial input audio ADC devices. They can be connected to either a SPI or I2C bus.
To avoid tedious iteration of the driver for the DT bindings it's generally helpful to submit the DT bindings as a separate patch.
Quoted 2 lines
sound/soc/codecs/adau1977-i2c.c | 58 ++ sound/soc/codecs/adau1977-spi.c | 73 +++
This isn't the general style, if we want to do that we should be converting all the other drivers.
sound/soc/codecs/Kconfig config SND_SOC_ADAU1701 · line 210
Quoted 11 lines
sound/soc/codecs/Kconfig +11
-0+config SND_SOC_ADAU1977 + tristate + +config SND_SOC_ADAU1977_I2C + tristate + select SND_SOC_ADAU1977 + +config SND_SOC_ADAU1977_SPI + tristate + select SND_SOC_ADAU1977 +
Please make these user visible if OF is in use.
sound/soc/codecs/adau1977-i2c.c line 53
Quoted 9 lines
sound/soc/codecs/adau1977-i2c.c new file +9
-0+static struct i2c_driver adau1977_i2c_driver = { + .driver = { + .name ="adau1977" , + .owner =THIS_MODULE , + }, + .probe = adau1977_i2c_probe, + .remove = adau1977_i2c_remove, + .id_table = adau1977_i2c_ids, +};
You should have explicit OF IDs.
sound/soc/codecs/adau1977.c line 310
Quoted 12 lines
sound/soc/codecs/adau1977.c new file +12
-0+if (rate >=8000 && rate <=12000 ) + ctrl0 =ADAU1977_SAI_CTRL0_FS_8000_12000 ; +else if (rate >=16000 && rate <=24000 ) + ctrl0 =ADAU1977_SAI_CTRL0_FS_16000_24000 ; +else if (rate >=32000 && rate <=48000 ) + ctrl0 =ADAU1977_SAI_CTRL0_FS_32000_48000 ; +else if (rate >=64000 && rate <=96000 ) + ctrl0 =ADAU1977_SAI_CTRL0_FS_64000_96000 ; +else if (rate >=128000 && rate <=192000 ) + ctrl0 =ADAU1977_SAI_CTRL0_FS_128000_192000 ; +else +return -EINVAL ;
There's a couple of these rate range if trees - how about a lookup in an array?
Quoted 7 lines
sound/soc/codecs/adau1977.c new file +7
-0+if (!enable) { + ret =regmap_update_bits (adau1977->regmap,ADAU1977_REG_POWER , +ADAU1977_POWER_PWUP ,0 ); +regcache_mark_dirty (adau1977->regmap); + }else { + ret =regulator_enable (adau1977->avdd_reg); +if (ret)
sound/soc/codecs/adau1977.c line 392
Quoted 10 lines
sound/soc/codecs/adau1977.c new file +10
-0+return ret; +if (adau1977->dvdd_reg) { + ret =regulator_enable (adau1977->dvdd_reg); +if (ret) + goto err_disable_avdd; + } + } + +if (adau1977->reset_gpio) +gpiod_set_value (adau1977->reset_gpio, enable);
_cansleep().
I'm not sure all this enable/disable logic within the function is helping clarity here. There seems to be no meaningful sharing between the two branches, separate functions for power up and power down is probably going to be clearer.
sound/soc/codecs/adau1977.c line 588
Quoted 7 lines
sound/soc/codecs/adau1977.c new file +7
-0+static int adau1977_mute (struct snd_soc_dai *dai,int mute,int stream) +{ +struct adau1977 *adau1977 =snd_soc_codec_get_drvdata (dai->codec); +unsigned int val; + +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) +return 0 ;
Why would this ever be called for an ADC?
Lars-Peter Clausen
maintainerRe: [PATCH 2/2] ASoC: Add ADAU1977 driver
Quoted 6 lines · Mark Brown
Quoted 2 lines
sound/soc/codecs/adau1977-i2c.c | 58 ++ sound/soc/codecs/adau1977-spi.c | 73 +++This isn't the general style, if we want to do that we should be converting all the other drivers.
I think we want to change it. Cause as it is right now we always get issues when the SPI core is build-in, but the I2C core is built as a module. Using the scheme used in this driver the core module for the driver does not depend on either framework, but provides a library to the bus specific modules. E.g. if SPI is built-in and the SPI driver for the ADAU1977 is built-in the core will also be built-in, but it is still possible to build I2C as a module and also build the ADAU1977 I2C driver as a module. And I know there is SND_SOC_I2C_AND_SPI, but in my opinion it's a hack to work around the issue. E.g. if you have a board driver and the board driver selects the CODEC driver, the board driver also has to depend on SND_SOC_I2C_AND_SPI to avoid any issues (None of the board drivers do this right now).
Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/Kconfig +5
-0+config SND_SOC_ADAU1977 + tristate + +config SND_SOC_ADAU1977_I2C + tristate
Quoted 8 lines
sound/soc/codecs/Kconfig config SND_SOC_ADAU1701 · line 210
Quoted 6 lines
sound/soc/codecs/Kconfig +6
-0+ select SND_SOC_ADAU1977 + +config SND_SOC_ADAU1977_SPI + tristate + select SND_SOC_ADAU1977 +Please make these user visible if OF is in use.
Was there a resolution on how to best do this? Make them always visible, or only when CONFIG_OF is selected?
- Lars
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: Add ADAU1977 driver
Quoted 8 lines · Lars-Peter Clausen
Quoted 5 lines · Mark Brown
Quoted 2 lines
sound/soc/codecs/adau1977-i2c.c | 58 ++ sound/soc/codecs/adau1977-spi.c | 73 +++This isn't the general style, if we want to do that we should be converting all the other drivers.
Quoted 13 lines
I think we want to change it. Cause as it is right now we always get issues when the SPI core is build-in, but the I2C core is built as a module. Using the scheme used in this driver the core module for the driver does not depend on either framework, but provides a library to the bus specific modules. E.g. if SPI is built-in and the SPI driver for the ADAU1977 is built-in the core will also be built-in, but it is still possible to build I2C as a module and also build the ADAU1977 I2C driver as a module. And I know there is
SND_SOC_I2C_AND_SPI, but in my opinion it's a hack to work around the issue. E.g. if you have a board driver and the board driver selects the CODEC driver, the board driver also has to depend onSND_SOC_I2C_AND_SPIto avoid any issues (None of the board drivers do this right now).
I'm having a hard time seeing that as a meaningful issue to be honest - only I2C has the modular option and I'm never terribly convinced about the realism of scenarios that trigger this. In any case the main thing is that we shouldn't be silently putting something like this into driver submissions, we should be actively making the change to all drivers.
Quoted 4 lines
Quoted 1 line
Please make these user visible if OF is in use.
Was there a resolution on how to best do this? Make them always visible, or only when
CONFIG_OFis selected?
Always visible if their dependencies are enabled.
Lars-Peter Clausen
maintainerRe: [PATCH 2/2] ASoC: Add ADAU1977 driver
Quoted 23 lines · Mark Brown
Quoted 8 lines · Lars-Peter Clausen
Quoted 5 lines · Mark Brown
Quoted 2 lines
sound/soc/codecs/adau1977-i2c.c | 58 ++ sound/soc/codecs/adau1977-spi.c | 73 +++This isn't the general style, if we want to do that we should be converting all the other drivers.
Quoted 13 lines
I think we want to change it. Cause as it is right now we always get issues when the SPI core is build-in, but the I2C core is built as a module. Using the scheme used in this driver the core module for the driver does not depend on either framework, but provides a library to the bus specific modules. E.g. if SPI is built-in and the SPI driver for the ADAU1977 is built-in the core will also be built-in, but it is still possible to build I2C as a module and also build the ADAU1977 I2C driver as a module. And I know there is
SND_SOC_I2C_AND_SPI, but in my opinion it's a hack to work around the issue. E.g. if you have a board driver and the board driver selects the CODEC driver, the board driver also has to depend onSND_SOC_I2C_AND_SPIto avoid any issues (None of the board drivers do this right now).
Quoted 5 lines
I'm having a hard time seeing that as a meaningful issue to be honest - only I2C has the modular option and I'm never terribly convinced about the realism of scenarios that trigger this. In any case the main thing is that we shouldn't be silently putting something like this into driver submissions, we should be actively making the change to all drivers.
I think this is the cleaner approach rather than the #ifdef mess we currently find in drivers with more than one interface. And there is the thing that you can actually build a config that results in a build error which triggers the occasional randconfig build failures for ASoC. Once the last three drivers that still soc-io have been converted to regmap I think we should move the selection of REGMAP_I2C and REGMAP_SPI to the individual drivers rather letting the core select them unconditionally. Using this new scheme will make it easier to avoid the situation where you end up selection REGMAP_I2C or REGMAP_SPI even though I2S or SPI_MASTER is not selected. I don't have a problem with updating the other drivers to use the new scheme, but it's not like we have to update them all at once in one atomic step. And you have to start somewhere.
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: Add ADAU1977 driver
Quoted 4 lines · Lars-Peter Clausen
currently find in drivers with more than one interface. And there is the thing that you can actually build a config that results in a build error which triggers the occasional randconfig build failures for for ASoC. Once the last three drivers that still soc-io have been
Those randconfig failures are for configurations that no human would ever generate, it's really hard to care.
Quoted 3 lines
converted to regmap I think we should move the selection of
REGMAP_I2CandREGMAP_SPIto the individual drivers rather letting the core select them unconditionally. Using this new scheme will
That's the idea, it does need the drivers handling first though. The fact that not everything works through select (there's the ignored dependencies thing and I think some other stuff) isn't helpful with this stuff either, it makes it all too fragile.
Quoted 2 lines
make it easier to avoid the situation where you end up selection
REGMAP_I2CorREGMAP_SPIeven though I2S orSPI_MASTERis not
The core only enables the regmap code if the bus is being built, we don't have a problem with that bit - that bit at least is fine.
Quoted 3 lines
selected. I don't have a problem with updating the other drivers to use the new scheme, but it's not like we have to update them all at once in one atomic step. And you have to start somewhere.
Right, but that somewhere shouldn't be doing it in a new driver without even mentioning that it's being done - it's not something that should be coming as a surprise in the middle of a review of something that should be unrelated. That's the biggest problem here, it wasn't even called out in the changelog so people wouldn't be able to figure out why this driver was being different.
An explicit conversion patch for at least one driver (possibly even this one on the end of the series) would be ideal, or adding a note in the changelog saying something like "We should do this in general because X but I didn't get round to starting yet" so that it's visible.
A message that is not in the archive (sent off-list or not yet received): 1391439428-3198-1-git-send-email-lars-Qo5EllUWu/[email protected]
Documentation/devicetree/bindings/sound/adi,adau1977.txt line 29
Quoted 13 lines · Lars-Peter Clausen
+ - adi,micbias: Configures the voltage setting for the MICBIAS pin. If not
Documentation/devicetree/bindings/sound/adi,adau1977.txt new file +12
-0+ specified the default value will be 8.5 Volts. This property is only valid + for the ADAU1977. + Valid values for this property are: + 0: 5.0V + 1: 5.5V + 2: 6.0V + 3: 6.5V + 4: 7.0V + 5: 7.5V + 6: 8.0V + 7: 8.5V + 8: 9.0V
This means the casual DTS reader need to know about the meaning of the values. You can avoid that by:
1. Using preprocessor defines. Drawback is that you have to add an include file.
2. Using mV, and specify minimum, maximum, and incrementals in the bindings, cfr.Documentation/devicetree/bindings/power_supply/ti,bq24735.txt
Drawback is that the user can easily specify invalid values.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAMuHMdVQGZE+1YuWCnJefzy08kb6vNmRN8k+1-K82BubOBAOxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 15 lines · Geert Uytterhoeven
Documentation/devicetree/bindings/sound/adi,adau1977.txt line 29
Quoted 13 lines · Lars-Peter Clausen
+ - adi,micbias: Configures the voltage setting for the MICBIAS pin. If not
Documentation/devicetree/bindings/sound/adi,adau1977.txt new file +12
-0+ specified the default value will be 8.5 Volts. This property is only valid + for the ADAU1977. + Valid values for this property are: + 0: 5.0V + 1: 5.5V + 2: 6.0V + 3: 6.5V + 4: 7.0V + 5: 7.5V + 6: 8.0V + 7: 8.5V + 8: 9.0V
Quoted 8 lines
This means the casual DTS reader need to know about the meaning of the values. You can avoid that by:
1. Using preprocessor defines. Drawback is that you have to add an include file.
2. Using mV, and specify minimum, maximum, and incrementals in the bindings, cfr.Documentation/devicetree/bindings/power_supply/ti,bq24735.txt
Drawback is that the user can easily specify invalid values.
Is there a preference for either of them?
Thanks,
- Lars
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html