From patchwork Fri Feb 9 10:05:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Fritz X-Patchwork-Id: 10208715 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 3D82F602D8 for ; Fri, 9 Feb 2018 10:06:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20D8229828 for ; Fri, 9 Feb 2018 10:06:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 151172982A; Fri, 9 Feb 2018 10:06:21 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 B285629828 for ; Fri, 9 Feb 2018 10:06:19 +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=Vc1lysus4UC7Yjt4yzP8iXoMGfRiC2L2qXk7NOZrCqs=; b=qvn0R4ruCbuSxR0w7qh7W28w9Y 25iAXo10MHyhWawicFauPuVdJEkVBy2eiGRkPeyJDchcouPjav7n9eAq1t+YwQFWxUj9xOa8dwzxI B8urmBUE4krdZa1wqReMk65UB8r4CxNuoA9lwKp10o95atlP+/XGjyUWm7OB38fIpZUgzkjbPYHmA DjDFnGMN+TNXpdXSChHM52NQHvpNFNnlEZVec2Xrh6V8Oqo4OKyw+EwYUxRvuEJlzsEGlKGAmzTfe w9pM0cN/5nlY67r/OKh6Lbkup0clPmGCSHT6ALTHyet5ydp0deVcj+ku1uJV2b+Zh08rPLXRv2ucZ iBxbOAGA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ek5ZR-00029W-Nx; Fri, 09 Feb 2018 10:06:17 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ek5ZE-0001ip-GT for linux-arm-kernel@lists.infradead.org; Fri, 09 Feb 2018 10:06:08 +0000 Received: by mail-wm0-x243.google.com with SMTP id v71so15190930wmv.2 for ; Fri, 09 Feb 2018 02:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KqRNtNuYbXSrmK5E4oKL7U4zv3DB7vP3VGdV6ff/syk=; b=JDskwU39XP3tdD7S385bVz+J46VQIXFHiarh+3AEQQtWwVKz42KZuNXbJbU58ffyV8 /rKSPXUlx+Hg62GOID3f/Mq6yrLQi4uc9E1i8ZwVCmmZhLZZMB0xFC+7DEGMfdD1xfD/ BezcpYMILRXbI+qj91w1aVXw+Tj9rFmoscshJ0RPlwVL5JqGcjhA8LGpYamjSLZ4J6rj /+wEWBCdC/edD1MfE6uTxD3PpPR5zBwMMD8mmBRYGFjW+lVEzCexhhQKCfy615cUTR10 nEuAbAtCZVp8LGfEk2lp0lHKHWGwagPgbfxu7Q9Iq4iI+2MnuSLBsxW2zSQXRslEqNYA Rv8w== 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=KqRNtNuYbXSrmK5E4oKL7U4zv3DB7vP3VGdV6ff/syk=; b=igqOtR/sT/yhLpvnQ57HEg/WWpHqr4YNm3WVvwmBBghJYjRE2WpIe3uI4vWKSqC2+B WTrsCg2sgTqRzz7ezOUQtyuLxsZMajSaaIldYPjMif+L+Ibp8LAdHiUY6MUHp4e9aZXA VxLsibDVximLEqnyeD1HTGGqDzNjIXI3VavzKXQqGrLVkNU5afoNE03Ocmu8fAvkh3IC zsy4gR0LCUOWE0gn9RNsUrClteAyrie1gSG+3YPJ4HXSNTFiw2Z1lxk+bnXrcFPs+kFI hQCVPOb0fiLH2OaW86OB2PNoiMbRAz9aWzTiL+Y6BU4QdRhCLybOk5UR9mLSZrZB+BFG 9Z+w== X-Gm-Message-State: APf1xPA1Btg93diiFLo1lN2mg8CcDLoIc9xeSIpgIUl0NPuYecd0sxLB vV8z75a2MLU/gdn5/Db5WhM= X-Google-Smtp-Source: AH8x225xu6nFXzxjg9xzUjjX5VVX0zWKnbJNW2nbbUP2CTzbp4tRPkOsYlxrmRl9Na9A/OVtS/Sn9g== X-Received: by 10.28.190.8 with SMTP id o8mr1763049wmf.52.1518170752278; Fri, 09 Feb 2018 02:05:52 -0800 (PST) Received: from lovely.phytec.de (mail.x-arc.co.uk. [217.6.246.34]) by smtp.googlemail.com with ESMTPSA id g8sm1947826wrb.88.2018.02.09.02.05.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 02:05:51 -0800 (PST) From: Christoph Fritz To: Shawn Guo , Rob Herring , Fabio Estevam Subject: [PATCH 1/3] regulator: da9062: add of_map_mode support for bucks Date: Fri, 9 Feb 2018 11:05:19 +0100 Message-Id: <1518170721-28198-2-git-send-email-chf.fritz@googlemail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1518170721-28198-1-git-send-email-chf.fritz@googlemail.com> References: <1518170721-28198-1-git-send-email-chf.fritz@googlemail.com> 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, linux-arm-kernel@lists.infradead.org, Christian Hemp 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 This patch adds of_map_mode support for bucks to set regulator modes from within regulator framework. Signed-off-by: Christoph Fritz Signed-off-by: Christian Hemp Reviewed-by: Fabio Estevam --- drivers/regulator/da9062-regulator.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c index 34a70d9..321abd0 100644 --- a/drivers/regulator/da9062-regulator.c +++ b/drivers/regulator/da9062-regulator.c @@ -119,6 +119,22 @@ static const int da9062_buck_b_limits[] = { 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 }; +static inline unsigned int da9062_map_mode(unsigned int mode) +{ + switch (mode) { + case BUCK_MODE_MANUAL: + return REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY; + case BUCK_MODE_SLEEP: + return REGULATOR_MODE_STANDBY; + case BUCK_MODE_SYNC: + return REGULATOR_MODE_FAST; + case BUCK_MODE_AUTO: + return REGULATOR_MODE_NORMAL; + default: + return -EINVAL; + } +} + static int da9062_set_current_limit(struct regulator_dev *rdev, int min_ua, int max_ua) { @@ -686,6 +702,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK1_A, .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_mode, .sleep = REG_FIELD(DA9062AA_VBUCK1_A, __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -724,6 +741,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK2_A, .desc.vsel_mask = DA9062AA_VBUCK2_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_mode, .sleep = REG_FIELD(DA9062AA_VBUCK2_A, __builtin_ffs((int)DA9062AA_BUCK2_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -762,6 +780,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK3_A, .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_mode, .sleep = REG_FIELD(DA9062AA_VBUCK3_A, __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1, sizeof(unsigned int) * 8 - @@ -800,6 +819,7 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { .desc.vsel_reg = DA9062AA_VBUCK4_A, .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK, .desc.linear_min_sel = 0, + .desc.of_map_mode = da9062_map_mode, .sleep = REG_FIELD(DA9062AA_VBUCK4_A, __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1, sizeof(unsigned int) * 8 -