All of lore.kernel.org
 help / color / mirror / Atom feed
From: Georgi Djakov <georgi.djakov@linaro.org>
To: linux-pm@vger.kernel.org, gregkh@linuxfoundation.org
Cc: rjw@rjwysocki.net, robh+dt@kernel.org, mturquette@baylibre.com,
	khilman@baylibre.com, vincent.guittot@linaro.org,
	skannan@codeaurora.org, bjorn.andersson@linaro.org,
	amit.kucheria@linaro.org, seansw@qti.qualcomm.com,
	davidai@quicinc.com, mark.rutland@arm.com,
	lorenzo.pieralisi@arm.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org
Subject: [PATCH v4 7/7] interconnect: Allow endpoints translation via DT
Date: Fri,  9 Mar 2018 23:09:58 +0200	[thread overview]
Message-ID: <20180309210958.16672-8-georgi.djakov@linaro.org> (raw)
In-Reply-To: <20180309210958.16672-1-georgi.djakov@linaro.org>

Currently we support only platform data for specifying the interconnect
endpoints. As now the endpoints are hard-coded into the consumer driver
this may leed to complications when a single driver is used by multiple
SoCs, which may have different interconnect topology.
To avoid cluttering the consumer drivers, introduce a translation function
to help us get the board specific interconnect data from device-tree.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
---
 drivers/interconnect/core.c  | 38 ++++++++++++++++++++++++++++++++++++++
 include/linux/interconnect.h |  6 ++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index a06f752a6aaa..014993473763 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 #include <linux/uaccess.h>
 
 static DEFINE_IDR(icc_idr);
@@ -297,6 +298,43 @@ static int constraints_apply(struct icc_path *path)
 	return 0;
 }
 
