From patchwork Thu Jan 3 10:46:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laxman Dewangan X-Patchwork-Id: 209211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-pa0-f58.google.com (mail-pa0-f58.google.com [209.85.220.58]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 6876B2C007E for ; Thu, 3 Jan 2013 21:48:06 +1100 (EST) Received: by mail-pa0-f58.google.com with SMTP id fa10sf9005838pad.23 for ; Thu, 03 Jan 2013 02:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-received:x-beenthere:x-received:x-received:received-spf :x-pgp-universal:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=TT5bG12j/Y+wg18vEi3ziO8h0k51m/8wFhY4Dlts+4A=; b=J+FTZVA6kmboT8TAQfvT05SFkg+EQN9armqNF5R2Sj7NRJTTafHQtNtkExsddXB8Ql z4tD5VFjMCOdyaGMU4ezEh2S+2VHEE5Muq2t1ARVLYFZPL9RG901JID/Q0s4UuJKqzi0 c7x0QNev3CkTA6QMGCR+CyLWlN0KzbDj78ej1yhSvsm0R2twJ7qbEP9Fxa8Gv3EVTsCx 1dxT1XBkPjnhSUf9wapLRfLhJ7vm4hGbrRzisj9XMzEsp/P3OFxG/xNP3ba+bYN4/SDP FrNfRQXiUDwGdLmLJwStCmXM2wAIqY4Ixz2fYHVth8mcoPlFfkjAVG2jE9hOxLjNzFqH VX1w== X-Received: by 10.50.108.200 with SMTP id hm8mr15694142igb.10.1357210084564; Thu, 03 Jan 2013 02:48:04 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.42.169 with SMTP id p9ls11076932igl.37.gmail; Thu, 03 Jan 2013 02:48:04 -0800 (PST) X-Received: by 10.66.81.170 with SMTP id b10mr6251877pay.31.1357210084185; Thu, 03 Jan 2013 02:48:04 -0800 (PST) X-Received: by 10.66.81.170 with SMTP id b10mr6251876pay.31.1357210084176; Thu, 03 Jan 2013 02:48:04 -0800 (PST) Received: from hqemgate03.nvidia.com (hqemgate03.nvidia.com. [216.228.121.140]) by gmr-mx.google.com with ESMTPS id n8si9824422paz.2.2013.01.03.02.48.04 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 02:48:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of ldewangan@nvidia.com designates 216.228.121.140 as permitted sender) client-ip=216.228.121.140; Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Thu, 03 Jan 2013 02:51:22 -0800 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp08.nvidia.com (PGP Universal service); Thu, 03 Jan 2013 02:47:30 -0800 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Thu, 03 Jan 2013 02:47:30 -0800 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server id 8.3.279.1; Thu, 3 Jan 2013 02:47:30 -0800 Received: from thelma.nvidia.com (Not Verified[172.16.212.77]) by hqnvemgw02.nvidia.com with MailMarshal (v6,7,2,8378) id ; Thu, 03 Jan 2013 02:47:30 -0800 Received: from ldewangan-ubuntu.nvidia.com ([10.19.65.30]) by thelma.nvidia.com (8.13.8+Sun/8.8.8) with ESMTP id r03AlDBS027770; Thu, 3 Jan 2013 02:47:26 -0800 (PST) From: Laxman Dewangan To: , , , CC: , , , , Laxman Dewangan Subject: [rtc-linux] [PATCH 2/4] mfd: palmas: add apis to access the Palmas' registers Date: Thu, 3 Jan 2013 16:16:58 +0530 Message-ID: <1357210020-19876-3-git-send-email-ldewangan@nvidia.com> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: <1357210020-19876-1-git-send-email-ldewangan@nvidia.com> References: <1357210020-19876-1-git-send-email-ldewangan@nvidia.com> MIME-Version: 1.0 X-Original-Sender: ldewangan@nvidia.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of ldewangan@nvidia.com designates 216.228.121.140 as permitted sender) smtp.mail=ldewangan@nvidia.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Palmas register set is divided into different blocks (base and offset) and hence different i2c addresses. The i2c address offsets are derived from base address of block of registers. Add inline APIs to access the Palma's registers which takes the base of register block and register offset. The i2c address offset is derived from the base address of register blocks. Signed-off-by: Laxman Dewangan --- include/linux/mfd/palmas.h | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 29f6616..a4d13d7 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -2789,4 +2789,56 @@ enum usb_irq_events { #define PALMAS_GPADC_TRIM15 0xE #define PALMAS_GPADC_TRIM16 0xF +static inline int palmas_read(struct palmas *palmas, unsigned int base, + unsigned int reg, unsigned int *val) +{ + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); + int slave_id = PALMAS_BASE_TO_SLAVE(base); + + return regmap_read(palmas->regmap[slave_id], addr, val); +} + +static inline int palmas_write(struct palmas *palmas, unsigned int base, + unsigned int reg, unsigned int value) +{ + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); + int slave_id = PALMAS_BASE_TO_SLAVE(base); + + return regmap_write(palmas->regmap[slave_id], addr, value); +} + +static inline int palmas_bulk_write(struct palmas *palmas, unsigned int base, + unsigned int reg, const void *val, size_t val_count) +{ + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); + int slave_id = PALMAS_BASE_TO_SLAVE(base); + + return regmap_bulk_write(palmas->regmap[slave_id], addr, + val, val_count); +} + +static inline int palmas_bulk_read(struct palmas *palmas, unsigned int base, + unsigned int reg, void *val, size_t val_count) +{ + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); + int slave_id = PALMAS_BASE_TO_SLAVE(base); + + return regmap_bulk_read(palmas->regmap[slave_id], addr, + val, val_count); +} + +static inline int palmas_update_bits(struct palmas *palmas, unsigned int base, + unsigned int reg, unsigned int mask, unsigned int val) +{ + unsigned int addr = PALMAS_BASE_TO_REG(base, reg); + int slave_id = PALMAS_BASE_TO_SLAVE(base); + + return regmap_update_bits(palmas->regmap[slave_id], addr, mask, val); +} + +static inline int palmas_irq_get_virq(struct palmas *palmas, int irq) +{ + return regmap_irq_get_virq(palmas->irq_data, irq); +} + #endif /* __LINUX_MFD_PALMAS_H */