Commit e26a2abc authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Mark Brown

ASoC: samsung: neo1973: turn into platform driver

Avoid machine specific headers by using a gpio lookup table
combined with a platform_driver for this board.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20200806182059.2431-25-krzk@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9666e27f
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
...@@ -474,6 +475,20 @@ static struct platform_device gta02_buttons_device = { ...@@ -474,6 +475,20 @@ static struct platform_device gta02_buttons_device = {
}, },
}; };
static struct gpiod_lookup_table gta02_audio_gpio_table = {
.dev_id = "neo1973-audio",
.table = {
GPIO_LOOKUP("GPIOJ", 2, "amp-shut", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("GPIOJ", 1, "hp", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct platform_device gta02_audio = {
.name = "neo1973-audio",
.id = -1,
};
static void __init gta02_map_io(void) static void __init gta02_map_io(void)
{ {
s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc)); s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
...@@ -498,6 +513,7 @@ static struct platform_device *gta02_devices[] __initdata = { ...@@ -498,6 +513,7 @@ static struct platform_device *gta02_devices[] __initdata = {
&gta02_buttons_device, &gta02_buttons_device,
&s3c_device_adc, &s3c_device_adc,
&s3c_device_ts, &s3c_device_ts,
&gta02_audio,
}; };
static void gta02_poweroff(void) static void gta02_poweroff(void)
...@@ -524,6 +540,7 @@ static void __init gta02_machine_init(void) ...@@ -524,6 +540,7 @@ static void __init gta02_machine_init(void)
i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs)); i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs));
gpiod_add_lookup_table(&gta02_audio_gpio_table);
platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices)); platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
pm_power_off = gta02_poweroff; pm_power_off = gta02_poweroff;
......
...@@ -11,14 +11,11 @@ ...@@ -11,14 +11,11 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <mach/gpio-samsung.h>
#include <asm/mach-types.h>
#include "regs-iis.h" #include "regs-iis.h"
#include "../codecs/wm8753.h" #include "../codecs/wm8753.h"
#include "s3c24xx-i2s.h" #include "s3c24xx-i2s.h"
...@@ -166,6 +163,7 @@ static struct snd_soc_ops neo1973_voice_ops = { ...@@ -166,6 +163,7 @@ static struct snd_soc_ops neo1973_voice_ops = {
.hw_free = neo1973_voice_hw_free, .hw_free = neo1973_voice_hw_free,
}; };
static struct gpio_desc *gpiod_hp_in, *gpiod_amp_shut;
static int gta02_speaker_enabled; static int gta02_speaker_enabled;
static int lm4853_set_spk(struct snd_kcontrol *kcontrol, static int lm4853_set_spk(struct snd_kcontrol *kcontrol,
...@@ -173,7 +171,7 @@ static int lm4853_set_spk(struct snd_kcontrol *kcontrol, ...@@ -173,7 +171,7 @@ static int lm4853_set_spk(struct snd_kcontrol *kcontrol,
{ {
gta02_speaker_enabled = ucontrol->value.integer.value[0]; gta02_speaker_enabled = ucontrol->value.integer.value[0];
gpio_set_value(S3C2410_GPJ(2), !gta02_speaker_enabled); gpiod_set_value(gpiod_hp_in, !gta02_speaker_enabled);
return 0; return 0;
} }
...@@ -188,7 +186,7 @@ static int lm4853_get_spk(struct snd_kcontrol *kcontrol, ...@@ -188,7 +186,7 @@ static int lm4853_get_spk(struct snd_kcontrol *kcontrol,
static int lm4853_event(struct snd_soc_dapm_widget *w, static int lm4853_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
gpio_set_value(S3C2410_GPJ(1), SND_SOC_DAPM_EVENT_OFF(event)); gpiod_set_value(gpiod_amp_shut, SND_SOC_DAPM_EVENT_OFF(event));
return 0; return 0;
} }
...@@ -308,13 +306,8 @@ static struct snd_soc_codec_conf neo1973_codec_conf[] = { ...@@ -308,13 +306,8 @@ static struct snd_soc_codec_conf neo1973_codec_conf[] = {
}, },
}; };
static const struct gpio neo1973_gta02_gpios[] = {
{ S3C2410_GPJ(2), GPIOF_OUT_INIT_HIGH, "GTA02_HP_IN" },
{ S3C2410_GPJ(1), GPIOF_OUT_INIT_HIGH, "GTA02_AMP_SHUT" },
};
static struct snd_soc_card neo1973 = { static struct snd_soc_card neo1973 = {
.name = "neo1973", .name = "neo1973gta02",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.dai_link = neo1973_dai, .dai_link = neo1973_dai,
.num_links = ARRAY_SIZE(neo1973_dai), .num_links = ARRAY_SIZE(neo1973_dai),
...@@ -332,62 +325,36 @@ static struct snd_soc_card neo1973 = { ...@@ -332,62 +325,36 @@ static struct snd_soc_card neo1973 = {
.fully_routed = true, .fully_routed = true,
}; };
static struct platform_device *neo1973_snd_device; static int neo1973_probe(struct platform_device *pdev)
static int __init neo1973_init(void)
{ {
int ret; struct device *dev = &pdev->dev;
if (!machine_is_neo1973_gta02())
return -ENODEV;
if (machine_is_neo1973_gta02()) { gpiod_hp_in = devm_gpiod_get(dev, "hp", GPIOD_OUT_HIGH);
neo1973.name = "neo1973gta02"; if (IS_ERR(gpiod_hp_in)) {
neo1973.num_aux_devs = 1; dev_err(dev, "missing gpio %s\n", "hp");
return PTR_ERR(gpiod_hp_in);
ret = gpio_request_array(neo1973_gta02_gpios,
ARRAY_SIZE(neo1973_gta02_gpios));
if (ret)
return ret;
} }
gpiod_amp_shut = devm_gpiod_get(dev, "amp-shut", GPIOD_OUT_HIGH);
neo1973_snd_device = platform_device_alloc("soc-audio", -1); if (IS_ERR(gpiod_amp_shut)) {
if (!neo1973_snd_device) { dev_err(dev, "missing gpio %s\n", "amp-shut");
ret = -ENOMEM; return PTR_ERR(gpiod_amp_shut);
goto err_gpio_free;
} }
platform_set_drvdata(neo1973_snd_device, &neo1973); neo1973.dev = dev;
ret = platform_device_add(neo1973_snd_device); return devm_snd_soc_register_card(dev, &neo1973);
if (ret)
goto err_put_device;
return 0;
err_put_device:
platform_device_put(neo1973_snd_device);
err_gpio_free:
if (machine_is_neo1973_gta02()) {
gpio_free_array(neo1973_gta02_gpios,
ARRAY_SIZE(neo1973_gta02_gpios));
}
return ret;
} }
module_init(neo1973_init);
static void __exit neo1973_exit(void)
{
platform_device_unregister(neo1973_snd_device);
if (machine_is_neo1973_gta02()) { struct platform_driver neo1973_audio = {
gpio_free_array(neo1973_gta02_gpios, .driver = {
ARRAY_SIZE(neo1973_gta02_gpios)); .name = "neo1973-audio",
} .pm = &snd_soc_pm_ops,
} },
module_exit(neo1973_exit); .probe = neo1973_probe,
};
module_platform_driver(neo1973_audio);
/* Module information */ /* Module information */
MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org, www.openmoko.org"); MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org, www.openmoko.org");
MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 and Frerunner"); MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 and Frerunner");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:neo1973-audio");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment