| Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * LP855x Backlight Driver | 
 | 3 |  * | 
 | 4 |  *			Copyright (C) 2011 Texas Instruments | 
 | 5 |  * | 
 | 6 |  * This program is free software; you can redistribute it and/or modify | 
 | 7 |  * it under the terms of the GNU General Public License version 2 as | 
 | 8 |  * published by the Free Software Foundation. | 
 | 9 |  * | 
 | 10 |  */ | 
 | 11 |  | 
 | 12 | #ifndef _LP855X_H | 
 | 13 | #define _LP855X_H | 
 | 14 |  | 
 | 15 | #define BL_CTL_SHFT	(0) | 
 | 16 | #define BRT_MODE_SHFT	(1) | 
 | 17 | #define BRT_MODE_MASK	(0x06) | 
 | 18 |  | 
 | 19 | /* Enable backlight. Only valid when BRT_MODE=10(I2C only) */ | 
 | 20 | #define ENABLE_BL	(1) | 
 | 21 | #define DISABLE_BL	(0) | 
 | 22 |  | 
 | 23 | #define I2C_CONFIG(id)	id ## _I2C_CONFIG | 
 | 24 | #define PWM_CONFIG(id)	id ## _PWM_CONFIG | 
 | 25 |  | 
 | 26 | /* DEVICE CONTROL register - LP8550 */ | 
 | 27 | #define LP8550_PWM_CONFIG	(LP8550_PWM_ONLY << BRT_MODE_SHFT) | 
 | 28 | #define LP8550_I2C_CONFIG	((ENABLE_BL << BL_CTL_SHFT) | \ | 
 | 29 | 				(LP8550_I2C_ONLY << BRT_MODE_SHFT)) | 
 | 30 |  | 
 | 31 | /* DEVICE CONTROL register - LP8551 */ | 
 | 32 | #define LP8551_PWM_CONFIG	LP8550_PWM_CONFIG | 
 | 33 | #define LP8551_I2C_CONFIG	LP8550_I2C_CONFIG | 
 | 34 |  | 
 | 35 | /* DEVICE CONTROL register - LP8552 */ | 
 | 36 | #define LP8552_PWM_CONFIG	LP8550_PWM_CONFIG | 
 | 37 | #define LP8552_I2C_CONFIG	LP8550_I2C_CONFIG | 
 | 38 |  | 
 | 39 | /* DEVICE CONTROL register - LP8553 */ | 
 | 40 | #define LP8553_PWM_CONFIG	LP8550_PWM_CONFIG | 
 | 41 | #define LP8553_I2C_CONFIG	LP8550_I2C_CONFIG | 
 | 42 |  | 
 | 43 | /* DEVICE CONTROL register - LP8556 */ | 
 | 44 | #define LP8556_PWM_CONFIG	(LP8556_PWM_ONLY << BRT_MODE_SHFT) | 
 | 45 | #define LP8556_COMB1_CONFIG	(LP8556_COMBINED1 << BRT_MODE_SHFT) | 
 | 46 | #define LP8556_I2C_CONFIG	((ENABLE_BL << BL_CTL_SHFT) | \ | 
 | 47 | 				(LP8556_I2C_ONLY << BRT_MODE_SHFT)) | 
 | 48 | #define LP8556_COMB2_CONFIG	(LP8556_COMBINED2 << BRT_MODE_SHFT) | 
 | 49 |  | 
 | 50 | /* ROM area boundary */ | 
 | 51 | #define EEPROM_START	(0xA0) | 
 | 52 | #define EEPROM_END	(0xA7) | 
 | 53 | #define EPROM_START	(0xA0) | 
 | 54 | #define EPROM_END	(0xAF) | 
 | 55 |  | 
 | 56 | enum lp855x_chip_id { | 
 | 57 | 	LP8550, | 
 | 58 | 	LP8551, | 
 | 59 | 	LP8552, | 
 | 60 | 	LP8553, | 
 | 61 | 	LP8556, | 
 | 62 | }; | 
 | 63 |  | 
 | 64 | enum lp855x_brightness_ctrl_mode { | 
 | 65 | 	PWM_BASED = 1, | 
 | 66 | 	REGISTER_BASED, | 
 | 67 | }; | 
 | 68 |  | 
 | 69 | enum lp8550_brighntess_source { | 
 | 70 | 	LP8550_PWM_ONLY, | 
 | 71 | 	LP8550_I2C_ONLY = 2, | 
 | 72 | }; | 
 | 73 |  | 
 | 74 | enum lp8551_brighntess_source { | 
 | 75 | 	LP8551_PWM_ONLY = LP8550_PWM_ONLY, | 
 | 76 | 	LP8551_I2C_ONLY = LP8550_I2C_ONLY, | 
 | 77 | }; | 
 | 78 |  | 
 | 79 | enum lp8552_brighntess_source { | 
 | 80 | 	LP8552_PWM_ONLY = LP8550_PWM_ONLY, | 
 | 81 | 	LP8552_I2C_ONLY = LP8550_I2C_ONLY, | 
 | 82 | }; | 
 | 83 |  | 
 | 84 | enum lp8553_brighntess_source { | 
 | 85 | 	LP8553_PWM_ONLY = LP8550_PWM_ONLY, | 
 | 86 | 	LP8553_I2C_ONLY = LP8550_I2C_ONLY, | 
 | 87 | }; | 
 | 88 |  | 
 | 89 | enum lp8556_brightness_source { | 
 | 90 | 	LP8556_PWM_ONLY, | 
 | 91 | 	LP8556_COMBINED1,	/* pwm + i2c before the shaper block */ | 
 | 92 | 	LP8556_I2C_ONLY, | 
 | 93 | 	LP8556_COMBINED2,	/* pwm + i2c after the shaper block */ | 
 | 94 | }; | 
 | 95 |  | 
 | 96 | struct lp855x_pwm_data { | 
 | 97 | 	void (*pwm_set_intensity) (int brightness, int max_brightness); | 
 | 98 | 	int (*pwm_get_intensity) (int max_brightness); | 
 | 99 | }; | 
 | 100 |  | 
 | 101 | struct lp855x_rom_data { | 
 | 102 | 	u8 addr; | 
 | 103 | 	u8 val; | 
 | 104 | }; | 
 | 105 |  | 
 | 106 | /** | 
 | 107 |  * struct lp855x_platform_data | 
 | 108 |  * @name : Backlight driver name. If it is not defined, default name is set. | 
 | 109 |  * @mode : brightness control by pwm or lp855x register | 
 | 110 |  * @device_control : value of DEVICE CONTROL register | 
 | 111 |  * @initial_brightness : initial value of backlight brightness | 
 | 112 |  * @pwm_data : platform specific pwm generation functions. | 
 | 113 | 		Only valid when mode is PWM_BASED. | 
 | 114 |  * @load_new_rom_data : | 
 | 115 | 	0 : use default configuration data | 
 | 116 | 	1 : update values of eeprom or eprom registers on loading driver | 
 | 117 |  * @size_program : total size of lp855x_rom_data | 
 | 118 |  * @rom_data : list of new eeprom/eprom registers | 
 | 119 |  */ | 
 | 120 | struct lp855x_platform_data { | 
 | 121 | 	char *name; | 
 | 122 | 	enum lp855x_brightness_ctrl_mode mode; | 
 | 123 | 	u8 device_control; | 
 | 124 | 	int initial_brightness; | 
 | 125 | 	struct lp855x_pwm_data pwm_data; | 
 | 126 | 	u8 load_new_rom_data; | 
 | 127 | 	int size_program; | 
 | 128 | 	struct lp855x_rom_data *rom_data; | 
 | 129 | }; | 
 | 130 |  | 
 | 131 | #endif |