aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mfd/tps6591x.h
blob: d0d829fc8aba8f30643dc4ca6cd43faad029cf7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * include/linux/mfd/tps6591x.c
 * Core driver interface for TI TPS6591x PMIC family
 *
 * Copyright (C) 2011 NVIDIA Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#ifndef __LINUX_MFD_TPS6591X_H
#define __LINUX_MFD_TPS6591X_H

#include <linux/rtc.h>

enum {
	TPS6591X_INT_PWRHOLD_F,
	TPS6591X_INT_VMBHI,
	TPS6591X_INT_PWRON,
	TPS6591X_INT_PWRON_LP,
	TPS6591X_INT_PWRHOLD_R,
	TPS6591X_INT_HOTDIE,
	TPS6591X_INT_RTC_ALARM,
	TPS6591X_INT_RTC_PERIOD,
	TPS6591X_INT_GPIO0,
	TPS6591X_INT_GPIO1,
	TPS6591X_INT_GPIO2,
	TPS6591X_INT_GPIO3,
	TPS6591X_INT_GPIO4,
	TPS6591X_INT_GPIO5,
	TPS6591X_INT_WTCHDG,
	TPS6591X_INT_VMBCH2_H,
	TPS6591X_INT_VMBCH2_L,
	TPS6591X_INT_PWRDN,

	/* Last entry */
	TPS6591X_INT_NR,
};

/* Gpio definitions */
enum {
	TPS6591X_GPIO_GP0 = 0,
	TPS6591X_GPIO_GP1 = 1,
	TPS6591X_GPIO_GP2 = 2,
	TPS6591X_GPIO_GP3 = 3,
	TPS6591X_GPIO_GP4 = 4,
	TPS6591X_GPIO_GP5 = 5,
	TPS6591X_GPIO_GP6 = 6,
	TPS6591X_GPIO_GP7 = 7,
	TPS6591X_GPIO_GP8 = 8,

	/* Last entry */
	TPS6591X_GPIO_NR,
};

struct tps6591x_subdev_info {
	int		id;
	const char	*name;
	void		*platform_data;
};

struct tps6591x_rtc_platform_data {
	int irq;
	struct rtc_time time;
};

struct tps6591x_sleep_keepon_data {
	/* set 1 to maintain the following on sleep mode */
	unsigned therm_keepon:1;	/* themal monitoring */
	unsigned clkout32k_keepon:1;	/* CLK32KOUT */
	unsigned vrtc_keepon:1;		/* LD0 full load capability */
	unsigned i2chs_keepon:1;	/* high speed internal clock */
};

struct tps6591x_gpio_init_data {
	unsigned sleep_en:1;	/* Enable sleep mode */
	unsigned pulldn_en:1;	/* Enable pull down */
	unsigned output_mode_en:1; /* Enable output mode during init */
	unsigned output_val:1;	/* Output value if it is in output mode */
	unsigned init_apply:1;	/* Apply init data on configuring gpios*/
};

struct tps6591x_platform_data {
	int gpio_base;
	int irq_base;

	int num_subdevs;
	struct tps6591x_subdev_info *subdevs;

	bool dev_slp_en;
	struct tps6591x_sleep_keepon_data *slp_keepon;

	struct tps6591x_gpio_init_data *gpio_init_data;
	int num_gpioinit_data;

	bool use_power_off;
};

/*
 * NOTE: the functions below are not intended for use outside
 * of the TPS6591X sub-device drivers
 */
extern int tps6591x_write(struct device *dev, int reg, uint8_t val);
extern int tps6591x_writes(struct device *dev, int reg, int len, uint8_t *val);
extern int tps6591x_read(struct device *dev, int reg, uint8_t *val);
extern int tps6591x_reads(struct device *dev, int reg, int len, uint8_t *val);
extern int tps6591x_set_bits(struct device *dev, int reg, uint8_t bit_mask);
extern int tps6591x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
extern int tps6591x_update(struct device *dev, int reg, uint8_t val,
			   uint8_t mask);

#endif /*__LINUX_MFD_TPS6591X_H */