Skip to content

Commit

Permalink
ASoC: tas*: Fix up GPIO usage
Browse files Browse the repository at this point in the history
Merge series from Linus Walleij <linus.walleij@linaro.org>:

The TI TAS drivers use some legacy GPIO code and headers,
this series fixes it up.

The TAS2781 is a special case since it adds a handful of
lines of deviating code to reconfigure a GPIO line for
IRQ mode and then never actually use the IRQ obtained in
the code. Is the line used by autonomous hardware? I'm
puzzled by this.

Anyways the patch suggest how to solve this properly by
fixing the parent irqchip and I'm happy to help.
  • Loading branch information
Mark Brown committed Aug 8, 2024
2 parents 001f844 + caab9a1 commit 5db564d
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 37 deletions.
7 changes: 1 addition & 6 deletions include/sound/tas2781.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,13 @@ struct tasdevice {
bool is_loaderr;
};

struct tasdevice_irqinfo {
int irq_gpio;
int irq;
};

struct calidata {
unsigned char *data;
unsigned long total_sz;
};

struct tasdevice_priv {
struct tasdevice tasdevice[TASDEVICE_MAX_CHANNELS];
struct tasdevice_irqinfo irq_info;
struct tasdevice_rca rcabin;
struct calidata cali_data;
struct tasdevice_fw *fmw;
Expand All @@ -115,6 +109,7 @@ struct tasdevice_priv {
unsigned int chip_id;
unsigned int sysclk;

int irq;
int cur_prog;
int cur_conf;
int fw_state;
Expand Down
2 changes: 1 addition & 1 deletion sound/pci/hda/tas2781_hda_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ static int tas2781_hda_i2c_probe(struct i2c_client *clt)
} else
return -ENODEV;

tas_hda->priv->irq_info.irq = clt->irq;
tas_hda->priv->irq = clt->irq;
ret = tas2781_read_acpi(tas_hda->priv, device_name);
if (ret)
return dev_err_probe(tas_hda->dev, ret,
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/tas2552.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <linux/errno.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/slab.h>
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/tas2764.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <linux/regmap.h>
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/tas2770.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <linux/firmware.h>
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/tas2780.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <linux/err.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/regmap.h>
#include <linux/of.h>
Expand Down
3 changes: 0 additions & 3 deletions sound/soc/codecs/tas2781-comlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
#include <linux/regmap.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -411,8 +410,6 @@ EXPORT_SYMBOL_GPL(tasdevice_dsp_remove);

void tasdevice_remove(struct tasdevice_priv *tas_priv)
{
if (gpio_is_valid(tas_priv->irq_info.irq_gpio))
gpio_free(tas_priv->irq_info.irq_gpio);
mutex_destroy(&tas_priv->codec_lock);
}
EXPORT_SYMBOL_GPL(tasdevice_remove);
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/tas2781-fmwlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
#include <linux/regmap.h>
#include <linux/slab.h>
Expand Down
26 changes: 4 additions & 22 deletions sound/soc/codecs/tas2781-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
#include <linux/regmap.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -758,7 +757,7 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv)
{
struct i2c_client *client = (struct i2c_client *)tas_priv->client;
unsigned int dev_addrs[TASDEVICE_MAX_CHANNELS];
int rc, i, ndev = 0;
int i, ndev = 0;

if (tas_priv->isacpi) {
ndev = device_property_read_u32_array(&client->dev,
Expand All @@ -773,7 +772,7 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv)
"ti,audio-slots", dev_addrs, ndev);
}

tas_priv->irq_info.irq_gpio =
tas_priv->irq =
acpi_dev_gpio_irq_get(ACPI_COMPANION(&client->dev), 0);
} else if (IS_ENABLED(CONFIG_OF)) {
struct device_node *np = tas_priv->dev->of_node;
Expand All @@ -785,7 +784,7 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv)
dev_addrs[ndev++] = addr;
}

tas_priv->irq_info.irq_gpio = of_irq_get(np, 0);
tas_priv->irq = of_irq_get(np, 0);
} else {
ndev = 1;
dev_addrs[0] = client->addr;
Expand All @@ -795,29 +794,12 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv)
tas_priv->tasdevice[i].dev_addr = dev_addrs[i];

tas_priv->reset = devm_gpiod_get_optional(&client->dev,
"reset-gpios", GPIOD_OUT_HIGH);
"reset", GPIOD_OUT_HIGH);
if (IS_ERR(tas_priv->reset))
dev_err(tas_priv->dev, "%s Can't get reset GPIO\n",
__func__);

strcpy(tas_priv->dev_name, tasdevice_id[tas_priv->chip_id].name);

if (gpio_is_valid(tas_priv->irq_info.irq_gpio)) {
rc = gpio_request(tas_priv->irq_info.irq_gpio,
"AUDEV-IRQ");
if (!rc) {
gpio_direction_input(
tas_priv->irq_info.irq_gpio);

tas_priv->irq_info.irq =
gpio_to_irq(tas_priv->irq_info.irq_gpio);
} else
dev_err(tas_priv->dev, "%s: GPIO %d request error\n",
__func__, tas_priv->irq_info.irq_gpio);
} else
dev_err(tas_priv->dev,
"Looking up irq-gpio property failed %d\n",
tas_priv->irq_info.irq_gpio);
}

static int tasdevice_i2c_probe(struct i2c_client *i2c)
Expand Down

0 comments on commit 5db564d

Please sign in to comment.