Skip to content

Commit

Permalink
Merge pull request #127 from clamor-s/patch
Browse files Browse the repository at this point in the history
Update sound routing and convert tegra gpio
  • Loading branch information
digetx authored Aug 15, 2022
2 parents b7e8027 + 9fa9353 commit 701ab7e
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 31 deletions.
8 changes: 5 additions & 3 deletions arch/arm/boot/dts/tegra20-asus-tf101.dts
Original file line number Diff line number Diff line change
Expand Up @@ -1230,15 +1230,17 @@
"Int Spk", "RON",
"Int Spk", "LOP",
"Int Spk", "LON",
"Mic Jack", "MICBIAS",
"IN1L", "Mic Jack";
"IN1L", "Headset Mic",
"IN2L", "Headset Mic",
"DMICDAT", "Int Mic";

nvidia,i2s-controller = <&tegra_i2s1>;
nvidia,audio-codec = <&wm8903>;

nvidia,spkr-en-gpios = <&wm8903 2 GPIO_ACTIVE_HIGH>;
nvidia,hp-det-gpios = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_LOW>;
nvidia,headset;
nvidia,mic-det-gpios = <&gpio TEGRA_GPIO(X, 1) GPIO_ACTIVE_HIGH>;
nvidia,coupled-mic-hp-det;

clocks = <&tegra_car TEGRA20_CLK_PLL_A>,
<&tegra_car TEGRA20_CLK_PLL_A_OUT0>,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/tegra30-asus-tf201.dts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@
"Int Spk", "SPOL",
"Int Spk", "SPOR",
"MIC1", "MIC Bias1",
"MIC Bias1", "Mic Jack",
"MIC Bias1", "Headset Mic",
"DMIC", "Int Mic";

nvidia,audio-codec = <&rt5631>;
Expand Down
5 changes: 2 additions & 3 deletions arch/arm/boot/dts/tegra30-asus-tf300t.dts
Original file line number Diff line number Diff line change
Expand Up @@ -1054,13 +1054,12 @@
"Int Spk", "RON",
"Int Spk", "LOP",
"Int Spk", "LON",
"IN1L", "Mic Jack",
"IN2L", "Mic Jack",
"IN1L", "Headset Mic",
"IN2L", "Headset Mic",
"DMICDAT", "Int Mic";

nvidia,audio-codec = <&wm8903>;
nvidia,spkr-en-gpios = <&wm8903 2 GPIO_ACTIVE_HIGH>;
nvidia,headset;
};
};

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/tegra30-asus-tf300tg.dts
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@
"Int Spk", "SPOL",
"Int Spk", "SPOR",
"MIC1", "MIC Bias1",
"MIC Bias1", "Mic Jack",
"MIC Bias1", "Headset Mic",
"DMIC", "Int Mic";

nvidia,audio-codec = <&rt5631>;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/tegra30-asus-tf300tl.dts
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@
"Int Spk", "SPOL",
"Int Spk", "SPOR",
"MIC1", "MIC Bias1",
"MIC Bias1", "Mic Jack",
"MIC Bias1", "Headset Mic",
"DMIC", "Int Mic";

nvidia,audio-codec = <&rt5631>;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/tegra30-asus-tf700t.dts
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@
"Int Spk", "SPOL",
"Int Spk", "SPOR",
"MIC1", "MIC Bias1",
"MIC Bias1", "Mic Jack",
"MIC Bias1", "Headset Mic",
"DMIC", "Int Mic";

nvidia,audio-codec = <&rt5631>;
Expand Down
9 changes: 5 additions & 4 deletions arch/arm/boot/dts/tegra30-asus-transformer-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,18 @@
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
};

