8
8
9
9
#include <linux/module.h>
10
10
#include <linux/init.h>
11
+ #include <linux/gpio/consumer.h>
11
12
#include <linux/delay.h>
12
13
#include <linux/pm.h>
13
14
#include <linux/property.h>
@@ -1485,6 +1486,11 @@ static const struct snd_soc_component_driver adau1373_component_driver = {
1485
1486
.endianness = 1 ,
1486
1487
};
1487
1488
1489
+ static void adau1373_reset (void * reset_gpio )
1490
+ {
1491
+ gpiod_set_value_cansleep (reset_gpio , 1 );
1492
+ }
1493
+
1488
1494
static int adau1373_parse_fw (struct device * dev , struct adau1373 * adau1373 )
1489
1495
{
1490
1496
int ret , drc_count ;
@@ -1547,6 +1553,7 @@ static int adau1373_parse_fw(struct device *dev, struct adau1373 *adau1373)
1547
1553
static int adau1373_i2c_probe (struct i2c_client * client )
1548
1554
{
1549
1555
struct adau1373 * adau1373 ;
1556
+ struct gpio_desc * gpiod ;
1550
1557
int ret ;
1551
1558
1552
1559
adau1373 = devm_kzalloc (& client -> dev , sizeof (* adau1373 ), GFP_KERNEL );
@@ -1558,7 +1565,26 @@ static int adau1373_i2c_probe(struct i2c_client *client)
1558
1565
if (IS_ERR (adau1373 -> regmap ))
1559
1566
return PTR_ERR (adau1373 -> regmap );
1560
1567
1561
- regmap_write (adau1373 -> regmap , ADAU1373_SOFT_RESET , 0x00 );
1568
+ /*
1569
+ * If the powerdown GPIO is specified, we use it for reset. Otherwise
1570
+ * a software reset is done.
1571
+ */
1572
+ gpiod = devm_gpiod_get_optional (& client -> dev , "powerdown" ,
1573
+ GPIOD_OUT_HIGH );
1574
+ if (IS_ERR (gpiod ))
1575
+ return PTR_ERR (gpiod );
1576
+
1577
+ if (gpiod ) {
1578
+ gpiod_set_value_cansleep (gpiod , 0 );
1579
+ fsleep (10 );
1580
+
1581
+ ret = devm_add_action_or_reset (& client -> dev , adau1373_reset ,
1582
+ gpiod );
1583
+ if (ret )
1584
+ return ret ;
1585
+ } else {
1586
+ regmap_write (adau1373 -> regmap , ADAU1373_SOFT_RESET , 0x00 );
1587
+ }
1562
1588
1563
1589
dev_set_drvdata (& client -> dev , adau1373 );
1564
1590
0 commit comments