From patchwork Tue Feb 5 19:48:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 14566 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E733423E92 for ; Tue, 5 Feb 2013 19:49:24 +0000 (UTC) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by fiordland.canonical.com (Postfix) with ESMTP id 8CC4DA1883C for ; Tue, 5 Feb 2013 19:49:24 +0000 (UTC) Received: by mail-ve0-f170.google.com with SMTP id 14so462190vea.29 for ; Tue, 05 Feb 2013 11:49:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type:x-gm-message-state; bh=qSeBmZ+REzVzHxVTZD0AcekDGAFN3YFZnD0TPF1BnEI=; b=e5IRMOSdYstnozQ5FISrx0mxsl+PeNz3qRz8QpMlcFTzc6LM80yjPhZOlUxDQ/+chj 21tEug/f1lgkRbl+F9B/OMkI96XMEKPGuyUuvp83XrcQCSEbdEju40FQJLaAhZ9Acrui lbRJKFx3J5Z2OVc2AhKGVzwrJ7gXlUrnAtOsXpKHvuX+gScWwWtxAUR71znnKG8euvgM zzL4JIk49vjuJ+OhnzyibSRF9jlV0j6GQH66A65VQ0puy1Hu8/c+buwYnR+36MYVqZ/1 QSh8GXHaEWWqCztxhMWaYus3SGALktiwbaIUxSyaTk7lpoIBsRHHSUVjAUxULEiHT9Vj OTvw== X-Received: by 10.220.219.77 with SMTP id ht13mr28828041vcb.66.1360093764094; Tue, 05 Feb 2013 11:49:24 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp143962vec; Tue, 5 Feb 2013 11:49:23 -0800 (PST) X-Received: by 10.14.219.6 with SMTP id l6mr46977524eep.23.1360093762717; Tue, 05 Feb 2013 11:49:22 -0800 (PST) Received: from eu1sys200aog114.obsmtp.com (eu1sys200aog114.obsmtp.com [207.126.144.137]) by mx.google.com with SMTP id f3si36974778eep.35.2013.02.05.11.49.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Feb 2013 11:49:22 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.137; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob114.postini.com ([207.126.147.11]) with SMTP ID DSNKURFiOvXTKCEqpf870ZyowH+9zn+jSREd@postini.com; Tue, 05 Feb 2013 19:49:21 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 02D67B3; Tue, 5 Feb 2013 19:41:01 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id EFC0CD42; Tue, 5 Feb 2013 19:49:10 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id C650CA8072; Tue, 5 Feb 2013 20:49:02 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 5 Feb 2013 20:49:09 +0100 From: Linus Walleij To: , Cc: Stephen Warren , Anmar Oueja , Lee Jones , Linus Walleij Subject: [PATCH 10/14] pinctrl/abx500: add Device Tree support Date: Tue, 5 Feb 2013 20:48:31 +0100 Message-ID: <1360093715-6348-11-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1360093715-6348-1-git-send-email-linus.walleij@stericsson.com> References: <1360093715-6348-1-git-send-email-linus.walleij@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkMPAzbwvgEAHEBj/XJ4KF/ltPyVGnLLgKExK5ViX66epZUHOWhUsstMOpnXnX7EyDRGhJF From: Lee Jones This patch will allow the ABX500 Pinctrl driver to be probed when Device Tree is enabled with an appropriate node contained. Signed-off-by: Lee Jones Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-abx500.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c index a0d324b..20f94cf 100644 --- a/drivers/pinctrl/pinctrl-abx500.c +++ b/drivers/pinctrl/pinctrl-abx500.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -825,22 +827,44 @@ static int abx500_get_gpio_num(struct abx500_pinctrl_soc_data *soc) return npins; } +static const struct of_device_id abx500_gpio_match[] = { + { .compatible = "stericsson,ab8500-gpio", .data = (void *)PINCTRL_AB8500, }, + { .compatible = "stericsson,ab8505-gpio", .data = (void *)PINCTRL_AB8505, }, + { .compatible = "stericsson,ab8540-gpio", .data = (void *)PINCTRL_AB8540, }, + { .compatible = "stericsson,ab9540-gpio", .data = (void *)PINCTRL_AB9540, }, +}; + static int abx500_gpio_probe(struct platform_device *pdev) { struct ab8500_platform_data *abx500_pdata = dev_get_platdata(pdev->dev.parent); - struct abx500_gpio_platform_data *pdata; + struct abx500_gpio_platform_data *pdata = NULL; + struct device_node *np = pdev->dev.of_node; struct abx500_pinctrl *pct; const struct platform_device_id *platid = platform_get_device_id(pdev); + unsigned int id = -1; int ret, err; int i; - pdata = abx500_pdata->gpio; + if (abx500_pdata) + pdata = abx500_pdata->gpio; if (!pdata) { - dev_err(&pdev->dev, "gpio platform data missing\n"); - return -ENODEV; + if (np) { + const struct of_device_id *match; + + match = of_match_device(abx500_gpio_match, &pdev->dev); + if (!match) + return -ENODEV; + id = (unsigned long)match->data; + } else { + dev_err(&pdev->dev, "gpio dt and platform data missing\n"); + return -ENODEV; + } } + if (platid) + id = platid->driver_data; + pct = devm_kzalloc(&pdev->dev, sizeof(struct abx500_pinctrl), GFP_KERNEL); if (pct == NULL) { @@ -854,12 +878,13 @@ static int abx500_gpio_probe(struct platform_device *pdev) pct->chip = abx500gpio_chip; pct->chip.dev = &pdev->dev; pct->chip.base = pdata->gpio_base; + pct->chip.base = (np) ? -1 : pdata->gpio_base; /* initialize the lock */ mutex_init(&pct->lock); /* Poke in other ASIC variants here */ - switch (platid->driver_data) { + switch (id) { case PINCTRL_AB8500: abx500_pinctrl_ab8500_init(&pct->soc); break; @@ -966,6 +991,7 @@ static struct platform_driver abx500_gpio_driver = { .driver = { .name = "abx500-gpio", .owner = THIS_MODULE, + .of_match_table = abx500_gpio_match, }, .probe = abx500_gpio_probe, .remove = abx500_gpio_remove,