Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp788188imm; Fri, 12 Oct 2018 06:47:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV60FmXxpFvsMRZQC3lb44raKhGn5FGVOFG3b0W2GDEUcfkV05tO6r90NgeLUB670Bpkt9ZTq X-Received: by 2002:a17:902:9a04:: with SMTP id v4-v6mr5950291plp.247.1539352022995; Fri, 12 Oct 2018 06:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539352022; cv=none; d=google.com; s=arc-20160816; b=vfIST+H2HhMsXjnanjPKoXgl5h2c2Q07T39Ud395EPcKxCAzElDZ2cb9KUEJU71t+y RVXp58jS+VI7NuocPAmK9MizV7aj75yNMswOtuOpCs2eDFBNUudwii1UD3/CSAQEmca7 Y8uxDHwOxOTPu3SY0gOiQ6zQ9ql71krXYofMQuHpH7V+4f8J0qnmexFWQl4ISl4mGzir Djc16GbwiXm/jPmMafiwvK+f448XlZKBxrcMRUDb7EO8bidO033KvS4YCRkGRYvwOZVr bW2fPy9DC7zd4pUQc0rXRaO6Ph03scBb/Mcj+O4JkLF0UjrKZIubF/KIi6D81RCVxpEY 1cLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=KeN+SUpjmDiAaen49SaDZ6E5VS/ehUxWu0tMqLAeIA0=; b=hHGPaFp4/yqdhObaVdcVzYlQXynzeAF1JN3Cnecx+uIJlRZjw2rOle/eDsPYa80HbW EK11XoH1SLyY22NHekesGdBk3Yuf+jsKeRwrDb/mvm0c/MDJIkQGDxEsWg3ovxZ31/wY 2FffeC/17WoviDYzuY9wu+GLE1m2aULUuVLxt39BAdU3o8M5k+YvgIrNqHy6GzpHCZyl hPkJXV/4tPKjim46j0YF2dgc2l/t4SM5X9Khd4eTwCWJyQNnsE8yamw4+ZpcorQ4xuMw LHLDy41l3lNVnKwzpch1Hdx2nBCcHw9JN83cfcuJ3+NH5LtaBN/o8z5NbxvJBymVJyTn js7A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y190-v6si1387616pfy.147.2018.10.12.06.46.47; Fri, 12 Oct 2018 06:47:02 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728752AbeJLVSy convert rfc822-to-8bit (ORCPT + 99 others); Fri, 12 Oct 2018 17:18:54 -0400 Received: from mail.bootlin.com ([62.4.15.54]:49904 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728574AbeJLVSx (ORCPT ); Fri, 12 Oct 2018 17:18:53 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 8D70B207B4; Fri, 12 Oct 2018 15:46:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (AAubervilliers-681-1-7-245.w90-88.abo.wanadoo.fr [90.88.129.245]) by mail.bootlin.com (Postfix) with ESMTPSA id 5A9A720701; Fri, 12 Oct 2018 15:46:19 +0200 (CEST) Date: Fri, 12 Oct 2018 15:46:20 +0200 From: Maxime Ripard To: Philipp Zabel Cc: Cheng-yi Chiang , Mark Brown , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Ryan Lee , alsa-devel@alsa-project.org, Dylan Reid , tzungbi@chromium.org Subject: Re: [PATCH 2/2] ASoC: max98927: Add reset-gpio support Message-ID: <20181012134620.fhhkyvvdgoq4sxqi@flea> References: <20180912121955.33048-1-cychiang@chromium.org> <20180912121955.33048-2-cychiang@chromium.org> <20180920161905.GM2471@sirena.org.uk> <1539338716.6204.2.camel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <1539338716.6204.2.camel@pengutronix.de> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 12, 2018 at 12:05:16PM +0200, Philipp Zabel wrote: > Hi Cheng-yi, > > [adding Maxime, devicetree to Cc:, the old discussion about GPIO resets > in [4] has never been resolved] > > On Tue, 2018-10-09 at 21:46 +0800, Cheng-yi Chiang wrote: > > +reset controller maintainer Philipp > > > > Hi Mark, > > Sorry for the late reply. It took me a while to investigate reset > > controller and its possible usage. I would like to figure out the > > proper way of reset handling because it is common to have a shared > > reset line for two max98927 codecs for left and right channels. > > Without supporting this usage, a simple reset-gpios change for single > > codec would not be useful, and perhaps will be duplicated if reset > > controller is a better way. > > > > Hi Philipp, > > I would like to seek your advice about whether we can use reset > > controller to support the use case where multiple devices share the > > same reset line. > > > > Let me summarize the use case: > > There are two max98927 codecs sharing the same reset line. > > The reset line is controlled by a GPIO. > > The goal is to toggle reset line once and only once. > > > > There was a similar scenario in tlv320aic3x codec driver [1]. > > A static list is used in the codec driver so probe function can know > > whether it is needed to toggle reset line. > > Mark pointed out that it is not suitable to handle the shared reset > > line inside codec driver. > > A point is that this only works for multiple devices using the same > > device driver. > > He suggested to look into reset controller so I searched through the > > usage for common reset line. > > > > Here I found a shared reset line use case [2]. > > With the patch [2], reset_control_reset can support this “reset once > > and for all” use case. > > This patch was applied as 7da33a37b48f. So the reset framework has > support for shared reset controls where only the first reset request > actually causes a reset pulse, and all others are no-ops. > > > However, I found that there are some missing pieces: > > > > Let’s assume there are two codecs c1 and c2 sharing a reset line > > controlled by GPIO. > > > > c1’s spec: > > Hold time: The minimum time to assert the reset line is t_a1. > > Release time: The minimum time to access the chip after deassert of > > the reset line is t_d1. > > > > c2’s spec: > > Hold time: The minimum time to assert the reset line is t_a2. > > Release time: The minimum time to access the chip after deassert of > > the reset line is t_d2. > > > > For both c1 and c2 to work properly, we need a reset controller that > > can assert the reset line for > > T = max(t_a1, t_a2). > > > > 1. We need reset controller to support GPIO. > > I still don't like the idea of describing a separate gpio reset > controller "device" in DT very much, as this is really just a software > abstraction, not actual hardware. For example: > > gpio_reset: reset-controller { > compatible = "gpio-reset"; > reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>, > <&gpio1 > 16 GPIO_ACTIVE_HIGH>; > reset-delays-us = <10000>, <500>; > }; > > c1 { > resets = <&gpio_reset 0>; /* maps to <&gpio0 15 ...> */ > }; > > c2 { > resets = <&gpio_reset 0>; > }; > > What I would like better would be to let the consumers keep their reset- > gpios bindings, but add an optional hold time override in the DT: > > c1 { > reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; > reset-delays-us = <10000>; > }; > > c2 { > reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; > reset-delays-us = <10000>; > }; > > The reset framework could create a reset_control backed by a gpio > instead of a rcdev. I have an unfinished patch for this, but without the > sharing requirement adding the reset framework abstraction between gpiod > and drivers never seemed really worth it. I don't remember the exact details of our past discussion, but I (still) don't really think that this would work well. I see two main shortcomings with that approach: - I guess that the main reason you want to do that would be to have easy DT backward compatibility. Yet, the addition of the reset-delay-us would break that compatibility, since drivers that would have been converted now need to have it somehow, but older DTs wouldn't have it - There's so many variations of the reset-gpios property name that you wouldn't be able to cover all the cases anyhow, at least without breaking the compatibility (again). But I also see your point, and you're right that converting everyone to a gpio-reset node will not happen (even though I'd still really like to have that binding). What about having a function that would be called by the consumer to instantiate that reset controller from a GPIO for us, instead of trying to do it automatically? That function could take the property name that holds the GPIO, which would cover the second drawback, and the delay, which would cover the first. And in order to cover shared GPIO reset lines, we could just look at the one already created by other drivers, and if one has been created, we just give the reference to that one instead of creating it. Does that make sense? Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com