Commit 83d74e35 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Mark Brown

ASoC: samsung: rx1950: 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-26-krzk@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e26a2abc
...@@ -728,6 +728,20 @@ static struct i2c_board_info rx1950_i2c_devices[] = { ...@@ -728,6 +728,20 @@ static struct i2c_board_info rx1950_i2c_devices[] = {
}, },
}; };
static struct gpiod_lookup_table rx1950_audio_gpio_table = {
.dev_id = "rx1950-audio",
.table = {
GPIO_LOOKUP("GPIOG", 12, "hp-gpio", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("GPIOA", 1, "speaker-power", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct platform_device rx1950_audio = {
.name = "rx1950-audio",
.id = -1,
};
static struct platform_device *rx1950_devices[] __initdata = { static struct platform_device *rx1950_devices[] __initdata = {
&s3c2410_device_dclk, &s3c2410_device_dclk,
&s3c_device_lcd, &s3c_device_lcd,
...@@ -746,6 +760,7 @@ static struct platform_device *rx1950_devices[] __initdata = { ...@@ -746,6 +760,7 @@ static struct platform_device *rx1950_devices[] __initdata = {
&power_supply, &power_supply,
&rx1950_battery, &rx1950_battery,
&rx1950_leds, &rx1950_leds,
&rx1950_audio,
}; };
static void __init rx1950_map_io(void) static void __init rx1950_map_io(void)
...@@ -813,6 +828,7 @@ static void __init rx1950_init_machine(void) ...@@ -813,6 +828,7 @@ static void __init rx1950_init_machine(void)
gpio_direction_output(S3C2410_GPJ(6), 0); gpio_direction_output(S3C2410_GPJ(6), 0);
pwm_add_table(rx1950_pwm_lookup, ARRAY_SIZE(rx1950_pwm_lookup)); pwm_add_table(rx1950_pwm_lookup, ARRAY_SIZE(rx1950_pwm_lookup));
gpiod_add_lookup_table(&rx1950_audio_gpio_table);
platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices)); platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
i2c_register_board_info(0, rx1950_i2c_devices, i2c_register_board_info(0, rx1950_i2c_devices,
......
...@@ -12,16 +12,13 @@ ...@@ -12,16 +12,13 @@
// Vasily Khoruzhick <anarsoul@gmail.com> // Vasily Khoruzhick <anarsoul@gmail.com>
#include <linux/types.h> #include <linux/types.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/jack.h> #include <sound/jack.h>
#include <mach/gpio-samsung.h>
#include "regs-iis.h" #include "regs-iis.h"
#include <asm/mach-types.h>
#include "s3c24xx-i2s.h" #include "s3c24xx-i2s.h"
static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd); static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd);
...@@ -58,7 +55,6 @@ static struct snd_soc_jack_pin hp_jack_pins[] = { ...@@ -58,7 +55,6 @@ static struct snd_soc_jack_pin hp_jack_pins[] = {
static struct snd_soc_jack_gpio hp_jack_gpios[] = { static struct snd_soc_jack_gpio hp_jack_gpios[] = {
[0] = { [0] = {
.gpio = S3C2410_GPG(12),
.name = "hp-gpio", .name = "hp-gpio",
.report = SND_JACK_HEADPHONE, .report = SND_JACK_HEADPHONE,
.invert = 1, .invert = 1,
...@@ -123,8 +119,6 @@ static struct snd_soc_card rx1950_asoc = { ...@@ -123,8 +119,6 @@ static struct snd_soc_card rx1950_asoc = {
.num_dapm_routes = ARRAY_SIZE(audio_map), .num_dapm_routes = ARRAY_SIZE(audio_map),
}; };
static struct platform_device *s3c24xx_snd_device;
static int rx1950_startup(struct snd_pcm_substream *substream) static int rx1950_startup(struct snd_pcm_substream *substream)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
...@@ -134,13 +128,15 @@ static int rx1950_startup(struct snd_pcm_substream *substream) ...@@ -134,13 +128,15 @@ static int rx1950_startup(struct snd_pcm_substream *substream)
&hw_rates); &hw_rates);
} }
struct gpio_desc *gpiod_speaker_power;
static int rx1950_spk_power(struct snd_soc_dapm_widget *w, static int rx1950_spk_power(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
if (SND_SOC_DAPM_EVENT_ON(event)) if (SND_SOC_DAPM_EVENT_ON(event))
gpio_set_value(S3C2410_GPA(1), 1); gpiod_set_value(gpiod_speaker_power, 1);
else else
gpio_set_value(S3C2410_GPA(1), 0); gpiod_set_value(gpiod_speaker_power, 0);
return 0; return 0;
} }
...@@ -214,57 +210,35 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) ...@@ -214,57 +210,35 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int __init rx1950_init(void) static int rx1950_probe(struct platform_device *pdev)
{ {
int ret; struct device *dev = &pdev->dev;
if (!machine_is_rx1950())
return -ENODEV;
/* configure some gpios */ /* configure some gpios */
ret = gpio_request(S3C2410_GPA(1), "speaker-power"); gpiod_speaker_power = devm_gpiod_get(dev, "speaker-power", GPIOD_OUT_LOW);
if (ret) if (IS_ERR(gpiod_speaker_power)) {
goto err_gpio; dev_err(dev, "cannot get gpio\n");
return PTR_ERR(gpiod_speaker_power);
ret = gpio_direction_output(S3C2410_GPA(1), 0);
if (ret)
goto err_gpio_conf;
s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
if (!s3c24xx_snd_device) {
ret = -ENOMEM;
goto err_plat_alloc;
}
platform_set_drvdata(s3c24xx_snd_device, &rx1950_asoc);
ret = platform_device_add(s3c24xx_snd_device);
if (ret) {
platform_device_put(s3c24xx_snd_device);
goto err_plat_add;
} }
return 0; hp_jack_gpios[0].gpiod_dev = dev;
rx1950_asoc.dev = dev;
err_plat_add:
err_plat_alloc:
err_gpio_conf:
gpio_free(S3C2410_GPA(1));
err_gpio: return devm_snd_soc_register_card(dev, &rx1950_asoc);
return ret;
} }
static void __exit rx1950_exit(void) struct platform_driver rx1950_audio = {
{ .driver = {
platform_device_unregister(s3c24xx_snd_device); .name = "rx1950-audio",
gpio_free(S3C2410_GPA(1)); .pm = &snd_soc_pm_ops,
} },
.probe = rx1950_probe,
};
module_init(rx1950_init); module_platform_driver(rx1950_audio);
module_exit(rx1950_exit);
/* Module information */ /* Module information */
MODULE_AUTHOR("Vasily Khoruzhick"); MODULE_AUTHOR("Vasily Khoruzhick");
MODULE_DESCRIPTION("ALSA SoC RX1950"); MODULE_DESCRIPTION("ALSA SoC RX1950");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:rx1950-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