Received: by 10.223.185.116 with SMTP id b49csp682301wrg; Fri, 23 Feb 2018 05:14:52 -0800 (PST) X-Google-Smtp-Source: AH8x225bRNQU8Rt+Lz68cdaMQONKuC6vzOx/YfIzcTg1jW4WYBBPtnh9XffKz5ESiYGYKtM8m+V2 X-Received: by 10.101.97.139 with SMTP id c11mr1410289pgv.435.1519391692419; Fri, 23 Feb 2018 05:14:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519391692; cv=none; d=google.com; s=arc-20160816; b=sivVJ6P+MNmcnF9kYjZVf2Q76SJ5AhFQ28uMAjPQ52lZBF9zk3PoLGZ9AAY0TKCPBO ApkMoXrNJf+tJLoC5PlAuUye98B97xlib9r7k7nxIQO0TSNfgBa2D9/NOjmJ2/XMU74e pj5vmXVK90vrhB1Cf595NBLkU+/JQzJEUUlbuz3PRrPjJ5WLzdJbZb+1Bq4CPitg3qU1 MfnV6042UZ4jw9/jY9/E5GtuQ6w5kyGAhmBqWecXkgHRSd+0kHsB72gu+lNNvVCEb6B1 WV3Z288Vaf1gtFYJcYgHLJQqBiJqP4Pbb9gD500CmGUTFnStGKFFJGYfm3QrLg+7e70L cNIA== 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=5R4SwOuywNuXaQOvr2xB47Y+Ti7VyA5sbzi84ek3cvE=; b=kf3VUCwDos3NHdA3Rwr+0tah/OXsVjbc/bfVKyMwI8zYjuYbVX9O0k+AdNtMPsGGvu M0cKGduvYjmGpD0C2HI8IQI0qgqqj7j9lB1qBYd3AWzW2mmEitiO5QokHUvZm6XMRJ44 ZHkT6TcOZIpp/q+SAVrSwDu6VrGDarhH2wqYbWcK0JAwa21EI2P9q7XC4/UFdEBNdp4y ovzT57uC3huhzOoBmFOgZPp3l2A0b+QoZHS4sX04IUy+Y1Nv2ciHl4WF+yg/fM7WelS8 gZD/qJbITqehRTFWIGFpqvTIn68I8c+w3r0MD2qSNvtUTMKi7UaUUSXm6HANFtsBxobK eerw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=r22cF1WZ; 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 y9si1514343pgq.548.2018.02.23.05.14.37; Fri, 23 Feb 2018 05:14:52 -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=r22cF1WZ; 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 S1751600AbeBWNNn (ORCPT + 99 others); Fri, 23 Feb 2018 08:13:43 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:38132 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbeBWNNm (ORCPT ); Fri, 23 Feb 2018 08:13:42 -0500 Received: by mail-qk0-f193.google.com with SMTP id s198so10669212qke.5 for ; Fri, 23 Feb 2018 05:13:41 -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=5R4SwOuywNuXaQOvr2xB47Y+Ti7VyA5sbzi84ek3cvE=; b=r22cF1WZXi/lcE66Cx4UeutrdAh5/8GiMelCiysxPAYKvrSj/ktHVJ1a3iZcqN95HA WuYLEu7h9M6IQjiueoAtrmQJX+aYwqatNKF3ERMrNeNT29WKZSsPpvhuyPRzJXWkDwNX W+8ejesOLZJihXLioEnMPvOoSptkC+N03Q/8frN/A379VaH1koSuMX8uuoX1Aa3WfGWa 72Y1Hzgk2XNb1alhYJenfqJJ75S9CVX9He6+0/wBJ24TFLN5Xv1tqJUocjNO6jX8jWzb Fu1IRb7qJfmErEeFWWnKcAJlgzfxphed/DleLZ5iJb9KZ64lRAngUObxZm10Nz0d+1tt SSCg== 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=5R4SwOuywNuXaQOvr2xB47Y+Ti7VyA5sbzi84ek3cvE=; b=QAkL1suPeE95pGJniJAqjwrAfntwU2hdSb2OORzeIzxy/O/5TVh9VwhkTaxb3uvK9K 0XqW/K1P1DulWjLaqvv/pARbgobanTa5vUWIvNiLw11leLkPr4cU4+zoPi42qHUBvtmJ uwtY75nOkK9dFCNfNWPe20Oogwgj7NOfD5JQfNX9yrYKKC+k0SmNz+QLrOSrV+tCyBRH nBIMmLVKv9871fY8LXQcJ+EVeGTgSaG23iHyjxWqsw7pziYude9t4Xyyd9Aa37ZZhkUT G7cvyMKHaha4r9sIhMs4eu2M9FzvAwZY9RrwFc1IWxtqx7kJnByT4BIFJrLD2Y4l4qxf ttAg== X-Gm-Message-State: APf1xPAfVV7DBKj0v3+ovQNzNgz1fLUot43GZzM6/FJYmP75MiM5BopB 3ryF0DwSVqdg0ZJLuIPICIRd3elqcsXl+V/fFn5RVw== X-Received: by 10.55.133.7 with SMTP id h7mr2527830qkd.130.1519391621389; Fri, 23 Feb 2018 05:13:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.42.33 with HTTP; Fri, 23 Feb 2018 05:13:41 -0800 (PST) In-Reply-To: <20180223113924.28957-1-brgl@bgdev.pl> References: <20180223113924.28957-1-brgl@bgdev.pl> From: Bartosz Golaszewski Date: Fri, 23 Feb 2018 14:13:41 +0100 Message-ID: Subject: Re: [PATCH v5] reset: add support for non-DT systems To: Philipp Zabel Cc: Linux Kernel Mailing List , Bartosz Golaszewski , Sekhar Nori , Kevin Hilman , David Lechner 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-23 12:39 GMT+01:00 Bartosz Golaszewski : > 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 reset lookup > entry structure. It contains data allowing the reset core to associate > reset lines with devices by comparing the dev_id and con_id strings. > > It also provides a function allowing drivers to register lookup entries > with the framework. > > 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 registration from a driver can be found below: > > static struct reset_control_lookup foobar_reset_lookup[] = { > RESET_LOOKUP("foo.0", "foo", 15), > RESET_LOOKUP("bar.0", NULL, 5), > }; > > foobar_probe() > { > ... > > reset_controller_add_lookup(&rcdev, foobar_reset_lookup, > ARRAY_SIZE(foobar_reset_lookup)); > > ... > } > > 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 > > v2 -> v3: > - added the reset id number field to the lookup struct so that we don't need > to rely on the array index > > v3 -> v4: > - separated the driver and lookup table registration logic by adding a > function meant to be called by machine-specific code that adds a lookup > table to the internal list > - the correct reset controller is now found by first finding the lookup > table associated with it, then finding the actual reset controller by > the associated device > > v4 -> v5: > - since the first user of this will be the davinci clk driver and it > already registers clock lookup from within the driver code - allow > drivers to register lookups with the assumption that the code can be > extended to make it possible to register entries from machine code as > well > - simplify the code - only expose a single lookup structure and a simply > registration function > - add the RESET_LOOKUP macro for brevity > > drivers/reset/core.c | 65 +++++++++++++++++++++++++++++++++++++++- > include/linux/reset-controller.h | 28 +++++++++++++++++ > 2 files changed, 92 insertions(+), 1 deletion(-) Also: I decided not to go the phy way of allocating memory dynamically for lookup entries - I believe this is overkill and makes the code more complicated with all the error checking required. Instead, the lookup entries structs should be provided by the caller. Bart