mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan@nvidia.com>
To: <sameo@linux.intel.com>, <linus.walleij@linaro.org>,
	<grant.likely@secretlab.ca>, <akpm@linux-foundation.org>
Cc: <a.zummo@towertech.it>, <broonie@opensource.wolfsonmicro.com>,
	<linux-kernel@vger.kernel.org>, <rtc-linux@googlegroups.com>,
	Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 2/4] mfd: palmas: add apis to access the Palmas' registers
Date: Thu, 3 Jan 2013 16:16:58 +0530	[thread overview]
Message-ID: <1357210020-19876-3-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1357210020-19876-1-git-send-email-ldewangan@nvidia.com>

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 <ldewangan@nvidia.com>
---
 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 */
-- 
1.7.1.1


  parent reply	other threads:[~2013-01-03 10:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-03 10:46 [PATCH 0/4] mfd: palma: add RTC and GPIO support Laxman Dewangan
2013-01-03 10:46 ` [PATCH 1/4] mfd: palmas: add rtc irq number as irq resource for palmas-rtc Laxman Dewangan
2013-01-03 10:46 ` Laxman Dewangan [this message]
2013-01-03 10:46 ` [PATCH 3/4] gpio: palmas: Add support for Palams GPIO Laxman Dewangan
2013-01-10 10:57   ` Linus Walleij
2013-01-10 11:03     ` Laxman Dewangan
2013-01-10 11:05     ` Mark Brown
2013-01-17 10:34   ` Linus Walleij
2013-01-17 10:35     ` Mark Brown
2013-01-17 10:37       ` Laxman Dewangan
2013-01-17 13:58         ` [rtc-linux] " Linus Walleij
2013-01-03 10:47 ` [PATCH 4/4] rtc: palmas: add RTC driver Palmas series PMIC Laxman Dewangan
2013-01-24  4:49 ` [PATCH 0/4] mfd: palma: add RTC and GPIO support Laxman Dewangan
2013-01-27  0:28 ` Samuel Ortiz
2013-01-27  8:45   ` Laxman Dewangan
2013-01-27 21:28     ` Samuel Ortiz
2013-01-28  5:30       ` Laxman Dewangan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357210020-19876-3-git-send-email-ldewangan@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=a.zummo@towertech.it \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®