From patchwork Wed Aug 19 10:29:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Hartmann X-Patchwork-Id: 7036781 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1E2979F372 for ; Wed, 19 Aug 2015 10:29:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9CB520425 for ; Wed, 19 Aug 2015 10:29:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2393520511 for ; Wed, 19 Aug 2015 10:29:26 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 70B7226500A; Wed, 19 Aug 2015 12:29:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id BA77C262618; Wed, 19 Aug 2015 12:29:15 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 85C9C264ED4; Wed, 19 Aug 2015 12:29:14 +0200 (CEST) Received: from mail-wi0-f195.google.com (mail-wi0-f195.google.com [209.85.212.195]) by alsa0.perex.cz (Postfix) with ESMTP id 50109260547 for ; Wed, 19 Aug 2015 12:29:09 +0200 (CEST) Received: by wicxr16 with SMTP id xr16so485904wic.2 for ; Wed, 19 Aug 2015 03:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=P3Mqohi6MN5Fia969LRAJS2YPPFMztLa1A1Nre/Jms4=; b=th1sy+KhbXWmdiTiM6TvlR08R9nlqn4OU5lKrD8PGvjeBYVP4SupaPTHNb5C6Rifux KjtkT7PyRheSbvd0r1o5mGs1w1AjoH03YIUkS7Wxtw4/KEXVOIQga6rDnHrdZobI2zIX lY79Kbw8Fvtwf46h1GpGGbA1SpMGnBYHZp79fv5uzRbU0IiqYM/nHqbtJLhcWuX4cjSY 1e5fbZgUirn9vbXfyd3LS2WiSIspe0GsC0IyBcGbl2G64Z/itbLK56xgSXjsLm+de34i 2BhfRqacHB5L1/UoIN2Cj0xR3wjb94yz+ceudnODFxNVoZ9duAl4rnA05cd1LwZ3Hy+/ XYPA== MIME-Version: 1.0 X-Received: by 10.180.103.34 with SMTP id ft2mr51895097wib.62.1439980148686; Wed, 19 Aug 2015 03:29:08 -0700 (PDT) Received: by 10.28.157.75 with HTTP; Wed, 19 Aug 2015 03:29:08 -0700 (PDT) In-Reply-To: References: <20150715081224.GN16517@opensource.wolfsonmicro.com> <20150715091709.GK11162@sirena.org.uk> <20150717085434.GO16517@opensource.wolfsonmicro.com> <20150810081001.GG25225@opensource.wolfsonmicro.com> <20150810083540.GE1540@lahna.fi.intel.com> <20150810140207.GB1541@lahna.fi.intel.com> Date: Wed, 19 Aug 2015 12:29:08 +0200 Message-ID: From: Christian Hartmann To: Mika Westerberg Cc: alsa-devel@alsa-project.org, Pierre-Louis Bossart , Haojian Zhuang , linux-spi@vger.kernel.org, Mark Brown , jarkko.nikula@linux.intel.com, Daniel Mack , Charles Keepax , Robert Jarzmik , dan.carpenter@oracle.com Subject: Re: [alsa-devel] Fwd: [PATCH 1/1] SPI : spi-pxa2xx : fix spi init of WM510205 codec via ACPI (resend) X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Hi >> There is acpi_fwnode_handle() in include/acpi/acpi_bus.h. However, if >> you have Linux device available you should really use devm_gpio_* >> functions instead. ok, after some changes I got it compiled, but there seems another mistake (by me?), it does not find the GPIOs yet. [ 5.851524] sst-acpi 80860F28:00: No matching ASoC machine driver found [ 5.873318] pxa2xx-spi 80860F0E:00: no DMA channels available, using PIO [ 5.877982] pxa2xx-spi 80860F0E:00: registered master spi32766 (dynamic) [ 5.878667] rfkill_gpio BCM2E84:00: GPIO lookup for consumer reset [ 5.878677] rfkill_gpio BCM2E84:00: using ACPI for GPIO lookup [ 5.878683] acpi BCM2E84:00: GPIO: looking up reset-gpios [ 5.878690] acpi BCM2E84:00: GPIO: _DSD returned BCM2E84:00 3 0 0 0 [ 5.878836] rfkill_gpio BCM2E84:00: GPIO lookup for consumer shutdown [ 5.878844] rfkill_gpio BCM2E84:00: using ACPI for GPIO lookup [ 5.878850] acpi BCM2E84:00: GPIO: looking up shutdown-gpios [ 5.878857] acpi BCM2E84:00: GPIO: _DSD returned BCM2E84:00 3 1 0 0 [ 5.884010] spi spi-WM510205:00: 8333333 Hz actual, PIO [ 5.884019] spi spi-WM510205:00: setup mode 0, 8 bits/w, 8000000 Hz max --> 0 [ 5.884102] spi spi-WM510205:00: checking WM510205 with bmp180 [ 5.884108] spi spi-WM510205:00: checking WM510205 with bmp181 [ 5.884113] spi spi-WM510205:00: modalias WM510205 in id_table not found, returns NULL [ 5.884140] arizona spi-WM510205:00: arizona_acpi_get_type(), than via spi_get_device_id(). [ 5.884146] arizona spi-WM510205:00: arizona_acpi_get_type matched [ 5.884151] arizona spi-WM510205:00: using 1 as type for arizona audio codec [ 5.884155] arizona spi-WM510205:00: regmap set to wm5102_spi [ 5.884765] rfkill_gpio BCM2E84:00: BCM2E84:00 device registered. [ 5.884831] rfkill_gpio LNV4752:00: GPIO lookup for consumer reset [ 5.884837] rfkill_gpio LNV4752:00: using ACPI for GPIO lookup [ 5.884843] acpi LNV4752:00: GPIO: looking up reset-gpios [ 5.884850] acpi LNV4752:00: GPIO: _DSD returned LNV4752:00 3 0 0 0 [ 5.884926] rfkill_gpio LNV4752:00: GPIO lookup for consumer shutdown [ 5.884931] rfkill_gpio LNV4752:00: using ACPI for GPIO lookup [ 5.884936] acpi LNV4752:00: GPIO: looking up shutdown-gpios [ 5.884941] acpi LNV4752:00: GPIO: _DSD returned LNV4752:00 3 1 0 0 [ 5.884977] acpi LNV4752:00: GPIO: looking up shutdown-gpio [ 5.884983] acpi LNV4752:00: GPIO: looking up 0 in _CRS [ 5.885019] gpio-411 (reset): gpiod_request: status -16 [ 5.889424] arizona spi-WM510205:00: spi_irq = -1 [ 5.889435] arizona spi-WM510205:00: arizona_spi_probe done, calling arizona_dev_init [ 5.889442] arizona spi-WM510205:00: acpi_dev_add_driver_gpios done, 0 [ 5.889447] arizona spi-WM510205:00: dev_set_drvdata done for 1 [ 5.889774] arizona spi-WM510205:00: GPIO lookup for consumer reset [ 5.889781] arizona spi-WM510205:00: using ACPI for GPIO lookup [ 5.889788] acpi WM510205:00: GPIO: looking up reset-gpios [ 5.889794] acpi WM510205:00: GPIO: looking up reset-gpio [ 5.889798] acpi WM510205:00: GPIO: looking up 0 in _CRS [ 5.891255] arizona spi-WM510205:00: GPIO lookup for consumer ldoena [ 5.891263] arizona spi-WM510205:00: using ACPI for GPIO lookup [ 5.891269] acpi WM510205:00: GPIO: looking up ldoena-gpios [ 5.891274] acpi WM510205:00: GPIO: looking up ldoena-gpio [ 5.891279] acpi WM510205:00: GPIO: looking up 0 in _CRS [ 5.891324] gpio-342 (reset): gpiod_request: status -16 [ 5.891330] arizona spi-WM510205:00: Failed to get ldoena line: -16 [ 5.891335] acpi WM510205:00: GPIO: looking up 0 in _CRS [ 5.891409] arizona spi-WM510205:00: arizona_of_get_core_pdata (ACPI) using irq_gpio GPIO = 146 [ 5.891415] arizona spi-WM510205:00: arizona_of_get_core_pdata (ACPI) using ldoena GPIO = 23 [ 5.891421] arizona spi-WM510205:00: arizona_of_get_core_pdata (ACPI) using reset GPIO = -184850384 [ 5.891425] arizona spi-WM510205:00: arizona_of_get_core_pdata for 1 [ 5.891430] arizona spi-WM510205:00: regcache_cache_only for 1 set [ 5.891434] arizona spi-WM510205:00: added wm5102_core_supplies for 1 [ 5.894845] rfkill_gpio: probe of LNV4752:00 failed with error -16 [ 5.906587] LDO1: Failed to request enable GPIO23: -517 [ 5.906673] arizona spi-WM510205:00: Failed to register LDO1 supply: -517 [ 5.923633] spi-WM510205:00 supply AVDD not found, using dummy regulator [ 5.923687] spi-WM510205:00 supply DBVDD1 not found, using dummy regulator [ 5.923718] spi-WM510205:00 supply DCVDD not found, using dummy regulator [ 5.923751] ------------[ cut here ]------------ [ 5.923763] WARNING: CPU: 2 PID: 474 at drivers/gpio/gpiolib.c:86 gpio_to_desc+0xbb/0xd0() in arizona-spi I try to map these GPIOs, which I want to get in arizona-core: arizona_dev_init #endif @@ -812,6 +840,70 @@ EXPORT_SYMBOL_GPL(arizona_of_match); #else static inline int arizona_of_get_core_pdata(struct arizona *arizona) { + struct arizona_pdata *pdata = &arizona->pdata; + struct gpio_desc *reset, *ldoena; + int ret; + + switch (arizona->type) { + case WM5102: + /* TODO: + * get the actual GPIO pins from ACPI namespace + * instead of hardcoding it here + pdata->reset = 0x03 ; + pdata->ldoena = 0x17 ; + */ + + reset = devm_gpiod_get_optional(arizona->dev, + "reset", + GPIOD_OUT_LOW); + if (IS_ERR(reset)) { + ret = PTR_ERR(reset); + dev_err(arizona->dev, "Failed to get reset line: %d\n", ret); + pdata->reset = 0x03 ; + /* + *return ret; + */ + } else { + pdata->reset = (int )reset; + } + + ldoena = devm_gpiod_get_optional(arizona->dev, + "ldoena", + GPIOD_OUT_LOW); + if (IS_ERR(ldoena)) { + ret = PTR_ERR(ldoena); + dev_err(arizona->dev, "Failed to get ldoena line: %d\n", ret); + pdata->ldoena = 0x17 ; + /* + * return ret; + */ + } else { + pdata->ldoena = (int )ldoena; + } + + pdata->irq_flags = IRQF_TRIGGER_RISING| + IRQF_TRIGGER_FALLING; + + /* get the ACPI GpioInt ressource for this device + * + */ + if (ACPI_COMPANION(arizona->dev)) { + pdata->irq_gpio = acpi_dev_gpio_irq_get(ACPI_COMPANION(arizona->dev), 0); + } else { + pdata->irq_gpio = 0x04 ; + } + + dev_err(arizona->dev, "arizona_of_get_core_pdata (ACPI) using irq_gpio GPIO = %i\n", + pdata->irq_gpio); + dev_err(arizona->dev, "arizona_of_get_core_pdata (ACPI) using ldoena GPIO = %i\n", + pdata->ldoena); + dev_err(arizona->dev, "arizona_of_get_core_pdata (ACPI) using reset GPIO = %i\n", + pdata->reset); + break; + default: + break; + } + so far, this are the most important and current testing changes. Does anybody has some ideas or hints about how to get the annoying GPIOs ldoena and reset ? cheers chris diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c index 1e845f6..52872a0 100644 --- a/drivers/mfd/arizona-spi.c +++ b/drivers/mfd/arizona-spi.c @@ -18,28 +18,58 @@ #include #include #include +#include #include #include "arizona.h" +const struct acpi_gpio_params reset_gpio = { 1, 0, false}; +const struct acpi_gpio_params ldoena_gpio = { 2, 0, false}; + +const struct acpi_gpio_mapping arizona_acpi_gpios[] = { + { "reset_gpio", &reset_gpio, 1,}, + { "ldoena_gpio", &ldoena_gpio, 1}, + { }, +}; static int arizona_spi_probe(struct spi_device *spi) { - const struct spi_device_id *id = spi_get_device_id(spi); + const struct spi_device_id *id; struct arizona *arizona; + struct acpi_device *adev; const struct regmap_config *regmap_config; unsigned long type; + acpi_handle handle; int ret; if (spi->dev.of_node) type = arizona_of_get_type(&spi->dev); - else - type = id->driver_data; + else { + dev_err(&spi->dev, "arizona_acpi_get_type(), than via spi_get_device_id().\n"); + if (( type = arizona_acpi_get_type(&spi->dev))) { + } else { + id = spi_get_device_id(spi) ; + if (!id || !id->driver_data) + return -ENODEV; + dev_err(&spi->dev, "matched spi\n"); + type = id->driver_data; + } + } + + + /* check if type is NULL before going on + */ + if (!type) { + dev_err(&spi->dev, "type is NULL, unable to get the id / type of this device\n"); + return -ENODEV; + } else + dev_err(&spi->dev, "using %lu as type for arizona audio codec\n",type); switch (type) { #ifdef CONFIG_MFD_WM5102 case WM5102: regmap_config = &wm5102_spi_regmap; + dev_err(&spi->dev, "regmap set to wm5102_spi \n"); break; #endif #ifdef CONFIG_MFD_WM5110 @@ -66,10 +96,32 @@ static int arizona_spi_probe(struct spi_device *spi) return ret; } - arizona->type = id->driver_data; + /* + * take the id if it is an spi id, or take the acpi id + * the case that it has no id and no acpi_id is yet open (yes the + * openfirmare interface introducted by apple) + */ + arizona->type = type; + arizona->dev = &spi->dev; arizona->irq = spi->irq; + dev_err(&spi->dev, "spi_irq = %i \n",spi->irq); + dev_err(&spi->dev, "arizona_spi_probe done, calling arizona_dev_init \n"); + +#ifdef CONFIG_ACPI + /* + *arizona->dev.fwnode = acpi_fwnode_handle(adev); + */ + handle = ACPI_HANDLE(&spi->dev); + if (!handle || acpi_bus_get_device(handle, &adev)) { + dev_err(&spi->dev, "unable to get ACPI handle\n"); + return -ENODEV; + } + ret = acpi_dev_add_driver_gpios(adev, arizona_acpi_gpios); + dev_err(&spi->dev, "acpi_dev_add_driver_gpios done, %i\n",ret); + +#endif return arizona_dev_init(arizona); } @@ -90,12 +142,22 @@ static const struct spi_device_id arizona_spi_ids[] = { }; MODULE_DEVICE_TABLE(spi, arizona_spi_ids); +static const struct acpi_device_id arizona_acpi_match[] = { + { + .id = "WM510205", + .driver_data = WM5102, + }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, arizona_acpi_match); + static struct spi_driver arizona_spi_driver = { .driver = { .name = "arizona", .owner = THIS_MODULE, .pm = &arizona_pm_ops, .of_match_table = of_match_ptr(arizona_of_match), + .acpi_match_table = ACPI_PTR(arizona_acpi_match), }, .probe = arizona_spi_probe, .remove = arizona_spi_remove, diff --git a/drivers/mfd/arizona.h b/drivers/mfd/arizona.h index fbe2843..ba9e9bc 100644 --- a/drivers/mfd/arizona.h +++ b/drivers/mfd/arizona.h @@ -55,4 +55,14 @@ static inline unsigned long arizona_of_get_type(struct device *dev) } #endif +#ifdef CONFIG_ACPI +#include +unsigned long arizona_acpi_get_type(struct device *dev); + +extern const struct acpi_gpio_params reset_gpio; +extern const struct acpi_gpio_params ldoena_gpio; + +extern const struct acpi_gpio_mapping arizona_acpi_gpios[]; +#endif +