From patchwork Thu Jul 16 17:55:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 51195 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1736C22A28 for ; Thu, 16 Jul 2015 17:58:40 +0000 (UTC) Received: by wgjx7 with SMTP id x7sf20493765wgj.3 for ; Thu, 16 Jul 2015 10:58:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=uKPYdbUwg68SSvTbUcKiw3B1m4A/+o9l1HRiOgLUXTg=; b=QypzAYtgHGS6TKDdqzkxpI5T9v7SHqcZ+FAlFh3xhavFxhG3zLsOrrZthrWgmrTMdH t1gHd181tYa8RsZ7LF1gCzKuPqjgpDM7gRZtXJtIlhNV3AYthYvz2D5RaoBrg3tEmvv7 wqXWwosPpsYlKLR17tVbbOujxI34RX8jzeSMDZ5/NPzX6D5PyEOCphejWZt0sRt302zP 9/qz4voUqKQIUqUimbiofb4Xx6rTJ20USe2JJouzG0hjz2AkxT4nXTJVlIXiK431zoti c7o49TlSZSnjzYN3zjr1PubWiLoXffknYGSk0JOvZpFF/NYSEuItUm2u21E80K9/CJaY rTyw== X-Gm-Message-State: ALoCoQmMeQj2Gt7Cxr9R1sd0uooHM/IlrzZKqdLqo5jKc9cFb59a1ktPH64ZoE2iohUSQydP3y+6 X-Received: by 10.112.85.69 with SMTP id f5mr5389014lbz.23.1437069519428; Thu, 16 Jul 2015 10:58:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.9 with SMTP id ci9ls425441lad.69.gmail; Thu, 16 Jul 2015 10:58:39 -0700 (PDT) X-Received: by 10.152.87.13 with SMTP id t13mr10597711laz.66.1437069519253; Thu, 16 Jul 2015 10:58:39 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id pc7si7566577lbb.120.2015.07.16.10.58.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 10:58:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbyj8 with SMTP id yj8so48335090lbb.0 for ; Thu, 16 Jul 2015 10:58:39 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr10786705lbb.56.1437069519137; Thu, 16 Jul 2015 10:58:39 -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.112.108.230 with SMTP id hn6csp410343lbb; Thu, 16 Jul 2015 10:58:37 -0700 (PDT) X-Received: by 10.66.145.74 with SMTP id ss10mr21388465pab.28.1437069516132; Thu, 16 Jul 2015 10:58:36 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nw8si14199388pbb.84.2015.07.16.10.58.35; Thu, 16 Jul 2015 10:58:36 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756223AbbGPR60 (ORCPT + 28 others); Thu, 16 Jul 2015 13:58:26 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:36830 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755647AbbGPR6X (ORCPT ); Thu, 16 Jul 2015 13:58:23 -0400 Received: by pdjr16 with SMTP id r16so48131478pdj.3 for ; Thu, 16 Jul 2015 10:58:22 -0700 (PDT) X-Received: by 10.70.131.73 with SMTP id ok9mr20923069pdb.109.1437069502391; Thu, 16 Jul 2015 10:58:22 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by smtp.gmail.com with ESMTPSA id vl1sm8659239pab.21.2015.07.16.10.58.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 10:58:21 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Cc: sameo@linux.intel.com, lee.jones@linaro.org, linux-kernel@vger.kernel.org, k.kozlowski@samsung.com, Vaibhav Hiremath Subject: [PATCH-v3 2/2] mfd: 88pm800: Add init time initial configuration support Date: Thu, 16 Jul 2015 23:25:49 +0530 Message-Id: <1437069349-15015-3-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437069349-15015-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1437069349-15015-1-git-send-email-vaibhav.hiremath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vaibhav.hiremath@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 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: , This patch adds init time configuration of 88PM800/805 and 88PM860. It includes, - Enable BUCK clock gating in low power mode - Full mode support for BUCK2 and 4 - Enable voltage change (LPF, DVC) in PMIC Note that both 88PM800 and 88PM860 do share common configurations, but since I can not validate the configuration on 88PM800, restricting myself only to 88PM860. If anyone can validate on 88PM800, we can move common code accordingly. Signed-off-by: Vaibhav Hiremath Reviewed-by: Krzysztof Kozlowski --- drivers/mfd/88pm800.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/88pm80x.h | 13 +++++++++ 2 files changed, 83 insertions(+) diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index 95c8ad4..f104a32 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c @@ -521,6 +521,69 @@ out: return ret; } +static int pm800_init_config(struct pm80x_chip *chip, struct device_node *np) +{ + int ret; + + /* + * Although both 88PM800 & 88PM860 do share some common configurations, + * and should have common code wherever possible. But due to lack of + * testing on 88pm800/88pm805 device, common code is avoided as of now. + * + * Once it is tested on 88PM800, it can be moved to common code. + */ + switch (chip->type) { + case CHIP_PM800: + case CHIP_PM805: + break; + case CHIP_PM860: + /* Enable LDO and BUCK clock gating in low power mode */ + ret = regmap_update_bits(chip->regmap, PM800_LOW_POWER_CONFIG3, + PM800_LDOBK_FREEZE, PM800_LDOBK_FREEZE); + if (ret) + goto error; + + /* Enable voltage change in pmic, POWER_HOLD = 1 */ + ret = regmap_update_bits(chip->regmap, PM800_WAKEUP1, + PM800_PWR_HOLD_EN, PM800_PWR_HOLD_EN); + if (ret) + goto error; + + /* + * Set buck2 and buck4 driver selection to be full. + * The default value is 0, for full drive support + * it should be set to 1. + * In A1 version it will be set to 1 by default. + * To be on safer side, set it explicitly + */ + ret = regmap_update_bits(chip->subchip->regmap_power, + PM860_BUCK2_MISC2, + PM860_BUCK2_FULL_DRV, + PM860_BUCK2_FULL_DRV); + if (ret) + goto error; + + ret = regmap_update_bits(chip->subchip->regmap_power, + PM860_BUCK4_MISC2, + PM860_BUCK4_FULL_DRV, + PM860_BUCK4_FULL_DRV); + if (ret) + goto error; + + + break; + default: + dev_err(chip->dev, "Unknown device type: %d\n", chip->type); + break; + } + + return 0; + +error: + dev_err(chip->dev, "failed to access registers\n"); + return ret; +} + static int pm800_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -585,6 +648,13 @@ static int pm800_probe(struct i2c_client *client, if (pdata->plat_config) pdata->plat_config(chip, pdata); + /* common register configurations , init time only */ + ret = pm800_init_config(chip, np); + if (ret) { + dev_err(chip->dev, "Failed to configure 88pm800 devices\n"); + goto err_device_init; + } + return 0; err_device_init: diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h index 2e25fb1..2ef62af 100644 --- a/include/linux/mfd/88pm80x.h +++ b/include/linux/mfd/88pm80x.h @@ -74,6 +74,7 @@ enum { /* Wakeup Registers */ #define PM800_WAKEUP1 (0x0D) +#define PM800_PWR_HOLD_EN BIT(7) #define PM800_WAKEUP2 (0x0E) #define PM800_WAKEUP2_INV_INT BIT(0) @@ -87,7 +88,10 @@ enum { /* Referance and low power registers */ #define PM800_LOW_POWER1 (0x20) #define PM800_LOW_POWER2 (0x21) + #define PM800_LOW_POWER_CONFIG3 (0x22) +#define PM800_LDOBK_FREEZE BIT(7) + #define PM800_LOW_POWER_CONFIG4 (0x23) /* GPIO register */ @@ -279,6 +283,15 @@ enum { #define PM805_EARPHONE_SETTING (0x29) #define PM805_AUTO_SEQ_SETTING (0x2A) + +/* 88PM860 Registers */ + +#define PM860_BUCK2_MISC2 (0x7C) +#define PM860_BUCK2_FULL_DRV BIT(2) + +#define PM860_BUCK4_MISC2 (0x82) +#define PM860_BUCK4_FULL_DRV BIT(2) + struct pm80x_rtc_pdata { int vrtc; int rtc_wakeup;