From patchwork Fri Jun 20 17:26:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 32288 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E1EC3203F4 for ; Fri, 20 Jun 2014 17:26:34 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id 20sf8713517yks.11 for ; Fri, 20 Jun 2014 10:26:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=okeTIZ5v1drD18yiLQDsCmnwFKA1mNoH7iMLPTVV/2w=; b=COsZMYBL0pX28SdeH4nMT8ZpUgafpf9wWxLqv0NYkUcQosuB8sv1aHrLMOnTksBXXw gssA9TcEyNcd4q9OMnpQbQ8zF0m7KI7JrT7bsVubC0Dsgh6Db3zjbSIG7J6XIqEaIj7w FfaLHZHxRhENn2T8OxUtf1NnQG2AXWD5I64J5zkRwBtJdWLP1DtcNrg5F5K1Anf03QHy HuJdDX7GWlrDt1wrPAk49gF0bDZ+oEBFHATu881tHj7c4cp9Uin4qWpCKqNKZ3/M4xFb hjzbm/wmCLqBk24xgiSDUoKW/fRQ96HNqapO6JRAgFPBBSWfbLxnlG7TgVAP+gouyaCX iBnw== X-Gm-Message-State: ALoCoQkhQiotywrR+V80yRFxa+S8IbO50mjevt9GpSrHWWEV5Q4yQTBwWjfEVnXk9XTS++qa6/xV X-Received: by 10.58.151.238 with SMTP id ut14mr1870692veb.11.1403285194607; Fri, 20 Jun 2014 10:26:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.178 with SMTP id w47ls1091246qge.55.gmail; Fri, 20 Jun 2014 10:26:34 -0700 (PDT) X-Received: by 10.220.43.193 with SMTP id x1mr1721596vce.57.1403285194499; Fri, 20 Jun 2014 10:26:34 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id lo19si4475261vdb.15.2014.06.20.10.26.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 10:26:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so3690605vcb.23 for ; Fri, 20 Jun 2014 10:26:34 -0700 (PDT) X-Received: by 10.58.198.46 with SMTP id iz14mr1799448vec.53.1403285194373; Fri, 20 Jun 2014 10:26:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp38757vcb; Fri, 20 Jun 2014 10:26:34 -0700 (PDT) X-Received: by 10.66.66.166 with SMTP id g6mr6549285pat.108.1403285193592; Fri, 20 Jun 2014 10:26:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gp6si10660503pac.215.2014.06.20.10.26.32; Fri, 20 Jun 2014 10:26:32 -0700 (PDT) Received-SPF: none (google.com: linux-omap-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935181AbaFTR0b (ORCPT + 6 others); Fri, 20 Jun 2014 13:26:31 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:41394 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935146AbaFTR0a (ORCPT ); Fri, 20 Jun 2014 13:26:30 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5KHQQQ3029281; Fri, 20 Jun 2014 12:26:26 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5KHQQnc031096; Fri, 20 Jun 2014 12:26:26 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Fri, 20 Jun 2014 12:26:26 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5KHQQ2R018110; Fri, 20 Jun 2014 12:26:26 -0500 From: Nishanth Menon To: Liam Girdwood , Mark Brown CC: , , , , , , Nishanth Menon Subject: [PATCH] regulator: palmas: Fix SMPS enable/disable/is_enabled Date: Fri, 20 Jun 2014 12:26:23 -0500 Message-ID: <1403285183-15926-1-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: nm@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We use regmap regulator ops to enable/disable and check if regulator is enabled for various SMPS. However, these depend on valid enable_reg, enable_mask and enable_value in regulator descriptor. Currently we do not populate these for SMPS other than SMPS10, this results in spurious results as regmap assumes that the values are valid and ends up reading register 0x0 RTC:SECONDS_REG on Palmas variants that do have RTC! To fix this, we update proper parameters for the descriptor fields. Further, we want to ensure the behavior consistent with logic prior to commit dbabd624d4eec50b6, where, once you do a set_mode, enable/disable ensure the logic remains consistent and configures Palmas to the configuration that we set with set_mode (since the configuration register is common). To do this, we can rely on the regulator core's regulator_register behavior where the regulator descriptor pointer provided by the regulator driver is stored. (no reallocation and copy is done). This lets us update the enable_value post registration, to remain consistent with the mode we configure as part of set_mode. Fixes: dbabd624d4eec50b6 ("regulator: palmas: Reemove open coded functions with helper functions") Reported-by: Alexandre Courbot Signed-off-by: Nishanth Menon Tested-by: Alexandre Courbot --- NOTE: there is a minor checkpatch check warning- but trying to fix it makes the code inconsistent with remaining code flow, so, I have chosen to ignore it. CHECK: Alignment should match open parenthesis #56: FILE: drivers/regulator/palmas-regulator.c:974: + PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, + palmas_regs_info[id].ctrl_addr); total: 0 errors, 0 warnings, 1 checks, 24 lines checked Original Report: http://marc.info/?t=140316427500004&r=1&w=2 Debug: http://marc.info/?t=140327063500007&r=1&w=2 drivers/regulator/palmas-regulator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index b982f0f..3c861d5 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -325,6 +325,10 @@ static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) if (rail_enable) palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); + + /* Switch the enable value to ensure this is used for enable */ + pmic->desc[id].enable_val = pmic->current_reg_mode[id]; + return 0; } @@ -964,6 +968,14 @@ static int palmas_regulators_probe(struct platform_device *pdev) return ret; pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; + + pmic->desc[id].enable_reg = + PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, + palmas_regs_info[id].ctrl_addr); + pmic->desc[id].enable_mask = + PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; + /* set_mode overrides this value */ + pmic->desc[id].enable_val = SMPS_CTRL_MODE_ON; } pmic->desc[id].type = REGULATOR_VOLTAGE;