From: Arnd Bergmann <arnd@arndb.de>
To: Kukjin Kim <kgene@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Sangbeom Kim <sbkim73@samsung.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linus.walleij@linaro.org,
Arnd Bergmann <arnd@arndb.de>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org
Subject: [PATCH 19/36] ARM: s3c: rx1950: turn into platform driver
Date: Thu, 10 Oct 2019 22:30:03 +0200 [thread overview]
Message-ID: <20191010203043.1241612-19-arnd@arndb.de> (raw)
Message-ID: <20191010203003.KrdP3bTiXbKSHJCr-3HF3ZdKIl4HZL4MPo7hu15R090@z> (raw)
In-Reply-To: <20191010203043.1241612-1-arnd@arndb.de>
Avoid machine specific headers by using a gpio lookup table
combined with a platform_driver for this board.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm/mach-s3c24xx/mach-rx1950.c | 16 +++++++
sound/soc/samsung/rx1950_uda1380.c | 72 +++++++++--------------------
2 files changed, 39 insertions(+), 49 deletions(-)
diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index 29f9b345a531..9f3b0f18cd36 100644
--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -724,6 +724,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,
@@ -742,6 +756,7 @@ static struct platform_device *rx1950_devices[] __initdata = {
&power_supply,
&rx1950_battery,
&rx1950_leds,
+ &rx1950_audio,
};
static void __init rx1950_map_io(void)
@@ -809,6 +824,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,
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c
index 4b247e91ae5b..cf96eaaf6b4e 100644
--- a/sound/soc/samsung/rx1950_uda1380.c
+++ b/sound/soc/samsung/rx1950_uda1380.c
@@ -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;
- }
-
- 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;
+ 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);
}
- return 0;
-
-err_plat_add:
-err_plat_alloc:
-err_gpio_conf:
- gpio_free(S3C2410_GPA(1));
+ hp_jack_gpios[0].gpiod_dev = dev;
+ rx1950_asoc.dev = dev;
-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");
--
2.20.0
next prev parent reply other threads:[~2019-10-10 20:44 UTC|newest]
Thread overview: 135+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 20:28 [PATCH 00/36] ARM: samsung platform cleanup Arnd Bergmann
2019-10-10 20:28 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 01/36] ARM: samsung: make S3C24XX_MISCCR access indirect Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 02/36] ARM: s3c: simplify mach/io.h Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 03/36] usb: gadget: s3c: use platform resources Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 10:06 ` Krzysztof Kozlowski
2019-10-23 12:46 ` Krzysztof Kozlowski
2019-10-23 13:26 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 04/36] usb: gadget: s3c-hsudc: remove platform header dependency Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 10:09 ` Krzysztof Kozlowski
2019-10-23 12:21 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 05/36] ARM: samsung: make pm-debug platform independent Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 10:27 ` Krzysztof Kozlowski
2019-10-23 12:13 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 06/36] ARM: samsung: move CONFIG_DEBUG_S3C_UART to Kconfig.debug Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 10:12 ` Krzysztof Kozlowski
2019-10-23 12:22 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 07/36] ARM: exynos: use private samsung_cpu_id copy Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 10:54 ` Krzysztof Kozlowski
2019-10-23 12:37 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 08/36] ARM: exynos: stop selecting PLAT_SAMSUNG Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-15 14:12 ` Ulf Hansson
2019-10-23 10:57 ` Krzysztof Kozlowski
2019-10-23 12:43 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 09/36] ARM: samsung: move pm check code to drivers/soc Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 11:32 ` Krzysztof Kozlowski
2019-10-23 12:45 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 10/36] ARM: s5pv210: use private pm save/restore Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 11:55 ` Krzysztof Kozlowski
2019-10-23 13:12 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 11/36] ARM: s5pv210: split from plat-samsung Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-11 5:51 ` Uwe Kleine-König
2019-10-11 5:51 ` Uwe Kleine-König
2019-10-22 14:01 ` Arnd Bergmann
2019-10-22 15:53 ` Uwe Kleine-König
2019-10-22 16:20 ` Arnd Bergmann
2019-10-15 14:13 ` Ulf Hansson
2019-10-15 14:23 ` Thierry Reding
2019-10-23 12:14 ` Krzysztof Kozlowski
2019-10-23 13:17 ` Arnd Bergmann
2019-10-23 14:12 ` Krzysztof Kozlowski
2019-10-10 20:29 ` [PATCH 12/36] ARM: s3c64xx: remove mach/hardware.h Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-16 10:09 ` Charles Keepax
2019-10-10 20:29 ` [PATCH 13/36] ARM: s3c: move regs-spi.h into spi driver Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-23 12:32 ` Krzysztof Kozlowski
2019-10-23 13:21 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 14/36] ARM: s3c: move irqchip driver back into platform Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 15/36] ARM: s3c: adc: move header to linux/soc/samsung Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann
2019-10-10 22:20 ` Guenter Roeck
2019-10-10 22:20 ` Guenter Roeck
2019-10-10 22:29 ` Dmitry Torokhov
2019-10-10 22:29 ` Dmitry Torokhov
2019-10-10 22:44 ` Sebastian Reichel
2019-10-10 22:44 ` Sebastian Reichel
2019-10-23 12:37 ` Krzysztof Kozlowski
2019-10-23 13:23 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 16/36] ARM: s3c: move spi fiq handler into platform Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 17/36] ARM: s3c: h1940-audio: turn into platform driver Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 18/36] ARM: s3c: gta02-audio: " Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann [this message]
2019-10-10 20:30 ` [PATCH 19/36] ARM: s3c: rx1950: " Arnd Bergmann
2019-10-10 20:30 ` [PATCH 20/36] ASoC: samsung: s3c2412-i2s: avoid hardcoded S3C2410_PA_IIS Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-11 10:50 ` Mark Brown
2019-10-11 10:50 ` Mark Brown
2019-10-10 20:30 ` [PATCH 21/36] ARM: s3c: move iis pinctrl config into boards Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-23 12:50 ` Krzysztof Kozlowski
2019-10-23 13:29 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 22/36] ARM: s3c: leds: move setpull() calls into board files Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 23/36] ARM: s3c: move s3cmci pinctrl handling " Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-15 14:12 ` Ulf Hansson
2019-10-16 13:12 ` Linus Walleij
2019-10-10 20:30 ` [PATCH 24/36] ARM: s3c: include mach/irqs.h where needed Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 25/36] ARM: s3c: spi: avoid hardcoding fiq number in driver Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 26/36] ARM: s3c: bast: avoid irq_desc array usage Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 27/36] ARM: s3c: fix mmc gpio lookup tables Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 28/36] fbdev: s3c2410fb: remove mach header dependency Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-23 13:13 ` Krzysztof Kozlowski
2019-10-23 13:35 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 29/36] ARM: s3c: cpufreq: split out registers Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 30/36] ARM: s3c: remove cpufreq header dependencies Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-23 13:38 ` Krzysztof Kozlowski
2019-10-23 13:46 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 31/36] ARM: s3c: cpufreq: use global s3c2412_cpufreq_setrefresh Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-23 13:44 ` Krzysztof Kozlowski
2019-10-23 13:57 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 32/36] ARM: s3c: iotiming: make functions static Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 33/36] ARM: s3c: move low-level clk reg access into platform code Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-23 13:49 ` Krzysztof Kozlowski
2019-10-23 13:54 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 34/36] ARM: s3c: stop including mach/hardware.h from mach/io.h Arnd Bergmann
2019-10-10 20:30 ` Arnd Bergmann
2019-10-10 21:02 ` Russell King - ARM Linux admin
2019-10-10 21:02 ` Russell King - ARM Linux admin
2019-10-10 21:53 ` Arnd Bergmann
2019-10-10 21:53 ` Arnd Bergmann
2019-10-15 14:52 ` [PATCH 01/36] ARM: samsung: make S3C24XX_MISCCR access indirect Tomasz Figa
2019-10-10 21:07 ` [PATCH 35/36] ARM: s3c: move into a common directory Arnd Bergmann
2019-10-10 21:07 ` Arnd Bergmann
2019-10-23 14:05 ` Krzysztof Kozlowski
2019-10-10 21:07 ` [PATCH 36/36] ARM: s3c: make headers local if possible Arnd Bergmann
2019-10-10 21:07 ` Arnd Bergmann
2019-10-23 13:10 ` [PATCH 00/36] ARM: samsung platform cleanup Krzysztof Kozlowski
2019-10-23 13:39 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191010203043.1241612-19-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=kgene@kernel.org \
--cc=krzk@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=perex@perex.cz \
--cc=s.nawrocki@samsung.com \
--cc=sbkim73@samsung.com \
--cc=tiwai@suse.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).