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: 10395737 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 2F3B560540 for ; Sat, 12 May 2018 01:49:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F60028FCA for ; Sat, 12 May 2018 01:49:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 140EC28FF4; Sat, 12 May 2018 01:49:00 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8922D28FE8 for ; Sat, 12 May 2018 01:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=WuAym+krKjzHKSaMd3mi/6Fu2BvRc1hupyICAPgOpc8=; b=GfEWvdFLfe9izI8wYq8EkjP114 Zt0o2d/gxBk27P91ypolCRJ4Ro79+2Kov96R47h/k96w0uAKzjqyw3lNRnGQWYln8QH2w7oF/HvO/ es1xdmpVtRNig8AJYROjdjxV9UAQY5Ft0oxRGwFJbkUsTQEFNdAVZEZRnQqH3wX7+LENcueYs0uE1 WUDtdh3KwVQwnitF9nLwKhy0xiuuvRKJQGkqE/pCkFviZYeHpOvfjBjzlyqSCUS7ZRN8AQvxFCyUA bnf6xXp4OFz7GWly1LW7d8+NKVWE3F+E9ZTq8iPnkOZ/ekJy0haqlCfHAnxVxOqEnPBaTsMLAtvjl q0hjfu7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fHJeT-0003gD-E3; Sat, 12 May 2018 01:48:49 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fHJco-0002w4-GV for linux-arm-kernel@lists.infradead.org; Sat, 12 May 2018 01:47:09 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 94D3A60767; 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180511_184706_637794_62EA9107 X-CRM114-Status: GOOD ( 15.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, rnayak@codeaurora.org, David Collins , sboyd@kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dianders@chromium.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;