From patchwork Mon Aug 20 16:41:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10817 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 4A86123E56 for ; Mon, 20 Aug 2012 16:41:48 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id A7E03A18009 for ; Mon, 20 Aug 2012 16:41:41 +0000 (UTC) Received: by ggmi2 with SMTP id i2so5480501ggm.11 for ; Mon, 20 Aug 2012 09:41:47 -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=G60Avr0x3T0fAEurjwkdi3euiogfRhmcTRx0gAuKFrM=; b=LEpYvig/606yMuzJ11b8I40Of/DAlZUKNgKsVoTLliWpOZzFIG90osfJlFeB2Ir0hM o0nYV1BasLjn9xoOQ57vA1wMMPSerXbL3XwOSqtIvZdMl/+VLxEudHsL/XIfDfDkrFlx kVp7oVpLNxpBcBLjpF6+4I5MGgD2XieMtWfGBL8GpY1nkL4DTEYIJfCf7rcGUAbJrLHg 1HF/d8NACqVDT9oApRzR4D+z0KgsnSfZuW3/piURM9PjWNEScGwEnWXDPiNi7LN0sspg jtEjy5ObJnKpgxJxOdHxOUK8CYg0mRkhkdQYJ9l/ZqUt09lZIYNIxiyukWEItS2CFNOm fQ5Q== Received: by 10.50.180.129 with SMTP id do1mr10503643igc.28.1345480906805; Mon, 20 Aug 2012 09:41:46 -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 ex8csp93442igc; Mon, 20 Aug 2012 09:41:46 -0700 (PDT) Received: by 10.14.202.66 with SMTP id c42mr9602965eeo.35.1345480905627; Mon, 20 Aug 2012 09:41:45 -0700 (PDT) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com. [207.126.144.133]) by mx.google.com with SMTP id o42si11193708eep.11.2012.08.20.09.41.42 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Aug 2012 09:41:45 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.133; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.133 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 eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKUDJoxTGvRa4mabuZ/OH2teUbkycnKrSj@postini.com; Mon, 20 Aug 2012 16:41:45 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 104D0AE; Mon, 20 Aug 2012 16:41:40 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BDF314978; Mon, 20 Aug 2012 16:41:40 +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 relay1.stm.gmessaging.net (Postfix) with ESMTPS id B425924C07C; Mon, 20 Aug 2012 18:41:31 +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:41:39 +0200 From: Linus Walleij To: Liam Girdwood , Mark Brown , Cc: Mattias Wallin , Linus Walleij , Axel Lin Subject: [PATCH v2] regulator: ab8500: provide per-regulator shift Date: Mon, 20 Aug 2012 18:41:35 +0200 Message-ID: <1345480895-18278-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: ALoCoQlQ2+pd5L9eaPfYkyzdA+R6h1SVMB0VShecvdDWiItXYKo2BgbC1DDEXDagK88VuqNwRlhr 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 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 8807166..812611f 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -37,6 +37,7 @@ * @voltage_bank: bank to control regulator voltage * @voltage_reg: register to control regulator voltage * @voltage_mask: mask to control regulator voltage + * @voltage_shift: shift to control regulator voltage * @delay: startup/set voltage delay in us */ struct ab8500_regulator_info { @@ -50,6 +51,7 @@ struct ab8500_regulator_info { u8 voltage_bank; u8 voltage_reg; u8 voltage_mask; + u8 voltage_shift; unsigned int delay; }; @@ -195,17 +197,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 +220,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); @@ -349,6 +348,7 @@ static struct ab8500_regulator_info .voltage_bank = 0x03, .voltage_reg = 0x80, .voltage_mask = 0x38, + .voltage_shift = 3, }, /*