xref: /linux/include/linux/mfd/lm3533.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * lm3533.h -- LM3533 interface
4  *
5  * Copyright (C) 2011-2012 Texas Instruments
6  *
7  * Author: Johan Hovold <jhovold@gmail.com>
8  */
9 
10 #ifndef __LINUX_MFD_LM3533_H
11 #define __LINUX_MFD_LM3533_H
12 
13 #define LM3533_ATTR_RO(_name) \
14 	DEVICE_ATTR(_name, S_IRUGO, show_##_name, NULL)
15 #define LM3533_ATTR_RW(_name) \
16 	DEVICE_ATTR(_name, S_IRUGO | S_IWUSR , show_##_name, store_##_name)
17 
18 struct device;
19 struct gpio_desc;
20 struct regmap;
21 
22 struct lm3533 {
23 	struct device *dev;
24 
25 	struct regmap *regmap;
26 
27 	struct gpio_desc *hwen;
28 	int irq;
29 
30 	unsigned have_als:1;
31 	unsigned have_backlights:1;
32 	unsigned have_leds:1;
33 };
34 
35 struct lm3533_ctrlbank {
36 	struct lm3533 *lm3533;
37 	struct device *dev;
38 	int id;
39 };
40 
41 struct lm3533_als_platform_data {
42 	unsigned pwm_mode:1;		/* PWM input mode (default analog) */
43 	u8 r_select;			/* 1 - 127 (ignored in PWM-mode) */
44 };
45 
46 struct lm3533_bl_platform_data {
47 	char *name;
48 	u16 max_current;		/* 5000 - 29800 uA (800 uA step) */
49 	u8 default_brightness;		/* 0 - 255 */
50 	u8 pwm;				/* 0 - 0x3f */
51 };
52 
53 struct lm3533_led_platform_data {
54 	char *name;
55 	const char *default_trigger;
56 	u16 max_current;		/* 5000 - 29800 uA (800 uA step) */
57 	u8 pwm;				/* 0 - 0x3f */
58 };
59 
60 enum lm3533_boost_freq {
61 	LM3533_BOOST_FREQ_500KHZ,
62 	LM3533_BOOST_FREQ_1000KHZ,
63 };
64 
65 enum lm3533_boost_ovp {
66 	LM3533_BOOST_OVP_16V,
67 	LM3533_BOOST_OVP_24V,
68 	LM3533_BOOST_OVP_32V,
69 	LM3533_BOOST_OVP_40V,
70 };
71 
72 struct lm3533_platform_data {
73 	enum lm3533_boost_ovp boost_ovp;
74 	enum lm3533_boost_freq boost_freq;
75 
76 	struct lm3533_als_platform_data *als;
77 
78 	struct lm3533_bl_platform_data *backlights;
79 	int num_backlights;
80 
81 	struct lm3533_led_platform_data *leds;
82 	int num_leds;
83 };
84 
85 extern int lm3533_ctrlbank_enable(struct lm3533_ctrlbank *cb);
86 extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb);
87 
88 extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val);
89 extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val);
90 extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb,
91 								u16 imax);
92 extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val);
93 extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val);
94 
95 extern int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val);
96 extern int lm3533_write(struct lm3533 *lm3533, u8 reg, u8 val);
97 extern int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask);
98 
99 #endif	/* __LINUX_MFD_LM3533_H */
100