Received: by 10.223.185.116 with SMTP id b49csp839725wrg; Tue, 20 Feb 2018 08:41:20 -0800 (PST) X-Google-Smtp-Source: AH8x227vicF2YY1fPWRZwyMMrRk0/mXte2/E/VKTgiC0a+5NWkS4BQ6uOo+rLRkA8Gx2nF/fEueZ X-Received: by 10.99.5.197 with SMTP id 188mr183292pgf.196.1519144880574; Tue, 20 Feb 2018 08:41:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519144880; cv=none; d=google.com; s=arc-20160816; b=f6Lt3XrMyA+7NsYdGRlrwK5OLs//P9V/cTWuxiHVqHunLRgQtOXO5IyES9zpHAwxOk 79cLTmktFolbTJq3K1KNp+fi3OetIb5SUzB3uQ9XBgfbNjDQoJjIa8RlVVV/2yyqL1DA x70+ujNV1m+ROE1Bqu72R47Vxz0SZ7FW8GfTg3J97fIsgqXjuqoMzj8ibBzr7fUSEbDT ibSVXqPJXXsvRS0DwdaqTokSaIfosKZ/UyKh1gdGm/6Tpy7513JXYGsDsw9eFWIsjZ/a +HTO3IqZ2Lim7YuCAvE4OohAlTiA63JT/kcuapu9m5E6IYKRshaYzOrX49OWIY6b6F/N 0Jhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=xAZesfam0x18teVMnYvs5m6MeQrQQkUEFLMMN/1DlJw=; b=Ext880qXYcYXTM/Xkr6roZ1zV2cAcT5xlr1PZk0gsByvKsLtIfDiEnB2QIjMB7kwfO LL1o4ZbMaCX6ZicoB5z+Kzuz8284xgfpaLmpb3uYIK7km9FIYsfuHCmfXEH5MSl5GJVC lK5r2G5+HQZ7W/F3S6pWX9S3i7avcjYNJilLnjjIaS+jNlQrzSHVcVSRNV/gxa2j6dl8 i18CKN7Mt7Vnd+IFO5x5R/oysWcb3N3aNCiNPDl7hlOALRMGY0w0g7ub2PL9C6F7ym4J UzBgK0D/3b6pCXDigQhBpPc+ySY9nB6GIhmXY6yO1S3tMVJMy0FwRQTUT0a9bXIyRUX+ OtrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=SMwSIZDG; 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 y7-v6si1203503plh.806.2018.02.20.08.41.06; Tue, 20 Feb 2018 08:41:20 -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=fail header.i=@lechnology.com header.s=default header.b=SMwSIZDG; 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 S1753257AbeBTQkE (ORCPT + 99 others); Tue, 20 Feb 2018 11:40:04 -0500 Received: from vern.gendns.com ([206.190.152.46]:48463 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753233AbeBTQkC (ORCPT ); Tue, 20 Feb 2018 11:40:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xAZesfam0x18teVMnYvs5m6MeQrQQkUEFLMMN/1DlJw=; b=SMwSIZDGo67FzL8hyVI7k2M8Hd U0cNaVf6ZCR7ucVSis33DZ/eK1pSaKZk7By+1/EpGr+EInI2SrgWPUa9bNmcn0ZLi7ScJpMqa8Eob vXYGqoP9ZUEg3iC6YQAVoZgHNJNhsXXta+sZn2lkXQXsxYoD/eipY2/VIgIoRpl3VJpy/HmD0W+9G wv/XkGVIaWBmNTvUpgreuhttUM/IW5hzy3RVVwfabNzN2fLh8zb4AkOmhKjFsa3eKwBEknFaqvxDZ zAlGT+0Xa2lQzEbiLlAs/K3zLLmFw5Et+poNV3AZ9WtaMMGSUnGSOCYX1L8CTwW2nqZwPdS9o+0LI HgyhFR3g==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:33932 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1eoAw9-003Q0Q-U9; Tue, 20 Feb 2018 11:38:38 -0500 Subject: Re: [PATCH v4] reset: add support for non-DT systems To: Philipp Zabel , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Sekhar Nori , Kevin Hilman References: <20180219165837.28913-1-brgl@bgdev.pl> <72cd2af4-ed6b-8c1b-2488-b999976b894a@lechnology.com> <1519123185.3470.5.camel@pengutronix.de> From: David Lechner Message-ID: <8ef4b901-f38d-d885-e7bc-657202a2e248@lechnology.com> Date: Tue, 20 Feb 2018 10:40:13 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1519123185.3470.5.camel@pengutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/20/2018 04:39 AM, Philipp Zabel wrote: > Hi Bartosz, David, > > On Mon, 2018-02-19 at 18:21 -0600, David Lechner wrote: >> On 02/19/2018 10:58 AM, Bartosz Golaszewski wrote: >>> From: Bartosz Golaszewski >>> >>> The reset framework only supports device-tree. There are some platforms >>> however, which need to use it even in legacy, board-file based mode. >>> >>> An example of such architecture is the DaVinci family of SoCs which >>> supports both device tree and legacy boot modes and we don't want to >>> introduce any regressions. >>> >>> We're currently working on converting the platform from its hand-crafted >>> clock API to using the common clock framework. Part of the overhaul will >>> be representing the chip's power sleep controller's reset lines using >>> the reset framework. >>> >>> This changeset extends the core reset code with new reset lookup >>> structures. Each lookup table contains a set of lookup entries which >>> allow the reset core to associate reset lines with devices (by >>> comparing the dev_id and con_id strings). >>> >>> Machine code can register a set of reset lines using this lookup table >>> and concerned devices can access them using the regular reset_control >>> API. >>> >>> The new lookup function is only called as a fallback in case the >>> of_node field is NULL and doesn't change anything for current users. >>> >>> Tested with a dummy reset driver with several lookup entries. >>> >>> An example lookup table can be found below: >>> >>> static struct platform_device foobar_reset_dev = { >>> .name = "foobar-reset", >>> }; >>> >>> static struct reset_lookup_entry foobar_reset_lookup_entries[] = { >>> { .con_id = "foo", id = 15 }, >>> { .con_id = "bar", id = 5 }, >>> }; >>> >>> static struct reset_lookup_table foobar_reset_lookup_table = { >>> .dev_id = "foobar-device", >>> .entries = foobar_reset_lookup_entries, >>> .num_entries = ARRAY_SIZE(foobar_reset_lookup_entries), >>> .dev = &foobar_reset_dev.dev, >>> }; >>> >> >> This seems like a lot of boilerplate to register a lookup. > > This could be shortened a bit by following the gpiod lookup model, > adding a RESET_LOOKUP macro and making the array NULL terminated: > > #define RESET_LOOKUP(reset_dev_id, idx, con_id) /*...*/ > > static struct reset_lookup_table foobar_reset_lookup_table = { > .dev_id = "foobar-device", > .entries = { > RESET_LOOKUP("foobar-reset.0", 15, "foo"), > RESET_LOOKUP("foobar-reset.0", 5, "bar"), > { }, > }, > }; > > /*...*/ > reset_add_lookup_table(&foobar_reset_lookup_table); > >> Can we have >> something like phy_create_lookup() instead where there is just a single >> function call to register a single lookup? This will be much easier to >> use in the davinci PSC driver. >> >> void reset_add_lookup(struct reset_controller_dev *rdev, int index, >> const char *dev_id, const char *con_id); > > In your case the platform code that adds the lookup may be identical to > the code that registers the struct reset_controller_dev, but that > doesn't have to be the case. I'm not sure how that is supposed to work > for the phy framework (I see no platform code adding phy lookups, only > drivers). > > My point was that if the reset controller is registered by a separate > driver, the platform code may not have access to the struct > reset_controller_dev, or even the struct platform_device. I like that > the gpiod lookups can match by dev_id of the gpio chip. > > regards > Philipp > In our use case, we would be adding the lookup in the driver rather than in the platform code, which is why I am suggesting doing it like the phy framework.