Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2506200rbb; Wed, 28 Feb 2024 04:13:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWNDxaD2cX8ntvjt81ghI8X9Q2D6s69z4Gk7oqa+M7996sB5AbOMXC18mSZ0cucpqTQiVoM8uO8jJhx6nhLUdPvXHc/CQLJsnaxDj8rtQ== X-Google-Smtp-Source: AGHT+IE1GgtN1oqyHxyau25TxzmjZVEvebjiQay8LX8LVZRAC10t7XIr2kkFNE24+d8MzCZgzuFB X-Received: by 2002:a54:4492:0:b0:3c1:3a0c:c1c8 with SMTP id v18-20020a544492000000b003c13a0cc1c8mr4416084oiv.51.1709122380159; Wed, 28 Feb 2024 04:13:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709122380; cv=pass; d=google.com; s=arc-20160816; b=zEbZcvu9iIrfy6uaTvvKfB0xPvAAudJms0CG47z0EHDKK1fATZ1VbmDakpu4m/UHuC Xmsiy+lXin41U9T1JfBpun7LgClU15OAGg/FnL8UsExFuErWBn/C9arMupnXUOKMpPg8 I/SLOu9YYudG26Ut0N+xy0lR73n00EfmsvXIZ+762nX/AuAO6bGYEcbYwbwkT8huLvIA Tk3m5EDM6niuaTDLxLcvAqJwdHcYGrkTO5GFQbEGPUuwraKh94cFDkN+YTSAW0Q9fF5Q Cfwk5PXPCzATtdO509SJaufnfJ3t9FWa97pChI4dlYJUz9ixgeYKRsbkrNij1Bg30MNW 6O4w== 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=7c9tumQQXuG4HieeWpZE+FRQlT5QELiXjdV48vp4z3o=; fh=FEGj322JUxHP58NgFBs9atrc2KpQCnFuCu2ueZtAhdY=; b=OrHpRqR7Fx3PsbH+cTO+dBB4R4h793pukV2dhVL8kSR+kPEsYFHeN7OJhZLMmUvGTg EULpy3Uzp9XUB1DUxtjDyoCqHU229djPOqd1Wq+D1TE7YCKHBXpD8PuFt4DzXMA9Uwww 5wMNaE5A4pv2R+sstnveJ/YxBIE5g+vLMtD0E8TztfRFojoLo7NXJVsbPgi+JHXq7AAJ fCiskVkPlCyaud9F+Qc1ChXyEDqExvUIJKIN8a9ld6vgvvDX57lya0vfz/kWJLiF1Wej YYzeCov5TVwEt9FzUGbdzM3kLmc+3O9/vE3xaS3RoEWmnfg0KRb+gS7Xjx4JV3xqlgp2 ITtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="k/iehBZp"; 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-84902-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bx34-20020a056a02052200b005ce087e004dsi7262928pgb.799.2024.02.28.04.12.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 04:13:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84902-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="k/iehBZp"; 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-84902-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84902-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 231D428CE75 for ; Wed, 28 Feb 2024 11:35:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CB8915CD40; Wed, 28 Feb 2024 11:28:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="k/iehBZp" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 B5BF915A4BA; Wed, 28 Feb 2024 11:28:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709119713; cv=none; b=FtRJn01CCJXh+yZgfE1x1Mxa9SSB+biWGWDNQlyjyYC86pa5lW+tsJuMhL8uw0Q70/XU5WbCIKbmNmXBR93HQQCEg6Z5UZoFQLRyyWZ+Mak2aAGSSs45nbx1Eg9sLCierNoIeWhrxBvCqBcbz9MTbBD6wQfH4hI5raPY3ohsJ1c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709119713; c=relaxed/simple; bh=P+PS9P5cePM2VctJfuVuc5xinmTQv+oenygZVIJyQ+I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nBrvEoKKYhs6prY552QIvG9YYMyt06e4ac4aPavRUIK2NdDan41PFchQX/fru7cGNpOZpCEkikeOVxvGsM7HH8W7q4Ogc2jK/NG1zX3i0WRh4w+bTnPGZO6/YYIMgc+zrgh3HddNlTxgaDfOOFv8JxNb9gPwDPKHXXsSAyV/0BU= 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=k/iehBZp; arc=none smtp.client-ip=217.70.183.201 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 BA1DE1BF203; Wed, 28 Feb 2024 11:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709119709; 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=7c9tumQQXuG4HieeWpZE+FRQlT5QELiXjdV48vp4z3o=; b=k/iehBZporOFOkjyRzIBzHutL0jHTIkX2HF3wMsXMUDCXGPWYoOJpPgmPxTVhcidxY/Ak6 Ju2GfeYXaBaNfnjii+TahW7TfEjhmKAvzBhJPHVJQMbQNtVs8WdhgIZF/wPYMaYINCNtPo HZXvCqXq2xEVWTMCSuzoVTLCiROviRrjPg/K7BimabQnIgzfawdqndMac5gUeuXxcpMYZr hpG0MfmwAozmxgPzbx07LrSSDrpHBeYg2b/vG7k13Jt1WWyZ+msOIfjRUh94rfXxAHbAGv b+BRVh/pM9K0L61U5Ax+UaxSqnRuga+M/jrpRcd4pTxJBSQsfTLcvhEfuInLgA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 28 Feb 2024 12:28:23 +0100 Subject: [PATCH v2 25/30] gpio: nomadik: grab optional reset control and deassert it at probe 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: <20240228-mbly-gpio-v2-25-3ba757474006@bootlin.com> References: <20240228-mbly-gpio-v2-0-3ba757474006@bootlin.com> In-Reply-To: <20240228-mbly-gpio-v2-0-3ba757474006@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.13.0 X-GND-Sasl: theo.lebrun@bootlin.com Fetch a reference to the optional shared reset control and deassert it if it exists. Optional because not all platforms that use this driver have a reset attached to the reset block. Shared because some platforms that use the reset (at least Mobileye EyeQ5) share the reset across banks. Do not keep a reference to the reset control as it is not needed afterwards; the driver does not handle suspend, does not use runtime PM, does not register a remove callback and does not support unbinding from sysfs (made explicit with suppress_bind_attrs). The operation is done in nmk_gpio_populate_chip(). This function is called by either gpio-nomadik or pinctrl-nomadik, whoever comes first. This is here for historic reasons and could probably be removed now; it seems gpio-ranges enforces the ordering to be pinctrl-first. It is not the topic of the present patch however. Signed-off-by: Théo Lebrun --- drivers/gpio/gpio-nomadik.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c index 6adb3c4417d3..c9fd6631e0aa 100644 --- a/drivers/gpio/gpio-nomadik.c +++ b/drivers/gpio/gpio-nomadik.c @@ -509,11 +509,13 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np, { struct nmk_gpio_chip *nmk_chip; struct platform_device *gpio_pdev; + struct reset_control *reset; struct device *gpio_dev; struct gpio_chip *chip; struct clk *clk; void __iomem *base; u32 id, ngpio; + int ret; gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np); if (!gpio_dev) { @@ -572,6 +574,24 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np, clk_prepare(clk); nmk_chip->clk = clk; + reset = devm_reset_control_get_optional_shared(gpio_dev, NULL); + if (IS_ERR(reset)) { + dev_err(&pdev->dev, "failed getting reset control: %ld\n", + PTR_ERR(reset)); + return ERR_CAST(reset); + } + + /* + * Reset might be shared and asserts/deasserts calls are unbalanced. We + * only support sharing this reset with other gpio-nomadik devices that + * use this reset to ensure deassertion at probe. + */ + ret = reset_control_deassert(reset); + if (ret) { + dev_err(&pdev->dev, "failed reset deassert: %d\n", ret); + return ERR_PTR(ret); + } + #ifdef CONFIG_PINCTRL_NOMADIK BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips)); nmk_gpio_chips[id] = nmk_chip; @@ -690,6 +710,7 @@ static struct platform_driver nmk_gpio_driver = { .driver = { .name = "nomadik-gpio", .of_match_table = nmk_gpio_match, + .suppress_bind_attrs = true, }, .probe = nmk_gpio_probe, }; -- 2.44.0