spi2_cs1_n_pw2 {
hp_detect {
nvidia,pins = "spi2_cs1_n_pw2";
nvidia,function = "spi2";
nvidia,pull = <TEGRA_PIN_PULL_UP>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
};

spi2_sck_px2 {
mic_detect {
nvidia,pins = "spi2_sck_px2";
nvidia,function = "spi2";
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,pull = <TEGRA_PIN_PULL_UP>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
};
Expand Down Expand Up @@ -1727,7 +1727,8 @@
nvidia,i2s-controller = <&tegra_i2s1>;

nvidia,hp-det-gpios = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_LOW>;
nvidia,hp-mute-gpios = <&gpio TEGRA_GPIO(X, 2) GPIO_ACTIVE_LOW>;
nvidia,mic-det-gpios = <&gpio TEGRA_GPIO(X, 2) GPIO_ACTIVE_LOW>;
nvidia,coupled-mic-hp-det;

clocks = <&tegra_car TEGRA30_CLK_PLL_A>,
<&tegra_car TEGRA30_CLK_PLL_A_OUT0>,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/tegra30-pegatron-chagall.dts
Original file line number Diff line number Diff line change
Expand Up @@ -2776,7 +2776,7 @@
"Int Spk", "RON",
"Int Spk", "LOP",
"Int Spk", "LON",
"IN1R", "Mic Jack",
"IN1R", "Headset Mic",
"DMICDAT", "Int Mic";

nvidia,i2s-controller = <&tegra_i2s1>;
Expand Down
56 changes: 40 additions & 16 deletions drivers/gpio/gpio-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/irqdomain.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/pinctrl/consumer.h>
Expand Down Expand Up @@ -94,7 +95,6 @@ struct tegra_gpio_info {
struct tegra_gpio_bank *bank_info;
const struct tegra_gpio_soc_config *soc;
struct gpio_chip gc;
struct irq_chip ic;
u32 bank_count;
unsigned int *irqs;
};
Expand Down Expand Up @@ -288,6 +288,7 @@ static void tegra_gpio_irq_mask(struct irq_data *d)
unsigned int gpio = d->hwirq;

tegra_gpio_mask_write(tgi, GPIO_MSK_INT_ENB(tgi, gpio), gpio, 0);
gpiochip_disable_irq(chip, gpio);
}

static void tegra_gpio_irq_unmask(struct irq_data *d)
Expand All @@ -296,6 +297,7 @@ static void tegra_gpio_irq_unmask(struct irq_data *d)
struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
unsigned int gpio = d->hwirq;

gpiochip_enable_irq(chip, gpio);
tegra_gpio_mask_write(tgi, GPIO_MSK_INT_ENB(tgi, gpio), gpio, 1);
}

Expand Down Expand Up @@ -598,10 +600,43 @@ static void tegra_gpio_irq_release_resources(struct irq_data *d)
tegra_gpio_enable(tgi, d->hwirq);
}

static void tegra_gpio_irq_print_chip(struct irq_data *d, struct seq_file *s)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);

seq_printf(s, dev_name(chip->parent));
}

static const struct irq_chip tegra_gpio_irq_chip = {
.irq_shutdown = tegra_gpio_irq_shutdown,
.irq_ack = tegra_gpio_irq_ack,
.irq_mask = tegra_gpio_irq_mask,
.irq_unmask = tegra_gpio_irq_unmask,
.irq_set_type = tegra_gpio_irq_set_type,
.irq_set_wake = pm_sleep_ptr(tegra_gpio_irq_set_wake),
.irq_print_chip = tegra_gpio_irq_print_chip,
.irq_request_resources = tegra_gpio_irq_request_resources,
.irq_release_resources = tegra_gpio_irq_release_resources,
.flags = IRQCHIP_IMMUTABLE,
};

static const struct irq_chip tegra210_gpio_irq_chip = {
.irq_shutdown = tegra_gpio_irq_shutdown,
.irq_ack = tegra_gpio_irq_ack,
.irq_mask = tegra_gpio_irq_mask,
.irq_unmask = tegra_gpio_irq_unmask,
.irq_set_affinity = tegra_gpio_irq_set_affinity,
.irq_set_type = tegra_gpio_irq_set_type,
.irq_set_wake = pm_sleep_ptr(tegra_gpio_irq_set_wake),
.irq_print_chip = tegra_gpio_irq_print_chip,
.irq_request_resources = tegra_gpio_irq_request_resources,
.irq_release_resources = tegra_gpio_irq_release_resources,
.flags = IRQCHIP_IMMUTABLE,
};

