From patchwork Mon Feb 4 11:54:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14507 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 5230723F96 for ; Mon, 4 Feb 2013 11:57:44 +0000 (UTC) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by fiordland.canonical.com (Postfix) with ESMTP id EC0CAA18F62 for ; Mon, 4 Feb 2013 11:57:43 +0000 (UTC) Received: by mail-ve0-f179.google.com with SMTP id da11so3576436veb.10 for ; Mon, 04 Feb 2013 03:57:43 -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=eyMNGbQRi+1xxzNSGAMz06icgxlosirXNXOT4zG3DIY=; b=BZkLuHu7K22whIwHrlbe25g+b4q6RzfZXVAFjz0huwY9x6C+xBR+Zq06elaV6irS0k eUhJkoL2S/S3UCNenXAh76w+DNHeFRAEpKUQ0B9f5fNSGOIJZbrzSaOPd2GwKSAqGMD8 wKy2mjvccsGz5KXvCeowXlYkeTGx5bHUZVsMj7bQIYBXnKka6EZ6vqScrAMnQY2bW/Lm O3o2rwM/F9L7L5IKPL4AfT2jq2pARQQfvJGqiRH65BIi3ed1At9R1OJgLEwqPd/F3JI5 AqgCSUsEb9MrlgclN8yf8Ng5NZ84avM+MwHbuthKwCVfEDggc3TZ+qUfsZtHqmDCHPJ+ 6qBA== X-Received: by 10.58.8.82 with SMTP id p18mr17668032vea.54.1359979063460; Mon, 04 Feb 2013 03:57:43 -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 zo8csp83120vec; Mon, 4 Feb 2013 03:57:42 -0800 (PST) X-Received: by 10.194.78.236 with SMTP id e12mr34517321wjx.32.1359979062098; Mon, 04 Feb 2013 03:57:42 -0800 (PST) Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]) by mx.google.com with ESMTPS id fk5si3466848wib.119.2013.02.04.03.57.41 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:57:42 -0800 (PST) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::236 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::236; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c03::236 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-f182.google.com with SMTP id t57so4836336wey.13 for ; Mon, 04 Feb 2013 03:57:41 -0800 (PST) X-Received: by 10.180.106.231 with SMTP id gx7mr9948017wib.4.1359979061665; Mon, 04 Feb 2013 03:57:41 -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.57.38 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:57:40 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com Cc: "xiaomei.zhang" , Lee Jones Subject: [PATCH 58/73] regulator: ab8500: Add new operations for Vaux3 Date: Mon, 4 Feb 2013 11:54:13 +0000 Message-Id: <1359978868-28736-59-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: ALoCoQmxSnWdL0+gED/QTn8UA3AjUtt4RZQv23g+vNOaIealm9ROYzeL9lrmtda3/pcTo9c4ipoy From: "xiaomei.zhang" In former functions, only can set Vaux3 to 2.91V, because the highest bit of Vaux3 register is put into another register. So add new expanded functions for Vaux3's operation. Signed-off-by: zhang xiaomei Signed-off-by: Lee Jones Reviewed-by: Philippe LANGLAIS --- drivers/regulator/ab8500.c | 120 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 7e8e332..cfa01b1 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -65,6 +65,13 @@ struct ab8500_regulator_info { u8 voltage_mask; u8 voltage_shift; unsigned int delay; + struct { + u8 voltage_limit; + u8 voltage_bank; + u8 voltage_reg; + u8 voltage_mask; + u8 voltage_shift; + } expand_register; }; /* voltage tables for the vauxn/vintcore supplies */ @@ -383,6 +390,57 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) return val >> info->voltage_shift; } +static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev) +{ + int ret, val; + struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); + u8 regval, regval_expand; + + if (info == NULL) { + dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); + return -EINVAL; + } + + ret = abx500_get_register_interruptible(info->dev, + info->voltage_bank, info->voltage_reg, ®val); + + if (ret < 0) { + dev_err(rdev_get_dev(rdev), + "couldn't read voltage reg for regulator\n"); + return ret; + } + + ret = abx500_get_register_interruptible(info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, ®val_expand); + + if (ret < 0) { + dev_err(rdev_get_dev(rdev), + "couldn't read voltage reg for regulator\n"); + return ret; + } + + dev_vdbg(rdev_get_dev(rdev), + "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," + " 0x%x\n", + info->desc.name, info->voltage_bank, info->voltage_reg, + info->voltage_mask, regval); + dev_vdbg(rdev_get_dev(rdev), + "%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," + " 0x%x\n", + info->desc.name, info->expand_register.voltage_bank, + info->expand_register.voltage_reg, + info->expand_register.voltage_mask, regval_expand); + + if (regval_expand&(info->expand_register.voltage_mask)) + /* Vaux3 has a different layout */ + val = info->expand_register.voltage_limit; + else + val = (regval & info->voltage_mask) >> info->voltage_shift; + + return val; +} + static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) { @@ -413,6 +471,46 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, return ret; } +static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev, + unsigned selector) +{ + int ret; + struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); + u8 regval; + + if (info == NULL) { + dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); + return -EINVAL; + } + + if (selector >= info->expand_register.voltage_limit) { + /* Vaux3 bit4 has different layout */ + regval = (u8)selector << info->expand_register.voltage_shift; + ret = abx500_mask_and_set_register_interruptible(info->dev, + info->expand_register.voltage_bank, + info->expand_register.voltage_reg, + info->expand_register.voltage_mask, + regval); + } else { + /* set the registers for the request */ + regval = (u8)selector << info->voltage_shift; + ret = abx500_mask_and_set_register_interruptible(info->dev, + info->voltage_bank, info->voltage_reg, + info->voltage_mask, regval); + } + if (ret < 0) + dev_err(rdev_get_dev(rdev), + "couldn't set voltage reg for regulator\n"); + + dev_vdbg(rdev_get_dev(rdev), + "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x," + " 0x%x\n", + info->desc.name, info->voltage_bank, info->voltage_reg, + info->voltage_mask, regval); + + return ret; +} + static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev *rdev, unsigned int old_sel, unsigned int new_sel) @@ -435,6 +533,19 @@ static struct regulator_ops ab8500_regulator_volt_mode_ops = { .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, }; +static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = { + .enable = ab8500_regulator_enable, + .disable = ab8500_regulator_disable, + .get_optimum_mode = ab8500_regulator_get_optimum_mode, + .set_mode = ab8500_regulator_set_mode, + .get_mode = ab8500_regulator_get_mode, + .is_enabled = ab8500_regulator_is_enabled, + .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel, + .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel, + .list_voltage = regulator_list_voltage_table, + .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, +}; + static struct regulator_ops ab8500_regulator_volt_ops = { .enable = ab8500_regulator_enable, .disable = ab8500_regulator_disable, @@ -1259,7 +1370,7 @@ static struct ab8500_regulator_info [AB8540_LDO_AUX3] = { .desc = { .name = "LDO-AUX3", - .ops = &ab8500_regulator_volt_mode_ops, + .ops = &ab8540_aux3_regulator_volt_mode_ops, .type = REGULATOR_VOLTAGE, .id = AB8540_LDO_AUX3, .owner = THIS_MODULE, @@ -1276,6 +1387,13 @@ static struct ab8500_regulator_info .voltage_bank = 0x04, .voltage_reg = 0x21, .voltage_mask = 0x07, + .expand_register = { + .voltage_limit = 8, + .voltage_bank = 0x04, + .voltage_reg = 0x01, + .voltage_mask = 0x10, + .voltage_shift = 1, + } }, [AB8540_LDO_AUX4] = { .desc = {