blob: 3f43069413e72dcc2975a14c1e9edf5677365627 [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
Laxman Dewangan759f2592012-11-20 08:44:49 +053028/* TPS65090 IRQs */
29enum {
Rhyland Klein751391c2013-03-12 18:08:06 -040030 TPS65090_IRQ_INTERRUPT,
Laxman Dewangan759f2592012-11-20 08:44:49 +053031 TPS65090_IRQ_VAC_STATUS_CHANGE,
32 TPS65090_IRQ_VSYS_STATUS_CHANGE,
33 TPS65090_IRQ_BAT_STATUS_CHANGE,
34 TPS65090_IRQ_CHARGING_STATUS_CHANGE,
35 TPS65090_IRQ_CHARGING_COMPLETE,
36 TPS65090_IRQ_OVERLOAD_DCDC1,
37 TPS65090_IRQ_OVERLOAD_DCDC2,
38 TPS65090_IRQ_OVERLOAD_DCDC3,
39 TPS65090_IRQ_OVERLOAD_FET1,
40 TPS65090_IRQ_OVERLOAD_FET2,
41 TPS65090_IRQ_OVERLOAD_FET3,
42 TPS65090_IRQ_OVERLOAD_FET4,
43 TPS65090_IRQ_OVERLOAD_FET5,
44 TPS65090_IRQ_OVERLOAD_FET6,
45 TPS65090_IRQ_OVERLOAD_FET7,
46};
Axel Lin06c49982012-04-17 17:08:56 +080047
Laxman Dewangan24282a12012-10-09 15:18:59 +053048/* TPS65090 Regulator ID */
49enum {
Laxman Dewangan8620ca92012-10-09 15:19:00 +053050 TPS65090_REGULATOR_DCDC1,
51 TPS65090_REGULATOR_DCDC2,
52 TPS65090_REGULATOR_DCDC3,
53 TPS65090_REGULATOR_FET1,
54 TPS65090_REGULATOR_FET2,
55 TPS65090_REGULATOR_FET3,
56 TPS65090_REGULATOR_FET4,
57 TPS65090_REGULATOR_FET5,
58 TPS65090_REGULATOR_FET6,
59 TPS65090_REGULATOR_FET7,
Laxman Dewangan3a81ef82012-10-09 15:19:01 +053060 TPS65090_REGULATOR_LDO1,
61 TPS65090_REGULATOR_LDO2,
Laxman Dewangan24282a12012-10-09 15:18:59 +053062
63 /* Last entry for maximum ID */
Laxman Dewangan8620ca92012-10-09 15:19:00 +053064 TPS65090_REGULATOR_MAX,
Laxman Dewangan24282a12012-10-09 15:18:59 +053065};
66
Axel Lin06c49982012-04-17 17:08:56 +080067struct tps65090 {
Axel Lin06c49982012-04-17 17:08:56 +080068 struct device *dev;
Axel Lin06c49982012-04-17 17:08:56 +080069 struct regmap *rmap;
Laxman Dewangan759f2592012-11-20 08:44:49 +053070 struct regmap_irq_chip_data *irq_data;
Venu Byravarasu3c33be062012-03-16 11:10:19 +053071};
72
Laxman Dewangan24282a12012-10-09 15:18:59 +053073/*
74 * struct tps65090_regulator_plat_data
75 *
76 * @reg_init_data: The regulator init data.
Laxman Dewanganf329b172012-10-09 15:19:02 +053077 * @enable_ext_control: Enable extrenal control or not. Only available for
78 * DCDC1, DCDC2 and DCDC3.
79 * @gpio: Gpio number if external control is enabled and controlled through
80 * gpio.
Laxman Dewangan24282a12012-10-09 15:18:59 +053081 */
Laxman Dewangan24282a12012-10-09 15:18:59 +053082struct tps65090_regulator_plat_data {
83 struct regulator_init_data *reg_init_data;
Laxman Dewanganf329b172012-10-09 15:19:02 +053084 bool enable_ext_control;
85 int gpio;
Laxman Dewangan24282a12012-10-09 15:18:59 +053086};
87
Venu Byravarasu3c33be062012-03-16 11:10:19 +053088struct tps65090_platform_data {
89 int irq_base;
Rhyland Klein6f8da5d2013-03-12 18:08:09 -040090
91 char **supplied_to;
92 size_t num_supplicants;
93 int enable_low_current_chrg;
94
Laxman Dewangan8620ca92012-10-09 15:19:00 +053095 struct tps65090_regulator_plat_data *reg_pdata[TPS65090_REGULATOR_MAX];
Venu Byravarasu3c33be062012-03-16 11:10:19 +053096};
97
98/*
99 * NOTE: the functions below are not intended for use outside
100 * of the TPS65090 sub-device drivers
101 */
Laxman Dewanganb9c79322012-11-20 08:44:48 +0530102static inline int tps65090_write(struct device *dev, int reg, uint8_t val)
103{
104 struct tps65090 *tps = dev_get_drvdata(dev);
105
106 return regmap_write(tps->rmap, reg, val);
107}
108
109static inline int tps65090_read(struct device *dev, int reg, uint8_t *val)
110{
111 struct tps65090 *tps = dev_get_drvdata(dev);
112 unsigned int temp_val;
113 int ret;
114
115 ret = regmap_read(tps->rmap, reg, &temp_val);
116 if (!ret)
117 *val = temp_val;
118 return ret;
119}
120
121static inline int tps65090_set_bits(struct device *dev, int reg,
122 uint8_t bit_num)
123{
124 struct tps65090 *tps = dev_get_drvdata(dev);
125
126 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u);
127}
128
129static inline int tps65090_clr_bits(struct device *dev, int reg,
130 uint8_t bit_num)
131{
132 struct tps65090 *tps = dev_get_drvdata(dev);
133
134 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
135}
Venu Byravarasu3c33be062012-03-16 11:10:19 +0530136
137#endif /*__LINUX_MFD_TPS65090_H */