blob: 1a5f916b73830f294115247979102c5e8ac02eda [file] [log] [blame]
Venu Byravarasu3c33be062012-03-16 11:10:19 +05301/*
2 * Core driver interface for TI TPS65090 PMIC family
3 *
4 * Copyright (C) 2012 NVIDIA Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 */
21
22#ifndef __LINUX_MFD_TPS65090_H
23#define __LINUX_MFD_TPS65090_H
24
Axel Lin06c49982012-04-17 17:08:56 +080025#include <linux/irq.h>
Laxman Dewanganb9c79322012-11-20 08:44:48 +053026#include <linux/regmap.h>
Axel Lin06c49982012-04-17 17:08:56 +080027
28struct tps65090 {
Axel Lin06c49982012-04-17 17:08:56 +080029 struct device *dev;
Axel Lin06c49982012-04-17 17:08:56 +080030 struct regmap *rmap;
31 struct irq_chip irq_chip;
32 struct mutex irq_lock;
33 int irq_base;
Venu Byravarasu3c33be062012-03-16 11:10:19 +053034};
35
36struct tps65090_platform_data {
37 int irq_base;
Venu Byravarasu3c33be062012-03-16 11:10:19 +053038};
39
40/*
41 * NOTE: the functions below are not intended for use outside
42 * of the TPS65090 sub-device drivers
43 */
Laxman Dewanganb9c79322012-11-20 08:44:48 +053044static inline int tps65090_write(struct device *dev, int reg, uint8_t val)
45{
46 struct tps65090 *tps = dev_get_drvdata(dev);
47
48 return regmap_write(tps->rmap, reg, val);
49}
50
51static inline int tps65090_read(struct device *dev, int reg, uint8_t *val)
52{
53 struct tps65090 *tps = dev_get_drvdata(dev);
54 unsigned int temp_val;
55 int ret;
56
57 ret = regmap_read(tps->rmap, reg, &temp_val);
58 if (!ret)
59 *val = temp_val;
60 return ret;
61}
62
63static inline int tps65090_set_bits(struct device *dev, int reg,
64 uint8_t bit_num)
65{
66 struct tps65090 *tps = dev_get_drvdata(dev);
67
68 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u);
69}
70
71static inline int tps65090_clr_bits(struct device *dev, int reg,
72 uint8_t bit_num)
73{
74 struct tps65090 *tps = dev_get_drvdata(dev);
75
76 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
77}
Venu Byravarasu3c33be062012-03-16 11:10:19 +053078
79#endif /*__LINUX_MFD_TPS65090_H */