Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: Add reset-gpio DT property to cs4270 driver

In the process of moving over from static board files to the device
tree, reset pins of peripheral reset pins should be handled by their
corresponding drivers.

Add a reset-gpio DT property to the cs4270 driver, and de-assert it
before probing the chip. The logic could be augmented some day to
re-assert it when codec is put to suspend.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Daniel Mack and committed by
Mark Brown
02286190 85d07e4d

+22
+5
Documentation/devicetree/bindings/sound/cs4270.txt
··· 8 8 9 9 - reg : the I2C address of the device for I2C 10 10 11 + Optional properties: 12 + 13 + - reset-gpio : a GPIO spec for the reset pin. If specified, it will be 14 + deasserted before communication to the codec starts. 15 + 11 16 Example: 12 17 13 18 codec: cs4270@48 {
+17
sound/soc/codecs/cs4270.c
··· 30 30 #include <linux/delay.h> 31 31 #include <linux/regulator/consumer.h> 32 32 #include <linux/of_device.h> 33 + #include <linux/of_gpio.h> 33 34 34 35 /* 35 36 * The codec isn't really big-endian or little-endian, since the I2S ··· 661 660 static int cs4270_i2c_probe(struct i2c_client *i2c_client, 662 661 const struct i2c_device_id *id) 663 662 { 663 + struct device_node *np = i2c_client->dev.of_node; 664 664 struct cs4270_private *cs4270; 665 665 int ret; 666 + 667 + /* See if we have a way to bring the codec out of reset */ 668 + if (np) { 669 + enum of_gpio_flags flags; 670 + int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); 671 + 672 + if (gpio_is_valid(gpio)) { 673 + ret = devm_gpio_request_one(&i2c_client->dev, gpio, 674 + flags & OF_GPIO_ACTIVE_LOW ? 675 + GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, 676 + "cs4270 reset"); 677 + if (ret < 0) 678 + return ret; 679 + } 680 + } 666 681 667 682 /* Verify that we have a CS4270 */ 668 683