Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp686798rdh; Wed, 14 Feb 2024 08:28:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUIoOlUO1CIIYQMQQGP0WA2TTwiuJdWoGiZP5yH+TEUkHudK+APdCJHoEsUHyTCPLOuJKNf0q3yHb//F6FsO/aK2wVM3RKkZp/driLFXQ== X-Google-Smtp-Source: AGHT+IHG+OS7dcTnlgjebvsH+wzODRM0+qOhtGbqIdIi9+iizSCBK5Lx+tN2LXXF8JvGWh+bflW6 X-Received: by 2002:a0c:f546:0:b0:68e:ee98:298c with SMTP id p6-20020a0cf546000000b0068eee98298cmr2451660qvm.65.1707928114094; Wed, 14 Feb 2024 08:28:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707928114; cv=pass; d=google.com; s=arc-20160816; b=jo0t1wq/aUpzzI8yqWCVKkP7qt+Q2x/V6FmWHn5iRbDobrDWYOC/KtmZQQVivNAmut TXyeDrzwp1FDbh0NTETvXfziSLTHEHINB4nsSviSZC4ju0bX1GsIWLDOPOPFq4CIjk2Q Ub6Sg9JRHZ0BqyWxWotoqGY15mTe6N/MKBLw7VjjM7YCdyV83eln5L4rjWOia3sNIvUo TaDjaAsC2lhj/9uxfx5M75whlUprt/LnYeqKbhYirkeJt44NUKB4aCFOWOqFuWMkTAEb XJNeT748Wme+fxktAvOqkfCe+jNQd2+yrzR0q/RQRfR3m3TSu7D8rDl7o1ebBNGNWw6p k0TQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=fLUHnKwkOTd/IZBZWn2NU/F1aOSU/MFfTb5Afq/ZxpU=; fh=zewLBm7pKUnFS4y2LrQhKYUBAaD12jGRiIt/WT3qB6A=; b=qe6kZHUWIMtcL3DTAUOLbdrMfN71ECTpgeUvdHjtRkFehXN5ZWufT1n/7ja2iaS+Oa r+z8nYhYm67BYsJWzgUploLS+I/tcC2W2m8Kp2RwGQ/hZmx7NQPz0gf7khYQ85aCzvrK /HIXC1d8F3Mjc/BKbtMnOpDpQElZkjOt29+JiKfypO7yfuLU14n8ZPnI66d3MNJ4xYRE 0ViDhjnrK4U5xHP3a+bLQDNgWndPdtb7I5MY2wtimv/BnJUr81iqMHVZZaH7jCTt7dYK xrsnGStinK+nRZ6U3h1jNmQNk3fwuFgSIXpgTtSsZ9CFJM2eGIhp1YmeNwTPFH7tTxsG G1rA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KDUEmIGK; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-65527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=2; AJvYcCUjtdQDHYSUNqiW6Xyw6AJBR5haTuYSE9uZcCjCtE5vgfSIcgiRcaqeaBcBbJCiJQGZD6SODIh1LqlUnH9r8xYIW7jo3uADTY8LDzGxyg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 11-20020a0562140d6b00b0068cbcdea333si5527477qvs.308.2024.02.14.08.28.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 08:28:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KDUEmIGK; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-65527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D6A1A1C214EC for ; Wed, 14 Feb 2024 16:28:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 275B864CE9; Wed, 14 Feb 2024 16:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KDUEmIGK" Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFAC560BA5; Wed, 14 Feb 2024 16:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707927901; cv=none; b=PJcVnfevy9IEouJffrpevQ+9Uxv7QqlNKuG7dM7K2wGJc5SsDCgzX071/6VVy9TXmmGm+xpDniMgg9Orf5Xkptt0wWxW0td4GgbwpU4agwLS/Q8XHKpQBpED49GZBDqghferw+Dtnl1qJ28GtAaU7+Zp71wiNojUMQvUNGm67Gs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707927901; c=relaxed/simple; bh=4p/q1upzUmGBHDVdiIWRLWepvE6bL1nLmhXsDRF2978=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SHzVJXe441Aq+iytLdXatINFad5RwzVztdHThIUVGPZrMurisRvxkU11mrRvR5Mym6Fh/wPWyarLa0TQ1o30V/vwAcouNqmtL37W4lGivxlHaaMV4A2zkSH2YVPHG5Y+lueeVgZesHfEz0ZzIQX8xbkqJEkhmrSVPTv4Pnbl/EQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KDUEmIGK; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id A1E0A6000A; Wed, 14 Feb 2024 16:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707927897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fLUHnKwkOTd/IZBZWn2NU/F1aOSU/MFfTb5Afq/ZxpU=; b=KDUEmIGKKiQDc+J8thUyJZBerQLKaPdgsNZr7DehO3Rhy5toF0HOTW1YOrn6nNzpcrwGN/ oj9RuY99yzMjMvxcyvxgwWqUSoMKptuu7bduNmiuGAKVM3Re4ZOny3YU5b7NB7W9gzzeuw k33u0eePU0RATJdE7JonqNNPXucIs6ejOm2U5fUcEKFFyXpmn2mkZ7pFCrSMmvW9idAeWz Y2T2Yi72fUlewtLa4z06hJwGuJawSbt7RnZ6Gy41wxK5FFHsjRHDzjBJgWivUbu/U3FBz7 x4txLn3YXqhc6ep62U95osgQi7VjQ9VItfL/Y0bpXCrB4T0eMFp3RSWp5dOnZQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 14 Feb 2024 17:24:10 +0100 Subject: [PATCH 17/23] gpio: nomadik: handle variadic GPIO count Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240214-mbly-gpio-v1-17-f88c0ccf372b@bootlin.com> References: <20240214-mbly-gpio-v1-0-f88c0ccf372b@bootlin.com> In-Reply-To: <20240214-mbly-gpio-v1-0-f88c0ccf372b@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Thomas Bogendoerfer Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, Gregory CLEMENT , Vladimir Kondratiev , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com Read the "ngpios" device-tree property to determine the number of GPIOs for a bank. If not available, fallback to NMK_GPIO_PER_CHIP ie 32 ie the current behavior. The IP block always supports 32 GPIOs, but platforms can expose a lesser amount. The Mobileye EyeQ5 is in this case; one bank is 29 GPIOs and the other is 23. Signed-off-by: Théo Lebrun --- drivers/gpio/gpio-nomadik.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c index 5b1e3b3efcff..02b53c58adf7 100644 --- a/drivers/gpio/gpio-nomadik.c +++ b/drivers/gpio/gpio-nomadik.c @@ -490,7 +490,7 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np, struct resource *res; struct clk *clk; void __iomem *base; - u32 id; + u32 id, ngpio; gpio_pdev = of_find_device_by_node(np); if (!gpio_pdev) { @@ -518,10 +518,15 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np, return ERR_PTR(-ENOMEM); } + if (of_property_read_u32(np, "ngpios", &ngpio)) { + ngpio = NMK_GPIO_PER_CHIP; + dev_dbg(&pdev->dev, "populate: using default ngpio (%d)\n", ngpio); + } + nmk_chip->bank = id; chip = &nmk_chip->chip; chip->base = -1; - chip->ngpio = NMK_GPIO_PER_CHIP; + chip->ngpio = ngpio; chip->label = dev_name(&gpio_pdev->dev); chip->parent = &gpio_pdev->dev; -- 2.43.1