From patchwork Wed Jun 20 12:11:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 139315 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp711572lji; Wed, 20 Jun 2018 05:12:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL9qwBxV4ZT86WywSg5Uh1amk//5mQdue7TPijw1w+fzMJLlipeZUKK7+gA0b5nVgU3VVzB X-Received: by 2002:a62:da07:: with SMTP id c7-v6mr22479656pfh.106.1529496725996; Wed, 20 Jun 2018 05:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529496725; cv=none; d=google.com; s=arc-20160816; b=x4Am7/US2SY0CNZ+juBFBkvzOzWYz2EpiD5acLQYKIOYGvgYf3o2K/L2rs1rKLipDT bAfOJOVZpamcaRN3UPoGeISGfLwQAYx3G28PoSo9d8FUVcCgXjb3sZ/8VnQ5xq4hn/Vs z8P2QlzFN9xB0Yl58ft7QIGlhGq08wR7ryWblkuzh3mt7VWg4CelOzUKbHQgFlWvTzdA 5BoaAZCTrfudZbIEGYxPaycoAdpPiVgK3yctk/Zu1s12ZisG0Y5mF2K1bArf0cuq5IBh akHBHAnqhIldbIMVUu+RNMko/Pg5x6B0zVWdpWVC/mICWku3u4QLg8EVGD7ZozooiKYL SKHA== 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=5E3iJBFFrio7tuGSnWOLbi/y66jhJ612NEom6Tcob3A=; b=iblZ/hPFUy0gxn13BF9Uu4Q58eFAp8/KLA5FALKbzHUdO0gwPNPGMznR9A4DsDXqGU Fotm7ea8GIcb4sz8FvjksUhXOq6n4u+rYjDbwIJqQ6AaCAp67FFYa9y+flccEx866M4w NGSPcRfuGsmZuY3Fqmk2epDj1boIlJMA0PJeZk838oYmj3/3hAJb76fGwvBBMj6rXFX1 Yf01K7q+s7idrX6kvK7GKcPUq4X8bdf57BxynqsEM62vYQzumonA/gW2OWX98tac8gOs I73e2mI0S4VB19u+8T1KE0802s4y5+8KwcJg84zlgP4+PTFCbDkqHWVe1R2sUs7kSzCx rGog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OIXjf1ze; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 s25-v6si1697670pgd.188.2018.06.20.05.12.05; Wed, 20 Jun 2018 05:12:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=OIXjf1ze; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1753972AbeFTMMC (ORCPT + 10 others); Wed, 20 Jun 2018 08:12:02 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33216 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753882AbeFTML7 (ORCPT ); Wed, 20 Jun 2018 08:11:59 -0400 Received: by mail-wm0-f66.google.com with SMTP id z6-v6so22530717wma.0 for ; Wed, 20 Jun 2018 05:11:58 -0700 (PDT) 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=5E3iJBFFrio7tuGSnWOLbi/y66jhJ612NEom6Tcob3A=; b=OIXjf1zeSod9R6cDfvXQ4qE1VQhZoGYaUWJ7evQIMPuUNOmHSeIc+oIEQwB3C8Ahnk bpmi88vYtpS4Gdj9jP81RFOeskO/2yJ/hiq/SBIBKvmgpPfRs81x1wpfxIzdpAWV1XW7 XEumiJfCI+AXzxjY1lvsxRRcKixc4nUUxLi5E= 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=5E3iJBFFrio7tuGSnWOLbi/y66jhJ612NEom6Tcob3A=; b=Gk/p2qjnacJwadmx0DFytYIDqup8D3ayYOsXZZLW4qhYsKnHr9Gy5coNVwEUsR+CW8 KxS1khLDePMqs4d6FjvNAoLmgIogdzBbNVOeofKaKNkIFj4uMRENEJfZEUDLcG8wQmRB 6GAe7aJBxjKljznYeltxuw1rceKaXk+L1gNsbF+dv51tRucKbXg9Il4FlNUfXeDwbON2 FetWkzH861rhL4NRajklYCW5CMyAJkxqZyCM5a73WQJ/GoYqNxblFUqkXBfZHPQNvpbn 8zZSyZBuF2cPAlJwk/A2njfAzjQ8A3gISIlDa9QCsX9K5q1tu7bsECfLYrDt5r5lvQzq KU8g== X-Gm-Message-State: APt69E2wT7hwBPlFwYX3H82S6g8gKAAIUaue9KAbnx4Vr+NvzSQxdL+/ M45sy8mm6fML9QRQIY0nxrNX2zVzkT8= X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr1435580wmb.147.1529496717923; Wed, 20 Jun 2018 05:11:57 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id e14-v6sm1656483wmh.17.2018.06.20.05.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jun 2018 05:11:57 -0700 (PDT) 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, daidavid1@codeaurora.org, evgreen@chromium.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, abailon@baylibre.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v5 8/8] interconnect: Allow endpoints translation via DT Date: Wed, 20 Jun 2018 15:11:41 +0300 Message-Id: <20180620121141.15403-9-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620121141.15403-1-georgi.djakov@linaro.org> References: <20180620121141.15403-1-georgi.djakov@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 lead 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 | 62 ++++++++++++++++++++++++++++++++++++ include/linux/interconnect.h | 7 ++++ 2 files changed, 69 insertions(+) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index dafc001ce758..2f07807ca4b4 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); @@ -306,6 +307,67 @@ static int apply_constraints(struct icc_path *path) return ret; } +struct icc_path *of_icc_get(struct device *dev, const char *name) +{ + struct device_node *np = NULL; + struct of_phandle_args src_args, dst_args; + u32 src_id, dst_id; + int idx = 0; + int ret; + + if (!dev || !dev->of_node) + return ERR_PTR(-ENODEV); + + np = dev->of_node; + + /* + * When the consumer DT node do not have "interconnects" property + * return a NULL path to skip setting constraints. + */ + if (!of_find_property(np, "interconnects", NULL)) + return NULL; + + /* + * 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. + */ + if (name) { + idx = of_property_match_string(np, "interconnect-names", name); + if (idx < 0) + return ERR_PTR(idx); + } + + ret = of_parse_phandle_with_args(np, "interconnects", + "#interconnect-cells", idx * 2, + &src_args); + if (ret) + return ERR_PTR(ret); + + of_node_put(src_args.np); + + if (!src_args.args_count || src_args.args_count > 1) + return ERR_PTR(-EINVAL); + + src_id = src_args.args[0]; + + ret = of_parse_phandle_with_args(np, "interconnects", + "#interconnect-cells", idx * 2 + 1, + &dst_args); + if (ret) + return ERR_PTR(ret); + + of_node_put(dst_args.np); + + if (!dst_args.args_count || dst_args.args_count > 1) + return ERR_PTR(-EINVAL); + + dst_id = dst_args.args[0]; + + return icc_get(dev, 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 593215371fd6..ae6744da9bc2 100644 --- a/include/linux/interconnect.h +++ b/include/linux/interconnect.h @@ -17,6 +17,7 @@ struct device; struct icc_path *icc_get(struct device *dev, 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); @@ -28,6 +29,12 @@ static inline struct icc_path *icc_get(struct device *dev, const int src_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) { }