Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp217470rdd; Tue, 9 Jan 2024 01:41:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6b9/abaJgQHZPoD07CRmjmWEZIyV9Wl92az/2vwYm7BxkCnWS9QoSWVT0/YB97gdJ4Qth X-Received: by 2002:ac2:4882:0:b0:50e:3fc6:ef3a with SMTP id x2-20020ac24882000000b0050e3fc6ef3amr1635060lfc.63.1704793297834; Tue, 09 Jan 2024 01:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704793297; cv=none; d=google.com; s=arc-20160816; b=zBMzIlKTHjSv3zPgSWvZ40DzOIOx6XeDYNBcTZYNMp57j96gtwZ2/lNCSTDZ+5I8/e HHW+myQJfFWogq0nU9QCTSORtgXVcKKcWlSp9ryLdc5HQf/qhVupFcjI7wr4IraBVQha VCaBWKjnDBfpdgVOqg1F4qZJIf7imx3rIIkDi8cUmbCSjAzyvuJKVSTcKaNCSReU6dxy moNYc5ynA+soHV5uF/G0o15aePz0H+x4n9kT2Hz9x9aiueq9PmDQwHcNY7N6jFgp39ZL W002O5DDCfUfYn0QYmMVJnJhWprkOWjJZXpjZmyk991zGoQ2TzQFA+N2ed+0pCbaObtz pKpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=0zJ90jY4oWOFnJfno88cKUg2qN1kQaJOunAzUnYwuCg=; fh=kzBalgiJZiZWa5x9WDnR5CVa4SyBU5kPLGpTzDpsgZ0=; b=xFgvsMZ9FlRxXUJ0IE3lo/wSL8YbE3R3Bp3rgFeA4m7Ik0BIyV99a/PXPxA/K8cBqj PnguAC50gho7FVPdR9U7zsEOgZDSBCScFfai/vPFDj5EU+AxMrakK1X7U6HQICHrzs3l L0vUaEqIBVh4kEVlzl9S7Ga+2yotl827UhDdWSJ+2TxvU8T22qrAlAAKOV/e8vf6KxLK KEOmyQSWY1RmzlnAUCfo3ZHusqcWoAVvGuRzHrHy4i26nsFeAiGwyRlWqvwt20m7vXOS sx0UPDBWPd4VaAfmCwXZLyDViW8o9oaYD/P/iiNQzP2aF3+eab0+sLLLQKWa7pD+aPJ+ U0sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i9NFCJQn; spf=pass (google.com: domain of linux-kernel+bounces-20677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id di15-20020a056402318f00b005552514e1f1si639378edb.38.2024.01.09.01.41.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:41:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i9NFCJQn; spf=pass (google.com: domain of linux-kernel+bounces-20677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 66A981F273C6 for ; Tue, 9 Jan 2024 09:41:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E064358AD; Tue, 9 Jan 2024 09:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="i9NFCJQn" Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 884021E520 for ; Tue, 9 Jan 2024 09:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-55770379ed4so2620702a12.3 for ; Tue, 09 Jan 2024 01:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704793283; x=1705398083; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=0zJ90jY4oWOFnJfno88cKUg2qN1kQaJOunAzUnYwuCg=; b=i9NFCJQn6S07uI7AnZU5xS0VlJ1TEA/+9V8r6nlklZO5X7zRnLGadjXgdzSxMbh//H ZVLDqF0m9jdHY8ruXyCdnxzw7Y26MiFaJ/WEsXVXEuzHe7YCemZuqc+2t36rzqRwIa0s tl7Bjko93l9yxgwLUbVNre5Yz3kU0/TBK9rn+QmObF2J7Ant1clkQeqJRzuvV54vSinB sA3vAbOeK7yio5vPHWeaunv4TqQyPdvl3LhS/WVUvCZHt4IJAb+RkRz/3PlJFmz06Kp2 TTb/5+IUcpJrD8NAzLuE1JsNzQIFTDtXHKI0mJhGQUCGvhk++nCVSguyDLI71JAXn1/9 BuoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704793283; x=1705398083; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0zJ90jY4oWOFnJfno88cKUg2qN1kQaJOunAzUnYwuCg=; b=TOzm7QvSecyWE+wCMVHTTxZzDG/ZdlLkNEFWhtfHhTVqaQ3Lat5d2N/UIPoLvYnLMo ZUZBZJHdgkEY+pvE11YG3lT5mGxePDBxCl6mt2ViTPyvFK8sbRrtm0/Og0Wo8FH0K/B9 F2nsDUbGxljnGnWnyD0sqmrebXfPTNdyIBN/wFXVMKEfceaqm1vZuNA8sGO8y1yQ2R0y tLLxUlcdSgsVn5olQo6AxGPiIehfbn1iUp+ITL6Dv8OZ4k0MU6L1WFHQg0/Pm4h2c1Nn W+LXZPN3/a3iEStwnKvAVMWxCGkJUON1xvGU4BxWsANiEhEcIr2DP8FmapsSPEP5enqF 3NZg== X-Gm-Message-State: AOJu0Yyg6gGEmJxEtiilA3Sw79md8of6Y++m/4f1yIudRWcjSlF0tOhr OSSS4DUxjDStPutNPga94sgz+/HFPqNv6Q== X-Received: by 2002:aa7:c98d:0:b0:54c:4837:7583 with SMTP id c13-20020aa7c98d000000b0054c48377583mr2408092edt.47.1704793282802; Tue, 09 Jan 2024 01:41:22 -0800 (PST) Received: from [192.168.1.20] ([178.197.223.112]) by smtp.gmail.com with ESMTPSA id bf13-20020a0564021a4d00b00557aa8d72c9sm752094edb.25.2024.01.09.01.41.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jan 2024 01:41:22 -0800 (PST) Message-ID: <93a89a11-fac1-49b3-92aa-1a4fd4bdd5b3@linaro.org> Date: Tue, 9 Jan 2024 10:41:20 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] reset: add GPIO-based reset controller Content-Language: en-US To: Philipp Zabel , Sean Anderson , Bjorn Andersson , Konrad Dybcio , Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , 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 Cc: Bartosz Golaszewski References: <20231222150133.732662-1-krzysztof.kozlowski@linaro.org> <20231222150133.732662-3-krzysztof.kozlowski@linaro.org> <530e3473-eb3b-477c-8599-e7aa12779640@seco.com> <88bd6668-7e67-42c7-97b6-d7029f371349@linaro.org> <075990bb-5fdb-4d30-9484-9df6b978e805@seco.com> <2be19fbf-4c73-4594-be42-31587dc7b747@seco.com> From: Krzysztof Kozlowski Autocrypt: addr=krzysztof.kozlowski@linaro.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5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HAcUF35hSJrvMJzPT/+u /oVmYDFZkbLlqs2XpWaVCo2jv8+iHxZZ9FL7F6AHFzqEFdqGnJQqmEApiRqH6b4jRBOgJ+cY qc+rJggwMQcJL9F+oDm3wX47nr6jIsEB5ZftdybIzpMZ5V9v45lUwmdnMrSzZVgC4jRGXzsU EViBQt2CopXtHtYfPAO5nAkIvKSNp3jmGxZw4aTc5xoAZBLo0OV+Ezo71pg3AYvq0a3/oGRG KQ06ztUMRrj8eVtpImjsWCd0bDWRaaR4vqhCHvAG9iWXZu4qh3ipie2Y0oSJygcZT7H3UZxq fyYKiqEmRuqsvv6dcbblD8ZLkz1EVZL6djImH5zc5x8qpVxlA0A0i23v5QvN00m6G9NFF0Le D2GYIS41Kv4Isx2dEFh+/Q== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 05/01/2024 15:31, Philipp Zabel wrote: >>>> Sorry, then I don't get what you refer to. The driver calls deassert >>>> when it is safe for it to do it, so the driver *knows*. Now, you claim >>>> that driver does not know that... core also does not know, so no one knows. >>> >>> Yes! That is the problem with this design. Someone has to coordinate the >>> reset, and it can't be the driver. But the core also doesn't have enough >>> information. So no one can do it. >> >> The point is that the driver coordinates. > > Currently the reset controller API supports two types of shared resets. > I hope distinguishing the two types and illustrating them helps the > discussion: > > 1) For devices that just require the reset to be deasserted while they > are active, and don't care otherwise, there is the clk-like behavior > described in [1]. > > requested reset signal via reset_control_deassert/assert(): > device A: ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ > device B: ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ > > actual reset signal to both devices: > ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ > > In this scenario, there should be no delays in the reset controller > driver. reset_control_deassert() may return as soon as the physical > reset signal is deasserted [2]. Any post-deassert delays required by > the devices are handled in the device drivers, and they can be > different for each device. The devices have to be able to cope with a > (much) longer post-deassert delay than expected (e.g. device B in this > case). It is assumed that the reset signal is initially asserted. > > The reset-gpio patchset supports this. Yep! :) > > 2) The second type is for devices that require a single reset pulse for > initialization, at any time before they become active. This is > described in [3]. > > requested reset signal via reset_control_reset/rearm(): > device A: ⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽ > device B: ⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽ > > actual reset signal to both devices: > ⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽ > > Here the reset controller needs to know the delay between assertion and > deassertion - either baked into the hardware or as a delay call in the > .reset callback. > > This is not supported by the reset-gpio patchset. It could be Yep, as well. > implemented via a delay property in the device tree that would have to > be the same for all devices sharing the reset line, and by adding the Or through dedicated node to which reset-gpio binds, just like in Sean's code some years ago. Nothing stops achieving that, except of course convincing Rob. The point is that although my design does not solve it, it also does not prevent it in the future. > .reset callback to the reset controller driver. The only issue is that > the initial state of the reset line should be deasserted, and at > reset_control_get() time, when the reset-gpio controller is > instantiated, it is not yet known which type the driver will use. > > Sharing a reset line between devices of different type is not > supported. Unfortunately, this will only fail at > reset_control_deassert() / reset_control_reset() time when the second > device tries to use the reset control in a different way than the > first. > > [1] https://docs.kernel.org/driver-api/reset.html#assertion-and-deassertion > [2] https://docs.kernel.org/driver-api/reset.html#c.reset_control_deassert > [3] https://docs.kernel.org/driver-api/reset.html#triggering > >>> For example, say we want to share a reset GPIO between two devices. Each >>> device has the following constraints: >>> >>> device post-assert delay post-deassert delay >>> ====== ================= =================== >>> A 500us 1ms >>> B 1ms 300us >> >> And now imagine that these values are incompatible between them, so >> using 1ms on device A is wrong - too long. >> >> This is just not doable. You invented some imaginary case to prove that >> hardware is broken. >> >> Now, if we are back to realistic cases - use just the longest reset time. > > Right. This all only works if no device has an upper bound to the > allowed delays on the shared reset line. If device had an upper bound, it would be quite a conflicting design, tricky to implement. I don't think we should target such case with generic solution. > > I interpret the post-assert delay to be the desired length of the reset > pulse between the rising edge and the falling edge in case 2) above, > since in case 1) a post-assert delay is not useful. > > The post-deassert delays are not supposed to be handled by the reset > controller drivers at all, except where they are needed to reach the > deasserted state on the reset line. Reset drivers that do have post- > deassert delays in the .deassert callback might be bending the rules a > bit for convenience. Best regards, Krzysztof