+struct icc_path *of_icc_get(struct device *dev, const char *name)
+{
+	struct device_node *np;
+	u32 src_id, dst_id;
+	int index, ret;
+
+	if (!dev || !name)
+		return NULL;
+
+	np = dev->of_node;
+
+	index = of_property_match_string(np, "interconnect-names", name);
+	if (index < 0)
+		return ERR_PTR(index);
+
+	/*
+	 * We use a combination of phandle and specifier for endpoint. For now
+	 * lets support only global ids and extend this is the future if needed
+	 * without breaking DT compatibility.
+	 */
+	ret = of_property_read_u32_index(np, "interconnects", index * 2 + 1,
+					 &src_id);
+	if (ret) {
+		dev_err(dev, "interconnect src port is invalid (%d)\n", ret);
+		return ERR_PTR(ret);
+	}
+	ret = of_property_read_u32_index(np, "interconnects", index * 2 + 3,
+					 &dst_id);
+	if (ret) {
+		dev_err(dev, "interconnect dst port is invalid (%d)\n", ret);
+		return ERR_PTR(ret);
+	}
+
+	return icc_get(src_id, dst_id);
+}
+EXPORT_SYMBOL_GPL(of_icc_get);
+
 /**
  * icc_set() - set constraints on an interconnect path between two endpoints
  * @path: reference to the path returned by icc_get()
diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h
index 5a7cf72b76a5..996c48ea67d5 100644
--- a/include/linux/interconnect.h
+++ b/include/linux/interconnect.h
@@ -16,6 +16,7 @@ struct device;
 #if IS_ENABLED(CONFIG_INTERCONNECT)
 
 struct icc_path *icc_get(const int src_id, const int dst_id);
+struct icc_path *of_icc_get(struct device *dev, const char *name);
 void icc_put(struct icc_path *path);
 int icc_set(struct icc_path *path, u32 avg_bw, u32 peak_bw);
 
@@ -26,6 +27,11 @@ static inline struct icc_path *icc_get(const int src_id, const int dst_id)
 	return NULL;
 }
 
+static inline struct icc_path *of_icc_get(struct device *dev, const char *name)
+{
+	return NULL;
+}
+
 static inline void icc_put(struct icc_path *path)
 {
 }

WARNING: multiple messages have this Message-ID (diff)
From: georgi.djakov@linaro.org (Georgi Djakov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 7/7] interconnect: Allow endpoints translation via DT
Date: Fri,  9 Mar 2018 23:09:58 +0200	[thread overview]
Message-ID: <20180309210958.16672-8-georgi.djakov@linaro.org> (raw)
In-Reply-To: <20180309210958.16672-1-georgi.djakov@linaro.org>

Currently we support only platform data for specifying the interconnect
endpoints. As now the endpoints are hard-coded into the consumer driver
this may leed to complications when a single driver is used by multiple
SoCs, which may have different interconnect topology.
To avoid cluttering the consumer drivers, introduce a translation function
to help us get the board specific interconnect data from device-tree.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
---
 drivers/interconnect/core.c  | 38 ++++++++++++++++++++++++++++++++++++++
 include/linux/interconnect.h |  6 ++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index a06f752a6aaa..014993473763 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 #include <linux/uaccess.h>
 
 static DEFINE_IDR(icc_idr);
@@ -297,6 +298,43 @@ static int constraints_apply(struct icc_path *path)
 	return 0;
 }
 
+struct icc_path *of_icc_get(struct device *dev, const char *name)
+{
+	struct device_node *np;
+	u32 src_id, dst_id;
+	int index, ret;
+
+	if (!dev || !name)
+		return NULL;
+
+	np = dev->of_node;
+
+	index = of_property_match_string(np, "interconnect-names", name);
+	if (index < 0)
+		return ERR_PTR(index);
+
+	/*
+	 * We use a combination of phandle and specifier for endpoint. For now
+	 * lets support only global ids and extend this is the future if needed
+	 * without breaking DT compatibility.
+	 */
+	ret = of_property_read_u32_index(np, "interconnects", index * 2 + 1,
+					 &src_id);
+	if (ret) {
+		dev_err(dev, "interconnect src port is invalid (%d)\n", ret);
+		return ERR_PTR(ret);
+	}
+	ret = of_property_read_u32_index(np, "interconnects", index * 2 + 3,
+					 &dst_id);
+	if (ret) {
+		dev_err(dev, "interconnect dst port is invalid (%d)\n", ret);
+		return ERR_PTR(ret);
+	}
+
+	return icc_get(src_id, dst_id);
+}
+EXPORT_SYMBOL_GPL(of_icc_get);
+
 /**
  * icc_set() - set constraints on an interconnect path between two endpoints
  * @path: reference to the path returned by icc_get()
diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h
index 5a7cf72b76a5..996c48ea67d5 100644
--- a/include/linux/interconnect.h
+++ b/include/linux/interconnect.h
@@ -16,6 +16,7 @@ struct device;
 #if IS_ENABLED(CONFIG_INTERCONNECT)
 
 struct icc_path *icc_get(const int src_id, const int dst_id);
+struct icc_path *of_icc_get(struct device *dev, const char *name);
 void icc_put(struct icc_path *path);
 int icc_set(struct icc_path *path, u32 avg_bw, u32 peak_bw);
 
@@ -26,6 +27,11 @@ static inline struct icc_path *icc_get(const int src_id, const int dst_id)
 	return NULL;
 }
 
+static inline struct icc_path *of_icc_get(struct device *dev, const char *name)
+{
+	return NULL;
+}
+
 static inline void icc_put(struct icc_path *path)
 {
 }

  parent reply	other threads:[~2018-03-09 21:09 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 21:09 [PATCH v4 0/7] Introduce on-chip interconnect API Georgi Djakov
2018-03-09 21:09 ` Georgi Djakov
2018-03-09 21:09 ` [PATCH v4 1/7] interconnect: Add generic " Georgi Djakov
2018-03-09 21:09   ` Georgi Djakov
2018-03-09 21:09   ` Georgi Djakov
2018-04-06 17:38   ` Matthias Kaehlcke
2018-04-06 17:38     ` Matthias Kaehlcke
2018-04-12 13:06     ` Georgi Djakov
2018-04-12 13:06       ` Georgi Djakov
2018-05-11 21:30   ` Evan Green
2018-05-11 21:30     ` Evan Green
2018-06-06 14:59     ` Georgi Djakov
2018-06-06 14:59       ` Georgi Djakov
2018-06-06 18:09       ` Georgi Djakov
2018-06-06 18:09         ` Georgi Djakov
2018-06-07  1:06         ` Evan Green
2018-06-07  1:06           ` Evan Green
2018-06-07  1:06           ` Evan Green
2018-05-25  8:26   ` Amit Kucheria
2018-05-25  8:26     ` Amit Kucheria
2018-06-06 15:08     ` Georgi Djakov
2018-06-06 15:08       ` Georgi Djakov
2018-06-08 15:57   ` Alexandre Bailon
2018-06-08 15:57     ` Alexandre Bailon
2018-06-09 19:15     ` Georgi Djakov
2018-06-09 19:15       ` Georgi Djakov
2018-03-09 21:09 ` [PATCH v4 2/7] dt-bindings: Introduce interconnect provider bindings Georgi Djakov
2018-03-09 21:09   ` Georgi Djakov
2018-03-18 22:50   ` Bjorn Andersson
2018-03-18 22:50     ` Bjorn Andersson
2018-03-19  9:34     ` Georgi Djakov
2018-03-19  9:34       ` Georgi Djakov
2018-04-12 13:15   ` Neil Armstrong
2018-04-12 13:15     ` Neil Armstrong
2018-06-06 15:23     ` Georgi Djakov
2018-06-06 15:23       ` Georgi Djakov
2018-03-09 21:09 ` [PATCH v4 3/7] interconnect: Add debugfs support Georgi Djakov
2018-03-09 21:09   ` Georgi Djakov
2018-03-09 21:09 ` [PATCH v4 4/7] interconnect: qcom: Add RPM communication Georgi Djakov
2018-03-09 21:09   ` Georgi Djakov
2018-05-11 21:30   ` Evan Green
2018-05-11 21:30     ` Evan Green
2018-06-06 15:00     ` Georgi Djakov
2018-06-06 15:00       ` Georgi Djakov
2018-03-09 21:09 ` [PATCH v4 5/7] interconnect: qcom: Add msm8916 interconnect provider driver Georgi Djakov
2018-03-09 21:09   ` Georgi Djakov
2018-04-05 22:58   ` Matthias Kaehlcke
2018-04-05 22:58     ` Matthias Kaehlcke
2018-04-12 13:09     ` Georgi Djakov
2018-04-12 13:09       ` Georgi Djakov
2018-05-11 21:29   ` Evan Green
2018-05-11 21:29     ` Evan Green
2018-06-06 15:03     ` Georgi Djakov
2018-06-06 15:03       ` Georgi Djakov
2018-05-25  8:27   ` Amit Kucheria
2018-05-25  8:27     ` Amit Kucheria
2018-06-06 15:14     ` Georgi Djakov
2018-06-06 15:14       ` Georgi Djakov
2018-03-09 21:09 ` [PATCH v4 6/7] dt-bindings: Introduce interconnect consumers bindings Georgi Djakov
2018-03-09 21:09   ` Georgi Djakov
2018-03-18 22:49   ` Bjorn Andersson
2018-03-18 22:49     ` Bjorn Andersson
2018-03-19  9:41     ` Georgi Djakov
2018-03-19  9:41       ` Georgi Djakov
2018-03-09 21:09 ` Georgi Djakov [this message]
2018-03-09 21:09   ` [PATCH v4 7/7] interconnect: Allow endpoints translation via DT Georgi Djakov
2018-05-11 21:29   ` Evan Green
2018-05-11 21:29     ` Evan Green

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180309210958.16672-8-georgi.djakov@linaro.org \
    --to=georgi.djakov@linaro.org \
    --cc=amit.kucheria@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=davidai@quicinc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=seansw@qti.qualcomm.com \
    --cc=skannan@codeaurora.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.