#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_irq.h>
-#include <linux/of_gpio.h>
#include <linux/of_platform.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
{
int time_left;
- gpio_set_value(twl6040->audpwron, 1);
+ gpiod_set_value_cansleep(twl6040->audpwron, 1);
time_left = wait_for_completion_timeout(&twl6040->ready,
msecs_to_jiffies(144));
intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
if (!(intid & TWL6040_READYINT)) {
dev_err(twl6040->dev, "automatic power-up failed\n");
- gpio_set_value(twl6040->audpwron, 0);
+ gpiod_set_value_cansleep(twl6040->audpwron, 0);
return -ETIMEDOUT;
}
}
/* Allow writes to the chip */
regcache_cache_only(twl6040->regmap, false);
- if (gpio_is_valid(twl6040->audpwron)) {
+ if (twl6040->audpwron) {
/* use automatic power-up sequence */
ret = twl6040_power_up_automatic(twl6040);
if (ret) {
if (--twl6040->power_count)
goto out;
- if (gpio_is_valid(twl6040->audpwron)) {
+ if (twl6040->audpwron) {
/* use AUDPWRON line */
- gpio_set_value(twl6040->audpwron, 0);
+ gpiod_set_value_cansleep(twl6040->audpwron, 0);
/* power-down sequence latency */
usleep_range(500, 700);
}
/* ERRATA: Automatic power-up is not possible in ES1.0 */
- if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0)
- twl6040->audpwron = of_get_named_gpio(node,
- "ti,audpwron-gpio", 0);
- else
- twl6040->audpwron = -EINVAL;
-
- if (gpio_is_valid(twl6040->audpwron)) {
- ret = devm_gpio_request_one(&client->dev, twl6040->audpwron,
- GPIOF_OUT_INIT_LOW, "audpwron");
+ if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) {
+ twl6040->audpwron = devm_gpiod_get_optional(&client->dev,
+ "ti,audpwron",
+ GPIOD_OUT_LOW);
+ ret = PTR_ERR_OR_ZERO(twl6040->audpwron);
if (ret)
goto gpio_err;
+ gpiod_set_consumer_name(twl6040->audpwron, "audpwron");
+
/* Clear any pending interrupt */
twl6040_reg_read(twl6040, TWL6040_REG_INTID);
}