From patchwork Mon Feb 4 11:53:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14468 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 377EB23F96 for ; Mon, 4 Feb 2013 11:56:25 +0000 (UTC) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id CC59BA18F62 for ; Mon, 4 Feb 2013 11:56:24 +0000 (UTC) Received: by mail-vc0-f180.google.com with SMTP id fo13so3791966vcb.39 for ; Mon, 04 Feb 2013 03:56:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=tY4L4JVn8XXlSWiH51NcH4pKRriq4XKbcSi8H6BQfcU=; b=bIJQAcpXEMv+Fu908D5633PLd1KE2zgDsuqAxfXnpqKIaFuNk0YSlmI99z3MYTMI5D KRq4Hs+30IhpggGLFdSUjFhNUF9bLUVde20kUyQzi21FCB51/5zHXsxD4qawMiNVyRQb gVQvOLc7ZxOq6Yawg6iVN+Nx76JKNj27z2rDQOfyaxi2u8515MnShCc35sNo9tnSRWHZ Z2vHK34q5htJ3FEnoXzMTtmw5GidQ1bvhe5kD3u3kgVfjqER9xUJk/OVeOubYmh37uRH oEGb8p0030jy6VB6ZAaYFvM+mIsu0sb1IWhC6v5OHL9cnJebj7KKwqigLneygNVkh8cC FWiA== X-Received: by 10.59.7.65 with SMTP id da1mr17665511ved.4.1359978984334; Mon, 04 Feb 2013 03:56:24 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp83048vec; Mon, 4 Feb 2013 03:56:23 -0800 (PST) X-Received: by 10.180.105.195 with SMTP id go3mr9825961wib.13.1359978983488; Mon, 04 Feb 2013 03:56:23 -0800 (PST) Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]) by mx.google.com with ESMTPS id o8si3482608wix.7.2013.02.04.03.56.23 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:56:23 -0800 (PST) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22d is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::22d; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c03::22d is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f173.google.com with SMTP id r5so4676614wey.18 for ; Mon, 04 Feb 2013 03:56:23 -0800 (PST) X-Received: by 10.194.174.196 with SMTP id bu4mr34481064wjc.35.1359978982990; Mon, 04 Feb 2013 03:56:22 -0800 (PST) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id j9sm12937128wia.5.2013.02.04.03.56.21 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:56:21 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com Cc: Lee Jones , Bengt Jonsson Subject: [PATCH 19/73] regulator: ab8500-ext: Add regulator_set_mode/get_mode Date: Mon, 4 Feb 2013 11:53:34 +0000 Message-Id: <1359978868-28736-20-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1359978868-28736-1-git-send-email-lee.jones@linaro.org> References: <1359978868-28736-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQm5Lpg/K7klkpfH6iCOyPrtqZQOi+ZpuPIoQERS++eTnzwFFRdCPmjb9/GnCuzpzDChlG0F Operations regulator_set_mode and regulator_get_mode are added. Signed-off-by: Bengt Jonsson Signed-off-by: Lee Jones Reviewed-by: Mattias NILSSON Reviewed-by: Jonas ABERG --- drivers/regulator/ab8500-ext.c | 64 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index 29d5cd4..2bf940d 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -197,6 +196,67 @@ static int ab8500_ext_regulator_is_enabled(struct regulator_dev *rdev) return info->is_enabled; } +static int ab8500_ext_regulator_set_mode(struct regulator_dev *rdev, + unsigned int mode) +{ + int ret = 0; + struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); + + if (info == NULL) { + dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); + return -EINVAL; + } + + switch (mode) { + case REGULATOR_MODE_NORMAL: + info->update_val = info->update_val_hp; + break; + case REGULATOR_MODE_IDLE: + info->update_val = info->update_val_lp; + break; + + default: + return -EINVAL; + } + + if (info->is_enabled) { + u8 regval; + + ret = enable(info, ®val); + if (ret < 0) + dev_err(rdev_get_dev(rdev), + "Could not set regulator mode.\n"); + + dev_dbg(rdev_get_dev(rdev), + "%s-set_mode (bank, reg, mask, value): " + "0x%x, 0x%x, 0x%x, 0x%x\n", + info->desc.name, info->update_bank, info->update_reg, + info->update_mask, regval); + } + + return ret; +} + +static unsigned int ab8500_ext_regulator_get_mode(struct regulator_dev *rdev) +{ + struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); + int ret; + + if (info == NULL) { + dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); + return -EINVAL; + } + + if (info->update_val == info->update_val_hp) + ret = REGULATOR_MODE_NORMAL; + else if (info->update_val == info->update_val_lp) + ret = REGULATOR_MODE_IDLE; + else + ret = -EINVAL; + + return ret; +} + static int ab8500_ext_fixed_get_voltage(struct regulator_dev *rdev) { struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); @@ -232,6 +292,8 @@ static struct regulator_ops ab8500_ext_regulator_ops = { .disable = ab8500_ext_regulator_disable, .set_suspend_disable = ab8500_ext_regulator_set_suspend_disable, .is_enabled = ab8500_ext_regulator_is_enabled, + .set_mode = ab8500_ext_regulator_set_mode, + .get_mode = ab8500_ext_regulator_get_mode, .get_voltage = ab8500_ext_fixed_get_voltage, .list_voltage = ab8500_ext_list_voltage, };