From patchwork Fri Mar 9 21:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 131253 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1455715lja; Fri, 9 Mar 2018 13:10:23 -0800 (PST) X-Google-Smtp-Source: AG47ELvCUsEGPtvIAvzziH8KaIKvOtt7StR8tdMDRlzBsZgbngjPmyjezS7VgK9+1XuRSxW6n3QV X-Received: by 2002:a17:902:7290:: with SMTP id d16-v6mr28963893pll.31.1520629823791; Fri, 09 Mar 2018 13:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520629823; cv=none; d=google.com; s=arc-20160816; b=xgGCvf0/eYLqmyV0RX8fL/eEZd5RvowGl55coBLR/K3Vuf+Pj1v2273vlbqiM7SlQN bzEJtKmsTMo/C/eWO0hTkQDizlOZlOs0w68Lmaq0cIK4fZqCNgHXyWFgfJnLJq3b4hCF MTgb419BlAUSw8Sma/Tl/XaAhhhY7QTVamiTHl5SmA9w9eVQfKg+sLqfTgLbCO9XC+NK 7K0UvwNriSOFavjIUjDPLe34l+V+BmEuZHkMNYRnaCFzbqjucJgyxDwoInoMQF3x5pFx ZbOZPCC4Us2YivRQ5ov+xXSQ0BCBY/KGLJyQpJl3PiVdfIv29gztRT6PAmYh945CCpT1 Bf2A== 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=PfprGdt6P4uSbpgw4t5pyaAwr2IR7Kg0L9cn3W82/QU=; b=NC37zcZUbC/++qUImvLfQfeUs3qYflgzxHslwrs22Op76ORiLyFjZ231Fojo71KWNN m96YV+jevoWLPBlv/Dz6l7GnwSv7DcvA2vhfp2viTd7m7epg1UcQkpA3fkJ+3V88Qr6Z X+r7jN7vyG9db3p5EtbERmVp3t/AhKc6hBFJy4yqrjTUI6YcyV/tgIQtplyqSAeLgGP3 //JDe+S5FXWBXdpqcHr2Ni4tN4WCYIEt+PT1k75+7CRx6W6AnxuVL8dwDi4hX1xiTMil 8t+WITc0P4LAuu7zaXrZoI8S0S+AI+RdHj6RImFiIvhqeIQMMMv6jy9Vlikbvasjghcz 1ytg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Z6QAARZo; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 g21si1450961pfh.379.2018.03.09.13.10.23; Fri, 09 Mar 2018 13:10:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Z6QAARZo; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932728AbeCIVKV (ORCPT + 10 others); Fri, 9 Mar 2018 16:10:21 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:39544 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932717AbeCIVKS (ORCPT ); Fri, 9 Mar 2018 16:10:18 -0500 Received: by mail-wr0-f196.google.com with SMTP id r66so2660927wrb.6 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=FBeGduTtRZh+VZFX5v1LQ0CYLrGYt3MzTbEStuhRRYUgwHmKhor883K018WC/tYjt1 T05uFKX9sFWqPgssu8E75G+prrhMZ7i81cnK28vqJNfXFEYqMva85XnwKHmoZ7HXwq7E jjpMppvJEaV8mqKCWfY/rD0hbd9F1jZ8v6G28kAEaachbWiTHkqeajYiNBSqNpVDIUTI eONaD9OM4UEvwpwQxeSTtabxHuDRrMrZj8EKcNBhZFeLSaJrmB+p2dRZLfohpa6f4x1E 3GrKaXXzKBB2js8cHH55gxH5j1H9Fit6Mn0ag9gm/y1uEVLj3klynMfg94A1dpsZEXYb M9BQ== X-Gm-Message-State: APf1xPCJ14G66JlpOFgbXICQ01hjPIHcsW1IoA5sLN+6lW1eEB8OQAkp /Qlv7bj25rHtD/cGps3PGOS51A== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(+) -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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) { }