From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753437AbdBDB4p (ORCPT ); Fri, 3 Feb 2017 20:56:45 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36591 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240AbdBDB4m (ORCPT ); Fri, 3 Feb 2017 20:56:42 -0500 Date: Sat, 4 Feb 2017 09:56:18 +0800 From: Peter Chen To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Peter Chen , Alan Stern , Ulf Hansson , Mark Brown , Sebastian Reichel , Rob Herring , Shawn Guo , Dmitry Eremin-Solenikov , Heiko Stuebner , "linux-arm-kernel@lists.infradead.org" , p.zabel@pengutronix.de, "devicetree@vger.kernel.org" , Pawel Moll , Mark Rutland , "open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:" , Arnd Bergmann , Sascha Hauer , mail@maciej.szmigiero.name, troy.kisky@boundarydevices.com, Fabio Estevam , oscar@naiandei.net, Stephen Boyd , Linux PM , Joshua Clayton , Linux Kernel Mailing List , mka@chromium.org, Vaibhav Hiremath , Gary Bisson , hverkuil@xs4all.nl, Krzysztof Kozlowski Subject: Re: [PATCH 2/8] power: add power sequence library Message-ID: <20170204015618.GB25013@b29397-desktop> References: <1483425211-14473-1-git-send-email-peter.chen@nxp.com> <20170201080817.GD17968@kroah.com> <20170203081614.GA24614@b29397-desktop> <16336642.sihi7izbLX@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16336642.sihi7izbLX@aspire.rjw.lan> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2017 at 10:14:31PM +0100, Rafael J. Wysocki wrote: > On Friday, February 03, 2017 04:16:15 PM Peter Chen wrote: > > On Wed, Feb 01, 2017 at 09:08:17AM +0100, Greg Kroah-Hartman wrote: > > > On Wed, Feb 01, 2017 at 12:10:17AM +0100, Rafael J. Wysocki wrote: > > > > On Tue, Jan 3, 2017 at 7:33 AM, Peter Chen wrote: > > > > > We have an well-known problem that the device needs to do some power > > > > > sequence before it can be recognized by related host, the typical > > > > > example like hard-wired mmc devices and usb devices. > > > > > > > > > > This power sequence is hard to be described at device tree and handled by > > > > > related host driver, so we have created a common power sequence > > > > > library to cover this requirement. The core code has supplied > > > > > some common helpers for host driver, and individual power sequence > > > > > libraries handle kinds of power sequence for devices. The pwrseq > > > > > librares always need to allocate extra instance for compatible > > > > > string match. > > > > > > > > > > pwrseq_generic is intended for general purpose of power sequence, which > > > > > handles gpios and clocks currently, and can cover other controls in > > > > > future. The host driver just needs to call of_pwrseq_on/of_pwrseq_off > > > > > if only one power sequence is needed, else call of_pwrseq_on_list > > > > > /of_pwrseq_off_list instead (eg, USB hub driver). > > > > > > > > > > For new power sequence library, it can add its compatible string > > > > > to pwrseq_of_match_table, then the pwrseq core will match it with > > > > > DT's, and choose this library at runtime. > > > > > > > > > > Signed-off-by: Peter Chen > > > > > Tested-by: Maciej S. Szmigiero > > > > > Tested-by Joshua Clayton > > > > > Reviewed-by: Matthias Kaehlcke > > > > > Tested-by: Matthias Kaehlcke > > > > > > > > Quite honestly, I have a really hard time with trying to follow this > > > > code and the total lack of documentation makes it even harder. > > > > Sorry about that, Is it ok I add the design doc at: > > Documentation/power/power-sequence/design.rst? > > You can do that if you think it will address the request to explain the design. > > > > > particular, the generic power sequence code is not even commented at > > > > all, > > > > The generic power sequence code just implements the APIs which are > > called at power/pwrseq/core.c, and those API are commented at > > include/linux/power/pwrseq.h. Anyway, I will add more comments at it. > > It actually seems to be doing more than that and I'm not sure why the code in > core.c is necessary at all. The "generic" thing seems to be the only user of > it anyway and the callbacks seem to be tailored to its needs. > Currently, the "generic" pwrseq is the only use case. But some devices may have custom power sequence [1], and MMC devices (mmc card/wifi) have two power sequences (drivers/mmc/core/pwrseq_emmc.c, drivers/mmc/core/pwrseq_simple.c) I have an example use case at v7 named pwrseq_compatible_sample.c for those custom use case [2]. [1] https://www.spinics.net/lists/devicetree/msg139756.html [2] https://lkml.org/lkml/2016/9/19/972 -- Best Regards, Peter Chen