From patchwork Tue Sep 16 17:22:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 4918731 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E63AABEEA5 for ; Tue, 16 Sep 2014 17:25:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F69D201F5 for ; Tue, 16 Sep 2014 17:25:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 193C72010F for ; Tue, 16 Sep 2014 17:25:40 +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 1XTwTR-0004rV-4W; Tue, 16 Sep 2014 17:23:29 +0000 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XTwTO-0004oL-RD for linux-arm-kernel@lists.infradead.org; Tue, 16 Sep 2014 17:23:27 +0000 Received: by mail-pa0-f52.google.com with SMTP id kq14so207398pab.39 for ; Tue, 16 Sep 2014 10:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=rCQlYl55hBW8e66WnDPLs0E1JB0fus01TiqlERdn1+c=; b=fFU+ZgbnrMD8pvXlRpwqFbkFBOks8YSYwvIrDUqVNbNTEuItbORJVIjXG8ay6r8zBW lIcsXEeEG176jriHtgSCO5qlVe10QifR2+x8L0UNHozKhz9isfBeY63X4Bz4W3k6/97j IGd+weHaJI8NLmscf7JfHBAKWGLm1kqdfgtsg= 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; bh=rCQlYl55hBW8e66WnDPLs0E1JB0fus01TiqlERdn1+c=; b=AsM6Oe+69M4YUBwSYuljVrXtAOeCxDwsFma5mqjtEKGr8f2bGHWM4wSEgOr13H4am4 uEcoVVGjawaStpxm7D6TelSJHCeUbymfBp3iPlHIrjX71oX/1t85l4h2zdFtQ/x/MOFT rg4TOGxq4dKJGht8U0ObB2tusppDN0bhc04C5QbdkZtijGztDnqfnfazDTdj4OsBoYOu EFs9nrYApYaYP1fotPLXphB9U+MMqLSUD/sx0+msj1krnEadRedO9+c8RL1WneH/rw1T 3qXPrG7wFn4Wd2TgXRSmcSkM4VsTfghSB11/bJFD/gZmFHGMX3fCWOIOFxk0Qqsh69m2 PAcg== X-Gm-Message-State: ALoCoQmN2tk0YC0uoO5bvjL8BKPU2NOO53AA89bhW3+CV6qC4IZ2MyPCqzSn5Q67viS9EdGxKMNj X-Received: by 10.67.23.164 with SMTP id ib4mr52464510pad.31.1410888184966; Tue, 16 Sep 2014 10:23:04 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.15]) by mx.google.com with ESMTPSA id p3sm14699359pde.35.2014.09.16.10.23.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Sep 2014 10:23:04 -0700 (PDT) From: Doug Anderson To: Mark Brown , Chris Zhong , Heiko Stuebner Subject: [PATCH] regulator: rk808: Add function for ramp delay for buck1/buck2 Date: Tue, 16 Sep 2014 10:22:54 -0700 Message-Id: <1410888174-8279-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140916_102326_901481_64ADBF7C X-CRM114-Status: GOOD ( 11.96 ) X-Spam-Score: -0.8 (/) Cc: axel.lin@ingics.com, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, Doug Anderson , linux-rockchip@lists.infradead.org, Sonny Rao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,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 On rk808 buck1 and buck2 have programmable ramp delays. Let's add a function to allow a client of rk808 to set them. Signed-off-by: Doug Anderson --- drivers/regulator/rk808-regulator.c | 57 +++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index 07b0eb4..e305416 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -28,6 +28,21 @@ #define RK808_BUCK4_VSEL_MASK 0xf #define RK808_LDO_VSEL_MASK 0x1f +/* Ramp rate definitions for buck1 / buck2 only */ +#define RK808_RAMP_RATE_OFFSET 3 +#define RK808_RAMP_RATE_MASK (3 << RK808_RAMP_RATE_OFFSET) +#define RK808_RAMP_RATE_2MV_PER_US (0 << RK808_RAMP_RATE_OFFSET) +#define RK808_RAMP_RATE_4MV_PER_US (1 << RK808_RAMP_RATE_OFFSET) +#define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET) +#define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET) + +static const int rk808_buck_config_regs[] = { + RK808_BUCK1_CONFIG_REG, + RK808_BUCK2_CONFIG_REG, + RK808_BUCK3_CONFIG_REG, + RK808_BUCK4_CONFIG_REG, +}; + static const struct regulator_linear_range rk808_buck_voltage_ranges[] = { REGULATOR_LINEAR_RANGE(700000, 0, 63, 12500), }; @@ -49,6 +64,44 @@ static const struct regulator_linear_range rk808_ldo6_voltage_ranges[] = { REGULATOR_LINEAR_RANGE(800000, 0, 17, 100000), }; +static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) +{ + unsigned int ramp_value = RK808_RAMP_RATE_10MV_PER_US; + unsigned int reg = rk808_buck_config_regs[rdev->desc->id - + RK808_ID_DCDC1]; + + switch (ramp_delay) { + case 1 ... 2000: + ramp_value = RK808_RAMP_RATE_2MV_PER_US; + break; + case 2001 ... 4000: + ramp_value = RK808_RAMP_RATE_4MV_PER_US; + break; + case 4001 ... 6000: + ramp_value = RK808_RAMP_RATE_6MV_PER_US; + break; + case 6001 ... 10000: + break; + default: + pr_warn("%s ramp_delay: %d not supported, setting 10000\n", + rdev->desc->name, ramp_delay); + } + + return regmap_update_bits(rdev->regmap, reg, + RK808_RAMP_RATE_MASK, ramp_value); +} + +static struct regulator_ops rk808_buck1_2_ops = { + .list_voltage = regulator_list_voltage_linear_range, + .map_voltage = regulator_map_voltage_linear_range, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .set_ramp_delay = rk808_set_ramp_delay, +}; + static struct regulator_ops rk808_reg_ops = { .list_voltage = regulator_list_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range, @@ -70,7 +123,7 @@ static const struct regulator_desc rk808_reg[] = { .name = "DCDC_REG1", .supply_name = "vcc1", .id = RK808_ID_DCDC1, - .ops = &rk808_reg_ops, + .ops = &rk808_buck1_2_ops, .type = REGULATOR_VOLTAGE, .n_voltages = 64, .linear_ranges = rk808_buck_voltage_ranges, @@ -84,7 +137,7 @@ static const struct regulator_desc rk808_reg[] = { .name = "DCDC_REG2", .supply_name = "vcc2", .id = RK808_ID_DCDC2, - .ops = &rk808_reg_ops, + .ops = &rk808_buck1_2_ops, .type = REGULATOR_VOLTAGE, .n_voltages = 64, .linear_ranges = rk808_buck_voltage_ranges,