From patchwork Tue Mar 18 16:26:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Dubois-Briand X-Patchwork-Id: 14021303 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 1A122211710; Tue, 18 Mar 2025 16:26:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742315217; cv=none; b=FOg8iP9q4Gmj0n24A3aG1licnFrbKW50gz+M2g8jBwPbnbol/Fmku2ShTsmF9DQBbEzu0E1dVG5rVMbEX0WnZWL6I84b+DgFI+yUjjx4jguHYd8FGPmjCtCqxtQGNYhbfvuqO3vIUiy68mo+SfwtksAivDiDFEFH7jjGIWZT750= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742315217; c=relaxed/simple; bh=v6yZqwygkCeRgnLn5U9TxR/CNMNGKJwXCTzt0j/DZM4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n4yoMYmCnBHlupQlZ0NSrXrRLYCMaJROH5dVXqmL8pHJ8pEL3D2gQaYrijr+KvV6hXKGlzVuEPauPvjSz/C9xW90zgnnfX7nxIVpcaqx385ZO46m5afPFt1O1/QIpNFKVqo8zzraEPf8M/XiVuD6LbS2N/i1Nv2xMv43wM9iJpw= 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=krbl+oLC; arc=none smtp.client-ip=217.70.183.198 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="krbl+oLC" Received: by mail.gandi.net (Postfix) with ESMTPSA id 917AF442BC; Tue, 18 Mar 2025 16:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1742315213; 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=oCRVmZQ5zL8pptF5J9xwaFL3evg8oQt49nQmaXiWeZk=; b=krbl+oLCYx5nWyMujfLxyAyBg+283j9MubUu5A3ddpb2LUlI16D45v+norg5Zp/BbWj6eT HgDhS/FsniMtIukcHY8JId3S2sSuYiSCLLqHLJRZGUyQ5lgt/ov7BKLQwKQa/nt7znCLwZ dapsnLr8gqc3z0zR/uFx1d95YQ1EoxTNB5v0JNDJbeKTRQNB1oabAeYyNShlBOxJHaBkHk 7LT6kdXOVL19zCHx/fQc0f1Rj+p3jjI3Te+plp9my+aHd6bxJjpacmyhqzEGJHVAj8kK1J ip6Nza6CmNey+Y7Pwa2iYEpn08o6dN3VtYSjggNTfC2PfhlAbJVT5HCN2luozw== From: Mathieu Dubois-Briand Date: Tue, 18 Mar 2025 17:26:23 +0100 Subject: [PATCH v5 07/11] gpio: regmap: Allow to provide init_valid_mask callback Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250318-mdb-max7360-support-v5-7-fb20baf97da0@bootlin.com> References: <20250318-mdb-max7360-support-v5-0-fb20baf97da0@bootlin.com> In-Reply-To: <20250318-mdb-max7360-support-v5-0-fb20baf97da0@bootlin.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kamel Bouhara , Linus Walleij , Bartosz Golaszewski , Dmitry Torokhov , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Michael Walle , Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-input@vger.kernel.org, linux-pwm@vger.kernel.org, andriy.shevchenko@intel.com, =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Mathieu Dubois-Briand X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1742315204; l=2141; i=mathieu.dubois-briand@bootlin.com; s=20241219; h=from:subject:message-id; bh=v6yZqwygkCeRgnLn5U9TxR/CNMNGKJwXCTzt0j/DZM4=; b=qv1/8i7rKJB1wuVZ1o4ZSmAthSpXKo8WsfIygUtKU1LorZ/n8K13TmRa+Vw5GlkwmVATSVKAy KuIUKVZltPPDNxKEes4EAGo9d0/TovhfQDsD1zq2B83XQEGlNfQ8NEd X-Developer-Key: i=mathieu.dubois-briand@bootlin.com; a=ed25519; pk=1PVTmzPXfKvDwcPUzG0aqdGoKZJA3b9s+3DqRlm0Lww= X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddugedvledvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrthhhihgvuhcuffhusghoihhsqdeurhhirghnugcuoehmrghthhhivghurdguuhgsohhishdqsghrihgrnhgusegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpedthfegtedvvdehjeeiheehheeuteejleektdefheehgfefgeelhfetgedttdfhteenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmeeffhgtfhemfhgstdgumeduvdeivdemvdgvjeeinecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvdgrtddumegtsgdugeemheehieemjegrtddtmeeffhgtfhemfhgstdgumeduvdeivdemvdgvjeeipdhhvghloheplgduvdejrddtrddurddungdpmhgrihhlfhhrohhmpehmrghthhhivghurdguuhgsohhishdqsghrihgrnhgusegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvfedprhgtphhtthhopehlihhnuhigqdhinhhpuhhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrkhhrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhesk hgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhgrthhhihgvuhdrughusghoihhsqdgsrhhirghnugessghoohhtlhhinhdrtghomhdprhgtphhtthhopehukhhlvghinhgvkheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepkhgrmhgvlhdrsghouhhhrghrrgessghoohhtlhhinhdrtghomhdprhgtphhtthhopehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhrghdprhgtphhtthhopehmfigrlhhlvgeskhgvrhhnvghlrdhorhhg X-GND-Sasl: mathieu.dubois-briand@bootlin.com Allows to populate the gpio_regmap_config structure with init_valid_mask() callback to set on the final gpio_chip structure. Signed-off-by: Mathieu Dubois-Briand Reviewed-by: Michael Walle --- drivers/gpio/gpio-regmap.c | 3 +-- include/linux/gpio/regmap.h | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index 61d5f48b445d..4c66a90bbbf1 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -262,9 +262,8 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config chip->names = config->names; chip->label = config->label ?: dev_name(config->parent); chip->can_sleep = regmap_might_sleep(config->regmap); + chip->init_valid_mask = config->init_valid_mask; - chip->request = gpiochip_generic_request; - chip->free = gpiochip_generic_free; chip->get = gpio_regmap_get; if (gpio->reg_set_base && gpio->reg_clr_base) chip->set = gpio_regmap_set_with_clear; diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h index 55df2527b982..c14bf65d22e9 100644 --- a/include/linux/gpio/regmap.h +++ b/include/linux/gpio/regmap.h @@ -6,6 +6,7 @@ struct device; struct fwnode_handle; struct gpio_regmap; +struct gpio_chip; struct irq_domain; struct regmap; @@ -40,6 +41,8 @@ struct regmap; * @drvdata: (Optional) Pointer to driver specific data which is * not used by gpio-remap but is provided "as is" to the * driver callback(s). + * @init_valid_mask: (Optional) Routine to initialize @valid_mask, to be used + * if not all GPIOs are valid. * @regmap_irq_chip: (Optional) Pointer on an regmap_irq_chip structure. If * set, a regmap-irq device will be created and the IRQ * domain will be set accordingly. @@ -97,6 +100,10 @@ struct gpio_regmap_config { unsigned int offset, unsigned int *reg, unsigned int *mask); + int (*init_valid_mask)(struct gpio_chip *gc, + unsigned long *valid_mask, + unsigned int ngpios); + void *drvdata; };