From patchwork Sat May 12 01:46:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Collins X-Patchwork-Id: 10395727 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 86B5B6053A for ; Sat, 12 May 2018 01:47:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78F8828F41 for ; Sat, 12 May 2018 01:47:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D24328FE8; Sat, 12 May 2018 01:47:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163CA28F41 for ; Sat, 12 May 2018 01:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751375AbeELBrK (ORCPT ); Fri, 11 May 2018 21:47:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47280 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858AbeELBq5 (ORCPT ); Fri, 11 May 2018 21:46:57 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8642960C55; Sat, 12 May 2018 01:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526089616; bh=dNxtqIHvakN+DL3COHGqEe2BL9qft/+QL/6TfxDLOwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=ii2FeK3PmCjbzhXoETdv6WrliaR7GHo1LlC5Twm0jk7A0XNiE9bzw4EEK9DuXjzXj goorEwFHzvuJa05vlAZ1oVgN6odaSM7L9b6YcyLZGcNoXLtYmMyn9vsCXaV2UL2BT6 NSJLt6ka7tNzXV3WVw/OGgMgiIkHq3HbO8/uHmfA= Received: from codeaurora.org (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: collinsd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6B8C46085F; Sat, 12 May 2018 01:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526089615; bh=dNxtqIHvakN+DL3COHGqEe2BL9qft/+QL/6TfxDLOwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=Lr9JoqVrG9VwNzY5hrG/22RGK693hwsdoerJStsaAzFzyOkI0xcFM0C4xELJDewVe znMxT2NBQgL3ClbLCB/SZqe6UqMAy5RI2lekrktcKRX0nAQlYF51bh/f9szvYCsvFp u7SE6gPtSuhOFpB5lvI0o64wK5T+1hd7TaB7N9bo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6B8C46085F Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=collinsd@codeaurora.org From: David Collins To: broonie@kernel.org, lgirdwood@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: David Collins , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, rnayak@codeaurora.org, sboyd@kernel.org, dianders@chromium.org Subject: [PATCH 2/2] regulator: of: add support for allowed modes configuration Date: Fri, 11 May 2018 18:46:47 -0700 Message-Id: <58bb4f965515a67a6cbbc726b0d7b092c22b79d7.1526088289.git.collinsd@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for configuring the machine constraints valid_modes_mask element based on a list of allowed modes specified via a device tree property. Signed-off-by: David Collins Reviewed-by: Douglas Anderson --- drivers/regulator/of_regulator.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 0d3f73e..d61fed2 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -32,7 +32,7 @@ static void of_get_regulation_constraints(struct device_node *np, struct regulator_state *suspend_state; struct device_node *suspend_np; unsigned int mode; - int ret, i; + int ret, i, len; u32 pval; constraints->name = of_get_property(np, "regulator-name", NULL); @@ -136,6 +136,33 @@ static void of_get_regulation_constraints(struct device_node *np, } } + len = of_property_count_elems_of_size(np, "regulator-allowed-modes", + sizeof(u32)); + if (len > 0) { + if (desc && desc->of_map_mode) { + for (i = 0; i < len; i++) { + ret = of_property_read_u32_index(np, + "regulator-allowed-modes", i, &pval); + if (ret) { + pr_err("%s: couldn't read allowed modes index %d, ret=%d\n", + np->name, i, ret); + break; + } + mode = desc->of_map_mode(pval); + if (mode == REGULATOR_MODE_INVALID) + pr_err("%s: invalid regulator-allowed-modes element %u\n", + np->name, pval); + else + constraints->valid_modes_mask |= mode; + } + if (constraints->valid_modes_mask) + constraints->valid_ops_mask + |= REGULATOR_CHANGE_MODE; + } else { + pr_warn("%s: mode mapping not defined\n", np->name); + } + } + if (!of_property_read_u32(np, "regulator-system-load", &pval)) constraints->system_load = pval;