History

ASoC: ti: Convert N810 ASoC to GPIO descriptors

The N810 uses GPIO descriptors pretty much exclusively, but not for ASoC, so let's fix it. Register the pins in a descriptor table in the machine since the ASoC device is not using device tree. Use static locals for the GPIO descriptors because I'm not able to experient with better state storage on any real hardware. Others using the N810 can come afterwards and improve this.

Linus Walleij committed 3 years ago

Commit 22041ed1 parent 5b12dd82 files · +27 −14Browse files

Unified · Split

2 files
  1. arch/arm/mach-omap2/board-n8x0.c +10 −0
  2. sound/soc/ti/n810.c +17 −14
arch/arm/mach-omap2/board-n8x0.c+10−0
@@ -498,6 +498,15 @@ struct menelaus_platform_data n8x0_menelaus_platform_data = { · 497 unmodified lines
498498 .late_init = n8x0_menelaus_late_init,
499499 };
500500
501+static struct gpiod_lookup_table nokia810_asoc_gpio_table = {
502+ .dev_id = "soc-audio",
503+ .table = {
504+ GPIO_LOOKUP("gpio-0-15", 10, "headset", GPIO_ACTIVE_HIGH),
505+ GPIO_LOOKUP("gpio-80-111", 21, "speaker", GPIO_ACTIVE_HIGH),
506+ { }
507+ },
508+};
509+
501510 static int __init n8x0_late_initcall(void)
502511 {
503512 if (!board_caps)
@@ -505,6 +514,7 @@ static int __init n8x0_late_initcall(void) · 1 unmodified line
505514
506515 n8x0_mmc_init();
507516 n8x0_usb_init();
517+ gpiod_add_lookup_table(&nokia810_asoc_gpio_table);
508518
509519 return 0;
510520 }
sound/soc/ti/n810.c+17−14
@@ -15,14 +15,14 @@ · 14 unmodified lines
1515 #include <sound/soc.h>
1616
1717 #include <asm/mach-types.h>
18−#include <linux/gpio.h>
18+#include <linux/gpio/consumer.h>
1919 #include <linux/module.h>
2020 #include <linux/platform_data/asoc-ti-mcbsp.h>
2121
2222 #include "omap-mcbsp.h"
2323
24−#define N810_HEADSET_AMP_GPIO 10
25−#define N810_SPEAKER_AMP_GPIO 101
24+static struct gpio_desc *n810_headset_amp;
25+static struct gpio_desc *n810_speaker_amp;
2626
2727 enum {
2828 N810_JACK_DISABLED,
@@ -187,9 +187,9 @@ static int n810_spk_event(struct snd_soc_dapm_widget *w, · 158 unmodified lines
187187 struct snd_kcontrol *k, int event)
188188 {
189189 if (SND_SOC_DAPM_EVENT_ON(event))
190− gpio_set_value(N810_SPEAKER_AMP_GPIO, 1);
190+ gpiod_set_value(n810_speaker_amp, 1);
191191 else
192− gpio_set_value(N810_SPEAKER_AMP_GPIO, 0);
192+ gpiod_set_value(n810_speaker_amp, 0);
193193
194194 return 0;
195195 }
@@ -198,9 +198,9 @@ static int n810_jack_event(struct snd_soc_dapm_widget *w, · 2 unmodified lines
198198 struct snd_kcontrol *k, int event)
199199 {
200200 if (SND_SOC_DAPM_EVENT_ON(event))
201− gpio_set_value(N810_HEADSET_AMP_GPIO, 1);
201+ gpiod_set_value(n810_headset_amp, 1);
202202 else
203− gpio_set_value(N810_HEADSET_AMP_GPIO, 0);
203+ gpiod_set_value(n810_headset_amp, 0);
204204
205205 return 0;
206206 }
@@ -327,14 +327,19 @@ static int __init n810_soc_init(void) · 120 unmodified lines
327327 clk_set_parent(sys_clkout2_src, func96m_clk);
328328 clk_set_rate(sys_clkout2, 12000000);
329329
330− if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) ||
331− (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) {
332− err = -EINVAL;
330+ n810_headset_amp = devm_gpiod_get(&n810_snd_device->dev,
331+ "headphone", GPIOD_OUT_LOW);
332+ if (IS_ERR(n810_headset_amp)) {
333+ err = PTR_ERR(n810_headset_amp);
333334 goto err4;
334335 }
335336
336− gpio_direction_output(N810_HEADSET_AMP_GPIO, 0);
337− gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);
337+ n810_speaker_amp = devm_gpiod_get(&n810_snd_device->dev,
338+ "speaker", GPIOD_OUT_LOW);
339+ if (IS_ERR(n810_speaker_amp)) {
340+ err = PTR_ERR(n810_speaker_amp);
341+ goto err4;
342+ }
338343
339344 return 0;
340345 err4:
@@ -351,8 +356,6 @@ err1: · 10 unmodified lines
351356
352357 static void __exit n810_soc_exit(void)
353358 {
354− gpio_free(N810_SPEAKER_AMP_GPIO);
355− gpio_free(N810_HEADSET_AMP_GPIO);
356359 clk_put(sys_clkout2_src);
357360 clk_put(sys_clkout2);
358361 clk_put(func96m_clk);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t