ASoC: cs42xx8: Add reset gpio handling
Handle the reset GPIO and reset the device every time we start it. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
b1f35dfd7c
commit
bfe95dfa4d
1 changed files with 13 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
|
#include <linux/of_gpio.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
#include <linux/regulator/consumer.h>
|
#include <linux/regulator/consumer.h>
|
||||||
#include <sound/pcm_params.h>
|
#include <sound/pcm_params.h>
|
||||||
|
@ -45,6 +46,7 @@ struct cs42xx8_priv {
|
||||||
bool slave_mode;
|
bool slave_mode;
|
||||||
unsigned long sysclk;
|
unsigned long sysclk;
|
||||||
u32 tx_channels;
|
u32 tx_channels;
|
||||||
|
struct gpio_desc *gpiod_reset;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -127.5dB to 0dB with step of 0.5dB */
|
/* -127.5dB to 0dB with step of 0.5dB */
|
||||||
|
@ -467,6 +469,13 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cs42xx8->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
|
||||||
|
GPIOD_OUT_HIGH);
|
||||||
|
if (IS_ERR(cs42xx8->gpiod_reset))
|
||||||
|
return PTR_ERR(cs42xx8->gpiod_reset);
|
||||||
|
|
||||||
|
gpiod_set_value_cansleep(cs42xx8->gpiod_reset, 0);
|
||||||
|
|
||||||
cs42xx8->clk = devm_clk_get(dev, "mclk");
|
cs42xx8->clk = devm_clk_get(dev, "mclk");
|
||||||
if (IS_ERR(cs42xx8->clk)) {
|
if (IS_ERR(cs42xx8->clk)) {
|
||||||
dev_err(dev, "failed to get the clock: %ld\n",
|
dev_err(dev, "failed to get the clock: %ld\n",
|
||||||
|
@ -547,6 +556,8 @@ static int cs42xx8_runtime_resume(struct device *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpiod_set_value_cansleep(cs42xx8->gpiod_reset, 0);
|
||||||
|
|
||||||
ret = regulator_bulk_enable(ARRAY_SIZE(cs42xx8->supplies),
|
ret = regulator_bulk_enable(ARRAY_SIZE(cs42xx8->supplies),
|
||||||
cs42xx8->supplies);
|
cs42xx8->supplies);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -585,6 +596,8 @@ static int cs42xx8_runtime_suspend(struct device *dev)
|
||||||
regulator_bulk_disable(ARRAY_SIZE(cs42xx8->supplies),
|
regulator_bulk_disable(ARRAY_SIZE(cs42xx8->supplies),
|
||||||
cs42xx8->supplies);
|
cs42xx8->supplies);
|
||||||
|
|
||||||
|
gpiod_set_value_cansleep(cs42xx8->gpiod_reset, 1);
|
||||||
|
|
||||||
clk_disable_unprepare(cs42xx8->clk);
|
clk_disable_unprepare(cs42xx8->clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue