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: 950087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41cPWw2fttz9ryl for ; Fri, 27 Jul 2018 19:57:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726034AbeG0LSX (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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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,