Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp685254yba; Fri, 12 Apr 2019 11:33:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnz6VQ/MzjzZwQ7WOztjiUBNyzQZdLCW69gslAUbbnQ3+Ug9fAGo5e16ud4UjY9FPQPWAV X-Received: by 2002:a17:902:7483:: with SMTP id h3mr4052517pll.211.1555094006133; Fri, 12 Apr 2019 11:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555094006; cv=none; d=google.com; s=arc-20160816; b=RlSmH196kiOcimGpLm7Y88b/zH7w2kT9RO3QrNj2dvE4vS3t2qI29ddV0Fah69iBHe tuzPws5ik41L/SBKEggXsWkLJTM5oCXIB8Bkrr2rARO0qbljE1WO1+oJgl5r3PhQxxVD z/Nnuu/iqG9lxCisJwD+u/R2zC07bzSYmiCiGuBJ4zyqvxuSszCd1SkoyMXA4oyq8JK9 gPRU0F7aCvysAOGzZXu9w4WIX+D+XC+QfXaz2e40k74/+tD3HI9udnPLTmDtOWCaus7H m1YN3T/Ia+hKyjVfVuudkOi80Ad3tPsf/ZOiFbRbRrZwT/6d/klh+qxuvrPt0JbDmLU4 s3Vg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sniZ26bFvxLPS/dbMvCNWyQEdfoiSoZhkaU9CTiavc8=; b=SSVD4P86efmuQQZ0Z0Gr0NdF1vbOmS8mR+0YrZQ6/FibtijNKFtLR6HvdEhok1PWez OA2WG1QPDKwEbYqgxlPFz7XiTEzddh8YdICGcg39QjSq0NEhh5Gc9n3LFgV3ADkQjqGy GaVbXzUDw91JfImY78SPlofTuXHipM1hNA3MdYkMUj0Oml9znFNZQwTn+BBn6d+31+6D m/0HbVsgJhgcjNDjJaycohRFv+Q6QMrgVeajNLPQWpPpqDA5Lmn7ee2NATWR4oTYyr9E 1C93eiI94w3uTL+wIqf/F4UBhD1ww5PNeviMglJvhDm0tNaGnrGpLKhbKhpKQXGtLmMa bbFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p9Jmaqpg; 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 t1si38120490pgi.330.2019.04.12.11.33.10; Fri, 12 Apr 2019 11:33:26 -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=p9Jmaqpg; 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 S1727216AbfDLScU (ORCPT + 99 others); Fri, 12 Apr 2019 14:32:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbfDLSby (ORCPT ); Fri, 12 Apr 2019 14:31:54 -0400 Received: from mail.kernel.org (unknown [104.132.0.74]) (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 7BD47218FC; Fri, 12 Apr 2019 18:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555093913; bh=zLRmPqxlLQc3AN/GbT8QG3oWhXh1GCS3AdlYegAqcRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p9JmaqpgtwWfs0Y/DwXacpg/lotkuQDpJdkfcMMeA3b2fWgi6i4coXaYPZQwBbWKV N3U6MLwCW5qdbi+59iWg6F15dt+XhA4a9Y+49CWjhYYkLmB6wosFgGD8lBRZ+bvceA KCWy7PnvXORvl31kpYlmRcHTcltX3dWGgGjbdOos= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Miquel Raynal , Jerome Brunet , Russell King , Jeffrey Hugo , Chen-Yu Tsai , Rob Herring Subject: [PATCH v4 5/9] clk: Add of_clk_hw_register() API for early clk drivers Date: Fri, 12 Apr 2019 11:31:46 -0700 Message-Id: <20190412183150.102131-6-sboyd@kernel.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190412183150.102131-1-sboyd@kernel.org> References: <20190412183150.102131-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some circumstances drivers register clks early and don't have access to a struct device because the device model isn't initialized yet. Add an API to let drivers register clks associated with a struct device_node so that these drivers can participate in getting parent clks through DT. Cc: Miquel Raynal Cc: Jerome Brunet Cc: Russell King Cc: Michael Turquette Cc: Jeffrey Hugo Cc: Chen-Yu Tsai Cc: Rob Herring Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 26 +++++++++++++++++++++++--- include/linux/clk-provider.h | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d27775a73e67..ffa63ddcd408 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -45,6 +45,7 @@ struct clk_core { struct clk_hw *hw; struct module *owner; struct device *dev; + struct device_node *of_node; struct clk_core *parent; const char **parent_names; struct clk_core **parents; @@ -3313,7 +3314,8 @@ struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, return clk; } -static struct clk *__clk_register(struct device *dev, struct clk_hw *hw) +static struct clk * +__clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw) { int i, ret; struct clk_core *core; @@ -3339,6 +3341,7 @@ static struct clk *__clk_register(struct device *dev, struct clk_hw *hw) if (dev && pm_runtime_enabled(dev)) core->rpm_enabled = true; core->dev = dev; + core->of_node = np; if (dev && dev->driver) core->owner = dev->driver->owner; core->hw = hw; @@ -3429,7 +3432,7 @@ static struct clk *__clk_register(struct device *dev, struct clk_hw *hw) */ struct clk *clk_register(struct device *dev, struct clk_hw *hw) { - return __clk_register(dev, hw); + return __clk_register(dev, dev_of_node(dev), hw); } EXPORT_SYMBOL_GPL(clk_register); @@ -3445,10 +3448,27 @@ EXPORT_SYMBOL_GPL(clk_register); */ int clk_hw_register(struct device *dev, struct clk_hw *hw) { - return PTR_ERR_OR_ZERO(__clk_register(dev, hw)); + return PTR_ERR_OR_ZERO(__clk_register(dev, dev_of_node(dev), hw)); } EXPORT_SYMBOL_GPL(clk_hw_register); +/* + * of_clk_hw_register - register a clk_hw and return an error code + * @node: device_node of device that is registering this clock + * @hw: link to hardware-specific clock data + * + * of_clk_hw_register() is the primary interface for populating the clock tree + * with new clock nodes when a struct device is not available, but a struct + * device_node is. It returns an integer equal to zero indicating success or + * less than zero indicating failure. Drivers must test for an error code after + * calling of_clk_hw_register(). + */ +int of_clk_hw_register(struct device_node *node, struct clk_hw *hw) +{ + return PTR_ERR_OR_ZERO(__clk_register(NULL, node, hw)); +} +EXPORT_SYMBOL_GPL(of_clk_hw_register); + /* Free memory allocated for a clock. */ static void __clk_release(struct kref *ref) { diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index b7cf80a71293..7d2d97e15b76 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -773,6 +773,7 @@ struct clk *devm_clk_register(struct device *dev, struct clk_hw *hw); int __must_check clk_hw_register(struct device *dev, struct clk_hw *hw); int __must_check devm_clk_hw_register(struct device *dev, struct clk_hw *hw); +int __must_check of_clk_hw_register(struct device_node *node, struct clk_hw *hw); void clk_unregister(struct clk *clk); void devm_clk_unregister(struct device *dev, struct clk *clk); -- Sent by a computer through tubes