From patchwork Fri Jul 11 13:45:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 4533891 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 913C6BEEAA for ; Fri, 11 Jul 2014 13:48:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A65AA20107 for ; Fri, 11 Jul 2014 13:48:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ACE2A20173 for ; Fri, 11 Jul 2014 13:48:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X5bA7-0006by-Of; Fri, 11 Jul 2014 13:46:55 +0000 Received: from mout.kundenserver.de ([212.227.17.13]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X5b9N-0005vq-US for linux-arm-kernel@lists.infradead.org; Fri, 11 Jul 2014 13:46:11 +0000 Received: from wuerfel.lan. (HSI-KBW-134-3-133-35.hsi14.kabel-badenwuerttemberg.de [134.3.133.35]) by mrelayeu.kundenserver.de (node=mreue103) with ESMTP (Nemesis) id 0Lyk6B-1WYefY0tCp-0169lp; Fri, 11 Jul 2014 15:45:27 +0200 From: Arnd Bergmann To: alsa-devel@alsa-project.org Subject: [PATCH 2/4] ASoC: samsung/smartq: use dynamic registration Date: Fri, 11 Jul 2014 15:45:06 +0200 Message-Id: <1405086308-1461192-5-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1405086308-1461192-1-git-send-email-arnd@arndb.de> References: <1405086308-1461192-1-git-send-email-arnd@arndb.de> X-Provags-ID: V02:K0:aNHOZ+aG0RT5Gw41RIbCQlMuQfhTzfxx66ig2C/pBSw mcoa8Xv/zw7VULW+g5mhgbFh4gRa8Dha93hN2iWyNKaHLOvnFI juKzxwvMtaVY3D2AlvcCPnsGc1THkW42bxDRrOLgB5Gle80svD 5FZ55iaKhkMi8fAprlQc0l0G8/9ZvOg+2GmvDMfSyvG3Nka+0N J1xEyojhjVsof0w6oPAwCcvaMVMd7fXLxFOZsd8n7h6GIxhc2j YMQED1c2JrCbzFIxFzQU5hCQb0ReUzHTv7jwLwKX4Nsl0+gxP1 wFlB0/T/JpvafWN84e/wIF4ybUWToKxGGgBuoJiBzZCyCgEXRf Kx4CGYWlD5cGU+PIvZHMhu3CEErYdYniumEtrZK6x X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140711_064610_387309_53597100 X-CRM114-Status: GOOD ( 19.81 ) X-Spam-Score: -0.7 (/) Cc: Kukjin Kim , Arnd Bergmann , t.figa@samsung.com, Maurus Cuelenaere , lgirdwood@gmail.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As a prerequisite for moving s3c64xx into multiplatform configurations, we need to change the smartq audio driver to stop using hardcoded gpio numbers from the header file, and instead pass the gpio data through platform_data. In order to do that, we also move the code to use module_platform_driver and register the platform device using platform_device_register_data. Signed-off-by: Arnd Bergmann Cc: Maurus Cuelenaere Cc: Kukjin Kim --- arch/arm/mach-s3c64xx/mach-smartq.c | 10 ++++ include/linux/platform_data/asoc-s3c-smartq.h | 10 ++++ sound/soc/samsung/smartq_wm8987.c | 73 ++++++++++----------------- 3 files changed, 47 insertions(+), 46 deletions(-) create mode 100644 include/linux/platform_data/asoc-s3c-smartq.h diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-s3c64xx/mach-smartq.c index b3d13537a7f0..4c111f60dbf2 100644 --- a/arch/arm/mach-s3c64xx/mach-smartq.c +++ b/arch/arm/mach-s3c64xx/mach-smartq.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -379,6 +380,11 @@ void __init smartq_map_io(void) smartq_lcd_mode_set(); } +static const __initconst struct smartq_audio_pdata smartq_audio_pdata = { + .gpio_jack = S3C64XX_GPL(12), + .gpio_amp = S3C64XX_GPK(12), +}; + void __init smartq_machine_init(void) { s3c_i2c0_set_platdata(NULL); @@ -397,4 +403,8 @@ void __init smartq_machine_init(void) WARN_ON(smartq_wifi_init()); platform_add_devices(smartq_devices, ARRAY_SIZE(smartq_devices)); + + platform_device_register_data(NULL, "smartq-audio", -1, + &smartq_audio_pdata, + sizeof (smartq_audio_pdata)); } diff --git a/include/linux/platform_data/asoc-s3c-smartq.h b/include/linux/platform_data/asoc-s3c-smartq.h new file mode 100644 index 000000000000..5bddc3586802 --- /dev/null +++ b/include/linux/platform_data/asoc-s3c-smartq.h @@ -0,0 +1,10 @@ +#ifndef __PLATFORM_DATA_ASOC_S3C_SMARTQ +#define __PLATFORM_DATA_ASOC_S3C_SMARTQ + +struct smartq_audio_pdata { + int gpio_jack; + int gpio_amp; +}; + +#endif + diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c index 9b0ffacab790..8c4a0a285ce7 100644 --- a/sound/soc/samsung/smartq_wm8987.c +++ b/sound/soc/samsung/smartq_wm8987.c @@ -19,8 +19,7 @@ #include #include -#include -#include +#include #include "i2s.h" #include "../codecs/wm8750.h" @@ -110,7 +109,7 @@ static struct snd_soc_jack_pin smartq_jack_pins[] = { static struct snd_soc_jack_gpio smartq_jack_gpios[] = { { - .gpio = S3C64XX_GPL(12), + .gpio = -1, .name = "headphone detect", .report = SND_JACK_HEADPHONE, .debounce_time = 200, @@ -127,7 +126,10 @@ static int smartq_speaker_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - gpio_set_value(S3C64XX_GPK(12), SND_SOC_DAPM_EVENT_OFF(event)); + struct smartq_audio_pdata *pdata; + pdata = snd_soc_smartq.dev->platform_data; + + gpio_set_value(pdata->gpio_amp, SND_SOC_DAPM_EVENT_OFF(event)); return 0; } @@ -218,62 +220,41 @@ static struct snd_soc_card snd_soc_smartq = { .num_controls = ARRAY_SIZE(wm8987_smartq_controls), }; -static struct platform_device *smartq_snd_device; - -static int __init smartq_init(void) +static int smartq_probe(struct platform_device *pdev) { + struct smartq_audio_pdata *pdata = pdev->dev.platform_data; int ret; - if (!machine_is_smartq7() && !machine_is_smartq5()) { - pr_info("Only SmartQ is supported by this ASoC driver\n"); - return -ENODEV; - } - - smartq_snd_device = platform_device_alloc("soc-audio", -1); - if (!smartq_snd_device) - return -ENOMEM; - - platform_set_drvdata(smartq_snd_device, &snd_soc_smartq); - - ret = platform_device_add(smartq_snd_device); - if (ret) { - platform_device_put(smartq_snd_device); - return ret; - } + platform_set_drvdata(pdev, &snd_soc_smartq); /* Initialise GPIOs used by amplifiers */ - ret = gpio_request(S3C64XX_GPK(12), "amplifiers shutdown"); + ret = devm_gpio_request_one(&pdev->dev, pdata->gpio_amp, + GPIOF_DIR_OUT | GPIOF_INIT_HIGH, + "amplifiers shutdown"); if (ret) { - dev_err(&smartq_snd_device->dev, "Failed to register GPK12\n"); - goto err_unregister_device; + dev_err(&pdev->dev, "Failed to register GPK12\n"); + goto out; } - /* Disable amplifiers */ - ret = gpio_direction_output(S3C64XX_GPK(12), 1); - if (ret) { - dev_err(&smartq_snd_device->dev, "Failed to configure GPK12\n"); - goto err_free_gpio_amp_shut; - } + smartq_jack_gpios[0].gpio = pdata->gpio_jack; - return 0; - -err_free_gpio_amp_shut: - gpio_free(S3C64XX_GPK(12)); -err_unregister_device: - platform_device_unregister(smartq_snd_device); + ret = devm_snd_soc_register_card(&pdev->dev, &snd_soc_smartq); + if (ret) + dev_err(&pdev->dev, "Failed to register card\n"); +out: return ret; } -static void __exit smartq_exit(void) -{ - gpio_free(S3C64XX_GPK(12)); - - platform_device_unregister(smartq_snd_device); -} +static struct platform_driver smartq_driver = { + .driver = { + .name = "smartq-audio", + .owner = THIS_MODULE, + }, + .probe = smartq_probe, +}; -module_init(smartq_init); -module_exit(smartq_exit); +module_platform_driver(smartq_driver); /* Module information */ MODULE_AUTHOR("Maurus Cuelenaere ");