Received: by 10.223.185.111 with SMTP id b44csp760254wrg; Fri, 9 Mar 2018 13:12:17 -0800 (PST) X-Google-Smtp-Source: AG47ELuch9Zv496xJZd0BquC/2qmN7i4RHc32AYzgaBXqMFVLbas8HI+5vsvnijI/8EzPc8di+Jp X-Received: by 10.99.123.92 with SMTP id k28mr25568789pgn.167.1520629937645; Fri, 09 Mar 2018 13:12:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520629937; cv=none; d=google.com; s=arc-20160816; b=rTHhZmHs8RKrwNxWKuEDLKuXbe6XjpnZQN0vmChkbb8KYOq3Fqnv1ar41NsNCR95Zw 8Qo/I3I7mfBJ/Q5vLHtfcFi5s2D/WoAywTCXpymhlvSfWlVKFEcVX9XoE+yITaLIO08O pOOulbs9G2jbKRb3FDcwJ47/VtRd+Y5/wEeBXi2Zdj+v0Nxtjd1O5maR+xgxrnV+mR3j m6OKtJg5lxOBRewY+nT8eESqTXvzQgG8+qiuT6AM+mDjXVMum2uEfN+rmxX06YSicQ5D KUZQZPbbtZ85SqxSB4i3Lj52XqKkYbZpOpGNW5eD2WvbmyoEcPdsSdm0rA5oixxJ0qY4 WuuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ubl75YrZdeVmEqG+voml2HeBoZ7TZ2oNfWbg7nL2iU8=; b=lzyl3HC8b2AFniWF3bHEuyC+VTZd/BguYoiySz9EOmTYOJ/zikzT0QkoS6wO39nLBv i+FOdvD10m+iyK8NGGEwgqkams5qKhyaUsZXO2ateYWU0BiUKhiuTa/WK+Q7ncmw2gYe p/YKqrsA4/t9x7a9cOe6FfvKyJKpscdlYXXFXruOyxjEBAiKsq2/fTxewLWe8q5MACxu CVECTaqENf3a+bves/i9p8j0KMWiFXX9ug+0q7cOMwhX3GqPiqq5Hl+x5tfPr4J5mVm/ 0/Nv2IzK2xjCDQ0/PEfz/IqDGj+aRgMoH31d4qyTy+iolhd0O7lHy9JY7EIjvNpqXcLv deWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z6QAARZo; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m22si1242096pgv.643.2018.03.09.13.12.03; Fri, 09 Mar 2018 13:12:17 -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=@linaro.org header.s=google header.b=Z6QAARZo; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932791AbeCIVLA (ORCPT + 99 others); Fri, 9 Mar 2018 16:11:00 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:32991 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932643AbeCIVKS (ORCPT ); Fri, 9 Mar 2018 16:10:18 -0500 Received: by mail-wr0-f193.google.com with SMTP id v18so10255233wrv.0 for ; Fri, 09 Mar 2018 13:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ubl75YrZdeVmEqG+voml2HeBoZ7TZ2oNfWbg7nL2iU8=; b=Z6QAARZoXws/5YhbWX9ngI4A6rh8acAMr+swwM37Jaibjz+iaxCgJ9cf00GYemvqpo sL9z0WVb3shp1kPOng1vBvJlt1Uyd607OTa9zYqj+BHYKOdcoVCvH/uFseNOBPaXXXvr GeBJzSeMWMfC+qgbaWamFLViBK3l4WTnEBLh8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ubl75YrZdeVmEqG+voml2HeBoZ7TZ2oNfWbg7nL2iU8=; b=Hq7Ly3gWYirJpbWqoj38IMzm0WCzTUwMvasIVzkpwMSDI6kl/P+YmfppweB8Px3x+O uk457aa7JBrQ+gu7nWyFm653v7Q/DPSQxWBp96+XxrKs7yy4rTz0vAlQ6NXGIVClY0bZ tM5+Ode3Vx3ZiNbyYnBF/DzHBpN5Rt4BXhYFWnjHSr11BorVKXDDOQ9BgKQndLap0Jvt vQlhVKtYHeZzq1XovFt09Tdub4TDucamju621YEeSaeUmTSXUFJHPyWpe/kcgfO9u8XH 8kjwPGkAvRGZfApvhvZZjoZ2FXkNS6EKq6Zw4O968AyzUCstXxhZ3uY06SDwB3ycYSzE v8Ew== X-Gm-Message-State: APf1xPC1Hg727jCcxng8S8dLk187FV3/hMLu3dnnVXxZss/ffW0dV9M7 fxA1ZXj56ZYLIVMZT2uG89d1Sg== X-Received: by 10.223.186.66 with SMTP id t2mr29517993wrg.155.1520629817051; Fri, 09 Mar 2018 13:10:17 -0800 (PST) Received: from mms-0441.qualcomm.mm-sol.com ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id g7sm1853118wrb.78.2018.03.09.13.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 13:10:16 -0800 (PST) From: Georgi Djakov 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 Message-Id: <20180309210958.16672-8-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180309210958.16672-1-georgi.djakov@linaro.org> References: <20180309210958.16672-1-georgi.djakov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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 #include #include +#include #include 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) { }