From patchwork Mon Aug 20 16:39:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10816 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 5257523E56 for ; Mon, 20 Aug 2012 16:40:04 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id DDC89A18467 for ; Mon, 20 Aug 2012 16:39:57 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id l8so5480169yen.11 for ; Mon, 20 Aug 2012 09:40:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=NvN4gtcSx6KXfzK6m9f3sUUpw14j2kxqSuxvt3sYjJg=; b=IDqOHeAmZCciy7cRjSbQwp7UeVb+RWP5tp3D+Qhj0PCCvRC/YcHaKPvQpdlwzcUDoA WBmqDLnY+kWrHavUBaMGLvvWVrRqzrQNG0DIE9TbGFcHkINCefRFSUK591ti8wjx7VeE R4aO4GgO8iJpYPQ0svJ1qz5CikhpLGQWqIP9Gz5BCBSk3/Q/M5S3kUDzLJMmRg72ac5s KbBTWIpbg3w3eXv8oUb2DDskzK/GXtjixINC72TgkJMP2cuHFCd6OdzQ6lsr99gGUp+2 1OZTAMrkNo9H4ww8BVHiRjBLkUwBAinmi8Vqd08SgaBd1U+o2cZ5aTF3mepggUmcnTmB MwNA== Received: by 10.50.182.162 with SMTP id ef2mr10361117igc.43.1345480803227; Mon, 20 Aug 2012 09:40:03 -0700 (PDT) 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.50.184.232 with SMTP id ex8csp93365igc; Mon, 20 Aug 2012 09:40:02 -0700 (PDT) Received: by 10.14.198.65 with SMTP id u41mr9577302een.22.1345480801647; Mon, 20 Aug 2012 09:40:01 -0700 (PDT) Received: from eu1sys200aog111.obsmtp.com (eu1sys200aog111.obsmtp.com. [207.126.144.131]) by mx.google.com with SMTP id u5si11184475eeo.41.2012.08.20.09.39.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Aug 2012 09:40:01 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.131 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.131; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.131 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKUDJoW7YuBJvDe2hsJO1/iEjbLWNqSO3E@postini.com; Mon, 20 Aug 2012 16:40:01 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5694AA2; Mon, 20 Aug 2012 16:39:48 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1287A4970; Mon, 20 Aug 2012 16:39:48 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 0EE60A8072; Mon, 20 Aug 2012 18:39:41 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 20 Aug 2012 18:39:47 +0200 From: Linus Walleij To: Liam Girdwood , Mark Brown , Cc: Mattias Wallin , Linus Walleij , Axel Lin Subject: [PATCH] regulator: ab8500: provide per-regulator shift Date: Mon, 20 Aug 2012 18:39:41 +0200 Message-ID: <1345480781-16754-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQl+/fRIeIR06kIqWmIZRWwksovh3w9gxwbrkKOVWHg5Rke1xWHkZYWjkCxcnJJCDC+MHhQZ From: Linus Walleij This encodes the voltage shifts (the number of bits to shift the register to get to the selector) into the regulator info. We have several new variants of the AB8500 so this varies a lot. Cc: Axel Lin Signed-off-by: Linus Walleij --- drivers/regulator/ab8500.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 8807166..c659127 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -195,17 +195,14 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) } 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); + "%s-get_voltage (bank, reg, mask, shift, value): " + "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", + info->desc.name, info->voltage_bank, + info->voltage_reg, info->voltage_mask, + info->voltage_shift, regval); - /* vintcore has a different layout */ val = regval & info->voltage_mask; - if (info->desc.id == AB8500_LDO_INTCORE) - return val >> 0x3; - else - return val; + return val >> info->voltage_shift; } static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, @@ -221,7 +218,7 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, } /* set the registers for the request */ - regval = (u8)selector; + 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);