From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73201C54FCB for ; Fri, 24 Apr 2020 15:36:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48CAD2087E for ; Fri, 24 Apr 2020 15:36:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="yhZCD7Qw"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VLGeO82e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728381AbgDXPgC (ORCPT ); Fri, 24 Apr 2020 11:36:02 -0400 Received: from wnew2-smtp.messagingengine.com ([64.147.123.27]:55889 "EHLO wnew2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728340AbgDXPf4 (ORCPT ); Fri, 24 Apr 2020 11:35:56 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 4188B78A; Fri, 24 Apr 2020 11:35:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 24 Apr 2020 11:35:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=RAyogzkukKZAd i7S8yBa6C6J+CTNVLFaPMJKvTHa5P4=; b=yhZCD7QwzRo929MJQo2eKzY6/OOJE Uv52BA1a/pFnCyTnOBLfX4i2h9n3D/I1tAWDksFwyr8tx00W3lCKVYb4nKQlCJ3Y OIKW1/VTBsb4+yr0HBVx+l5fxmn1gYzMAaSwXD81r2UTuIKwt6styluBdVyH84z9 L4r/RdUoQJ8ecx655K7Y00LcDfzhxCW5C1Bt27I1Rk6xd8Wj/Tu0jTgbXbfkHwhC M5kyXIZQ/aar3CsuJtyi2TtN+eutvF38QWyXxEqDhVcd0vSQ/N5PZfAXvMZ53Msj ucqiRa7CRGUqubgdTB2rsJflX8IAVFvZt1R8aL6uouMW0tqr9z29NJzJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=RAyogzkukKZAdi7S8yBa6C6J+CTNVLFaPMJKvTHa5P4=; b=VLGeO82e vTD/HLM+NvsfFEdXq3Yg6t6GMg4l8JKRMiifEYE6B1E9KycDXkZKzChH7OH/13qb AapEdFS4rLMkqYOCFmkYJPt6EvTV+GWb7q5ykvnGhaMSTRrY8/gf00Zm8sENLK2d ds//UH30shAFEHdM9d/q5k6WDDSUpVytCOYopeA221kevx/xNPzso6ptGYfDRk2P SdFFpaF9K3uVTA08y5VA98YF9pjanr+x/ZnTecdK7s3m0HkDhFX9sahjarfVD0sY mRuw8Lvb/H6+DA02Fne563Tmdor5IrIBS0QBhO2Pd5gnj1JDhETLtA+6Hcj8o3rS kp5mjmWz3ui4/A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrhedugdekiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucfkphepledtrd ekledrieekrdejieenucevlhhushhtvghrufhiiigvpeduleenucfrrghrrghmpehmrghi lhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 7E3E73065D87; Fri, 24 Apr 2020 11:35:54 -0400 (EDT) From: Maxime Ripard To: Nicolas Saenz Julienne , Eric Anholt Cc: dri-devel@lists.freedesktop.org, linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson , Tim Gover , Phil Elwell , Maxime Ripard , Philipp Zabel Subject: [PATCH v2 23/91] reset: simple: Add reset callback Date: Fri, 24 Apr 2020 17:34:04 +0200 Message-Id: <31e3daec5d5b703bd87ef9d77e353589daf6fa3e.1587742492.git-series.maxime@cerno.tech> X-Mailer: git-send-email 2.26.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The reset-simple code lacks a reset callback that is still pretty easy to implement. The only real thing to consider is the delay needed for a device to be reset, so let's expose that as part of the reset-simple driver data. Cc: Philipp Zabel Signed-off-by: Maxime Ripard --- drivers/reset/reset-simple.c | 24 ++++++++++++++++++++++++ include/linux/reset/reset-simple.h | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/reset/reset-simple.c b/drivers/reset/reset-simple.c index c854aa351640..602ed972b0a9 100644 --- a/drivers/reset/reset-simple.c +++ b/drivers/reset/reset-simple.c @@ -11,6 +11,7 @@ * Maxime Ripard */ +#include #include #include #include @@ -63,6 +64,28 @@ static int reset_simple_deassert(struct reset_controller_dev *rcdev, return reset_simple_update(rcdev, id, false); } +static int reset_simple_reset(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct reset_simple_data *data = to_reset_simple_data(rcdev); + int ret; + + if (!data->reset_us) + return -ENOTSUPP; + + ret = reset_simple_assert(rcdev, id); + if (ret) + return ret; + + usleep_range(data->reset_us, data->reset_us * 2); + + ret = reset_simple_deassert(rcdev, id); + if (ret) + return ret; + + return 0; +} + static int reset_simple_status(struct reset_controller_dev *rcdev, unsigned long id) { @@ -80,6 +103,7 @@ static int reset_simple_status(struct reset_controller_dev *rcdev, const struct reset_control_ops reset_simple_ops = { .assert = reset_simple_assert, .deassert = reset_simple_deassert, + .reset = reset_simple_reset, .status = reset_simple_status, }; EXPORT_SYMBOL_GPL(reset_simple_ops); diff --git a/include/linux/reset/reset-simple.h b/include/linux/reset/reset-simple.h index 08ccb25a55e6..5eb83625a495 100644 --- a/include/linux/reset/reset-simple.h +++ b/include/linux/reset/reset-simple.h @@ -27,6 +27,11 @@ * @status_active_low: if true, bits read back as cleared while the reset is * asserted. Otherwise, bits read back as set while the * reset is asserted. + * @reset_us: Minimum delay in microseconds needed that needs to be + * waited for between an assert and a deassert to reset the + * device. If multiple consumers with different delay + * requirements are connected to this controller, it must + * be the largest minimum delay. */ struct reset_simple_data { spinlock_t lock; @@ -34,6 +39,7 @@ struct reset_simple_data { struct reset_controller_dev rcdev; bool active_low; bool status_active_low; + unsigned int reset_us; }; extern const struct reset_control_ops reset_simple_ops; -- git-series 0.9.1