aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-01-03 05:46:58 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-02-13 18:22:44 -0500
commit60c185f059c88ad4b9b170b1f9322e3adcccca07 (patch)
tree413128ca84526604a04527605e6ed2b9f8a8f192
parenta36516b016f52f0f6e5284025e3487f63b4be33b (diff)
mfd: palmas: Add APIs to access the Palmas' registers
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> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--include/linux/mfd/palmas.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 29f6616e12f0..a4d13d7cd001 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -2789,4 +2789,56 @@ enum usb_irq_events {
2789#define PALMAS_GPADC_TRIM15 0xE 2789#define PALMAS_GPADC_TRIM15 0xE
2790#define PALMAS_GPADC_TRIM16 0xF 2790#define PALMAS_GPADC_TRIM16 0xF
2791 2791
2792static inline int palmas_read(struct palmas *palmas, unsigned int base,
2793 unsigned int reg, unsigned int *val)
2794{
2795 unsigned int addr = PALMAS_BASE_TO_REG(base, reg);
2796 int slave_id = PALMAS_BASE_TO_SLAVE(base);
2797
2798 return regmap_read(palmas->regmap[slave_id], addr, val);
2799}
2800
2801static inline int palmas_write(struct palmas *palmas, unsigned int base,
2802 unsigned int reg, unsigned int value)
2803{
2804 unsigned int addr = PALMAS_BASE_TO_REG(base, reg);
2805 int slave_id = PALMAS_BASE_TO_SLAVE(base);
2806
2807 return regmap_write(palmas->regmap[slave_id], addr, value);
2808}
2809
2810static inline int palmas_bulk_write(struct palmas *palmas, unsigned int base,
2811 unsigned int reg, const void *val, size_t val_count)
2812{
2813 unsigned int addr = PALMAS_BASE_TO_REG(base, reg);
2814 int slave_id = PALMAS_BASE_TO_SLAVE(base);
2815
2816 return regmap_bulk_write(palmas->regmap[slave_id], addr,
2817 val, val_count);
2818}
2819
2820static inline int palmas_bulk_read(struct palmas *palmas, unsigned int base,
2821 unsigned int reg, void *val, size_t val_count)
2822{
2823 unsigned int addr = PALMAS_BASE_TO_REG(base, reg);
2824 int slave_id = PALMAS_BASE_TO_SLAVE(base);
2825
2826 return regmap_bulk_read(palmas->regmap[slave_id], addr,
2827 val, val_count);
2828}
2829
2830static inline int palmas_update_bits(struct palmas *palmas, unsigned int base,
2831 unsigned int reg, unsigned int mask, unsigned int val)
2832{
2833 unsigned int addr = PALMAS_BASE_TO_REG(base, reg);
2834 int slave_id = PALMAS_BASE_TO_SLAVE(base);
2835
2836 return regmap_update_bits(palmas->regmap[slave_id], addr, mask, val);
2837}
2838
2839static inline int palmas_irq_get_virq(struct palmas *palmas, int irq)
2840{
2841 return regmap_irq_get_virq(palmas->irq_data, irq);
2842}
2843
2792#endif /* __LINUX_MFD_PALMAS_H */ 2844#endif /* __LINUX_MFD_PALMAS_H */