From patchwork Thu Jul 9 11:47:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 6755241 Return-Path: X-Original-To: patchwork-linux-arm@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 736D1C05AC for ; Thu, 9 Jul 2015 11:52:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AF8420763 for ; Thu, 9 Jul 2015 11:52:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42C7620782 for ; Thu, 9 Jul 2015 11:52:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZDALC-0004TS-TU; Thu, 09 Jul 2015 11:50:10 +0000 Received: from mail-pd0-f179.google.com ([209.85.192.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZDAL3-0003Df-1F for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2015 11:50:01 +0000 Received: by pdbqm3 with SMTP id qm3so20505053pdb.0 for ; Thu, 09 Jul 2015 04:49:40 -0700 (PDT) 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=Jx4cFru/nciBFhOjy0QXkgPDEOlYWYATMC5Argq/O70=; b=GnM8O+AKV83CblXBNcDjJTvLjh5+KvCQgdZXXnsWHX7QnW76yah+Qj0VH+bjkhBz0s sJ7Lm5c13ECfNw8qLqcKn/KL0XghNxA9GsCt6BNQxcsx+Rdv/PbTzQBHaX8NwHFPGpAd c9ktahg9Hl8ljqzCWUf1mGKY+rtXVLb3lpAAFR+Tmlu6CUsnkbJreKYnnR6wtR716HNk Q5FJ2+AkCgAPFl4VlfopddkfdHuk4JnhM/jPz1xYeaC0R+Uvvw0BmVg86G+8vKMvJsRm OB2X2NNXEW1/K45vhSqrp0+mddKn6KU8lltpzP+QjJjvtoT3snqTuLgeerQYLVdmLVyR +6Mg== X-Gm-Message-State: ALoCoQn7tBZ+cbIaBa+1lxHgm1JdeGu51j8Nm4VLN6k3wT2XfsJupgRCFL7lX8m8you9hvpGmupk X-Received: by 10.68.251.35 with SMTP id zh3mr30233670pbc.166.1436442580188; Thu, 09 Jul 2015 04:49:40 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by smtp.gmail.com with ESMTPSA id qo1sm5709802pbc.89.2015.07.09.04.49.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Jul 2015 04:49:39 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/6] mfd: 88pm800: Add init time initial configuration support Date: Thu, 9 Jul 2015 17:17:07 +0530 Message-Id: <1436442431-3471-3-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436442431-3471-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1436442431-3471-1-git-send-email-vaibhav.hiremath@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150709_045001_106620_5DE94C54 X-CRM114-Status: GOOD ( 16.97 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, k.kozlowski@samsung.com, sameo@linux.intel.com, linux-kernel@vger.kernel.org, Vaibhav Hiremath , robh+dt@kernel.org, lee.jones@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 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 | 64 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/88pm80x.h | 13 +++++++++ 2 files changed, 77 insertions(+) diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index 95c8ad4..80a1bc1 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c @@ -521,6 +521,63 @@ out: return ret; } +static int pm800_init_config(struct pm80x_chip *chip, struct device_node *np) +{ + int ret; + unsigned int val; + + 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 +642,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;