1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * LP855x Backlight Driver
4  *
5  *			Copyright (C) 2011 Texas Instruments
6  */
7 
8 #ifndef _LP855X_H
9 #define _LP855X_H
10 
11 #define BL_CTL_SHFT	(0)
12 #define BRT_MODE_SHFT	(1)
13 #define BRT_MODE_MASK	(0x06)
14 
15 /* Enable backlight. Only valid when BRT_MODE=10(I2C only) */
16 #define ENABLE_BL	(1)
17 #define DISABLE_BL	(0)
18 
19 #define I2C_CONFIG(id)	id ## _I2C_CONFIG
20 #define PWM_CONFIG(id)	id ## _PWM_CONFIG
21 
22 /* DEVICE CONTROL register - LP8550 */
23 #define LP8550_PWM_CONFIG	(LP8550_PWM_ONLY << BRT_MODE_SHFT)
24 #define LP8550_I2C_CONFIG	((ENABLE_BL << BL_CTL_SHFT) | \
25 				(LP8550_I2C_ONLY << BRT_MODE_SHFT))
26 
27 /* DEVICE CONTROL register - LP8551 */
28 #define LP8551_PWM_CONFIG	LP8550_PWM_CONFIG
29 #define LP8551_I2C_CONFIG	LP8550_I2C_CONFIG
30 
31 /* DEVICE CONTROL register - LP8552 */
32 #define LP8552_PWM_CONFIG	LP8550_PWM_CONFIG
33 #define LP8552_I2C_CONFIG	LP8550_I2C_CONFIG
34 
35 /* DEVICE CONTROL register - LP8553 */
36 #define LP8553_PWM_CONFIG	LP8550_PWM_CONFIG
37 #define LP8553_I2C_CONFIG	LP8550_I2C_CONFIG
38 
39 /* CONFIG register - LP8555 */
40 #define LP8555_PWM_STANDBY	BIT(7)
41 #define LP8555_PWM_FILTER	BIT(6)
42 #define LP8555_RELOAD_EPROM	BIT(3)	/* use it if EPROMs should be reset
43 					   when the backlight turns on */
44 #define LP8555_OFF_OPENLEDS	BIT(2)
45 #define LP8555_PWM_CONFIG	LP8555_PWM_ONLY
46 #define LP8555_I2C_CONFIG	LP8555_I2C_ONLY
47 #define LP8555_COMB1_CONFIG	LP8555_COMBINED1
48 #define LP8555_COMB2_CONFIG	LP8555_COMBINED2
49 
50 /* DEVICE CONTROL register - LP8556 */
51 #define LP8556_PWM_CONFIG	(LP8556_PWM_ONLY << BRT_MODE_SHFT)
52 #define LP8556_COMB1_CONFIG	(LP8556_COMBINED1 << BRT_MODE_SHFT)
53 #define LP8556_I2C_CONFIG	((ENABLE_BL << BL_CTL_SHFT) | \
54 				(LP8556_I2C_ONLY << BRT_MODE_SHFT))
55 #define LP8556_COMB2_CONFIG	(LP8556_COMBINED2 << BRT_MODE_SHFT)
56 #define LP8556_FAST_CONFIG	BIT(7) /* use it if EPROMs should be maintained
57 					  when exiting the low power mode */
58 
59 /* CONFIG register - LP8557 */
60 #define LP8557_PWM_STANDBY	BIT(7)
61 #define LP8557_PWM_FILTER	BIT(6)
62 #define LP8557_RELOAD_EPROM	BIT(3)	/* use it if EPROMs should be reset
63 					   when the backlight turns on */
64 #define LP8557_OFF_OPENLEDS	BIT(2)
65 #define LP8557_PWM_CONFIG	LP8557_PWM_ONLY
66 #define LP8557_I2C_CONFIG	LP8557_I2C_ONLY
67 #define LP8557_COMB1_CONFIG	LP8557_COMBINED1
68 #define LP8557_COMB2_CONFIG	LP8557_COMBINED2
69 
70 enum lp855x_chip_id {
71 	LP8550,
72 	LP8551,
73 	LP8552,
74 	LP8553,
75 	LP8555,
76 	LP8556,
77 	LP8557,
78 };
79 
80 enum lp8550_brighntess_source {
81 	LP8550_PWM_ONLY,
82 	LP8550_I2C_ONLY = 2,
83 };
84 
85 enum lp8551_brighntess_source {
86 	LP8551_PWM_ONLY = LP8550_PWM_ONLY,
87 	LP8551_I2C_ONLY = LP8550_I2C_ONLY,
88 };
89 
90 enum lp8552_brighntess_source {
91 	LP8552_PWM_ONLY = LP8550_PWM_ONLY,
92 	LP8552_I2C_ONLY = LP8550_I2C_ONLY,
93 };
94 
95 enum lp8553_brighntess_source {
96 	LP8553_PWM_ONLY = LP8550_PWM_ONLY,
97 	LP8553_I2C_ONLY = LP8550_I2C_ONLY,
98 };
99 
100 enum lp8555_brightness_source {
101 	LP8555_PWM_ONLY,
102 	LP8555_I2C_ONLY,
103 	LP8555_COMBINED1,	/* Brightness register with shaped PWM */
104 	LP8555_COMBINED2,	/* PWM with shaped brightness register */
105 };
106 
107 enum lp8556_brightness_source {
108 	LP8556_PWM_ONLY,
109 	LP8556_COMBINED1,	/* pwm + i2c before the shaper block */
110 	LP8556_I2C_ONLY,
111 	LP8556_COMBINED2,	/* pwm + i2c after the shaper block */
112 };
113 
114 enum lp8557_brightness_source {
115 	LP8557_PWM_ONLY,
116 	LP8557_I2C_ONLY,
117 	LP8557_COMBINED1,	/* pwm + i2c after the shaper block */
118 	LP8557_COMBINED2,	/* pwm + i2c before the shaper block */
119 };
120 
121 struct lp855x_rom_data {
122 	u8 addr;
123 	u8 val;
124 };
125 
126 /**
127  * struct lp855x_platform_data
128  * @name : Backlight driver name. If it is not defined, default name is set.
129  * @device_control : value of DEVICE CONTROL register
130  * @initial_brightness : initial value of backlight brightness
131  * @period_ns : platform specific pwm period value. unit is nano.
132 		Only valid when mode is PWM_BASED.
133  * @size_program : total size of lp855x_rom_data
134  * @rom_data : list of new eeprom/eprom registers
135  */
136 struct lp855x_platform_data {
137 	const char *name;
138 	u8 device_control;
139 	u8 initial_brightness;
140 	unsigned int period_ns;
141 	int size_program;
142 	struct lp855x_rom_data *rom_data;
143 };
144 
145 #endif
146