summaryrefslogtreecommitdiff
path: root/include/linux/mfd/max8831.h
blob: 45c640e77843f913986ba5c6cfaef715ac38780b (plain)
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
/*
 * include/linux/mfd/max8831.h
 *
 * Copyright (C) 2012-2013 NVIDIA Corporation. All rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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.
 *
 */

#include <linux/regmap.h>

#ifndef __LINUX_MFD_MAX8831
#define __LINUX_MFD_MAX8831
/*LED MAX8831 Registers */
#define MAX8831_CTRL			0x00

#define MAX8831_CTRL_LED1_ENB		1
#define MAX8831_CTRL_LED2_ENB		(1<<1)
#define MAX8831_CTRL_LED3_ENB		(1<<2)
#define MAX8831_CTRL_LED4_ENB		(1<<3)
#define MAX8831_CTRL_LED5_ENB		(1<<4)

#define MAX8831_RAMP_CTRL_LED1		0x03
#define MAX8831_RAMP_CTRL_LED2		0x04
#define MAX8831_RAMP_CTRL_LED3		0x05
#define MAX8831_RAMP_CTRL_LED4		0x06
#define MAX8831_RAMP_CTRL_LED5		0x07

#define MAX8831_CURRENT_CTRL_LED1	0x0B
#define MAX8831_CURRENT_CTRL_LED2	0x0C
#define MAX8831_CURRENT_CTRL_LED3	0x0D
#define MAX8831_CURRENT_CTRL_LED4	0x0E
#define MAX8831_CURRENT_CTRL_LED5	0x0F

#define MAX8831_BL_LEDS_MAX_CURR	0x7F
#define MAX8831_KEY_LEDS_MAX_CURR	0x1F

#define MAX8831_BLINK_CTRL_LED3		0x17
#define MAX8831_BLINK_CTRL_LED4		0x18
#define MAX8831_BLINK_CTRL_LED5		0x19

#define MAX8831_BLINK_ENB		(1<<6)
#define MAX8831_BLINK_OFF_TIMER_SHIFT	3
#define MAX8831_BLINK_ON_TIMER_SHIFT	0

#define MAX8831_BOOST_CTRL		0x1D
#define MAX8831_BOOST_CTRL_LED5		(1<<4)
#define MAX8831_BOOST_CTRL_LED4		(1<<3)
#define MAX8831_BOOST_CTRL_LED3		(1<<2)

#define MAX8831_LEDS_STAT1		0x2D
#define MAX8831_STAT1_LED1_FAULT	1
#define MAX8831_STAT1_LED2_FAULT	(1<<1)
#define MAX8831_STAT1_LED3_FAULT	(1<<2)
#define MAX8831_STAT1_LED4_FAULT	(1<<3)
#define MAX8831_STAT1_LED5_FAULT	(1<<4)

#define MAX8831_LEDS_STAT2		0x2E
#define MAX8831_STAT2_OSOD		(1<<2)
#define MAX8831_STAT2_TSD		(1<<1)
#define MAX8831_STAT2_OVP		1

/* IDs for each of the LEDs */
enum max8831_led_ids {
	MAX8831_ID_LED1,
	MAX8831_ID_LED2,
	MAX8831_ID_LED3,
	MAX8831_ID_LED4,
	MAX8831_ID_LED5,
	MAX8831_BL_LEDS,/* Refers to LED1 and LED2 together for video bl */
};

struct max8831_subdev_info {
	int		id;
	const char	*name;
	void		*platform_data;
	size_t		pdata_size;
};

struct max8831_platform_data {
	int				num_subdevs;
	struct max8831_subdev_info	*subdevs;
};

struct max8831_chip {
	struct i2c_client	*client;
	struct device		*dev;
	struct regmap		*regmap;

};

static inline int max8831_write(struct device *dev,
	unsigned int reg, unsigned int val)
{
	struct max8831_chip *chip = dev_get_drvdata(dev);
	return regmap_write(chip->regmap, reg, val);
}

static inline int max8831_read(struct device *dev,
	unsigned int reg, unsigned int *val)
{
	struct max8831_chip *chip = dev_get_drvdata(dev);
	return regmap_read(chip->regmap, reg, (unsigned int *) val);
}

static inline int max8831_update_bits(struct device *dev,
	unsigned int reg,
	unsigned int bit_mask,
	unsigned int val)
{
	struct max8831_chip *chip = dev_get_drvdata(dev);
	return regmap_update_bits(chip->regmap, reg, bit_mask, val);
}

#endif