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 regmap;
20 
21 struct lm3533 {
22 	struct device *dev;
23 
24 	struct regmap *regmap;
25 
26 	int gpio_hwen;
27 	int irq;
28 
29 	unsigned have_als:1;
30 	unsigned have_backlights:1;
31 	unsigned have_leds:1;
32 };
33 
34 struct lm3533_ctrlbank {
35 	struct lm3533 *lm3533;
36 	struct device *dev;
37 	int id;
38 };
39 
40 struct lm3533_als_platform_data {
41 	unsigned pwm_mode:1;		/* PWM input mode (default analog) */
42 	u8 r_select;			/* 1 - 127 (ignored in PWM-mode) */
43 };
44 
45 struct lm3533_bl_platform_data {
46 	char *name;
47 	u16 max_current;		/* 5000 - 29800 uA (800 uA step) */
48 	u8 default_brightness;		/* 0 - 255 */
49 	u8 pwm;				/* 0 - 0x3f */
50 };
51 
52 struct lm3533_led_platform_data {
53 	char *name;
54 	const char *default_trigger;
55 	u16 max_current;		/* 5000 - 29800 uA (800 uA step) */
56 	u8 pwm;				/* 0 - 0x3f */
57 };
58 
59 enum lm3533_boost_freq {
60 	LM3533_BOOST_FREQ_500KHZ,
61 	LM3533_BOOST_FREQ_1000KHZ,
62 };
63 
64 enum lm3533_boost_ovp {
65 	LM3533_BOOST_OVP_16V,
66 	LM3533_BOOST_OVP_24V,
67 	LM3533_BOOST_OVP_32V,
68 	LM3533_BOOST_OVP_40V,
69 };
70 
71 struct lm3533_platform_data {
72 	int gpio_hwen;
73 
74 	enum lm3533_boost_ovp boost_ovp;
75 	enum lm3533_boost_freq boost_freq;
76 
77 	struct lm3533_als_platform_data *als;
78 
79 	struct lm3533_bl_platform_data *backlights;
80 	int num_backlights;
81 
82 	struct lm3533_led_platform_data *leds;
83 	int num_leds;
84 };
85 
86 extern int lm3533_ctrlbank_enable(struct lm3533_ctrlbank *cb);
87 extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb);
88 
89 extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val);
90 extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val);
91 extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb,
92 								u16 imax);
93 extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val);
94 extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val);
95 
96 extern int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val);
97 extern int lm3533_write(struct lm3533 *lm3533, u8 reg, u8 val);
98 extern int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask);
99 
100 #endif	/* __LINUX_MFD_LM3533_H */
101