Received: by 10.223.185.116 with SMTP id b49csp3697504wrg; Mon, 19 Feb 2018 04:36:46 -0800 (PST) X-Google-Smtp-Source: AH8x226xyPyJGHqLcASClGvMbhUxy0SFqGvKl0bWuPU6uRJ9bNUfbnLBpRZ1MV/7odNdLbLmL1mf X-Received: by 10.98.9.130 with SMTP id 2mr3899851pfj.149.1519043806148; Mon, 19 Feb 2018 04:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519043806; cv=none; d=google.com; s=arc-20160816; b=i//fkfO/M1E0OiF7H7mNFv23DSNB+M7EerI1KZlH5vxZgWWk5OKA/LtHQ32oihntwV U3O3eatMZNI5JhF9CUgEXgx2jQWKxW8ljRZfgF4aY4B7e0ih/rYU7qJnpD3J1RiZETJE vg7ug0s0ssTB4GSHVjnnSHNNbchtUKiqUoD9ck4dwrbf46Ch8TsipUWuSHVRndZhEzgb 4Ux3n4/69x8SiuJi63tBB8MsW3VqTsncMdKGkdwaS12FtpwcHw90W7KibZcw1CCwyE3S wjVYJ9kJPTTeRygv4/LtMlGRMhlhf1KtDl0sErX7d580PMMiKcR//iXD8K827yR5J5mi rt4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=RTEmsdSW9I/OYU8bPLbQRGSZp0F2pZyQT83TgGanCXM=; b=N6/3Y+k7ZrSiGJ5fNvC35dAifZFLPflK8O5aL1Ekm88eSQ+UFJO6NAHsvZfC+hwGKW 3o6YRTx2PxrVdX4ne0uAERGSSvBPGXhPAaghJk5rCxoEFpOuYtK+OWgGRW3AlIgxXz7z HSGRU1dE6xtLdNjpSsNKlQjPKkGJrl3vkc1Z/SW5gNv7aISahC+RC/egV21bwl15/5SF xIdMGN9h9O62Jt4jIZrGk58CWK7b4UYXYzjZY5ebzXHds+x2EtyM+QRokevZHxIVzH+Q 7i9Bnf1hEhsQU4RNsjqEwvVlmWAJMm+8VP+8zGsdtMCplra4E42D5hgu09eog0nauaHu EmIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=kvlfdyi/; 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 g128si5414137pgc.574.2018.02.19.04.36.31; Mon, 19 Feb 2018 04:36:46 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=kvlfdyi/; 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 S1752746AbeBSMfm (ORCPT + 99 others); Mon, 19 Feb 2018 07:35:42 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:43416 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696AbeBSMfl (ORCPT ); Mon, 19 Feb 2018 07:35:41 -0500 Received: by mail-ot0-f193.google.com with SMTP id q12so8301203otg.10 for ; Mon, 19 Feb 2018 04:35:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RTEmsdSW9I/OYU8bPLbQRGSZp0F2pZyQT83TgGanCXM=; b=kvlfdyi/Sz01gc1GynRMh4mkrk83c34Q9CMV7B70FSoB4xtLIYVQDnA2R6Z21NQcD/ DqDOLJ7Q6HEMqBE1elTwcc9ywB38pauxHh4+7o0F1UN21gfRr7CE/1Q+o8r4jETsDxa4 Q0YPF5aeDaNyxPTXIT+EyNbdVHroW3qFqNwUIMniakB5dYs9IlF4kyP3lRuTeqCFudmf MaJXN3XX/Hor6Vq4NPlYJms7tBMSzFmzotVpMcPl4g/GVJrF84/07RT1MEtuv82k8AwE FVWkbNl3RhgkjFYnAzEn4Ose2+8i7Q8G6kZmUvFUWbzwr/tXratOQBChSykYikt6Iaie 6uug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RTEmsdSW9I/OYU8bPLbQRGSZp0F2pZyQT83TgGanCXM=; b=L6ogWznLCxplOdJkhMWaX7d0KSogQLTcAHyXMsoEqCPst+LcP+s8tXWGOEw9+zYvYi rgIsca6FX+bM5ltNeYAHWVhrkhhZU8+ueWJlaBuW76f+ejBWijuw/txHkV7I+GXpppMT W33vWHKB6HoUuVzVTh9DS/QhOi0qRSncXnWE8CVSoDEd6MCrYBTD3oH8k4wsQykMnok5 twf0+mvjNATTlvM+JR3ip8sXadEEN8msRituM2WZWQcg+vXq7woRqlfll40ikJ1DBLSD NOBYvYVzn+KdAT7psZylsm7OL21wRUwgelSlI5fhV9Q4A8J0B+iTU/Z5hKUW7GCNpX7W BW2Q== X-Gm-Message-State: APf1xPBtobgzcHPyRX6Sivzs4LEnzuV4rLHifj1KcCP/s91YzejWEfzv ksku+QI9UgbhTqRyHzqd4wtCHc5CUg9w8TOIuffTRg== X-Received: by 10.157.61.131 with SMTP id l3mr10019940otc.394.1519043740460; Mon, 19 Feb 2018 04:35:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.45.2 with HTTP; Mon, 19 Feb 2018 04:35:40 -0800 (PST) In-Reply-To: References: <20180213183946.1662-1-brgl@bgdev.pl> From: Bartosz Golaszewski Date: Mon, 19 Feb 2018 13:35:40 +0100 Message-ID: Subject: Re: [PATCH v2] reset: add support for non-DT systems To: David Lechner Cc: Philipp Zabel , Linux Kernel Mailing List , Bartosz Golaszewski , Sekhar Nori , Kevin Hilman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-02-17 3:01 GMT+01:00 David Lechner : > On 02/13/2018 12:39 PM, 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 >> --- >> v1 -> v2: >> - renamed the new function to __reset_control_get_from_lookup() >> - added a missing break; when a matching entry is found >> - rearranged the code in __reset_control_get() - we can no longer get to >> the >> return at the bottom, so remove it and return from >> __reset_control_get_from_lookup() if __of_reset_control_get() fails >> - return -ENOENT from reset_contol_get() if we can't find a matching >> entry, >> prevously returned -EINVAL referred to the fact that we passed a device >> without the of_node which is no longer an error condition >> - add a comment about needing a sentinel in the lookup table >> >> drivers/reset/core.c | 40 >> +++++++++++++++++++++++++++++++++++++++- >> include/linux/reset-controller.h | 14 ++++++++++++++ >> 2 files changed, 53 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/reset/core.c b/drivers/reset/core.c >> index da4292e9de97..b104a0c5c511 100644 >> --- a/drivers/reset/core.c >> +++ b/drivers/reset/core.c >> @@ -493,6 +493,44 @@ 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_from_lookup(struct device *dev, const char *id, >> + 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); >> + break; >> + } >> + } >> + } > > > > This method of determining the index is not very useful. In the case of the > DSP > reset on OMAP-L138, the index *must* be the LPSC module domain number, which > is > 15. This would require us to create 15 dummy entries in the rcdev->lookup > array > so that we get the correct index in order to get the correct reset control. > > I think it would be better to just store the index in struct reset_lookup. > > Another option would be to require the length of lookup to be > rcdev->nr_resets > instead of using a sentinel. Indeed. Please take a look at v3. Thanks, Bartosz