#ifdef CONFIG_DEBUG_FS

#include <linux/debugfs.h>
#include <linux/seq_file.h>

static int tegra_dbg_gpio_show(struct seq_file *s, void *unused)
{
Expand Down Expand Up @@ -689,18 +724,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
tgi->gc.ngpio = tgi->bank_count * 32;
tgi->gc.parent = &pdev->dev;

tgi->ic.name = "GPIO";
tgi->ic.irq_ack = tegra_gpio_irq_ack;
tgi->ic.irq_mask = tegra_gpio_irq_mask;
tgi->ic.irq_unmask = tegra_gpio_irq_unmask;
tgi->ic.irq_set_type = tegra_gpio_irq_set_type;
tgi->ic.irq_shutdown = tegra_gpio_irq_shutdown;
#ifdef CONFIG_PM_SLEEP
tgi->ic.irq_set_wake = tegra_gpio_irq_set_wake;
#endif
tgi->ic.irq_request_resources = tegra_gpio_irq_request_resources;
tgi->ic.irq_release_resources = tegra_gpio_irq_release_resources;

platform_set_drvdata(pdev, tgi);

if (tgi->soc->debounce_supported)
Expand Down Expand Up @@ -733,7 +756,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
}

irq = &tgi->gc.irq;
irq->chip = &tgi->ic;
irq->fwnode = of_node_to_fwnode(pdev->dev.of_node);
irq->child_to_parent_hwirq = tegra_gpio_child_to_parent_hwirq;
irq->populate_parent_alloc_arg = tegra_gpio_populate_parent_fwspec;
Expand All @@ -752,7 +774,9 @@ static int tegra_gpio_probe(struct platform_device *pdev)
if (!irq->parent_domain)
return -EPROBE_DEFER;

tgi->ic.irq_set_affinity = tegra_gpio_irq_set_affinity;
gpio_irq_chip_set_chip(irq, &tegra210_gpio_irq_chip);
} else {
gpio_irq_chip_set_chip(irq, &tegra_gpio_irq_chip);
}

tgi->regs = devm_platform_ioremap_resource(pdev, 0);
Expand Down
17 changes: 17 additions & 0 deletions sound/soc/tegra/tegra_asoc_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ static struct snd_soc_jack_gpio tegra_machine_headset_jack_gpio = {
};

/* Mic Jack */
static int headset_check(void *data)
{
struct tegra_machine *machine = (struct tegra_machine *) data;

/* Detect mic insertion only if 3.5 jack is in */
if (gpiod_get_value_cansleep(machine->gpiod_hp_det) &&
gpiod_get_value_cansleep(machine->gpiod_mic_det))
return SND_JACK_MICROPHONE;

return 0;
}

static struct snd_soc_jack tegra_machine_mic_jack;

Expand Down Expand Up @@ -189,8 +200,13 @@ int tegra_asoc_machine_init(struct snd_soc_pcm_runtime *rtd)
return err;
}

tegra_machine_mic_jack_gpio.data = machine;
tegra_machine_mic_jack_gpio.desc = machine->gpiod_mic_det;

if (of_property_read_bool(card->dev->of_node,
"nvidia,coupled-mic-hp-det"))
tegra_machine_mic_jack_gpio.jack_status_check = headset_check;

err = snd_soc_jack_add_gpios(&tegra_machine_mic_jack, 1,
&tegra_machine_mic_jack_gpio);
if (err)
Expand Down Expand Up @@ -960,6 +976,7 @@ static const struct tegra_asoc_data tegra_rt5631_data = {
.add_common_dapm_widgets = true,
.add_common_controls = true,
.add_common_snd_ops = true,
.add_mic_jack = true,
.add_hp_jack = true,
};

Expand Down

0 comments on commit 701ab7e

Please sign in to comment.