Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp685012yba; Fri, 12 Apr 2019 11:33:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6ASvmI/gUJQTPbAlkdGwaagllMFCWWvvWvH+0iGPOdFrUABvEAm7F6WOjWqzu9Lbq1/Vo X-Received: by 2002:aa7:8c84:: with SMTP id p4mr59093512pfd.164.1555093987345; Fri, 12 Apr 2019 11:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555093987; cv=none; d=google.com; s=arc-20160816; b=VFqxkvAhrunZtyEdwAlgsGTJfHsv8SIt93kVCsDu09NAuJIY73C6UvllboGTOpZ4Ws GK4D1Lqdsphoy1nhBtmBW0j2VnAAA/jdkmH8ypoqZcFd2k02/cArjCZWQ/cf9vBpXN2B SY+27clVFOdu3Qob8ltqkZC5O4jsowNhYHSaA1q7UErQlUBAGw4HUCPBg+zomQv5jG5c tlOqNGkEboIS8NKkRW8Zp/ajT5oxhcoMYRktCyCbtgPutPEoEgQMDSsSaq9KwOBye3rU tDY0Ckn2bmW4CnyYU/s/9D9Q+KlE2jyZEfHManTogA1WHA2MiefJKNo4DcZIJuvxpn3q 7Pzg== 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=xoLV77StZA8meCMRsUNQLcv6eTPg6RN4e/DctAcAD5w=; b=xsJ9Vc1P8uNqb7c5RqzkIoUG34Gjkvu8dQe1x1aGGmbwr4CbBMX11/g0hN33EABR/C GQjtR4q4U7hd8wurw37Te/hR/f71O/aP8v7ktPSkhxCL37f2Rm9mOzay7ClqlDdum9qU Dh+kYmZsm4wzJZEMG5q4vofw9WOkkWptdOdrK5L1SlTNnJJ91SypxXGMN4fN8IP4JwRm M62z/kyCA+m7Sip0xN9a/IsgJdIUnAKFOELvU/0VXY8R4ifI3lwnyoPe2c+9NF2lmKHW pozP37srLbTgwWw05lZ7XA1Ypdd6/nXAjyTF5MnuyXhyfnI9QoDE26sdbn8agsG2kwYB XctQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iWs6oxVh; 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 j7si36629317pfb.75.2019.04.12.11.32.51; Fri, 12 Apr 2019 11:33:07 -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=iWs6oxVh; 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 S1727129AbfDLScA (ORCPT + 99 others); Fri, 12 Apr 2019 14:32:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:50350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbfDLSbz (ORCPT ); Fri, 12 Apr 2019 14:31:55 -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 D5849218D9; Fri, 12 Apr 2019 18:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555093915; bh=jiLNbmEM7Idc3pt65bEuMUpgmufpjAZ+SN1eZ0ORQxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iWs6oxVhXKz3fFxukKWnf06n7xo5ktMhKIBrgqEQmix2dt51VxdWw8zInpXBCPJow 0Bu04UTV+Yh6W88D236c7BgiZ88E+VnG6Tb7zVWrEmMUY+b/+HbuVeOSSbD2xQO8CT IO3GMq/XwqSl3c5JP3/CgFVDtHsuJyLdHySGm0nU= 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 Subject: [PATCH v4 8/9] clk: Allow parents to be specified via clkspec index Date: Fri, 12 Apr 2019 11:31:49 -0700 Message-Id: <20190412183150.102131-9-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 Some clk providers are simple DT nodes that only have a 'clocks' property without having an associated 'clock-names' property. In these cases, we want to let these clk providers point to their parent clks without having to dereference the 'clocks' property at probe time to figure out the parent's globally unique clk name. Let's add an 'index' property to the parent_data structure so that clk providers can indicate that their parent is a particular index in the 'clocks' DT property. Cc: Miquel Raynal Cc: Jerome Brunet Cc: Russell King Cc: Michael Turquette Cc: Jeffrey Hugo Cc: Chen-Yu Tsai Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 18 +++++++++++------- include/linux/clk-provider.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 42f29fd6bfd8..65fe50b139ea 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -44,6 +44,7 @@ struct clk_parent_map { struct clk_core *core; const char *fw_name; const char *name; + int index; }; struct clk_core { @@ -326,7 +327,8 @@ static struct clk_core *clk_core_lookup(const char *name) /** * clk_core_get - Find the clk_core parent of a clk * @core: clk to find parent of - * @name: name to search for + * @name: name to search for (if string based) + * @index: index to use for search (if DT index based) * * This is the preferred method for clk providers to find the parent of a * clk when that parent is external to the clk controller. The parent_names @@ -358,22 +360,23 @@ static struct clk_core *clk_core_lookup(const char *name) * provider knows about the clk but it isn't provided on this system. * A valid clk_core pointer when the clk can be found in the provider. */ -static struct clk_core *clk_core_get(struct clk_core *core, const char *name) +static struct clk_core *clk_core_get(struct clk_core *core, const char *name, + int index) { struct clk_hw *hw = ERR_PTR(-ENOENT); struct device *dev = core->dev; const char *dev_id = dev ? dev_name(dev) : NULL; struct device_node *np = core->of_node; - if (np) - hw = of_clk_get_hw(np, -1, name); + if (np && index >= 0) + hw = of_clk_get_hw(np, index, name); /* * If the DT search above couldn't find the provider or the provider * didn't know about this clk, fallback to looking up via clkdev based * clk_lookups */ - if (PTR_ERR(hw) == -ENOENT) + if (PTR_ERR(hw) == -ENOENT && name) hw = clk_find_hw(dev_id, name); if (IS_ERR(hw)) @@ -397,8 +400,7 @@ static void clk_core_fill_parent_index(struct clk_core *core, u8 index) if (!parent) parent = ERR_PTR(-EPROBE_DEFER); } else { - if (entry->fw_name) - parent = clk_core_get(core, entry->fw_name); + parent = clk_core_get(core, entry->fw_name, entry->index); if (IS_ERR(parent) && PTR_ERR(parent) == -ENOENT) parent = clk_core_lookup(entry->name); } @@ -3443,6 +3445,7 @@ static int clk_core_populate_parent_map(struct clk_core *core) /* Copy everything over because it might be __initdata */ for (i = 0, parent = parents; i < num_parents; i++, parent++) { + parent->index = -1; if (parent_names) { /* throw a WARN if any entries are NULL */ WARN(!parent_names[i], @@ -3452,6 +3455,7 @@ static int clk_core_populate_parent_map(struct clk_core *core) true); } else if (parent_data) { parent->hw = parent_data[i].hw; + parent->index = parent_data[i].index; ret = clk_cpy_name(&parent->fw_name, parent_data[i].fw_name, false); if (!ret) diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 95d5a9d4e8c3..12fef24b740f 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -255,11 +255,13 @@ struct clk_ops { * @hw: parent clk_hw pointer (used for clk providers with internal clks) * @fw_name: parent name local to provider registering clk * @name: globally unique parent name (used as a fallback) + * @index: parent index local to provider registering clk (if @fw_name absent) */ struct clk_parent_data { const struct clk_hw *hw; const char *fw_name; const char *name; + int index; }; /** -- Sent by a computer through tubes