Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2917760ybh; Mon, 5 Aug 2019 08:57:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwd9O+l9YSL1Urc1aqb74cHOKaJmU65UDBBY8kEswNmBKRxdAaJuzpcdoWupTmRl2P2+/lB X-Received: by 2002:a63:1765:: with SMTP id 37mr68851955pgx.447.1565020644459; Mon, 05 Aug 2019 08:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565020644; cv=none; d=google.com; s=arc-20160816; b=qlHv6TRxezCOyI2PNuLIcuzyNrFfTcmiSYNH+rkciZSBMewbf85qQs34dqaZeMZ9IJ +gds0ssriKEUpXtei6PeHKnhJsXdUbpqyn+pqVT3R800qkicTXkBjMC1hynFDB4gsQ0v Mcas2t9AVpzg8AU6xBCONt/NC0S3tFJGsL+c9+0H2SEW2s/2gpUPHManYikEUFkezhTi A8G83+podjsPdNH5dUz9o1eG8eEEAzZ3DWkPf8LBpoGwvs7Ra8bvauG686NFPQpsRwfV 23+lL+Lz6Hvlo2hzIao5CAI4G01vgkWLAaMPVKyunxmpBjxA3tLS/+ccrdxy2s7ZpQPb dzkQ== 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 :in-reply-to:references:mime-version:dkim-signature; bh=eY/wEqZtEBvTGf+dl4QWxcEi9yOdjDPWlUK9oEMafxU=; b=cjQOz2E+iAMm0GgQiLbP3DCT789FIErjZq7lvxbMUzfmn0hiKZTae7Xy5xCQj+QYCq 6Q8wuJAeacyxP7O9SY/Ilx6gfdFklmGQvLc8YErIwQFXRAYte1w5Vjk82XV8596N/H/D lL7RLOby7Hid4E/GtbfC+uCuaxyQmhdy+98tq+KsvKrNIPLJpWI1Qtp0sjv3VceDDueT P7oRnLn6b9hE+ZW5tJIRC5s82NwbtP5KjYbLvvFS7qBxfDvK+Y8xwTu2D5QIj42iPmg0 A7oUnXAGS6ce+qE79k2N7sNnfgoyr2nnBrQHMv9JzCPeMyg6G8aV8tQfGc6mYgZKEV3T HLwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vNvjROcP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s31si5287957plb.362.2019.08.05.08.57.08; Mon, 05 Aug 2019 08:57:24 -0700 (PDT) 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=@kernel.org header.s=default header.b=vNvjROcP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729282AbfHEPyt (ORCPT + 99 others); Mon, 5 Aug 2019 11:54:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:49518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729042AbfHEPyt (ORCPT ); Mon, 5 Aug 2019 11:54:49 -0400 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0A9212173C; Mon, 5 Aug 2019 15:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565020488; bh=GqH8P8Sc5z4BoLebSRYjQW+TVTAwhdGRVGtddclJmxY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=vNvjROcPu+7yaOA4CmFHRvfPgFiNVGV+xXMikkoDn+sXkSwDhZ4+5hYxEAbBTD7VG vByLOYoOoBXdEGxacgnA2dPqb//W18X7uaqiqGW4RqdHW1qknvjED9mGzTKWw0WSVb Rv2TVfmT2BZ08O1V8VqJn5W3b2XANdgAoLDEnB9s= Received: by mail-qk1-f182.google.com with SMTP id t187so7775081qke.8; Mon, 05 Aug 2019 08:54:48 -0700 (PDT) X-Gm-Message-State: APjAAAXFX7sL2zEnAQuObWlVVDmA98ZBY0FcbgHQiMVA69M879zuNhBf vg+kvPNvvQMPO4FIV4386Mc8uWkFJb/4IaEigA== X-Received: by 2002:a37:a48e:: with SMTP id n136mr104724739qke.223.1565020487172; Mon, 05 Aug 2019 08:54:47 -0700 (PDT) MIME-Version: 1.0 References: <20190805145211.23161-1-dinguyen@kernel.org> In-Reply-To: <20190805145211.23161-1-dinguyen@kernel.org> From: Rob Herring Date: Mon, 5 Aug 2019 09:54:34 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv2] drivers/amba: add reset control to primecell probe To: Dinh Nguyen Cc: devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Frank Rowand , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck 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 On Mon, Aug 5, 2019 at 8:52 AM Dinh Nguyen wrote: > > The primecell controller on some SoCs, i.e. SoCFPGA, is held in reset by > default. Until recently, the DMA controller was brought out of reset by the > bootloader(i.e. U-Boot). But a recent change in U-Boot, the peripherals that > are not used are held in reset and are left to Linux to bring them out of > reset. > > Add a mechanism for getting the reset property and de-assert the primecell > module from reset if found. This is a not a hard fail if the reset property > is not present in the device tree node, so the driver will continue to probe. > > Because there are different variants of the controller that may have multiple > reset signals, the code will find all reset(s) specified and de-assert them. > > Signed-off-by: Dinh Nguyen > --- > v2: move reset control to bus code > find all reset properties and de-assert them > --- > drivers/amba/bus.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c > index 100e798a5c82..75e18b9e4808 100644 > --- a/drivers/amba/bus.c > +++ b/drivers/amba/bus.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > > #include > > @@ -401,6 +402,18 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent) > ret = amba_get_enable_pclk(dev); > if (ret == 0) { > u32 pid, cid; > + int count; > + struct reset_control *rstc; > + > + /* > + * Find reset control(s) of the amba bus and de-assert them. > + */ > + count = reset_control_get_count(&dev->dev); > + while (count > 0) { > + rstc = of_reset_control_get_shared_by_index(dev->dev.of_node, count - 1); > + reset_control_deassert(rstc); > + count--; > + } Aren't you going to need a put somewhere? And then there's the fun possibility of deferred probe which could happen on any of the resets. Rob