From patchwork Fri Jul 27 09:51:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 10546821 X-Patchwork-Delegate: geert@linux-m68k.org 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 B2B6E180E for ; Fri, 27 Jul 2018 09:57:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A19A42863F for ; Fri, 27 Jul 2018 09:57:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 953812B4BC; Fri, 27 Jul 2018 09:57:16 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24A952863F for ; Fri, 27 Jul 2018 09:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730318AbeG0LSX (ORCPT ); Fri, 27 Jul 2018 07:18:23 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:53904 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729560AbeG0LSX (ORCPT ); Fri, 27 Jul 2018 07:18:23 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie3.idc.renesas.com with ESMTP; 27 Jul 2018 18:57:13 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 95EC1731CF; Fri, 27 Jul 2018 18:57:13 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.51,408,1526310000"; d="scan'208";a="286554701" Received: from unknown (HELO be1yocto.ree.adwin.renesas.com) ([172.29.43.62]) by relmlii1.idc.renesas.com with ESMTP; 27 Jul 2018 18:57:11 +0900 From: Biju Das To: Linus Walleij Cc: Biju Das , linux-gpio@vger.kernel.org, Simon Horman , Geert Uytterhoeven , Chris Paterson , Fabrizio Castro , linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/4] gpio: rcar: Enhance gpio-ranges support Date: Fri, 27 Jul 2018 10:51:26 +0100 Message-Id: <1532685089-35645-2-git-send-email-biju.das@bp.renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532685089-35645-1-git-send-email-biju.das@bp.renesas.com> References: <1532685089-35645-1-git-send-email-biju.das@bp.renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enhance gpio-ranges to support more than one gpio-range. Signed-off-by: Biju Das Reviewed-by: Fabrizio Castro --- cat /sys/kernel/debug/pinctrl/e6060000.pin-controller-sh-pfc/gpio- GPIO ranges handled: 0: e6050000.gpio GPIOS [1001 - 1023] PINS [0 - 22] 0: e6051000.gpio GPIOS [978 - 1000] PINS [32 - 54] 0: e6052000.gpio GPIOS [946 - 977] PINS [64 - 95] 0: e6053000.gpio GPIOS [926 - 942] PINS [96 - 112] 17: e6053000.gpio GPIOS [943 - 945] PINS [123 - 125] 0: e6054000.gpio GPIOS [900 - 925] PINS [128 - 153] 0: e6055000.gpio GPIOS [868 - 899] PINS [160 - 191] --- drivers/gpio/gpio-rcar.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 350390c..a7bbe78 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -399,13 +399,22 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) struct device_node *np = p->pdev->dev.of_node; const struct gpio_rcar_info *info; struct of_phandle_args args; - int ret; + int index = 0, ret; info = of_device_get_match_data(&p->pdev->dev); - ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args); - *npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK; p->has_both_edge_trigger = info->has_both_edge_trigger; + *npins = 0; + for (;; index++) { + ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, + index, &args); + if (ret) { + if (index == 0) + *npins = RCAR_MAX_GPIO_PER_BANK; + break; + } + *npins += args.args[2]; + } if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) { dev_warn(&p->pdev->dev,