From patchwork Wed Apr 24 08:08:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien DESSENNE X-Patchwork-Id: 10914321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8D441515 for ; Wed, 24 Apr 2019 08:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95B86289F4 for ; Wed, 24 Apr 2019 08:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8910428A0D; Wed, 24 Apr 2019 08:09:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D7CBD289F4 for ; Wed, 24 Apr 2019 08:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+3adMzP/Q+ReuJPQK+Vy/wOVg2gheDPh0h+8jba11SU=; b=okAchCy25ud2as M8uRHf4Lrn3gu241CCASv2gXdbHaMca4rRF26F/wnJbXC62h+YRpL/EImwGffOmTXohv1aBU6Gab7 29PT0u286ODPB40cXU3aJ6DV2W3wQcByMcBIa4ryKJd/8V8TRo+wuhPoAJINJS8fGY4Q7/XW7M34Y k/GIbcaD4K1nRLg4eK65aDLctQ7TdjtD6ikJJu+4eb8nSy/w6ULmEeA0bWVSuuMiDR7nqD5NucXUE JRhqwBhRh1NCGKUvhiIwteuU0R9DU0BkY6R0Rk4eWYJGn7/LGJBl0H8k2J1XSSioETlbHczD/RNrq rbyw6RKL6EyHhv3+QiQw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJCxo-00065h-WF; Wed, 24 Apr 2019 08:09:09 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJCxl-00064t-H7 for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2019 08:09:07 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3O86etE026280; Wed, 24 Apr 2019 10:08:57 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=gWhmMJfG4KCKGsbfm55+Bl3jiOH6AJEwnEp7zdS68zg=; b=ySogtWNZxpSiI9dOW7zUhAeM7zDWryiHYdNdwu0Sg/C9C9UFYLh5nVaQofDwjeN3j/Zi GC8s4RbNGyyzXb9jlaGpM2JVKuU4EMT1D/jblDj1TuDmY+8V8Ov0dDEVxOBHGmNhbhWf C7x14fTtBAauN3q6tblKgq+d3aeeV/+ALCObQNHlPNRLe2/MmGZtRzuAF7jhDgF57pNA cX+6J3tMgurBn09nzqQsBUtz7YKudLkcvCl+N/PdJEb5dIWamE+UNgM1Zyvc7i1/UbEj uj6dmwB5Xo39537kD/iyUZLX8kfL4kHFUXxs/vvFyrP4oHYKLNT/2G88hd75CfQQlbvl UQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2ryrvxc55a-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 24 Apr 2019 10:08:57 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C4F0B31; Wed, 24 Apr 2019 08:08:55 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 997211409; Wed, 24 Apr 2019 08:08:55 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 24 Apr 2019 10:08:55 +0200 Received: from localhost (10.201.23.25) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 24 Apr 2019 10:08:54 +0200 From: Fabien Dessenne To: Linus Walleij , Maxime Coquelin , Alexandre Torgue , Benjamin Gaignard , , , , Subject: [PATCH] pinctrl: stm32: check irq controller availability at probe Date: Wed, 24 Apr 2019 10:08:44 +0200 Message-ID: <1556093324-1008-1-git-send-email-fabien.dessenne@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.201.23.25] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-24_05:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190424_010906_022338_35AFF912 X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabien Dessenne Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It is not guaranteed that the IRQ controller driver is probed before the pin controller driver gets probed. Considering this, check for the irq domain availability during probe and return EPROBE_DEFER if needed. Signed-off-by: Fabien Dessenne Acked-by: Alexandre TORGUE --- drivers/pinctrl/stm32/pinctrl-stm32.c | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index 0aebc31..2317ccf 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -1122,23 +1122,35 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, return 0; } +static struct irq_domain *stm32_pctrl_get_irq_domain(struct device_node *np) +{ + struct device_node *parent; + struct irq_domain *domain; + + if (!of_find_property(np, "interrupt-parent", NULL)) + return NULL; + + parent = of_irq_find_parent(np); + if (!parent) + return ERR_PTR(-ENXIO); + + domain = irq_find_host(parent); + if (!domain) + /* domain not registered yet */ + return ERR_PTR(-EPROBE_DEFER); + + return domain; +} + static int stm32_pctrl_dt_setup_irq(struct platform_device *pdev, struct stm32_pinctrl *pctl) { - struct device_node *np = pdev->dev.of_node, *parent; + struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; struct regmap *rm; int offset, ret, i; int mask, mask_width; - parent = of_irq_find_parent(np); - if (!parent) - return -ENXIO; - - pctl->domain = irq_find_host(parent); - if (!pctl->domain) - return -ENXIO; - pctl->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); if (IS_ERR(pctl->regmap)) return PTR_ERR(pctl->regmap); @@ -1264,6 +1276,11 @@ int stm32_pctl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pctl); + /* check for IRQ controller (may require deferred probe) */ + pctl->domain = stm32_pctrl_get_irq_domain(np); + if (IS_ERR(pctl->domain)) + return PTR_ERR(pctl->domain); + /* hwspinlock is optional */ hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0); if (hwlock_id < 0) { @@ -1294,7 +1311,7 @@ int stm32_pctl_probe(struct platform_device *pdev) return -EINVAL; } - if (of_find_property(np, "interrupt-parent", NULL)) { + if (pctl->domain) { ret = stm32_pctrl_dt_setup_irq(pdev, pctl); if (ret) return ret;