blob: eeae6e742471f0bbf796439ba21668e511bc4df5 [file] [log] [blame]
Shreshtha Kumar Sahub1e6b702011-03-22 16:30:16 -07001/*
2 * Copyright (C) 2011 ST-Ericsson SA.
3 * Copyright (C) 2009 Motorola, Inc.
4 *
5 * License Terms: GNU General Public License v2
6 *
7 * Simple driver for National Semiconductor LM35330 Backlight driver chip
8 *
9 * Author: Shreshtha Kumar SAHU <shreshthakumar.sahu@stericsson.com>
10 * based on leds-lm3530.c by Dan Murphy <D.Murphy@motorola.com>
11 */
12
13#ifndef _LINUX_LED_LM3530_H__
14#define _LINUX_LED_LM3530_H__
15
16#define LM3530_FS_CURR_5mA (0) /* Full Scale Current */
17#define LM3530_FS_CURR_8mA (1)
18#define LM3530_FS_CURR_12mA (2)
19#define LM3530_FS_CURR_15mA (3)
20#define LM3530_FS_CURR_19mA (4)
21#define LM3530_FS_CURR_22mA (5)
22#define LM3530_FS_CURR_26mA (6)
23#define LM3530_FS_CURR_29mA (7)
24
25#define LM3530_ALS_AVRG_TIME_32ms (0) /* ALS Averaging Time */
26#define LM3530_ALS_AVRG_TIME_64ms (1)
27#define LM3530_ALS_AVRG_TIME_128ms (2)
28#define LM3530_ALS_AVRG_TIME_256ms (3)
29#define LM3530_ALS_AVRG_TIME_512ms (4)
30#define LM3530_ALS_AVRG_TIME_1024ms (5)
31#define LM3530_ALS_AVRG_TIME_2048ms (6)
32#define LM3530_ALS_AVRG_TIME_4096ms (7)
33
34#define LM3530_RAMP_TIME_1ms (0) /* Brigtness Ramp Time */
35#define LM3530_RAMP_TIME_130ms (1) /* Max to 0 and vice versa */
36#define LM3530_RAMP_TIME_260ms (2)
37#define LM3530_RAMP_TIME_520ms (3)
38#define LM3530_RAMP_TIME_1s (4)
39#define LM3530_RAMP_TIME_2s (5)
40#define LM3530_RAMP_TIME_4s (6)
41#define LM3530_RAMP_TIME_8s (7)
42
43/* ALS Resistor Select */
Lucas De Marchi25985ed2011-03-30 22:57:33 -030044#define LM3530_ALS_IMPD_Z (0x00) /* ALS Impedance */
Shreshtha Kumar Sahub1e6b702011-03-22 16:30:16 -070045#define LM3530_ALS_IMPD_13_53kOhm (0x01)
46#define LM3530_ALS_IMPD_9_01kOhm (0x02)
47#define LM3530_ALS_IMPD_5_41kOhm (0x03)
48#define LM3530_ALS_IMPD_2_27kOhm (0x04)
49#define LM3530_ALS_IMPD_1_94kOhm (0x05)
50#define LM3530_ALS_IMPD_1_81kOhm (0x06)
51#define LM3530_ALS_IMPD_1_6kOhm (0x07)
52#define LM3530_ALS_IMPD_1_138kOhm (0x08)
53#define LM3530_ALS_IMPD_1_05kOhm (0x09)
54#define LM3530_ALS_IMPD_1_011kOhm (0x0A)
55#define LM3530_ALS_IMPD_941Ohm (0x0B)
56#define LM3530_ALS_IMPD_759Ohm (0x0C)
57#define LM3530_ALS_IMPD_719Ohm (0x0D)
58#define LM3530_ALS_IMPD_700Ohm (0x0E)
59#define LM3530_ALS_IMPD_667Ohm (0x0F)
60
61enum lm3530_mode {
62 LM3530_BL_MODE_MANUAL = 0, /* "man" */
63 LM3530_BL_MODE_ALS, /* "als" */
64 LM3530_BL_MODE_PWM, /* "pwm" */
65};
66
67/* ALS input select */
68enum lm3530_als_mode {
69 LM3530_INPUT_AVRG = 0, /* ALS1 and ALS2 input average */
70 LM3530_INPUT_ALS1, /* ALS1 Input */
71 LM3530_INPUT_ALS2, /* ALS2 Input */
72 LM3530_INPUT_CEIL, /* Max of ALS1 and ALS2 */
73};
74
Kim, Milobb982002012-03-23 15:02:12 -070075/* PWM Platform Specific Data */
76struct lm3530_pwm_data {
77 void (*pwm_set_intensity) (int brightness, int max_brightness);
78 int (*pwm_get_intensity) (int max_brightness);
79};
80
Shreshtha Kumar Sahub1e6b702011-03-22 16:30:16 -070081/**
82 * struct lm3530_platform_data
83 * @mode: mode of operation i.e. Manual, ALS or PWM
84 * @als_input_mode: select source of ALS input - ALS1/2 or average
85 * @max_current: full scale LED current
86 * @pwm_pol_hi: PWM input polarity - active high/active low
87 * @als_avrg_time: ALS input averaging time
88 * @brt_ramp_law: brightness mapping mode - exponential/linear
89 * @brt_ramp_fall: rate of fall of led current
90 * @brt_ramp_rise: rate of rise of led current
91 * @als1_resistor_sel: internal resistance from ALS1 input to ground
92 * @als2_resistor_sel: internal resistance from ALS2 input to ground
Shreshtha Kumar Sahu40b14452011-07-25 17:13:17 -070093 * @als_vmin: als input voltage calibrated for max brightness in mV
94 * @als_vmax: als input voltage calibrated for min brightness in mV
Shreshtha Kumar Sahub1e6b702011-03-22 16:30:16 -070095 * @brt_val: brightness value (0-255)
Kim, Milobb982002012-03-23 15:02:12 -070096 * @pwm_data: PWM control functions (only valid when the mode is PWM)
Shreshtha Kumar Sahub1e6b702011-03-22 16:30:16 -070097 */
98struct lm3530_platform_data {
99 enum lm3530_mode mode;
100 enum lm3530_als_mode als_input_mode;
101
102 u8 max_current;
103 bool pwm_pol_hi;
104 u8 als_avrg_time;
105
106 bool brt_ramp_law;
107 u8 brt_ramp_fall;
108 u8 brt_ramp_rise;
109
110 u8 als1_resistor_sel;
111 u8 als2_resistor_sel;
112
Shreshtha Kumar Sahu40b14452011-07-25 17:13:17 -0700113 u32 als_vmin;
114 u32 als_vmax;
115
Shreshtha Kumar Sahub1e6b702011-03-22 16:30:16 -0700116 u8 brt_val;
Kim, Milobb982002012-03-23 15:02:12 -0700117
118 struct lm3530_pwm_data pwm_data;
Shreshtha Kumar Sahub1e6b702011-03-22 16:30:16 -0700119};
120
121#endif /* _LINUX_LED_LM3530_H__ */