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
498 .late_init = n8x0_menelaus_late_init,498 .late_init = n8x0_menelaus_late_init,
499};499};
500 500
501static 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
501static int __init n8x0_late_initcall(void)510static int __init n8x0_late_initcall(void)
502{511{
503 if (!board_caps)512 if (!board_caps)
@@ -505,6 +514,7 @@ static int __init n8x0_late_initcall(void) · 1 unmodified line
505 514
506 n8x0_mmc_init();515 n8x0_mmc_init();
507 n8x0_usb_init();516 n8x0_usb_init();
517 gpiod_add_lookup_table(&nokia810_asoc_gpio_table);
508 518
509 return 0;519 return 0;
510}520}
sound/soc/ti/n810.c+17−14
@@ -15,14 +15,14 @@ · 14 unmodified lines
15#include <sound/soc.h>15#include <sound/soc.h>
16 16
17#include <asm/mach-types.h>17#include <asm/mach-types.h>
18#include <linux/gpio.h>18#include <linux/gpio/consumer.h>
19#include <linux/module.h>19#include <linux/module.h>
20#include <linux/platform_data/asoc-ti-mcbsp.h>20#include <linux/platform_data/asoc-ti-mcbsp.h>
21 21
22#include "omap-mcbsp.h"22#include "omap-mcbsp.h"
23 23
24#define N810_HEADSET_AMP_GPIO 1024static struct gpio_desc *n810_headset_amp;
25#define N810_SPEAKER_AMP_GPIO 10125static struct gpio_desc *n810_speaker_amp;
26 26
27enum {27enum {
28 N810_JACK_DISABLED,28 N810_JACK_DISABLED,
@@ -187,9 +187,9 @@ static int n810_spk_event(struct snd_soc_dapm_widget *w, · 158 unmodified lines
187 struct snd_kcontrol *k, int event)187 struct snd_kcontrol *k, int event)
188{188{
189 if (SND_SOC_DAPM_EVENT_ON(event))189 if (SND_SOC_DAPM_EVENT_ON(event))
190 gpio_set_value(N810_SPEAKER_AMP_GPIO, 1);190 gpiod_set_value(n810_speaker_amp, 1);
191 else191 else
192 gpio_set_value(N810_SPEAKER_AMP_GPIO, 0);192 gpiod_set_value(n810_speaker_amp, 0);
193 193
194 return 0;194 return 0;
195}195}
@@ -198,9 +198,9 @@ static int n810_jack_event(struct snd_soc_dapm_widget *w, · 2 unmodified lines
198 struct snd_kcontrol *k, int event)198 struct snd_kcontrol *k, int event)
199{199{
200 if (SND_SOC_DAPM_EVENT_ON(event))200 if (SND_SOC_DAPM_EVENT_ON(event))
201 gpio_set_value(N810_HEADSET_AMP_GPIO, 1);201 gpiod_set_value(n810_headset_amp, 1);
202 else202 else
203 gpio_set_value(N810_HEADSET_AMP_GPIO, 0);203 gpiod_set_value(n810_headset_amp, 0);
204 204
205 return 0;205 return 0;
206}206}
@@ -327,14 +327,19 @@ static int __init n810_soc_init(void) · 120 unmodified lines
327 clk_set_parent(sys_clkout2_src, func96m_clk);327 clk_set_parent(sys_clkout2_src, func96m_clk);
328 clk_set_rate(sys_clkout2, 12000000);328 clk_set_rate(sys_clkout2, 12000000);
329 329
330 if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) ||330 n810_headset_amp = devm_gpiod_get(&n810_snd_device->dev,
331 (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) {331 "headphone", GPIOD_OUT_LOW);
332 err = -EINVAL;332 if (IS_ERR(n810_headset_amp)) {
333 err = PTR_ERR(n810_headset_amp);
333 goto err4;334 goto err4;
334 }335 }
335 336
336 gpio_direction_output(N810_HEADSET_AMP_GPIO, 0);337 n810_speaker_amp = devm_gpiod_get(&n810_snd_device->dev,
337 gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);338 "speaker", GPIOD_OUT_LOW);
339 if (IS_ERR(n810_speaker_amp)) {
340 err = PTR_ERR(n810_speaker_amp);
341 goto err4;
342 }
338 343
339 return 0;344 return 0;
340err4:345err4:
@@ -351,8 +356,6 @@ err1: · 10 unmodified lines
351 356
352static void __exit n810_soc_exit(void)357static void __exit n810_soc_exit(void)
353{358{
354 gpio_free(N810_SPEAKER_AMP_GPIO);
355 gpio_free(N810_HEADSET_AMP_GPIO);
356 clk_put(sys_clkout2_src);359 clk_put(sys_clkout2_src);
357 clk_put(sys_clkout2);360 clk_put(sys_clkout2);
358 clk_put(func96m_clk);361 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