Commit 8dba6988 authored by Mark Brown's avatar Mark Brown

Merge tag 'samsung-platdrv-boards' into asoc-5.10

ASoC: Convert Samsung drivers to platform drivers
parents a2f6d303 dcacbc0f
......@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
#include <linux/workqueue.h>
......@@ -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)
{
s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
......@@ -498,6 +513,7 @@ static struct platform_device *gta02_devices[] __initdata = {
&gta02_buttons_device,
&s3c_device_adc,
&s3c_device_ts,
&gta02_audio,
};
static void gta02_poweroff(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));
gpiod_add_lookup_table(&gta02_audio_gpio_table);
platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
pm_power_off = gta02_poweroff;
......
......@@ -475,6 +475,22 @@ static struct gpiod_lookup_table h1940_mmc_gpio_table = {
},
};
static struct gpiod_lookup_table h1940_audio_gpio_table = {
.dev_id = "h1940-audio",
.table = {
GPIO_LOOKUP("H1940_LATCH",
H1940_LATCH_AUDIO_POWER - H1940_LATCH_GPIO(0),
"speaker-power", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("GPIOG", 4, "hp", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct platform_device h1940_audio = {
.name = "h1940-audio",
.id = -1,
};
static struct pwm_lookup h1940_pwm_lookup[] = {
PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 36296,
PWM_POLARITY_NORMAL),
......@@ -651,6 +667,7 @@ static struct platform_device *h1940_devices[] __initdata = {
&s3c_device_ts,
&power_supply,
&h1940_battery,
&h1940_audio,
};
static void __init h1940_map_io(void)
......@@ -690,6 +707,7 @@ static void __init h1940_init(void)
s3c24xx_fb_set_platdata(&h1940_fb_info);
gpiod_add_lookup_table(&h1940_mmc_gpio_table);
gpiod_add_lookup_table(&h1940_audio_gpio_table);
s3c24xx_mci_set_platdata(&h1940_mmc_cfg);
s3c24xx_udc_set_platdata(&h1940_udc_cfg);
s3c24xx_ts_set_platdata(&h1940_ts_cfg);
......
......@@ -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 = {
&s3c2410_device_dclk,
&s3c_device_lcd,
......@@ -746,6 +760,7 @@ static struct platform_device *rx1950_devices[] __initdata = {
&power_supply,
&rx1950_battery,
&rx1950_leds,
&rx1950_audio,
};
static void __init rx1950_map_io(void)
......@@ -813,6 +828,7 @@ static void __init rx1950_init_machine(void)
gpio_direction_output(S3C2410_GPJ(6), 0);
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));
i2c_register_board_info(0, rx1950_i2c_devices,
......
......@@ -15,9 +15,6 @@
#include <sound/jack.h>
#include "regs-iis.h"
#include <asm/mach-types.h>
#include <mach/gpio-samsung.h>
#include "s3c24xx-i2s.h"
static const unsigned int rates[] = {
......@@ -31,6 +28,8 @@ static const struct snd_pcm_hw_constraint_list hw_rates = {
.list = rates,
};
static struct gpio_desc *gpiod_speaker_power;
static struct snd_soc_jack hp_jack;
static struct snd_soc_jack_pin hp_jack_pins[] = {
......@@ -47,7 +46,6 @@ static struct snd_soc_jack_pin hp_jack_pins[] = {
static struct snd_soc_jack_gpio hp_jack_gpios[] = {
{
.gpio = S3C2410_GPG(4),
.name = "hp-gpio",
.report = SND_JACK_HEADPHONE,
.invert = 1,
......@@ -123,9 +121,9 @@ static int h1940_spk_power(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
if (SND_SOC_DAPM_EVENT_ON(event))
gpio_set_value(S3C_GPIO_END + 9, 1);
gpiod_set_value(gpiod_speaker_power, 1);
else
gpio_set_value(S3C_GPIO_END + 9, 0);
gpiod_set_value(gpiod_speaker_power, 0);
return 0;
}
......@@ -151,8 +149,6 @@ static const struct snd_soc_dapm_route audio_map[] = {
{"VINM", NULL, "Mic Jack"},
};
static struct platform_device *s3c24xx_snd_device;
static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
{
snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
......@@ -194,55 +190,34 @@ static struct snd_soc_card h1940_asoc = {
.num_dapm_routes = ARRAY_SIZE(audio_map),
};
static int __init h1940_init(void)
static int h1940_probe(struct platform_device *pdev)
{
int ret;
if (!machine_is_h1940())
return -ENODEV;
struct device *dev = &pdev->dev;
/* configure some gpios */
ret = gpio_request(S3C_GPIO_END + 9, "speaker-power");
if (ret)
goto err_out;
h1940_asoc.dev = dev;
hp_jack_gpios[0].gpiod_dev = dev;
gpiod_speaker_power = devm_gpiod_get(&pdev->dev, "speaker-power",
GPIOD_OUT_LOW);
ret = gpio_direction_output(S3C_GPIO_END + 9, 0);
if (ret)
goto err_gpio;
s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
if (!s3c24xx_snd_device) {
ret = -ENOMEM;
goto err_gpio;
if (IS_ERR(gpiod_speaker_power)) {
dev_err(dev, "Could not get gpio\n");
return PTR_ERR(gpiod_speaker_power);
}
platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
ret = platform_device_add(s3c24xx_snd_device);
if (ret)
goto err_plat;
return 0;
err_plat:
platform_device_put(s3c24xx_snd_device);
err_gpio:
gpio_free(S3C_GPIO_END + 9);
err_out:
return ret;
}
static void __exit h1940_exit(void)
{
platform_device_unregister(s3c24xx_snd_device);
gpio_free(S3C_GPIO_END + 9);
return devm_snd_soc_register_card(dev, &h1940_asoc);
}
module_init(h1940_init);
module_exit(h1940_exit);
static struct platform_driver h1940_audio_driver = {
.driver = {
.name = "h1940-audio",
.pm = &snd_soc_pm_ops,
},
.probe = h1940_probe,
};
module_platform_driver(h1940_audio_driver);
/* Module information */
MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
MODULE_DESCRIPTION("ALSA SoC H1940");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:h1940-audio");
......@@ -11,14 +11,11 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <sound/soc.h>
#include <mach/gpio-samsung.h>
#include <asm/mach-types.h>
#include "regs-iis.h"
#include "../codecs/wm8753.h"
#include "s3c24xx-i2s.h"
......@@ -166,6 +163,7 @@ static struct snd_soc_ops neo1973_voice_ops = {
.hw_free = neo1973_voice_hw_free,
};
static struct gpio_desc *gpiod_hp_in, *gpiod_amp_shut;
static int gta02_speaker_enabled;
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];
gpio_set_value(S3C2410_GPJ(2), !gta02_speaker_enabled);
gpiod_set_value(gpiod_hp_in, !gta02_speaker_enabled);
return 0;
}
......@@ -188,7 +186,7 @@ static int lm4853_get_spk(struct snd_kcontrol *kcontrol,
static int lm4853_event(struct snd_soc_dapm_widget *w,
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;
}
......@@ -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 = {
.name = "neo1973",
.name = "neo1973gta02",
.owner = THIS_MODULE,
.dai_link = neo1973_dai,
.num_links = ARRAY_SIZE(neo1973_dai),
......@@ -332,62 +325,36 @@ static struct snd_soc_card neo1973 = {
.fully_routed = true,
};
static struct platform_device *neo1973_snd_device;
static int __init neo1973_init(void)
static int neo1973_probe(struct platform_device *pdev)
{
int ret;
if (!machine_is_neo1973_gta02())
return -ENODEV;
struct device *dev = &pdev->dev;
if (machine_is_neo1973_gta02()) {
neo1973.name = "neo1973gta02";
neo1973.num_aux_devs = 1;
ret = gpio_request_array(neo1973_gta02_gpios,
ARRAY_SIZE(neo1973_gta02_gpios));
if (ret)
return ret;
gpiod_hp_in = devm_gpiod_get(dev, "hp", GPIOD_OUT_HIGH);
if (IS_ERR(gpiod_hp_in)) {
dev_err(dev, "missing gpio %s\n", "hp");
return PTR_ERR(gpiod_hp_in);
}
neo1973_snd_device = platform_device_alloc("soc-audio", -1);
if (!neo1973_snd_device) {
ret = -ENOMEM;
goto err_gpio_free;
gpiod_amp_shut = devm_gpiod_get(dev, "amp-shut", GPIOD_OUT_HIGH);
if (IS_ERR(gpiod_amp_shut)) {
dev_err(dev, "missing gpio %s\n", "amp-shut");
return PTR_ERR(gpiod_amp_shut);
}
platform_set_drvdata(neo1973_snd_device, &neo1973);
ret = platform_device_add(neo1973_snd_device);
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;
neo1973.dev = dev;
return devm_snd_soc_register_card(dev, &neo1973);
}
module_init(neo1973_init);
static void __exit neo1973_exit(void)
{
platform_device_unregister(neo1973_snd_device);
if (machine_is_neo1973_gta02()) {
gpio_free_array(neo1973_gta02_gpios,
ARRAY_SIZE(neo1973_gta02_gpios));
}
}
module_exit(neo1973_exit);
struct platform_driver neo1973_audio = {
.driver = {
.name = "neo1973-audio",
.pm = &snd_soc_pm_ops,
},
.probe = neo1973_probe,
};
module_platform_driver(neo1973_audio);
/* Module information */
MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org, www.openmoko.org");
MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 and Frerunner");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:neo1973-audio");
......@@ -12,16 +12,13 @@
// Vasily Khoruzhick <anarsoul@gmail.com>
#include <linux/types.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <sound/soc.h>
#include <sound/jack.h>
#include <mach/gpio-samsung.h>
#include "regs-iis.h"
#include <asm/mach-types.h>
#include "s3c24xx-i2s.h"
static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd);
......@@ -58,7 +55,6 @@ static struct snd_soc_jack_pin hp_jack_pins[] = {
static struct snd_soc_jack_gpio hp_jack_gpios[] = {
[0] = {
.gpio = S3C2410_GPG(12),
.name = "hp-gpio",
.report = SND_JACK_HEADPHONE,
.invert = 1,
......@@ -123,8 +119,6 @@ static struct snd_soc_card rx1950_asoc = {
.num_dapm_routes = ARRAY_SIZE(audio_map),
};
static struct platform_device *s3c24xx_snd_device;
static int rx1950_startup(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
......@@ -134,13 +128,15 @@ static int rx1950_startup(struct snd_pcm_substream *substream)
&hw_rates);
}
struct gpio_desc *gpiod_speaker_power;
static int rx1950_spk_power(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
if (SND_SOC_DAPM_EVENT_ON(event))
gpio_set_value(S3C2410_GPA(1), 1);
gpiod_set_value(gpiod_speaker_power, 1);
else
gpio_set_value(S3C2410_GPA(1), 0);
gpiod_set_value(gpiod_speaker_power, 0);
return 0;
}
......@@ -214,57 +210,35 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
static int __init rx1950_init(void)
static int rx1950_probe(struct platform_device *pdev)
{
int ret;
if (!machine_is_rx1950())
return -ENODEV;
struct device *dev = &pdev->dev;
/* configure some gpios */
ret = gpio_request(S3C2410_GPA(1), "speaker-power");
if (ret)
goto err_gpio;
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;
gpiod_speaker_power = devm_gpiod_get(dev, "speaker-power", GPIOD_OUT_LOW);
if (IS_ERR(gpiod_speaker_power)) {
dev_err(dev, "cannot get gpio\n");
return PTR_ERR(gpiod_speaker_power);
}
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;
}
hp_jack_gpios[0].gpiod_dev = dev;
rx1950_asoc.dev = dev;
return 0;
err_plat_add:
err_plat_alloc:
err_gpio_conf:
gpio_free(S3C2410_GPA(1));
err_gpio:
return ret;
return devm_snd_soc_register_card(dev, &rx1950_asoc);
}
static void __exit rx1950_exit(void)
{
platform_device_unregister(s3c24xx_snd_device);
gpio_free(S3C2410_GPA(1));
}
struct platform_driver rx1950_audio = {
.driver = {
.name = "rx1950-audio",
.pm = &snd_soc_pm_ops,
},
.probe = rx1950_probe,
};
module_init(rx1950_init);
module_exit(rx1950_exit);
module_platform_driver(rx1950_audio);
/* Module information */
MODULE_AUTHOR("Vasily Khoruzhick");
MODULE_DESCRIPTION("ALSA SoC RX1950");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:rx1950-audio");
......@@ -616,8 +616,7 @@ int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
EXPORT_SYMBOL_GPL(s3c_i2sv2_iis_calc_rate);
int s3c_i2sv2_probe(struct snd_soc_dai *dai,
struct s3c_i2sv2_info *i2s,
unsigned long base)
struct s3c_i2sv2_info *i2s)
{
struct device *dev = dai->dev;
unsigned int iismod;
......
......@@ -83,8 +83,7 @@ extern int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
* @base: The base address for the registers.
*/
extern int s3c_i2sv2_probe(struct snd_soc_dai *dai,
struct s3c_i2sv2_info *i2s,
unsigned long base);
struct s3c_i2sv2_info *i2s);
/**
* s3c_i2sv2_cleanup - cleanup resources allocated in s3c_i2sv2_probe
......
......@@ -49,7 +49,7 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai)
snd_soc_dai_init_dma_data(dai, &s3c2412_i2s_pcm_stereo_out,
&s3c2412_i2s_pcm_stereo_in);
ret = s3c_i2sv2_probe(dai, &s3c2412_i2s, S3C2410_PA_IIS);
ret = s3c_i2sv2_probe(dai, &s3c2412_i2s);
if (ret)
return ret;
......
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