From patchwork Wed Nov 25 16:06:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7700871 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BD153BF90C for ; Wed, 25 Nov 2015 16:08:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B52102085D for ; Wed, 25 Nov 2015 16:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABA3A206FB for ; Wed, 25 Nov 2015 16:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752947AbbKYQH6 (ORCPT ); Wed, 25 Nov 2015 11:07:58 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:62860 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752873AbbKYQHy (ORCPT ); Wed, 25 Nov 2015 11:07:54 -0500 Received: from wuerfel.lan. ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0MCfv0-1aB0W22Bne-009Rrm; Wed, 25 Nov 2015 17:07:04 +0100 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Kukjin Kim , Krzysztof Kozlowski , Mark Brown , Vasily Khoruzhick , Charles Keepax , Tomasz Figa , Ben Dooks , linux-samsung-soc@vger.kernel.org, Arnd Bergmann Subject: [PATCH 02/10] ASoC: samsung/smartq: use dynamic registration Date: Wed, 25 Nov 2015 17:06:47 +0100 Message-Id: <1448467615-447097-3-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.1.0.rc2 In-Reply-To: <1448467615-447097-1-git-send-email-arnd@arndb.de> References: <1448467615-447097-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:LqIi3jmgk5hDGXuw1XgFz/8xzreZZEWmh7Qc7+uh6Pk9kVTj3ki 11eJH9GF8YI8ymuEVRN5JAF6BglaTtoxmTRP+UxMEILzSxLdc1Rs0Py6qQWNHsIartztbTP 6GW4mfSTUhyf31TM46CJvP2Q54XJQfOBzUWEX8ZocNZ5xW6Joq4uei4d+VDZiuKLloKd5qU eSQmmul9xjQnV0IBNjSSw== X-UI-Out-Filterresults: notjunk:1; V01:K0:oHqyDkaOh+g=:Hcx13+ncaGPh0Ro8F6qHgH TwQox6SzKQUDCY8IFX4GNsf/WQhDma7swmdZlz1ymxdXRrN/Mw4GolT6vMMUZY/tDjjBEFXYN M3Ej10cl6OHFpp464OlVG34VylDhGT6w7hEEeJEcyQkLj/vUZHT2AsWt4oEh0RQAueMa3lWtq b2l817Gd5QKjvy4BId2M+P8O88z84PVjoCGstcavsM3FB75ZVoYD0Vuc52jzwQDf39OpyqhrZ YhBkrmW5ewv2KpGi8pTuU4V0WQ+QLeFbCtc/rtQEmY4hzXHTn20m13kIN5EqHsMCxu50xGcI6 FdTXNLPpXE8tiHO/K3SHnZOYF5EGTVVNVQtGph7u2uFgUMjCHnDK0OxpaeupT83rm2WWvYtxu M4+l0V5BeqNeXwyqZuQ/KaIqg4PqiHNTjw3S1ZamiSZudeTL3q6sp0QgqmfHMmmAdiZUTl7I1 l56R3W9l+3O4BVMFKXz3om9sTvhltdARPopJQBaEiMGd4z6RxLwTqhAi2zRvj12D8eqd0RV1L l87QHOds7N0ge59jRbEHwbuidl3fIb2mK4Lvi4ahpjvdAAWO9anqMgppvWHkRAf9z6uJpvSkc 0etstJp+nS+titfXKQdUnQi66gQ+LWdWUTPNNt+mHf6KoVQGDHzADpYCZ0fuEuCfIkGCUIqCN CKrGoJ44L8CgrZnpo9amuQX/GNqdOKTduJtICHcudBsJKDKZn5Q+BCgLrgg+C1EQKLHc= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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_simple and register the gpios through the gpiod API. Signed-off-by: Arnd Bergmann Acked-by: Mark Brown Reviewed-by: Krzysztof Kozlowski --- arch/arm/mach-s3c64xx/mach-smartq.c | 13 +++++++ sound/soc/samsung/smartq_wm8987.c | 77 +++++++++++++------------------------ 2 files changed, 40 insertions(+), 50 deletions(-) diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-s3c64xx/mach-smartq.c index acdfb5fac40f..96784e7f894a 100644 --- a/arch/arm/mach-s3c64xx/mach-smartq.c +++ b/arch/arm/mach-s3c64xx/mach-smartq.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -383,6 +384,15 @@ void __init smartq_map_io(void) smartq_lcd_mode_set(); } +static struct gpiod_lookup_table smartq_audio_gpios = { + .dev_id = "smartq-audio", + .table = { + GPIO_LOOKUP("GPL", 12, "headphone detect", 0), + GPIO_LOOKUP("GPK", 12, "amplifiers shutdown", 0), + { }, + }, +}; + void __init smartq_machine_init(void) { s3c_i2c0_set_platdata(NULL); @@ -402,4 +412,7 @@ void __init smartq_machine_init(void) pwm_add_table(smartq_pwm_lookup, ARRAY_SIZE(smartq_pwm_lookup)); platform_add_devices(smartq_devices, ARRAY_SIZE(smartq_devices)); + + gpiod_add_lookup_table(&smartq_audio_gpios); + platform_device_register_simple("smartq-audio", -1, NULL, 0); } diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c index a0fe37fbed9f..c6769b16eb19 100644 --- a/sound/soc/samsung/smartq_wm8987.c +++ b/sound/soc/samsung/smartq_wm8987.c @@ -13,15 +13,12 @@ * */ -#include +#include #include #include #include -#include -#include - #include "i2s.h" #include "../codecs/wm8750.h" @@ -96,7 +93,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, @@ -113,7 +110,9 @@ 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 gpio_desc *gpio = snd_soc_card_get_drvdata(&snd_soc_smartq); + + gpiod_set_value(gpio, SND_SOC_DAPM_EVENT_OFF(event)); return 0; } @@ -199,62 +198,40 @@ 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 gpio_desc *gpio; 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"); - if (ret) { - dev_err(&smartq_snd_device->dev, "Failed to register GPK12\n"); - goto err_unregister_device; + gpio = devm_gpiod_get(&pdev->dev, "amplifiers shutdown", + GPIOD_OUT_HIGH); + if (IS_ERR(gpio)) { + dev_err(&pdev->dev, "Failed to register GPK12\n"); + ret = PTR_ERR(gpio); + goto out; } + snd_soc_card_set_drvdata(&snd_soc_smartq, gpio); - /* 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; - } - - 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 ");