]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/commitdiff
mfd: palmas: Add APIs to access the Palmas' registers
authorLaxman Dewangan <ldewangan@nvidia.com>
Wed, 24 Apr 2013 06:20:53 +0000 (11:50 +0530)
committerJ Keerthy <j-keerthy@ti.com>
Tue, 28 May 2013 05:39:19 +0000 (11:09 +0530)
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.

This patch is picked up from Mainline kernel:
https://patchwork.kernel.org/patch/1926911/
Commit id: 60c185f059c88ad4b9b170b1f9322e3adcccca07

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
[j-keerthy@ti.com: backport from upstream 60c185f059c88ad4b9b170b1f9322e3adcccca07]
Signed-off-by: J Keerthy <j-keerthy@ti.com>
include/linux/mfd/palmas.h

index 346bed95dd0fca56c852f2fc93cbdc898db49536..14a09657afa902509e00d853dc331ef7430fd282 100644 (file)
@@ -2850,4 +2850,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 */