Commit | Line | Data |
---|---|---|
3c33be06 VB |
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 | ||
06c4998b | 25 | #include <linux/irq.h> |
b9c79323 | 26 | #include <linux/regmap.h> |
06c4998b | 27 | |
759f2598 LD |
28 | /* TPS65090 IRQs */ |
29 | enum { | |
30 | TPS65090_IRQ_VAC_STATUS_CHANGE, | |
31 | TPS65090_IRQ_VSYS_STATUS_CHANGE, | |
32 | TPS65090_IRQ_BAT_STATUS_CHANGE, | |
33 | TPS65090_IRQ_CHARGING_STATUS_CHANGE, | |
34 | TPS65090_IRQ_CHARGING_COMPLETE, | |
35 | TPS65090_IRQ_OVERLOAD_DCDC1, | |
36 | TPS65090_IRQ_OVERLOAD_DCDC2, | |
37 | TPS65090_IRQ_OVERLOAD_DCDC3, | |
38 | TPS65090_IRQ_OVERLOAD_FET1, | |
39 | TPS65090_IRQ_OVERLOAD_FET2, | |
40 | TPS65090_IRQ_OVERLOAD_FET3, | |
41 | TPS65090_IRQ_OVERLOAD_FET4, | |
42 | TPS65090_IRQ_OVERLOAD_FET5, | |
43 | TPS65090_IRQ_OVERLOAD_FET6, | |
44 | TPS65090_IRQ_OVERLOAD_FET7, | |
45 | }; | |
06c4998b | 46 | |
24282a1c LD |
47 | /* TPS65090 Regulator ID */ |
48 | enum { | |
8620ca9f LD |
49 | TPS65090_REGULATOR_DCDC1, |
50 | TPS65090_REGULATOR_DCDC2, | |
51 | TPS65090_REGULATOR_DCDC3, | |
52 | TPS65090_REGULATOR_FET1, | |
53 | TPS65090_REGULATOR_FET2, | |
54 | TPS65090_REGULATOR_FET3, | |
55 | TPS65090_REGULATOR_FET4, | |
56 | TPS65090_REGULATOR_FET5, | |
57 | TPS65090_REGULATOR_FET6, | |
58 | TPS65090_REGULATOR_FET7, | |
3a81ef8c LD |
59 | TPS65090_REGULATOR_LDO1, |
60 | TPS65090_REGULATOR_LDO2, | |
24282a1c LD |
61 | |
62 | /* Last entry for maximum ID */ | |
8620ca9f | 63 | TPS65090_REGULATOR_MAX, |
24282a1c LD |
64 | }; |
65 | ||
06c4998b | 66 | struct tps65090 { |
06c4998b | 67 | struct device *dev; |
06c4998b | 68 | struct regmap *rmap; |
759f2598 | 69 | struct regmap_irq_chip_data *irq_data; |
3c33be06 VB |
70 | }; |
71 | ||
24282a1c LD |
72 | /* |
73 | * struct tps65090_regulator_plat_data | |
74 | * | |
75 | * @reg_init_data: The regulator init data. | |
f329b175 LD |
76 | * @enable_ext_control: Enable extrenal control or not. Only available for |
77 | * DCDC1, DCDC2 and DCDC3. | |
78 | * @gpio: Gpio number if external control is enabled and controlled through | |
79 | * gpio. | |
24282a1c | 80 | */ |
24282a1c LD |
81 | struct tps65090_regulator_plat_data { |
82 | struct regulator_init_data *reg_init_data; | |
f329b175 LD |
83 | bool enable_ext_control; |
84 | int gpio; | |
24282a1c LD |
85 | }; |
86 | ||
3c33be06 VB |
87 | struct tps65090_platform_data { |
88 | int irq_base; | |
6f8da5df RK |
89 | |
90 | char **supplied_to; | |
91 | size_t num_supplicants; | |
92 | int enable_low_current_chrg; | |
93 | ||
8620ca9f | 94 | struct tps65090_regulator_plat_data *reg_pdata[TPS65090_REGULATOR_MAX]; |
3c33be06 VB |
95 | }; |
96 | ||
97 | /* | |
98 | * NOTE: the functions below are not intended for use outside | |
99 | * of the TPS65090 sub-device drivers | |
100 | */ | |
b9c79323 LD |
101 | static inline int tps65090_write(struct device *dev, int reg, uint8_t val) |
102 | { | |
103 | struct tps65090 *tps = dev_get_drvdata(dev); | |
104 | ||
105 | return regmap_write(tps->rmap, reg, val); | |
106 | } | |
107 | ||
108 | static inline int tps65090_read(struct device *dev, int reg, uint8_t *val) | |
109 | { | |
110 | struct tps65090 *tps = dev_get_drvdata(dev); | |
111 | unsigned int temp_val; | |
112 | int ret; | |
113 | ||
114 | ret = regmap_read(tps->rmap, reg, &temp_val); | |
115 | if (!ret) | |
116 | *val = temp_val; | |
117 | return ret; | |
118 | } | |
119 | ||
120 | static inline int tps65090_set_bits(struct device *dev, int reg, | |
121 | uint8_t bit_num) | |
122 | { | |
123 | struct tps65090 *tps = dev_get_drvdata(dev); | |
124 | ||
125 | return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u); | |
126 | } | |
127 | ||
128 | static inline int tps65090_clr_bits(struct device *dev, int reg, | |
129 | uint8_t bit_num) | |
130 | { | |
131 | struct tps65090 *tps = dev_get_drvdata(dev); | |
132 | ||
133 | return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u); | |
134 | } | |
3c33be06 VB |
135 | |
136 | #endif /*__LINUX_MFD_TPS65090_H */ |