regulator: tps65090: add wait_timeout support for FETx
[linux-2.6.git] / include / linux / mfd / tps65090.h
1 /*
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
25 #include <linux/irq.h>
26 #include <linux/regmap.h>
27
28 struct tps65090_charger_data {
29         int irq_base;
30         void (*update_status)(void);
31 };
32
33 struct tps65090 {
34         struct device           *dev;
35         struct regmap           *rmap;
36         struct irq_chip         irq_chip;
37         struct mutex            irq_lock;
38         int                     irq_base;
39 };
40
41 struct tps65090_platform_data {
42         int irq_base;
43         unsigned long irq_flag;
44         struct tps65090_regulator_platform_data **reg_pdata;
45         int num_reg_pdata;
46         struct tps65090_charger_data *charger_pdata;
47 };
48
49 /* Define tps65090 IRQ numbers */
50 enum tps65090_irqs {
51         /* IRQ1 registers */
52         TPS65090_IRQ,
53         TPS65090_VACG_IRQ,
54         TPS65090_VSYSG_IRQ,
55         TPS65090_VBATG_IRQ,
56         TPS65090_CGACT_IRQ,
57         TPS65090_CGCPL_IRQ,
58         TPS65090_OLDCDC1_IRQ,
59         TPS65090_OLDCDC2_IRQ,
60         /* IRQ2 registers */
61         TPS65090_OLDCDC3_IRQ,
62         TPS65090_OLFET1_IRQ,
63         TPS65090_OLFET2_IRQ,
64         TPS65090_OLFET3_IRQ,
65         TPS65090_OLFET4_IRQ,
66         TPS65090_OLFET5_IRQ,
67         TPS65090_OLFET6_IRQ,
68         TPS65090_OLFET7_IRQ,
69         TPS65090_NUM_IRQ,
70 };
71
72 /*
73  * NOTE: the functions below are not intended for use outside
74  * of the TPS65090 sub-device drivers
75  */
76 static inline int tps65090_write(struct device *dev, int reg, uint8_t val)
77 {
78         struct tps65090 *tps = dev_get_drvdata(dev);
79
80         return regmap_write(tps->rmap, reg, val);
81 }
82
83 static inline int tps65090_read(struct device *dev, int reg, uint8_t *val)
84 {
85         struct tps65090 *tps = dev_get_drvdata(dev);
86         unsigned int temp_val;
87         int ret;
88
89         ret = regmap_read(tps->rmap, reg, &temp_val);
90         if (!ret)
91                 *val = temp_val;
92         return ret;
93 }
94
95 static inline int tps65090_set_bits(struct device *dev, int reg,
96                 uint8_t bit_num)
97 {
98         struct tps65090 *tps = dev_get_drvdata(dev);
99
100         return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u);
101 }
102
103 static inline int tps65090_clr_bits(struct device *dev, int reg,
104                 uint8_t bit_num)
105 {
106         struct tps65090 *tps = dev_get_drvdata(dev);
107
108         return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
109 }
110
111 static inline int tps65090_update_bits(struct device *dev, int reg,
112                 uint8_t bit_mask, uint8_t val)
113 {
114         struct tps65090 *tps = dev_get_drvdata(dev);
115
116         return regmap_update_bits(tps->rmap, reg, bit_mask, val);
117 }
118
119 #endif /*__LINUX_MFD_TPS65090_H */