Received: by 10.223.185.116 with SMTP id b49csp3893714wrg; Tue, 13 Feb 2018 09:18:43 -0800 (PST) X-Google-Smtp-Source: AH8x226W74tkToMgyoruvRisBSSixlcU+BXC+GqKZx/5nJ/D/1xx1kmfLv7m6GrMGhc45nt0cmtP X-Received: by 2002:a17:902:32a2:: with SMTP id z31-v6mr1815329plb.32.1518542323849; Tue, 13 Feb 2018 09:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518542323; cv=none; d=google.com; s=arc-20160816; b=v1cJ2YkWiVVrlu2r7E2ERA3nojYGmgL/6Zt2QgXXEg4HHkwJmXmZyhgR7ruQ9zq1ye GYcyjbEne9B+OqGqcw/yLEXFTAinjZlKdVUGZ3wReeeUg6/k08rDp36h1NbeCqFn/joc j4aduQqwaMGd2VTgzAc2nCfXJgMGBgOJBxIRjDUluzZgdpmfB9MudAi1iFE4JyuK6u6G 8kvhAO5j4sYR+x8KnnaJgGJs0bxCbSPLHeaAod6NY4+ZBoaFgU1pW13SIN/QCFuhwWvj j4W2qR5L7VWY53mSVQwH8KJ7dMnhaVe3mQmKqbsas7M6hOUaCvpkJEqdnl3waBIVnWbH mrVQ== 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=TopN/WJ3hvVh/EDiqw7dzyW/5n7Xr/kPZIBvI8nmBBI=; b=NSW3aG2I9j/fLxRYxYFc4/MG9h5DWQhW9t89bNyqhw9tzaSsYanZLVHukHrH2giaMx 6JjYxCpBMz0O3kVu6bY/Sr34CxMIbvewRtlqLM+6CGBMbJC1ZF//BGGibOWyqtubttCn uC+nNeEhkTmt3ROLWUFA+/yDi84WFDkOfDoxnA1yM9TQHHugm0VfyQ5mbQ3oBpCtVxJR Y4PRxwCMKcflCl55czIJmcQSBSxGVC+3JRiCJyTqqyoZ7X8XP0SmydbLKp2VDN9RyJkl tOLA29z7UiyRQ6cmvVZWYbxsyFFoSQd9C2xHfbSetKwGgICamYSKrB0CFckEfIZ4kO7Z r0XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=egIaTuW6; 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 n9si3632114pge.307.2018.02.13.09.18.28; Tue, 13 Feb 2018 09:18:43 -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=egIaTuW6; 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 S965241AbeBMRRv (ORCPT + 99 others); Tue, 13 Feb 2018 12:17:51 -0500 Received: from vern.gendns.com ([206.190.152.46]:43542 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965091AbeBMRRt (ORCPT ); Tue, 13 Feb 2018 12:17:49 -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=TopN/WJ3hvVh/EDiqw7dzyW/5n7Xr/kPZIBvI8nmBBI=; b=egIaTuW616s8YdgGlaNULituGb ZR+77XK4hc//X/ezrrgBM8B2akxUtRERs8xyxq/lBEU29g5EPWYlrODxRUtG1mI4dZT0DniqzYUxe Qz05ke5TXUD5e48iu8G7GrteylIL8zyFwpzQc83chVAOMwsL424lwMvRtYZixWm6dTSAwiATaxY60 agb3F34B47DwOPz5EKOXbD6IC8zLQln4mksKKJWVbaNTNbhupkO7Jnr1Fu+CnAELkh4qCU0H4bFWe QnUBvG7uFvTdSA6eqmHxOjdkSTnYgrGBHQbG8FPzRdmKMw1FB8IoQ+CFESt8SQwuzTcMuOSdtJFlY JDcFFDCw==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:46266 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 1eleC5-001JOF-3v; Tue, 13 Feb 2018 12:16:37 -0500 Subject: Re: [PATCH] reset: add support for non-DT systems To: Bartosz Golaszewski , Philipp Zabel Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Sekhar Nori , Kevin Hilman References: <20180213152524.16620-1-brgl@bgdev.pl> From: David Lechner Message-ID: Date: Tue, 13 Feb 2018 11:17:56 -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: <20180213152524.16620-1-brgl@bgdev.pl> 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/13/2018 09:25 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 a new field in the > reset controller struct which contains an array of lookup entries. Each > entry contains the device name and an additional, optional identifier > string. > > Drivers can register a set of reset lines using this lookup table and > concerned devices can access them using the regular reset_control API. > > This new 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 look like this: > > static const struct reset_lookup foobar_reset_lookup[] = { > [FOO_RESET] = { .dev = "foo", .id = "foo_id" }, > [BAR_RESET] = { .dev = "bar", .id = NULL }, > { } > }; > > where FOO_RESET and BAR_RESET will correspond with the id parameters > of reset callbacks. > > Cc: Sekhar Nori > Cc: Kevin Hilman > Cc: David Lechner > Signed-off-by: Bartosz Golaszewski > --- Looks good to me. I just made a few very minor comments. I will try to use this in PSC driver later today. > drivers/reset/core.c | 43 ++++++++++++++++++++++++++++++++++++++-- > include/linux/reset-controller.h | 13 ++++++++++++ > 2 files changed, 54 insertions(+), 2 deletions(-) > > diff --git a/drivers/reset/core.c b/drivers/reset/core.c > index da4292e9de97..ba7011c6e06f 100644 > --- a/drivers/reset/core.c > +++ b/drivers/reset/core.c > @@ -493,12 +493,51 @@ struct reset_control *__of_reset_control_get(struct device_node *node, > } > EXPORT_SYMBOL_GPL(__of_reset_control_get); > > +static struct reset_control * > +__reset_control_get_lookup(struct device *dev, const char *id, Based on the name of the function, I expected this to return struct reset_lookup. Perhaps __reset_control_lookup() or __reset_control_match_lookup() would be a slightly better name? > + bool shared, bool optional) > +{ > + struct reset_controller_dev *rcdev; > + const char *dev_id = dev_name(dev); > + struct reset_control *rstc = NULL; > + const struct reset_lookup *lookup; > + int index; > + > + mutex_lock(&reset_list_mutex); > + > + list_for_each_entry(rcdev, &reset_controller_list, list) { > + if (!rcdev->lookup) > + continue; > + > + lookup = rcdev->lookup; > + for (index = 0; lookup->dev; index++, lookup++) { > + if (strcmp(dev_id, lookup->dev)) > + continue; > + > + if ((!id && !lookup->id) || > + (id && lookup->id && !strcmp(id, lookup->id))) { > + rstc = __reset_control_get_internal(rcdev, > + index, shared); > + } > + } > + } > + > + mutex_unlock(&reset_list_mutex); > + > + if (!rstc) > + return optional ? NULL : ERR_PTR(-ENOENT); > + > + return rstc; > +} > + > struct reset_control *__reset_control_get(struct device *dev, const char *id, > int index, bool shared, bool optional) > { > if (dev->of_node) > - return __of_reset_control_get(dev->of_node, id, index, shared, > - optional); > + return __of_reset_control_get(dev->of_node, id, > + index, shared, optional); I don't understand why this line is changed. It is just being rearranged? > + else > + return __reset_control_get_lookup(dev, id, shared, optional); > > return optional ? NULL : ERR_PTR(-EINVAL); > } > diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h > index adb88f8cefbc..0c081336e08b 100644 > --- a/include/linux/reset-controller.h > +++ b/include/linux/reset-controller.h > @@ -22,6 +22,17 @@ struct reset_control_ops { > int (*status)(struct reset_controller_dev *rcdev, unsigned long id); > }; > > +/** > + * struct reset_lookup - a single entry in a reset lookup table > + * > + * @dev: name of the device associated with this reset > + * @id: additional reset identifier (if the device uses multiple reset lines) > + */ > +struct reset_lookup { > + const char *dev; > + const char *id; > +}; > + > struct module; > struct device_node; > struct of_phandle_args; > @@ -34,6 +45,7 @@ struct of_phandle_args; > * @list: internal list of reset controller devices > * @reset_control_head: head of internal list of requested reset controls > * @of_node: corresponding device tree node as phandle target > + * @lookup: array of lookup entries associated with this request controller Might be nice to mention that this array must end with an empty struct (i.e. lookup->dev == NULL) > * @of_reset_n_cells: number of cells in reset line specifiers > * @of_xlate: translation function to translate from specifier as found in the > * device tree to id as given to the reset control ops > @@ -45,6 +57,7 @@ struct reset_controller_dev { > struct list_head list; > struct list_head reset_control_head; > struct device_node *of_node; > + const struct reset_lookup *lookup; > int of_reset_n_cells; > int (*of_xlate)(struct reset_controller_dev *rcdev, > const struct of_phandle_args *reset_spec); >