From patchwork Mon Apr 4 18:57:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 8743721 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 053A3C0553 for ; Mon, 4 Apr 2016 18:58:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE81720225 for ; Mon, 4 Apr 2016 18:58:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E25CD20109 for ; Mon, 4 Apr 2016 18:58:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755929AbcDDS5y (ORCPT ); Mon, 4 Apr 2016 14:57:54 -0400 Received: from mail-lb0-f196.google.com ([209.85.217.196]:34730 "EHLO mail-lb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753305AbcDDS5w (ORCPT ); Mon, 4 Apr 2016 14:57:52 -0400 Received: by mail-lb0-f196.google.com with SMTP id vk4so24264651lbb.1; Mon, 04 Apr 2016 11:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=79vvDCej4+TFKxjyYNa6Pi2tsbAYaSBTmJ0lrfOU7bk=; b=PxyFMPH/zyjThc4K6jK7+ttx6ib2M00NjTjrLDwUFncQ4wINOC/ztdxnkIrhs1Apsf j8ikysdyzdUIfig0W7zqGyPt8bddGvaJQkjA/bb0zOPRGf4aR7HSG4I2QsZb1r4va9Uw twjVbc4ZXfTdGgKf9yeRuEtrWOmvl4LSYXGWq6a3W5zp25eQPlOTtA9pDQ7WdszIv1TG 9Z1TF15qGWlUviqGYPC+KsQvbVSVRVqzHxPVnPr5+cUKr5hGKDMbhNDcntwbSEAdy6AA DL/DISPI/DCa/TzTZrfPxBf5VjsI//67ofK1GdW+fDsLWXrMdNuQLy5Phcm0PKxL/Uma R9hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=79vvDCej4+TFKxjyYNa6Pi2tsbAYaSBTmJ0lrfOU7bk=; b=kHN836zVF18JdZDPAafQsnwrFJBt0/W3QDxMbp7h5r0WD969BIakr9Fv0SNDGS+KBe B1TCvsJfnfs3l9yxVKDZXrsujP7CzuknBXLQ2srsGwQGasmwXK242+VYjGmAEVSQI0rI 0PlBMJo+63luHsqUWkswgxpkF6FrIvGmssl4hCqQte6D1iqzVrtaDJuB32vJGQUnCavQ 3LFg5+pQNhB584KCdU3VleWm4Sr7ZWTePRoy7DwbIhfPZY3Sg0ujDrjfSeyh9B+FPaNg 0nFkXafIxXcUFavUWCNKTXMk65SimH24aIBme4a/9qYIM5PuJue4Oh7M/HpnUMnFhg/U R3rg== X-Gm-Message-State: AD7BkJJzb69cqfBVN5hOD3UHc+zO39DKWFSi3DhLS4H6sq5/1Q8ZG20zFpsag7ONSYtBCQ== X-Received: by 10.28.227.130 with SMTP id a124mr13486777wmh.2.1459796270647; Mon, 04 Apr 2016 11:57:50 -0700 (PDT) Received: from localhost.localdomain ([46.249.74.23]) by smtp.gmail.com with ESMTPSA id c128sm15316331wma.11.2016.04.04.11.57.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Apr 2016 11:57:50 -0700 (PDT) From: Ivaylo Dimitrov To: broonie@kernel.org, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, tony@atomide.com, lgirdwood@gmail.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Ivaylo Dimitrov Subject: [PATCH] regulator: twl: Provide of_map_mode for twl4030 Date: Mon, 4 Apr 2016 21:57:14 +0300 Message-Id: <1459796234-2430-1-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20160328093938.GA2350@sirena.org.uk> References: <20160328093938.GA2350@sirena.org.uk> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_map_mode is needed so to be possible to set initial regulators mode from the board DTS. Otherwise, for DT boot, regulators are left in their default state after reset/reboot. Document device specific modes as well. Signed-off-by: Ivaylo Dimitrov --- .../devicetree/bindings/regulator/twl-regulator.txt | 8 ++++++++ drivers/regulator/twl-regulator.c | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/twl-regulator.txt b/Documentation/devicetree/bindings/regulator/twl-regulator.txt index 75b0c16..fe759903 100644 --- a/Documentation/devicetree/bindings/regulator/twl-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/twl-regulator.txt @@ -57,6 +57,14 @@ For twl4030 regulators/LDOs Optional properties: - Any optional property defined in bindings/regulator/regulator.txt +For twl4030 regulators/LDOs: + - regulator-initial-mode: + - 0x00 - Off mode, the output voltage is not maintained and voltage regulator + power consumption is 0. + - 0x08 - Sleep mode, the nominal output voltage is maintained with low power + consumption with low load current capability. + - 0x0e - Active mode, the regulator can deliver its nominal output voltage + with full-load current capability. Example: diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index aad748b0..be8d05e 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -395,6 +395,12 @@ static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) return twl4030_send_pb_msg(message); } +static inline unsigned int twl4030reg_map_mode(unsigned int mode) +{ + return mode == RES_STATE_ACTIVE ? + REGULATOR_MODE_NORMAL : REGULATOR_MODE_STANDBY; +} + static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) { struct twlreg_info *info = rdev_get_drvdata(rdev); @@ -897,10 +903,11 @@ static struct regulator_ops twlsmps_ops = { #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ remap_conf) \ TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ - remap_conf, TWL4030, twl4030fixed_ops) + remap_conf, TWL4030, twl4030fixed_ops, \ + twl4030reg_map_mode) #define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \ TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \ - 0x0, TWL6030, twl6030fixed_ops) + 0x0, TWL6030, twl6030fixed_ops, 0x0) #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \ static const struct twlreg_info TWL4030_INFO_##label = { \ @@ -917,6 +924,7 @@ static const struct twlreg_info TWL4030_INFO_##label = { \ .type = REGULATOR_VOLTAGE, \ .owner = THIS_MODULE, \ .enable_time = turnon_delay, \ + .of_map_mode = twl4030reg_map_mode, \ }, \ } @@ -932,6 +940,7 @@ static const struct twlreg_info TWL4030_INFO_##label = { \ .type = REGULATOR_VOLTAGE, \ .owner = THIS_MODULE, \ .enable_time = turnon_delay, \ + .of_map_mode = twl4030reg_map_mode, \ }, \ } @@ -977,7 +986,7 @@ static const struct twlreg_info TWL6032_INFO_##label = { \ } #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ - family, operations) \ + family, operations, map_mode) \ static const struct twlreg_info TWLFIXED_INFO_##label = { \ .base = offset, \ .id = num, \ @@ -992,6 +1001,7 @@ static const struct twlreg_info TWLFIXED_INFO_##label = { \ .owner = THIS_MODULE, \ .min_uV = mVolts * 1000, \ .enable_time = turnon_delay, \ + .of_map_mode = map_mode, \ }, \ }