Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp533153rdb; Tue, 23 Jan 2024 07:07:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFz4vGWJEk0/dCmE4RWzJ2YFUQcUq0Mzm5aKloipGWrLCfVal3XR11Rtfg0yIX1piSusSPL X-Received: by 2002:aa7:de0a:0:b0:55a:e43e:7063 with SMTP id h10-20020aa7de0a000000b0055ae43e7063mr948774edv.8.1706022457540; Tue, 23 Jan 2024 07:07:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706022457; cv=pass; d=google.com; s=arc-20160816; b=sBcbEl/ETZVackf4PvjvWQWU6uRVXtCaY0TasVh/z1RT30LV9IEBHLTYWhiwoYXGad 7bopH3dG8svdrOpqi39rmTFkPMg3P9H8WlZhteYOPR6VVIxtoOJUxPFkXgvxLq9EMaP4 I12KZFyPCDQQwwMkuIcMrsPLYFQEunYNMgsLDlg/drVgVP5tWssITRGG76uKmJgw19ZG 4Tj8FL8tgbSA/Fif/lprNOxOTeTaBJ57XCucTuQkTszShycE7yP9PREsaiJYxJtE6gD/ hWax8ikayvan7yb7SJxvyaO0cswAVsFteoELqeoJthkuNN/2vL4bBXzlcVOtm2pVeZNC ysHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id; bh=dROrPcpY+/hK/XNeWvYA4dNpky3uvuWRDdG0/B412dw=; fh=xRzS6+55PGLFXGC460wxGzSXKpYa7lB1cNtDooOjqvY=; b=JlwvF1LbtQe2Znqz43TZjpcrYD0tT63tL7a2cdvxP+oqxDe8a5mOLhT4P9wmEfaC6c DrVhRTNG4fYct0MJ9t6R5/ikcDrg1WvuQTeBuOHPkzLeeUsu6VVg7D6SNX0WAmB7SwCK UGrKH+1gl98tcVqGUmpO6UJnyNWu9KX0cC8u9sMUjS7axZys3Crj+uWNj1Lt7vhEPbOY 4yiV8Ecvr+owVw0Hq5K9lMEXTle11Eatfsi4EhFkn3/PmQfCB1wRgFm2zlKxWK3YkPR5 HrMSzLS1GJ5u7baUFI9p5lVagUpyM/uQ+v173lzgOqE7Ee2UeYxr3mVCAMrjZPLioyjJ LJ/w== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-35503-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35503-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i1-20020a05640242c100b005590583beb1si10767357edc.501.2024.01.23.07.07.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 07:07:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35503-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-35503-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35503-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 511171F27F3A for ; Tue, 23 Jan 2024 15:07:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52C065FBA9; Tue, 23 Jan 2024 15:07:15 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 694225FB9F for ; Tue, 23 Jan 2024 15:07:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706022434; cv=none; b=t3ixlIp+p0Sbh/msmMI8iP9r0eX5rJr22Uh1VrMeaCflXAnzHGXefsnQNCQZQCyln4Uq2RY9abTeSxEJTH2vfH3d2wjDkawJUMGFhTrogZcG0pvXdMmiTilRsrNj5RDR5eaNfxIWLpIp9tjnA5gILyHjd57acujMx8/qn2n04Cg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706022434; c=relaxed/simple; bh=b0nsHC1LlsVf82gw0OcuACEz8HSMsfQcxZCNzRl/XfU=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=DXzbrjAOeUnhzLXevoEfHLIknaFSkz1BFhhmPeaez/BfkWU8L90T9YxNceBm7qMP3VKrwffT55hIBgcsFyAnI8/qRrrG4/LgPYhUSCjKO7bWxGP8/fqXE711t8+qi2aiRNmrV5AgOvZG+TqICPjmz6H0iwOGUHiyzwjp9PRsCPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rSIMU-0001Fo-Gh; Tue, 23 Jan 2024 16:06:50 +0100 Received: from [2a0a:edc0:0:900:1d::4e] (helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSIMR-001rL1-Fx; Tue, 23 Jan 2024 16:06:47 +0100 Received: from pza by lupine with local (Exim 4.96) (envelope-from ) id 1rSIMR-000Ab1-1K; Tue, 23 Jan 2024 16:06:47 +0100 Message-ID: Subject: Re: [PATCH v4 4/6] reset: Instantiate reset GPIO controller for shared reset-gpios From: Philipp Zabel To: Krzysztof Kozlowski , Bjorn Andersson , Konrad Dybcio , Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , Jaroslav Kysela , Takashi Iwai , linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Bartosz Golaszewski , Chris Packham , Sean Anderson Date: Tue, 23 Jan 2024 16:06:47 +0100 In-Reply-To: <20240123141311.220505-5-krzysztof.kozlowski@linaro.org> References: <20240123141311.220505-1-krzysztof.kozlowski@linaro.org> <20240123141311.220505-5-krzysztof.kozlowski@linaro.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org On Di, 2024-01-23 at 15:13 +0100, Krzysztof Kozlowski wrote: > Devices sharing a reset GPIO could use the reset framework for > coordinated handling of that shared GPIO line. We have several cases of > such needs, at least for Devicetree-based platforms. >=20 > If Devicetree-based device requests a reset line, while "resets" > Devicetree property is missing but there is a "reset-gpios" one, > instantiate a new "reset-gpio" platform device which will handle such > reset line. This allows seamless handling of such shared reset-gpios > without need of changing Devicetree binding [1]. >=20 > To avoid creating multiple "reset-gpio" platform devices, store the > Devicetree "reset-gpios" GPIO specifiers used for new devices on a > linked list. Later such Devicetree GPIO specifier (phandle to GPIO > controller, GPIO number and GPIO flags) is used to check if reset > controller for given GPIO was already registered. >=20 > If two devices have conflicting "reset-gpios" property, e.g. with > different ACTIVE_xxx flags, this would allow to spawn two separate > "reset-gpio" devices, where the second would fail probing on busy GPIO > request. >=20 > Link: https://lore.kernel.org/all/YXi5CUCEi7YmNxXM@robh.at.kernel.org/ [1= ] > Cc: Bartosz Golaszewski > Cc: Chris Packham > Cc: Sean Anderson > Signed-off-by: Krzysztof Kozlowski I'm nearly out of complaints, two tiny cosmetic issues remaining: [...] > diff --git a/drivers/reset/core.c b/drivers/reset/core.c > index 4d5a78d3c085..6e81b8d35055 100644 > --- a/drivers/reset/core.c > +++ b/drivers/reset/core.c [...] > @@ -813,12 +838,161 @@ static void __reset_control_put_internal(struct re= set_control *rstc) > kref_put(&rstc->refcnt, __reset_control_release); > } > =20 > +static int __reset_add_reset_gpio_lookup(int id, struct device_node *np, > + unsigned int gpio, > + unsigned int of_flags) > +{ > + unsigned int lookup_flags; > + const char *label_tmp; > + > + /* > + * Later we map GPIO flags between OF and Linux, however not all > + * constants from include/dt-bindings/gpio/gpio.h and > + * include/linux/gpio/machine.h match each other. > + */ > + if (of_flags > GPIO_ACTIVE_LOW) { > + pr_err("reset-gpio code does not support GPIO flags %u for GPIO %u\n", > + of_flags, gpio); Alignment to parenthesis is slightly off. > + return -EINVAL; > + } > + > + struct gpio_device *gdev __free(gpio_device_put) =3D gpio_device_find_b= y_fwnode(of_fwnode_handle(np)); Adding a local fwnode variable would make this fit in the 100 character limit again. regards Philipp