From patchwork Sun Mar 29 21:20:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 6117861 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 182DEBF4A6 for ; Sun, 29 Mar 2015 21:23:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FA0C20263 for ; Sun, 29 Mar 2015 21:23:23 +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 EFB662025A for ; Sun, 29 Mar 2015 21:23:21 +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 1YcKdY-0003Qh-7X; Sun, 29 Mar 2015 21:20:52 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YcKdW-0003Kk-CC for linux-arm-kernel@lists.infradead.org; Sun, 29 Mar 2015 21:20:50 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1YcKcy-0008HF-2T; Sun, 29 Mar 2015 23:20:16 +0200 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1YcKcw-0005Wy-HJ; Sun, 29 Mar 2015 23:20:14 +0200 From: Markus Pargmann To: Linus Walleij Subject: [PATCH] pinctrl: imx: Allow parsing DT without function nodes Date: Sun, 29 Mar 2015 23:20:04 +0200 Message-Id: <1427664004-21056-1-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 2.1.4 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150329_142050_636134_8DA798F0 X-CRM114-Status: GOOD ( 18.29 ) X-Spam-Score: -0.0 (/) Cc: Fabio Estevam , Stefan Agner , Shawn Guo , kernel@pengutronix.de, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Markus Pargmann , 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 The old format to define pinctrl settings for imx in DT has two hierarchy levels. The first level are function device nodes. The second level are pingroups which contain a property fsl,pins. The original intention was to define all pin functions in a single dtsi file and just reference the correct ones in the board files. This idea was rejected some time ago leading to the current design to have all the pinfunctions defined in the board files. So we don't need the function device nodes anymore. This patch changes the pinctrl driver to accept devicetrees which do not have the first hierarchy level, function device nodes. For example karo-tx25 already has such a devicetree. Old devicetrees are still parsed and supported. Signed-off-by: Markus Pargmann --- drivers/pinctrl/freescale/pinctrl-imx.c | 41 +++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index 448f10986c28..4f1b0e4ff361 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -610,14 +610,29 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev, struct device_node *child; u32 nfuncs = 0; u32 i = 0; + bool flat_funcs = false; if (!np) return -ENODEV; - nfuncs = of_get_child_count(np); - if (nfuncs <= 0) { - dev_err(&pdev->dev, "no functions defined\n"); - return -EINVAL; + /* + * Check if the DT contains pins in the direct child nodes. This + * indicates the newer DT format to store pins. The old format with + * function devicenodes which contain group nodes which contain + * fsl,pins is still parsed if flat_funcs is false. + */ + child = of_get_next_child(np, NULL); + if (child) + flat_funcs = of_property_read_bool(child, "fsl,pins"); + + if (flat_funcs) { + nfuncs = 1; + } else { + nfuncs = of_get_child_count(np); + if (nfuncs <= 0) { + dev_err(&pdev->dev, "no functions defined\n"); + return -EINVAL; + } } info->nfunctions = nfuncs; @@ -626,16 +641,24 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev, if (!info->functions) return -ENOMEM; - info->ngroups = 0; - for_each_child_of_node(np, child) - info->ngroups += of_get_child_count(child); + if (flat_funcs) { + info->ngroups = of_get_child_count(np); + } else { + info->ngroups = 0; + for_each_child_of_node(np, child) + info->ngroups += of_get_child_count(child); + } info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct imx_pin_group), GFP_KERNEL); if (!info->groups) return -ENOMEM; - for_each_child_of_node(np, child) - imx_pinctrl_parse_functions(child, info, i++); + if (flat_funcs) { + imx_pinctrl_parse_functions(np, info, 0); + } else { + for_each_child_of_node(np, child) + imx_pinctrl_parse_functions(child, info, i++); + } return 0; }