blob: 4bbbb1350b91f8fd0f84e775a38a75c5b2328cf9 [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 {
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};
46
Axel Lin06c49982012-04-17 17:08:56 +080047struct tps65090 {
Axel Lin06c49982012-04-17 17:08:56 +080048 struct device *dev;
Axel Lin06c49982012-04-17 17:08:56 +080049 struct regmap *rmap;
Laxman Dewangan759f2592012-11-20 08:44:49 +053050 struct regmap_irq_chip_data *irq_data;
Venu Byravarasu3c33be062012-03-16 11:10:19 +053051};
52
53struct tps65090_platform_data {
54 int irq_base;
Venu Byravarasu3c33be062012-03-16 11:10:19 +053055};
56
57/*
58 * NOTE: the functions below are not intended for use outside
59 * of the TPS65090 sub-device drivers
60 */
Laxman Dewanganb9c79322012-11-20 08:44:48 +053061static inline int tps65090_write(struct device *dev, int reg, uint8_t val)
62{
63 struct tps65090 *tps = dev_get_drvdata(dev);
64
65 return regmap_write(tps->rmap, reg, val);
66}
67
68static inline int tps65090_read(struct device *dev, int reg, uint8_t *val)
69{
70 struct tps65090 *tps = dev_get_drvdata(dev);
71 unsigned int temp_val;
72 int ret;
73
74 ret = regmap_read(tps->rmap, reg, &temp_val);
75 if (!ret)
76 *val = temp_val;
77 return ret;
78}
79
80static inline int tps65090_set_bits(struct device *dev, int reg,
81 uint8_t bit_num)
82{
83 struct tps65090 *tps = dev_get_drvdata(dev);
84
85 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u);
86}
87
88static inline int tps65090_clr_bits(struct device *dev, int reg,
89 uint8_t bit_num)
90{
91 struct tps65090 *tps = dev_get_drvdata(dev);
92
93 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
94}
Venu Byravarasu3c33be062012-03-16 11:10:19 +053095
96#endif /*__LINUX_MFD_TPS65090_H */