Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp643555imj; Wed, 13 Feb 2019 14:51:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IY6MQSqgen5cIvEom9yN57gYExg/sqRlH7tp3E5pNB9VlfwskwVsaoPS+KxfUVC4p4HEYyc X-Received: by 2002:aa7:8392:: with SMTP id u18mr575694pfm.59.1550098297920; Wed, 13 Feb 2019 14:51:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550098297; cv=none; d=google.com; s=arc-20160816; b=oaONngToOJYieSivWOR2sMPs1R911Y68mKo53+QzBUFvoSLjTDOa8WXJshHMaPzimF vTjBOhgmp7zRljNqjnKrI9XDOV2Q3VGG35vpXsY+qe99H/anuqJjEp+0Bb6NS89q+JOG lUVw93wCB2Tg9q5f4OCCnCb9kpbiwGdHUJ18Na8JvrnxPupXqqCU4NUpZugItFA3EX6U T29B2kVD5s3LAiBTixRDE+kPcI29P/ZUhn5bt15/hC5UoaFHu3reyeODZfzXIL3fX0Ez x8kaGE47WqWfbfqIHTxmVZmNeMG/Ai+irN/IF+SQE4ih7AWsVw2cvgDsX/oYtXnrTz46 ZJ4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:from:cc:references:message-id :subject:user-agent:in-reply-to:to:content-transfer-encoding :mime-version:dkim-signature; bh=Icpq+ZI7vGDf+7yoYd03f+a0bL+hgVYSFxaVHFX5T7U=; b=qOEhXk20YgZRsMEVZugAGdSmhbU3iS8PD2/9++l8e08CxXt7L7GPtvVC3hEOl+43V1 nrbxGAL7bCgemobMg6zHjHOd1luuwaCzYQSv/tkf+IFgh4S3B4mcy8h2A/wxwnkAVGX2 Z+5PPzVqhmq7lazwsDj7HTgFMlDj7HqRJHy1hmGR0Oasmgq/MXh7UQHCQ5xZP++Ng2wK loi24FJGHyNEPS8U02qSM76oRFJ4hhQLOdn0mMLFAJunMd80fvBupG2/DuztTjJ4GVcl SciEkYfZSoZ+3Zc686sCbby9FZDrcXhWwJS2Vw4IPFL9Cp67ac0vq+XYvP4CDMz4Mkuw /43A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LmtamxuT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si511768pgq.319.2019.02.13.14.51.21; Wed, 13 Feb 2019 14:51:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LmtamxuT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392730AbfBMROY (ORCPT + 99 others); Wed, 13 Feb 2019 12:14:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:49700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729760AbfBMROY (ORCPT ); Wed, 13 Feb 2019 12:14:24 -0500 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 60ED120821; Wed, 13 Feb 2019 17:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550078063; bh=o45AkmZPc7WsoEj8sr1V/Y30S0WSYywOZiHs1ICTHBY=; h=To:In-Reply-To:Subject:References:Cc:From:Date:From; b=LmtamxuT9jiIIAXCM081Bqc4MecnuvxG6wgq6XJwOLyZaTv6eVvkVYjlpKSfFWZlM brSHzlw80cfQAsRuQlqRQnKxTLoyc/i3WRj0z7bctcln6HRtxz6ViqtQk6rqZXWbEt vNZEhZoyETdHzxTeJsJ+7h6s+DXN7V+EO46knIYc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Michael Turquette , Thomas Petazzoni In-Reply-To: <20190211135818.10518-1-thomas.petazzoni@bootlin.com> User-Agent: alot/0.8 Subject: Re: [PATCH] clk: clk-gpio: add support for sleeping GPIOs in gpio-gate-clk Message-ID: <155007806256.115909.10137511038361789251@swboyd.mtv.corp.google.com> References: <20190211135818.10518-1-thomas.petazzoni@bootlin.com> Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni From: Stephen Boyd Date: Wed, 13 Feb 2019 09:14:22 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Thomas Petazzoni (2019-02-11 05:58:18) > The current implementation of gpio-gate-clk enables/disables the clock > using the GPIO in the ->enable() and ->disable() clock callbacks. This > requires the GPIO to be configurable in atomic contexts. While it is > the case for most memory-mapped GPIO controllers, it is not the case > for GPIO expanders on I2C or SPI. >=20 > This commit extends the gpio-gate-clk to check whether the GPIO calls > require sleeping or not. If sleeping is not required, the current > implementation based on ->enable()/->disable() is kept. However, if > sleeping is needed, we instead implement the logic in the ->prepare() > and ->unprepare() hooks. Thanks to this, a gate clock connected to a > GPIO on a GPIO expander can be controlled with the existing driver. >=20 > Signed-off-by: Thomas Petazzoni Sounds like a good idea! > diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c > index 6a43ce420492..f5d481713c7d 100644 > --- a/drivers/clk/clk-gpio.c > +++ b/drivers/clk/clk-gpio.c > @@ -61,6 +61,35 @@ const struct clk_ops clk_gpio_gate_ops =3D { > }; > EXPORT_SYMBOL_GPL(clk_gpio_gate_ops); > =20 > +static int clk_sleeping_gpio_gate_prepare(struct clk_hw *hw) > +{ > + struct clk_gpio *clk =3D to_clk_gpio(hw); > + > + gpiod_set_value_cansleep(clk->gpiod, 1); > + > + return 0; > +} > + > +static void clk_sleeping_gpio_gate_unprepare(struct clk_hw *hw) > +{ > + struct clk_gpio *clk =3D to_clk_gpio(hw); > + > + gpiod_set_value_cansleep(clk->gpiod, 0); > +} > + > +static int clk_sleeping_gpio_gate_is_prepared(struct clk_hw *hw) > +{ > + struct clk_gpio *clk =3D to_clk_gpio(hw); > + > + return gpiod_get_value_cansleep(clk->gpiod); > +} > + > +const struct clk_ops clk_sleeping_gpio_gate_ops =3D { static? > + .prepare =3D clk_sleeping_gpio_gate_prepare, > + .unprepare =3D clk_sleeping_gpio_gate_unprepare, > + .is_prepared =3D clk_sleeping_gpio_gate_is_prepared, > +}; > + > /** > * DOC: basic clock multiplexer which can be controlled with a gpio outp= ut > * Traits of this clock: