Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1544869imm; Fri, 11 May 2018 18:47:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr19STaMNEKf06n9hD+XQMMDoRR6kxpf+CBx9P/bXxHvi/tiS8gKIU+QKnDJUhR8Xrn/mcq X-Received: by 2002:a63:be4b:: with SMTP id g11-v6mr1155676pgo.41.1526089669083; Fri, 11 May 2018 18:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526089669; cv=none; d=google.com; s=arc-20160816; b=ujf54UaKS5j2Lkez/xxl5GHYzEo1/tJPRSCDVbTGxMlIc1KnsZelhXe5Ty1TjLp1Kg 2ennkWp6ydyXvXQ7GGgcm+B/zg0l2utjKszy8T2O/RLPVfcDOZuKrnURZr69Sl8nByvn 7KdcmYn7jtioWgMpyXGVFieU7CE30HSTQEZ8lB8kz3MRvfR16A8I/9+CbG0e9sEVwGL1 fL2GlHWYs7u4ib/r/t4kFyiuPi8oPzUIN3V/e5Uy4y/cUj+iKnrfQdaiLNqWt9vmFPmV BwmLZ6I5nHE7hhrO0y8nd8dXCb3guUj5hfqu1fv6orhDfqQi0XMRZNYxIIXDLuae4Emj 1Ixg== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=gwL/S4tpxNcteSPicNRB1GxEgVIMcZQDm9U/fO3ktnw=; b=cUGHaByu56RpiDVtemISNXFGyA99pR/a4OC1ZemnekASBa5D5zZ81FD2G97alUPIMv rANvQF5dOmR5I8LrV3rNIGzisUUSGQfm4siRVzexs4iQl48EEJ080BX3AtfSrInnyMkC 1StW6nCdh+Z7mWqHagcZEf/SWDCvcc++vMyiqwaDjHtC29oJQuSv799PnLA9C9B3fn3y iK6TtXS+lvMBIyjGSR+Jt79LvMZXgf8nqh6R2HLBRygPWIs8fcgPJ6F/O4rQKmLhZzPB 6cEi693NisfXh3gCbq7XT4+FWSxDKhqgNTPo2DEWDCm1G8ijBkhHacvVjB7+ys+GVjCY qxiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=ii2FeK3P; dkim=pass header.i=@codeaurora.org header.s=default header.b=Lr9JoqVr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b34-v6si3899217pld.272.2018.05.11.18.47.34; Fri, 11 May 2018 18:47:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@codeaurora.org header.s=default header.b=ii2FeK3P; dkim=pass header.i=@codeaurora.org header.s=default header.b=Lr9JoqVr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751564AbeELBrL (ORCPT + 99 others); Fri, 11 May 2018 21:47:11 -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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project