From patchwork Wed Aug 26 11:50:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248409 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp4241180ils; Wed, 26 Aug 2020 04:54:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVFyOHpY0K6P7t6xkljS+CIhwC3y2AyTS8po+qWTqUn0kGaKmCnhFTU6v5C+jc5khZJY4t X-Received: by 2002:a05:6402:212:: with SMTP id t18mr15193537edv.124.1598442857543; Wed, 26 Aug 2020 04:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598442857; cv=none; d=google.com; s=arc-20160816; b=ABIs6WNSI1dlJnPBg+ysufs5d+VB3Gg4JWOdZjsnlzLSTJObI09Xqfkf+/Lu9xRLy8 gUSVFOoRerh6NBX3YJh9ZJMm3W2WE9WkzqbLuMI3hXNZKglb8Ji6xfxb5FxbaKd5YHCN kJg7WT96sMDy1jqZ8QezonCI3X8OCD+fRjuoWNszKgi5RPOdrgKe0qn3Zs9oixqivMyl SIE1h9FKj12/JDIBYn45TTz1RqHuj65AdEv3FXBdPnGUlS53wqXaoRLpj6ORbvvoQXes EvEmHI35J2g8bXicl6Z+ia8e5G1B1BaUlaJhKbeaIfivcsrIIeui4p0hQHPhORLncD8E gAGQ== 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=tryfDmsq8J+S8CIysHu14Sy9xIe8k9L5z/SAmRPWEvQ=; b=esk+JTzlTFiBSWPwmUif+W0vdZ9/WCh1ZTqXHtalulff7GQi6ZwiLwoNAJVLAQpNFF g3gSvj1iaXj8TWiSag/QuuJN2OSSM59Gj2AQqE1Z8ZHJceZjOoqcAUIyKOGq1XWb1S9b ogdLNqOqvkU23IKVvmXbvY4ajUaIRbn/7Q5mW2OTskfPw984dBNU20g/Iqz4g/qvm8rp jjmHYB9JXSYiQtEqcwJ5P6xOr5+KPVzC8mVxVSAep2jEDHN2BxZ+b+nJbUNE5BiHiNHW 7OKgRNd6eyFEfwIlTdnSw4zn1oy1oObGW+DuI/On6i7UzpqOislkg+8UpiROv8sEHBRU GpCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K9S6Gl/y"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id l11si1429333ejx.280.2020.08.26.04.54.17; Wed, 26 Aug 2020 04:54:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K9S6Gl/y"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 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 S1729251AbgHZLyQ (ORCPT + 10 others); Wed, 26 Aug 2020 07:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729169AbgHZLur (ORCPT ); Wed, 26 Aug 2020 07:50:47 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091CDC061797 for ; Wed, 26 Aug 2020 04:50:47 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id p11so838480pfn.11 for ; Wed, 26 Aug 2020 04:50:47 -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 :mime-version:content-transfer-encoding; bh=tryfDmsq8J+S8CIysHu14Sy9xIe8k9L5z/SAmRPWEvQ=; b=K9S6Gl/yPJf+4iRIOJURLX0jZIfzzKuoLqIWdhAwGNvRwUtT7rlO+a91+tpquF6m63 TqKnKg0EmKJmU1iAU7ZRvzgTJhWy5MlAsKJ727GsNY7I3yeh4calb536VT5LQUKuKsME LJJerq2jwlelEqub3qvFIjfL7M8AcQEzhnOO0AwvM544Bqgbb3NVL9X3X0UWBJFGalye BGqrpBUU8y4ua1rv9gYqbfNfuXkc7qKOQol/C1JpQl02XwFgq6XBF52SrkhA8aHoi4Yv iTUGdM5pYqeVBft3p0T+exfAUm5tzMi0oDDaH+NWRLAdUTcUYp4O8ycUnR62H6rUFx0r +kTg== 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:mime-version:content-transfer-encoding; bh=tryfDmsq8J+S8CIysHu14Sy9xIe8k9L5z/SAmRPWEvQ=; b=DbVETxLz0SY5QMOj1UxYDtGVslWCYZ3/aba9vyG2MMpKl5XbsQ0DnTG3ld1BYrNUq9 z6BYyoME9icFG9QVeIWHsGXgltnwUp1Qx5CsMmlQgdFsTpP7sJqTwH2A3GEsT5W/pBHI ymHebpkzyX7UZSifzrpVVidWh4N4fLj+R1ncmti529nVKYJPbNHs/vU4pqRGrQAcp8uG 7v/DaIB0HfPxOwk0BQdNp1C22HMkP7pMA4GHJQfihvQ19lvPZzgEIGIp3UZMvvTNyZu0 3qPZlP6vpDqYxLrLv//f7RjY9C+wOtBF+pRR1FmYpmjfalzNLTIMhUadzYOVYiaSZ1wO t8kw== X-Gm-Message-State: AOAM532wW3eV9EVkf2CE35xDU/VhuGvNdm23DbrzGhE5bFoxALoAOC2p ONQnTuZuAHSibvWWKVqFpn8l1w== X-Received: by 2002:a65:50c1:: with SMTP id s1mr9999244pgp.341.1598442646550; Wed, 26 Aug 2020 04:50:46 -0700 (PDT) Received: from localhost ([122.172.43.13]) by smtp.gmail.com with ESMTPSA id c8sm2632593pfc.203.2020.08.26.04.50.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2020 04:50:45 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , Rob Herring , Dmitry Osipenko , Stephan Gerhold , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] opp: Allow opp-supported-hw to contain multiple versions Date: Wed, 26 Aug 2020 17:20:29 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The bindings allow multiple versions to be passed to "opp-supported-hw" property, either of which can result in enabling of the OPP. Update code to allow that. Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af Tested-by: Stephan Gerhold Tested-by: Dmitry Osipenko diff --git a/drivers/opp/of.c b/drivers/opp/of.c index e39ddcc779af..5dac8bffd68c 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -434,9 +434,9 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_find_icc_paths); static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, struct device_node *np) { - unsigned int count = opp_table->supported_hw_count; - u32 version; - int ret; + unsigned int levels = opp_table->supported_hw_count; + int count, versions, ret, i, j; + u32 val; if (!opp_table->supported_hw) { /* @@ -451,21 +451,40 @@ static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, return true; } - while (count--) { - ret = of_property_read_u32_index(np, "opp-supported-hw", count, - &version); - if (ret) { - dev_warn(dev, "%s: failed to read opp-supported-hw property at index %d: %d\n", - __func__, count, ret); - return false; + count = of_property_count_u32_elems(np, "opp-supported-hw"); + if (count <= 0 || count % levels) { + dev_err(dev, "%s: Invalid opp-supported-hw property (%d)\n", + __func__, count); + return false; + } + + versions = count / levels; + + /* All levels in at least one of the versions should match */ + for (i = 0; i < versions; i++) { + bool supported = true; + + for (j = 0; j < levels; j++) { + ret = of_property_read_u32_index(np, "opp-supported-hw", + i * levels + j, &val); + if (ret) { + dev_warn(dev, "%s: failed to read opp-supported-hw property at index %d: %d\n", + __func__, i * levels + j, ret); + return false; + } + + /* Check if the level is supported */ + if (!(val & opp_table->supported_hw[j])) { + supported = false; + break; + } } - /* Both of these are bitwise masks of the versions */ - if (!(version & opp_table->supported_hw[count])) - return false; + if (supported) + return true; } - return true; + return false; } static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,